@plasmicpkgs/dnd-kit 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dnd-kit.cjs.development.js","sources":["../src/util.ts","../src/sortable.tsx","../src/index.tsx"],"sourcesContent":["import {\n ComponentMeta,\n default as registerComponent,\n} from \"@plasmicapp/host/registerComponent\";\nimport { default as registerGlobalContext } from \"@plasmicapp/host/registerGlobalContext\";\nimport { default as registerToken } from \"@plasmicapp/host/registerToken\";\nimport React from \"react\";\n\nexport type Registerable = {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n registerToken: typeof registerToken;\n};\n\nexport function registerComponentHelper<T extends React.ComponentType<any>>(\n loader: Registerable | undefined,\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n if (loader) {\n loader.registerComponent(component, meta);\n } else {\n registerComponent(component, meta);\n }\n}\n","import React, { cloneElement, useEffect, useRef, useState } from \"react\";\nimport type { Key, ReactElement, ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { isElement } from \"react-dom/test-utils\";\nimport {\n closestCenter,\n DragOverlay,\n DndContext,\n KeyboardSensor,\n MouseSensor,\n TouchSensor,\n useSensor,\n useSensors,\n defaultDropAnimationSideEffects,\n} from \"@dnd-kit/core\";\nimport type {\n SortingStrategy,\n AnimateLayoutChanges,\n NewIndexGetter,\n} from \"@dnd-kit/sortable\";\nimport {\n arrayMove,\n useSortable,\n SortableContext,\n sortableKeyboardCoordinates,\n rectSortingStrategy,\n} from \"@dnd-kit/sortable\";\n\nimport { DataProvider, useSelector } from \"@plasmicapp/host\";\n\nimport type {\n DraggableSyntheticListeners,\n Active,\n Announcements,\n CollisionDetection,\n DropAnimation,\n KeyboardCoordinateGetter,\n Modifiers,\n MeasuringConfiguration,\n PointerActivationConstraint,\n ScreenReaderInstructions,\n UniqueIdentifier,\n} from \"@dnd-kit/core\";\nimport type { Transform } from \"@dnd-kit/utilities\";\nimport {\n restrictToFirstScrollableAncestor,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToVerticalAxis,\n restrictToWindowEdges,\n} from \"@dnd-kit/modifiers\";\nimport { Registerable, registerComponentHelper } from \"./util\";\n\nexport interface ItemProps {\n dragOverlay?: boolean;\n color?: string;\n disabled?: boolean;\n dragging?: boolean;\n height?: number;\n index?: number;\n fadeIn?: boolean;\n transform?: Transform | null;\n listeners?: DraggableSyntheticListeners;\n sorting?: boolean;\n style?: React.CSSProperties;\n transition?: string | null;\n wrapperStyle?: React.CSSProperties;\n value: React.ReactNode;\n renderItem?(\n args: {\n dragOverlay: boolean;\n dragging: boolean;\n sorting: boolean;\n index: number | undefined;\n fadeIn: boolean;\n listeners: DraggableSyntheticListeners;\n ref: React.Ref<HTMLElement>;\n style: React.CSSProperties | undefined;\n transform: ItemProps[\"transform\"];\n transition: ItemProps[\"transition\"];\n value: ItemProps[\"value\"];\n },\n currentItem: ItemProps[\"value\"]\n ): React.ReactElement;\n}\n\nexport const Item = React.memo(\n React.forwardRef<HTMLLIElement, ItemProps>(\n (\n {\n color,\n dragOverlay,\n dragging,\n disabled,\n fadeIn,\n height,\n index,\n listeners,\n renderItem = () => <div />,\n sorting,\n style,\n transition,\n transform,\n value,\n wrapperStyle,\n ...props\n },\n ref\n ) => {\n useEffect(() => {\n if (!dragOverlay) {\n return;\n }\n\n document.body.style.cursor = \"grabbing\";\n\n return () => {\n document.body.style.cursor = \"\";\n };\n }, [dragOverlay]);\n\n const child = renderItem(\n {\n dragOverlay: Boolean(dragOverlay),\n dragging: Boolean(dragging),\n sorting: Boolean(sorting),\n index,\n fadeIn: Boolean(fadeIn),\n listeners,\n ref,\n style,\n transform,\n transition,\n value,\n },\n value\n );\n\n return isElement(child)\n ? cloneElement(child, {\n ref,\n style: {\n transition: [transition].filter(Boolean).join(\", \"),\n transform: `translate3d(${transform?.x ?? 0}px, ${\n transform?.y ?? 0\n }px, 0) scaleX(${transform?.scaleX ?? 1}) scaleY(${\n transform?.scaleY ?? 1\n }`,\n },\n })\n : child;\n }\n )\n);\n\nexport interface SortableProps {\n onReorder?: (\n fromIndex: number,\n toIndex: number,\n newItems: any[],\n oldItems: any[]\n ) => void;\n themeResetClass?: string;\n activationConstraint?: PointerActivationConstraint;\n animateLayoutChanges?: AnimateLayoutChanges;\n adjustScale?: boolean;\n collisionDetection?: CollisionDetection;\n coordinateGetter?: KeyboardCoordinateGetter;\n Container?: any; // To-do: Fix me\n dropAnimation?: DropAnimation | null;\n getNewIndex?: NewIndexGetter;\n rowKey?: (item: any) => Key;\n itemCount?: number;\n items?: any[];\n measuring?: MeasuringConfiguration;\n modifiers?: Modifiers;\n renderItem?: any;\n removable?: boolean;\n reorderItems?: typeof arrayMove;\n strategy?: SortingStrategy;\n style?: React.CSSProperties;\n useDragOverlay?: boolean;\n modifierNames?: (\n | \"restrictToHorizontalAxis\"\n | \"restrictToVerticalAxis\"\n | \"restrictToWindowEdges\"\n | \"restrictToParentElement\"\n | \"restrictToFirstScrollableAncestor\"\n )[];\n getItemStyles?(args: {\n id: UniqueIdentifier;\n index: number;\n isSorting: boolean;\n isDragOverlay: boolean;\n overIndex: number;\n isDragging: boolean;\n }): React.CSSProperties;\n wrapperStyle?(args: {\n active: Pick<Active, \"id\"> | null;\n index: number;\n isDragging: boolean;\n id: UniqueIdentifier;\n }): React.CSSProperties;\n isDisabled?(id: UniqueIdentifier): boolean;\n className?: string;\n}\n\nconst dropAnimationConfig: DropAnimation = {\n sideEffects: defaultDropAnimationSideEffects({\n styles: {\n active: {\n opacity: \"0.5\",\n },\n },\n }),\n};\n\nconst screenReaderInstructions: ScreenReaderInstructions = {\n draggable: `\n To pick up a sortable item, press the space bar.\n While sorting, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n `,\n};\n\nexport const modifierByName = {\n restrictToVerticalAxis,\n restrictToWindowEdges,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToFirstScrollableAncestor,\n};\n\nexport function Sortable({\n className,\n style,\n activationConstraint,\n animateLayoutChanges,\n adjustScale = false,\n collisionDetection = closestCenter,\n coordinateGetter = sortableKeyboardCoordinates,\n dropAnimation = dropAnimationConfig,\n getNewIndex,\n rowKey = (item) => item.id,\n items: initialItems = [],\n measuring,\n modifiers,\n removable,\n renderItem,\n reorderItems = arrayMove,\n strategy = rectSortingStrategy,\n useDragOverlay = true,\n modifierNames,\n themeResetClass,\n onReorder,\n}: SortableProps) {\n modifiers =\n modifiers ?? (modifierNames ?? []).map((name) => modifierByName[name]);\n\n // This is the optimistic version.\n const [items, setItems] = useState<UniqueIdentifier[]>(() => initialItems);\n useEffect(() => {\n setItems(initialItems);\n }, [initialItems]);\n const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n const sensors = useSensors(\n useSensor(MouseSensor, {\n activationConstraint,\n }),\n useSensor(TouchSensor, {\n activationConstraint,\n }),\n useSensor(KeyboardSensor, {\n // Disable smooth scrolling in Cypress automated tests\n scrollBehavior: \"Cypress\" in globalThis ? \"auto\" : undefined,\n coordinateGetter,\n })\n );\n const isFirstAnnouncement = useRef(true);\n const getIndex = (id: UniqueIdentifier) =>\n items.findIndex((item) => rowKey(item) === id);\n const getPosition = (id: UniqueIdentifier) => getIndex(id) + 1;\n const activeIndex = activeId ? getIndex(activeId) : -1;\n const announcements: Announcements = {\n onDragStart({ active: { id } }) {\n return `Picked up sortable item ${String(\n id\n )}. Sortable item ${id} is in position ${getPosition(id)} of ${\n items.length\n }`;\n },\n onDragOver({ active, over }) {\n // In this specific use-case, the picked up item's `id` is always the same as the first `over` id.\n // The first `onDragOver` event therefore doesn't need to be announced, because it is called\n // immediately after the `onDragStart` announcement and is redundant.\n if (isFirstAnnouncement.current === true) {\n isFirstAnnouncement.current = false;\n return;\n }\n\n if (over) {\n return `Sortable item ${\n active.id\n } was moved into position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragEnd({ active, over }) {\n if (over) {\n return `Sortable item ${\n active.id\n } was dropped at position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragCancel({ active: { id } }) {\n return `Sorting was cancelled. Sortable item ${id} was dropped and returned to position ${getPosition(\n id\n )} of ${items.length}.`;\n },\n };\n useEffect(() => {\n if (!activeId) {\n isFirstAnnouncement.current = true;\n }\n }, [activeId]);\n\n return (\n <div className={className} style={style}>\n <DndContext\n accessibility={{\n announcements,\n screenReaderInstructions,\n }}\n sensors={sensors}\n collisionDetection={collisionDetection}\n onDragStart={({ active }) => {\n if (!active) {\n return;\n }\n\n setActiveId(active.id);\n }}\n onDragEnd={({ over }) => {\n setActiveId(null);\n\n if (over) {\n const overIndex = getIndex(over.id);\n const reordered = reorderItems(items, activeIndex, overIndex);\n onReorder?.(activeIndex, overIndex, reordered, items);\n if (activeIndex !== overIndex) {\n setItems((items) => reordered);\n }\n }\n }}\n onDragCancel={() => setActiveId(null)}\n measuring={measuring}\n modifiers={modifiers}\n >\n <SortableContext items={items.map(rowKey)} strategy={strategy}>\n {items.map((value, index) => (\n <SortableItem\n key={rowKey(value)}\n id={rowKey(value)}\n value={value}\n index={index}\n renderItem={renderItem}\n animateLayoutChanges={animateLayoutChanges}\n useDragOverlay={useDragOverlay}\n getNewIndex={getNewIndex}\n />\n ))}\n </SortableContext>\n {useDragOverlay && typeof document !== \"undefined\"\n ? createPortal(\n <DragOverlay\n adjustScale={adjustScale}\n dropAnimation={dropAnimation}\n >\n {activeId ? (\n <Item\n index={activeIndex}\n value={items[activeIndex]}\n renderItem={(...args) => (\n <div className={themeResetClass}>\n {renderItem(...args)}\n </div>\n )}\n dragOverlay\n />\n ) : null}\n </DragOverlay>,\n document.body\n )\n : null}\n </DndContext>\n </div>\n );\n}\n\ninterface SortableItemProps {\n animateLayoutChanges?: AnimateLayoutChanges;\n getNewIndex?: NewIndexGetter;\n id: UniqueIdentifier;\n index: number;\n useDragOverlay?: boolean;\n renderItem?(args: any): React.ReactElement;\n value?: any;\n}\n\nexport function SortableItem({\n animateLayoutChanges,\n getNewIndex,\n id,\n value,\n index,\n renderItem,\n useDragOverlay,\n}: SortableItemProps) {\n const sortableData = useSortable({\n id,\n animateLayoutChanges,\n getNewIndex,\n });\n const {\n attributes,\n isDragging,\n isSorting,\n listeners,\n setNodeRef,\n transform,\n transition,\n } = sortableData;\n\n return (\n <DataProvider hidden={true} name={\"sortableItem\"} data={sortableData}>\n <Item\n ref={setNodeRef}\n value={value}\n dragging={isDragging}\n sorting={isSorting}\n renderItem={renderItem}\n index={index}\n transform={transform}\n transition={transition}\n listeners={listeners}\n data-index={index}\n data-id={id}\n dragOverlay={!useDragOverlay && isDragging}\n {...attributes}\n />\n </DataProvider>\n );\n}\n\nexport function SortableHandle({ children }: { children?: ReactNode }) {\n const data = useSelector(\"sortableItem\");\n const child = React.Children.toArray(children)[0];\n return isElement(child)\n ? cloneElement(child as ReactElement, {\n ...data?.listeners,\n ref: data?.setActivatorNodeRef,\n tabIndex: 0,\n })\n : null;\n}\n\nexport function registerSortable(loader?: Registerable) {\n registerComponentHelper(loader, SortableHandle, {\n name: \"SortableHandle\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"text\",\n value: \"Handle\",\n },\n mergeWithParent: true,\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"SortableHandle\",\n });\n\n registerComponentHelper(loader, Sortable, {\n name: \"Sortable\",\n props: {\n items: {\n type: \"array\",\n defaultValue: [\n { id: 1, name: \"hello\" },\n { id: 2, name: \"world\" },\n ],\n },\n modifierNames: {\n displayName: \"Options\",\n type: \"choice\",\n multiSelect: true,\n options: Object.keys(modifierByName).map((v) => ({\n value: v,\n label:\n v[0].toUpperCase() + v.slice(1).replace(/([a-z])([A-Z])/g, \"$1 $2\"),\n })),\n },\n onReorder: {\n type: \"eventHandler\",\n argTypes: [\n {\n name: \"fromIndex\",\n type: \"number\",\n },\n {\n name: \"toIndex\",\n type: \"number\",\n },\n {\n name: \"newItems\",\n type: \"object\",\n },\n {\n name: \"oldItems\",\n type: \"object\",\n },\n ],\n },\n themeResetClass: {\n type: \"themeResetClass\",\n },\n renderItem: {\n type: \"slot\",\n renderPropParams: [\"sortableData\", \"currentItem\"],\n mergeWithParent: true,\n defaultValue: {\n type: \"hbox\",\n children: [\n {\n type: \"text\",\n value: \"Item\",\n },\n {\n type: \"component\",\n name: \"SortableHandle\",\n },\n ],\n },\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"Sortable\",\n });\n}\n","import { registerSortable } from \"./sortable\";\nimport { Registerable } from \"./util\";\n\nexport function registerAll(loader?: Registerable) {\n registerSortable(loader);\n}\n\nexport * from \"./sortable\";\n"],"names":["registerComponentHelper","loader","component","meta","registerComponent","Item","React","memo","forwardRef","_ref","ref","dragOverlay","dragging","disabled","fadeIn","height","index","listeners","_ref$renderItem","renderItem","sorting","style","transition","transform","value","wrapperStyle","props","_objectWithoutPropertiesLoose","_excluded","useEffect","document","body","cursor","child","Boolean","isElement","cloneElement","filter","join","_transform$x","x","_transform$y","y","_transform$scaleX","scaleX","_transform$scaleY","scaleY","dropAnimationConfig","sideEffects","defaultDropAnimationSideEffects","styles","active","opacity","screenReaderInstructions","draggable","modifierByName","restrictToVerticalAxis","restrictToWindowEdges","restrictToHorizontalAxis","restrictToParentElement","restrictToFirstScrollableAncestor","Sortable","_ref2","className","activationConstraint","animateLayoutChanges","_ref2$adjustScale","adjustScale","_ref2$collisionDetect","collisionDetection","closestCenter","_ref2$coordinateGette","coordinateGetter","sortableKeyboardCoordinates","_ref2$dropAnimation","dropAnimation","getNewIndex","_ref2$rowKey","rowKey","item","id","_ref2$items","items","initialItems","measuring","modifiers","removable","_ref2$reorderItems","reorderItems","arrayMove","_ref2$strategy","strategy","rectSortingStrategy","_ref2$useDragOverlay","useDragOverlay","modifierNames","themeResetClass","onReorder","_modifiers","map","name","_useState","useState","setItems","_useState2","activeId","setActiveId","sensors","useSensors","useSensor","MouseSensor","TouchSensor","KeyboardSensor","scrollBehavior","globalThis","undefined","isFirstAnnouncement","useRef","getIndex","findIndex","getPosition","activeIndex","announcements","onDragStart","_ref3","String","length","onDragOver","_ref4","over","current","onDragEnd","_ref5","onDragCancel","_ref6","DndContext","accessibility","_ref7","_ref8","overIndex","reordered","SortableContext","SortableItem","key","createPortal","DragOverlay","apply","arguments","_ref9","sortableData","useSortable","attributes","isDragging","isSorting","setNodeRef","DataProvider","hidden","data","SortableHandle","_ref10","children","useSelector","Children","toArray","_extends","setActivatorNodeRef","tabIndex","registerSortable","type","defaultValue","mergeWithParent","importPath","importName","displayName","multiSelect","options","Object","keys","v","label","toUpperCase","slice","replace","argTypes","renderPropParams","registerAll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAcgBA,uBAAuBA,CACrCC,MAAgC,EAChCC,SAAY,EACZC,IAA4C;EAE5C,IAAIF,MAAM,EAAE;IACVA,MAAM,CAACG,iBAAiB,CAACF,SAAS,EAAEC,IAAI,CAAC;GAC1C,MAAM;IACLC,iBAAiB,CAACF,SAAS,EAAEC,IAAI,CAAC;;AAEtC;;;ACxBA,IAsFaE,IAAI,gBAAGC,cAAK,CAACC,IAAI,cAC5BD,cAAK,CAACE,UAAU,CACd,UAAAC,IAAA,EAmBEC,GAAG;;MAhBDC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IACXC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,AACAC,MAAM,GAAAL,IAAA,CAANK,MAAM;IACNC,AACAC,KAAK,GAAAP,IAAA,CAALO,KAAK;IACLC,SAAS,GAAAR,IAAA,CAATQ,SAAS;IAAAC,eAAA,GAAAT,IAAA,CACTU,UAAU;IAAVA,UAAU,GAAAD,eAAA,cAAG;MAAA,OAAMZ,yCAAO;QAAAY,eAAA;IAC1BE,OAAO,GAAAX,IAAA,CAAPW,OAAO;IACPC,KAAK,GAAAZ,IAAA,CAALY,KAAK;IACLC,UAAU,GAAAb,I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AAE,SAAS;QACtBL,IAAI,EAAE,QAAQ;QACdM,WAAW,EAAE,IAAI;QACjBC,OAAO,EAAEC,MAAM,CAACC,IAAI,CAAC1H,cAAc,CAAC,CAAC4C,GAAG,CAAC,UAAC+E,CAAC;UAAA,OAAM;YAC/C1J,KAAK,EAAE0J,CAAC;YACRC,KAAK,EACHD,CAAC,CAAC,CAAC,CAAC,CAACE,WAAW,EAAE,GAAGF,CAAC,CAACG,KAAK,CAAC,CAAC,CAAC,CAACC,OAAO,CAAC,iBAAiB,EAAE,OAAO;WACrE;SAAC;OACH;MACDrF,SAAS,EAAE;QACTuE,IAAI,EAAE,cAAc;QACpBe,QAAQ,EAAE,CACR;UACEnF,IAAI,EAAE,WAAW;UACjBoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,SAAS;UACfoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,UAAU;UAChBoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,UAAU;UAChBoE,IAAI,EAAE;SACP;OAEJ;MACDxE,eAAe,EAAE;QACfwE,IAAI,EAAE;OACP;MACDrJ,UAAU,EAAE;QACVqJ,IAAI,EAAE,MAAM;QACZgB,gBAAgB,EAAE,CAAC,cAAc,EAAE,aAAa,CAAC;QACjDd,eAAe,EAAE,IAAI;QACrBD,YAAY,EAAE;UACZD,IAAI,EAAE,MAAM;UACZR,QAAQ,EAAE,CACR;YACEQ,IAAI,EAAE,MAAM;YACZhJ,KAAK,EAAE;WACR,EACD;YACEgJ,IAAI,EAAE,WAAW;YACjBpE,IAAI,EAAE;WACP;;;KAIR;IACDuE,UAAU,EAAE,sBAAsB;IAClCC,UAAU,EAAE;GACb,CAAC;AACJ;;SCriBgBa,WAAWA,CAACxL,MAAqB;EAC/CsK,gBAAgB,CAACtK,MAAM,CAAC;AAC1B;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"dnd-kit.cjs.development.js","sources":["../src/util.ts","../src/sortable.tsx","../src/index.tsx"],"sourcesContent":["import {\n CodeComponentMeta,\n default as registerComponent,\n} from \"@plasmicapp/host/registerComponent\";\nimport { default as registerGlobalContext } from \"@plasmicapp/host/registerGlobalContext\";\nimport { default as registerToken } from \"@plasmicapp/host/registerToken\";\nimport React from \"react\";\n\nexport type Registerable = {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n registerToken: typeof registerToken;\n};\n\nexport function registerComponentHelper<T extends React.ComponentType<any>>(\n loader: Registerable | undefined,\n component: T,\n meta: CodeComponentMeta<React.ComponentProps<T>>\n) {\n if (loader) {\n loader.registerComponent(component, meta);\n } else {\n registerComponent(component, meta);\n }\n}\n","import React, { cloneElement, useEffect, useRef, useState } from \"react\";\nimport type { Key, ReactElement, ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { isElement } from \"react-dom/test-utils\";\nimport {\n closestCenter,\n DragOverlay,\n DndContext,\n KeyboardSensor,\n MouseSensor,\n TouchSensor,\n useSensor,\n useSensors,\n defaultDropAnimationSideEffects,\n} from \"@dnd-kit/core\";\nimport type {\n SortingStrategy,\n AnimateLayoutChanges,\n NewIndexGetter,\n} from \"@dnd-kit/sortable\";\nimport {\n arrayMove,\n useSortable,\n SortableContext,\n sortableKeyboardCoordinates,\n rectSortingStrategy,\n} from \"@dnd-kit/sortable\";\n\nimport { DataProvider, useSelector } from \"@plasmicapp/host\";\n\nimport type {\n DraggableSyntheticListeners,\n Active,\n Announcements,\n CollisionDetection,\n DropAnimation,\n KeyboardCoordinateGetter,\n Modifiers,\n MeasuringConfiguration,\n PointerActivationConstraint,\n ScreenReaderInstructions,\n UniqueIdentifier,\n} from \"@dnd-kit/core\";\nimport type { Transform } from \"@dnd-kit/utilities\";\nimport {\n restrictToFirstScrollableAncestor,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToVerticalAxis,\n restrictToWindowEdges,\n} from \"@dnd-kit/modifiers\";\nimport { Registerable, registerComponentHelper } from \"./util\";\n\nexport interface ItemProps {\n dragOverlay?: boolean;\n color?: string;\n disabled?: boolean;\n dragging?: boolean;\n height?: number;\n index?: number;\n fadeIn?: boolean;\n transform?: Transform | null;\n listeners?: DraggableSyntheticListeners;\n sorting?: boolean;\n style?: React.CSSProperties;\n transition?: string | null;\n wrapperStyle?: React.CSSProperties;\n value: React.ReactNode;\n renderItem?(\n args: {\n dragOverlay: boolean;\n dragging: boolean;\n sorting: boolean;\n index: number | undefined;\n fadeIn: boolean;\n listeners: DraggableSyntheticListeners;\n ref: React.Ref<HTMLElement>;\n style: React.CSSProperties | undefined;\n transform: ItemProps[\"transform\"];\n transition: ItemProps[\"transition\"];\n value: ItemProps[\"value\"];\n },\n currentItem: ItemProps[\"value\"]\n ): React.ReactElement;\n}\n\nexport const Item = React.memo(\n React.forwardRef<HTMLLIElement, ItemProps>(\n (\n {\n color,\n dragOverlay,\n dragging,\n disabled,\n fadeIn,\n height,\n index,\n listeners,\n renderItem = () => <div />,\n sorting,\n style,\n transition,\n transform,\n value,\n wrapperStyle,\n ...props\n },\n ref\n ) => {\n useEffect(() => {\n if (!dragOverlay) {\n return;\n }\n\n document.body.style.cursor = \"grabbing\";\n\n return () => {\n document.body.style.cursor = \"\";\n };\n }, [dragOverlay]);\n\n const child = renderItem(\n {\n dragOverlay: Boolean(dragOverlay),\n dragging: Boolean(dragging),\n sorting: Boolean(sorting),\n index,\n fadeIn: Boolean(fadeIn),\n listeners,\n ref,\n style,\n transform,\n transition,\n value,\n },\n value\n );\n\n return isElement(child)\n ? cloneElement(child, {\n ref,\n style: {\n transition: [transition].filter(Boolean).join(\", \"),\n transform: `translate3d(${transform?.x ?? 0}px, ${\n transform?.y ?? 0\n }px, 0) scaleX(${transform?.scaleX ?? 1}) scaleY(${\n transform?.scaleY ?? 1\n }`,\n },\n })\n : child;\n }\n )\n);\n\nexport interface SortableProps {\n onReorder?: (\n fromIndex: number,\n toIndex: number,\n newItems: any[],\n oldItems: any[]\n ) => void;\n themeResetClass?: string;\n activationConstraint?: PointerActivationConstraint;\n animateLayoutChanges?: AnimateLayoutChanges;\n adjustScale?: boolean;\n collisionDetection?: CollisionDetection;\n coordinateGetter?: KeyboardCoordinateGetter;\n Container?: any; // To-do: Fix me\n dropAnimation?: DropAnimation | null;\n getNewIndex?: NewIndexGetter;\n rowKey?: (item: any) => Key;\n itemCount?: number;\n items?: any[];\n measuring?: MeasuringConfiguration;\n modifiers?: Modifiers;\n renderItem?: any;\n removable?: boolean;\n reorderItems?: typeof arrayMove;\n strategy?: SortingStrategy;\n style?: React.CSSProperties;\n useDragOverlay?: boolean;\n modifierNames?: (\n | \"restrictToHorizontalAxis\"\n | \"restrictToVerticalAxis\"\n | \"restrictToWindowEdges\"\n | \"restrictToParentElement\"\n | \"restrictToFirstScrollableAncestor\"\n )[];\n getItemStyles?(args: {\n id: UniqueIdentifier;\n index: number;\n isSorting: boolean;\n isDragOverlay: boolean;\n overIndex: number;\n isDragging: boolean;\n }): React.CSSProperties;\n wrapperStyle?(args: {\n active: Pick<Active, \"id\"> | null;\n index: number;\n isDragging: boolean;\n id: UniqueIdentifier;\n }): React.CSSProperties;\n isDisabled?(id: UniqueIdentifier): boolean;\n className?: string;\n}\n\nconst dropAnimationConfig: DropAnimation = {\n sideEffects: defaultDropAnimationSideEffects({\n styles: {\n active: {\n opacity: \"0.5\",\n },\n },\n }),\n};\n\nconst screenReaderInstructions: ScreenReaderInstructions = {\n draggable: `\n To pick up a sortable item, press the space bar.\n While sorting, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n `,\n};\n\nexport const modifierByName = {\n restrictToVerticalAxis,\n restrictToWindowEdges,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToFirstScrollableAncestor,\n};\n\nexport function Sortable({\n className,\n style,\n activationConstraint,\n animateLayoutChanges,\n adjustScale = false,\n collisionDetection = closestCenter,\n coordinateGetter = sortableKeyboardCoordinates,\n dropAnimation = dropAnimationConfig,\n getNewIndex,\n rowKey = (item) => item.id,\n items: initialItems = [],\n measuring,\n modifiers,\n removable,\n renderItem,\n reorderItems = arrayMove,\n strategy = rectSortingStrategy,\n useDragOverlay = true,\n modifierNames,\n themeResetClass,\n onReorder,\n}: SortableProps) {\n modifiers =\n modifiers ?? (modifierNames ?? []).map((name) => modifierByName[name]);\n\n // This is the optimistic version.\n const [items, setItems] = useState<UniqueIdentifier[]>(() => initialItems);\n useEffect(() => {\n setItems(initialItems);\n }, [initialItems]);\n const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n const sensors = useSensors(\n useSensor(MouseSensor, {\n activationConstraint,\n }),\n useSensor(TouchSensor, {\n activationConstraint,\n }),\n useSensor(KeyboardSensor, {\n // Disable smooth scrolling in Cypress automated tests\n scrollBehavior: \"Cypress\" in globalThis ? \"auto\" : undefined,\n coordinateGetter,\n })\n );\n const isFirstAnnouncement = useRef(true);\n const getIndex = (id: UniqueIdentifier) =>\n items.findIndex((item) => rowKey(item) === id);\n const getPosition = (id: UniqueIdentifier) => getIndex(id) + 1;\n const activeIndex = activeId ? getIndex(activeId) : -1;\n const announcements: Announcements = {\n onDragStart({ active: { id } }) {\n return `Picked up sortable item ${String(\n id\n )}. Sortable item ${id} is in position ${getPosition(id)} of ${\n items.length\n }`;\n },\n onDragOver({ active, over }) {\n // In this specific use-case, the picked up item's `id` is always the same as the first `over` id.\n // The first `onDragOver` event therefore doesn't need to be announced, because it is called\n // immediately after the `onDragStart` announcement and is redundant.\n if (isFirstAnnouncement.current === true) {\n isFirstAnnouncement.current = false;\n return;\n }\n\n if (over) {\n return `Sortable item ${\n active.id\n } was moved into position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragEnd({ active, over }) {\n if (over) {\n return `Sortable item ${\n active.id\n } was dropped at position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragCancel({ active: { id } }) {\n return `Sorting was cancelled. Sortable item ${id} was dropped and returned to position ${getPosition(\n id\n )} of ${items.length}.`;\n },\n };\n useEffect(() => {\n if (!activeId) {\n isFirstAnnouncement.current = true;\n }\n }, [activeId]);\n\n return (\n <div className={className} style={style}>\n <DndContext\n accessibility={{\n announcements,\n screenReaderInstructions,\n }}\n sensors={sensors}\n collisionDetection={collisionDetection}\n onDragStart={({ active }) => {\n if (!active) {\n return;\n }\n\n setActiveId(active.id);\n }}\n onDragEnd={({ over }) => {\n setActiveId(null);\n\n if (over) {\n const overIndex = getIndex(over.id);\n const reordered = reorderItems(items, activeIndex, overIndex);\n onReorder?.(activeIndex, overIndex, reordered, items);\n if (activeIndex !== overIndex) {\n setItems((items) => reordered);\n }\n }\n }}\n onDragCancel={() => setActiveId(null)}\n measuring={measuring}\n modifiers={modifiers}\n >\n <SortableContext items={items.map(rowKey)} strategy={strategy}>\n {items.map((value, index) => (\n <SortableItem\n key={rowKey(value)}\n id={rowKey(value)}\n value={value}\n index={index}\n renderItem={renderItem}\n animateLayoutChanges={animateLayoutChanges}\n useDragOverlay={useDragOverlay}\n getNewIndex={getNewIndex}\n />\n ))}\n </SortableContext>\n {useDragOverlay && typeof document !== \"undefined\"\n ? createPortal(\n <DragOverlay\n adjustScale={adjustScale}\n dropAnimation={dropAnimation}\n >\n {activeId ? (\n <Item\n index={activeIndex}\n value={items[activeIndex]}\n renderItem={(...args) => (\n <div className={themeResetClass}>\n {renderItem(...args)}\n </div>\n )}\n dragOverlay\n />\n ) : null}\n </DragOverlay>,\n document.body\n )\n : null}\n </DndContext>\n </div>\n );\n}\n\ninterface SortableItemProps {\n animateLayoutChanges?: AnimateLayoutChanges;\n getNewIndex?: NewIndexGetter;\n id: UniqueIdentifier;\n index: number;\n useDragOverlay?: boolean;\n renderItem?(args: any): React.ReactElement;\n value?: any;\n}\n\nexport function SortableItem({\n animateLayoutChanges,\n getNewIndex,\n id,\n value,\n index,\n renderItem,\n useDragOverlay,\n}: SortableItemProps) {\n const sortableData = useSortable({\n id,\n animateLayoutChanges,\n getNewIndex,\n });\n const {\n attributes,\n isDragging,\n isSorting,\n listeners,\n setNodeRef,\n transform,\n transition,\n } = sortableData;\n\n return (\n <DataProvider hidden={true} name={\"sortableItem\"} data={sortableData}>\n <Item\n ref={setNodeRef}\n value={value}\n dragging={isDragging}\n sorting={isSorting}\n renderItem={renderItem}\n index={index}\n transform={transform}\n transition={transition}\n listeners={listeners}\n data-index={index}\n data-id={id}\n dragOverlay={!useDragOverlay && isDragging}\n {...attributes}\n />\n </DataProvider>\n );\n}\n\nexport function SortableHandle({ children }: { children?: ReactNode }) {\n const data = useSelector(\"sortableItem\");\n const child = React.Children.toArray(children)[0];\n return isElement(child)\n ? cloneElement(child as ReactElement, {\n ...data?.listeners,\n ref: data?.setActivatorNodeRef,\n tabIndex: 0,\n })\n : null;\n}\n\nexport function registerSortable(loader?: Registerable) {\n registerComponentHelper(loader, SortableHandle, {\n name: \"SortableHandle\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"text\",\n value: \"Handle\",\n },\n mergeWithParent: true,\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"SortableHandle\",\n });\n\n registerComponentHelper(loader, Sortable, {\n name: \"Sortable\",\n props: {\n items: {\n type: \"array\",\n defaultValue: [\n { id: 1, name: \"hello\" },\n { id: 2, name: \"world\" },\n ],\n },\n modifierNames: {\n displayName: \"Options\",\n type: \"choice\",\n multiSelect: true,\n options: Object.keys(modifierByName).map((v) => ({\n value: v,\n label:\n v[0].toUpperCase() + v.slice(1).replace(/([a-z])([A-Z])/g, \"$1 $2\"),\n })),\n },\n onReorder: {\n type: \"eventHandler\",\n argTypes: [\n {\n name: \"fromIndex\",\n type: \"number\",\n },\n {\n name: \"toIndex\",\n type: \"number\",\n },\n {\n name: \"newItems\",\n type: \"object\",\n },\n {\n name: \"oldItems\",\n type: \"object\",\n },\n ],\n },\n themeResetClass: {\n type: \"themeResetClass\",\n },\n renderItem: {\n type: \"slot\",\n renderPropParams: [\"sortableData\", \"currentItem\"],\n mergeWithParent: true,\n defaultValue: {\n type: \"hbox\",\n children: [\n {\n type: \"text\",\n value: \"Item\",\n },\n {\n type: \"component\",\n name: \"SortableHandle\",\n },\n ],\n },\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"Sortable\",\n });\n}\n","import { registerSortable } from \"./sortable\";\nimport { Registerable } from \"./util\";\n\nexport function registerAll(loader?: Registerable) {\n registerSortable(loader);\n}\n\nexport * from \"./sortable\";\n"],"names":["registerComponentHelper","loader","component","meta","registerComponent","Item","React","memo","forwardRef","_ref","ref","dragOverlay","dragging","disabled","fadeIn","height","index","listeners","_ref$renderItem","renderItem","sorting","style","transition","transform","value","wrapperStyle","props","_objectWithoutPropertiesLoose","_excluded","useEffect","document","body","cursor","child","Boolean","isElement","cloneElement","filter","join","_transform$x","x","_transform$y","y","_transform$scaleX","scaleX","_transform$scaleY","scaleY","dropAnimationConfig","sideEffects","defaultDropAnimationSideEffects","styles","active","opacity","screenReaderInstructions","draggable","modifierByName","restrictToVerticalAxis","restrictToWindowEdges","restrictToHorizontalAxis","restrictToParentElement","restrictToFirstScrollableAncestor","Sortable","_ref2","className","activationConstraint","animateLayoutChanges","_ref2$adjustScale","adjustScale","_ref2$collisionDetect","collisionDetection","closestCenter","_ref2$coordinateGette","coordinateGetter","sortableKeyboardCoordinates","_ref2$dropAnimation","dropAnimation","getNewIndex","_ref2$rowKey","rowKey","item","id","_ref2$items","items","initialItems","measuring","modifiers","removable","_ref2$reorderItems","reorderItems","arrayMove","_ref2$strategy","strategy","rectSortingStrategy","_ref2$useDragOverlay","useDragOverlay","modifierNames","themeResetClass","onReorder","_modifiers","map","name","_useState","useState","setItems","_useState2","activeId","setActiveId","sensors","useSensors","useSensor","MouseSensor","TouchSensor","KeyboardSensor","scrollBehavior","globalThis","undefined","isFirstAnnouncement","useRef","getIndex","findIndex","getPosition","activeIndex","announcements","onDragStart","_ref3","String","length","onDragOver","_ref4","over","current","onDragEnd","_ref5","onDragCancel","_ref6","DndContext","accessibility","_ref7","_ref8","overIndex","reordered","SortableContext","SortableItem","key","createPortal","DragOverlay","apply","arguments","_ref9","sortableData","useSortable","attributes","isDragging","isSorting","setNodeRef","DataProvider","hidden","data","SortableHandle","_ref10","children","useSelector","Children","toArray","_extends","setActivatorNodeRef","tabIndex","registerSortable","type","defaultValue","mergeWithParent","importPath","importName","displayName","multiSelect","options","Object","keys","v","label","toUpperCase","slice","replace","argTypes","renderPropParams","registerAll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAcgBA,uBAAuBA,CACrCC,MAAgC,EAChCC,SAAY,EACZC,IAAgD;EAEhD,IAAIF,MAAM,EAAE;IACVA,MAAM,CAACG,iBAAiB,CAACF,SAAS,EAAEC,IAAI,CAAC;GAC1C,MAAM;IACLC,iBAAiB,CAACF,SAAS,EAAEC,IAAI,CAAC;;AAEtC;;;ACxBA,IAsFaE,IAAI,gBAAGC,cAAK,CAACC,IAAI,cAC5BD,cAAK,CAACE,UAAU,CACd,UAAAC,IAAA,EAmBEC,GAAG;;MAhBDC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IACXC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,AACAC,MAAM,GAAAL,IAAA,CAANK,MAAM;IACNC,AACAC,KAAK,GAAAP,IAAA,CAALO,KAAK;IACLC,SAAS,GAAAR,IAAA,CAATQ,SAAS;IAAAC,eAAA,GAAAT,IAAA,CACTU,UAAU;IAAVA,UAAU,GAAAD,eAAA,cAAG;MAAA,OAAMZ,yCAAO;QAAAY,eAAA;IAC1BE,OAAO,GAAAX,IAAA,CAAPW,OAAO;IACPC,KAAK,GAAAZ,IAAA,CAALY,KAAK;IACLC,UAAU,GAAAb,IAAA,CAAVa,UAAU;IACVC,SAAS,GAAAd,IAAA,CAATc,SAAS;IACTC,KAAK,GAAAf,IAAA,CAALe,KAAK;IACLC,AACGC,KAAK,GAAAC,6BAAA,CAAAlB,IAAA,EAAAmB,SAAA;EAIVC,eAAS,CAAC;IACR,IAAI,CAAClB,WAAW,EAAE;MAChB;;IA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D,CAAC,CAAC,CAAC,CAAC,CAACE,WAAW,EAAE,GAAGF,CAAC,CAACG,KAAK,CAAC,CAAC,CAAC,CAACC,OAAO,CAAC,iBAAiB,EAAE,OAAO;WACrE;SAAC;OACH;MACDrF,SAAS,EAAE;QACTuE,IAAI,EAAE,cAAc;QACpBe,QAAQ,EAAE,CACR;UACEnF,IAAI,EAAE,WAAW;UACjBoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,SAAS;UACfoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,UAAU;UAChBoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,UAAU;UAChBoE,IAAI,EAAE;SACP;OAEJ;MACDxE,eAAe,EAAE;QACfwE,IAAI,EAAE;OACP;MACDrJ,UAAU,EAAE;QACVqJ,IAAI,EAAE,MAAM;QACZgB,gBAAgB,EAAE,CAAC,cAAc,EAAE,aAAa,CAAC;QACjDd,eAAe,EAAE,IAAI;QACrBD,YAAY,EAAE;UACZD,IAAI,EAAE,MAAM;UACZR,QAAQ,EAAE,CACR;YACEQ,IAAI,EAAE,MAAM;YACZhJ,KAAK,EAAE;WACR,EACD;YACEgJ,IAAI,EAAE,WAAW;YACjBpE,IAAI,EAAE;WACP;;;KAIR;IACDuE,UAAU,EAAE,sBAAsB;IAClCC,UAAU,EAAE;GACb,CAAC;AACJ;;SCriBgBa,WAAWA,CAACxL,MAAqB;EAC/CsK,gBAAgB,CAACtK,MAAM,CAAC;AAC1B;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dnd-kit.cjs.production.min.js","sources":["../src/util.ts","../src/sortable.tsx","../src/index.tsx"],"sourcesContent":["import {\n ComponentMeta,\n default as registerComponent,\n} from \"@plasmicapp/host/registerComponent\";\nimport { default as registerGlobalContext } from \"@plasmicapp/host/registerGlobalContext\";\nimport { default as registerToken } from \"@plasmicapp/host/registerToken\";\nimport React from \"react\";\n\nexport type Registerable = {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n registerToken: typeof registerToken;\n};\n\nexport function registerComponentHelper<T extends React.ComponentType<any>>(\n loader: Registerable | undefined,\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n if (loader) {\n loader.registerComponent(component, meta);\n } else {\n registerComponent(component, meta);\n }\n}\n","import React, { cloneElement, useEffect, useRef, useState } from \"react\";\nimport type { Key, ReactElement, ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { isElement } from \"react-dom/test-utils\";\nimport {\n closestCenter,\n DragOverlay,\n DndContext,\n KeyboardSensor,\n MouseSensor,\n TouchSensor,\n useSensor,\n useSensors,\n defaultDropAnimationSideEffects,\n} from \"@dnd-kit/core\";\nimport type {\n SortingStrategy,\n AnimateLayoutChanges,\n NewIndexGetter,\n} from \"@dnd-kit/sortable\";\nimport {\n arrayMove,\n useSortable,\n SortableContext,\n sortableKeyboardCoordinates,\n rectSortingStrategy,\n} from \"@dnd-kit/sortable\";\n\nimport { DataProvider, useSelector } from \"@plasmicapp/host\";\n\nimport type {\n DraggableSyntheticListeners,\n Active,\n Announcements,\n CollisionDetection,\n DropAnimation,\n KeyboardCoordinateGetter,\n Modifiers,\n MeasuringConfiguration,\n PointerActivationConstraint,\n ScreenReaderInstructions,\n UniqueIdentifier,\n} from \"@dnd-kit/core\";\nimport type { Transform } from \"@dnd-kit/utilities\";\nimport {\n restrictToFirstScrollableAncestor,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToVerticalAxis,\n restrictToWindowEdges,\n} from \"@dnd-kit/modifiers\";\nimport { Registerable, registerComponentHelper } from \"./util\";\n\nexport interface ItemProps {\n dragOverlay?: boolean;\n color?: string;\n disabled?: boolean;\n dragging?: boolean;\n height?: number;\n index?: number;\n fadeIn?: boolean;\n transform?: Transform | null;\n listeners?: DraggableSyntheticListeners;\n sorting?: boolean;\n style?: React.CSSProperties;\n transition?: string | null;\n wrapperStyle?: React.CSSProperties;\n value: React.ReactNode;\n renderItem?(\n args: {\n dragOverlay: boolean;\n dragging: boolean;\n sorting: boolean;\n index: number | undefined;\n fadeIn: boolean;\n listeners: DraggableSyntheticListeners;\n ref: React.Ref<HTMLElement>;\n style: React.CSSProperties | undefined;\n transform: ItemProps[\"transform\"];\n transition: ItemProps[\"transition\"];\n value: ItemProps[\"value\"];\n },\n currentItem: ItemProps[\"value\"]\n ): React.ReactElement;\n}\n\nexport const Item = React.memo(\n React.forwardRef<HTMLLIElement, ItemProps>(\n (\n {\n color,\n dragOverlay,\n dragging,\n disabled,\n fadeIn,\n height,\n index,\n listeners,\n renderItem = () => <div />,\n sorting,\n style,\n transition,\n transform,\n value,\n wrapperStyle,\n ...props\n },\n ref\n ) => {\n useEffect(() => {\n if (!dragOverlay) {\n return;\n }\n\n document.body.style.cursor = \"grabbing\";\n\n return () => {\n document.body.style.cursor = \"\";\n };\n }, [dragOverlay]);\n\n const child = renderItem(\n {\n dragOverlay: Boolean(dragOverlay),\n dragging: Boolean(dragging),\n sorting: Boolean(sorting),\n index,\n fadeIn: Boolean(fadeIn),\n listeners,\n ref,\n style,\n transform,\n transition,\n value,\n },\n value\n );\n\n return isElement(child)\n ? cloneElement(child, {\n ref,\n style: {\n transition: [transition].filter(Boolean).join(\", \"),\n transform: `translate3d(${transform?.x ?? 0}px, ${\n transform?.y ?? 0\n }px, 0) scaleX(${transform?.scaleX ?? 1}) scaleY(${\n transform?.scaleY ?? 1\n }`,\n },\n })\n : child;\n }\n )\n);\n\nexport interface SortableProps {\n onReorder?: (\n fromIndex: number,\n toIndex: number,\n newItems: any[],\n oldItems: any[]\n ) => void;\n themeResetClass?: string;\n activationConstraint?: PointerActivationConstraint;\n animateLayoutChanges?: AnimateLayoutChanges;\n adjustScale?: boolean;\n collisionDetection?: CollisionDetection;\n coordinateGetter?: KeyboardCoordinateGetter;\n Container?: any; // To-do: Fix me\n dropAnimation?: DropAnimation | null;\n getNewIndex?: NewIndexGetter;\n rowKey?: (item: any) => Key;\n itemCount?: number;\n items?: any[];\n measuring?: MeasuringConfiguration;\n modifiers?: Modifiers;\n renderItem?: any;\n removable?: boolean;\n reorderItems?: typeof arrayMove;\n strategy?: SortingStrategy;\n style?: React.CSSProperties;\n useDragOverlay?: boolean;\n modifierNames?: (\n | \"restrictToHorizontalAxis\"\n | \"restrictToVerticalAxis\"\n | \"restrictToWindowEdges\"\n | \"restrictToParentElement\"\n | \"restrictToFirstScrollableAncestor\"\n )[];\n getItemStyles?(args: {\n id: UniqueIdentifier;\n index: number;\n isSorting: boolean;\n isDragOverlay: boolean;\n overIndex: number;\n isDragging: boolean;\n }): React.CSSProperties;\n wrapperStyle?(args: {\n active: Pick<Active, \"id\"> | null;\n index: number;\n isDragging: boolean;\n id: UniqueIdentifier;\n }): React.CSSProperties;\n isDisabled?(id: UniqueIdentifier): boolean;\n className?: string;\n}\n\nconst dropAnimationConfig: DropAnimation = {\n sideEffects: defaultDropAnimationSideEffects({\n styles: {\n active: {\n opacity: \"0.5\",\n },\n },\n }),\n};\n\nconst screenReaderInstructions: ScreenReaderInstructions = {\n draggable: `\n To pick up a sortable item, press the space bar.\n While sorting, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n `,\n};\n\nexport const modifierByName = {\n restrictToVerticalAxis,\n restrictToWindowEdges,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToFirstScrollableAncestor,\n};\n\nexport function Sortable({\n className,\n style,\n activationConstraint,\n animateLayoutChanges,\n adjustScale = false,\n collisionDetection = closestCenter,\n coordinateGetter = sortableKeyboardCoordinates,\n dropAnimation = dropAnimationConfig,\n getNewIndex,\n rowKey = (item) => item.id,\n items: initialItems = [],\n measuring,\n modifiers,\n removable,\n renderItem,\n reorderItems = arrayMove,\n strategy = rectSortingStrategy,\n useDragOverlay = true,\n modifierNames,\n themeResetClass,\n onReorder,\n}: SortableProps) {\n modifiers =\n modifiers ?? (modifierNames ?? []).map((name) => modifierByName[name]);\n\n // This is the optimistic version.\n const [items, setItems] = useState<UniqueIdentifier[]>(() => initialItems);\n useEffect(() => {\n setItems(initialItems);\n }, [initialItems]);\n const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n const sensors = useSensors(\n useSensor(MouseSensor, {\n activationConstraint,\n }),\n useSensor(TouchSensor, {\n activationConstraint,\n }),\n useSensor(KeyboardSensor, {\n // Disable smooth scrolling in Cypress automated tests\n scrollBehavior: \"Cypress\" in globalThis ? \"auto\" : undefined,\n coordinateGetter,\n })\n );\n const isFirstAnnouncement = useRef(true);\n const getIndex = (id: UniqueIdentifier) =>\n items.findIndex((item) => rowKey(item) === id);\n const getPosition = (id: UniqueIdentifier) => getIndex(id) + 1;\n const activeIndex = activeId ? getIndex(activeId) : -1;\n const announcements: Announcements = {\n onDragStart({ active: { id } }) {\n return `Picked up sortable item ${String(\n id\n )}. Sortable item ${id} is in position ${getPosition(id)} of ${\n items.length\n }`;\n },\n onDragOver({ active, over }) {\n // In this specific use-case, the picked up item's `id` is always the same as the first `over` id.\n // The first `onDragOver` event therefore doesn't need to be announced, because it is called\n // immediately after the `onDragStart` announcement and is redundant.\n if (isFirstAnnouncement.current === true) {\n isFirstAnnouncement.current = false;\n return;\n }\n\n if (over) {\n return `Sortable item ${\n active.id\n } was moved into position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragEnd({ active, over }) {\n if (over) {\n return `Sortable item ${\n active.id\n } was dropped at position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragCancel({ active: { id } }) {\n return `Sorting was cancelled. Sortable item ${id} was dropped and returned to position ${getPosition(\n id\n )} of ${items.length}.`;\n },\n };\n useEffect(() => {\n if (!activeId) {\n isFirstAnnouncement.current = true;\n }\n }, [activeId]);\n\n return (\n <div className={className} style={style}>\n <DndContext\n accessibility={{\n announcements,\n screenReaderInstructions,\n }}\n sensors={sensors}\n collisionDetection={collisionDetection}\n onDragStart={({ active }) => {\n if (!active) {\n return;\n }\n\n setActiveId(active.id);\n }}\n onDragEnd={({ over }) => {\n setActiveId(null);\n\n if (over) {\n const overIndex = getIndex(over.id);\n const reordered = reorderItems(items, activeIndex, overIndex);\n onReorder?.(activeIndex, overIndex, reordered, items);\n if (activeIndex !== overIndex) {\n setItems((items) => reordered);\n }\n }\n }}\n onDragCancel={() => setActiveId(null)}\n measuring={measuring}\n modifiers={modifiers}\n >\n <SortableContext items={items.map(rowKey)} strategy={strategy}>\n {items.map((value, index) => (\n <SortableItem\n key={rowKey(value)}\n id={rowKey(value)}\n value={value}\n index={index}\n renderItem={renderItem}\n animateLayoutChanges={animateLayoutChanges}\n useDragOverlay={useDragOverlay}\n getNewIndex={getNewIndex}\n />\n ))}\n </SortableContext>\n {useDragOverlay && typeof document !== \"undefined\"\n ? createPortal(\n <DragOverlay\n adjustScale={adjustScale}\n dropAnimation={dropAnimation}\n >\n {activeId ? (\n <Item\n index={activeIndex}\n value={items[activeIndex]}\n renderItem={(...args) => (\n <div className={themeResetClass}>\n {renderItem(...args)}\n </div>\n )}\n dragOverlay\n />\n ) : null}\n </DragOverlay>,\n document.body\n )\n : null}\n </DndContext>\n </div>\n );\n}\n\ninterface SortableItemProps {\n animateLayoutChanges?: AnimateLayoutChanges;\n getNewIndex?: NewIndexGetter;\n id: UniqueIdentifier;\n index: number;\n useDragOverlay?: boolean;\n renderItem?(args: any): React.ReactElement;\n value?: any;\n}\n\nexport function SortableItem({\n animateLayoutChanges,\n getNewIndex,\n id,\n value,\n index,\n renderItem,\n useDragOverlay,\n}: SortableItemProps) {\n const sortableData = useSortable({\n id,\n animateLayoutChanges,\n getNewIndex,\n });\n const {\n attributes,\n isDragging,\n isSorting,\n listeners,\n setNodeRef,\n transform,\n transition,\n } = sortableData;\n\n return (\n <DataProvider hidden={true} name={\"sortableItem\"} data={sortableData}>\n <Item\n ref={setNodeRef}\n value={value}\n dragging={isDragging}\n sorting={isSorting}\n renderItem={renderItem}\n index={index}\n transform={transform}\n transition={transition}\n listeners={listeners}\n data-index={index}\n data-id={id}\n dragOverlay={!useDragOverlay && isDragging}\n {...attributes}\n />\n </DataProvider>\n );\n}\n\nexport function SortableHandle({ children }: { children?: ReactNode }) {\n const data = useSelector(\"sortableItem\");\n const child = React.Children.toArray(children)[0];\n return isElement(child)\n ? cloneElement(child as ReactElement, {\n ...data?.listeners,\n ref: data?.setActivatorNodeRef,\n tabIndex: 0,\n })\n : null;\n}\n\nexport function registerSortable(loader?: Registerable) {\n registerComponentHelper(loader, SortableHandle, {\n name: \"SortableHandle\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"text\",\n value: \"Handle\",\n },\n mergeWithParent: true,\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"SortableHandle\",\n });\n\n registerComponentHelper(loader, Sortable, {\n name: \"Sortable\",\n props: {\n items: {\n type: \"array\",\n defaultValue: [\n { id: 1, name: \"hello\" },\n { id: 2, name: \"world\" },\n ],\n },\n modifierNames: {\n displayName: \"Options\",\n type: \"choice\",\n multiSelect: true,\n options: Object.keys(modifierByName).map((v) => ({\n value: v,\n label:\n v[0].toUpperCase() + v.slice(1).replace(/([a-z])([A-Z])/g, \"$1 $2\"),\n })),\n },\n onReorder: {\n type: \"eventHandler\",\n argTypes: [\n {\n name: \"fromIndex\",\n type: \"number\",\n },\n {\n name: \"toIndex\",\n type: \"number\",\n },\n {\n name: \"newItems\",\n type: \"object\",\n },\n {\n name: \"oldItems\",\n type: \"object\",\n },\n ],\n },\n themeResetClass: {\n type: \"themeResetClass\",\n },\n renderItem: {\n type: \"slot\",\n renderPropParams: [\"sortableData\", \"currentItem\"],\n mergeWithParent: true,\n defaultValue: {\n type: \"hbox\",\n children: [\n {\n type: \"text\",\n value: \"Item\",\n },\n {\n type: \"component\",\n name: \"SortableHandle\",\n },\n ],\n },\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"Sortable\",\n });\n}\n","import { registerSortable } from \"./sortable\";\nimport { Registerable } from \"./util\";\n\nexport function registerAll(loader?: Registerable) {\n registerSortable(loader);\n}\n\nexport * from \"./sortable\";\n"],"names":["registerComponentHelper","loader","component","meta","registerComponent","Item","React","memo","forwardRef","_ref","ref","dragOverlay","dragging","disabled","fadeIn","height","index","listeners","_ref$renderItem","renderItem","sorting","style","transition","transform","value","_objectWithoutPropertiesLoose","_excluded","useEffect","document","body","cursor","child","Boolean","isElement","cloneElement","filter","join","_transform$x","x","_transform$y","y","_transform$scaleX","scaleX","_transform$scaleY","scaleY","dropAnimationConfig","sideEffects","defaultDropAnimationSideEffects","styles","active","opacity","screenReaderInstructions","draggable","modifierByName","restrictToVerticalAxis","restrictToWindowEdges","restrictToHorizontalAxis","restrictToParentElement","restrictToFirstScrollableAncestor","Sortable","_ref2","className","activationConstraint","animateLayoutChanges","_ref2$adjustScale","adjustScale","_ref2$collisionDetect","collisionDetection","closestCenter","_ref2$coordinateGette","coordinateGetter","sortableKeyboardCoordinates","_ref2$dropAnimation","dropAnimation","getNewIndex","_ref2$rowKey","rowKey","item","id","_ref2$items","items","initialItems","measuring","modifiers","removable","_ref2$reorderItems","reorderItems","arrayMove","_ref2$strategy","strategy","rectSortingStrategy","_ref2$useDragOverlay","useDragOverlay","modifierNames","themeResetClass","onReorder","_modifiers","map","name","_useState","useState","setItems","_useState2","activeId","setActiveId","sensors","useSensors","useSensor","MouseSensor","TouchSensor","KeyboardSensor","scrollBehavior","globalThis","undefined","isFirstAnnouncement","useRef","getIndex","findIndex","getPosition","activeIndex","announcements","onDragStart","_ref3","String","length","onDragOver","_ref4","over","current","onDragEnd","_ref5","onDragCancel","_ref6","DndContext","accessibility","_ref7","_ref8","overIndex","reordered","SortableContext","SortableItem","key","createPortal","DragOverlay","apply","arguments","_ref9","sortableData","useSortable","isDragging","DataProvider","hidden","data","setNodeRef","isSorting","attributes","SortableHandle","_ref10","children","useSelector","Children","toArray","_extends","setActivatorNodeRef","tabIndex","registerSortable","props","type","defaultValue","mergeWithParent","importPath","importName","displayName","multiSelect","options","Object","keys","v","label","toU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nBhI,EAAQzB,EAAM0J,SAASC,QAAQH,GAAU,GAC/C,OAAO7H,YAAUF,GACbG,eAAaH,EAAqBmI,WAC7BV,SAAAA,EAAMvI,WACTP,UAAK8I,SAAAA,EAAMW,oBACXC,SAAU,KAEZ,cAGUC,EAAiBpK,GAC/BD,EAAwBC,EAAQ2J,EAAgB,CAC9C1D,KAAM,iBACNoE,MAAO,CACLR,SAAU,CACRS,KAAM,OACNC,aAAc,CACZD,KAAM,OACN/I,MAAO,UAETiJ,iBAAiB,IAGrBC,WAAY,uBACZC,WAAY,mBAGd3K,EAAwBC,EAAQ0D,EAAU,CACxCuC,KAAM,WACNoE,MAAO,CACLtF,MAAO,CACLuF,KAAM,QACNC,aAAc,CACZ,CAAE1F,GAAI,EAAGoB,KAAM,SACf,CAAEpB,GAAI,EAAGoB,KAAM,WAGnBL,cAAe,CACb+E,YAAa,UACbL,KAAM,SACNM,aAAa,EACbC,QAASC,OAAOC,KAAK3H,GAAgB4C,KAAI,SAACgF,GAAC,MAAM,CAC/CzJ,MAAOyJ,EACPC,MACED,EAAE,GAAGE,cAAgBF,EAAEG,MAAM,GAAGC,QAAQ,kBAAmB,cAGjEtF,UAAW,CACTwE,KAAM,eACNe,SAAU,CACR,CACEpF,KAAM,YACNqE,KAAM,UAER,CACErE,KAAM,UACNqE,KAAM,UAER,CACErE,KAAM,WACNqE,KAAM,UAER,CACErE,KAAM,WACNqE,KAAM,YAIZzE,gBAAiB,CACfyE,KAAM,mBAERpJ,WAAY,CACVoJ,KAAM,OACNgB,iBAAkB,CAAC,eAAgB,eACnCd,iBAAiB,EACjBD,aAAc,CACZD,KAAM,OACNT,SAAU,CACR,CACES,KAAM,OACN/I,MAAO,QAET,CACE+I,KAAM,YACNrE,KAAM,sBAMhBwE,WAAY,uBACZC,WAAY,qJCniBY1K,GAC1BoK,EAAiBpK"}
|
|
1
|
+
{"version":3,"file":"dnd-kit.cjs.production.min.js","sources":["../src/util.ts","../src/sortable.tsx","../src/index.tsx"],"sourcesContent":["import {\n CodeComponentMeta,\n default as registerComponent,\n} from \"@plasmicapp/host/registerComponent\";\nimport { default as registerGlobalContext } from \"@plasmicapp/host/registerGlobalContext\";\nimport { default as registerToken } from \"@plasmicapp/host/registerToken\";\nimport React from \"react\";\n\nexport type Registerable = {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n registerToken: typeof registerToken;\n};\n\nexport function registerComponentHelper<T extends React.ComponentType<any>>(\n loader: Registerable | undefined,\n component: T,\n meta: CodeComponentMeta<React.ComponentProps<T>>\n) {\n if (loader) {\n loader.registerComponent(component, meta);\n } else {\n registerComponent(component, meta);\n }\n}\n","import React, { cloneElement, useEffect, useRef, useState } from \"react\";\nimport type { Key, ReactElement, ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { isElement } from \"react-dom/test-utils\";\nimport {\n closestCenter,\n DragOverlay,\n DndContext,\n KeyboardSensor,\n MouseSensor,\n TouchSensor,\n useSensor,\n useSensors,\n defaultDropAnimationSideEffects,\n} from \"@dnd-kit/core\";\nimport type {\n SortingStrategy,\n AnimateLayoutChanges,\n NewIndexGetter,\n} from \"@dnd-kit/sortable\";\nimport {\n arrayMove,\n useSortable,\n SortableContext,\n sortableKeyboardCoordinates,\n rectSortingStrategy,\n} from \"@dnd-kit/sortable\";\n\nimport { DataProvider, useSelector } from \"@plasmicapp/host\";\n\nimport type {\n DraggableSyntheticListeners,\n Active,\n Announcements,\n CollisionDetection,\n DropAnimation,\n KeyboardCoordinateGetter,\n Modifiers,\n MeasuringConfiguration,\n PointerActivationConstraint,\n ScreenReaderInstructions,\n UniqueIdentifier,\n} from \"@dnd-kit/core\";\nimport type { Transform } from \"@dnd-kit/utilities\";\nimport {\n restrictToFirstScrollableAncestor,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToVerticalAxis,\n restrictToWindowEdges,\n} from \"@dnd-kit/modifiers\";\nimport { Registerable, registerComponentHelper } from \"./util\";\n\nexport interface ItemProps {\n dragOverlay?: boolean;\n color?: string;\n disabled?: boolean;\n dragging?: boolean;\n height?: number;\n index?: number;\n fadeIn?: boolean;\n transform?: Transform | null;\n listeners?: DraggableSyntheticListeners;\n sorting?: boolean;\n style?: React.CSSProperties;\n transition?: string | null;\n wrapperStyle?: React.CSSProperties;\n value: React.ReactNode;\n renderItem?(\n args: {\n dragOverlay: boolean;\n dragging: boolean;\n sorting: boolean;\n index: number | undefined;\n fadeIn: boolean;\n listeners: DraggableSyntheticListeners;\n ref: React.Ref<HTMLElement>;\n style: React.CSSProperties | undefined;\n transform: ItemProps[\"transform\"];\n transition: ItemProps[\"transition\"];\n value: ItemProps[\"value\"];\n },\n currentItem: ItemProps[\"value\"]\n ): React.ReactElement;\n}\n\nexport const Item = React.memo(\n React.forwardRef<HTMLLIElement, ItemProps>(\n (\n {\n color,\n dragOverlay,\n dragging,\n disabled,\n fadeIn,\n height,\n index,\n listeners,\n renderItem = () => <div />,\n sorting,\n style,\n transition,\n transform,\n value,\n wrapperStyle,\n ...props\n },\n ref\n ) => {\n useEffect(() => {\n if (!dragOverlay) {\n return;\n }\n\n document.body.style.cursor = \"grabbing\";\n\n return () => {\n document.body.style.cursor = \"\";\n };\n }, [dragOverlay]);\n\n const child = renderItem(\n {\n dragOverlay: Boolean(dragOverlay),\n dragging: Boolean(dragging),\n sorting: Boolean(sorting),\n index,\n fadeIn: Boolean(fadeIn),\n listeners,\n ref,\n style,\n transform,\n transition,\n value,\n },\n value\n );\n\n return isElement(child)\n ? cloneElement(child, {\n ref,\n style: {\n transition: [transition].filter(Boolean).join(\", \"),\n transform: `translate3d(${transform?.x ?? 0}px, ${\n transform?.y ?? 0\n }px, 0) scaleX(${transform?.scaleX ?? 1}) scaleY(${\n transform?.scaleY ?? 1\n }`,\n },\n })\n : child;\n }\n )\n);\n\nexport interface SortableProps {\n onReorder?: (\n fromIndex: number,\n toIndex: number,\n newItems: any[],\n oldItems: any[]\n ) => void;\n themeResetClass?: string;\n activationConstraint?: PointerActivationConstraint;\n animateLayoutChanges?: AnimateLayoutChanges;\n adjustScale?: boolean;\n collisionDetection?: CollisionDetection;\n coordinateGetter?: KeyboardCoordinateGetter;\n Container?: any; // To-do: Fix me\n dropAnimation?: DropAnimation | null;\n getNewIndex?: NewIndexGetter;\n rowKey?: (item: any) => Key;\n itemCount?: number;\n items?: any[];\n measuring?: MeasuringConfiguration;\n modifiers?: Modifiers;\n renderItem?: any;\n removable?: boolean;\n reorderItems?: typeof arrayMove;\n strategy?: SortingStrategy;\n style?: React.CSSProperties;\n useDragOverlay?: boolean;\n modifierNames?: (\n | \"restrictToHorizontalAxis\"\n | \"restrictToVerticalAxis\"\n | \"restrictToWindowEdges\"\n | \"restrictToParentElement\"\n | \"restrictToFirstScrollableAncestor\"\n )[];\n getItemStyles?(args: {\n id: UniqueIdentifier;\n index: number;\n isSorting: boolean;\n isDragOverlay: boolean;\n overIndex: number;\n isDragging: boolean;\n }): React.CSSProperties;\n wrapperStyle?(args: {\n active: Pick<Active, \"id\"> | null;\n index: number;\n isDragging: boolean;\n id: UniqueIdentifier;\n }): React.CSSProperties;\n isDisabled?(id: UniqueIdentifier): boolean;\n className?: string;\n}\n\nconst dropAnimationConfig: DropAnimation = {\n sideEffects: defaultDropAnimationSideEffects({\n styles: {\n active: {\n opacity: \"0.5\",\n },\n },\n }),\n};\n\nconst screenReaderInstructions: ScreenReaderInstructions = {\n draggable: `\n To pick up a sortable item, press the space bar.\n While sorting, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n `,\n};\n\nexport const modifierByName = {\n restrictToVerticalAxis,\n restrictToWindowEdges,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToFirstScrollableAncestor,\n};\n\nexport function Sortable({\n className,\n style,\n activationConstraint,\n animateLayoutChanges,\n adjustScale = false,\n collisionDetection = closestCenter,\n coordinateGetter = sortableKeyboardCoordinates,\n dropAnimation = dropAnimationConfig,\n getNewIndex,\n rowKey = (item) => item.id,\n items: initialItems = [],\n measuring,\n modifiers,\n removable,\n renderItem,\n reorderItems = arrayMove,\n strategy = rectSortingStrategy,\n useDragOverlay = true,\n modifierNames,\n themeResetClass,\n onReorder,\n}: SortableProps) {\n modifiers =\n modifiers ?? (modifierNames ?? []).map((name) => modifierByName[name]);\n\n // This is the optimistic version.\n const [items, setItems] = useState<UniqueIdentifier[]>(() => initialItems);\n useEffect(() => {\n setItems(initialItems);\n }, [initialItems]);\n const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n const sensors = useSensors(\n useSensor(MouseSensor, {\n activationConstraint,\n }),\n useSensor(TouchSensor, {\n activationConstraint,\n }),\n useSensor(KeyboardSensor, {\n // Disable smooth scrolling in Cypress automated tests\n scrollBehavior: \"Cypress\" in globalThis ? \"auto\" : undefined,\n coordinateGetter,\n })\n );\n const isFirstAnnouncement = useRef(true);\n const getIndex = (id: UniqueIdentifier) =>\n items.findIndex((item) => rowKey(item) === id);\n const getPosition = (id: UniqueIdentifier) => getIndex(id) + 1;\n const activeIndex = activeId ? getIndex(activeId) : -1;\n const announcements: Announcements = {\n onDragStart({ active: { id } }) {\n return `Picked up sortable item ${String(\n id\n )}. Sortable item ${id} is in position ${getPosition(id)} of ${\n items.length\n }`;\n },\n onDragOver({ active, over }) {\n // In this specific use-case, the picked up item's `id` is always the same as the first `over` id.\n // The first `onDragOver` event therefore doesn't need to be announced, because it is called\n // immediately after the `onDragStart` announcement and is redundant.\n if (isFirstAnnouncement.current === true) {\n isFirstAnnouncement.current = false;\n return;\n }\n\n if (over) {\n return `Sortable item ${\n active.id\n } was moved into position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragEnd({ active, over }) {\n if (over) {\n return `Sortable item ${\n active.id\n } was dropped at position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragCancel({ active: { id } }) {\n return `Sorting was cancelled. Sortable item ${id} was dropped and returned to position ${getPosition(\n id\n )} of ${items.length}.`;\n },\n };\n useEffect(() => {\n if (!activeId) {\n isFirstAnnouncement.current = true;\n }\n }, [activeId]);\n\n return (\n <div className={className} style={style}>\n <DndContext\n accessibility={{\n announcements,\n screenReaderInstructions,\n }}\n sensors={sensors}\n collisionDetection={collisionDetection}\n onDragStart={({ active }) => {\n if (!active) {\n return;\n }\n\n setActiveId(active.id);\n }}\n onDragEnd={({ over }) => {\n setActiveId(null);\n\n if (over) {\n const overIndex = getIndex(over.id);\n const reordered = reorderItems(items, activeIndex, overIndex);\n onReorder?.(activeIndex, overIndex, reordered, items);\n if (activeIndex !== overIndex) {\n setItems((items) => reordered);\n }\n }\n }}\n onDragCancel={() => setActiveId(null)}\n measuring={measuring}\n modifiers={modifiers}\n >\n <SortableContext items={items.map(rowKey)} strategy={strategy}>\n {items.map((value, index) => (\n <SortableItem\n key={rowKey(value)}\n id={rowKey(value)}\n value={value}\n index={index}\n renderItem={renderItem}\n animateLayoutChanges={animateLayoutChanges}\n useDragOverlay={useDragOverlay}\n getNewIndex={getNewIndex}\n />\n ))}\n </SortableContext>\n {useDragOverlay && typeof document !== \"undefined\"\n ? createPortal(\n <DragOverlay\n adjustScale={adjustScale}\n dropAnimation={dropAnimation}\n >\n {activeId ? (\n <Item\n index={activeIndex}\n value={items[activeIndex]}\n renderItem={(...args) => (\n <div className={themeResetClass}>\n {renderItem(...args)}\n </div>\n )}\n dragOverlay\n />\n ) : null}\n </DragOverlay>,\n document.body\n )\n : null}\n </DndContext>\n </div>\n );\n}\n\ninterface SortableItemProps {\n animateLayoutChanges?: AnimateLayoutChanges;\n getNewIndex?: NewIndexGetter;\n id: UniqueIdentifier;\n index: number;\n useDragOverlay?: boolean;\n renderItem?(args: any): React.ReactElement;\n value?: any;\n}\n\nexport function SortableItem({\n animateLayoutChanges,\n getNewIndex,\n id,\n value,\n index,\n renderItem,\n useDragOverlay,\n}: SortableItemProps) {\n const sortableData = useSortable({\n id,\n animateLayoutChanges,\n getNewIndex,\n });\n const {\n attributes,\n isDragging,\n isSorting,\n listeners,\n setNodeRef,\n transform,\n transition,\n } = sortableData;\n\n return (\n <DataProvider hidden={true} name={\"sortableItem\"} data={sortableData}>\n <Item\n ref={setNodeRef}\n value={value}\n dragging={isDragging}\n sorting={isSorting}\n renderItem={renderItem}\n index={index}\n transform={transform}\n transition={transition}\n listeners={listeners}\n data-index={index}\n data-id={id}\n dragOverlay={!useDragOverlay && isDragging}\n {...attributes}\n />\n </DataProvider>\n );\n}\n\nexport function SortableHandle({ children }: { children?: ReactNode }) {\n const data = useSelector(\"sortableItem\");\n const child = React.Children.toArray(children)[0];\n return isElement(child)\n ? cloneElement(child as ReactElement, {\n ...data?.listeners,\n ref: data?.setActivatorNodeRef,\n tabIndex: 0,\n })\n : null;\n}\n\nexport function registerSortable(loader?: Registerable) {\n registerComponentHelper(loader, SortableHandle, {\n name: \"SortableHandle\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"text\",\n value: \"Handle\",\n },\n mergeWithParent: true,\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"SortableHandle\",\n });\n\n registerComponentHelper(loader, Sortable, {\n name: \"Sortable\",\n props: {\n items: {\n type: \"array\",\n defaultValue: [\n { id: 1, name: \"hello\" },\n { id: 2, name: \"world\" },\n ],\n },\n modifierNames: {\n displayName: \"Options\",\n type: \"choice\",\n multiSelect: true,\n options: Object.keys(modifierByName).map((v) => ({\n value: v,\n label:\n v[0].toUpperCase() + v.slice(1).replace(/([a-z])([A-Z])/g, \"$1 $2\"),\n })),\n },\n onReorder: {\n type: \"eventHandler\",\n argTypes: [\n {\n name: \"fromIndex\",\n type: \"number\",\n },\n {\n name: \"toIndex\",\n type: \"number\",\n },\n {\n name: \"newItems\",\n type: \"object\",\n },\n {\n name: \"oldItems\",\n type: \"object\",\n },\n ],\n },\n themeResetClass: {\n type: \"themeResetClass\",\n },\n renderItem: {\n type: \"slot\",\n renderPropParams: [\"sortableData\", \"currentItem\"],\n mergeWithParent: true,\n defaultValue: {\n type: \"hbox\",\n children: [\n {\n type: \"text\",\n value: \"Item\",\n },\n {\n type: \"component\",\n name: \"SortableHandle\",\n },\n ],\n },\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"Sortable\",\n });\n}\n","import { registerSortable } from \"./sortable\";\nimport { Registerable } from \"./util\";\n\nexport function registerAll(loader?: Registerable) {\n registerSortable(loader);\n}\n\nexport * from \"./sortable\";\n"],"names":["registerComponentHelper","loader","component","meta","registerComponent","Item","React","memo","forwardRef","_ref","ref","dragOverlay","dragging","disabled","fadeIn","height","index","listeners","_ref$renderItem","renderItem","sorting","style","transition","transform","value","_objectWithoutPropertiesLoose","_excluded","useEffect","document","body","cursor","child","Boolean","isElement","cloneElement","filter","join","_transform$x","x","_transform$y","y","_transform$scaleX","scaleX","_transform$scaleY","scaleY","dropAnimationConfig","sideEffects","defaultDropAnimationSideEffects","styles","active","opacity","screenReaderInstructions","draggable","modifierByName","restrictToVerticalAxis","restrictToWindowEdges","restrictToHorizontalAxis","restrictToParentElement","restrictToFirstScrollableAncestor","Sortable","_ref2","className","activationConstraint","animateLayoutChanges","_ref2$adjustScale","adjustScale","_ref2$collisionDetect","collisionDetection","closestCenter","_ref2$coordinateGette","coordinateGetter","sortableKeyboardCoordinates","_ref2$dropAnimation","dropAnimation","getNewIndex","_ref2$rowKey","rowKey","item","id","_ref2$items","items","initialItems","measuring","modifiers","removable","_ref2$reorderItems","reorderItems","arrayMove","_ref2$strategy","strategy","rectSortingStrategy","_ref2$useDragOverlay","useDragOverlay","modifierNames","themeResetClass","onReorder","_modifiers","map","name","_useState","useState","setItems","_useState2","activeId","setActiveId","sensors","useSensors","useSensor","MouseSensor","TouchSensor","KeyboardSensor","scrollBehavior","globalThis","undefined","isFirstAnnouncement","useRef","getIndex","findIndex","getPosition","activeIndex","announcements","onDragStart","_ref3","String","length","onDragOver","_ref4","over","current","onDragEnd","_ref5","onDragCancel","_ref6","DndContext","accessibility","_ref7","_ref8","overIndex","reordered","SortableContext","SortableItem","key","createPortal","DragOverlay","apply","arguments","_ref9","sortableData","useSortable","isDragging","DataProvider","hidden","data","setNodeRef","isSorting","attributes","SortableHandle","_ref10","children","useSelector","Children","toArray","_extends","setActivatorNodeRef","tabIndex","registerSortable","props","type","defaultValue","mergeWithParent","importPath","importName","displayName","multiSelect","options","Object","keys","v","label","toUpperCase","slice","replace","argTypes","renderPropParams"],"mappings":"4mBAcgBA,EACdC,EACAC,EACAC,GAEIF,EACFA,EAAOG,kBAAkBF,EAAWC,GAEpCC,EAAkBF,EAAWC,4KCgEpBE,EAAOC,EAAMC,KACxBD,EAAME,YACJ,SAAAC,EAmBEC,eAhBEC,EAAWF,EAAXE,YACAC,EAAQH,EAARG,SACAC,EACMJ,EAANK,OACAC,EACKN,EAALO,MACAC,EAASR,EAATQ,UAASC,EAAAT,EACTU,WAAAA,WAAUD,EAAG,WAAA,OAAMZ,6BAAOY,EAC1BE,EAAOX,EAAPW,QACAC,EAAKZ,EAALY,MACAC,EAAUb,EAAVa,WACAC,EAASd,EAATc,UACAC,EAAKf,EAALe,0IAEQC,CAAAhB,EAAAiB,GAIVC,aAAU,WACR,GAAKhB,EAML,OAFAiB,SAASC,KAAKR,MAAMS,OAAS,WAEtB,WACLF,SAASC,KAAKR,MAAMS,OAAS,MAE9B,CAACnB,IAEJ,IAAMoB,EAAQZ,EACZ,CACER,YAAaqB,QAAQrB,GACrBC,SAAUoB,QAAQpB,GAClBQ,QAASY,QAAQZ,GACjBJ,MAAAA,EACAF,OAAQkB,QAAQlB,GAChBG,UAAAA,EACAP,IAAAA,EACAW,MAAAA,EACAE,UAAAA,EACAD,WAAAA,EACAE,MAAAA,GAEFA,GAGF,OAAOS,YAAUF,GACbG,eAAaH,EAAO,CAClBrB,IAAAA,EACAW,MAAO,CACLC,WAAY,CAACA,GAAYa,OAAOH,SAASI,KAAK,MAC9Cb,iCAASc,QAAiBd,SAAAA,EAAWe,GAACD,EAAI,kBAACE,QACzChB,SAAAA,EAAWiB,GAACD,EAAI,4BAClBE,QAAiBlB,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/I,MAAO,QAET,CACE+I,KAAM,YACNrE,KAAM,sBAMhBwE,WAAY,uBACZC,WAAY,qJCniBY1K,GAC1BoK,EAAiBpK"}
|
package/dist/dnd-kit.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dnd-kit.esm.js","sources":["../src/util.ts","../src/sortable.tsx","../src/index.tsx"],"sourcesContent":["import {\n ComponentMeta,\n default as registerComponent,\n} from \"@plasmicapp/host/registerComponent\";\nimport { default as registerGlobalContext } from \"@plasmicapp/host/registerGlobalContext\";\nimport { default as registerToken } from \"@plasmicapp/host/registerToken\";\nimport React from \"react\";\n\nexport type Registerable = {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n registerToken: typeof registerToken;\n};\n\nexport function registerComponentHelper<T extends React.ComponentType<any>>(\n loader: Registerable | undefined,\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n if (loader) {\n loader.registerComponent(component, meta);\n } else {\n registerComponent(component, meta);\n }\n}\n","import React, { cloneElement, useEffect, useRef, useState } from \"react\";\nimport type { Key, ReactElement, ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { isElement } from \"react-dom/test-utils\";\nimport {\n closestCenter,\n DragOverlay,\n DndContext,\n KeyboardSensor,\n MouseSensor,\n TouchSensor,\n useSensor,\n useSensors,\n defaultDropAnimationSideEffects,\n} from \"@dnd-kit/core\";\nimport type {\n SortingStrategy,\n AnimateLayoutChanges,\n NewIndexGetter,\n} from \"@dnd-kit/sortable\";\nimport {\n arrayMove,\n useSortable,\n SortableContext,\n sortableKeyboardCoordinates,\n rectSortingStrategy,\n} from \"@dnd-kit/sortable\";\n\nimport { DataProvider, useSelector } from \"@plasmicapp/host\";\n\nimport type {\n DraggableSyntheticListeners,\n Active,\n Announcements,\n CollisionDetection,\n DropAnimation,\n KeyboardCoordinateGetter,\n Modifiers,\n MeasuringConfiguration,\n PointerActivationConstraint,\n ScreenReaderInstructions,\n UniqueIdentifier,\n} from \"@dnd-kit/core\";\nimport type { Transform } from \"@dnd-kit/utilities\";\nimport {\n restrictToFirstScrollableAncestor,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToVerticalAxis,\n restrictToWindowEdges,\n} from \"@dnd-kit/modifiers\";\nimport { Registerable, registerComponentHelper } from \"./util\";\n\nexport interface ItemProps {\n dragOverlay?: boolean;\n color?: string;\n disabled?: boolean;\n dragging?: boolean;\n height?: number;\n index?: number;\n fadeIn?: boolean;\n transform?: Transform | null;\n listeners?: DraggableSyntheticListeners;\n sorting?: boolean;\n style?: React.CSSProperties;\n transition?: string | null;\n wrapperStyle?: React.CSSProperties;\n value: React.ReactNode;\n renderItem?(\n args: {\n dragOverlay: boolean;\n dragging: boolean;\n sorting: boolean;\n index: number | undefined;\n fadeIn: boolean;\n listeners: DraggableSyntheticListeners;\n ref: React.Ref<HTMLElement>;\n style: React.CSSProperties | undefined;\n transform: ItemProps[\"transform\"];\n transition: ItemProps[\"transition\"];\n value: ItemProps[\"value\"];\n },\n currentItem: ItemProps[\"value\"]\n ): React.ReactElement;\n}\n\nexport const Item = React.memo(\n React.forwardRef<HTMLLIElement, ItemProps>(\n (\n {\n color,\n dragOverlay,\n dragging,\n disabled,\n fadeIn,\n height,\n index,\n listeners,\n renderItem = () => <div />,\n sorting,\n style,\n transition,\n transform,\n value,\n wrapperStyle,\n ...props\n },\n ref\n ) => {\n useEffect(() => {\n if (!dragOverlay) {\n return;\n }\n\n document.body.style.cursor = \"grabbing\";\n\n return () => {\n document.body.style.cursor = \"\";\n };\n }, [dragOverlay]);\n\n const child = renderItem(\n {\n dragOverlay: Boolean(dragOverlay),\n dragging: Boolean(dragging),\n sorting: Boolean(sorting),\n index,\n fadeIn: Boolean(fadeIn),\n listeners,\n ref,\n style,\n transform,\n transition,\n value,\n },\n value\n );\n\n return isElement(child)\n ? cloneElement(child, {\n ref,\n style: {\n transition: [transition].filter(Boolean).join(\", \"),\n transform: `translate3d(${transform?.x ?? 0}px, ${\n transform?.y ?? 0\n }px, 0) scaleX(${transform?.scaleX ?? 1}) scaleY(${\n transform?.scaleY ?? 1\n }`,\n },\n })\n : child;\n }\n )\n);\n\nexport interface SortableProps {\n onReorder?: (\n fromIndex: number,\n toIndex: number,\n newItems: any[],\n oldItems: any[]\n ) => void;\n themeResetClass?: string;\n activationConstraint?: PointerActivationConstraint;\n animateLayoutChanges?: AnimateLayoutChanges;\n adjustScale?: boolean;\n collisionDetection?: CollisionDetection;\n coordinateGetter?: KeyboardCoordinateGetter;\n Container?: any; // To-do: Fix me\n dropAnimation?: DropAnimation | null;\n getNewIndex?: NewIndexGetter;\n rowKey?: (item: any) => Key;\n itemCount?: number;\n items?: any[];\n measuring?: MeasuringConfiguration;\n modifiers?: Modifiers;\n renderItem?: any;\n removable?: boolean;\n reorderItems?: typeof arrayMove;\n strategy?: SortingStrategy;\n style?: React.CSSProperties;\n useDragOverlay?: boolean;\n modifierNames?: (\n | \"restrictToHorizontalAxis\"\n | \"restrictToVerticalAxis\"\n | \"restrictToWindowEdges\"\n | \"restrictToParentElement\"\n | \"restrictToFirstScrollableAncestor\"\n )[];\n getItemStyles?(args: {\n id: UniqueIdentifier;\n index: number;\n isSorting: boolean;\n isDragOverlay: boolean;\n overIndex: number;\n isDragging: boolean;\n }): React.CSSProperties;\n wrapperStyle?(args: {\n active: Pick<Active, \"id\"> | null;\n index: number;\n isDragging: boolean;\n id: UniqueIdentifier;\n }): React.CSSProperties;\n isDisabled?(id: UniqueIdentifier): boolean;\n className?: string;\n}\n\nconst dropAnimationConfig: DropAnimation = {\n sideEffects: defaultDropAnimationSideEffects({\n styles: {\n active: {\n opacity: \"0.5\",\n },\n },\n }),\n};\n\nconst screenReaderInstructions: ScreenReaderInstructions = {\n draggable: `\n To pick up a sortable item, press the space bar.\n While sorting, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n `,\n};\n\nexport const modifierByName = {\n restrictToVerticalAxis,\n restrictToWindowEdges,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToFirstScrollableAncestor,\n};\n\nexport function Sortable({\n className,\n style,\n activationConstraint,\n animateLayoutChanges,\n adjustScale = false,\n collisionDetection = closestCenter,\n coordinateGetter = sortableKeyboardCoordinates,\n dropAnimation = dropAnimationConfig,\n getNewIndex,\n rowKey = (item) => item.id,\n items: initialItems = [],\n measuring,\n modifiers,\n removable,\n renderItem,\n reorderItems = arrayMove,\n strategy = rectSortingStrategy,\n useDragOverlay = true,\n modifierNames,\n themeResetClass,\n onReorder,\n}: SortableProps) {\n modifiers =\n modifiers ?? (modifierNames ?? []).map((name) => modifierByName[name]);\n\n // This is the optimistic version.\n const [items, setItems] = useState<UniqueIdentifier[]>(() => initialItems);\n useEffect(() => {\n setItems(initialItems);\n }, [initialItems]);\n const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n const sensors = useSensors(\n useSensor(MouseSensor, {\n activationConstraint,\n }),\n useSensor(TouchSensor, {\n activationConstraint,\n }),\n useSensor(KeyboardSensor, {\n // Disable smooth scrolling in Cypress automated tests\n scrollBehavior: \"Cypress\" in globalThis ? \"auto\" : undefined,\n coordinateGetter,\n })\n );\n const isFirstAnnouncement = useRef(true);\n const getIndex = (id: UniqueIdentifier) =>\n items.findIndex((item) => rowKey(item) === id);\n const getPosition = (id: UniqueIdentifier) => getIndex(id) + 1;\n const activeIndex = activeId ? getIndex(activeId) : -1;\n const announcements: Announcements = {\n onDragStart({ active: { id } }) {\n return `Picked up sortable item ${String(\n id\n )}. Sortable item ${id} is in position ${getPosition(id)} of ${\n items.length\n }`;\n },\n onDragOver({ active, over }) {\n // In this specific use-case, the picked up item's `id` is always the same as the first `over` id.\n // The first `onDragOver` event therefore doesn't need to be announced, because it is called\n // immediately after the `onDragStart` announcement and is redundant.\n if (isFirstAnnouncement.current === true) {\n isFirstAnnouncement.current = false;\n return;\n }\n\n if (over) {\n return `Sortable item ${\n active.id\n } was moved into position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragEnd({ active, over }) {\n if (over) {\n return `Sortable item ${\n active.id\n } was dropped at position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragCancel({ active: { id } }) {\n return `Sorting was cancelled. Sortable item ${id} was dropped and returned to position ${getPosition(\n id\n )} of ${items.length}.`;\n },\n };\n useEffect(() => {\n if (!activeId) {\n isFirstAnnouncement.current = true;\n }\n }, [activeId]);\n\n return (\n <div className={className} style={style}>\n <DndContext\n accessibility={{\n announcements,\n screenReaderInstructions,\n }}\n sensors={sensors}\n collisionDetection={collisionDetection}\n onDragStart={({ active }) => {\n if (!active) {\n return;\n }\n\n setActiveId(active.id);\n }}\n onDragEnd={({ over }) => {\n setActiveId(null);\n\n if (over) {\n const overIndex = getIndex(over.id);\n const reordered = reorderItems(items, activeIndex, overIndex);\n onReorder?.(activeIndex, overIndex, reordered, items);\n if (activeIndex !== overIndex) {\n setItems((items) => reordered);\n }\n }\n }}\n onDragCancel={() => setActiveId(null)}\n measuring={measuring}\n modifiers={modifiers}\n >\n <SortableContext items={items.map(rowKey)} strategy={strategy}>\n {items.map((value, index) => (\n <SortableItem\n key={rowKey(value)}\n id={rowKey(value)}\n value={value}\n index={index}\n renderItem={renderItem}\n animateLayoutChanges={animateLayoutChanges}\n useDragOverlay={useDragOverlay}\n getNewIndex={getNewIndex}\n />\n ))}\n </SortableContext>\n {useDragOverlay && typeof document !== \"undefined\"\n ? createPortal(\n <DragOverlay\n adjustScale={adjustScale}\n dropAnimation={dropAnimation}\n >\n {activeId ? (\n <Item\n index={activeIndex}\n value={items[activeIndex]}\n renderItem={(...args) => (\n <div className={themeResetClass}>\n {renderItem(...args)}\n </div>\n )}\n dragOverlay\n />\n ) : null}\n </DragOverlay>,\n document.body\n )\n : null}\n </DndContext>\n </div>\n );\n}\n\ninterface SortableItemProps {\n animateLayoutChanges?: AnimateLayoutChanges;\n getNewIndex?: NewIndexGetter;\n id: UniqueIdentifier;\n index: number;\n useDragOverlay?: boolean;\n renderItem?(args: any): React.ReactElement;\n value?: any;\n}\n\nexport function SortableItem({\n animateLayoutChanges,\n getNewIndex,\n id,\n value,\n index,\n renderItem,\n useDragOverlay,\n}: SortableItemProps) {\n const sortableData = useSortable({\n id,\n animateLayoutChanges,\n getNewIndex,\n });\n const {\n attributes,\n isDragging,\n isSorting,\n listeners,\n setNodeRef,\n transform,\n transition,\n } = sortableData;\n\n return (\n <DataProvider hidden={true} name={\"sortableItem\"} data={sortableData}>\n <Item\n ref={setNodeRef}\n value={value}\n dragging={isDragging}\n sorting={isSorting}\n renderItem={renderItem}\n index={index}\n transform={transform}\n transition={transition}\n listeners={listeners}\n data-index={index}\n data-id={id}\n dragOverlay={!useDragOverlay && isDragging}\n {...attributes}\n />\n </DataProvider>\n );\n}\n\nexport function SortableHandle({ children }: { children?: ReactNode }) {\n const data = useSelector(\"sortableItem\");\n const child = React.Children.toArray(children)[0];\n return isElement(child)\n ? cloneElement(child as ReactElement, {\n ...data?.listeners,\n ref: data?.setActivatorNodeRef,\n tabIndex: 0,\n })\n : null;\n}\n\nexport function registerSortable(loader?: Registerable) {\n registerComponentHelper(loader, SortableHandle, {\n name: \"SortableHandle\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"text\",\n value: \"Handle\",\n },\n mergeWithParent: true,\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"SortableHandle\",\n });\n\n registerComponentHelper(loader, Sortable, {\n name: \"Sortable\",\n props: {\n items: {\n type: \"array\",\n defaultValue: [\n { id: 1, name: \"hello\" },\n { id: 2, name: \"world\" },\n ],\n },\n modifierNames: {\n displayName: \"Options\",\n type: \"choice\",\n multiSelect: true,\n options: Object.keys(modifierByName).map((v) => ({\n value: v,\n label:\n v[0].toUpperCase() + v.slice(1).replace(/([a-z])([A-Z])/g, \"$1 $2\"),\n })),\n },\n onReorder: {\n type: \"eventHandler\",\n argTypes: [\n {\n name: \"fromIndex\",\n type: \"number\",\n },\n {\n name: \"toIndex\",\n type: \"number\",\n },\n {\n name: \"newItems\",\n type: \"object\",\n },\n {\n name: \"oldItems\",\n type: \"object\",\n },\n ],\n },\n themeResetClass: {\n type: \"themeResetClass\",\n },\n renderItem: {\n type: \"slot\",\n renderPropParams: [\"sortableData\", \"currentItem\"],\n mergeWithParent: true,\n defaultValue: {\n type: \"hbox\",\n children: [\n {\n type: \"text\",\n value: \"Item\",\n },\n {\n type: \"component\",\n name: \"SortableHandle\",\n },\n ],\n },\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"Sortable\",\n });\n}\n","import { registerSortable } from \"./sortable\";\nimport { Registerable } from \"./util\";\n\nexport function registerAll(loader?: Registerable) {\n registerSortable(loader);\n}\n\nexport * from \"./sortable\";\n"],"names":["registerComponentHelper","loader","component","meta","registerComponent","Item","React","memo","forwardRef","_ref","ref","dragOverlay","dragging","disabled","fadeIn","height","index","listeners","_ref$renderItem","renderItem","sorting","style","transition","transform","value","wrapperStyle","props","_objectWithoutPropertiesLoose","_excluded","useEffect","document","body","cursor","child","Boolean","isElement","cloneElement","filter","join","_transform$x","x","_transform$y","y","_transform$scaleX","scaleX","_transform$scaleY","scaleY","dropAnimationConfig","sideEffects","defaultDropAnimationSideEffects","styles","active","opacity","screenReaderInstructions","draggable","modifierByName","restrictToVerticalAxis","restrictToWindowEdges","restrictToHorizontalAxis","restrictToParentElement","restrictToFirstScrollableAncestor","Sortable","_ref2","className","activationConstraint","animateLayoutChanges","_ref2$adjustScale","adjustScale","_ref2$collisionDetect","collisionDetection","closestCenter","_ref2$coordinateGette","coordinateGetter","sortableKeyboardCoordinates","_ref2$dropAnimation","dropAnimation","getNewIndex","_ref2$rowKey","rowKey","item","id","_ref2$items","items","initialItems","measuring","modifiers","removable","_ref2$reorderItems","reorderItems","arrayMove","_ref2$strategy","strategy","rectSortingStrategy","_ref2$useDragOverlay","useDragOverlay","modifierNames","themeResetClass","onReorder","_modifiers","map","name","_useState","useState","setItems","_useState2","activeId","setActiveId","sensors","useSensors","useSensor","MouseSensor","TouchSensor","KeyboardSensor","scrollBehavior","globalThis","undefined","isFirstAnnouncement","useRef","getIndex","findIndex","getPosition","activeIndex","announcements","onDragStart","_ref3","String","length","onDragOver","_ref4","over","current","onDragEnd","_ref5","onDragCancel","_ref6","DndContext","accessibility","_ref7","_ref8","overIndex","reordered","SortableContext","SortableItem","key","createPortal","DragOverlay","apply","arguments","_ref9","sortableData","useSortable","attributes","isDragging","isSorting","setNodeRef","DataProvider","hidden","data","SortableHandle","_ref10","children","useSelector","Children","toArray","_extends","setActivatorNodeRef","tabIndex","registerSortable","type","defaultValue","mergeWithParent","importPath","importName","displayName","multiSelect","options","Object","keys","v","label","toUpperCase","slice","replace","argTypes","renderPropParams","registerAll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;SAcgBA,uBAAuBA,CACrCC,MAAgC,EAChCC,SAAY,EACZC,IAA4C;EAE5C,IAAIF,MAAM,EAAE;IACVA,MAAM,CAACG,iBAAiB,CAACF,SAAS,EAAEC,IAAI,CAAC;GAC1C,MAAM;IACLC,iBAAiB,CAACF,SAAS,EAAEC,IAAI,CAAC;;AAEtC;;;ACxBA,IAsFaE,IAAI,gBAAGC,KAAK,CAACC,IAAI,cAC5BD,KAAK,CAACE,UAAU,CACd,UAAAC,IAAA,EAmBEC,GAAG;;MAhBDC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IACXC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,AACAC,MAAM,GAAAL,IAAA,CAANK,MAAM;IACNC,AACAC,KAAK,GAAAP,IAAA,CAALO,KAAK;IACLC,SAAS,GAAAR,IAAA,CAATQ,SAAS;IAAAC,eAAA,GAAAT,IAAA,CACTU,UAAU;IAAVA,UAAU,GAAAD,eAAA,cAAG;MAAA,OAAMZ,gCAAO;QAAAY,eAAA;IAC1BE,OAAO,GAAAX,IAAA,CAAPW,OAAO;IACPC,KAAK,GAAAZ,IAAA,CAALY,KAAK;IACLC,UAAU,GAAA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BL,IAAI,EAAE,QAAQ;QACdM,WAAW,EAAE,IAAI;QACjBC,OAAO,EAAEC,MAAM,CAACC,IAAI,CAAC1H,cAAc,CAAC,CAAC4C,GAAG,CAAC,UAAC+E,CAAC;UAAA,OAAM;YAC/C1J,KAAK,EAAE0J,CAAC;YACRC,KAAK,EACHD,CAAC,CAAC,CAAC,CAAC,CAACE,WAAW,EAAE,GAAGF,CAAC,CAACG,KAAK,CAAC,CAAC,CAAC,CAACC,OAAO,CAAC,iBAAiB,EAAE,OAAO;WACrE;SAAC;OACH;MACDrF,SAAS,EAAE;QACTuE,IAAI,EAAE,cAAc;QACpBe,QAAQ,EAAE,CACR;UACEnF,IAAI,EAAE,WAAW;UACjBoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,SAAS;UACfoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,UAAU;UAChBoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,UAAU;UAChBoE,IAAI,EAAE;SACP;OAEJ;MACDxE,eAAe,EAAE;QACfwE,IAAI,EAAE;OACP;MACDrJ,UAAU,EAAE;QACVqJ,IAAI,EAAE,MAAM;QACZgB,gBAAgB,EAAE,CAAC,cAAc,EAAE,aAAa,CAAC;QACjDd,eAAe,EAAE,IAAI;QACrBD,YAAY,EAAE;UACZD,IAAI,EAAE,MAAM;UACZR,QAAQ,EAAE,CACR;YACEQ,IAAI,EAAE,MAAM;YACZhJ,KAAK,EAAE;WACR,EACD;YACEgJ,IAAI,EAAE,WAAW;YACjBpE,IAAI,EAAE;WACP;;;KAIR;IACDuE,UAAU,EAAE,sBAAsB;IAClCC,UAAU,EAAE;GACb,CAAC;AACJ;;SCriBgBa,WAAWA,CAACxL,MAAqB;EAC/CsK,gBAAgB,CAACtK,MAAM,CAAC;AAC1B;;;;"}
|
|
1
|
+
{"version":3,"file":"dnd-kit.esm.js","sources":["../src/util.ts","../src/sortable.tsx","../src/index.tsx"],"sourcesContent":["import {\n CodeComponentMeta,\n default as registerComponent,\n} from \"@plasmicapp/host/registerComponent\";\nimport { default as registerGlobalContext } from \"@plasmicapp/host/registerGlobalContext\";\nimport { default as registerToken } from \"@plasmicapp/host/registerToken\";\nimport React from \"react\";\n\nexport type Registerable = {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n registerToken: typeof registerToken;\n};\n\nexport function registerComponentHelper<T extends React.ComponentType<any>>(\n loader: Registerable | undefined,\n component: T,\n meta: CodeComponentMeta<React.ComponentProps<T>>\n) {\n if (loader) {\n loader.registerComponent(component, meta);\n } else {\n registerComponent(component, meta);\n }\n}\n","import React, { cloneElement, useEffect, useRef, useState } from \"react\";\nimport type { Key, ReactElement, ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { isElement } from \"react-dom/test-utils\";\nimport {\n closestCenter,\n DragOverlay,\n DndContext,\n KeyboardSensor,\n MouseSensor,\n TouchSensor,\n useSensor,\n useSensors,\n defaultDropAnimationSideEffects,\n} from \"@dnd-kit/core\";\nimport type {\n SortingStrategy,\n AnimateLayoutChanges,\n NewIndexGetter,\n} from \"@dnd-kit/sortable\";\nimport {\n arrayMove,\n useSortable,\n SortableContext,\n sortableKeyboardCoordinates,\n rectSortingStrategy,\n} from \"@dnd-kit/sortable\";\n\nimport { DataProvider, useSelector } from \"@plasmicapp/host\";\n\nimport type {\n DraggableSyntheticListeners,\n Active,\n Announcements,\n CollisionDetection,\n DropAnimation,\n KeyboardCoordinateGetter,\n Modifiers,\n MeasuringConfiguration,\n PointerActivationConstraint,\n ScreenReaderInstructions,\n UniqueIdentifier,\n} from \"@dnd-kit/core\";\nimport type { Transform } from \"@dnd-kit/utilities\";\nimport {\n restrictToFirstScrollableAncestor,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToVerticalAxis,\n restrictToWindowEdges,\n} from \"@dnd-kit/modifiers\";\nimport { Registerable, registerComponentHelper } from \"./util\";\n\nexport interface ItemProps {\n dragOverlay?: boolean;\n color?: string;\n disabled?: boolean;\n dragging?: boolean;\n height?: number;\n index?: number;\n fadeIn?: boolean;\n transform?: Transform | null;\n listeners?: DraggableSyntheticListeners;\n sorting?: boolean;\n style?: React.CSSProperties;\n transition?: string | null;\n wrapperStyle?: React.CSSProperties;\n value: React.ReactNode;\n renderItem?(\n args: {\n dragOverlay: boolean;\n dragging: boolean;\n sorting: boolean;\n index: number | undefined;\n fadeIn: boolean;\n listeners: DraggableSyntheticListeners;\n ref: React.Ref<HTMLElement>;\n style: React.CSSProperties | undefined;\n transform: ItemProps[\"transform\"];\n transition: ItemProps[\"transition\"];\n value: ItemProps[\"value\"];\n },\n currentItem: ItemProps[\"value\"]\n ): React.ReactElement;\n}\n\nexport const Item = React.memo(\n React.forwardRef<HTMLLIElement, ItemProps>(\n (\n {\n color,\n dragOverlay,\n dragging,\n disabled,\n fadeIn,\n height,\n index,\n listeners,\n renderItem = () => <div />,\n sorting,\n style,\n transition,\n transform,\n value,\n wrapperStyle,\n ...props\n },\n ref\n ) => {\n useEffect(() => {\n if (!dragOverlay) {\n return;\n }\n\n document.body.style.cursor = \"grabbing\";\n\n return () => {\n document.body.style.cursor = \"\";\n };\n }, [dragOverlay]);\n\n const child = renderItem(\n {\n dragOverlay: Boolean(dragOverlay),\n dragging: Boolean(dragging),\n sorting: Boolean(sorting),\n index,\n fadeIn: Boolean(fadeIn),\n listeners,\n ref,\n style,\n transform,\n transition,\n value,\n },\n value\n );\n\n return isElement(child)\n ? cloneElement(child, {\n ref,\n style: {\n transition: [transition].filter(Boolean).join(\", \"),\n transform: `translate3d(${transform?.x ?? 0}px, ${\n transform?.y ?? 0\n }px, 0) scaleX(${transform?.scaleX ?? 1}) scaleY(${\n transform?.scaleY ?? 1\n }`,\n },\n })\n : child;\n }\n )\n);\n\nexport interface SortableProps {\n onReorder?: (\n fromIndex: number,\n toIndex: number,\n newItems: any[],\n oldItems: any[]\n ) => void;\n themeResetClass?: string;\n activationConstraint?: PointerActivationConstraint;\n animateLayoutChanges?: AnimateLayoutChanges;\n adjustScale?: boolean;\n collisionDetection?: CollisionDetection;\n coordinateGetter?: KeyboardCoordinateGetter;\n Container?: any; // To-do: Fix me\n dropAnimation?: DropAnimation | null;\n getNewIndex?: NewIndexGetter;\n rowKey?: (item: any) => Key;\n itemCount?: number;\n items?: any[];\n measuring?: MeasuringConfiguration;\n modifiers?: Modifiers;\n renderItem?: any;\n removable?: boolean;\n reorderItems?: typeof arrayMove;\n strategy?: SortingStrategy;\n style?: React.CSSProperties;\n useDragOverlay?: boolean;\n modifierNames?: (\n | \"restrictToHorizontalAxis\"\n | \"restrictToVerticalAxis\"\n | \"restrictToWindowEdges\"\n | \"restrictToParentElement\"\n | \"restrictToFirstScrollableAncestor\"\n )[];\n getItemStyles?(args: {\n id: UniqueIdentifier;\n index: number;\n isSorting: boolean;\n isDragOverlay: boolean;\n overIndex: number;\n isDragging: boolean;\n }): React.CSSProperties;\n wrapperStyle?(args: {\n active: Pick<Active, \"id\"> | null;\n index: number;\n isDragging: boolean;\n id: UniqueIdentifier;\n }): React.CSSProperties;\n isDisabled?(id: UniqueIdentifier): boolean;\n className?: string;\n}\n\nconst dropAnimationConfig: DropAnimation = {\n sideEffects: defaultDropAnimationSideEffects({\n styles: {\n active: {\n opacity: \"0.5\",\n },\n },\n }),\n};\n\nconst screenReaderInstructions: ScreenReaderInstructions = {\n draggable: `\n To pick up a sortable item, press the space bar.\n While sorting, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n `,\n};\n\nexport const modifierByName = {\n restrictToVerticalAxis,\n restrictToWindowEdges,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToFirstScrollableAncestor,\n};\n\nexport function Sortable({\n className,\n style,\n activationConstraint,\n animateLayoutChanges,\n adjustScale = false,\n collisionDetection = closestCenter,\n coordinateGetter = sortableKeyboardCoordinates,\n dropAnimation = dropAnimationConfig,\n getNewIndex,\n rowKey = (item) => item.id,\n items: initialItems = [],\n measuring,\n modifiers,\n removable,\n renderItem,\n reorderItems = arrayMove,\n strategy = rectSortingStrategy,\n useDragOverlay = true,\n modifierNames,\n themeResetClass,\n onReorder,\n}: SortableProps) {\n modifiers =\n modifiers ?? (modifierNames ?? []).map((name) => modifierByName[name]);\n\n // This is the optimistic version.\n const [items, setItems] = useState<UniqueIdentifier[]>(() => initialItems);\n useEffect(() => {\n setItems(initialItems);\n }, [initialItems]);\n const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n const sensors = useSensors(\n useSensor(MouseSensor, {\n activationConstraint,\n }),\n useSensor(TouchSensor, {\n activationConstraint,\n }),\n useSensor(KeyboardSensor, {\n // Disable smooth scrolling in Cypress automated tests\n scrollBehavior: \"Cypress\" in globalThis ? \"auto\" : undefined,\n coordinateGetter,\n })\n );\n const isFirstAnnouncement = useRef(true);\n const getIndex = (id: UniqueIdentifier) =>\n items.findIndex((item) => rowKey(item) === id);\n const getPosition = (id: UniqueIdentifier) => getIndex(id) + 1;\n const activeIndex = activeId ? getIndex(activeId) : -1;\n const announcements: Announcements = {\n onDragStart({ active: { id } }) {\n return `Picked up sortable item ${String(\n id\n )}. Sortable item ${id} is in position ${getPosition(id)} of ${\n items.length\n }`;\n },\n onDragOver({ active, over }) {\n // In this specific use-case, the picked up item's `id` is always the same as the first `over` id.\n // The first `onDragOver` event therefore doesn't need to be announced, because it is called\n // immediately after the `onDragStart` announcement and is redundant.\n if (isFirstAnnouncement.current === true) {\n isFirstAnnouncement.current = false;\n return;\n }\n\n if (over) {\n return `Sortable item ${\n active.id\n } was moved into position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragEnd({ active, over }) {\n if (over) {\n return `Sortable item ${\n active.id\n } was dropped at position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragCancel({ active: { id } }) {\n return `Sorting was cancelled. Sortable item ${id} was dropped and returned to position ${getPosition(\n id\n )} of ${items.length}.`;\n },\n };\n useEffect(() => {\n if (!activeId) {\n isFirstAnnouncement.current = true;\n }\n }, [activeId]);\n\n return (\n <div className={className} style={style}>\n <DndContext\n accessibility={{\n announcements,\n screenReaderInstructions,\n }}\n sensors={sensors}\n collisionDetection={collisionDetection}\n onDragStart={({ active }) => {\n if (!active) {\n return;\n }\n\n setActiveId(active.id);\n }}\n onDragEnd={({ over }) => {\n setActiveId(null);\n\n if (over) {\n const overIndex = getIndex(over.id);\n const reordered = reorderItems(items, activeIndex, overIndex);\n onReorder?.(activeIndex, overIndex, reordered, items);\n if (activeIndex !== overIndex) {\n setItems((items) => reordered);\n }\n }\n }}\n onDragCancel={() => setActiveId(null)}\n measuring={measuring}\n modifiers={modifiers}\n >\n <SortableContext items={items.map(rowKey)} strategy={strategy}>\n {items.map((value, index) => (\n <SortableItem\n key={rowKey(value)}\n id={rowKey(value)}\n value={value}\n index={index}\n renderItem={renderItem}\n animateLayoutChanges={animateLayoutChanges}\n useDragOverlay={useDragOverlay}\n getNewIndex={getNewIndex}\n />\n ))}\n </SortableContext>\n {useDragOverlay && typeof document !== \"undefined\"\n ? createPortal(\n <DragOverlay\n adjustScale={adjustScale}\n dropAnimation={dropAnimation}\n >\n {activeId ? (\n <Item\n index={activeIndex}\n value={items[activeIndex]}\n renderItem={(...args) => (\n <div className={themeResetClass}>\n {renderItem(...args)}\n </div>\n )}\n dragOverlay\n />\n ) : null}\n </DragOverlay>,\n document.body\n )\n : null}\n </DndContext>\n </div>\n );\n}\n\ninterface SortableItemProps {\n animateLayoutChanges?: AnimateLayoutChanges;\n getNewIndex?: NewIndexGetter;\n id: UniqueIdentifier;\n index: number;\n useDragOverlay?: boolean;\n renderItem?(args: any): React.ReactElement;\n value?: any;\n}\n\nexport function SortableItem({\n animateLayoutChanges,\n getNewIndex,\n id,\n value,\n index,\n renderItem,\n useDragOverlay,\n}: SortableItemProps) {\n const sortableData = useSortable({\n id,\n animateLayoutChanges,\n getNewIndex,\n });\n const {\n attributes,\n isDragging,\n isSorting,\n listeners,\n setNodeRef,\n transform,\n transition,\n } = sortableData;\n\n return (\n <DataProvider hidden={true} name={\"sortableItem\"} data={sortableData}>\n <Item\n ref={setNodeRef}\n value={value}\n dragging={isDragging}\n sorting={isSorting}\n renderItem={renderItem}\n index={index}\n transform={transform}\n transition={transition}\n listeners={listeners}\n data-index={index}\n data-id={id}\n dragOverlay={!useDragOverlay && isDragging}\n {...attributes}\n />\n </DataProvider>\n );\n}\n\nexport function SortableHandle({ children }: { children?: ReactNode }) {\n const data = useSelector(\"sortableItem\");\n const child = React.Children.toArray(children)[0];\n return isElement(child)\n ? cloneElement(child as ReactElement, {\n ...data?.listeners,\n ref: data?.setActivatorNodeRef,\n tabIndex: 0,\n })\n : null;\n}\n\nexport function registerSortable(loader?: Registerable) {\n registerComponentHelper(loader, SortableHandle, {\n name: \"SortableHandle\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"text\",\n value: \"Handle\",\n },\n mergeWithParent: true,\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"SortableHandle\",\n });\n\n registerComponentHelper(loader, Sortable, {\n name: \"Sortable\",\n props: {\n items: {\n type: \"array\",\n defaultValue: [\n { id: 1, name: \"hello\" },\n { id: 2, name: \"world\" },\n ],\n },\n modifierNames: {\n displayName: \"Options\",\n type: \"choice\",\n multiSelect: true,\n options: Object.keys(modifierByName).map((v) => ({\n value: v,\n label:\n v[0].toUpperCase() + v.slice(1).replace(/([a-z])([A-Z])/g, \"$1 $2\"),\n })),\n },\n onReorder: {\n type: \"eventHandler\",\n argTypes: [\n {\n name: \"fromIndex\",\n type: \"number\",\n },\n {\n name: \"toIndex\",\n type: \"number\",\n },\n {\n name: \"newItems\",\n type: \"object\",\n },\n {\n name: \"oldItems\",\n type: \"object\",\n },\n ],\n },\n themeResetClass: {\n type: \"themeResetClass\",\n },\n renderItem: {\n type: \"slot\",\n renderPropParams: [\"sortableData\", \"currentItem\"],\n mergeWithParent: true,\n defaultValue: {\n type: \"hbox\",\n children: [\n {\n type: \"text\",\n value: \"Item\",\n },\n {\n type: \"component\",\n name: \"SortableHandle\",\n },\n ],\n },\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"Sortable\",\n });\n}\n","import { registerSortable } from \"./sortable\";\nimport { Registerable } from \"./util\";\n\nexport function registerAll(loader?: Registerable) {\n registerSortable(loader);\n}\n\nexport * from \"./sortable\";\n"],"names":["registerComponentHelper","loader","component","meta","registerComponent","Item","React","memo","forwardRef","_ref","ref","dragOverlay","dragging","disabled","fadeIn","height","index","listeners","_ref$renderItem","renderItem","sorting","style","transition","transform","value","wrapperStyle","props","_objectWithoutPropertiesLoose","_excluded","useEffect","document","body","cursor","child","Boolean","isElement","cloneElement","filter","join","_transform$x","x","_transform$y","y","_transform$scaleX","scaleX","_transform$scaleY","scaleY","dropAnimationConfig","sideEffects","defaultDropAnimationSideEffects","styles","active","opacity","screenReaderInstructions","draggable","modifierByName","restrictToVerticalAxis","restrictToWindowEdges","restrictToHorizontalAxis","restrictToParentElement","restrictToFirstScrollableAncestor","Sortable","_ref2","className","activationConstraint","animateLayoutChanges","_ref2$adjustScale","adjustScale","_ref2$collisionDetect","collisionDetection","closestCenter","_ref2$coordinateGette","coordinateGetter","sortableKeyboardCoordinates","_ref2$dropAnimation","dropAnimation","getNewIndex","_ref2$rowKey","rowKey","item","id","_ref2$items","items","initialItems","measuring","modifiers","removable","_ref2$reorderItems","reorderItems","arrayMove","_ref2$strategy","strategy","rectSortingStrategy","_ref2$useDragOverlay","useDragOverlay","modifierNames","themeResetClass","onReorder","_modifiers","map","name","_useState","useState","setItems","_useState2","activeId","setActiveId","sensors","useSensors","useSensor","MouseSensor","TouchSensor","KeyboardSensor","scrollBehavior","globalThis","undefined","isFirstAnnouncement","useRef","getIndex","findIndex","getPosition","activeIndex","announcements","onDragStart","_ref3","String","length","onDragOver","_ref4","over","current","onDragEnd","_ref5","onDragCancel","_ref6","DndContext","accessibility","_ref7","_ref8","overIndex","reordered","SortableContext","SortableItem","key","createPortal","DragOverlay","apply","arguments","_ref9","sortableData","useSortable","attributes","isDragging","isSorting","setNodeRef","DataProvider","hidden","data","SortableHandle","_ref10","children","useSelector","Children","toArray","_extends","setActivatorNodeRef","tabIndex","registerSortable","type","defaultValue","mergeWithParent","importPath","importName","displayName","multiSelect","options","Object","keys","v","label","toUpperCase","slice","replace","argTypes","renderPropParams","registerAll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;SAcgBA,uBAAuBA,CACrCC,MAAgC,EAChCC,SAAY,EACZC,IAAgD;EAEhD,IAAIF,MAAM,EAAE;IACVA,MAAM,CAACG,iBAAiB,CAACF,SAAS,EAAEC,IAAI,CAAC;GAC1C,MAAM;IACLC,iBAAiB,CAACF,SAAS,EAAEC,IAAI,CAAC;;AAEtC;;;ACxBA,IAsFaE,IAAI,gBAAGC,KAAK,CAACC,IAAI,cAC5BD,KAAK,CAACE,UAAU,CACd,UAAAC,IAAA,EAmBEC,GAAG;;MAhBDC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IACXC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,AACAC,MAAM,GAAAL,IAAA,CAANK,MAAM;IACNC,AACAC,KAAK,GAAAP,IAAA,CAALO,KAAK;IACLC,SAAS,GAAAR,IAAA,CAATQ,SAAS;IAAAC,eAAA,GAAAT,IAAA,CACTU,UAAU;IAAVA,UAAU,GAAAD,eAAA,cAAG;MAAA,OAAMZ,gCAAO;QAAAY,eAAA;IAC1BE,OAAO,GAAAX,IAAA,CAAPW,OAAO;IACPC,KAAK,GAAAZ,IAAA,CAALY,KAAK;IACLC,UAAU,GAAAb,IAAA,CAAVa,UAAU;IACVC,SAAS,GAAAd,IAAA,CAATc,SAAS;IACTC,KAAK,GAAAf,IAAA,CAALe,KAAK;IACLC,AACGC,KAAK,GAAAC,6BAAA,CAAAlB,IAAA,EAAAmB,SAAA;EAIVC,SAAS,CAAC;IACR,IAAI,CAAClB,WAAW,EAAE;MAChB;;IAGFmB,QAAQ,CAACC,IAAI,CAACV,KA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CAAC,CAACG,KAAK,CAAC,CAAC,CAAC,CAACC,OAAO,CAAC,iBAAiB,EAAE,OAAO;WACrE;SAAC;OACH;MACDrF,SAAS,EAAE;QACTuE,IAAI,EAAE,cAAc;QACpBe,QAAQ,EAAE,CACR;UACEnF,IAAI,EAAE,WAAW;UACjBoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,SAAS;UACfoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,UAAU;UAChBoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,UAAU;UAChBoE,IAAI,EAAE;SACP;OAEJ;MACDxE,eAAe,EAAE;QACfwE,IAAI,EAAE;OACP;MACDrJ,UAAU,EAAE;QACVqJ,IAAI,EAAE,MAAM;QACZgB,gBAAgB,EAAE,CAAC,cAAc,EAAE,aAAa,CAAC;QACjDd,eAAe,EAAE,IAAI;QACrBD,YAAY,EAAE;UACZD,IAAI,EAAE,MAAM;UACZR,QAAQ,EAAE,CACR;YACEQ,IAAI,EAAE,MAAM;YACZhJ,KAAK,EAAE;WACR,EACD;YACEgJ,IAAI,EAAE,WAAW;YACjBpE,IAAI,EAAE;WACP;;;KAIR;IACDuE,UAAU,EAAE,sBAAsB;IAClCC,UAAU,EAAE;GACb,CAAC;AACJ;;SCriBgBa,WAAWA,CAACxL,MAAqB;EAC/CsK,gBAAgB,CAACtK,MAAM,CAAC;AAC1B;;;;"}
|
package/dist/util.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CodeComponentMeta, default as registerComponent } from "@plasmicapp/host/registerComponent";
|
|
2
2
|
import { default as registerGlobalContext } from "@plasmicapp/host/registerGlobalContext";
|
|
3
3
|
import { default as registerToken } from "@plasmicapp/host/registerToken";
|
|
4
4
|
import React from "react";
|
|
@@ -7,4 +7,4 @@ export declare type Registerable = {
|
|
|
7
7
|
registerGlobalContext: typeof registerGlobalContext;
|
|
8
8
|
registerToken: typeof registerToken;
|
|
9
9
|
};
|
|
10
|
-
export declare function registerComponentHelper<T extends React.ComponentType<any>>(loader: Registerable | undefined, component: T, meta:
|
|
10
|
+
export declare function registerComponentHelper<T extends React.ComponentType<any>>(loader: Registerable | undefined, component: T, meta: CodeComponentMeta<React.ComponentProps<T>>): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicpkgs/dnd-kit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "Plasmic Spotify components.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"@dnd-kit/sortable": "^7.0.2",
|
|
50
50
|
"@dnd-kit/utilities": "^3.2.1"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "bbba4b6636e69a3441c6dbe4cefb860ed30e826f"
|
|
53
53
|
}
|