@react-stately/dnd 3.3.2-nightly.4701 → 3.3.2-nightly.4704

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.
package/dist/types.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { Collection, DraggableCollectionEndEvent, DraggableCollectionProps, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, Key, Node, DragTypes, DroppableCollectionProps, DropTarget } from "@react-types/shared";
1
+ import { Collection, DraggableCollectionEndEvent, DraggableCollectionProps, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, Key, Node, RefObject, DragTypes, DroppableCollectionProps, DropTarget } from "@react-types/shared";
2
2
  import { MultipleSelectionManager } from "@react-stately/selection";
3
- import { RefObject } from "react";
4
3
  export interface DraggableCollectionStateOptions extends DraggableCollectionProps {
5
4
  /** A collection of items. */
6
5
  collection: Collection<Node<unknown>>;
@@ -1 +1 @@
1
- {"mappings":";;;AAgBA,gDAAiD,SAAQ,wBAAwB;IAC/E,6BAA6B;IAC7B,UAAU,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;IACtC,sEAAsE;IACtE,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C,kDAAkD;IAClD,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;IACE,6BAA6B;IAC7B,UAAU,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;IACtC,sEAAsE;IACtE,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C,iDAAiD;IACjD,UAAU,EAAE,GAAG,GAAG,IAAI,CAAC;IACvB,8DAA8D;IAC9D,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gEAAgE;IAChE,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC;IAC9B,mGAAmG;IACnG,cAAc,CAAC,GAAG,EA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AE,OAAO,CAAC;IACrB,oCAAoC;IACpC,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,iFAAiF;IACjF,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC;IAC1C,2DAA2D;IAC3D,gBAAgB,CAAC,CAAC,EAAE,kBAAkB,GAAG,aAAa,CAAA;CACvD;AAED;;GAEG;AACH,4CAA4C,KAAK,EAAE,+BAA+B,GAAG,wBAAwB,CAsH5G","sources":["packages/@react-stately/dnd/src/packages/@react-stately/dnd/src/useDraggableCollectionState.ts","packages/@react-stately/dnd/src/packages/@react-stately/dnd/src/useDroppableCollectionState.ts","packages/@react-stately/dnd/src/packages/@react-stately/dnd/src/index.ts","packages/@react-stately/dnd/src/index.ts"],"sourcesContent":[null,null,null,"/*\n * Copyright 2020 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\nexport type {DraggableCollectionStateOptions, DraggableCollectionState} from './useDraggableCollectionState';\nexport type {DroppableCollectionStateOptions, DroppableCollectionState} from './useDroppableCollectionState';\nexport {useDraggableCollectionState} from './useDraggableCollectionState';\nexport {useDroppableCollectionState} from './useDroppableCollectionState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;AAgBA,gDAAiD,SAAQ,wBAAwB;IAC/E,6BAA6B;IAC7B,UAAU,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;IACtC,sEAAsE;IACtE,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C,kDAAkD;IAClD,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;IACE,6BAA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H,6BAA6B;IAC7B,UAAU,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;IACtC,sEAAsE;IACtE,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C,kDAAkD;IAClD,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;IACE,6BAA6B;IAC7B,UAAU,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;IACtC,sEAAsE;IACtE,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C,+BAA+B;IAC/B,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAC1B,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oCAAoC;IACpC,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,iFAAiF;IACjF,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC;IAC1C,2DAA2D;IAC3D,gBAAgB,CAAC,CAAC,EAAE,kBAAkB,GAAG,aAAa,CAAA;CACvD;AAED;;GAEG;AACH,4CAA4C,KAAK,EAAE,+BAA+B,GAAG,wBAAwB,CAsH5G","sources":["packages/@react-stately/dnd/src/packages/@react-stately/dnd/src/useDraggableCollectionState.ts","packages/@react-stately/dnd/src/packages/@react-stately/dnd/src/useDroppableCollectionState.ts","packages/@react-stately/dnd/src/packages/@react-stately/dnd/src/index.ts","packages/@react-stately/dnd/src/index.ts"],"sourcesContent":[null,null,null,"/*\n * Copyright 2020 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\nexport type {DraggableCollectionStateOptions, DraggableCollectionState} from './useDraggableCollectionState';\nexport type {DroppableCollectionStateOptions, DroppableCollectionState} from './useDroppableCollectionState';\nexport {useDraggableCollectionState} from './useDraggableCollectionState';\nexport {useDroppableCollectionState} from './useDroppableCollectionState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AA+CM,SAAS,0CAA4B,KAAsC;IAChF,IAAI,YACF,QAAQ,cACR,UAAU,cACV,UAAU,oBACV,gBAAgB,eAChB,WAAW,cACX,UAAU,aACV,SAAS,WACT,OAAO,4BACP,wBAAwB,EACzB,GAAG;IACJ,IAAI,GAAG,YAAY,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC/B,IAAI,eAAe,CAAA,GAAA,mBAAK,EAAE,IAAI;IAC9B,IAAI,aAAa,CAAA,GAAA,mBAAK,EAAE;IACxB,IAAI,UAAU,CAAC;QACb,mFAAmF;QACnF,qFAAqF;QACrF,uDAAuD;QACvD,IAAI,OAAO,IAAI,IACb,iBAAiB,UAAU,CAAC,OACxB,IAAI,IAAI;eAAI,iBAAiB,YAAY;SAAC,CAAC,MAAM,CAAC,CAAA,MAAO,CAAC,CAAC,WAAW,OAAO,CAAC,SAC9E,EAAE;QAGR,KAAK,GAAG,CAAC;QACT,OAAO;IACT;IAEA,OAAO;oBACL;0BACA;QACA,IAAI,cAAa;YACf,OAAO,WAAW,OAAO;QAC3B;QACA,IAAI,gBAAe;YACjB,OAAO,aAAa,OAAO;QAC7B;QACA,YAAW,GAAG;YACZ,OAAO,aAAa,OAAO,CAAC,GAAG,CAAC;QAClC;QACA,gBAAgB;QAChB,UAAS,GAAG;YACV,OAAO,SAAS,QAAQ;QAC1B;oBACA;iBACA;kCACA;QACA,WAAU,GAAG,EAAE,KAAK;YAClB,IAAI,OAAO,QAAQ;YACnB,aAAa,OAAO,GAAG;YACvB,WAAW,OAAO,GAAG;YACrB,iBAAiB,UAAU,CAAC;YAC5B,YAAY;YACZ,IAAI,OAAO,gBAAgB,YACzB,YAAY;gBACV,GAAG,KAAK;sBACR;YACF;QAEJ;QACA,UAAS,KAAK;YACZ,IAAI,OAAO,eAAe,YACxB,WAAW;gBACT,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;YAC5B;QAEJ;QACA,SAAQ,KAAK;YACX,IAAI,cACF,UAAU,EACX,GAAG;YAEJ,IAAI,OAAO,cAAc,YACvB,UAAU;gBACR,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;4BAC1B;YACF;YAGF,aAAa,OAAO,GAAG,IAAI;YAC3B,WAAW,OAAO,GAAG;YACrB,YAAY;QACd;IACF;AACF","sources":["packages/@react-stately/dnd/src/useDraggableCollectionState.ts"],"sourcesContent":["/*\n * Copyright 2020 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 {Collection, DraggableCollectionEndEvent, DraggableCollectionProps, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, Key, Node} from '@react-types/shared';\nimport {MultipleSelectionManager} from '@react-stately/selection';\nimport {RefObject, useRef, useState} from 'react';\n\nexport interface DraggableCollectionStateOptions extends DraggableCollectionProps {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** Whether the drag events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface DraggableCollectionState {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** The key of the item that initiated a drag. */\n draggedKey: Key | null,\n /** The keys of the items that are currently being dragged. */\n draggingKeys: Set<Key>,\n /** Whether drag events are disabled. */\n isDisabled?: boolean,\n /** Returns whether the given key is currently being dragged. */\n isDragging(key: Key): boolean,\n /** Returns the keys of the items that will be dragged with the given key (e.g. selected items). */\n getKeysForDrag(key: Key): Set<Key>,\n /** Returns the items to drag for the given key. */\n getItems(key: Key): DragItem[],\n /** The ref of the element that will be rendered as the drag preview while dragging. */\n preview?: RefObject<DragPreviewRenderer | null>,\n /** Function that returns the drop operations that are allowed for the dragged items. If not provided, all drop operations are allowed. */\n getAllowedDropOperations?: () => DropOperation[],\n /** Begins a drag for the given key. This triggers the onDragStart event. */\n startDrag(key: Key, event: DragStartEvent): void,\n /** Triggers an onDragMove event. */\n moveDrag(event: DragMoveEvent): void,\n /** Ends the current drag, and emits an onDragEnd event. */\n endDrag(event: DraggableCollectionEndEvent): void\n}\n\n/**\n * Manages state for a draggable collection.\n */\nexport function useDraggableCollectionState(props: DraggableCollectionStateOptions): DraggableCollectionState {\n let {\n getItems,\n isDisabled,\n collection,\n selectionManager,\n onDragStart,\n onDragMove,\n onDragEnd,\n preview,\n getAllowedDropOperations\n } = props;\n let [, setDragging] = useState(false);\n let draggingKeys = useRef(new Set<Key>());\n let draggedKey = useRef(null);\n let getKeys = (key: Key) => {\n // The clicked item is always added to the drag. If it is selected, then all of the\n // other selected items are also dragged. If it is not selected, the only the clicked\n // item is dragged. This matches native macOS behavior.\n let keys = new Set(\n selectionManager.isSelected(key)\n ? new Set([...selectionManager.selectedKeys].filter(key => !!collection.getItem(key)))\n : []\n );\n\n keys.add(key);\n return keys;\n };\n\n return {\n collection,\n selectionManager,\n get draggedKey() {\n return draggedKey.current;\n },\n get draggingKeys() {\n return draggingKeys.current;\n },\n isDragging(key) {\n return draggingKeys.current.has(key);\n },\n getKeysForDrag: getKeys,\n getItems(key) {\n return getItems(getKeys(key));\n },\n isDisabled,\n preview,\n getAllowedDropOperations,\n startDrag(key, event) {\n let keys = getKeys(key);\n draggingKeys.current = keys;\n draggedKey.current = key;\n selectionManager.setFocused(false);\n setDragging(true);\n if (typeof onDragStart === 'function') {\n onDragStart({\n ...event,\n keys\n });\n }\n },\n moveDrag(event) {\n if (typeof onDragMove === 'function') {\n onDragMove({\n ...event,\n keys: draggingKeys.current\n });\n }\n },\n endDrag(event) {\n let {\n isInternal\n } = event;\n\n if (typeof onDragEnd === 'function') {\n onDragEnd({\n ...event,\n keys: draggingKeys.current,\n isInternal\n });\n }\n\n draggingKeys.current = new Set();\n draggedKey.current = null;\n setDragging(false);\n }\n };\n}\n"],"names":[],"version":3,"file":"useDraggableCollectionState.main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AA+CM,SAAS,0CAA4B,KAAsC;IAChF,IAAI,YACF,QAAQ,cACR,UAAU,cACV,UAAU,oBACV,gBAAgB,eAChB,WAAW,cACX,UAAU,aACV,SAAS,WACT,OAAO,4BACP,wBAAwB,EACzB,GAAG;IACJ,IAAI,GAAG,YAAY,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC/B,IAAI,eAAe,CAAA,GAAA,mBAAK,EAAE,IAAI;IAC9B,IAAI,aAAa,CAAA,GAAA,mBAAK,EAAE;IACxB,IAAI,UAAU,CAAC;QACb,mFAAmF;QACnF,qFAAqF;QACrF,uDAAuD;QACvD,IAAI,OAAO,IAAI,IACb,iBAAiB,UAAU,CAAC,OACxB,IAAI,IAAI;eAAI,iBAAiB,YAAY;SAAC,CAAC,MAAM,CAAC,CAAA,MAAO,CAAC,CAAC,WAAW,OAAO,CAAC,SAC9E,EAAE;QAGR,KAAK,GAAG,CAAC;QACT,OAAO;IACT;IAEA,OAAO;oBACL;0BACA;QACA,IAAI,cAAa;YACf,OAAO,WAAW,OAAO;QAC3B;QACA,IAAI,gBAAe;YACjB,OAAO,aAAa,OAAO;QAC7B;QACA,YAAW,GAAG;YACZ,OAAO,aAAa,OAAO,CAAC,GAAG,CAAC;QAClC;QACA,gBAAgB;QAChB,UAAS,GAAG;YACV,OAAO,SAAS,QAAQ;QAC1B;oBACA;iBACA;kCACA;QACA,WAAU,GAAG,EAAE,KAAK;YAClB,IAAI,OAAO,QAAQ;YACnB,aAAa,OAAO,GAAG;YACvB,WAAW,OAAO,GAAG;YACrB,iBAAiB,UAAU,CAAC;YAC5B,YAAY;YACZ,IAAI,OAAO,gBAAgB,YACzB,YAAY;gBACV,GAAG,KAAK;sBACR;YACF;QAEJ;QACA,UAAS,KAAK;YACZ,IAAI,OAAO,eAAe,YACxB,WAAW;gBACT,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;YAC5B;QAEJ;QACA,SAAQ,KAAK;YACX,IAAI,cACF,UAAU,EACX,GAAG;YAEJ,IAAI,OAAO,cAAc,YACvB,UAAU;gBACR,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;4BAC1B;YACF;YAGF,aAAa,OAAO,GAAG,IAAI;YAC3B,WAAW,OAAO,GAAG;YACrB,YAAY;QACd;IACF;AACF","sources":["packages/@react-stately/dnd/src/useDraggableCollectionState.ts"],"sourcesContent":["/*\n * Copyright 2020 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 {Collection, DraggableCollectionEndEvent, DraggableCollectionProps, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, Key, Node, RefObject} from '@react-types/shared';\nimport {MultipleSelectionManager} from '@react-stately/selection';\nimport {useRef, useState} from 'react';\n\nexport interface DraggableCollectionStateOptions extends DraggableCollectionProps {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** Whether the drag events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface DraggableCollectionState {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** The key of the item that initiated a drag. */\n draggedKey: Key | null,\n /** The keys of the items that are currently being dragged. */\n draggingKeys: Set<Key>,\n /** Whether drag events are disabled. */\n isDisabled?: boolean,\n /** Returns whether the given key is currently being dragged. */\n isDragging(key: Key): boolean,\n /** Returns the keys of the items that will be dragged with the given key (e.g. selected items). */\n getKeysForDrag(key: Key): Set<Key>,\n /** Returns the items to drag for the given key. */\n getItems(key: Key): DragItem[],\n /** The ref of the element that will be rendered as the drag preview while dragging. */\n preview?: RefObject<DragPreviewRenderer | null>,\n /** Function that returns the drop operations that are allowed for the dragged items. If not provided, all drop operations are allowed. */\n getAllowedDropOperations?: () => DropOperation[],\n /** Begins a drag for the given key. This triggers the onDragStart event. */\n startDrag(key: Key, event: DragStartEvent): void,\n /** Triggers an onDragMove event. */\n moveDrag(event: DragMoveEvent): void,\n /** Ends the current drag, and emits an onDragEnd event. */\n endDrag(event: DraggableCollectionEndEvent): void\n}\n\n/**\n * Manages state for a draggable collection.\n */\nexport function useDraggableCollectionState(props: DraggableCollectionStateOptions): DraggableCollectionState {\n let {\n getItems,\n isDisabled,\n collection,\n selectionManager,\n onDragStart,\n onDragMove,\n onDragEnd,\n preview,\n getAllowedDropOperations\n } = props;\n let [, setDragging] = useState(false);\n let draggingKeys = useRef(new Set<Key>());\n let draggedKey = useRef(null);\n let getKeys = (key: Key) => {\n // The clicked item is always added to the drag. If it is selected, then all of the\n // other selected items are also dragged. If it is not selected, the only the clicked\n // item is dragged. This matches native macOS behavior.\n let keys = new Set(\n selectionManager.isSelected(key)\n ? new Set([...selectionManager.selectedKeys].filter(key => !!collection.getItem(key)))\n : []\n );\n\n keys.add(key);\n return keys;\n };\n\n return {\n collection,\n selectionManager,\n get draggedKey() {\n return draggedKey.current;\n },\n get draggingKeys() {\n return draggingKeys.current;\n },\n isDragging(key) {\n return draggingKeys.current.has(key);\n },\n getKeysForDrag: getKeys,\n getItems(key) {\n return getItems(getKeys(key));\n },\n isDisabled,\n preview,\n getAllowedDropOperations,\n startDrag(key, event) {\n let keys = getKeys(key);\n draggingKeys.current = keys;\n draggedKey.current = key;\n selectionManager.setFocused(false);\n setDragging(true);\n if (typeof onDragStart === 'function') {\n onDragStart({\n ...event,\n keys\n });\n }\n },\n moveDrag(event) {\n if (typeof onDragMove === 'function') {\n onDragMove({\n ...event,\n keys: draggingKeys.current\n });\n }\n },\n endDrag(event) {\n let {\n isInternal\n } = event;\n\n if (typeof onDragEnd === 'function') {\n onDragEnd({\n ...event,\n keys: draggingKeys.current,\n isInternal\n });\n }\n\n draggingKeys.current = new Set();\n draggedKey.current = null;\n setDragging(false);\n }\n };\n}\n"],"names":[],"version":3,"file":"useDraggableCollectionState.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AA+CM,SAAS,0CAA4B,KAAsC;IAChF,IAAI,YACF,QAAQ,cACR,UAAU,cACV,UAAU,oBACV,gBAAgB,eAChB,WAAW,cACX,UAAU,aACV,SAAS,WACT,OAAO,4BACP,wBAAwB,EACzB,GAAG;IACJ,IAAI,GAAG,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE;IAC/B,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE,IAAI;IAC9B,IAAI,aAAa,CAAA,GAAA,aAAK,EAAE;IACxB,IAAI,UAAU,CAAC;QACb,mFAAmF;QACnF,qFAAqF;QACrF,uDAAuD;QACvD,IAAI,OAAO,IAAI,IACb,iBAAiB,UAAU,CAAC,OACxB,IAAI,IAAI;eAAI,iBAAiB,YAAY;SAAC,CAAC,MAAM,CAAC,CAAA,MAAO,CAAC,CAAC,WAAW,OAAO,CAAC,SAC9E,EAAE;QAGR,KAAK,GAAG,CAAC;QACT,OAAO;IACT;IAEA,OAAO;oBACL;0BACA;QACA,IAAI,cAAa;YACf,OAAO,WAAW,OAAO;QAC3B;QACA,IAAI,gBAAe;YACjB,OAAO,aAAa,OAAO;QAC7B;QACA,YAAW,GAAG;YACZ,OAAO,aAAa,OAAO,CAAC,GAAG,CAAC;QAClC;QACA,gBAAgB;QAChB,UAAS,GAAG;YACV,OAAO,SAAS,QAAQ;QAC1B;oBACA;iBACA;kCACA;QACA,WAAU,GAAG,EAAE,KAAK;YAClB,IAAI,OAAO,QAAQ;YACnB,aAAa,OAAO,GAAG;YACvB,WAAW,OAAO,GAAG;YACrB,iBAAiB,UAAU,CAAC;YAC5B,YAAY;YACZ,IAAI,OAAO,gBAAgB,YACzB,YAAY;gBACV,GAAG,KAAK;sBACR;YACF;QAEJ;QACA,UAAS,KAAK;YACZ,IAAI,OAAO,eAAe,YACxB,WAAW;gBACT,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;YAC5B;QAEJ;QACA,SAAQ,KAAK;YACX,IAAI,cACF,UAAU,EACX,GAAG;YAEJ,IAAI,OAAO,cAAc,YACvB,UAAU;gBACR,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;4BAC1B;YACF;YAGF,aAAa,OAAO,GAAG,IAAI;YAC3B,WAAW,OAAO,GAAG;YACrB,YAAY;QACd;IACF;AACF","sources":["packages/@react-stately/dnd/src/useDraggableCollectionState.ts"],"sourcesContent":["/*\n * Copyright 2020 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 {Collection, DraggableCollectionEndEvent, DraggableCollectionProps, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, Key, Node} from '@react-types/shared';\nimport {MultipleSelectionManager} from '@react-stately/selection';\nimport {RefObject, useRef, useState} from 'react';\n\nexport interface DraggableCollectionStateOptions extends DraggableCollectionProps {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** Whether the drag events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface DraggableCollectionState {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** The key of the item that initiated a drag. */\n draggedKey: Key | null,\n /** The keys of the items that are currently being dragged. */\n draggingKeys: Set<Key>,\n /** Whether drag events are disabled. */\n isDisabled?: boolean,\n /** Returns whether the given key is currently being dragged. */\n isDragging(key: Key): boolean,\n /** Returns the keys of the items that will be dragged with the given key (e.g. selected items). */\n getKeysForDrag(key: Key): Set<Key>,\n /** Returns the items to drag for the given key. */\n getItems(key: Key): DragItem[],\n /** The ref of the element that will be rendered as the drag preview while dragging. */\n preview?: RefObject<DragPreviewRenderer | null>,\n /** Function that returns the drop operations that are allowed for the dragged items. If not provided, all drop operations are allowed. */\n getAllowedDropOperations?: () => DropOperation[],\n /** Begins a drag for the given key. This triggers the onDragStart event. */\n startDrag(key: Key, event: DragStartEvent): void,\n /** Triggers an onDragMove event. */\n moveDrag(event: DragMoveEvent): void,\n /** Ends the current drag, and emits an onDragEnd event. */\n endDrag(event: DraggableCollectionEndEvent): void\n}\n\n/**\n * Manages state for a draggable collection.\n */\nexport function useDraggableCollectionState(props: DraggableCollectionStateOptions): DraggableCollectionState {\n let {\n getItems,\n isDisabled,\n collection,\n selectionManager,\n onDragStart,\n onDragMove,\n onDragEnd,\n preview,\n getAllowedDropOperations\n } = props;\n let [, setDragging] = useState(false);\n let draggingKeys = useRef(new Set<Key>());\n let draggedKey = useRef(null);\n let getKeys = (key: Key) => {\n // The clicked item is always added to the drag. If it is selected, then all of the\n // other selected items are also dragged. If it is not selected, the only the clicked\n // item is dragged. This matches native macOS behavior.\n let keys = new Set(\n selectionManager.isSelected(key)\n ? new Set([...selectionManager.selectedKeys].filter(key => !!collection.getItem(key)))\n : []\n );\n\n keys.add(key);\n return keys;\n };\n\n return {\n collection,\n selectionManager,\n get draggedKey() {\n return draggedKey.current;\n },\n get draggingKeys() {\n return draggingKeys.current;\n },\n isDragging(key) {\n return draggingKeys.current.has(key);\n },\n getKeysForDrag: getKeys,\n getItems(key) {\n return getItems(getKeys(key));\n },\n isDisabled,\n preview,\n getAllowedDropOperations,\n startDrag(key, event) {\n let keys = getKeys(key);\n draggingKeys.current = keys;\n draggedKey.current = key;\n selectionManager.setFocused(false);\n setDragging(true);\n if (typeof onDragStart === 'function') {\n onDragStart({\n ...event,\n keys\n });\n }\n },\n moveDrag(event) {\n if (typeof onDragMove === 'function') {\n onDragMove({\n ...event,\n keys: draggingKeys.current\n });\n }\n },\n endDrag(event) {\n let {\n isInternal\n } = event;\n\n if (typeof onDragEnd === 'function') {\n onDragEnd({\n ...event,\n keys: draggingKeys.current,\n isInternal\n });\n }\n\n draggingKeys.current = new Set();\n draggedKey.current = null;\n setDragging(false);\n }\n };\n}\n"],"names":[],"version":3,"file":"useDraggableCollectionState.module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AA+CM,SAAS,0CAA4B,KAAsC;IAChF,IAAI,YACF,QAAQ,cACR,UAAU,cACV,UAAU,oBACV,gBAAgB,eAChB,WAAW,cACX,UAAU,aACV,SAAS,WACT,OAAO,4BACP,wBAAwB,EACzB,GAAG;IACJ,IAAI,GAAG,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE;IAC/B,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE,IAAI;IAC9B,IAAI,aAAa,CAAA,GAAA,aAAK,EAAE;IACxB,IAAI,UAAU,CAAC;QACb,mFAAmF;QACnF,qFAAqF;QACrF,uDAAuD;QACvD,IAAI,OAAO,IAAI,IACb,iBAAiB,UAAU,CAAC,OACxB,IAAI,IAAI;eAAI,iBAAiB,YAAY;SAAC,CAAC,MAAM,CAAC,CAAA,MAAO,CAAC,CAAC,WAAW,OAAO,CAAC,SAC9E,EAAE;QAGR,KAAK,GAAG,CAAC;QACT,OAAO;IACT;IAEA,OAAO;oBACL;0BACA;QACA,IAAI,cAAa;YACf,OAAO,WAAW,OAAO;QAC3B;QACA,IAAI,gBAAe;YACjB,OAAO,aAAa,OAAO;QAC7B;QACA,YAAW,GAAG;YACZ,OAAO,aAAa,OAAO,CAAC,GAAG,CAAC;QAClC;QACA,gBAAgB;QAChB,UAAS,GAAG;YACV,OAAO,SAAS,QAAQ;QAC1B;oBACA;iBACA;kCACA;QACA,WAAU,GAAG,EAAE,KAAK;YAClB,IAAI,OAAO,QAAQ;YACnB,aAAa,OAAO,GAAG;YACvB,WAAW,OAAO,GAAG;YACrB,iBAAiB,UAAU,CAAC;YAC5B,YAAY;YACZ,IAAI,OAAO,gBAAgB,YACzB,YAAY;gBACV,GAAG,KAAK;sBACR;YACF;QAEJ;QACA,UAAS,KAAK;YACZ,IAAI,OAAO,eAAe,YACxB,WAAW;gBACT,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;YAC5B;QAEJ;QACA,SAAQ,KAAK;YACX,IAAI,cACF,UAAU,EACX,GAAG;YAEJ,IAAI,OAAO,cAAc,YACvB,UAAU;gBACR,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;4BAC1B;YACF;YAGF,aAAa,OAAO,GAAG,IAAI;YAC3B,WAAW,OAAO,GAAG;YACrB,YAAY;QACd;IACF;AACF","sources":["packages/@react-stately/dnd/src/useDraggableCollectionState.ts"],"sourcesContent":["/*\n * Copyright 2020 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 {Collection, DraggableCollectionEndEvent, DraggableCollectionProps, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, Key, Node, RefObject} from '@react-types/shared';\nimport {MultipleSelectionManager} from '@react-stately/selection';\nimport {useRef, useState} from 'react';\n\nexport interface DraggableCollectionStateOptions extends DraggableCollectionProps {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** Whether the drag events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface DraggableCollectionState {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** The key of the item that initiated a drag. */\n draggedKey: Key | null,\n /** The keys of the items that are currently being dragged. */\n draggingKeys: Set<Key>,\n /** Whether drag events are disabled. */\n isDisabled?: boolean,\n /** Returns whether the given key is currently being dragged. */\n isDragging(key: Key): boolean,\n /** Returns the keys of the items that will be dragged with the given key (e.g. selected items). */\n getKeysForDrag(key: Key): Set<Key>,\n /** Returns the items to drag for the given key. */\n getItems(key: Key): DragItem[],\n /** The ref of the element that will be rendered as the drag preview while dragging. */\n preview?: RefObject<DragPreviewRenderer | null>,\n /** Function that returns the drop operations that are allowed for the dragged items. If not provided, all drop operations are allowed. */\n getAllowedDropOperations?: () => DropOperation[],\n /** Begins a drag for the given key. This triggers the onDragStart event. */\n startDrag(key: Key, event: DragStartEvent): void,\n /** Triggers an onDragMove event. */\n moveDrag(event: DragMoveEvent): void,\n /** Ends the current drag, and emits an onDragEnd event. */\n endDrag(event: DraggableCollectionEndEvent): void\n}\n\n/**\n * Manages state for a draggable collection.\n */\nexport function useDraggableCollectionState(props: DraggableCollectionStateOptions): DraggableCollectionState {\n let {\n getItems,\n isDisabled,\n collection,\n selectionManager,\n onDragStart,\n onDragMove,\n onDragEnd,\n preview,\n getAllowedDropOperations\n } = props;\n let [, setDragging] = useState(false);\n let draggingKeys = useRef(new Set<Key>());\n let draggedKey = useRef(null);\n let getKeys = (key: Key) => {\n // The clicked item is always added to the drag. If it is selected, then all of the\n // other selected items are also dragged. If it is not selected, the only the clicked\n // item is dragged. This matches native macOS behavior.\n let keys = new Set(\n selectionManager.isSelected(key)\n ? new Set([...selectionManager.selectedKeys].filter(key => !!collection.getItem(key)))\n : []\n );\n\n keys.add(key);\n return keys;\n };\n\n return {\n collection,\n selectionManager,\n get draggedKey() {\n return draggedKey.current;\n },\n get draggingKeys() {\n return draggingKeys.current;\n },\n isDragging(key) {\n return draggingKeys.current.has(key);\n },\n getKeysForDrag: getKeys,\n getItems(key) {\n return getItems(getKeys(key));\n },\n isDisabled,\n preview,\n getAllowedDropOperations,\n startDrag(key, event) {\n let keys = getKeys(key);\n draggingKeys.current = keys;\n draggedKey.current = key;\n selectionManager.setFocused(false);\n setDragging(true);\n if (typeof onDragStart === 'function') {\n onDragStart({\n ...event,\n keys\n });\n }\n },\n moveDrag(event) {\n if (typeof onDragMove === 'function') {\n onDragMove({\n ...event,\n keys: draggingKeys.current\n });\n }\n },\n endDrag(event) {\n let {\n isInternal\n } = event;\n\n if (typeof onDragEnd === 'function') {\n onDragEnd({\n ...event,\n keys: draggingKeys.current,\n isInternal\n });\n }\n\n draggingKeys.current = new Set();\n draggedKey.current = null;\n setDragging(false);\n }\n };\n}\n"],"names":[],"version":3,"file":"useDraggableCollectionState.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/dnd",
3
- "version": "3.3.2-nightly.4701+76365df43",
3
+ "version": "3.3.2-nightly.4704+546ffa41f",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,8 +22,8 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-stately/selection": "3.0.0-nightly.2989+76365df43",
26
- "@react-types/shared": "3.0.0-nightly.2989+76365df43",
25
+ "@react-stately/selection": "3.0.0-nightly.2992+546ffa41f",
26
+ "@react-types/shared": "3.0.0-nightly.2992+546ffa41f",
27
27
  "@swc/helpers": "^0.5.0"
28
28
  },
29
29
  "peerDependencies": {
@@ -32,5 +32,5 @@
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "76365df434b6f65b137113557ba14a32ea466c8f"
35
+ "gitHead": "546ffa41f7d1d3a566950a14d8f46cf726891220"
36
36
  }
@@ -10,9 +10,9 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {Collection, DraggableCollectionEndEvent, DraggableCollectionProps, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, Key, Node} from '@react-types/shared';
13
+ import {Collection, DraggableCollectionEndEvent, DraggableCollectionProps, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, Key, Node, RefObject} from '@react-types/shared';
14
14
  import {MultipleSelectionManager} from '@react-stately/selection';
15
- import {RefObject, useRef, useState} from 'react';
15
+ import {useRef, useState} from 'react';
16
16
 
17
17
  export interface DraggableCollectionStateOptions extends DraggableCollectionProps {
18
18
  /** A collection of items. */