@react-stately/dnd 3.4.3 → 3.5.0

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2019 Adobe
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/dist/types.d.ts CHANGED
@@ -65,9 +65,9 @@ export interface DroppableCollectionState {
65
65
  /** Whether drop events are disabled. */
66
66
  isDisabled?: boolean;
67
67
  /** Sets the current drop target. */
68
- setTarget(target: DropTarget): void;
68
+ setTarget(target: DropTarget | null): void;
69
69
  /** Returns whether the given target is equivalent to the current drop target. */
70
- isDropTarget(target: DropTarget): boolean;
70
+ isDropTarget(target: DropTarget | null): boolean;
71
71
  /** Returns the drop operation for the given parameters. */
72
72
  getDropOperation(e: DropOperationEvent): DropOperation;
73
73
  }
@@ -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,EAAE,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,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M,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,6BAA6B;IAC7B,UAAU,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC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C,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,GAAG,IAAI,CAAC;IAC3C,iFAAiF;IACjF,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,OAAO,CAAC;IACjD,2DAA2D;IAC3D,gBAAgB,CAAC,CAAC,EAAE,kBAAkB,GAAG,aAAa,CAAA;CACvD;AAED;;GAEG;AACH,4CAA4C,KAAK,EAAE,+BAA+B,GAAG,wBAAwB,CA0H5G","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, 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
+ {"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,EAAc;IACpC,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<Key | null>(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, 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"}
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,EAAc;IACpC,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<Key | null>(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"}
@@ -37,17 +37,18 @@ function $6ce4cbfbe5e354f1$export$926850f6ecef79d0(props) {
37
37
  dropPosition: 'before'
38
38
  } : null;
39
39
  }
40
+ return null;
40
41
  };
41
42
  let defaultGetDropOperation = (0, $ax21c$react.useCallback)((e)=>{
42
- if (isDisabled) return 'cancel';
43
43
  let { target: target, types: types, allowedOperations: allowedOperations, isInternal: isInternal, draggingKeys: draggingKeys } = e;
44
+ if (isDisabled || !target) return 'cancel';
44
45
  if (acceptedDragTypes === 'all' || acceptedDragTypes.some((type)=>types.has(type))) {
45
46
  let isValidInsert = onInsert && target.type === 'item' && !isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');
46
47
  let isValidReorder = onReorder && target.type === 'item' && isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');
47
48
  // Feedback was that internal root drop was weird so preventing that from happening
48
49
  let isValidRootDrop = onRootDrop && target.type === 'root' && !isInternal;
49
50
  // Automatically prevent items (i.e. folders) from being dropped on themselves.
50
- let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));
51
+ let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && target.key != null && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));
51
52
  if (onDrop || isValidInsert || isValidReorder || isValidRootDrop || isValidOnItemDrop) {
52
53
  if (getDropOperation) return getDropOperation(target, types, allowedOperations);
53
54
  else return allowedOperations[0];
@@ -85,11 +86,12 @@ function $6ce4cbfbe5e354f1$export$926850f6ecef79d0(props) {
85
86
  y: 0,
86
87
  target: newTarget
87
88
  });
88
- targetRef.current = newTarget;
89
- setTarget(newTarget);
89
+ targetRef.current = newTarget !== null && newTarget !== void 0 ? newTarget : null;
90
+ setTarget(newTarget !== null && newTarget !== void 0 ? newTarget : null);
90
91
  },
91
92
  isDropTarget (dropTarget) {
92
93
  let target = targetRef.current;
94
+ if (!target || !dropTarget) return false;
93
95
  if ($6ce4cbfbe5e354f1$var$isEqualDropTarget(dropTarget, target)) return true;
94
96
  // Check if the targets point at the same point between two items, one referring before, and the other after.
95
97
  if ((dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.type) === 'item' && (target === null || target === void 0 ? void 0 : target.type) === 'item' && dropTarget.key !== target.key && dropTarget.dropPosition !== target.dropPosition && dropTarget.dropPosition !== 'on' && target.dropPosition !== 'on') return $6ce4cbfbe5e354f1$var$isEqualDropTarget(getOppositeTar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Y,KAAK,MAExB,OAAO,wCAAkB,kBAAkB,aAAa,WACtD,wCAAkB,YAAY,kBAAkB;YAGpD,OAAO;QACT;QACA,kBAAiB,CAAC;YAChB,OAAO,wBAAwB;QACjC;IACF;AACF;AAEA,SAAS,wCAAkB,CAAa,EAAE,CAAa;IACrD,IAAI,CAAC,GACH,OAAO,CAAC;IAGV,OAAQ,EAAE,IAAI;QACZ,KAAK;YACH,OAAO,CAAA,cAAA,wBAAA,EAAG,IAAI,MAAK;QACrB,KAAK;YACH,OAAO,CAAA,cAAA,wBAAA,EAAG,IAAI,MAAK,UAAU,CAAA,cAAA,wBAAA,EAAG,GAAG,MAAK,EAAE,GAAG,IAAI,CAAA,cAAA,wBAAA,EAAG,YAAY,MAAK,EAAE,YAAY;IACvF;AACF","sources":["packages/@react-stately/dnd/src/useDroppableCollectionState.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, DragTypes, DropOperation, DroppableCollectionProps, DropTarget, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {MultipleSelectionManager} from '@react-stately/selection';\nimport {useCallback, useRef, useState} from 'react';\n\ninterface DropOperationEvent {\n target: DropTarget,\n types: DragTypes,\n allowedOperations: DropOperation[],\n isInternal: boolean,\n draggingKeys: Set<Key>\n}\n\nexport interface DroppableCollectionStateOptions extends Omit<DroppableCollectionProps, 'onDropMove' | 'onDropActivate'> {\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 drop events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface DroppableCollectionState {\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 current drop target. */\n target: DropTarget | null,\n /** Whether drop events are disabled. */\n isDisabled?: boolean,\n /** Sets the current drop target. */\n setTarget(target: DropTarget): void,\n /** Returns whether the given target is equivalent to the current drop target. */\n isDropTarget(target: DropTarget): boolean,\n /** Returns the drop operation for the given parameters. */\n getDropOperation(e: DropOperationEvent): DropOperation\n}\n\n/**\n * Manages state for a droppable collection.\n */\nexport function useDroppableCollectionState(props: DroppableCollectionStateOptions): DroppableCollectionState {\n let {\n acceptedDragTypes = 'all',\n isDisabled,\n onInsert,\n onRootDrop,\n onItemDrop,\n onReorder,\n shouldAcceptItemDrop,\n collection,\n selectionManager,\n onDropEnter,\n getDropOperation,\n onDrop\n } = props;\n let [target, setTarget] = useState<DropTarget>(null);\n let targetRef = useRef<DropTarget>(null);\n\n let getOppositeTarget = (target: ItemDropTarget): ItemDropTarget => {\n if (target.dropPosition === 'before') {\n let key = collection.getKeyBefore(target.key);\n return key != null ? {type: 'item', key, dropPosition: 'after'} : null;\n } else if (target.dropPosition === 'after') {\n let key = collection.getKeyAfter(target.key);\n return key != null ? {type: 'item', key, dropPosition: 'before'} : null;\n }\n };\n\n let defaultGetDropOperation = useCallback((e: DropOperationEvent) => {\n if (isDisabled) {\n return 'cancel';\n }\n\n let {\n target,\n types,\n allowedOperations,\n isInternal,\n draggingKeys\n } = e;\n\n if (acceptedDragTypes === 'all' || acceptedDragTypes.some(type => types.has(type))) {\n let isValidInsert = onInsert && target.type === 'item' && !isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');\n let isValidReorder = onReorder && target.type === 'item' && isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');\n // Feedback was that internal root drop was weird so preventing that from happening\n let isValidRootDrop = onRootDrop && target.type === 'root' && !isInternal;\n // Automatically prevent items (i.e. folders) from being dropped on themselves.\n let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));\n\n if (onDrop || isValidInsert || isValidReorder || isValidRootDrop || isValidOnItemDrop) {\n if (getDropOperation) {\n return getDropOperation(target, types, allowedOperations);\n } else {\n return allowedOperations[0];\n }\n }\n }\n\n return 'cancel';\n }, [isDisabled, acceptedDragTypes, getDropOperation, onInsert, onRootDrop, onItemDrop, shouldAcceptItemDrop, onReorder, onDrop]);\n\n return {\n collection,\n selectionManager,\n isDisabled,\n target,\n setTarget(newTarget) {\n if (this.isDropTarget(newTarget)) {\n return;\n }\n\n let target = targetRef.current;\n if (target && typeof props.onDropExit === 'function') {\n props.onDropExit({\n type: 'dropexit',\n x: 0, // todo\n y: 0,\n target\n });\n }\n\n if (newTarget && typeof onDropEnter === 'function') {\n onDropEnter({\n type: 'dropenter',\n x: 0, // todo\n y: 0,\n target: newTarget\n });\n }\n\n targetRef.current = newTarget;\n setTarget(newTarget);\n },\n isDropTarget(dropTarget) {\n let target = targetRef.current;\n if (isEqualDropTarget(dropTarget, target)) {\n return true;\n }\n\n // Check if the targets point at the same point between two items, one referring before, and the other after.\n if (\n dropTarget?.type === 'item' &&\n target?.type === 'item' &&\n dropTarget.key !== target.key &&\n dropTarget.dropPosition !== target.dropPosition &&\n dropTarget.dropPosition !== 'on' &&\n target.dropPosition !== 'on'\n ) {\n return isEqualDropTarget(getOppositeTarget(dropTarget), target) ||\n isEqualDropTarget(dropTarget, getOppositeTarget(target));\n }\n\n return false;\n },\n getDropOperation(e) {\n return defaultGetDropOperation(e);\n }\n };\n}\n\nfunction isEqualDropTarget(a: DropTarget, b: DropTarget) {\n if (!a) {\n return !b;\n }\n\n switch (a.type) {\n case 'root':\n return b?.type === 'root';\n case 'item':\n return b?.type === 'item' && b?.key === a.key && b?.dropPosition === a.dropPosition;\n }\n}\n"],"names":[],"version":3,"file":"useDroppable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YAAY,KAAK,OAAO,YAAY,IAC/C,WAAW,YAAY,KAAK,QAC5B,OAAO,YAAY,KAAK,MAExB,OAAO,wCAAkB,kBAAkB,aAAa,WACtD,wCAAkB,YAAY,kBAAkB;YAGpD,OAAO;QACT;QACA,kBAAiB,CAAC;YAChB,OAAO,wBAAwB;QACjC;IACF;AACF;AAEA,SAAS,wCAAkB,CAAqB,EAAE,CAAqB;IACrE,IAAI,CAAC,GACH,OAAO,CAAC;IAGV,OAAQ,EAAE,IAAI;QACZ,KAAK;YACH,OAAO,CAAA,cAAA,wBAAA,EAAG,IAAI,MAAK;QACrB,KAAK;YACH,OAAO,CAAA,cAAA,wBAAA,EAAG,IAAI,MAAK,UAAU,CAAA,cAAA,wBAAA,EAAG,GAAG,MAAK,EAAE,GAAG,IAAI,CAAA,cAAA,wBAAA,EAAG,YAAY,MAAK,EAAE,YAAY;IACvF;AACF","sources":["packages/@react-stately/dnd/src/useDroppableCollectionState.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, DragTypes, DropOperation, DroppableCollectionProps, DropTarget, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {MultipleSelectionManager} from '@react-stately/selection';\nimport {useCallback, useRef, useState} from 'react';\n\ninterface DropOperationEvent {\n target: DropTarget,\n types: DragTypes,\n allowedOperations: DropOperation[],\n isInternal: boolean,\n draggingKeys: Set<Key>\n}\n\nexport interface DroppableCollectionStateOptions extends Omit<DroppableCollectionProps, 'onDropMove' | 'onDropActivate'> {\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 drop events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface DroppableCollectionState {\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 current drop target. */\n target: DropTarget | null,\n /** Whether drop events are disabled. */\n isDisabled?: boolean,\n /** Sets the current drop target. */\n setTarget(target: DropTarget | null): void,\n /** Returns whether the given target is equivalent to the current drop target. */\n isDropTarget(target: DropTarget | null): boolean,\n /** Returns the drop operation for the given parameters. */\n getDropOperation(e: DropOperationEvent): DropOperation\n}\n\n/**\n * Manages state for a droppable collection.\n */\nexport function useDroppableCollectionState(props: DroppableCollectionStateOptions): DroppableCollectionState {\n let {\n acceptedDragTypes = 'all',\n isDisabled,\n onInsert,\n onRootDrop,\n onItemDrop,\n onReorder,\n shouldAcceptItemDrop,\n collection,\n selectionManager,\n onDropEnter,\n getDropOperation,\n onDrop\n } = props;\n let [target, setTarget] = useState<DropTarget | null>(null);\n let targetRef = useRef<DropTarget | null>(null);\n\n let getOppositeTarget = (target: ItemDropTarget): ItemDropTarget | null => {\n if (target.dropPosition === 'before') {\n let key = collection.getKeyBefore(target.key);\n return key != null ? {type: 'item', key, dropPosition: 'after'} : null;\n } else if (target.dropPosition === 'after') {\n let key = collection.getKeyAfter(target.key);\n return key != null ? {type: 'item', key, dropPosition: 'before'} : null;\n }\n return null;\n };\n\n let defaultGetDropOperation = useCallback((e: DropOperationEvent) => {\n let {\n target,\n types,\n allowedOperations,\n isInternal,\n draggingKeys\n } = e;\n\n if (isDisabled || !target) {\n return 'cancel';\n }\n\n if (acceptedDragTypes === 'all' || acceptedDragTypes.some(type => types.has(type))) {\n let isValidInsert = onInsert && target.type === 'item' && !isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');\n let isValidReorder = onReorder && target.type === 'item' && isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');\n // Feedback was that internal root drop was weird so preventing that from happening\n let isValidRootDrop = onRootDrop && target.type === 'root' && !isInternal;\n // Automatically prevent items (i.e. folders) from being dropped on themselves.\n let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && target.key != null && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));\n\n if (onDrop || isValidInsert || isValidReorder || isValidRootDrop || isValidOnItemDrop) {\n if (getDropOperation) {\n return getDropOperation(target, types, allowedOperations);\n } else {\n return allowedOperations[0];\n }\n }\n }\n\n return 'cancel';\n }, [isDisabled, acceptedDragTypes, getDropOperation, onInsert, onRootDrop, onItemDrop, shouldAcceptItemDrop, onReorder, onDrop]);\n\n return {\n collection,\n selectionManager,\n isDisabled,\n target,\n setTarget(newTarget) {\n if (this.isDropTarget(newTarget)) {\n return;\n }\n\n let target = targetRef.current;\n if (target && typeof props.onDropExit === 'function') {\n props.onDropExit({\n type: 'dropexit',\n x: 0, // todo\n y: 0,\n target\n });\n }\n\n if (newTarget && typeof onDropEnter === 'function') {\n onDropEnter({\n type: 'dropenter',\n x: 0, // todo\n y: 0,\n target: newTarget\n });\n }\n\n targetRef.current = newTarget ?? null;\n setTarget(newTarget ?? null);\n },\n isDropTarget(dropTarget) {\n let target = targetRef.current;\n if (!target || !dropTarget) {\n return false;\n }\n if (isEqualDropTarget(dropTarget, target)) {\n return true;\n }\n\n // Check if the targets point at the same point between two items, one referring before, and the other after.\n if (\n dropTarget?.type === 'item' &&\n target?.type === 'item' &&\n dropTarget.key !== target.key &&\n dropTarget.dropPosition !== target.dropPosition &&\n dropTarget.dropPosition !== 'on' &&\n target.dropPosition !== 'on'\n ) {\n return isEqualDropTarget(getOppositeTarget(dropTarget), target) ||\n isEqualDropTarget(dropTarget, getOppositeTarget(target));\n }\n\n return false;\n },\n getDropOperation(e) {\n return defaultGetDropOperation(e);\n }\n };\n}\n\nfunction isEqualDropTarget(a?: DropTarget | null, b?: DropTarget | null) {\n if (!a) {\n return !b;\n }\n\n switch (a.type) {\n case 'root':\n return b?.type === 'root';\n case 'item':\n return b?.type === 'item' && b?.key === a.key && b?.dropPosition === a.dropPosition;\n }\n}\n"],"names":[],"version":3,"file":"useDroppableCollectionState.main.js.map"}
@@ -31,17 +31,18 @@ function $e672e8bc247525d1$export$926850f6ecef79d0(props) {
31
31
  dropPosition: 'before'
32
32
  } : null;
33
33
  }
34
+ return null;
34
35
  };
35
36
  let defaultGetDropOperation = (0, $lyPoT$useCallback)((e)=>{
36
- if (isDisabled) return 'cancel';
37
37
  let { target: target, types: types, allowedOperations: allowedOperations, isInternal: isInternal, draggingKeys: draggingKeys } = e;
38
+ if (isDisabled || !target) return 'cancel';
38
39
  if (acceptedDragTypes === 'all' || acceptedDragTypes.some((type)=>types.has(type))) {
39
40
  let isValidInsert = onInsert && target.type === 'item' && !isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');
40
41
  let isValidReorder = onReorder && target.type === 'item' && isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');
41
42
  // Feedback was that internal root drop was weird so preventing that from happening
42
43
  let isValidRootDrop = onRootDrop && target.type === 'root' && !isInternal;
43
44
  // Automatically prevent items (i.e. folders) from being dropped on themselves.
44
- let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));
45
+ let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && target.key != null && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));
45
46
  if (onDrop || isValidInsert || isValidReorder || isValidRootDrop || isValidOnItemDrop) {
46
47
  if (getDropOperation) return getDropOperation(target, types, allowedOperations);
47
48
  else return allowedOperations[0];
@@ -79,11 +80,12 @@ function $e672e8bc247525d1$export$926850f6ecef79d0(props) {
79
80
  y: 0,
80
81
  target: newTarget
81
82
  });
82
- targetRef.current = newTarget;
83
- setTarget(newTarget);
83
+ targetRef.current = newTarget !== null && newTarget !== void 0 ? newTarget : null;
84
+ setTarget(newTarget !== null && newTarget !== void 0 ? newTarget : null);
84
85
  },
85
86
  isDropTarget (dropTarget) {
86
87
  let target = targetRef.current;
88
+ if (!target || !dropTarget) return false;
87
89
  if ($e672e8bc247525d1$var$isEqualDropTarget(dropTarget, target)) return true;
88
90
  // Check if the targets point at the same point between two items, one referring before, and the other after.
89
91
  if ((dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.type) === 'item' && (target === null || target === void 0 ? void 0 : target.type) === 'item' && dropTarget.key !== target.key && dropTarget.dropPosition !== target.dropPosition && dropTarget.dropPosition !== 'on' && target.dropPosition !== 'on') return $e672e8bc247525d1$var$isEqualDropTarget(getOppositeTarget(dropTarget), target) || $e672e8bc247525d1$var$isEqualDropTarget(dropTarget, getOppositeTarget(target));
@@ -31,17 +31,18 @@ function $e672e8bc247525d1$export$926850f6ecef79d0(props) {
31
31
  dropPosition: 'before'
32
32
  } : null;
33
33
  }
34
+ return null;
34
35
  };
35
36
  let defaultGetDropOperation = (0, $lyPoT$useCallback)((e)=>{
36
- if (isDisabled) return 'cancel';
37
37
  let { target: target, types: types, allowedOperations: allowedOperations, isInternal: isInternal, draggingKeys: draggingKeys } = e;
38
+ if (isDisabled || !target) return 'cancel';
38
39
  if (acceptedDragTypes === 'all' || acceptedDragTypes.some((type)=>types.has(type))) {
39
40
  let isValidInsert = onInsert && target.type === 'item' && !isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');
40
41
  let isValidReorder = onReorder && target.type === 'item' && isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');
41
42
  // Feedback was that internal root drop was weird so preventing that from happening
42
43
  let isValidRootDrop = onRootDrop && target.type === 'root' && !isInternal;
43
44
  // Automatically prevent items (i.e. folders) from being dropped on themselves.
44
- let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));
45
+ let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && target.key != null && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));
45
46
  if (onDrop || isValidInsert || isValidReorder || isValidRootDrop || isValidOnItemDrop) {
46
47
  if (getDropOperation) return getDropOperation(target, types, allowedOperations);
47
48
  else return allowedOperations[0];
@@ -79,11 +80,12 @@ function $e672e8bc247525d1$export$926850f6ecef79d0(props) {
79
80
  y: 0,
80
81
  target: newTarget
81
82
  });
82
- targetRef.current = newTarget;
83
- setTarget(newTarget);
83
+ targetRef.current = newTarget !== null && newTarget !== void 0 ? newTarget : null;
84
+ setTarget(newTarget !== null && newTarget !== void 0 ? newTarget : null);
84
85
  },
85
86
  isDropTarget (dropTarget) {
86
87
  let target = targetRef.current;
88
+ if (!target || !dropTarget) return false;
87
89
  if ($e672e8bc247525d1$var$isEqualDropTarget(dropTarget, target)) return true;
88
90
  // Check if the targets point at the same point between two items, one referring before, and the other after.
89
91
  if ((dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.type) === 'item' && (target === null || target === void 0 ? void 0 : target.type) === 'item' && dropTarget.key !== target.key && dropTarget.dropPosition !== target.dropPosition && dropTarget.dropPosition !== 'on' && target.dropPosition !== 'on') return $e672e8bc247525d1$var$isEqualDropTarget(getOppositeTarget(dropTarget), target) || $e672e8bc247525d1$var$isEqualDropTarget(dropTarget, getOppositeTarget(target));
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AA2CM,SAAS,0CAA4B,KAAsC;IAChF,IAAI,qBACF,oBAAoB,mBACpB,UAAU,YACV,QAAQ,cACR,UAAU,cACV,UAAU,aACV,SAAS,wBACT,oBAAoB,cACpB,UAAU,oBACV,gBAAgB,eAChB,WAAW,oBACX,gBAAgB,UAChB,MAAM,EACP,GAAG;IACJ,IAAI,CAAC,QAAQ,UAAU,GAAG,CA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AAA,cAAA,wBAAA,EAAG,GAAG,MAAK,EAAE,GAAG,IAAI,CAAA,cAAA,wBAAA,EAAG,YAAY,MAAK,EAAE,YAAY;IACvF;AACF","sources":["packages/@react-stately/dnd/src/useDroppableCollectionState.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, DragTypes, DropOperation, DroppableCollectionProps, DropTarget, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {MultipleSelectionManager} from '@react-stately/selection';\nimport {useCallback, useRef, useState} from 'react';\n\ninterface DropOperationEvent {\n target: DropTarget,\n types: DragTypes,\n allowedOperations: DropOperation[],\n isInternal: boolean,\n draggingKeys: Set<Key>\n}\n\nexport interface DroppableCollectionStateOptions extends Omit<DroppableCollectionProps, 'onDropMove' | 'onDropActivate'> {\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 drop events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface DroppableCollectionState {\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 current drop target. */\n target: DropTarget | null,\n /** Whether drop events are disabled. */\n isDisabled?: boolean,\n /** Sets the current drop target. */\n setTarget(target: DropTarget): void,\n /** Returns whether the given target is equivalent to the current drop target. */\n isDropTarget(target: DropTarget): boolean,\n /** Returns the drop operation for the given parameters. */\n getDropOperation(e: DropOperationEvent): DropOperation\n}\n\n/**\n * Manages state for a droppable collection.\n */\nexport function useDroppableCollectionState(props: DroppableCollectionStateOptions): DroppableCollectionState {\n let {\n acceptedDragTypes = 'all',\n isDisabled,\n onInsert,\n onRootDrop,\n onItemDrop,\n onReorder,\n shouldAcceptItemDrop,\n collection,\n selectionManager,\n onDropEnter,\n getDropOperation,\n onDrop\n } = props;\n let [target, setTarget] = useState<DropTarget>(null);\n let targetRef = useRef<DropTarget>(null);\n\n let getOppositeTarget = (target: ItemDropTarget): ItemDropTarget => {\n if (target.dropPosition === 'before') {\n let key = collection.getKeyBefore(target.key);\n return key != null ? {type: 'item', key, dropPosition: 'after'} : null;\n } else if (target.dropPosition === 'after') {\n let key = collection.getKeyAfter(target.key);\n return key != null ? {type: 'item', key, dropPosition: 'before'} : null;\n }\n };\n\n let defaultGetDropOperation = useCallback((e: DropOperationEvent) => {\n if (isDisabled) {\n return 'cancel';\n }\n\n let {\n target,\n types,\n allowedOperations,\n isInternal,\n draggingKeys\n } = e;\n\n if (acceptedDragTypes === 'all' || acceptedDragTypes.some(type => types.has(type))) {\n let isValidInsert = onInsert && target.type === 'item' && !isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');\n let isValidReorder = onReorder && target.type === 'item' && isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');\n // Feedback was that internal root drop was weird so preventing that from happening\n let isValidRootDrop = onRootDrop && target.type === 'root' && !isInternal;\n // Automatically prevent items (i.e. folders) from being dropped on themselves.\n let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));\n\n if (onDrop || isValidInsert || isValidReorder || isValidRootDrop || isValidOnItemDrop) {\n if (getDropOperation) {\n return getDropOperation(target, types, allowedOperations);\n } else {\n return allowedOperations[0];\n }\n }\n }\n\n return 'cancel';\n }, [isDisabled, acceptedDragTypes, getDropOperation, onInsert, onRootDrop, onItemDrop, shouldAcceptItemDrop, onReorder, onDrop]);\n\n return {\n collection,\n selectionManager,\n isDisabled,\n target,\n setTarget(newTarget) {\n if (this.isDropTarget(newTarget)) {\n return;\n }\n\n let target = targetRef.current;\n if (target && typeof props.onDropExit === 'function') {\n props.onDropExit({\n type: 'dropexit',\n x: 0, // todo\n y: 0,\n target\n });\n }\n\n if (newTarget && typeof onDropEnter === 'function') {\n onDropEnter({\n type: 'dropenter',\n x: 0, // todo\n y: 0,\n target: newTarget\n });\n }\n\n targetRef.current = newTarget;\n setTarget(newTarget);\n },\n isDropTarget(dropTarget) {\n let target = targetRef.current;\n if (isEqualDropTarget(dropTarget, target)) {\n return true;\n }\n\n // Check if the targets point at the same point between two items, one referring before, and the other after.\n if (\n dropTarget?.type === 'item' &&\n target?.type === 'item' &&\n dropTarget.key !== target.key &&\n dropTarget.dropPosition !== target.dropPosition &&\n dropTarget.dropPosition !== 'on' &&\n target.dropPosition !== 'on'\n ) {\n return isEqualDropTarget(getOppositeTarget(dropTarget), target) ||\n isEqualDropTarget(dropTarget, getOppositeTarget(target));\n }\n\n return false;\n },\n getDropOperation(e) {\n return defaultGetDropOperation(e);\n }\n };\n}\n\nfunction isEqualDropTarget(a: DropTarget, b: DropTarget) {\n if (!a) {\n return !b;\n }\n\n switch (a.type) {\n case 'root':\n return b?.type === 'root';\n case 'item':\n return b?.type === 'item' && b?.key === a.key && b?.dropPosition === a.dropPosition;\n }\n}\n"],"names":[],"version":3,"file":"useDroppableCollectionState.module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AA2CM,SAAS,0CAA4B,KAAsC;IAChF,IAAI,qBACF,oBAAoB,mBACpB,UAAU,YACV,QAAQ,cACR,UAAU,cACV,UAAU,aACV,SAAS,wBACT,oBAAoB,cACpB,UAAU,oBACV,gBAAgB,eAChB,WAAW,oBACX,gBAAgB,UAChB,MAAM,EACP,GAAG;IACJ,IAAI,CAAC,QAAQ,UAAU,GAAG,CAAA,GAAA,eAAO,EAAqB;IACtD,IAAI,YAAY,CAAA,GAAA,aAAK,EAAqB;IAE1C,I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AK;YACH,OAAO,CAAA,cAAA,wBAAA,EAAG,IAAI,MAAK,UAAU,CAAA,cAAA,wBAAA,EAAG,GAAG,MAAK,EAAE,GAAG,IAAI,CAAA,cAAA,wBAAA,EAAG,YAAY,MAAK,EAAE,YAAY;IACvF;AACF","sources":["packages/@react-stately/dnd/src/useDroppableCollectionState.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, DragTypes, DropOperation, DroppableCollectionProps, DropTarget, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {MultipleSelectionManager} from '@react-stately/selection';\nimport {useCallback, useRef, useState} from 'react';\n\ninterface DropOperationEvent {\n target: DropTarget,\n types: DragTypes,\n allowedOperations: DropOperation[],\n isInternal: boolean,\n draggingKeys: Set<Key>\n}\n\nexport interface DroppableCollectionStateOptions extends Omit<DroppableCollectionProps, 'onDropMove' | 'onDropActivate'> {\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 drop events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface DroppableCollectionState {\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 current drop target. */\n target: DropTarget | null,\n /** Whether drop events are disabled. */\n isDisabled?: boolean,\n /** Sets the current drop target. */\n setTarget(target: DropTarget | null): void,\n /** Returns whether the given target is equivalent to the current drop target. */\n isDropTarget(target: DropTarget | null): boolean,\n /** Returns the drop operation for the given parameters. */\n getDropOperation(e: DropOperationEvent): DropOperation\n}\n\n/**\n * Manages state for a droppable collection.\n */\nexport function useDroppableCollectionState(props: DroppableCollectionStateOptions): DroppableCollectionState {\n let {\n acceptedDragTypes = 'all',\n isDisabled,\n onInsert,\n onRootDrop,\n onItemDrop,\n onReorder,\n shouldAcceptItemDrop,\n collection,\n selectionManager,\n onDropEnter,\n getDropOperation,\n onDrop\n } = props;\n let [target, setTarget] = useState<DropTarget | null>(null);\n let targetRef = useRef<DropTarget | null>(null);\n\n let getOppositeTarget = (target: ItemDropTarget): ItemDropTarget | null => {\n if (target.dropPosition === 'before') {\n let key = collection.getKeyBefore(target.key);\n return key != null ? {type: 'item', key, dropPosition: 'after'} : null;\n } else if (target.dropPosition === 'after') {\n let key = collection.getKeyAfter(target.key);\n return key != null ? {type: 'item', key, dropPosition: 'before'} : null;\n }\n return null;\n };\n\n let defaultGetDropOperation = useCallback((e: DropOperationEvent) => {\n let {\n target,\n types,\n allowedOperations,\n isInternal,\n draggingKeys\n } = e;\n\n if (isDisabled || !target) {\n return 'cancel';\n }\n\n if (acceptedDragTypes === 'all' || acceptedDragTypes.some(type => types.has(type))) {\n let isValidInsert = onInsert && target.type === 'item' && !isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');\n let isValidReorder = onReorder && target.type === 'item' && isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');\n // Feedback was that internal root drop was weird so preventing that from happening\n let isValidRootDrop = onRootDrop && target.type === 'root' && !isInternal;\n // Automatically prevent items (i.e. folders) from being dropped on themselves.\n let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && target.key != null && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));\n\n if (onDrop || isValidInsert || isValidReorder || isValidRootDrop || isValidOnItemDrop) {\n if (getDropOperation) {\n return getDropOperation(target, types, allowedOperations);\n } else {\n return allowedOperations[0];\n }\n }\n }\n\n return 'cancel';\n }, [isDisabled, acceptedDragTypes, getDropOperation, onInsert, onRootDrop, onItemDrop, shouldAcceptItemDrop, onReorder, onDrop]);\n\n return {\n collection,\n selectionManager,\n isDisabled,\n target,\n setTarget(newTarget) {\n if (this.isDropTarget(newTarget)) {\n return;\n }\n\n let target = targetRef.current;\n if (target && typeof props.onDropExit === 'function') {\n props.onDropExit({\n type: 'dropexit',\n x: 0, // todo\n y: 0,\n target\n });\n }\n\n if (newTarget && typeof onDropEnter === 'function') {\n onDropEnter({\n type: 'dropenter',\n x: 0, // todo\n y: 0,\n target: newTarget\n });\n }\n\n targetRef.current = newTarget ?? null;\n setTarget(newTarget ?? null);\n },\n isDropTarget(dropTarget) {\n let target = targetRef.current;\n if (!target || !dropTarget) {\n return false;\n }\n if (isEqualDropTarget(dropTarget, target)) {\n return true;\n }\n\n // Check if the targets point at the same point between two items, one referring before, and the other after.\n if (\n dropTarget?.type === 'item' &&\n target?.type === 'item' &&\n dropTarget.key !== target.key &&\n dropTarget.dropPosition !== target.dropPosition &&\n dropTarget.dropPosition !== 'on' &&\n target.dropPosition !== 'on'\n ) {\n return isEqualDropTarget(getOppositeTarget(dropTarget), target) ||\n isEqualDropTarget(dropTarget, getOppositeTarget(target));\n }\n\n return false;\n },\n getDropOperation(e) {\n return defaultGetDropOperation(e);\n }\n };\n}\n\nfunction isEqualDropTarget(a?: DropTarget | null, b?: DropTarget | null) {\n if (!a) {\n return !b;\n }\n\n switch (a.type) {\n case 'root':\n return b?.type === 'root';\n case 'item':\n return b?.type === 'item' && b?.key === a.key && b?.dropPosition === a.dropPosition;\n }\n}\n"],"names":[],"version":3,"file":"useDroppableCollectionState.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/dnd",
3
- "version": "3.4.3",
3
+ "version": "3.5.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,14 +22,15 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-stately/selection": "^3.17.0",
26
- "@react-types/shared": "^3.25.0",
25
+ "@react-stately/selection": "^3.18.0",
26
+ "@react-types/shared": "^3.26.0",
27
27
  "@swc/helpers": "^0.5.0"
28
28
  },
29
29
  "peerDependencies": {
30
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
30
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
34
- }
35
- }
34
+ },
35
+ "gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
36
+ }
@@ -69,7 +69,7 @@ export function useDraggableCollectionState(props: DraggableCollectionStateOptio
69
69
  } = props;
70
70
  let [, setDragging] = useState(false);
71
71
  let draggingKeys = useRef(new Set<Key>());
72
- let draggedKey = useRef(null);
72
+ let draggedKey = useRef<Key | null>(null);
73
73
  let getKeys = (key: Key) => {
74
74
  // The clicked item is always added to the drag. If it is selected, then all of the
75
75
  // other selected items are also dragged. If it is not selected, the only the clicked
@@ -41,9 +41,9 @@ export interface DroppableCollectionState {
41
41
  /** Whether drop events are disabled. */
42
42
  isDisabled?: boolean,
43
43
  /** Sets the current drop target. */
44
- setTarget(target: DropTarget): void,
44
+ setTarget(target: DropTarget | null): void,
45
45
  /** Returns whether the given target is equivalent to the current drop target. */
46
- isDropTarget(target: DropTarget): boolean,
46
+ isDropTarget(target: DropTarget | null): boolean,
47
47
  /** Returns the drop operation for the given parameters. */
48
48
  getDropOperation(e: DropOperationEvent): DropOperation
49
49
  }
@@ -66,10 +66,10 @@ export function useDroppableCollectionState(props: DroppableCollectionStateOptio
66
66
  getDropOperation,
67
67
  onDrop
68
68
  } = props;
69
- let [target, setTarget] = useState<DropTarget>(null);
70
- let targetRef = useRef<DropTarget>(null);
69
+ let [target, setTarget] = useState<DropTarget | null>(null);
70
+ let targetRef = useRef<DropTarget | null>(null);
71
71
 
72
- let getOppositeTarget = (target: ItemDropTarget): ItemDropTarget => {
72
+ let getOppositeTarget = (target: ItemDropTarget): ItemDropTarget | null => {
73
73
  if (target.dropPosition === 'before') {
74
74
  let key = collection.getKeyBefore(target.key);
75
75
  return key != null ? {type: 'item', key, dropPosition: 'after'} : null;
@@ -77,13 +77,10 @@ export function useDroppableCollectionState(props: DroppableCollectionStateOptio
77
77
  let key = collection.getKeyAfter(target.key);
78
78
  return key != null ? {type: 'item', key, dropPosition: 'before'} : null;
79
79
  }
80
+ return null;
80
81
  };
81
82
 
82
83
  let defaultGetDropOperation = useCallback((e: DropOperationEvent) => {
83
- if (isDisabled) {
84
- return 'cancel';
85
- }
86
-
87
84
  let {
88
85
  target,
89
86
  types,
@@ -92,13 +89,17 @@ export function useDroppableCollectionState(props: DroppableCollectionStateOptio
92
89
  draggingKeys
93
90
  } = e;
94
91
 
92
+ if (isDisabled || !target) {
93
+ return 'cancel';
94
+ }
95
+
95
96
  if (acceptedDragTypes === 'all' || acceptedDragTypes.some(type => types.has(type))) {
96
97
  let isValidInsert = onInsert && target.type === 'item' && !isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');
97
98
  let isValidReorder = onReorder && target.type === 'item' && isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');
98
99
  // Feedback was that internal root drop was weird so preventing that from happening
99
100
  let isValidRootDrop = onRootDrop && target.type === 'root' && !isInternal;
100
101
  // Automatically prevent items (i.e. folders) from being dropped on themselves.
101
- let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));
102
+ let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && target.key != null && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));
102
103
 
103
104
  if (onDrop || isValidInsert || isValidReorder || isValidRootDrop || isValidOnItemDrop) {
104
105
  if (getDropOperation) {
@@ -141,11 +142,14 @@ export function useDroppableCollectionState(props: DroppableCollectionStateOptio
141
142
  });
142
143
  }
143
144
 
144
- targetRef.current = newTarget;
145
- setTarget(newTarget);
145
+ targetRef.current = newTarget ?? null;
146
+ setTarget(newTarget ?? null);
146
147
  },
147
148
  isDropTarget(dropTarget) {
148
149
  let target = targetRef.current;
150
+ if (!target || !dropTarget) {
151
+ return false;
152
+ }
149
153
  if (isEqualDropTarget(dropTarget, target)) {
150
154
  return true;
151
155
  }
@@ -171,7 +175,7 @@ export function useDroppableCollectionState(props: DroppableCollectionStateOptio
171
175
  };
172
176
  }
173
177
 
174
- function isEqualDropTarget(a: DropTarget, b: DropTarget) {
178
+ function isEqualDropTarget(a?: DropTarget | null, b?: DropTarget | null) {
175
179
  if (!a) {
176
180
  return !b;
177
181
  }