@react-aria/dnd 3.7.4 → 3.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/DragManager.main.js +25 -13
  2. package/dist/DragManager.main.js.map +1 -1
  3. package/dist/DragManager.mjs +25 -13
  4. package/dist/DragManager.module.js +25 -13
  5. package/dist/DragManager.module.js.map +1 -1
  6. package/dist/DragPreview.main.js +9 -4
  7. package/dist/DragPreview.main.js.map +1 -1
  8. package/dist/DragPreview.mjs +10 -5
  9. package/dist/DragPreview.module.js +10 -5
  10. package/dist/DragPreview.module.js.map +1 -1
  11. package/dist/ListDropTargetDelegate.main.js +5 -4
  12. package/dist/ListDropTargetDelegate.main.js.map +1 -1
  13. package/dist/ListDropTargetDelegate.mjs +5 -4
  14. package/dist/ListDropTargetDelegate.module.js +5 -4
  15. package/dist/ListDropTargetDelegate.module.js.map +1 -1
  16. package/dist/ar-AE.main.js.map +1 -1
  17. package/dist/ar-AE.module.js.map +1 -1
  18. package/dist/bg-BG.main.js.map +1 -1
  19. package/dist/bg-BG.module.js.map +1 -1
  20. package/dist/constants.main.js +3 -3
  21. package/dist/constants.main.js.map +1 -1
  22. package/dist/constants.mjs +3 -3
  23. package/dist/constants.module.js +3 -3
  24. package/dist/constants.module.js.map +1 -1
  25. package/dist/cs-CZ.main.js.map +1 -1
  26. package/dist/cs-CZ.module.js.map +1 -1
  27. package/dist/da-DK.main.js.map +1 -1
  28. package/dist/da-DK.module.js.map +1 -1
  29. package/dist/de-DE.main.js.map +1 -1
  30. package/dist/de-DE.module.js.map +1 -1
  31. package/dist/el-GR.main.js.map +1 -1
  32. package/dist/el-GR.module.js.map +1 -1
  33. package/dist/en-US.main.js.map +1 -1
  34. package/dist/en-US.module.js.map +1 -1
  35. package/dist/es-ES.main.js.map +1 -1
  36. package/dist/es-ES.module.js.map +1 -1
  37. package/dist/et-EE.main.js.map +1 -1
  38. package/dist/et-EE.module.js.map +1 -1
  39. package/dist/fi-FI.main.js.map +1 -1
  40. package/dist/fi-FI.module.js.map +1 -1
  41. package/dist/fr-FR.main.js.map +1 -1
  42. package/dist/fr-FR.module.js.map +1 -1
  43. package/dist/he-IL.main.js.map +1 -1
  44. package/dist/he-IL.module.js.map +1 -1
  45. package/dist/hr-HR.main.js.map +1 -1
  46. package/dist/hr-HR.module.js.map +1 -1
  47. package/dist/hu-HU.main.js.map +1 -1
  48. package/dist/hu-HU.module.js.map +1 -1
  49. package/dist/it-IT.main.js.map +1 -1
  50. package/dist/it-IT.module.js.map +1 -1
  51. package/dist/ja-JP.main.js.map +1 -1
  52. package/dist/ja-JP.module.js.map +1 -1
  53. package/dist/ko-KR.main.js.map +1 -1
  54. package/dist/ko-KR.module.js.map +1 -1
  55. package/dist/lt-LT.main.js.map +1 -1
  56. package/dist/lt-LT.module.js.map +1 -1
  57. package/dist/lv-LV.main.js.map +1 -1
  58. package/dist/lv-LV.module.js.map +1 -1
  59. package/dist/nb-NO.main.js.map +1 -1
  60. package/dist/nb-NO.module.js.map +1 -1
  61. package/dist/nl-NL.main.js.map +1 -1
  62. package/dist/nl-NL.module.js.map +1 -1
  63. package/dist/pl-PL.main.js.map +1 -1
  64. package/dist/pl-PL.module.js.map +1 -1
  65. package/dist/pt-BR.main.js.map +1 -1
  66. package/dist/pt-BR.module.js.map +1 -1
  67. package/dist/pt-PT.main.js.map +1 -1
  68. package/dist/pt-PT.module.js.map +1 -1
  69. package/dist/ro-RO.main.js.map +1 -1
  70. package/dist/ro-RO.module.js.map +1 -1
  71. package/dist/ru-RU.main.js.map +1 -1
  72. package/dist/ru-RU.module.js.map +1 -1
  73. package/dist/sk-SK.main.js.map +1 -1
  74. package/dist/sk-SK.module.js.map +1 -1
  75. package/dist/sl-SI.main.js.map +1 -1
  76. package/dist/sl-SI.module.js.map +1 -1
  77. package/dist/sr-SP.main.js.map +1 -1
  78. package/dist/sr-SP.module.js.map +1 -1
  79. package/dist/sv-SE.main.js.map +1 -1
  80. package/dist/sv-SE.module.js.map +1 -1
  81. package/dist/tr-TR.main.js.map +1 -1
  82. package/dist/tr-TR.module.js.map +1 -1
  83. package/dist/types.d.ts +4 -4
  84. package/dist/types.d.ts.map +1 -1
  85. package/dist/uk-UA.main.js.map +1 -1
  86. package/dist/uk-UA.module.js.map +1 -1
  87. package/dist/useAutoScroll.main.js +5 -5
  88. package/dist/useAutoScroll.main.js.map +1 -1
  89. package/dist/useAutoScroll.mjs +5 -5
  90. package/dist/useAutoScroll.module.js +5 -5
  91. package/dist/useAutoScroll.module.js.map +1 -1
  92. package/dist/useClipboard.main.js +13 -7
  93. package/dist/useClipboard.main.js.map +1 -1
  94. package/dist/useClipboard.mjs +13 -7
  95. package/dist/useClipboard.module.js +13 -7
  96. package/dist/useClipboard.module.js.map +1 -1
  97. package/dist/useDrag.main.js +2 -2
  98. package/dist/useDrag.main.js.map +1 -1
  99. package/dist/useDrag.mjs +2 -2
  100. package/dist/useDrag.module.js +2 -2
  101. package/dist/useDrag.module.js.map +1 -1
  102. package/dist/useDrop.main.js +5 -4
  103. package/dist/useDrop.main.js.map +1 -1
  104. package/dist/useDrop.mjs +5 -4
  105. package/dist/useDrop.module.js +5 -4
  106. package/dist/useDrop.module.js.map +1 -1
  107. package/dist/useDropIndicator.main.js +3 -2
  108. package/dist/useDropIndicator.main.js.map +1 -1
  109. package/dist/useDropIndicator.mjs +3 -2
  110. package/dist/useDropIndicator.module.js +3 -2
  111. package/dist/useDropIndicator.module.js.map +1 -1
  112. package/dist/useDroppableCollection.main.js +33 -19
  113. package/dist/useDroppableCollection.main.js.map +1 -1
  114. package/dist/useDroppableCollection.mjs +33 -19
  115. package/dist/useDroppableCollection.module.js +33 -19
  116. package/dist/useDroppableCollection.module.js.map +1 -1
  117. package/dist/useVirtualDrop.main.js.map +1 -1
  118. package/dist/useVirtualDrop.module.js.map +1 -1
  119. package/dist/utils.main.js +5 -3
  120. package/dist/utils.main.js.map +1 -1
  121. package/dist/utils.mjs +5 -3
  122. package/dist/utils.module.js +5 -3
  123. package/dist/utils.module.js.map +1 -1
  124. package/dist/zh-CN.main.js.map +1 -1
  125. package/dist/zh-CN.module.js.map +1 -1
  126. package/dist/zh-TW.main.js.map +1 -1
  127. package/dist/zh-TW.module.js.map +1 -1
  128. package/package.json +13 -13
  129. package/src/DragManager.ts +26 -24
  130. package/src/DragPreview.tsx +18 -12
  131. package/src/ListDropTargetDelegate.ts +8 -5
  132. package/src/useAutoScroll.ts +6 -6
  133. package/src/useClipboard.ts +12 -6
  134. package/src/useDrag.ts +5 -2
  135. package/src/useDrop.ts +17 -9
  136. package/src/useDropIndicator.ts +10 -4
  137. package/src/useDroppableCollection.ts +62 -39
  138. package/src/useVirtualDrop.ts +3 -2
  139. package/src/utils.ts +16 -10
@@ -106,10 +106,10 @@ function $7f93a158ac20b90a$export$f4e2f423c21f7b04(props, state, ref) {
106
106
  let { dropProps: dropProps } = (0, $1ca228bc9257ca16$exports.useDrop)({
107
107
  ref: ref,
108
108
  onDropEnter () {
109
- state.setTarget(localState.nextTarget);
109
+ if (localState.nextTarget != null) state.setTarget(localState.nextTarget);
110
110
  },
111
111
  onDropMove (e) {
112
- state.setTarget(localState.nextTarget);
112
+ if (localState.nextTarget != null) state.setTarget(localState.nextTarget);
113
113
  autoScroll.move(e.x, e.y);
114
114
  },
115
115
  getDropOperationForPoint (types, allowedOperations, x, y) {
@@ -205,9 +205,11 @@ function $7f93a158ac20b90a$export$f4e2f423c21f7b04(props, state, ref) {
205
205
  state.selectionManager.setFocusedKey(first);
206
206
  if (state.selectionManager.selectionMode === 'none') (0, $foOxf$reactariainteractions.setInteractionModality)('keyboard');
207
207
  }
208
- } else if (state.selectionManager.focusedKey === prevFocusedKey && isInternal && target.type === 'item' && target.dropPosition !== 'on' && draggingKeys.has((_state_collection_getItem = state.collection.getItem(prevFocusedKey)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.parentKey)) {
208
+ } else if (prevFocusedKey != null && state.selectionManager.focusedKey === prevFocusedKey && isInternal && target.type === 'item' && target.dropPosition !== 'on' && draggingKeys.has((_state_collection_getItem = state.collection.getItem(prevFocusedKey)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.parentKey)) {
209
+ var _state_collection_getItem1;
210
+ var _state_collection_getItem_parentKey;
209
211
  // Focus row instead of cell when reordering.
210
- state.selectionManager.setFocusedKey(state.collection.getItem(prevFocusedKey).parentKey);
212
+ state.selectionManager.setFocusedKey((_state_collection_getItem_parentKey = (_state_collection_getItem1 = state.collection.getItem(prevFocusedKey)) === null || _state_collection_getItem1 === void 0 ? void 0 : _state_collection_getItem1.parentKey) !== null && _state_collection_getItem_parentKey !== void 0 ? _state_collection_getItem_parentKey : null);
211
213
  (0, $foOxf$reactariainteractions.setInteractionModality)('keyboard');
212
214
  } else if (state.selectionManager.focusedKey === prevFocusedKey && target.type === 'item' && target.dropPosition === 'on' && state.collection.getItem(target.key) != null) {
213
215
  // If focus didn't move already (e.g. due to an insert), and the user dropped on an item,
@@ -215,7 +217,7 @@ function $7f93a158ac20b90a$export$f4e2f423c21f7b04(props, state, ref) {
215
217
  // Also show the focus ring if the focused key is not selected, e.g. in case of a reorder.
216
218
  state.selectionManager.setFocusedKey(target.key);
217
219
  (0, $foOxf$reactariainteractions.setInteractionModality)('keyboard');
218
- } else if (!state.selectionManager.isSelected(state.selectionManager.focusedKey)) (0, $foOxf$reactariainteractions.setInteractionModality)('keyboard');
220
+ } else if (state.selectionManager.focusedKey != null && !state.selectionManager.isSelected(state.selectionManager.focusedKey)) (0, $foOxf$reactariainteractions.setInteractionModality)('keyboard');
219
221
  state.selectionManager.setFocused(true);
220
222
  }
221
223
  }, [
@@ -225,7 +227,7 @@ function $7f93a158ac20b90a$export$f4e2f423c21f7b04(props, state, ref) {
225
227
  let { state: state } = localState;
226
228
  // Save some state of the collection/selection before the drop occurs so we can compare later.
227
229
  droppingState.current = {
228
- timeout: null,
230
+ timeout: undefined,
229
231
  focusedKey: state.selectionManager.focusedKey,
230
232
  collection: state.collection,
231
233
  selectedKeys: state.selectionManager.selectedKeys,
@@ -255,7 +257,6 @@ function $7f93a158ac20b90a$export$f4e2f423c21f7b04(props, state, ref) {
255
257
  ref,
256
258
  updateFocusAfterDrop
257
259
  ]);
258
- // eslint-disable-next-line arrow-body-style
259
260
  (0, $foOxf$react.useEffect)(()=>{
260
261
  return ()=>{
261
262
  if (droppingState.current) clearTimeout(droppingState.current.timeout);
@@ -267,14 +268,16 @@ function $7f93a158ac20b90a$export$f4e2f423c21f7b04(props, state, ref) {
267
268
  });
268
269
  let { direction: direction } = (0, $foOxf$reactariai18n.useLocale)();
269
270
  (0, $foOxf$react.useEffect)(()=>{
271
+ if (!ref.current) return;
270
272
  let getNextTarget = (target, wrap = true, horizontal = false)=>{
273
+ var _keyboardDelegate_getKeyRightOf, _keyboardDelegate_getKeyBelow, _keyboardDelegate_getLastKey, _keyboardDelegate_getFirstKey;
271
274
  if (!target) return {
272
275
  type: 'root'
273
276
  };
274
277
  let { keyboardDelegate: keyboardDelegate } = localState.props;
275
278
  let nextKey;
276
- if ((target === null || target === void 0 ? void 0 : target.type) === 'item') nextKey = horizontal ? keyboardDelegate.getKeyRightOf(target.key) : keyboardDelegate.getKeyBelow(target.key);
277
- else nextKey = horizontal && direction === 'rtl' ? keyboardDelegate.getLastKey() : keyboardDelegate.getFirstKey();
279
+ if ((target === null || target === void 0 ? void 0 : target.type) === 'item') nextKey = horizontal ? (_keyboardDelegate_getKeyRightOf = keyboardDelegate.getKeyRightOf) === null || _keyboardDelegate_getKeyRightOf === void 0 ? void 0 : _keyboardDelegate_getKeyRightOf.call(keyboardDelegate, target.key) : (_keyboardDelegate_getKeyBelow = keyboardDelegate.getKeyBelow) === null || _keyboardDelegate_getKeyBelow === void 0 ? void 0 : _keyboardDelegate_getKeyBelow.call(keyboardDelegate, target.key);
280
+ else nextKey = horizontal && direction === 'rtl' ? (_keyboardDelegate_getLastKey = keyboardDelegate.getLastKey) === null || _keyboardDelegate_getLastKey === void 0 ? void 0 : _keyboardDelegate_getLastKey.call(keyboardDelegate) : (_keyboardDelegate_getFirstKey = keyboardDelegate.getFirstKey) === null || _keyboardDelegate_getFirstKey === void 0 ? void 0 : _keyboardDelegate_getFirstKey.call(keyboardDelegate);
278
281
  let dropPositions = horizontal && direction === 'rtl' ? $7f93a158ac20b90a$var$DROP_POSITIONS_RTL : $7f93a158ac20b90a$var$DROP_POSITIONS;
279
282
  let dropPosition = dropPositions[0];
280
283
  if (target.type === 'item') {
@@ -308,10 +311,11 @@ function $7f93a158ac20b90a$export$f4e2f423c21f7b04(props, state, ref) {
308
311
  };
309
312
  };
310
313
  let getPreviousTarget = (target, wrap = true, horizontal = false)=>{
314
+ var _keyboardDelegate_getKeyLeftOf, _keyboardDelegate_getKeyAbove, _keyboardDelegate_getFirstKey, _keyboardDelegate_getLastKey;
311
315
  let { keyboardDelegate: keyboardDelegate } = localState.props;
312
316
  let nextKey;
313
- if ((target === null || target === void 0 ? void 0 : target.type) === 'item') nextKey = horizontal ? keyboardDelegate.getKeyLeftOf(target.key) : keyboardDelegate.getKeyAbove(target.key);
314
- else nextKey = horizontal && direction === 'rtl' ? keyboardDelegate.getFirstKey() : keyboardDelegate.getLastKey();
317
+ if ((target === null || target === void 0 ? void 0 : target.type) === 'item') nextKey = horizontal ? (_keyboardDelegate_getKeyLeftOf = keyboardDelegate.getKeyLeftOf) === null || _keyboardDelegate_getKeyLeftOf === void 0 ? void 0 : _keyboardDelegate_getKeyLeftOf.call(keyboardDelegate, target.key) : (_keyboardDelegate_getKeyAbove = keyboardDelegate.getKeyAbove) === null || _keyboardDelegate_getKeyAbove === void 0 ? void 0 : _keyboardDelegate_getKeyAbove.call(keyboardDelegate, target.key);
318
+ else nextKey = horizontal && direction === 'rtl' ? (_keyboardDelegate_getFirstKey = keyboardDelegate.getFirstKey) === null || _keyboardDelegate_getFirstKey === void 0 ? void 0 : _keyboardDelegate_getFirstKey.call(keyboardDelegate) : (_keyboardDelegate_getLastKey = keyboardDelegate.getLastKey) === null || _keyboardDelegate_getLastKey === void 0 ? void 0 : _keyboardDelegate_getLastKey.call(keyboardDelegate);
315
319
  let dropPositions = horizontal && direction === 'rtl' ? $7f93a158ac20b90a$var$DROP_POSITIONS_RTL : $7f93a158ac20b90a$var$DROP_POSITIONS;
316
320
  let dropPosition = !target || target.type === 'root' ? dropPositions[2] : 'on';
317
321
  if ((target === null || target === void 0 ? void 0 : target.type) === 'item') {
@@ -388,7 +392,7 @@ function $7f93a158ac20b90a$export$f4e2f423c21f7b04(props, state, ref) {
388
392
  onDropEnter (e, drag) {
389
393
  let types = (0, $4620ae0dc40f0031$exports.getTypes)(drag.items);
390
394
  let selectionManager = localState.state.selectionManager;
391
- let target;
395
+ let target = null;
392
396
  // Update the drop collection ref tracker for useDroppableItem's getDropOperation isInternal check
393
397
  (0, $4620ae0dc40f0031$exports.setDropCollectionRef)(ref);
394
398
  // When entering the droppable collection for the first time, the default drop target
@@ -397,13 +401,13 @@ function $7f93a158ac20b90a$export$f4e2f423c21f7b04(props, state, ref) {
397
401
  let dropPosition = 'after';
398
402
  // If the focused key is a cell, get the parent item instead.
399
403
  // For now, we assume that individual cells cannot be dropped on.
400
- let item = localState.state.collection.getItem(key);
404
+ let item = key != null ? localState.state.collection.getItem(key) : null;
401
405
  if ((item === null || item === void 0 ? void 0 : item.type) === 'cell') key = item.parentKey;
402
406
  // If the focused item is also selected, the default drop target is after the last selected item.
403
407
  // But if the focused key is the first selected item, then default to before the first selected item.
404
408
  // This is to make reordering lists slightly easier. If you select top down, we assume you want to
405
409
  // move the items down. If you select bottom up, we assume you want to move the items up.
406
- if (selectionManager.isSelected(key)) {
410
+ if (key != null && selectionManager.isSelected(key)) {
407
411
  if (selectionManager.selectedKeys.size > 1 && selectionManager.firstSelectedKey === key) dropPosition = 'before';
408
412
  else key = selectionManager.lastSelectedKey;
409
413
  }
@@ -494,14 +498,21 @@ function $7f93a158ac20b90a$export$f4e2f423c21f7b04(props, state, ref) {
494
498
  let target = localState.state.target;
495
499
  if (!target) target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);
496
500
  else {
501
+ var _keyboardDelegate_getFirstKey, _keyboardDelegate_getLastKey;
497
502
  // If on the root, go to the item a page below the top. Otherwise a page below the current item.
498
- let nextKey = keyboardDelegate.getKeyPageBelow(target.type === 'item' ? target.key : keyboardDelegate.getFirstKey());
503
+ let targetKey = (_keyboardDelegate_getFirstKey = keyboardDelegate.getFirstKey) === null || _keyboardDelegate_getFirstKey === void 0 ? void 0 : _keyboardDelegate_getFirstKey.call(keyboardDelegate);
504
+ if (target.type === 'item') targetKey = target.key;
505
+ let nextKey = null;
506
+ if (targetKey != null) nextKey = keyboardDelegate.getKeyPageBelow(targetKey);
499
507
  let dropPosition = target.type === 'item' ? target.dropPosition : 'after';
500
508
  // If there is no next key, or we are starting on the last key, jump to the last possible position.
501
- if (nextKey == null || target.type === 'item' && target.key === keyboardDelegate.getLastKey()) {
502
- nextKey = keyboardDelegate.getLastKey();
509
+ if (nextKey == null || target.type === 'item' && target.key === ((_keyboardDelegate_getLastKey = keyboardDelegate.getLastKey) === null || _keyboardDelegate_getLastKey === void 0 ? void 0 : _keyboardDelegate_getLastKey.call(keyboardDelegate))) {
510
+ var _keyboardDelegate_getLastKey1;
511
+ var _keyboardDelegate_getLastKey2;
512
+ nextKey = (_keyboardDelegate_getLastKey2 = (_keyboardDelegate_getLastKey1 = keyboardDelegate.getLastKey) === null || _keyboardDelegate_getLastKey1 === void 0 ? void 0 : _keyboardDelegate_getLastKey1.call(keyboardDelegate)) !== null && _keyboardDelegate_getLastKey2 !== void 0 ? _keyboardDelegate_getLastKey2 : null;
503
513
  dropPosition = 'after';
504
514
  }
515
+ if (nextKey == null) break;
505
516
  target = {
506
517
  type: 'item',
507
518
  key: nextKey,
@@ -530,17 +541,20 @@ function $7f93a158ac20b90a$export$f4e2f423c21f7b04(props, state, ref) {
530
541
  let target = localState.state.target;
531
542
  if (!target) target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);
532
543
  else if (target.type === 'item') {
544
+ var _keyboardDelegate_getFirstKey1;
533
545
  // If at the top already, switch to the root. Otherwise navigate a page up.
534
- if (target.key === keyboardDelegate.getFirstKey()) target = {
546
+ if (target.key === ((_keyboardDelegate_getFirstKey1 = keyboardDelegate.getFirstKey) === null || _keyboardDelegate_getFirstKey1 === void 0 ? void 0 : _keyboardDelegate_getFirstKey1.call(keyboardDelegate))) target = {
535
547
  type: 'root'
536
548
  };
537
549
  else {
538
550
  let nextKey = keyboardDelegate.getKeyPageAbove(target.key);
539
551
  let dropPosition = target.dropPosition;
540
552
  if (nextKey == null) {
541
- nextKey = keyboardDelegate.getFirstKey();
553
+ var _keyboardDelegate_getFirstKey2;
554
+ nextKey = (_keyboardDelegate_getFirstKey2 = keyboardDelegate.getFirstKey) === null || _keyboardDelegate_getFirstKey2 === void 0 ? void 0 : _keyboardDelegate_getFirstKey2.call(keyboardDelegate);
542
555
  dropPosition = 'before';
543
556
  }
557
+ if (nextKey == null) break;
544
558
  target = {
545
559
  type: 'item',
546
560
  key: nextKey,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAwDD,MAAM,uCAAiC;IAAC;IAAU;IAAM;CAAQ;AAChE,MAAM,2CAAqC;IAAC;IAAS;IAAM;CAAS;AAM7D,SAAS,0CAAuB,KAAiC,EAAE,KAA+B,EAAE,GAAkC;IAC3I,IAAI,aAAa,CAAA,GAAA,mBAAK,EAAE;eACtB;eACA;QACA,YAAY;QACZ,eAAe;IACjB,GAAG,OAAO;IACV,WAAW,KAAK,GAAG;IACnB,WAAW,KAAK,GAAG;IAEnB,IAAI,gBAAgB,CAAA,GAAA,wBAAU,EAAE,OAAO;QACrC,IAAI,YACF,QAAQ,cACR,UAAU,cACV,UAAU,aACV,SAAS,qBACT,oBAAoB,6BACpB,oBAAoB,EACrB,GAAG,WAAW,KAAK;QAEpB,IAAI,gBAAC,YAA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AAqB;gDAAE;kDAAY;gCAAY;oCAE9H;gCADX,IAAI,cAAc,UAChB,SAAS,CAAA,oBAAA,gBAAgB,QAAQ,OAAO,KAAK,qBAAqB,EAAE,mBAAmB,oBAA9E,+BAAA,oBACJ,gBAAgB,QAAQ,OAAO,KAAK,qBAAqB,EAAE,eAAe;4BAEnF;4BAEA,WAAW,KAAK,CAAC,SAAS,CAAC,mBAAA,oBAAA,SAAU,WAAW,KAAK,CAAC,MAAM;4BAC5D;wBACF;gBACF;YACF;QACF;IACF,GAAG;QAAC;QAAY;QAAK;QAAQ;KAAU;IAEvC,IAAI,KAAK,CAAA,GAAA,2BAAI;IACb,CAAA,GAAA,gDAAqB,EAAE,GAAG,CAAC,OAAO;YAAC;aAAI;IAAG;IAC1C,OAAO;QACL,iBAAiB,CAAA,GAAA,gCAAS,EAAE,WAAW;gBACrC;YACA,oFAAoF;YACpF,6FAA6F;YAC7F,oBAAoB;QACtB;IACF;AACF","sources":["packages/@react-aria/dnd/src/useDroppableCollection.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 {\n clearGlobalDnDState,\n DIRECTORY_DRAG_TYPE,\n droppableCollectionMap,\n getTypes,\n globalDndState,\n isInternalDropOperation,\n setDropCollectionRef\n} from './utils';\nimport {\n Collection,\n DropEvent,\n DropOperation,\n DroppableCollectionDropEvent,\n DroppableCollectionProps,\n DropPosition,\n DropTarget,\n DropTargetDelegate,\n Key,\n KeyboardDelegate,\n Node,\n RefObject\n} from '@react-types/shared';\nimport * as DragManager from './DragManager';\nimport {DroppableCollectionState} from '@react-stately/dnd';\nimport {HTMLAttributes, useCallback, useEffect, useRef} from 'react';\nimport {mergeProps, useId, useLayoutEffect} from '@react-aria/utils';\nimport {setInteractionModality} from '@react-aria/interactions';\nimport {useAutoScroll} from './useAutoScroll';\nimport {useDrop} from './useDrop';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface DroppableCollectionOptions extends DroppableCollectionProps {\n /** A delegate object that implements behavior for keyboard focus movement. */\n keyboardDelegate: KeyboardDelegate,\n /** A delegate object that provides drop targets for pointer coordinates within the collection. */\n dropTargetDelegate: DropTargetDelegate\n}\n\nexport interface DroppableCollectionResult {\n /** Props for the collection element. */\n collectionProps: HTMLAttributes<HTMLElement>\n}\n\ninterface DroppingState {\n collection: Collection<Node<unknown>>,\n focusedKey: Key,\n selectedKeys: Set<Key>,\n target: DropTarget,\n draggingKeys: Set<Key>,\n isInternal: boolean,\n timeout: ReturnType<typeof setTimeout>\n}\n\nconst DROP_POSITIONS: DropPosition[] = ['before', 'on', 'after'];\nconst DROP_POSITIONS_RTL: DropPosition[] = ['after', 'on', 'before'];\n\n/**\n * Handles drop interactions for a collection component, with support for traditional mouse and touch\n * based drag and drop, in addition to full parity for keyboard and screen reader users.\n */\nexport function useDroppableCollection(props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>): DroppableCollectionResult {\n let localState = useRef({\n props,\n state,\n nextTarget: null,\n dropOperation: null\n }).current;\n localState.props = props;\n localState.state = state;\n\n let defaultOnDrop = useCallback(async (e: DroppableCollectionDropEvent) => {\n let {\n onInsert,\n onRootDrop,\n onItemDrop,\n onReorder,\n acceptedDragTypes = 'all',\n shouldAcceptItemDrop\n } = localState.props;\n\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n let {\n target,\n dropOperation,\n items\n } = e;\n\n let filteredItems = items;\n if (acceptedDragTypes !== 'all' || shouldAcceptItemDrop) {\n filteredItems = items.filter(item => {\n let itemTypes: Set<string | symbol>;\n if (item.kind === 'directory') {\n itemTypes = new Set([DIRECTORY_DRAG_TYPE]);\n } else {\n itemTypes = item.kind === 'file' ? new Set([item.type]) : item.types;\n }\n\n if (acceptedDragTypes === 'all' || acceptedDragTypes.some(type => itemTypes.has(type))) {\n // If we are performing a on item drop, check if the item in question accepts the dropped item since the item may have heavier restrictions\n // than the droppable collection itself\n if (target.type === 'item' && target.dropPosition === 'on' && shouldAcceptItemDrop) {\n return shouldAcceptItemDrop(target, itemTypes);\n }\n return true;\n }\n\n return false;\n });\n }\n\n if (filteredItems.length > 0) {\n if (target.type === 'root' && onRootDrop) {\n await onRootDrop({items: filteredItems, dropOperation});\n }\n\n if (target.type === 'item') {\n if (target.dropPosition === 'on' && onItemDrop) {\n await onItemDrop({items: filteredItems, dropOperation, isInternal, target});\n }\n\n if (target.dropPosition !== 'on') {\n if (!isInternal && onInsert) {\n await onInsert({items: filteredItems, dropOperation, target});\n }\n\n if (isInternal && onReorder) {\n await onReorder({keys: draggingKeys, dropOperation, target});\n }\n }\n }\n }\n }, [localState, ref]);\n\n let autoScroll = useAutoScroll(ref);\n let {dropProps} = useDrop({\n ref,\n onDropEnter() {\n state.setTarget(localState.nextTarget);\n },\n onDropMove(e) {\n state.setTarget(localState.nextTarget);\n autoScroll.move(e.x, e.y);\n },\n getDropOperationForPoint(types, allowedOperations, x, y) {\n let {draggingKeys, dropCollectionRef} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n let isValidDropTarget = (target) => state.getDropOperation({target, types, allowedOperations, isInternal, draggingKeys}) !== 'cancel';\n let target = props.dropTargetDelegate.getDropTargetFromPoint(x, y, isValidDropTarget);\n if (!target) {\n localState.dropOperation = 'cancel';\n localState.nextTarget = null;\n return 'cancel';\n }\n\n localState.dropOperation = state.getDropOperation({target, types, allowedOperations, isInternal, draggingKeys});\n\n // If the target doesn't accept the drop, see if the root accepts it instead.\n if (localState.dropOperation === 'cancel') {\n let rootTarget: DropTarget = {type: 'root'};\n let dropOperation = state.getDropOperation({target: rootTarget, types, allowedOperations, isInternal, draggingKeys});\n if (dropOperation !== 'cancel') {\n target = rootTarget;\n localState.dropOperation = dropOperation;\n }\n }\n\n // Only set dropCollectionRef if there is a valid drop target since we cleanup dropCollectionRef in onDropExit\n // which only runs when leaving a valid drop target or if the dropEffect become none (mouse dnd only).\n if (target && localState.dropOperation !== 'cancel' && ref?.current !== dropCollectionRef?.current) {\n setDropCollectionRef(ref);\n }\n localState.nextTarget = localState.dropOperation === 'cancel' ? null : target;\n return localState.dropOperation;\n },\n onDropExit() {\n setDropCollectionRef(undefined);\n state.setTarget(null);\n autoScroll.stop();\n },\n onDropActivate(e) {\n if (state.target?.type === 'item' && state.target?.dropPosition === 'on' && typeof props.onDropActivate === 'function') {\n props.onDropActivate({\n type: 'dropactivate',\n x: e.x, // todo\n y: e.y,\n target: state.target\n });\n }\n },\n onDrop(e) {\n setDropCollectionRef(ref);\n if (state.target) {\n onDrop(e, state.target);\n }\n\n // If there wasn't a collection being tracked as a dragged collection, then we are in a case where a non RSP drag is dropped on a\n // RSP collection and thus we don't need to preserve the global DnD state for onDragEnd\n let {draggingCollectionRef} = globalDndState;\n if (draggingCollectionRef == null) {\n clearGlobalDnDState();\n }\n }\n });\n\n let droppingState = useRef<DroppingState>(null);\n let updateFocusAfterDrop = useCallback(() => {\n let {state} = localState;\n if (droppingState.current) {\n let {\n target,\n collection: prevCollection,\n selectedKeys: prevSelectedKeys,\n focusedKey: prevFocusedKey,\n isInternal,\n draggingKeys\n } = droppingState.current;\n \n // If an insert occurs during a drop, we want to immediately select these items to give\n // feedback to the user that a drop occurred. Only do this if the selection didn't change\n // since the drop started so we don't override if the user or application did something.\n if (\n state.collection.size > prevCollection.size &&\n state.selectionManager.isSelectionEqual(prevSelectedKeys)\n ) {\n let newKeys = new Set<Key>();\n for (let key of state.collection.getKeys()) {\n if (!prevCollection.getItem(key)) {\n newKeys.add(key);\n }\n }\n\n state.selectionManager.setSelectedKeys(newKeys);\n\n // If the focused item didn't change since the drop occurred, also focus the first\n // inserted item. If selection is disabled, then also show the focus ring so there\n // is some indication that items were added.\n if (state.selectionManager.focusedKey === prevFocusedKey) {\n let first = newKeys.keys().next().value;\n let item = state.collection.getItem(first);\n\n // If this is a cell, focus the parent row.\n if (item?.type === 'cell') {\n first = item.parentKey;\n }\n\n state.selectionManager.setFocusedKey(first);\n\n if (state.selectionManager.selectionMode === 'none') {\n setInteractionModality('keyboard');\n }\n }\n } else if (\n state.selectionManager.focusedKey === prevFocusedKey &&\n isInternal &&\n target.type === 'item' &&\n target.dropPosition !== 'on' &&\n draggingKeys.has(state.collection.getItem(prevFocusedKey)?.parentKey)\n ) {\n // Focus row instead of cell when reordering.\n state.selectionManager.setFocusedKey(state.collection.getItem(prevFocusedKey).parentKey);\n setInteractionModality('keyboard');\n } else if (\n state.selectionManager.focusedKey === prevFocusedKey &&\n target.type === 'item' && \n target.dropPosition === 'on' && \n state.collection.getItem(target.key) != null\n ) {\n // If focus didn't move already (e.g. due to an insert), and the user dropped on an item,\n // focus that item and show the focus ring to give the user feedback that the drop occurred.\n // Also show the focus ring if the focused key is not selected, e.g. in case of a reorder.\n state.selectionManager.setFocusedKey(target.key);\n setInteractionModality('keyboard');\n } else if (!state.selectionManager.isSelected(state.selectionManager.focusedKey)) {\n setInteractionModality('keyboard');\n }\n\n state.selectionManager.setFocused(true);\n }\n }, [localState]);\n\n let onDrop = useCallback((e: DropEvent, target: DropTarget) => {\n let {state} = localState;\n \n // Save some state of the collection/selection before the drop occurs so we can compare later.\n droppingState.current = {\n timeout: null,\n focusedKey: state.selectionManager.focusedKey,\n collection: state.collection,\n selectedKeys: state.selectionManager.selectedKeys,\n draggingKeys: globalDndState.draggingKeys,\n isInternal: isInternalDropOperation(ref),\n target\n };\n\n let onDropFn = localState.props.onDrop || defaultOnDrop;\n onDropFn({\n type: 'drop',\n x: e.x, // todo\n y: e.y,\n target,\n items: e.items,\n dropOperation: e.dropOperation\n });\n\n // Wait for a short time period after the onDrop is called to allow the data to be read asynchronously\n // and for React to re-render. If the collection didn't already change during this time (handled below),\n // update the focused key here.\n droppingState.current.timeout = setTimeout(() => {\n updateFocusAfterDrop();\n droppingState.current = null;\n }, 50);\n }, [localState, defaultOnDrop, ref, updateFocusAfterDrop]);\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n if (droppingState.current) {\n clearTimeout(droppingState.current.timeout);\n }\n };\n }, []);\n\n useLayoutEffect(() => {\n // If the collection changed after a drop, update the focused key.\n if (droppingState.current && state.collection !== droppingState.current.collection) {\n updateFocusAfterDrop();\n }\n });\n\n let {direction} = useLocale();\n useEffect(() => {\n let getNextTarget = (target: DropTarget, wrap = true, horizontal = false): DropTarget => {\n if (!target) {\n return {\n type: 'root'\n };\n }\n\n let {keyboardDelegate} = localState.props;\n let nextKey: Key;\n if (target?.type === 'item') {\n nextKey = horizontal ? keyboardDelegate.getKeyRightOf(target.key) : keyboardDelegate.getKeyBelow(target.key);\n } else {\n nextKey = horizontal && direction === 'rtl' ? keyboardDelegate.getLastKey() : keyboardDelegate.getFirstKey();\n }\n let dropPositions = horizontal && direction === 'rtl' ? DROP_POSITIONS_RTL : DROP_POSITIONS;\n let dropPosition: DropPosition = dropPositions[0];\n\n if (target.type === 'item') {\n // If the the keyboard delegate returned the next key in the collection,\n // first try the other positions in the current key. Otherwise (e.g. in a grid layout),\n // jump to the same drop position in the new key.\n let nextCollectionKey = horizontal && direction === 'rtl' ? localState.state.collection.getKeyBefore(target.key) : localState.state.collection.getKeyAfter(target.key);\n if (nextKey == null || nextKey === nextCollectionKey) {\n let positionIndex = dropPositions.indexOf(target.dropPosition);\n let nextDropPosition = dropPositions[positionIndex + 1];\n if (positionIndex < dropPositions.length - 1 && !(nextDropPosition === dropPositions[2] && nextKey != null)) {\n return {\n type: 'item',\n key: target.key,\n dropPosition: nextDropPosition\n };\n }\n\n // If the last drop position was 'after', then 'before' on the next key is equivalent.\n // Switch to 'on' instead.\n if (target.dropPosition === dropPositions[2]) {\n dropPosition = 'on';\n }\n } else {\n dropPosition = target.dropPosition;\n }\n }\n\n if (nextKey == null) {\n if (wrap) {\n return {\n type: 'root'\n };\n }\n\n return null;\n }\n\n return {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n };\n\n let getPreviousTarget = (target: DropTarget, wrap = true, horizontal = false): DropTarget => {\n let {keyboardDelegate} = localState.props;\n let nextKey: Key;\n if (target?.type === 'item') {\n nextKey = horizontal ? keyboardDelegate.getKeyLeftOf(target.key) : keyboardDelegate.getKeyAbove(target.key);\n } else {\n nextKey = horizontal && direction === 'rtl' ? keyboardDelegate.getFirstKey() : keyboardDelegate.getLastKey();\n }\n let dropPositions = horizontal && direction === 'rtl' ? DROP_POSITIONS_RTL : DROP_POSITIONS;\n let dropPosition: DropPosition = !target || target.type === 'root' ? dropPositions[2] : 'on';\n\n if (target?.type === 'item') {\n // If the the keyboard delegate returned the previous key in the collection,\n // first try the other positions in the current key. Otherwise (e.g. in a grid layout),\n // jump to the same drop position in the new key.\n let prevCollectionKey = horizontal && direction === 'rtl' ? localState.state.collection.getKeyAfter(target.key) : localState.state.collection.getKeyBefore(target.key);\n if (nextKey == null || nextKey === prevCollectionKey) {\n let positionIndex = dropPositions.indexOf(target.dropPosition);\n let nextDropPosition = dropPositions[positionIndex - 1];\n if (positionIndex > 0 && nextDropPosition !== dropPositions[2]) {\n return {\n type: 'item',\n key: target.key,\n dropPosition: nextDropPosition\n };\n }\n\n // If the last drop position was 'before', then 'after' on the previous key is equivalent.\n // Switch to 'on' instead.\n if (target.dropPosition === dropPositions[0]) {\n dropPosition = 'on';\n }\n } else {\n dropPosition = target.dropPosition;\n }\n }\n\n if (nextKey == null) {\n if (wrap) {\n return {\n type: 'root'\n };\n }\n\n return null;\n }\n\n return {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n };\n\n let nextValidTarget = (\n target: DropTarget,\n types: Set<string>,\n allowedDropOperations: DropOperation[],\n getNextTarget: (target: DropTarget, wrap: boolean) => DropTarget,\n wrap = true\n ): DropTarget => {\n let seenRoot = 0;\n let operation: DropOperation;\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n do {\n let nextTarget = getNextTarget(target, wrap);\n if (!nextTarget) {\n return null;\n }\n target = nextTarget;\n operation = localState.state.getDropOperation({target: nextTarget, types, allowedOperations: allowedDropOperations, isInternal, draggingKeys});\n if (target.type === 'root') {\n seenRoot++;\n }\n } while (\n operation === 'cancel' &&\n !localState.state.isDropTarget(target) &&\n seenRoot < 2\n );\n\n if (operation === 'cancel') {\n return null;\n }\n\n return target;\n };\n\n return DragManager.registerDropTarget({\n element: ref.current,\n preventFocusOnDrop: true,\n getDropOperation(types, allowedOperations) {\n if (localState.state.target) {\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n return localState.state.getDropOperation({target: localState.state.target, types, allowedOperations, isInternal, draggingKeys});\n }\n\n // Check if any of the targets accept the drop.\n // TODO: should we have a faster way of doing this or e.g. for pagination?\n let target = nextValidTarget(null, types, allowedOperations, getNextTarget);\n return target ? 'move' : 'cancel';\n },\n onDropEnter(e, drag) {\n let types = getTypes(drag.items);\n let selectionManager = localState.state.selectionManager;\n let target: DropTarget;\n // Update the drop collection ref tracker for useDroppableItem's getDropOperation isInternal check\n setDropCollectionRef(ref);\n\n // When entering the droppable collection for the first time, the default drop target\n // is after the focused key.\n let key = selectionManager.focusedKey;\n let dropPosition: DropPosition = 'after';\n\n // If the focused key is a cell, get the parent item instead.\n // For now, we assume that individual cells cannot be dropped on.\n let item = localState.state.collection.getItem(key);\n if (item?.type === 'cell') {\n key = item.parentKey;\n }\n\n // If the focused item is also selected, the default drop target is after the last selected item.\n // But if the focused key is the first selected item, then default to before the first selected item.\n // This is to make reordering lists slightly easier. If you select top down, we assume you want to\n // move the items down. If you select bottom up, we assume you want to move the items up.\n if (selectionManager.isSelected(key)) {\n if (selectionManager.selectedKeys.size > 1 && selectionManager.firstSelectedKey === key) {\n dropPosition = 'before';\n } else {\n key = selectionManager.lastSelectedKey;\n }\n }\n\n if (key != null) {\n target = {\n type: 'item',\n key,\n dropPosition\n };\n\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n // If the default target is not valid, find the next one that is.\n if (localState.state.getDropOperation({target, types, allowedOperations: drag.allowedDropOperations, isInternal, draggingKeys}) === 'cancel') {\n target = nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false)\n ?? nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false);\n }\n }\n\n // If no focused key, then start from the root.\n if (!target) {\n target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);\n }\n\n localState.state.setTarget(target);\n },\n onDropExit() {\n setDropCollectionRef(undefined);\n localState.state.setTarget(null);\n },\n onDropTargetEnter(target) {\n localState.state.setTarget(target);\n },\n onDropActivate(e) {\n if (\n localState.state.target?.type === 'item' &&\n localState.state.target?.dropPosition === 'on' &&\n typeof localState.props.onDropActivate === 'function'\n ) {\n localState.props.onDropActivate({\n type: 'dropactivate',\n x: e.x, // todo\n y: e.y,\n target: localState.state.target\n });\n }\n },\n onDrop(e, target) {\n setDropCollectionRef(ref);\n if (localState.state.target) {\n onDrop(e, target || localState.state.target);\n }\n },\n onKeyDown(e, drag) {\n let {keyboardDelegate} = localState.props;\n let types = getTypes(drag.items);\n switch (e.key) {\n case 'ArrowDown': {\n if (keyboardDelegate.getKeyBelow) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, getNextTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'ArrowUp': {\n if (keyboardDelegate.getKeyAbove) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, getPreviousTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'ArrowLeft': {\n if (keyboardDelegate.getKeyLeftOf) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap) => getPreviousTarget(target, wrap, true));\n localState.state.setTarget(target);\n }\n break;\n }\n case 'ArrowRight': {\n if (keyboardDelegate.getKeyRightOf) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap) => getNextTarget(target, wrap, true));\n localState.state.setTarget(target);\n }\n break;\n }\n case 'Home': {\n if (keyboardDelegate.getFirstKey) {\n let target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'End': {\n if (keyboardDelegate.getLastKey) {\n let target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'PageDown': {\n if (keyboardDelegate.getKeyPageBelow) {\n let target = localState.state.target;\n if (!target) {\n target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);\n } else {\n // If on the root, go to the item a page below the top. Otherwise a page below the current item.\n let nextKey = keyboardDelegate.getKeyPageBelow(\n target.type === 'item'\n ? target.key\n : keyboardDelegate.getFirstKey()\n );\n let dropPosition = target.type === 'item' ? target.dropPosition : 'after';\n\n // If there is no next key, or we are starting on the last key, jump to the last possible position.\n if (nextKey == null || (target.type === 'item' && target.key === keyboardDelegate.getLastKey())) {\n nextKey = keyboardDelegate.getLastKey();\n dropPosition = 'after';\n }\n\n target = {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n\n // If the target does not accept the drop, find the next valid target.\n // If no next valid target, find the previous valid target.\n let {draggingCollectionRef, draggingKeys} = globalDndState;\n let isInternal = draggingCollectionRef?.current === ref?.current;\n let operation = localState.state.getDropOperation({target, types, allowedOperations: drag.allowedDropOperations, isInternal, draggingKeys});\n if (operation === 'cancel') {\n target = nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false)\n ?? nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false);\n }\n }\n\n localState.state.setTarget(target ?? localState.state.target);\n }\n break;\n }\n case 'PageUp': {\n if (!keyboardDelegate.getKeyPageAbove) {\n break;\n }\n\n let target = localState.state.target;\n if (!target) {\n target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);\n } else if (target.type === 'item') {\n // If at the top already, switch to the root. Otherwise navigate a page up.\n if (target.key === keyboardDelegate.getFirstKey()) {\n target = {\n type: 'root'\n };\n } else {\n let nextKey = keyboardDelegate.getKeyPageAbove(target.key);\n let dropPosition = target.dropPosition;\n if (nextKey == null) {\n nextKey = keyboardDelegate.getFirstKey();\n dropPosition = 'before';\n }\n\n target = {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n }\n\n // If the target does not accept the drop, find the previous valid target.\n // If no next valid target, find the next valid target.\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n let operation = localState.state.getDropOperation({target, types, allowedOperations: drag.allowedDropOperations, isInternal, draggingKeys});\n if (operation === 'cancel') {\n target = nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false)\n ?? nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false);\n }\n }\n\n localState.state.setTarget(target ?? localState.state.target);\n break;\n }\n }\n }\n });\n }, [localState, ref, onDrop, direction]);\n\n let id = useId();\n droppableCollectionMap.set(state, {id, ref});\n return {\n collectionProps: mergeProps(dropProps, {\n id,\n // Remove description from collection element. If dropping on the entire collection,\n // there should be a drop indicator that has this description, so no need to double announce.\n 'aria-describedby': null\n })\n };\n}\n"],"names":[],"version":3,"file":"useDroppableCollection.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAwDD,MAAM,uCAAiC;IAAC;IAAU;IAAM;CAAQ;AAChE,MAAM,2CAAqC;IAAC;IAAS;IAAM;CAAS;AAM7D,SAAS,0CAAuB,KAAiC,EAAE,KAA+B,EAAE,GAAkC;IAC3I,IAAI,aAAa,CAAA,GAAA,mBAAK,EAKnB;eACD;eACA;QACA,YAAY;QACZ,eAAe;IACjB,GAAG,OAAO;IACV,WAAW,KAAK,GAAG;IACnB,WAAW,KAAK,GAAG;IAEnB,IAAI,gBAAgB,CAAA,GAAA,wBAAU,EAAE,OAAO;QACrC,IAAI,YACF,QAAQ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BAEA,WAAW,KAAK,CAAC,SAAS,CAAC,mBAAA,oBAAA,SAAU,WAAW,KAAK,CAAC,MAAM;4BAC5D;wBACF;gBACF;YACF;QACF;IACF,GAAG;QAAC;QAAY;QAAK;QAAQ;KAAU;IAEvC,IAAI,KAAK,CAAA,GAAA,2BAAI;IACb,CAAA,GAAA,gDAAqB,EAAE,GAAG,CAAC,OAAO;YAAC;aAAI;IAAG;IAC1C,OAAO;QACL,iBAAiB,CAAA,GAAA,gCAAS,EAAE,WAAW;gBACrC;YACA,oFAAoF;YACpF,6FAA6F;YAC7F,oBAAoB;QACtB;IACF;AACF","sources":["packages/@react-aria/dnd/src/useDroppableCollection.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 {\n clearGlobalDnDState,\n DIRECTORY_DRAG_TYPE,\n droppableCollectionMap,\n getTypes,\n globalDndState,\n isInternalDropOperation,\n setDropCollectionRef\n} from './utils';\nimport {\n Collection,\n DropEvent,\n DropOperation,\n DroppableCollectionDropEvent,\n DroppableCollectionProps,\n DropPosition,\n DropTarget,\n DropTargetDelegate,\n Key,\n KeyboardDelegate,\n Node,\n RefObject\n} from '@react-types/shared';\nimport * as DragManager from './DragManager';\nimport {DroppableCollectionState} from '@react-stately/dnd';\nimport {HTMLAttributes, useCallback, useEffect, useRef} from 'react';\nimport {mergeProps, useId, useLayoutEffect} from '@react-aria/utils';\nimport {setInteractionModality} from '@react-aria/interactions';\nimport {useAutoScroll} from './useAutoScroll';\nimport {useDrop} from './useDrop';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface DroppableCollectionOptions extends DroppableCollectionProps {\n /** A delegate object that implements behavior for keyboard focus movement. */\n keyboardDelegate: KeyboardDelegate,\n /** A delegate object that provides drop targets for pointer coordinates within the collection. */\n dropTargetDelegate: DropTargetDelegate\n}\n\nexport interface DroppableCollectionResult {\n /** Props for the collection element. */\n collectionProps: HTMLAttributes<HTMLElement>\n}\n\ninterface DroppingState {\n collection: Collection<Node<unknown>>,\n focusedKey: Key | null,\n selectedKeys: Set<Key>,\n target: DropTarget,\n draggingKeys: Set<Key | null | undefined>,\n isInternal: boolean,\n timeout: ReturnType<typeof setTimeout> | undefined\n}\n\nconst DROP_POSITIONS: DropPosition[] = ['before', 'on', 'after'];\nconst DROP_POSITIONS_RTL: DropPosition[] = ['after', 'on', 'before'];\n\n/**\n * Handles drop interactions for a collection component, with support for traditional mouse and touch\n * based drag and drop, in addition to full parity for keyboard and screen reader users.\n */\nexport function useDroppableCollection(props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>): DroppableCollectionResult {\n let localState = useRef<{\n props: DroppableCollectionOptions,\n state: DroppableCollectionState,\n nextTarget: DropTarget | null,\n dropOperation: DropOperation | null\n }>({\n props,\n state,\n nextTarget: null,\n dropOperation: null\n }).current;\n localState.props = props;\n localState.state = state;\n\n let defaultOnDrop = useCallback(async (e: DroppableCollectionDropEvent) => {\n let {\n onInsert,\n onRootDrop,\n onItemDrop,\n onReorder,\n acceptedDragTypes = 'all',\n shouldAcceptItemDrop\n } = localState.props;\n\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n let {\n target,\n dropOperation,\n items\n } = e;\n\n let filteredItems = items;\n if (acceptedDragTypes !== 'all' || shouldAcceptItemDrop) {\n filteredItems = items.filter(item => {\n let itemTypes: Set<string | symbol>;\n if (item.kind === 'directory') {\n itemTypes = new Set([DIRECTORY_DRAG_TYPE]);\n } else {\n itemTypes = item.kind === 'file' ? new Set([item.type]) : item.types;\n }\n\n if (acceptedDragTypes === 'all' || acceptedDragTypes.some(type => itemTypes.has(type))) {\n // If we are performing a on item drop, check if the item in question accepts the dropped item since the item may have heavier restrictions\n // than the droppable collection itself\n if (target.type === 'item' && target.dropPosition === 'on' && shouldAcceptItemDrop) {\n return shouldAcceptItemDrop(target, itemTypes);\n }\n return true;\n }\n\n return false;\n });\n }\n\n if (filteredItems.length > 0) {\n if (target.type === 'root' && onRootDrop) {\n await onRootDrop({items: filteredItems, dropOperation});\n }\n\n if (target.type === 'item') {\n if (target.dropPosition === 'on' && onItemDrop) {\n await onItemDrop({items: filteredItems, dropOperation, isInternal, target});\n }\n\n if (target.dropPosition !== 'on') {\n if (!isInternal && onInsert) {\n await onInsert({items: filteredItems, dropOperation, target});\n }\n\n if (isInternal && onReorder) {\n await onReorder({keys: draggingKeys, dropOperation, target});\n }\n }\n }\n }\n }, [localState, ref]);\n\n let autoScroll = useAutoScroll(ref);\n let {dropProps} = useDrop({\n ref,\n onDropEnter() {\n if (localState.nextTarget != null) {\n state.setTarget(localState.nextTarget);\n }\n },\n onDropMove(e) {\n if (localState.nextTarget != null) {\n state.setTarget(localState.nextTarget);\n }\n autoScroll.move(e.x, e.y);\n },\n getDropOperationForPoint(types, allowedOperations, x, y) {\n let {draggingKeys, dropCollectionRef} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n let isValidDropTarget = (target) => state.getDropOperation({target, types, allowedOperations, isInternal, draggingKeys}) !== 'cancel';\n let target = props.dropTargetDelegate.getDropTargetFromPoint(x, y, isValidDropTarget);\n if (!target) {\n localState.dropOperation = 'cancel';\n localState.nextTarget = null;\n return 'cancel';\n }\n\n localState.dropOperation = state.getDropOperation({target, types, allowedOperations, isInternal, draggingKeys});\n\n // If the target doesn't accept the drop, see if the root accepts it instead.\n if (localState.dropOperation === 'cancel') {\n let rootTarget: DropTarget = {type: 'root'};\n let dropOperation = state.getDropOperation({target: rootTarget, types, allowedOperations, isInternal, draggingKeys});\n if (dropOperation !== 'cancel') {\n target = rootTarget;\n localState.dropOperation = dropOperation;\n }\n }\n\n // Only set dropCollectionRef if there is a valid drop target since we cleanup dropCollectionRef in onDropExit\n // which only runs when leaving a valid drop target or if the dropEffect become none (mouse dnd only).\n if (target && localState.dropOperation !== 'cancel' && ref?.current !== dropCollectionRef?.current) {\n setDropCollectionRef(ref);\n }\n localState.nextTarget = localState.dropOperation === 'cancel' ? null : target;\n return localState.dropOperation;\n },\n onDropExit() {\n setDropCollectionRef(undefined);\n state.setTarget(null);\n autoScroll.stop();\n },\n onDropActivate(e) {\n if (state.target?.type === 'item' && state.target?.dropPosition === 'on' && typeof props.onDropActivate === 'function') {\n props.onDropActivate({\n type: 'dropactivate',\n x: e.x, // todo\n y: e.y,\n target: state.target\n });\n }\n },\n onDrop(e) {\n setDropCollectionRef(ref);\n if (state.target) {\n onDrop(e, state.target);\n }\n\n // If there wasn't a collection being tracked as a dragged collection, then we are in a case where a non RSP drag is dropped on a\n // RSP collection and thus we don't need to preserve the global DnD state for onDragEnd\n let {draggingCollectionRef} = globalDndState;\n if (draggingCollectionRef == null) {\n clearGlobalDnDState();\n }\n }\n });\n\n let droppingState = useRef<DroppingState>(null);\n let updateFocusAfterDrop = useCallback(() => {\n let {state} = localState;\n if (droppingState.current) {\n let {\n target,\n collection: prevCollection,\n selectedKeys: prevSelectedKeys,\n focusedKey: prevFocusedKey,\n isInternal,\n draggingKeys\n } = droppingState.current;\n\n // If an insert occurs during a drop, we want to immediately select these items to give\n // feedback to the user that a drop occurred. Only do this if the selection didn't change\n // since the drop started so we don't override if the user or application did something.\n if (\n state.collection.size > prevCollection.size &&\n state.selectionManager.isSelectionEqual(prevSelectedKeys)\n ) {\n let newKeys = new Set<Key>();\n for (let key of state.collection.getKeys()) {\n if (!prevCollection.getItem(key)) {\n newKeys.add(key);\n }\n }\n\n state.selectionManager.setSelectedKeys(newKeys);\n\n // If the focused item didn't change since the drop occurred, also focus the first\n // inserted item. If selection is disabled, then also show the focus ring so there\n // is some indication that items were added.\n if (state.selectionManager.focusedKey === prevFocusedKey) {\n let first = newKeys.keys().next().value;\n let item = state.collection.getItem(first);\n\n // If this is a cell, focus the parent row.\n if (item?.type === 'cell') {\n first = item.parentKey;\n }\n\n state.selectionManager.setFocusedKey(first);\n\n if (state.selectionManager.selectionMode === 'none') {\n setInteractionModality('keyboard');\n }\n }\n } else if (\n prevFocusedKey != null &&\n state.selectionManager.focusedKey === prevFocusedKey &&\n isInternal &&\n target.type === 'item' &&\n target.dropPosition !== 'on' &&\n draggingKeys.has(state.collection.getItem(prevFocusedKey)?.parentKey)\n ) {\n // Focus row instead of cell when reordering.\n state.selectionManager.setFocusedKey(state.collection.getItem(prevFocusedKey)?.parentKey ?? null);\n setInteractionModality('keyboard');\n } else if (\n state.selectionManager.focusedKey === prevFocusedKey &&\n target.type === 'item' &&\n target.dropPosition === 'on' &&\n state.collection.getItem(target.key) != null\n ) {\n // If focus didn't move already (e.g. due to an insert), and the user dropped on an item,\n // focus that item and show the focus ring to give the user feedback that the drop occurred.\n // Also show the focus ring if the focused key is not selected, e.g. in case of a reorder.\n state.selectionManager.setFocusedKey(target.key);\n setInteractionModality('keyboard');\n } else if (state.selectionManager.focusedKey != null && !state.selectionManager.isSelected(state.selectionManager.focusedKey)) {\n setInteractionModality('keyboard');\n }\n\n state.selectionManager.setFocused(true);\n }\n }, [localState]);\n\n let onDrop = useCallback((e: DropEvent, target: DropTarget) => {\n let {state} = localState;\n\n // Save some state of the collection/selection before the drop occurs so we can compare later.\n droppingState.current = {\n timeout: undefined,\n focusedKey: state.selectionManager.focusedKey,\n collection: state.collection,\n selectedKeys: state.selectionManager.selectedKeys,\n draggingKeys: globalDndState.draggingKeys,\n isInternal: isInternalDropOperation(ref),\n target\n };\n\n let onDropFn = localState.props.onDrop || defaultOnDrop;\n onDropFn({\n type: 'drop',\n x: e.x, // todo\n y: e.y,\n target,\n items: e.items,\n dropOperation: e.dropOperation\n });\n\n // Wait for a short time period after the onDrop is called to allow the data to be read asynchronously\n // and for React to re-render. If the collection didn't already change during this time (handled below),\n // update the focused key here.\n droppingState.current.timeout = setTimeout(() => {\n updateFocusAfterDrop();\n droppingState.current = null;\n }, 50);\n }, [localState, defaultOnDrop, ref, updateFocusAfterDrop]);\n\n \n useEffect(() => {\n return () => {\n if (droppingState.current) {\n clearTimeout(droppingState.current.timeout);\n }\n };\n }, []);\n\n useLayoutEffect(() => {\n // If the collection changed after a drop, update the focused key.\n if (droppingState.current && state.collection !== droppingState.current.collection) {\n updateFocusAfterDrop();\n }\n });\n\n let {direction} = useLocale();\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n let getNextTarget = (target: DropTarget | null | undefined, wrap = true, horizontal = false): DropTarget | null => {\n if (!target) {\n return {\n type: 'root'\n };\n }\n\n let {keyboardDelegate} = localState.props;\n let nextKey: Key | null | undefined;\n if (target?.type === 'item') {\n nextKey = horizontal ? keyboardDelegate.getKeyRightOf?.(target.key) : keyboardDelegate.getKeyBelow?.(target.key);\n } else {\n nextKey = horizontal && direction === 'rtl' ? keyboardDelegate.getLastKey?.() : keyboardDelegate.getFirstKey?.();\n }\n let dropPositions = horizontal && direction === 'rtl' ? DROP_POSITIONS_RTL : DROP_POSITIONS;\n let dropPosition: DropPosition = dropPositions[0];\n\n if (target.type === 'item') {\n // If the the keyboard delegate returned the next key in the collection,\n // first try the other positions in the current key. Otherwise (e.g. in a grid layout),\n // jump to the same drop position in the new key.\n let nextCollectionKey = horizontal && direction === 'rtl' ? localState.state.collection.getKeyBefore(target.key) : localState.state.collection.getKeyAfter(target.key);\n if (nextKey == null || nextKey === nextCollectionKey) {\n let positionIndex = dropPositions.indexOf(target.dropPosition);\n let nextDropPosition = dropPositions[positionIndex + 1];\n if (positionIndex < dropPositions.length - 1 && !(nextDropPosition === dropPositions[2] && nextKey != null)) {\n return {\n type: 'item',\n key: target.key,\n dropPosition: nextDropPosition\n };\n }\n\n // If the last drop position was 'after', then 'before' on the next key is equivalent.\n // Switch to 'on' instead.\n if (target.dropPosition === dropPositions[2]) {\n dropPosition = 'on';\n }\n } else {\n dropPosition = target.dropPosition;\n }\n }\n\n if (nextKey == null) {\n if (wrap) {\n return {\n type: 'root'\n };\n }\n\n return null;\n }\n\n return {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n };\n\n let getPreviousTarget = (target: DropTarget | null | undefined, wrap = true, horizontal = false): DropTarget | null => {\n let {keyboardDelegate} = localState.props;\n let nextKey: Key | null | undefined;\n if (target?.type === 'item') {\n nextKey = horizontal ? keyboardDelegate.getKeyLeftOf?.(target.key) : keyboardDelegate.getKeyAbove?.(target.key);\n } else {\n nextKey = horizontal && direction === 'rtl' ? keyboardDelegate.getFirstKey?.() : keyboardDelegate.getLastKey?.();\n }\n let dropPositions = horizontal && direction === 'rtl' ? DROP_POSITIONS_RTL : DROP_POSITIONS;\n let dropPosition: DropPosition = !target || target.type === 'root' ? dropPositions[2] : 'on';\n\n if (target?.type === 'item') {\n // If the the keyboard delegate returned the previous key in the collection,\n // first try the other positions in the current key. Otherwise (e.g. in a grid layout),\n // jump to the same drop position in the new key.\n let prevCollectionKey = horizontal && direction === 'rtl' ? localState.state.collection.getKeyAfter(target.key) : localState.state.collection.getKeyBefore(target.key);\n if (nextKey == null || nextKey === prevCollectionKey) {\n let positionIndex = dropPositions.indexOf(target.dropPosition);\n let nextDropPosition = dropPositions[positionIndex - 1];\n if (positionIndex > 0 && nextDropPosition !== dropPositions[2]) {\n return {\n type: 'item',\n key: target.key,\n dropPosition: nextDropPosition\n };\n }\n\n // If the last drop position was 'before', then 'after' on the previous key is equivalent.\n // Switch to 'on' instead.\n if (target.dropPosition === dropPositions[0]) {\n dropPosition = 'on';\n }\n } else {\n dropPosition = target.dropPosition;\n }\n }\n\n if (nextKey == null) {\n if (wrap) {\n return {\n type: 'root'\n };\n }\n\n return null;\n }\n\n return {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n };\n\n let nextValidTarget = (\n target: DropTarget | null | undefined,\n types: Set<string>,\n allowedDropOperations: DropOperation[],\n getNextTarget: (target: DropTarget | null | undefined, wrap: boolean) => DropTarget | null,\n wrap = true\n ): DropTarget | null => {\n let seenRoot = 0;\n let operation: DropOperation;\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n do {\n let nextTarget = getNextTarget(target, wrap);\n if (!nextTarget) {\n return null;\n }\n target = nextTarget;\n operation = localState.state.getDropOperation({target: nextTarget, types, allowedOperations: allowedDropOperations, isInternal, draggingKeys});\n if (target.type === 'root') {\n seenRoot++;\n }\n } while (\n operation === 'cancel' &&\n !localState.state.isDropTarget(target) &&\n seenRoot < 2\n );\n\n if (operation === 'cancel') {\n return null;\n }\n\n return target;\n };\n\n return DragManager.registerDropTarget({\n element: ref.current,\n preventFocusOnDrop: true,\n getDropOperation(types, allowedOperations) {\n if (localState.state.target) {\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n return localState.state.getDropOperation({target: localState.state.target, types, allowedOperations, isInternal, draggingKeys});\n }\n\n // Check if any of the targets accept the drop.\n // TODO: should we have a faster way of doing this or e.g. for pagination?\n let target = nextValidTarget(null, types, allowedOperations, getNextTarget);\n return target ? 'move' : 'cancel';\n },\n onDropEnter(e, drag) {\n let types = getTypes(drag.items);\n let selectionManager = localState.state.selectionManager;\n let target: DropTarget | null = null;\n // Update the drop collection ref tracker for useDroppableItem's getDropOperation isInternal check\n setDropCollectionRef(ref);\n\n // When entering the droppable collection for the first time, the default drop target\n // is after the focused key.\n let key: Key | null | undefined = selectionManager.focusedKey;\n let dropPosition: DropPosition = 'after';\n\n // If the focused key is a cell, get the parent item instead.\n // For now, we assume that individual cells cannot be dropped on.\n let item = key != null ? localState.state.collection.getItem(key) : null;\n if (item?.type === 'cell') {\n key = item.parentKey;\n }\n\n // If the focused item is also selected, the default drop target is after the last selected item.\n // But if the focused key is the first selected item, then default to before the first selected item.\n // This is to make reordering lists slightly easier. If you select top down, we assume you want to\n // move the items down. If you select bottom up, we assume you want to move the items up.\n if (key != null && selectionManager.isSelected(key)) {\n if (selectionManager.selectedKeys.size > 1 && selectionManager.firstSelectedKey === key) {\n dropPosition = 'before';\n } else {\n key = selectionManager.lastSelectedKey;\n }\n }\n\n if (key != null) {\n target = {\n type: 'item',\n key,\n dropPosition\n };\n\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n // If the default target is not valid, find the next one that is.\n if (localState.state.getDropOperation({target, types, allowedOperations: drag.allowedDropOperations, isInternal, draggingKeys}) === 'cancel') {\n target = nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false)\n ?? nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false);\n }\n }\n\n // If no focused key, then start from the root.\n if (!target) {\n target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);\n }\n\n localState.state.setTarget(target);\n },\n onDropExit() {\n setDropCollectionRef(undefined);\n localState.state.setTarget(null);\n },\n onDropTargetEnter(target) {\n localState.state.setTarget(target);\n },\n onDropActivate(e) {\n if (\n localState.state.target?.type === 'item' &&\n localState.state.target?.dropPosition === 'on' &&\n typeof localState.props.onDropActivate === 'function'\n ) {\n localState.props.onDropActivate({\n type: 'dropactivate',\n x: e.x, // todo\n y: e.y,\n target: localState.state.target\n });\n }\n },\n onDrop(e, target) {\n setDropCollectionRef(ref);\n if (localState.state.target) {\n onDrop(e, target || localState.state.target);\n }\n },\n onKeyDown(e, drag) {\n let {keyboardDelegate} = localState.props;\n let types = getTypes(drag.items);\n switch (e.key) {\n case 'ArrowDown': {\n if (keyboardDelegate.getKeyBelow) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, getNextTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'ArrowUp': {\n if (keyboardDelegate.getKeyAbove) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, getPreviousTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'ArrowLeft': {\n if (keyboardDelegate.getKeyLeftOf) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap) => getPreviousTarget(target, wrap, true));\n localState.state.setTarget(target);\n }\n break;\n }\n case 'ArrowRight': {\n if (keyboardDelegate.getKeyRightOf) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap) => getNextTarget(target, wrap, true));\n localState.state.setTarget(target);\n }\n break;\n }\n case 'Home': {\n if (keyboardDelegate.getFirstKey) {\n let target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'End': {\n if (keyboardDelegate.getLastKey) {\n let target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'PageDown': {\n if (keyboardDelegate.getKeyPageBelow) {\n let target = localState.state.target;\n if (!target) {\n target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);\n } else {\n // If on the root, go to the item a page below the top. Otherwise a page below the current item.\n let targetKey = keyboardDelegate.getFirstKey?.();\n if (target.type === 'item') {\n targetKey = target.key;\n }\n let nextKey: Key | null = null;\n if (targetKey != null) {\n nextKey = keyboardDelegate.getKeyPageBelow(targetKey);\n }\n let dropPosition = target.type === 'item' ? target.dropPosition : 'after';\n\n // If there is no next key, or we are starting on the last key, jump to the last possible position.\n if (nextKey == null || (target.type === 'item' && target.key === keyboardDelegate.getLastKey?.())) {\n nextKey = keyboardDelegate.getLastKey?.() ?? null;\n dropPosition = 'after';\n }\n\n if (nextKey == null) {\n break;\n }\n target = {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n\n // If the target does not accept the drop, find the next valid target.\n // If no next valid target, find the previous valid target.\n let {draggingCollectionRef, draggingKeys} = globalDndState;\n let isInternal = draggingCollectionRef?.current === ref?.current;\n let operation = localState.state.getDropOperation({target, types, allowedOperations: drag.allowedDropOperations, isInternal, draggingKeys});\n if (operation === 'cancel') {\n target = nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false)\n ?? nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false);\n }\n }\n\n localState.state.setTarget(target ?? localState.state.target);\n }\n break;\n }\n case 'PageUp': {\n if (!keyboardDelegate.getKeyPageAbove) {\n break;\n }\n\n let target = localState.state.target;\n if (!target) {\n target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);\n } else if (target.type === 'item') {\n // If at the top already, switch to the root. Otherwise navigate a page up.\n if (target.key === keyboardDelegate.getFirstKey?.()) {\n target = {\n type: 'root'\n };\n } else {\n let nextKey: Key | null | undefined = keyboardDelegate.getKeyPageAbove(target.key);\n let dropPosition = target.dropPosition;\n if (nextKey == null) {\n nextKey = keyboardDelegate.getFirstKey?.();\n dropPosition = 'before';\n }\n\n if (nextKey == null) {\n break;\n }\n target = {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n }\n\n // If the target does not accept the drop, find the previous valid target.\n // If no next valid target, find the next valid target.\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n let operation = localState.state.getDropOperation({target, types, allowedOperations: drag.allowedDropOperations, isInternal, draggingKeys});\n if (operation === 'cancel') {\n target = nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false)\n ?? nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false);\n }\n }\n\n localState.state.setTarget(target ?? localState.state.target);\n break;\n }\n }\n }\n });\n }, [localState, ref, onDrop, direction]);\n\n let id = useId();\n droppableCollectionMap.set(state, {id, ref});\n return {\n collectionProps: mergeProps(dropProps, {\n id,\n // Remove description from collection element. If dropping on the entire collection,\n // there should be a drop indicator that has this description, so no need to double announce.\n 'aria-describedby': null\n })\n };\n}\n"],"names":[],"version":3,"file":"useDroppableCollection.main.js.map"}
@@ -100,10 +100,10 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
100
100
  let { dropProps: dropProps } = (0, $5c06e4929e123553$export$ccdee5eaf73cf661)({
101
101
  ref: ref,
102
102
  onDropEnter () {
103
- state.setTarget(localState.nextTarget);
103
+ if (localState.nextTarget != null) state.setTarget(localState.nextTarget);
104
104
  },
105
105
  onDropMove (e) {
106
- state.setTarget(localState.nextTarget);
106
+ if (localState.nextTarget != null) state.setTarget(localState.nextTarget);
107
107
  autoScroll.move(e.x, e.y);
108
108
  },
109
109
  getDropOperationForPoint (types, allowedOperations, x, y) {
@@ -199,9 +199,11 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
199
199
  state.selectionManager.setFocusedKey(first);
200
200
  if (state.selectionManager.selectionMode === 'none') (0, $4ZR0C$setInteractionModality)('keyboard');
201
201
  }
202
- } else if (state.selectionManager.focusedKey === prevFocusedKey && isInternal && target.type === 'item' && target.dropPosition !== 'on' && draggingKeys.has((_state_collection_getItem = state.collection.getItem(prevFocusedKey)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.parentKey)) {
202
+ } else if (prevFocusedKey != null && state.selectionManager.focusedKey === prevFocusedKey && isInternal && target.type === 'item' && target.dropPosition !== 'on' && draggingKeys.has((_state_collection_getItem = state.collection.getItem(prevFocusedKey)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.parentKey)) {
203
+ var _state_collection_getItem1;
204
+ var _state_collection_getItem_parentKey;
203
205
  // Focus row instead of cell when reordering.
204
- state.selectionManager.setFocusedKey(state.collection.getItem(prevFocusedKey).parentKey);
206
+ state.selectionManager.setFocusedKey((_state_collection_getItem_parentKey = (_state_collection_getItem1 = state.collection.getItem(prevFocusedKey)) === null || _state_collection_getItem1 === void 0 ? void 0 : _state_collection_getItem1.parentKey) !== null && _state_collection_getItem_parentKey !== void 0 ? _state_collection_getItem_parentKey : null);
205
207
  (0, $4ZR0C$setInteractionModality)('keyboard');
206
208
  } else if (state.selectionManager.focusedKey === prevFocusedKey && target.type === 'item' && target.dropPosition === 'on' && state.collection.getItem(target.key) != null) {
207
209
  // If focus didn't move already (e.g. due to an insert), and the user dropped on an item,
@@ -209,7 +211,7 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
209
211
  // Also show the focus ring if the focused key is not selected, e.g. in case of a reorder.
210
212
  state.selectionManager.setFocusedKey(target.key);
211
213
  (0, $4ZR0C$setInteractionModality)('keyboard');
212
- } else if (!state.selectionManager.isSelected(state.selectionManager.focusedKey)) (0, $4ZR0C$setInteractionModality)('keyboard');
214
+ } else if (state.selectionManager.focusedKey != null && !state.selectionManager.isSelected(state.selectionManager.focusedKey)) (0, $4ZR0C$setInteractionModality)('keyboard');
213
215
  state.selectionManager.setFocused(true);
214
216
  }
215
217
  }, [
@@ -219,7 +221,7 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
219
221
  let { state: state } = localState;
220
222
  // Save some state of the collection/selection before the drop occurs so we can compare later.
221
223
  droppingState.current = {
222
- timeout: null,
224
+ timeout: undefined,
223
225
  focusedKey: state.selectionManager.focusedKey,
224
226
  collection: state.collection,
225
227
  selectedKeys: state.selectionManager.selectedKeys,
@@ -249,7 +251,6 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
249
251
  ref,
250
252
  updateFocusAfterDrop
251
253
  ]);
252
- // eslint-disable-next-line arrow-body-style
253
254
  (0, $4ZR0C$useEffect)(()=>{
254
255
  return ()=>{
255
256
  if (droppingState.current) clearTimeout(droppingState.current.timeout);
@@ -261,14 +262,16 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
261
262
  });
262
263
  let { direction: direction } = (0, $4ZR0C$useLocale)();
263
264
  (0, $4ZR0C$useEffect)(()=>{
265
+ if (!ref.current) return;
264
266
  let getNextTarget = (target, wrap = true, horizontal = false)=>{
267
+ var _keyboardDelegate_getKeyRightOf, _keyboardDelegate_getKeyBelow, _keyboardDelegate_getLastKey, _keyboardDelegate_getFirstKey;
265
268
  if (!target) return {
266
269
  type: 'root'
267
270
  };
268
271
  let { keyboardDelegate: keyboardDelegate } = localState.props;
269
272
  let nextKey;
270
- if ((target === null || target === void 0 ? void 0 : target.type) === 'item') nextKey = horizontal ? keyboardDelegate.getKeyRightOf(target.key) : keyboardDelegate.getKeyBelow(target.key);
271
- else nextKey = horizontal && direction === 'rtl' ? keyboardDelegate.getLastKey() : keyboardDelegate.getFirstKey();
273
+ if ((target === null || target === void 0 ? void 0 : target.type) === 'item') nextKey = horizontal ? (_keyboardDelegate_getKeyRightOf = keyboardDelegate.getKeyRightOf) === null || _keyboardDelegate_getKeyRightOf === void 0 ? void 0 : _keyboardDelegate_getKeyRightOf.call(keyboardDelegate, target.key) : (_keyboardDelegate_getKeyBelow = keyboardDelegate.getKeyBelow) === null || _keyboardDelegate_getKeyBelow === void 0 ? void 0 : _keyboardDelegate_getKeyBelow.call(keyboardDelegate, target.key);
274
+ else nextKey = horizontal && direction === 'rtl' ? (_keyboardDelegate_getLastKey = keyboardDelegate.getLastKey) === null || _keyboardDelegate_getLastKey === void 0 ? void 0 : _keyboardDelegate_getLastKey.call(keyboardDelegate) : (_keyboardDelegate_getFirstKey = keyboardDelegate.getFirstKey) === null || _keyboardDelegate_getFirstKey === void 0 ? void 0 : _keyboardDelegate_getFirstKey.call(keyboardDelegate);
272
275
  let dropPositions = horizontal && direction === 'rtl' ? $4b52e4eff84e5217$var$DROP_POSITIONS_RTL : $4b52e4eff84e5217$var$DROP_POSITIONS;
273
276
  let dropPosition = dropPositions[0];
274
277
  if (target.type === 'item') {
@@ -302,10 +305,11 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
302
305
  };
303
306
  };
304
307
  let getPreviousTarget = (target, wrap = true, horizontal = false)=>{
308
+ var _keyboardDelegate_getKeyLeftOf, _keyboardDelegate_getKeyAbove, _keyboardDelegate_getFirstKey, _keyboardDelegate_getLastKey;
305
309
  let { keyboardDelegate: keyboardDelegate } = localState.props;
306
310
  let nextKey;
307
- if ((target === null || target === void 0 ? void 0 : target.type) === 'item') nextKey = horizontal ? keyboardDelegate.getKeyLeftOf(target.key) : keyboardDelegate.getKeyAbove(target.key);
308
- else nextKey = horizontal && direction === 'rtl' ? keyboardDelegate.getFirstKey() : keyboardDelegate.getLastKey();
311
+ if ((target === null || target === void 0 ? void 0 : target.type) === 'item') nextKey = horizontal ? (_keyboardDelegate_getKeyLeftOf = keyboardDelegate.getKeyLeftOf) === null || _keyboardDelegate_getKeyLeftOf === void 0 ? void 0 : _keyboardDelegate_getKeyLeftOf.call(keyboardDelegate, target.key) : (_keyboardDelegate_getKeyAbove = keyboardDelegate.getKeyAbove) === null || _keyboardDelegate_getKeyAbove === void 0 ? void 0 : _keyboardDelegate_getKeyAbove.call(keyboardDelegate, target.key);
312
+ else nextKey = horizontal && direction === 'rtl' ? (_keyboardDelegate_getFirstKey = keyboardDelegate.getFirstKey) === null || _keyboardDelegate_getFirstKey === void 0 ? void 0 : _keyboardDelegate_getFirstKey.call(keyboardDelegate) : (_keyboardDelegate_getLastKey = keyboardDelegate.getLastKey) === null || _keyboardDelegate_getLastKey === void 0 ? void 0 : _keyboardDelegate_getLastKey.call(keyboardDelegate);
309
313
  let dropPositions = horizontal && direction === 'rtl' ? $4b52e4eff84e5217$var$DROP_POSITIONS_RTL : $4b52e4eff84e5217$var$DROP_POSITIONS;
310
314
  let dropPosition = !target || target.type === 'root' ? dropPositions[2] : 'on';
311
315
  if ((target === null || target === void 0 ? void 0 : target.type) === 'item') {
@@ -382,7 +386,7 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
382
386
  onDropEnter (e, drag) {
383
387
  let types = (0, $7252cd45fc48c07c$export$e1d41611756c6326)(drag.items);
384
388
  let selectionManager = localState.state.selectionManager;
385
- let target;
389
+ let target = null;
386
390
  // Update the drop collection ref tracker for useDroppableItem's getDropOperation isInternal check
387
391
  (0, $7252cd45fc48c07c$export$dac8db29d42db9a1)(ref);
388
392
  // When entering the droppable collection for the first time, the default drop target
@@ -391,13 +395,13 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
391
395
  let dropPosition = 'after';
392
396
  // If the focused key is a cell, get the parent item instead.
393
397
  // For now, we assume that individual cells cannot be dropped on.
394
- let item = localState.state.collection.getItem(key);
398
+ let item = key != null ? localState.state.collection.getItem(key) : null;
395
399
  if ((item === null || item === void 0 ? void 0 : item.type) === 'cell') key = item.parentKey;
396
400
  // If the focused item is also selected, the default drop target is after the last selected item.
397
401
  // But if the focused key is the first selected item, then default to before the first selected item.
398
402
  // This is to make reordering lists slightly easier. If you select top down, we assume you want to
399
403
  // move the items down. If you select bottom up, we assume you want to move the items up.
400
- if (selectionManager.isSelected(key)) {
404
+ if (key != null && selectionManager.isSelected(key)) {
401
405
  if (selectionManager.selectedKeys.size > 1 && selectionManager.firstSelectedKey === key) dropPosition = 'before';
402
406
  else key = selectionManager.lastSelectedKey;
403
407
  }
@@ -488,14 +492,21 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
488
492
  let target = localState.state.target;
489
493
  if (!target) target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);
490
494
  else {
495
+ var _keyboardDelegate_getFirstKey, _keyboardDelegate_getLastKey;
491
496
  // If on the root, go to the item a page below the top. Otherwise a page below the current item.
492
- let nextKey = keyboardDelegate.getKeyPageBelow(target.type === 'item' ? target.key : keyboardDelegate.getFirstKey());
497
+ let targetKey = (_keyboardDelegate_getFirstKey = keyboardDelegate.getFirstKey) === null || _keyboardDelegate_getFirstKey === void 0 ? void 0 : _keyboardDelegate_getFirstKey.call(keyboardDelegate);
498
+ if (target.type === 'item') targetKey = target.key;
499
+ let nextKey = null;
500
+ if (targetKey != null) nextKey = keyboardDelegate.getKeyPageBelow(targetKey);
493
501
  let dropPosition = target.type === 'item' ? target.dropPosition : 'after';
494
502
  // If there is no next key, or we are starting on the last key, jump to the last possible position.
495
- if (nextKey == null || target.type === 'item' && target.key === keyboardDelegate.getLastKey()) {
496
- nextKey = keyboardDelegate.getLastKey();
503
+ if (nextKey == null || target.type === 'item' && target.key === ((_keyboardDelegate_getLastKey = keyboardDelegate.getLastKey) === null || _keyboardDelegate_getLastKey === void 0 ? void 0 : _keyboardDelegate_getLastKey.call(keyboardDelegate))) {
504
+ var _keyboardDelegate_getLastKey1;
505
+ var _keyboardDelegate_getLastKey2;
506
+ nextKey = (_keyboardDelegate_getLastKey2 = (_keyboardDelegate_getLastKey1 = keyboardDelegate.getLastKey) === null || _keyboardDelegate_getLastKey1 === void 0 ? void 0 : _keyboardDelegate_getLastKey1.call(keyboardDelegate)) !== null && _keyboardDelegate_getLastKey2 !== void 0 ? _keyboardDelegate_getLastKey2 : null;
497
507
  dropPosition = 'after';
498
508
  }
509
+ if (nextKey == null) break;
499
510
  target = {
500
511
  type: 'item',
501
512
  key: nextKey,
@@ -524,17 +535,20 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
524
535
  let target = localState.state.target;
525
536
  if (!target) target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);
526
537
  else if (target.type === 'item') {
538
+ var _keyboardDelegate_getFirstKey1;
527
539
  // If at the top already, switch to the root. Otherwise navigate a page up.
528
- if (target.key === keyboardDelegate.getFirstKey()) target = {
540
+ if (target.key === ((_keyboardDelegate_getFirstKey1 = keyboardDelegate.getFirstKey) === null || _keyboardDelegate_getFirstKey1 === void 0 ? void 0 : _keyboardDelegate_getFirstKey1.call(keyboardDelegate))) target = {
529
541
  type: 'root'
530
542
  };
531
543
  else {
532
544
  let nextKey = keyboardDelegate.getKeyPageAbove(target.key);
533
545
  let dropPosition = target.dropPosition;
534
546
  if (nextKey == null) {
535
- nextKey = keyboardDelegate.getFirstKey();
547
+ var _keyboardDelegate_getFirstKey2;
548
+ nextKey = (_keyboardDelegate_getFirstKey2 = keyboardDelegate.getFirstKey) === null || _keyboardDelegate_getFirstKey2 === void 0 ? void 0 : _keyboardDelegate_getFirstKey2.call(keyboardDelegate);
536
549
  dropPosition = 'before';
537
550
  }
551
+ if (nextKey == null) break;
538
552
  target = {
539
553
  type: 'item',
540
554
  key: nextKey,