@react-spectrum/dnd 3.4.3 → 3.5.1

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.
@@ -31,7 +31,8 @@ function $e96ca2229d77f411$export$2cfc5be7a55829f6(options) {
31
31
  hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props) {
32
32
  return (0, $9NCiI$reactstatelydnd.useDraggableCollectionState)({
33
33
  ...props,
34
- ...options
34
+ ...options,
35
+ getItems: options.getItems
35
36
  });
36
37
  };
37
38
  hooks.useDraggableCollection = (0, $9NCiI$reactariadnd.useDraggableCollection);
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAiEM,SAAS,0CAAe,OAA2B;IACxD,IAAI,mBAAmB,CAAA,GAAA,oBAAM,EAAE;QAC7B,IAAI,UACF,MAAM,YACN,QAAQ,cACR,UAAU,aACV,SAAS,cACT,UAAU,YACV,QAAQ,iBACR,aAAa,EACb,GAAG;QAEL,IAAI,cAAc,CAAC,CAAC;QACpB,IAAI,cAAc,CAAC,CAAE,CAAA,UAAU,YAAY,cAAc,aAAa,UAAS;QAE/E,IAAI,QAAQ,CAAC;QACb,IAAI,aAAa;YACf,MAAM,2BAA2B,GAAG,SAAS,oCAAoC,KAAsC;gBACrH,OAAO,CAAA,GAAA,kDAA0B,EAAE;oBAAC,GAAG,KAAK;oBAAE,GAAG,OAAO;gBAAA;YAC1D;YACA,MAAM,sBAAsB,GAAG,CAAA,GAAA,0CAAqB;YACpD,MAAM,gBAAgB,GAAG,CAAA,GAAA,oCAAe;YACxC,MAAM,WAAW,GAAG,CAAA,GAAA,+BAAU;YAC9B,MAAM,aAAa,GAAG;QACxB;QAEA,IAAI,aAAa;YACf,MAAM,2BAA2B,GAAG,SAAS,oCAAoC,KAAsC;gBACrH,OAAO,CAAA,GAAA,kDAA0B,EAAE;oBAAC,GAAG,KAAK;oBAAE,GAAG,OAAO;gBAAA;YAC1D;YACA,MAAM,gBAAgB,GAAG,CAAA,GAAA,oCAAe;YACxC,MAAM,sBAAsB,GAAG,SAAS,+BAA+B,KAAiC,EAAE,KAA+B,EAAE,GAAkC;gBAC3K,OAAO,CAAA,GAAA,0CAAqB,EAAE;oBAAC,GAAG,KAAK;oBAAE,GAAG,OAAO;gBAAA,GAAG,OAAO;YAC/D;YACA,MAAM,gBAAgB,GAAG,CAAA,GAAA,oCAAe;QAC1C;QAEA,IAAI,eAAe,aACjB,MAAM,iBAAiB,GAAG,CAAA,GAAA,qCAAgB;QAG5C,OAAO;IACT,GAAG;QAAC;KAAQ;IAEZ,OAAO;QACL,kBAAkB;IACpB;AACF","sources":["packages/@react-spectrum/dnd/src/useDragAndDrop.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n DraggableCollectionOptions,\n DraggableItemProps,\n DraggableItemResult,\n DragPreview,\n DropIndicatorAria,\n DropIndicatorProps,\n DroppableCollectionOptions,\n DroppableCollectionResult,\n DroppableItemOptions,\n DroppableItemResult,\n isVirtualDragging,\n useDraggableCollection,\n useDraggableItem,\n useDropIndicator,\n useDroppableCollection,\n useDroppableItem\n} from '@react-aria/dnd';\nimport {DraggableCollectionProps, DragItem, DroppableCollectionProps, Key, RefObject} from '@react-types/shared';\nimport {\n DraggableCollectionState,\n DraggableCollectionStateOptions,\n DroppableCollectionState,\n DroppableCollectionStateOptions,\n useDraggableCollectionState,\n useDroppableCollectionState\n} from '@react-stately/dnd';\nimport {JSX, useMemo} from 'react';\n\ninterface DraggableCollectionStateOpts extends Omit<DraggableCollectionStateOptions, 'getItems'> {}\n\ninterface DragHooks {\n useDraggableCollectionState?: (props: DraggableCollectionStateOpts) => DraggableCollectionState,\n useDraggableCollection?: (props: DraggableCollectionOptions, state: DraggableCollectionState, ref: RefObject<HTMLElement | null>) => void,\n useDraggableItem?: (props: DraggableItemProps, state: DraggableCollectionState) => DraggableItemResult,\n DragPreview?: typeof DragPreview\n}\n\ninterface DropHooks {\n useDroppableCollectionState?: (props: DroppableCollectionStateOptions) => DroppableCollectionState,\n useDroppableCollection?: (props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DroppableCollectionResult,\n useDroppableItem?: (options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DroppableItemResult,\n useDropIndicator?: (props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DropIndicatorAria\n}\n\nexport interface DragAndDropHooks {\n /** Drag and drop hooks for the collection element. */\n dragAndDropHooks: DragHooks & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element}\n}\n\nexport interface DragAndDropOptions extends Omit<DraggableCollectionProps, 'preview' | 'getItems'>, DroppableCollectionProps {\n /**\n * A function that returns the items being dragged. If not specified, we assume that the collection is not draggable.\n * @default () => []\n */\n getItems?: (keys: Set<Key>) => DragItem[],\n /** Provide a custom drag preview. `draggedKey` represents the key of the item the user actually dragged. */\n renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element\n}\n\n/**\n * Provides the hooks required to enable drag and drop behavior for a drag and drop compatible React Spectrum component.\n */\nexport function useDragAndDrop(options: DragAndDropOptions): DragAndDropHooks {\n let dragAndDropHooks = useMemo(() => {\n let {\n onDrop,\n onInsert,\n onItemDrop,\n onReorder,\n onRootDrop,\n getItems,\n renderPreview\n } = options;\n\n let isDraggable = !!getItems;\n let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);\n\n let hooks = {} as DragHooks & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element};\n if (isDraggable) {\n hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props: DraggableCollectionStateOptions) {\n return useDraggableCollectionState({...props, ...options});\n };\n hooks.useDraggableCollection = useDraggableCollection;\n hooks.useDraggableItem = useDraggableItem;\n hooks.DragPreview = DragPreview;\n hooks.renderPreview = renderPreview;\n }\n\n if (isDroppable) {\n hooks.useDroppableCollectionState = function useDroppableCollectionStateOverride(props: DroppableCollectionStateOptions) {\n return useDroppableCollectionState({...props, ...options});\n };\n hooks.useDroppableItem = useDroppableItem;\n hooks.useDroppableCollection = function useDroppableCollectionOverride(props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) {\n return useDroppableCollection({...props, ...options}, state, ref);\n };\n hooks.useDropIndicator = useDropIndicator;\n }\n\n if (isDraggable || isDroppable) {\n hooks.isVirtualDragging = isVirtualDragging;\n }\n\n return hooks;\n }, [options]);\n\n return {\n dragAndDropHooks: dragAndDropHooks\n };\n}\n"],"names":[],"version":3,"file":"useDragAndDrop.main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAiEM,SAAS,0CAAe,OAA2B;IACxD,IAAI,mBAAmB,CAAA,GAAA,oBAAM,EAAE;QAC7B,IAAI,UACF,MAAM,YACN,QAAQ,cACR,UAAU,aACV,SAAS,cACT,UAAU,YACV,QAAQ,iBACR,aAAa,EACb,GAAG;QAEL,IAAI,cAAc,CAAC,CAAC;QACpB,IAAI,cAAc,CAAC,CAAE,CAAA,UAAU,YAAY,cAAc,aAAa,UAAS;QAE/E,IAAI,QAAQ,CAAC;QACb,IAAI,aAAa;YACf,MAAM,2BAA2B,GAAG,SAAS,oCAAoC,KAAmC;gBAClH,OAAO,CAAA,GAAA,kDAA0B,EAAE;oBAAC,GAAG,KAAK;oBAAE,GAAG,OAAO;oBAAE,UAAU,QAAQ,QAAQ;gBAAC;YACvF;YACA,MAAM,sBAAsB,GAAG,CAAA,GAAA,0CAAqB;YACpD,MAAM,gBAAgB,GAAG,CAAA,GAAA,oCAAe;YACxC,MAAM,WAAW,GAAG,CAAA,GAAA,+BAAU;YAC9B,MAAM,aAAa,GAAG;QACxB;QAEA,IAAI,aAAa;YACf,MAAM,2BAA2B,GAAG,SAAS,oCAAoC,KAAsC;gBACrH,OAAO,CAAA,GAAA,kDAA0B,EAAE;oBAAC,GAAG,KAAK;oBAAE,GAAG,OAAO;gBAAA;YAC1D;YACA,MAAM,gBAAgB,GAAG,CAAA,GAAA,oCAAe;YACxC,MAAM,sBAAsB,GAAG,SAAS,+BAA+B,KAAiC,EAAE,KAA+B,EAAE,GAAkC;gBAC3K,OAAO,CAAA,GAAA,0CAAqB,EAAE;oBAAC,GAAG,KAAK;oBAAE,GAAG,OAAO;gBAAA,GAAG,OAAO;YAC/D;YACA,MAAM,gBAAgB,GAAG,CAAA,GAAA,oCAAe;QAC1C;QAEA,IAAI,eAAe,aACjB,MAAM,iBAAiB,GAAG,CAAA,GAAA,qCAAgB;QAG5C,OAAO;IACT,GAAG;QAAC;KAAQ;IAEZ,OAAO;QACL,kBAAkB;IACpB;AACF","sources":["packages/@react-spectrum/dnd/src/useDragAndDrop.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n DraggableCollectionOptions,\n DraggableItemProps,\n DraggableItemResult,\n DragPreview,\n DropIndicatorAria,\n DropIndicatorProps,\n DroppableCollectionOptions,\n DroppableCollectionResult,\n DroppableItemOptions,\n DroppableItemResult,\n isVirtualDragging,\n useDraggableCollection,\n useDraggableItem,\n useDropIndicator,\n useDroppableCollection,\n useDroppableItem\n} from '@react-aria/dnd';\nimport {DraggableCollectionProps, DragItem, DroppableCollectionProps, Key, RefObject} from '@react-types/shared';\nimport {\n DraggableCollectionState,\n DraggableCollectionStateOptions,\n DroppableCollectionState,\n DroppableCollectionStateOptions,\n useDraggableCollectionState,\n useDroppableCollectionState\n} from '@react-stately/dnd';\nimport {JSX, useMemo} from 'react';\n\ninterface DraggableCollectionStateOpts extends Omit<DraggableCollectionStateOptions, 'getItems'> {}\n\ninterface DragHooks {\n useDraggableCollectionState?: (props: DraggableCollectionStateOpts) => DraggableCollectionState,\n useDraggableCollection?: (props: DraggableCollectionOptions, state: DraggableCollectionState, ref: RefObject<HTMLElement | null>) => void,\n useDraggableItem?: (props: DraggableItemProps, state: DraggableCollectionState) => DraggableItemResult,\n DragPreview?: typeof DragPreview\n}\n\ninterface DropHooks {\n useDroppableCollectionState?: (props: DroppableCollectionStateOptions) => DroppableCollectionState,\n useDroppableCollection?: (props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DroppableCollectionResult,\n useDroppableItem?: (options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DroppableItemResult,\n useDropIndicator?: (props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DropIndicatorAria\n}\n\nexport interface DragAndDropHooks {\n /** Drag and drop hooks for the collection element. */\n dragAndDropHooks: DragHooks & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element}\n}\n\nexport interface DragAndDropOptions extends Omit<DraggableCollectionProps, 'preview' | 'getItems'>, DroppableCollectionProps {\n /**\n * A function that returns the items being dragged. If not specified, we assume that the collection is not draggable.\n * @default () => []\n */\n getItems?: (keys: Set<Key>) => DragItem[],\n /** Provide a custom drag preview. `draggedKey` represents the key of the item the user actually dragged. */\n renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element\n}\n\n/**\n * Provides the hooks required to enable drag and drop behavior for a drag and drop compatible React Spectrum component.\n */\nexport function useDragAndDrop(options: DragAndDropOptions): DragAndDropHooks {\n let dragAndDropHooks = useMemo(() => {\n let {\n onDrop,\n onInsert,\n onItemDrop,\n onReorder,\n onRootDrop,\n getItems,\n renderPreview\n } = options;\n\n let isDraggable = !!getItems;\n let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);\n\n let hooks = {} as DragHooks & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element};\n if (isDraggable) {\n hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props: DraggableCollectionStateOpts) {\n return useDraggableCollectionState({...props, ...options, getItems: options.getItems!});\n };\n hooks.useDraggableCollection = useDraggableCollection;\n hooks.useDraggableItem = useDraggableItem;\n hooks.DragPreview = DragPreview;\n hooks.renderPreview = renderPreview;\n }\n\n if (isDroppable) {\n hooks.useDroppableCollectionState = function useDroppableCollectionStateOverride(props: DroppableCollectionStateOptions) {\n return useDroppableCollectionState({...props, ...options});\n };\n hooks.useDroppableItem = useDroppableItem;\n hooks.useDroppableCollection = function useDroppableCollectionOverride(props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) {\n return useDroppableCollection({...props, ...options}, state, ref);\n };\n hooks.useDropIndicator = useDropIndicator;\n }\n\n if (isDraggable || isDroppable) {\n hooks.isVirtualDragging = isVirtualDragging;\n }\n\n return hooks;\n }, [options]);\n\n return {\n dragAndDropHooks: dragAndDropHooks\n };\n}\n"],"names":[],"version":3,"file":"useDragAndDrop.main.js.map"}
@@ -25,7 +25,8 @@ function $8d44a09a765f4c9c$export$2cfc5be7a55829f6(options) {
25
25
  hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props) {
26
26
  return (0, $ejrPO$useDraggableCollectionState)({
27
27
  ...props,
28
- ...options
28
+ ...options,
29
+ getItems: options.getItems
29
30
  });
30
31
  };
31
32
  hooks.useDraggableCollection = (0, $ejrPO$useDraggableCollection);
@@ -25,7 +25,8 @@ function $8d44a09a765f4c9c$export$2cfc5be7a55829f6(options) {
25
25
  hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props) {
26
26
  return (0, $ejrPO$useDraggableCollectionState)({
27
27
  ...props,
28
- ...options
28
+ ...options,
29
+ getItems: options.getItems
29
30
  });
30
31
  };
31
32
  hooks.useDraggableCollection = (0, $ejrPO$useDraggableCollection);
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAiEM,SAAS,0CAAe,OAA2B;IACxD,IAAI,mBAAmB,CAAA,GAAA,cAAM,EAAE;QAC7B,IAAI,UACF,MAAM,YACN,QAAQ,cACR,UAAU,aACV,SAAS,cACT,UAAU,YACV,QAAQ,iBACR,aAAa,EACb,GAAG;QAEL,IAAI,cAAc,CAAC,CAAC;QACpB,IAAI,cAAc,CAAC,CAAE,CAAA,UAAU,YAAY,cAAc,aAAa,UAAS;QAE/E,IAAI,QAAQ,CAAC;QACb,IAAI,aAAa;YACf,MAAM,2BAA2B,GAAG,SAAS,oCAAoC,KAAsC;gBACrH,OAAO,CAAA,GAAA,kCAA0B,EAAE;oBAAC,GAAG,KAAK;oBAAE,GAAG,OAAO;gBAAA;YAC1D;YACA,MAAM,sBAAsB,GAAG,CAAA,GAAA,6BAAqB;YACpD,MAAM,gBAAgB,GAAG,CAAA,GAAA,uBAAe;YACxC,MAAM,WAAW,GAAG,CAAA,GAAA,kBAAU;YAC9B,MAAM,aAAa,GAAG;QACxB;QAEA,IAAI,aAAa;YACf,MAAM,2BAA2B,GAAG,SAAS,oCAAoC,KAAsC;gBACrH,OAAO,CAAA,GAAA,kCAA0B,EAAE;oBAAC,GAAG,KAAK;oBAAE,GAAG,OAAO;gBAAA;YAC1D;YACA,MAAM,gBAAgB,GAAG,CAAA,GAAA,uBAAe;YACxC,MAAM,sBAAsB,GAAG,SAAS,+BAA+B,KAAiC,EAAE,KAA+B,EAAE,GAAkC;gBAC3K,OAAO,CAAA,GAAA,6BAAqB,EAAE;oBAAC,GAAG,KAAK;oBAAE,GAAG,OAAO;gBAAA,GAAG,OAAO;YAC/D;YACA,MAAM,gBAAgB,GAAG,CAAA,GAAA,uBAAe;QAC1C;QAEA,IAAI,eAAe,aACjB,MAAM,iBAAiB,GAAG,CAAA,GAAA,wBAAgB;QAG5C,OAAO;IACT,GAAG;QAAC;KAAQ;IAEZ,OAAO;QACL,kBAAkB;IACpB;AACF","sources":["packages/@react-spectrum/dnd/src/useDragAndDrop.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n DraggableCollectionOptions,\n DraggableItemProps,\n DraggableItemResult,\n DragPreview,\n DropIndicatorAria,\n DropIndicatorProps,\n DroppableCollectionOptions,\n DroppableCollectionResult,\n DroppableItemOptions,\n DroppableItemResult,\n isVirtualDragging,\n useDraggableCollection,\n useDraggableItem,\n useDropIndicator,\n useDroppableCollection,\n useDroppableItem\n} from '@react-aria/dnd';\nimport {DraggableCollectionProps, DragItem, DroppableCollectionProps, Key, RefObject} from '@react-types/shared';\nimport {\n DraggableCollectionState,\n DraggableCollectionStateOptions,\n DroppableCollectionState,\n DroppableCollectionStateOptions,\n useDraggableCollectionState,\n useDroppableCollectionState\n} from '@react-stately/dnd';\nimport {JSX, useMemo} from 'react';\n\ninterface DraggableCollectionStateOpts extends Omit<DraggableCollectionStateOptions, 'getItems'> {}\n\ninterface DragHooks {\n useDraggableCollectionState?: (props: DraggableCollectionStateOpts) => DraggableCollectionState,\n useDraggableCollection?: (props: DraggableCollectionOptions, state: DraggableCollectionState, ref: RefObject<HTMLElement | null>) => void,\n useDraggableItem?: (props: DraggableItemProps, state: DraggableCollectionState) => DraggableItemResult,\n DragPreview?: typeof DragPreview\n}\n\ninterface DropHooks {\n useDroppableCollectionState?: (props: DroppableCollectionStateOptions) => DroppableCollectionState,\n useDroppableCollection?: (props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DroppableCollectionResult,\n useDroppableItem?: (options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DroppableItemResult,\n useDropIndicator?: (props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DropIndicatorAria\n}\n\nexport interface DragAndDropHooks {\n /** Drag and drop hooks for the collection element. */\n dragAndDropHooks: DragHooks & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element}\n}\n\nexport interface DragAndDropOptions extends Omit<DraggableCollectionProps, 'preview' | 'getItems'>, DroppableCollectionProps {\n /**\n * A function that returns the items being dragged. If not specified, we assume that the collection is not draggable.\n * @default () => []\n */\n getItems?: (keys: Set<Key>) => DragItem[],\n /** Provide a custom drag preview. `draggedKey` represents the key of the item the user actually dragged. */\n renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element\n}\n\n/**\n * Provides the hooks required to enable drag and drop behavior for a drag and drop compatible React Spectrum component.\n */\nexport function useDragAndDrop(options: DragAndDropOptions): DragAndDropHooks {\n let dragAndDropHooks = useMemo(() => {\n let {\n onDrop,\n onInsert,\n onItemDrop,\n onReorder,\n onRootDrop,\n getItems,\n renderPreview\n } = options;\n\n let isDraggable = !!getItems;\n let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);\n\n let hooks = {} as DragHooks & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element};\n if (isDraggable) {\n hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props: DraggableCollectionStateOptions) {\n return useDraggableCollectionState({...props, ...options});\n };\n hooks.useDraggableCollection = useDraggableCollection;\n hooks.useDraggableItem = useDraggableItem;\n hooks.DragPreview = DragPreview;\n hooks.renderPreview = renderPreview;\n }\n\n if (isDroppable) {\n hooks.useDroppableCollectionState = function useDroppableCollectionStateOverride(props: DroppableCollectionStateOptions) {\n return useDroppableCollectionState({...props, ...options});\n };\n hooks.useDroppableItem = useDroppableItem;\n hooks.useDroppableCollection = function useDroppableCollectionOverride(props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) {\n return useDroppableCollection({...props, ...options}, state, ref);\n };\n hooks.useDropIndicator = useDropIndicator;\n }\n\n if (isDraggable || isDroppable) {\n hooks.isVirtualDragging = isVirtualDragging;\n }\n\n return hooks;\n }, [options]);\n\n return {\n dragAndDropHooks: dragAndDropHooks\n };\n}\n"],"names":[],"version":3,"file":"useDragAndDrop.module.js.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAiEM,SAAS,0CAAe,OAA2B;IACxD,IAAI,mBAAmB,CAAA,GAAA,cAAM,EAAE;QAC7B,IAAI,UACF,MAAM,YACN,QAAQ,cACR,UAAU,aACV,SAAS,cACT,UAAU,YACV,QAAQ,iBACR,aAAa,EACb,GAAG;QAEL,IAAI,cAAc,CAAC,CAAC;QACpB,IAAI,cAAc,CAAC,CAAE,CAAA,UAAU,YAAY,cAAc,aAAa,UAAS;QAE/E,IAAI,QAAQ,CAAC;QACb,IAAI,aAAa;YACf,MAAM,2BAA2B,GAAG,SAAS,oCAAoC,KAAmC;gBAClH,OAAO,CAAA,GAAA,kCAA0B,EAAE;oBAAC,GAAG,KAAK;oBAAE,GAAG,OAAO;oBAAE,UAAU,QAAQ,QAAQ;gBAAC;YACvF;YACA,MAAM,sBAAsB,GAAG,CAAA,GAAA,6BAAqB;YACpD,MAAM,gBAAgB,GAAG,CAAA,GAAA,uBAAe;YACxC,MAAM,WAAW,GAAG,CAAA,GAAA,kBAAU;YAC9B,MAAM,aAAa,GAAG;QACxB;QAEA,IAAI,aAAa;YACf,MAAM,2BAA2B,GAAG,SAAS,oCAAoC,KAAsC;gBACrH,OAAO,CAAA,GAAA,kCAA0B,EAAE;oBAAC,GAAG,KAAK;oBAAE,GAAG,OAAO;gBAAA;YAC1D;YACA,MAAM,gBAAgB,GAAG,CAAA,GAAA,uBAAe;YACxC,MAAM,sBAAsB,GAAG,SAAS,+BAA+B,KAAiC,EAAE,KAA+B,EAAE,GAAkC;gBAC3K,OAAO,CAAA,GAAA,6BAAqB,EAAE;oBAAC,GAAG,KAAK;oBAAE,GAAG,OAAO;gBAAA,GAAG,OAAO;YAC/D;YACA,MAAM,gBAAgB,GAAG,CAAA,GAAA,uBAAe;QAC1C;QAEA,IAAI,eAAe,aACjB,MAAM,iBAAiB,GAAG,CAAA,GAAA,wBAAgB;QAG5C,OAAO;IACT,GAAG;QAAC;KAAQ;IAEZ,OAAO;QACL,kBAAkB;IACpB;AACF","sources":["packages/@react-spectrum/dnd/src/useDragAndDrop.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n DraggableCollectionOptions,\n DraggableItemProps,\n DraggableItemResult,\n DragPreview,\n DropIndicatorAria,\n DropIndicatorProps,\n DroppableCollectionOptions,\n DroppableCollectionResult,\n DroppableItemOptions,\n DroppableItemResult,\n isVirtualDragging,\n useDraggableCollection,\n useDraggableItem,\n useDropIndicator,\n useDroppableCollection,\n useDroppableItem\n} from '@react-aria/dnd';\nimport {DraggableCollectionProps, DragItem, DroppableCollectionProps, Key, RefObject} from '@react-types/shared';\nimport {\n DraggableCollectionState,\n DraggableCollectionStateOptions,\n DroppableCollectionState,\n DroppableCollectionStateOptions,\n useDraggableCollectionState,\n useDroppableCollectionState\n} from '@react-stately/dnd';\nimport {JSX, useMemo} from 'react';\n\ninterface DraggableCollectionStateOpts extends Omit<DraggableCollectionStateOptions, 'getItems'> {}\n\ninterface DragHooks {\n useDraggableCollectionState?: (props: DraggableCollectionStateOpts) => DraggableCollectionState,\n useDraggableCollection?: (props: DraggableCollectionOptions, state: DraggableCollectionState, ref: RefObject<HTMLElement | null>) => void,\n useDraggableItem?: (props: DraggableItemProps, state: DraggableCollectionState) => DraggableItemResult,\n DragPreview?: typeof DragPreview\n}\n\ninterface DropHooks {\n useDroppableCollectionState?: (props: DroppableCollectionStateOptions) => DroppableCollectionState,\n useDroppableCollection?: (props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DroppableCollectionResult,\n useDroppableItem?: (options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DroppableItemResult,\n useDropIndicator?: (props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DropIndicatorAria\n}\n\nexport interface DragAndDropHooks {\n /** Drag and drop hooks for the collection element. */\n dragAndDropHooks: DragHooks & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element}\n}\n\nexport interface DragAndDropOptions extends Omit<DraggableCollectionProps, 'preview' | 'getItems'>, DroppableCollectionProps {\n /**\n * A function that returns the items being dragged. If not specified, we assume that the collection is not draggable.\n * @default () => []\n */\n getItems?: (keys: Set<Key>) => DragItem[],\n /** Provide a custom drag preview. `draggedKey` represents the key of the item the user actually dragged. */\n renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element\n}\n\n/**\n * Provides the hooks required to enable drag and drop behavior for a drag and drop compatible React Spectrum component.\n */\nexport function useDragAndDrop(options: DragAndDropOptions): DragAndDropHooks {\n let dragAndDropHooks = useMemo(() => {\n let {\n onDrop,\n onInsert,\n onItemDrop,\n onReorder,\n onRootDrop,\n getItems,\n renderPreview\n } = options;\n\n let isDraggable = !!getItems;\n let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);\n\n let hooks = {} as DragHooks & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element};\n if (isDraggable) {\n hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props: DraggableCollectionStateOpts) {\n return useDraggableCollectionState({...props, ...options, getItems: options.getItems!});\n };\n hooks.useDraggableCollection = useDraggableCollection;\n hooks.useDraggableItem = useDraggableItem;\n hooks.DragPreview = DragPreview;\n hooks.renderPreview = renderPreview;\n }\n\n if (isDroppable) {\n hooks.useDroppableCollectionState = function useDroppableCollectionStateOverride(props: DroppableCollectionStateOptions) {\n return useDroppableCollectionState({...props, ...options});\n };\n hooks.useDroppableItem = useDroppableItem;\n hooks.useDroppableCollection = function useDroppableCollectionOverride(props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) {\n return useDroppableCollection({...props, ...options}, state, ref);\n };\n hooks.useDropIndicator = useDropIndicator;\n }\n\n if (isDraggable || isDroppable) {\n hooks.isVirtualDragging = isVirtualDragging;\n }\n\n return hooks;\n }, [options]);\n\n return {\n dragAndDropHooks: dragAndDropHooks\n };\n}\n"],"names":[],"version":3,"file":"useDragAndDrop.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-spectrum/dnd",
3
- "version": "3.4.3",
3
+ "version": "3.5.1",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -36,9 +36,9 @@
36
36
  "url": "https://github.com/adobe/react-spectrum"
37
37
  },
38
38
  "dependencies": {
39
- "@react-aria/dnd": "^3.7.4",
40
- "@react-stately/dnd": "^3.4.3",
41
- "@react-types/shared": "^3.25.0",
39
+ "@react-aria/dnd": "^3.8.1",
40
+ "@react-stately/dnd": "^3.5.1",
41
+ "@react-types/shared": "^3.27.0",
42
42
  "@swc/helpers": "^0.5.0"
43
43
  },
44
44
  "devDependencies": {
@@ -46,11 +46,11 @@
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@react-spectrum/provider": "^3.0.0",
49
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
50
- "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
49
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
50
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
54
54
  },
55
- "gitHead": "8e0a28d188cdbdbd2b32296fa034b1b02ddde229"
55
+ "gitHead": "09e7f44bebdc9d89122926b2b439a0a38a2814ea"
56
56
  }
@@ -90,8 +90,8 @@ export function useDragAndDrop(options: DragAndDropOptions): DragAndDropHooks {
90
90
 
91
91
  let hooks = {} as DragHooks & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element};
92
92
  if (isDraggable) {
93
- hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props: DraggableCollectionStateOptions) {
94
- return useDraggableCollectionState({...props, ...options});
93
+ hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props: DraggableCollectionStateOpts) {
94
+ return useDraggableCollectionState({...props, ...options, getItems: options.getItems!});
95
95
  };
96
96
  hooks.useDraggableCollection = useDraggableCollection;
97
97
  hooks.useDraggableItem = useDraggableItem;