@graphql-hive/laboratory
Version:
49 lines (48 loc) • 2.32 kB
TypeScript
import { DragOverlay, DndContextProps, DragEndEvent, UniqueIdentifier } from '@dnd-kit/core';
import { SortableContextProps } from '@dnd-kit/sortable';
import { ReactPortal } from 'react';
interface GetItemValue<T> {
/**
* Callback that returns a unique identifier for each sortable item. Required for array of objects.
* @example getItemValue={(item) => item.id}
*/
getItemValue: (item: T) => UniqueIdentifier;
}
type SortableRootProps<T> = DndContextProps & (T extends object ? GetItemValue<T> : Partial<GetItemValue<T>>) & {
value: T[];
onValueChange?: (items: T[]) => void;
onMove?: (event: DragEndEvent & {
activeIndex: number;
overIndex: number;
}) => void;
strategy?: SortableContextProps["strategy"];
orientation?: "vertical" | "horizontal" | "mixed";
flatCursor?: boolean;
};
declare function SortableRoot<T>(props: SortableRootProps<T>): import("react/jsx-runtime").JSX.Element;
interface SortableContentProps extends React.ComponentProps<"div"> {
strategy?: SortableContextProps["strategy"];
children: React.ReactNode;
asChild?: boolean;
withoutSlot?: boolean;
}
declare function SortableContent(props: SortableContentProps): import("react/jsx-runtime").JSX.Element;
interface SortableItemProps extends React.ComponentProps<"div"> {
value: UniqueIdentifier;
asHandle?: boolean;
asChild?: boolean;
disabled?: boolean;
}
declare function SortableItem(props: SortableItemProps): import("react/jsx-runtime").JSX.Element;
interface SortableItemHandleProps extends React.ComponentProps<"button"> {
asChild?: boolean;
}
declare function SortableItemHandle(props: SortableItemHandleProps): import("react/jsx-runtime").JSX.Element;
interface SortableOverlayProps extends Omit<React.ComponentProps<typeof DragOverlay>, "children"> {
container?: Element | DocumentFragment | null;
children?: ((params: {
value: UniqueIdentifier;
}) => React.ReactNode) | React.ReactNode;
}
declare function SortableOverlay(props: SortableOverlayProps): ReactPortal | null;
export { SortableRoot as Sortable, SortableContent, SortableItem, SortableItemHandle, SortableOverlay, SortableRoot as Root, SortableContent as Content, SortableItem as Item, SortableItemHandle as ItemHandle, SortableOverlay as Overlay, };