mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
a39aa37231
React 19 dropped the no-arg useRef overload — the type-only useRef<T>() form (no initial value) is gone, every call must pass an initial value. The codebase had 15 occurrences of useRef<HTMLDivElement>() (DOM ref pattern) all flagged by tsgo as 'Expected 1 arguments, but got 0'. Mechanical sweep to useRef<HTMLDivElement>(null) — no behavior change, React still hands out a ref object with .current set to null at mount. Net tsgo error count: 57 -> 42.
34 lines
1.5 KiB
TypeScript
34 lines
1.5 KiB
TypeScript
import { FC, useMemo, useRef } from 'react';
|
|
import { Column, ColumnProps } from '..';
|
|
import { DraggableWindow, DraggableWindowPosition, DraggableWindowProps } from '../draggable-window';
|
|
import { NitroCardContextProvider } from './NitroCardContext';
|
|
|
|
export interface NitroCardViewProps extends DraggableWindowProps, ColumnProps
|
|
{
|
|
theme?: string;
|
|
isResizable?: boolean;
|
|
}
|
|
|
|
export const NitroCardView: FC<NitroCardViewProps> = props =>
|
|
{
|
|
const { theme = 'primary', uniqueKey = null, handleSelector = '.drag-handler', windowPosition = DraggableWindowPosition.CENTER, disableDrag = false, overflow = 'hidden', position = 'relative', gap = 0, classNames = [], isResizable = true, ...rest } = props;
|
|
const elementRef = useRef<HTMLDivElement>(null);
|
|
|
|
const getClassNames = useMemo(() =>
|
|
{
|
|
const newClassNames: string[] = [ isResizable ? 'resize' : 'resize-none', 'nitro-card-shell' ];
|
|
|
|
if(classNames.length) newClassNames.push(...classNames);
|
|
|
|
return newClassNames;
|
|
}, [ classNames, isResizable ]);
|
|
|
|
return (
|
|
<NitroCardContextProvider value={ { theme } }>
|
|
<DraggableWindow disableDrag={ disableDrag } handleSelector={ handleSelector } uniqueKey={ uniqueKey } windowPosition={ windowPosition }>
|
|
<Column classNames={ getClassNames } gap={ gap } innerRef={ elementRef } overflow={ overflow } position={ position } { ...rest } />
|
|
</DraggableWindow>
|
|
</NitroCardContextProvider>
|
|
);
|
|
};
|