@react-aria/dnd 3.11.5 → 3.12.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/dist/import.mjs +8 -18
- package/dist/main.js +22 -32
- package/dist/main.js.map +1 -1
- package/dist/module.js +8 -18
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +13 -0
- package/package.json +16 -21
- package/src/index.ts +13 -56
- package/dist/DragManager.main.js +0 -519
- package/dist/DragManager.main.js.map +0 -1
- package/dist/DragManager.mjs +0 -510
- package/dist/DragManager.module.js +0 -510
- package/dist/DragManager.module.js.map +0 -1
- package/dist/DragPreview.main.js +0 -73
- package/dist/DragPreview.main.js.map +0 -1
- package/dist/DragPreview.mjs +0 -64
- package/dist/DragPreview.module.js +0 -64
- package/dist/DragPreview.module.js.map +0 -1
- package/dist/DropTargetKeyboardNavigation.main.js +0 -205
- package/dist/DropTargetKeyboardNavigation.main.js.map +0 -1
- package/dist/DropTargetKeyboardNavigation.mjs +0 -200
- package/dist/DropTargetKeyboardNavigation.module.js +0 -200
- package/dist/DropTargetKeyboardNavigation.module.js.map +0 -1
- package/dist/ListDropTargetDelegate.main.js +0 -129
- package/dist/ListDropTargetDelegate.main.js.map +0 -1
- package/dist/ListDropTargetDelegate.mjs +0 -124
- package/dist/ListDropTargetDelegate.module.js +0 -124
- package/dist/ListDropTargetDelegate.module.js.map +0 -1
- package/dist/ar-AE.main.js +0 -44
- package/dist/ar-AE.main.js.map +0 -1
- package/dist/ar-AE.mjs +0 -46
- package/dist/ar-AE.module.js +0 -46
- package/dist/ar-AE.module.js.map +0 -1
- package/dist/bg-BG.main.js +0 -44
- package/dist/bg-BG.main.js.map +0 -1
- package/dist/bg-BG.mjs +0 -46
- package/dist/bg-BG.module.js +0 -46
- package/dist/bg-BG.module.js.map +0 -1
- package/dist/constants.main.js +0 -64
- package/dist/constants.main.js.map +0 -1
- package/dist/constants.mjs +0 -52
- package/dist/constants.module.js +0 -52
- package/dist/constants.module.js.map +0 -1
- package/dist/cs-CZ.main.js +0 -45
- package/dist/cs-CZ.main.js.map +0 -1
- package/dist/cs-CZ.mjs +0 -47
- package/dist/cs-CZ.module.js +0 -47
- package/dist/cs-CZ.module.js.map +0 -1
- package/dist/da-DK.main.js +0 -44
- package/dist/da-DK.main.js.map +0 -1
- package/dist/da-DK.mjs +0 -46
- package/dist/da-DK.module.js +0 -46
- package/dist/da-DK.module.js.map +0 -1
- package/dist/de-DE.main.js +0 -44
- package/dist/de-DE.main.js.map +0 -1
- package/dist/de-DE.mjs +0 -46
- package/dist/de-DE.module.js +0 -46
- package/dist/de-DE.module.js.map +0 -1
- package/dist/el-GR.main.js +0 -44
- package/dist/el-GR.main.js.map +0 -1
- package/dist/el-GR.mjs +0 -46
- package/dist/el-GR.module.js +0 -46
- package/dist/el-GR.module.js.map +0 -1
- package/dist/en-US.main.js +0 -44
- package/dist/en-US.main.js.map +0 -1
- package/dist/en-US.mjs +0 -46
- package/dist/en-US.module.js +0 -46
- package/dist/en-US.module.js.map +0 -1
- package/dist/es-ES.main.js +0 -44
- package/dist/es-ES.main.js.map +0 -1
- package/dist/es-ES.mjs +0 -46
- package/dist/es-ES.module.js +0 -46
- package/dist/es-ES.module.js.map +0 -1
- package/dist/et-EE.main.js +0 -44
- package/dist/et-EE.main.js.map +0 -1
- package/dist/et-EE.mjs +0 -46
- package/dist/et-EE.module.js +0 -46
- package/dist/et-EE.module.js.map +0 -1
- package/dist/fi-FI.main.js +0 -44
- package/dist/fi-FI.main.js.map +0 -1
- package/dist/fi-FI.mjs +0 -46
- package/dist/fi-FI.module.js +0 -46
- package/dist/fi-FI.module.js.map +0 -1
- package/dist/fr-FR.main.js +0 -44
- package/dist/fr-FR.main.js.map +0 -1
- package/dist/fr-FR.mjs +0 -46
- package/dist/fr-FR.module.js +0 -46
- package/dist/fr-FR.module.js.map +0 -1
- package/dist/he-IL.main.js +0 -44
- package/dist/he-IL.main.js.map +0 -1
- package/dist/he-IL.mjs +0 -46
- package/dist/he-IL.module.js +0 -46
- package/dist/he-IL.module.js.map +0 -1
- package/dist/hr-HR.main.js +0 -44
- package/dist/hr-HR.main.js.map +0 -1
- package/dist/hr-HR.mjs +0 -46
- package/dist/hr-HR.module.js +0 -46
- package/dist/hr-HR.module.js.map +0 -1
- package/dist/hu-HU.main.js +0 -44
- package/dist/hu-HU.main.js.map +0 -1
- package/dist/hu-HU.mjs +0 -46
- package/dist/hu-HU.module.js +0 -46
- package/dist/hu-HU.module.js.map +0 -1
- package/dist/intlStrings.main.js +0 -108
- package/dist/intlStrings.main.js.map +0 -1
- package/dist/intlStrings.mjs +0 -110
- package/dist/intlStrings.module.js +0 -110
- package/dist/intlStrings.module.js.map +0 -1
- package/dist/it-IT.main.js +0 -44
- package/dist/it-IT.main.js.map +0 -1
- package/dist/it-IT.mjs +0 -46
- package/dist/it-IT.module.js +0 -46
- package/dist/it-IT.module.js.map +0 -1
- package/dist/ja-JP.main.js +0 -44
- package/dist/ja-JP.main.js.map +0 -1
- package/dist/ja-JP.mjs +0 -46
- package/dist/ja-JP.module.js +0 -46
- package/dist/ja-JP.module.js.map +0 -1
- package/dist/ko-KR.main.js +0 -44
- package/dist/ko-KR.main.js.map +0 -1
- package/dist/ko-KR.mjs +0 -46
- package/dist/ko-KR.module.js +0 -46
- package/dist/ko-KR.module.js.map +0 -1
- package/dist/lt-LT.main.js +0 -44
- package/dist/lt-LT.main.js.map +0 -1
- package/dist/lt-LT.mjs +0 -46
- package/dist/lt-LT.module.js +0 -46
- package/dist/lt-LT.module.js.map +0 -1
- package/dist/lv-LV.main.js +0 -44
- package/dist/lv-LV.main.js.map +0 -1
- package/dist/lv-LV.mjs +0 -46
- package/dist/lv-LV.module.js +0 -46
- package/dist/lv-LV.module.js.map +0 -1
- package/dist/nb-NO.main.js +0 -44
- package/dist/nb-NO.main.js.map +0 -1
- package/dist/nb-NO.mjs +0 -46
- package/dist/nb-NO.module.js +0 -46
- package/dist/nb-NO.module.js.map +0 -1
- package/dist/nl-NL.main.js +0 -44
- package/dist/nl-NL.main.js.map +0 -1
- package/dist/nl-NL.mjs +0 -46
- package/dist/nl-NL.module.js +0 -46
- package/dist/nl-NL.module.js.map +0 -1
- package/dist/pl-PL.main.js +0 -44
- package/dist/pl-PL.main.js.map +0 -1
- package/dist/pl-PL.mjs +0 -46
- package/dist/pl-PL.module.js +0 -46
- package/dist/pl-PL.module.js.map +0 -1
- package/dist/pt-BR.main.js +0 -44
- package/dist/pt-BR.main.js.map +0 -1
- package/dist/pt-BR.mjs +0 -46
- package/dist/pt-BR.module.js +0 -46
- package/dist/pt-BR.module.js.map +0 -1
- package/dist/pt-PT.main.js +0 -44
- package/dist/pt-PT.main.js.map +0 -1
- package/dist/pt-PT.mjs +0 -46
- package/dist/pt-PT.module.js +0 -46
- package/dist/pt-PT.module.js.map +0 -1
- package/dist/ro-RO.main.js +0 -44
- package/dist/ro-RO.main.js.map +0 -1
- package/dist/ro-RO.mjs +0 -46
- package/dist/ro-RO.module.js +0 -46
- package/dist/ro-RO.module.js.map +0 -1
- package/dist/ru-RU.main.js +0 -44
- package/dist/ru-RU.main.js.map +0 -1
- package/dist/ru-RU.mjs +0 -46
- package/dist/ru-RU.module.js +0 -46
- package/dist/ru-RU.module.js.map +0 -1
- package/dist/sk-SK.main.js +0 -44
- package/dist/sk-SK.main.js.map +0 -1
- package/dist/sk-SK.mjs +0 -46
- package/dist/sk-SK.module.js +0 -46
- package/dist/sk-SK.module.js.map +0 -1
- package/dist/sl-SI.main.js +0 -44
- package/dist/sl-SI.main.js.map +0 -1
- package/dist/sl-SI.mjs +0 -46
- package/dist/sl-SI.module.js +0 -46
- package/dist/sl-SI.module.js.map +0 -1
- package/dist/sr-SP.main.js +0 -44
- package/dist/sr-SP.main.js.map +0 -1
- package/dist/sr-SP.mjs +0 -46
- package/dist/sr-SP.module.js +0 -46
- package/dist/sr-SP.module.js.map +0 -1
- package/dist/sv-SE.main.js +0 -44
- package/dist/sv-SE.main.js.map +0 -1
- package/dist/sv-SE.mjs +0 -46
- package/dist/sv-SE.module.js +0 -46
- package/dist/sv-SE.module.js.map +0 -1
- package/dist/tr-TR.main.js +0 -44
- package/dist/tr-TR.main.js.map +0 -1
- package/dist/tr-TR.mjs +0 -46
- package/dist/tr-TR.module.js +0 -46
- package/dist/tr-TR.module.js.map +0 -1
- package/dist/types.d.ts +0 -244
- package/dist/types.d.ts.map +0 -1
- package/dist/uk-UA.main.js +0 -44
- package/dist/uk-UA.main.js.map +0 -1
- package/dist/uk-UA.mjs +0 -46
- package/dist/uk-UA.module.js +0 -46
- package/dist/uk-UA.module.js.map +0 -1
- package/dist/useAutoScroll.main.js +0 -89
- package/dist/useAutoScroll.main.js.map +0 -1
- package/dist/useAutoScroll.mjs +0 -84
- package/dist/useAutoScroll.module.js +0 -84
- package/dist/useAutoScroll.module.js.map +0 -1
- package/dist/useClipboard.main.js +0 -111
- package/dist/useClipboard.main.js.map +0 -1
- package/dist/useClipboard.mjs +0 -106
- package/dist/useClipboard.module.js +0 -106
- package/dist/useClipboard.module.js.map +0 -1
- package/dist/useDrag.main.js +0 -307
- package/dist/useDrag.main.js.map +0 -1
- package/dist/useDrag.mjs +0 -302
- package/dist/useDrag.module.js +0 -302
- package/dist/useDrag.module.js.map +0 -1
- package/dist/useDraggableCollection.main.js +0 -27
- package/dist/useDraggableCollection.main.js.map +0 -1
- package/dist/useDraggableCollection.mjs +0 -22
- package/dist/useDraggableCollection.module.js +0 -22
- package/dist/useDraggableCollection.module.js.map +0 -1
- package/dist/useDraggableItem.main.js +0 -128
- package/dist/useDraggableItem.main.js.map +0 -1
- package/dist/useDraggableItem.mjs +0 -123
- package/dist/useDraggableItem.module.js +0 -123
- package/dist/useDraggableItem.module.js.map +0 -1
- package/dist/useDrop.main.js +0 -295
- package/dist/useDrop.main.js.map +0 -1
- package/dist/useDrop.mjs +0 -290
- package/dist/useDrop.module.js +0 -290
- package/dist/useDrop.module.js.map +0 -1
- package/dist/useDropIndicator.main.js +0 -102
- package/dist/useDropIndicator.main.js.map +0 -1
- package/dist/useDropIndicator.mjs +0 -97
- package/dist/useDropIndicator.module.js +0 -97
- package/dist/useDropIndicator.module.js.map +0 -1
- package/dist/useDroppableCollection.main.js +0 -536
- package/dist/useDroppableCollection.main.js.map +0 -1
- package/dist/useDroppableCollection.mjs +0 -531
- package/dist/useDroppableCollection.module.js +0 -531
- package/dist/useDroppableCollection.module.js.map +0 -1
- package/dist/useDroppableItem.main.js +0 -81
- package/dist/useDroppableItem.main.js.map +0 -1
- package/dist/useDroppableItem.mjs +0 -76
- package/dist/useDroppableItem.module.js +0 -76
- package/dist/useDroppableItem.module.js.map +0 -1
- package/dist/useVirtualDrop.main.js +0 -56
- package/dist/useVirtualDrop.main.js.map +0 -1
- package/dist/useVirtualDrop.mjs +0 -51
- package/dist/useVirtualDrop.module.js +0 -51
- package/dist/useVirtualDrop.module.js.map +0 -1
- package/dist/utils.main.js +0 -285
- package/dist/utils.main.js.map +0 -1
- package/dist/utils.mjs +0 -257
- package/dist/utils.module.js +0 -257
- package/dist/utils.module.js.map +0 -1
- package/dist/zh-CN.main.js +0 -44
- package/dist/zh-CN.main.js.map +0 -1
- package/dist/zh-CN.mjs +0 -46
- package/dist/zh-CN.module.js +0 -46
- package/dist/zh-CN.module.js.map +0 -1
- package/dist/zh-TW.main.js +0 -44
- package/dist/zh-TW.main.js.map +0 -1
- package/dist/zh-TW.mjs +0 -46
- package/dist/zh-TW.module.js +0 -46
- package/dist/zh-TW.module.js.map +0 -1
- package/src/DragManager.ts +0 -656
- package/src/DragPreview.tsx +0 -81
- package/src/DropTargetKeyboardNavigation.ts +0 -282
- package/src/ListDropTargetDelegate.ts +0 -182
- package/src/constants.ts +0 -85
- package/src/useAutoScroll.ts +0 -105
- package/src/useClipboard.ts +0 -151
- package/src/useDrag.ts +0 -390
- package/src/useDraggableCollection.ts +0 -29
- package/src/useDraggableItem.ts +0 -158
- package/src/useDrop.ts +0 -444
- package/src/useDropIndicator.ts +0 -124
- package/src/useDroppableCollection.ts +0 -665
- package/src/useDroppableItem.ts +0 -86
- package/src/useVirtualDrop.ts +0 -49
- package/src/utils.ts +0 -385
package/dist/DragPreview.main.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
var $l6JIF$reactdom = require("react-dom");
|
|
2
|
-
var $l6JIF$react = require("react");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function $parcel$interopDefault(a) {
|
|
6
|
-
return a && a.__esModule ? a.default : a;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function $parcel$export(e, n, v, s) {
|
|
10
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
$parcel$export(module.exports, "DragPreview", () => $2dccaca1f4baa446$export$905ab40ac2179daa);
|
|
14
|
-
/*
|
|
15
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
16
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
17
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
18
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
-
*
|
|
20
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
21
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
22
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
23
|
-
* governing permissions and limitations under the License.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const $2dccaca1f4baa446$export$905ab40ac2179daa = /*#__PURE__*/ (0, ($parcel$interopDefault($l6JIF$react))).forwardRef(function DragPreview(props, ref) {
|
|
27
|
-
let render = props.children;
|
|
28
|
-
let [children, setChildren] = (0, $l6JIF$react.useState)(null);
|
|
29
|
-
let domRef = (0, $l6JIF$react.useRef)(null);
|
|
30
|
-
let raf = (0, $l6JIF$react.useRef)(undefined);
|
|
31
|
-
(0, $l6JIF$react.useImperativeHandle)(ref, ()=>(items, callback)=>{
|
|
32
|
-
// This will be called during the onDragStart event by useDrag. We need to render the
|
|
33
|
-
// preview synchronously before this event returns so we can call event.dataTransfer.setDragImage.
|
|
34
|
-
let result = render(items);
|
|
35
|
-
let element;
|
|
36
|
-
let offsetX;
|
|
37
|
-
let offsetY;
|
|
38
|
-
if (result && typeof result === 'object' && 'element' in result) {
|
|
39
|
-
element = result.element;
|
|
40
|
-
offsetX = result.x;
|
|
41
|
-
offsetY = result.y;
|
|
42
|
-
} else element = result;
|
|
43
|
-
(0, $l6JIF$reactdom.flushSync)(()=>{
|
|
44
|
-
setChildren(element);
|
|
45
|
-
});
|
|
46
|
-
// Yield back to useDrag to set the drag image.
|
|
47
|
-
callback(domRef.current, offsetX, offsetY);
|
|
48
|
-
// Remove the preview from the DOM after a frame so the browser has time to paint.
|
|
49
|
-
raf.current = requestAnimationFrame(()=>{
|
|
50
|
-
setChildren(null);
|
|
51
|
-
});
|
|
52
|
-
}, [
|
|
53
|
-
render
|
|
54
|
-
]);
|
|
55
|
-
(0, $l6JIF$react.useEffect)(()=>{
|
|
56
|
-
return ()=>{
|
|
57
|
-
if (raf.current) cancelAnimationFrame(raf.current);
|
|
58
|
-
};
|
|
59
|
-
}, []);
|
|
60
|
-
if (!children) return null;
|
|
61
|
-
return /*#__PURE__*/ (0, ($parcel$interopDefault($l6JIF$react))).createElement("div", {
|
|
62
|
-
style: {
|
|
63
|
-
zIndex: -100,
|
|
64
|
-
position: 'fixed',
|
|
65
|
-
top: 0,
|
|
66
|
-
left: -100000
|
|
67
|
-
},
|
|
68
|
-
ref: domRef
|
|
69
|
-
}, children);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
//# sourceMappingURL=DragPreview.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAeM,MAAM,0DAEb,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC,SAAS,YAAY,KAAuB,EAAE,GAA6C;IAC1G,IAAI,SAAS,MAAM,QAAQ;IAC3B,IAAI,CAAC,UAAU,YAAY,GAAG,CAAA,GAAA,qBAAO,EAAsB;IAC3D,IAAI,SAAS,CAAA,GAAA,mBAAK,EAAyB;IAC3C,IAAI,MAAM,CAAA,GAAA,mBAAK,EAAwD;IAEvE,CAAA,GAAA,gCAAkB,EAAE,KAAK,IAAM,CAAC,OAAmB;YACjD,qFAAqF;YACrF,kGAAkG;YAElG,IAAI,SAAS,OAAO;YACpB,IAAI;YACJ,IAAI;YACJ,IAAI;YAEJ,IAAI,UAAU,OAAO,WAAW,YAAY,aAAa,QAAQ;gBAC/D,UAAU,OAAO,OAAO;gBACxB,UAAU,OAAO,CAAC;gBAClB,UAAU,OAAO,CAAC;YACpB,OACE,UAAU;YAGZ,CAAA,GAAA,yBAAQ,EAAE;gBACR,YAAY;YACd;YAEA,+CAA+C;YAC/C,SAAS,OAAO,OAAO,EAAE,SAAS;YAElC,kFAAkF;YAClF,IAAI,OAAO,GAAG,sBAAsB;gBAClC,YAAY;YACd;QACF,GAAG;QAAC;KAAO;IAEX,CAAA,GAAA,sBAAQ,EAAE;QACR,OAAO;YACL,IAAI,IAAI,OAAO,EACb,qBAAqB,IAAI,OAAO;QAEpC;IACF,GAAG,EAAE;IAEL,IAAI,CAAC,UACH,OAAO;IAGT,qBACE,0DAAC;QAAI,OAAO;YAAC,QAAQ;YAAM,UAAU;YAAS,KAAK;YAAG,MAAM;QAAO;QAAG,KAAK;OACxE;AAGP","sources":["packages/@react-aria/dnd/src/DragPreview.tsx"],"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 {DragItem, DragPreviewRenderer} from '@react-types/shared';\nimport {flushSync} from 'react-dom';\nimport React, {ForwardedRef, JSX, useEffect, useImperativeHandle, useRef, useState} from 'react';\n\nexport interface DragPreviewProps {\n /**\n * A render function which returns a preview element, or an object containing the element\n * and a custom offset. If an object is returned, the provided `x` and `y` values will be\n * used as the drag preview offset instead of the default calculation.\n */\n children: (items: DragItem[]) => JSX.Element | {element: JSX.Element, x: number, y: number} | null\n}\n\nexport const DragPreview:\n React.ForwardRefExoticComponent<DragPreviewProps & React.RefAttributes<DragPreviewRenderer | null>> =\nReact.forwardRef(function DragPreview(props: DragPreviewProps, ref: ForwardedRef<DragPreviewRenderer | null>) {\n let render = props.children;\n let [children, setChildren] = useState<JSX.Element | null>(null);\n let domRef = useRef<HTMLDivElement | null>(null);\n let raf = useRef<ReturnType<typeof requestAnimationFrame> | undefined>(undefined);\n\n useImperativeHandle(ref, () => (items: DragItem[], callback: (node: HTMLElement | null, x?: number, y?: number) => void) => {\n // This will be called during the onDragStart event by useDrag. We need to render the\n // preview synchronously before this event returns so we can call event.dataTransfer.setDragImage.\n\n let result = render(items);\n let element: JSX.Element | null;\n let offsetX: number | undefined;\n let offsetY: number | undefined;\n\n if (result && typeof result === 'object' && 'element' in result) {\n element = result.element;\n offsetX = result.x;\n offsetY = result.y;\n } else {\n element = result as JSX.Element | null;\n }\n\n flushSync(() => {\n setChildren(element);\n });\n\n // Yield back to useDrag to set the drag image.\n callback(domRef.current, offsetX, offsetY);\n\n // Remove the preview from the DOM after a frame so the browser has time to paint.\n raf.current = requestAnimationFrame(() => {\n setChildren(null);\n });\n }, [render]);\n\n useEffect(() => {\n return () => {\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n };\n }, []);\n\n if (!children) {\n return null;\n }\n\n return (\n <div style={{zIndex: -100, position: 'fixed', top: 0, left: -100000}} ref={domRef}>\n {children}\n </div>\n );\n});\n"],"names":[],"version":3,"file":"DragPreview.main.js.map"}
|
package/dist/DragPreview.mjs
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {flushSync as $eLjnH$flushSync} from "react-dom";
|
|
2
|
-
import $eLjnH$react, {useState as $eLjnH$useState, useRef as $eLjnH$useRef, useImperativeHandle as $eLjnH$useImperativeHandle, useEffect as $eLjnH$useEffect} from "react";
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
-
* governing permissions and limitations under the License.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
const $ad0e3f3d9c50e4ba$export$905ab40ac2179daa = /*#__PURE__*/ (0, $eLjnH$react).forwardRef(function DragPreview(props, ref) {
|
|
17
|
-
let render = props.children;
|
|
18
|
-
let [children, setChildren] = (0, $eLjnH$useState)(null);
|
|
19
|
-
let domRef = (0, $eLjnH$useRef)(null);
|
|
20
|
-
let raf = (0, $eLjnH$useRef)(undefined);
|
|
21
|
-
(0, $eLjnH$useImperativeHandle)(ref, ()=>(items, callback)=>{
|
|
22
|
-
// This will be called during the onDragStart event by useDrag. We need to render the
|
|
23
|
-
// preview synchronously before this event returns so we can call event.dataTransfer.setDragImage.
|
|
24
|
-
let result = render(items);
|
|
25
|
-
let element;
|
|
26
|
-
let offsetX;
|
|
27
|
-
let offsetY;
|
|
28
|
-
if (result && typeof result === 'object' && 'element' in result) {
|
|
29
|
-
element = result.element;
|
|
30
|
-
offsetX = result.x;
|
|
31
|
-
offsetY = result.y;
|
|
32
|
-
} else element = result;
|
|
33
|
-
(0, $eLjnH$flushSync)(()=>{
|
|
34
|
-
setChildren(element);
|
|
35
|
-
});
|
|
36
|
-
// Yield back to useDrag to set the drag image.
|
|
37
|
-
callback(domRef.current, offsetX, offsetY);
|
|
38
|
-
// Remove the preview from the DOM after a frame so the browser has time to paint.
|
|
39
|
-
raf.current = requestAnimationFrame(()=>{
|
|
40
|
-
setChildren(null);
|
|
41
|
-
});
|
|
42
|
-
}, [
|
|
43
|
-
render
|
|
44
|
-
]);
|
|
45
|
-
(0, $eLjnH$useEffect)(()=>{
|
|
46
|
-
return ()=>{
|
|
47
|
-
if (raf.current) cancelAnimationFrame(raf.current);
|
|
48
|
-
};
|
|
49
|
-
}, []);
|
|
50
|
-
if (!children) return null;
|
|
51
|
-
return /*#__PURE__*/ (0, $eLjnH$react).createElement("div", {
|
|
52
|
-
style: {
|
|
53
|
-
zIndex: -100,
|
|
54
|
-
position: 'fixed',
|
|
55
|
-
top: 0,
|
|
56
|
-
left: -100000
|
|
57
|
-
},
|
|
58
|
-
ref: domRef
|
|
59
|
-
}, children);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
export {$ad0e3f3d9c50e4ba$export$905ab40ac2179daa as DragPreview};
|
|
64
|
-
//# sourceMappingURL=DragPreview.module.js.map
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {flushSync as $eLjnH$flushSync} from "react-dom";
|
|
2
|
-
import $eLjnH$react, {useState as $eLjnH$useState, useRef as $eLjnH$useRef, useImperativeHandle as $eLjnH$useImperativeHandle, useEffect as $eLjnH$useEffect} from "react";
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
-
* governing permissions and limitations under the License.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
const $ad0e3f3d9c50e4ba$export$905ab40ac2179daa = /*#__PURE__*/ (0, $eLjnH$react).forwardRef(function DragPreview(props, ref) {
|
|
17
|
-
let render = props.children;
|
|
18
|
-
let [children, setChildren] = (0, $eLjnH$useState)(null);
|
|
19
|
-
let domRef = (0, $eLjnH$useRef)(null);
|
|
20
|
-
let raf = (0, $eLjnH$useRef)(undefined);
|
|
21
|
-
(0, $eLjnH$useImperativeHandle)(ref, ()=>(items, callback)=>{
|
|
22
|
-
// This will be called during the onDragStart event by useDrag. We need to render the
|
|
23
|
-
// preview synchronously before this event returns so we can call event.dataTransfer.setDragImage.
|
|
24
|
-
let result = render(items);
|
|
25
|
-
let element;
|
|
26
|
-
let offsetX;
|
|
27
|
-
let offsetY;
|
|
28
|
-
if (result && typeof result === 'object' && 'element' in result) {
|
|
29
|
-
element = result.element;
|
|
30
|
-
offsetX = result.x;
|
|
31
|
-
offsetY = result.y;
|
|
32
|
-
} else element = result;
|
|
33
|
-
(0, $eLjnH$flushSync)(()=>{
|
|
34
|
-
setChildren(element);
|
|
35
|
-
});
|
|
36
|
-
// Yield back to useDrag to set the drag image.
|
|
37
|
-
callback(domRef.current, offsetX, offsetY);
|
|
38
|
-
// Remove the preview from the DOM after a frame so the browser has time to paint.
|
|
39
|
-
raf.current = requestAnimationFrame(()=>{
|
|
40
|
-
setChildren(null);
|
|
41
|
-
});
|
|
42
|
-
}, [
|
|
43
|
-
render
|
|
44
|
-
]);
|
|
45
|
-
(0, $eLjnH$useEffect)(()=>{
|
|
46
|
-
return ()=>{
|
|
47
|
-
if (raf.current) cancelAnimationFrame(raf.current);
|
|
48
|
-
};
|
|
49
|
-
}, []);
|
|
50
|
-
if (!children) return null;
|
|
51
|
-
return /*#__PURE__*/ (0, $eLjnH$react).createElement("div", {
|
|
52
|
-
style: {
|
|
53
|
-
zIndex: -100,
|
|
54
|
-
position: 'fixed',
|
|
55
|
-
top: 0,
|
|
56
|
-
left: -100000
|
|
57
|
-
},
|
|
58
|
-
ref: domRef
|
|
59
|
-
}, children);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
export {$ad0e3f3d9c50e4ba$export$905ab40ac2179daa as DragPreview};
|
|
64
|
-
//# sourceMappingURL=DragPreview.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAeM,MAAM,0DAEb,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC,SAAS,YAAY,KAAuB,EAAE,GAA6C;IAC1G,IAAI,SAAS,MAAM,QAAQ;IAC3B,IAAI,CAAC,UAAU,YAAY,GAAG,CAAA,GAAA,eAAO,EAAsB;IAC3D,IAAI,SAAS,CAAA,GAAA,aAAK,EAAyB;IAC3C,IAAI,MAAM,CAAA,GAAA,aAAK,EAAwD;IAEvE,CAAA,GAAA,0BAAkB,EAAE,KAAK,IAAM,CAAC,OAAmB;YACjD,qFAAqF;YACrF,kGAAkG;YAElG,IAAI,SAAS,OAAO;YACpB,IAAI;YACJ,IAAI;YACJ,IAAI;YAEJ,IAAI,UAAU,OAAO,WAAW,YAAY,aAAa,QAAQ;gBAC/D,UAAU,OAAO,OAAO;gBACxB,UAAU,OAAO,CAAC;gBAClB,UAAU,OAAO,CAAC;YACpB,OACE,UAAU;YAGZ,CAAA,GAAA,gBAAQ,EAAE;gBACR,YAAY;YACd;YAEA,+CAA+C;YAC/C,SAAS,OAAO,OAAO,EAAE,SAAS;YAElC,kFAAkF;YAClF,IAAI,OAAO,GAAG,sBAAsB;gBAClC,YAAY;YACd;QACF,GAAG;QAAC;KAAO;IAEX,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO;YACL,IAAI,IAAI,OAAO,EACb,qBAAqB,IAAI,OAAO;QAEpC;IACF,GAAG,EAAE;IAEL,IAAI,CAAC,UACH,OAAO;IAGT,qBACE,gCAAC;QAAI,OAAO;YAAC,QAAQ;YAAM,UAAU;YAAS,KAAK;YAAG,MAAM;QAAO;QAAG,KAAK;OACxE;AAGP","sources":["packages/@react-aria/dnd/src/DragPreview.tsx"],"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 {DragItem, DragPreviewRenderer} from '@react-types/shared';\nimport {flushSync} from 'react-dom';\nimport React, {ForwardedRef, JSX, useEffect, useImperativeHandle, useRef, useState} from 'react';\n\nexport interface DragPreviewProps {\n /**\n * A render function which returns a preview element, or an object containing the element\n * and a custom offset. If an object is returned, the provided `x` and `y` values will be\n * used as the drag preview offset instead of the default calculation.\n */\n children: (items: DragItem[]) => JSX.Element | {element: JSX.Element, x: number, y: number} | null\n}\n\nexport const DragPreview:\n React.ForwardRefExoticComponent<DragPreviewProps & React.RefAttributes<DragPreviewRenderer | null>> =\nReact.forwardRef(function DragPreview(props: DragPreviewProps, ref: ForwardedRef<DragPreviewRenderer | null>) {\n let render = props.children;\n let [children, setChildren] = useState<JSX.Element | null>(null);\n let domRef = useRef<HTMLDivElement | null>(null);\n let raf = useRef<ReturnType<typeof requestAnimationFrame> | undefined>(undefined);\n\n useImperativeHandle(ref, () => (items: DragItem[], callback: (node: HTMLElement | null, x?: number, y?: number) => void) => {\n // This will be called during the onDragStart event by useDrag. We need to render the\n // preview synchronously before this event returns so we can call event.dataTransfer.setDragImage.\n\n let result = render(items);\n let element: JSX.Element | null;\n let offsetX: number | undefined;\n let offsetY: number | undefined;\n\n if (result && typeof result === 'object' && 'element' in result) {\n element = result.element;\n offsetX = result.x;\n offsetY = result.y;\n } else {\n element = result as JSX.Element | null;\n }\n\n flushSync(() => {\n setChildren(element);\n });\n\n // Yield back to useDrag to set the drag image.\n callback(domRef.current, offsetX, offsetY);\n\n // Remove the preview from the DOM after a frame so the browser has time to paint.\n raf.current = requestAnimationFrame(() => {\n setChildren(null);\n });\n }, [render]);\n\n useEffect(() => {\n return () => {\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n };\n }, []);\n\n if (!children) {\n return null;\n }\n\n return (\n <div style={{zIndex: -100, position: 'fixed', top: 0, left: -100000}} ref={domRef}>\n {children}\n </div>\n );\n});\n"],"names":[],"version":3,"file":"DragPreview.module.js.map"}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
var $2pOR2$reactstatelycollections = require("@react-stately/collections");
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function $parcel$export(e, n, v, s) {
|
|
5
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
$parcel$export(module.exports, "navigate", () => $6e16de4c92a0f271$export$ff7962acd6052c28);
|
|
9
|
-
|
|
10
|
-
function $6e16de4c92a0f271$export$ff7962acd6052c28(keyboardDelegate, collection, target, direction, rtl = false, wrap = false) {
|
|
11
|
-
switch(direction){
|
|
12
|
-
case 'left':
|
|
13
|
-
return rtl ? $6e16de4c92a0f271$var$nextDropTarget(keyboardDelegate, collection, target, wrap, 'left') : $6e16de4c92a0f271$var$previousDropTarget(keyboardDelegate, collection, target, wrap, 'left');
|
|
14
|
-
case 'right':
|
|
15
|
-
return rtl ? $6e16de4c92a0f271$var$previousDropTarget(keyboardDelegate, collection, target, wrap, 'right') : $6e16de4c92a0f271$var$nextDropTarget(keyboardDelegate, collection, target, wrap, 'right');
|
|
16
|
-
case 'up':
|
|
17
|
-
return $6e16de4c92a0f271$var$previousDropTarget(keyboardDelegate, collection, target, wrap);
|
|
18
|
-
case 'down':
|
|
19
|
-
return $6e16de4c92a0f271$var$nextDropTarget(keyboardDelegate, collection, target, wrap);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function $6e16de4c92a0f271$var$nextDropTarget(keyboardDelegate, collection, target, wrap = false, horizontal = null) {
|
|
23
|
-
if (!target) return {
|
|
24
|
-
type: 'root'
|
|
25
|
-
};
|
|
26
|
-
if (target.type === 'root') {
|
|
27
|
-
var _keyboardDelegate_getFirstKey;
|
|
28
|
-
var _keyboardDelegate_getFirstKey1;
|
|
29
|
-
let nextKey = (_keyboardDelegate_getFirstKey1 = (_keyboardDelegate_getFirstKey = keyboardDelegate.getFirstKey) === null || _keyboardDelegate_getFirstKey === void 0 ? void 0 : _keyboardDelegate_getFirstKey.call(keyboardDelegate)) !== null && _keyboardDelegate_getFirstKey1 !== void 0 ? _keyboardDelegate_getFirstKey1 : null;
|
|
30
|
-
if (nextKey != null) return {
|
|
31
|
-
type: 'item',
|
|
32
|
-
key: nextKey,
|
|
33
|
-
dropPosition: 'before'
|
|
34
|
-
};
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
if (target.type === 'item') {
|
|
38
|
-
var _keyboardDelegate_getKeyRightOf, _keyboardDelegate_getKeyLeftOf, _keyboardDelegate_getKeyBelow;
|
|
39
|
-
let nextKey = null;
|
|
40
|
-
if (horizontal) nextKey = horizontal === 'right' ? (_keyboardDelegate_getKeyRightOf = keyboardDelegate.getKeyRightOf) === null || _keyboardDelegate_getKeyRightOf === void 0 ? void 0 : _keyboardDelegate_getKeyRightOf.call(keyboardDelegate, target.key) : (_keyboardDelegate_getKeyLeftOf = keyboardDelegate.getKeyLeftOf) === null || _keyboardDelegate_getKeyLeftOf === void 0 ? void 0 : _keyboardDelegate_getKeyLeftOf.call(keyboardDelegate, target.key);
|
|
41
|
-
else nextKey = (_keyboardDelegate_getKeyBelow = keyboardDelegate.getKeyBelow) === null || _keyboardDelegate_getKeyBelow === void 0 ? void 0 : _keyboardDelegate_getKeyBelow.call(keyboardDelegate, target.key);
|
|
42
|
-
let nextCollectionKey = collection.getKeyAfter(target.key);
|
|
43
|
-
// If the keyboard delegate did not move to the next key in the collection,
|
|
44
|
-
// jump to that key with the same drop position. Otherwise, try the other
|
|
45
|
-
// drop positions on the current key first.
|
|
46
|
-
if (nextKey != null && nextKey !== nextCollectionKey) return {
|
|
47
|
-
type: 'item',
|
|
48
|
-
key: nextKey,
|
|
49
|
-
dropPosition: target.dropPosition
|
|
50
|
-
};
|
|
51
|
-
switch(target.dropPosition){
|
|
52
|
-
case 'before':
|
|
53
|
-
return {
|
|
54
|
-
type: 'item',
|
|
55
|
-
key: target.key,
|
|
56
|
-
dropPosition: 'on'
|
|
57
|
-
};
|
|
58
|
-
case 'on':
|
|
59
|
-
{
|
|
60
|
-
// If there are nested items, traverse to them prior to the "after" position of this target.
|
|
61
|
-
// If the next key is on the same level, then its "before" position is equivalent to this item's "after" position.
|
|
62
|
-
let targetNode = collection.getItem(target.key);
|
|
63
|
-
let nextNode = nextKey != null ? collection.getItem(nextKey) : null;
|
|
64
|
-
if (targetNode && nextNode && nextNode.level >= targetNode.level) return {
|
|
65
|
-
type: 'item',
|
|
66
|
-
key: nextNode.key,
|
|
67
|
-
dropPosition: 'before'
|
|
68
|
-
};
|
|
69
|
-
return {
|
|
70
|
-
type: 'item',
|
|
71
|
-
key: target.key,
|
|
72
|
-
dropPosition: 'after'
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
case 'after':
|
|
76
|
-
{
|
|
77
|
-
// If this is the last sibling in a level, traverse to the parent.
|
|
78
|
-
let targetNode = collection.getItem(target.key);
|
|
79
|
-
let nextItemInSameLevel = (targetNode === null || targetNode === void 0 ? void 0 : targetNode.nextKey) != null ? collection.getItem(targetNode.nextKey) : null;
|
|
80
|
-
while(nextItemInSameLevel != null && nextItemInSameLevel.type !== 'item')nextItemInSameLevel = nextItemInSameLevel.nextKey != null ? collection.getItem(nextItemInSameLevel.nextKey) : null;
|
|
81
|
-
if (targetNode && nextItemInSameLevel == null && targetNode.parentKey != null) {
|
|
82
|
-
// If the parent item has an item after it, use the "before" position.
|
|
83
|
-
let parentNode = collection.getItem(targetNode.parentKey);
|
|
84
|
-
const nextNode = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.nextKey) != null ? collection.getItem(parentNode.nextKey) : null;
|
|
85
|
-
if ((nextNode === null || nextNode === void 0 ? void 0 : nextNode.type) === 'item') return {
|
|
86
|
-
type: 'item',
|
|
87
|
-
key: nextNode.key,
|
|
88
|
-
dropPosition: 'before'
|
|
89
|
-
};
|
|
90
|
-
if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.type) === 'item') return {
|
|
91
|
-
type: 'item',
|
|
92
|
-
key: parentNode.key,
|
|
93
|
-
dropPosition: 'after'
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
if (nextItemInSameLevel) return {
|
|
97
|
-
type: 'item',
|
|
98
|
-
key: nextItemInSameLevel.key,
|
|
99
|
-
dropPosition: 'on'
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (wrap) return {
|
|
105
|
-
type: 'root'
|
|
106
|
-
};
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
function $6e16de4c92a0f271$var$previousDropTarget(keyboardDelegate, collection, target, wrap = false, horizontal = null) {
|
|
110
|
-
// Start after the last root-level item.
|
|
111
|
-
if (!target || wrap && target.type === 'root') {
|
|
112
|
-
var _keyboardDelegate_getLastKey;
|
|
113
|
-
// Keyboard delegate gets the deepest item but we want the shallowest.
|
|
114
|
-
let prevKey = null;
|
|
115
|
-
let lastKey = (_keyboardDelegate_getLastKey = keyboardDelegate.getLastKey) === null || _keyboardDelegate_getLastKey === void 0 ? void 0 : _keyboardDelegate_getLastKey.call(keyboardDelegate);
|
|
116
|
-
while(lastKey != null){
|
|
117
|
-
let node = collection.getItem(lastKey);
|
|
118
|
-
if ((node === null || node === void 0 ? void 0 : node.type) !== 'item') break;
|
|
119
|
-
prevKey = lastKey;
|
|
120
|
-
lastKey = node === null || node === void 0 ? void 0 : node.parentKey;
|
|
121
|
-
}
|
|
122
|
-
if (prevKey != null) return {
|
|
123
|
-
type: 'item',
|
|
124
|
-
key: prevKey,
|
|
125
|
-
dropPosition: 'after'
|
|
126
|
-
};
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
if (target.type === 'item') {
|
|
130
|
-
var _keyboardDelegate_getKeyLeftOf, _keyboardDelegate_getKeyRightOf, _keyboardDelegate_getKeyAbove;
|
|
131
|
-
let prevKey = null;
|
|
132
|
-
if (horizontal) prevKey = horizontal === 'left' ? (_keyboardDelegate_getKeyLeftOf = keyboardDelegate.getKeyLeftOf) === null || _keyboardDelegate_getKeyLeftOf === void 0 ? void 0 : _keyboardDelegate_getKeyLeftOf.call(keyboardDelegate, target.key) : (_keyboardDelegate_getKeyRightOf = keyboardDelegate.getKeyRightOf) === null || _keyboardDelegate_getKeyRightOf === void 0 ? void 0 : _keyboardDelegate_getKeyRightOf.call(keyboardDelegate, target.key);
|
|
133
|
-
else prevKey = (_keyboardDelegate_getKeyAbove = keyboardDelegate.getKeyAbove) === null || _keyboardDelegate_getKeyAbove === void 0 ? void 0 : _keyboardDelegate_getKeyAbove.call(keyboardDelegate, target.key);
|
|
134
|
-
let prevCollectionKey = collection.getKeyBefore(target.key);
|
|
135
|
-
// If the keyboard delegate did not move to the next key in the collection,
|
|
136
|
-
// jump to that key with the same drop position. Otherwise, try the other
|
|
137
|
-
// drop positions on the current key first.
|
|
138
|
-
if (prevKey != null && prevKey !== prevCollectionKey) return {
|
|
139
|
-
type: 'item',
|
|
140
|
-
key: prevKey,
|
|
141
|
-
dropPosition: target.dropPosition
|
|
142
|
-
};
|
|
143
|
-
switch(target.dropPosition){
|
|
144
|
-
case 'before':
|
|
145
|
-
{
|
|
146
|
-
// Move after the last child of the previous item.
|
|
147
|
-
let targetNode = collection.getItem(target.key);
|
|
148
|
-
if (targetNode && targetNode.prevKey != null) {
|
|
149
|
-
let lastChild = $6e16de4c92a0f271$var$getLastChild(collection, targetNode.prevKey);
|
|
150
|
-
if (lastChild) return lastChild;
|
|
151
|
-
}
|
|
152
|
-
if (prevKey != null) return {
|
|
153
|
-
type: 'item',
|
|
154
|
-
key: prevKey,
|
|
155
|
-
dropPosition: 'on'
|
|
156
|
-
};
|
|
157
|
-
return {
|
|
158
|
-
type: 'root'
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
case 'on':
|
|
162
|
-
return {
|
|
163
|
-
type: 'item',
|
|
164
|
-
key: target.key,
|
|
165
|
-
dropPosition: 'before'
|
|
166
|
-
};
|
|
167
|
-
case 'after':
|
|
168
|
-
{
|
|
169
|
-
// Move after the last child of this item.
|
|
170
|
-
let lastChild = $6e16de4c92a0f271$var$getLastChild(collection, target.key);
|
|
171
|
-
if (lastChild) return lastChild;
|
|
172
|
-
return {
|
|
173
|
-
type: 'item',
|
|
174
|
-
key: target.key,
|
|
175
|
-
dropPosition: 'on'
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
if (target.type !== 'root') return {
|
|
181
|
-
type: 'root'
|
|
182
|
-
};
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
function $6e16de4c92a0f271$var$getLastChild(collection, key) {
|
|
186
|
-
// getChildNodes still returns child tree items even when the item is collapsed.
|
|
187
|
-
// Checking if the next item has a greater level is a silly way to determine if the item is expanded.
|
|
188
|
-
let targetNode = collection.getItem(key);
|
|
189
|
-
let nextKey = collection.getKeyAfter(key);
|
|
190
|
-
let nextNode = nextKey != null ? collection.getItem(nextKey) : null;
|
|
191
|
-
if (targetNode && nextNode && nextNode.level > targetNode.level) {
|
|
192
|
-
let children = (0, $2pOR2$reactstatelycollections.getChildNodes)(targetNode, collection);
|
|
193
|
-
let lastChild = null;
|
|
194
|
-
for (let child of children)if (child.type === 'item') lastChild = child;
|
|
195
|
-
if (lastChild) return {
|
|
196
|
-
type: 'item',
|
|
197
|
-
key: lastChild.key,
|
|
198
|
-
dropPosition: 'after'
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
return null;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
//# sourceMappingURL=DropTargetKeyboardNavigation.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAGO,SAAS,0CACd,gBAAkC,EAClC,UAAqC,EACrC,MAAqC,EACrC,SAA2C,EAC3C,MAAM,KAAK,EACX,OAAO,KAAK;IAEZ,OAAQ;QACN,KAAK;YACH,OAAO,MACH,qCAAe,kBAAkB,YAAY,QAAQ,MAAM,UAC3D,yCAAmB,kBAAkB,YAAY,QAAQ,MAAM;QACrE,KAAK;YACH,OAAO,MACH,yCAAmB,kBAAkB,YAAY,QAAQ,MAAM,WAC/D,qCAAe,kBAAkB,YAAY,QAAQ,MAAM;QACjE,KAAK;YACH,OAAO,yCAAmB,kBAAkB,YAAY,QAAQ;QAClE,KAAK;YACH,OAAO,qCAAe,kBAAkB,YAAY,QAAQ;IAChE;AACF;AAEA,SAAS,qCACP,gBAAkC,EAClC,UAAqC,EACrC,MAAqC,EACrC,OAAO,KAAK,EACZ,aAAsC,IAAI;IAE1C,IAAI,CAAC,QACH,OAAO;QACL,MAAM;IACR;IAGF,IAAI,OAAO,IAAI,KAAK,QAAQ;YACZ;YAAA;QAAd,IAAI,UAAU,CAAA,kCAAA,gCAAA,iBAAiB,WAAW,cAA5B,oDAAA,mCAAA,+BAAA,4CAAA,iCAAoC;QAClD,IAAI,WAAW,MACb,OAAO;YACL,MAAM;YACN,KAAK;YACL,cAAc;QAChB;QAGF,OAAO;IACT;IAEA,IAAI,OAAO,IAAI,KAAK,QAAQ;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aAAa,WAAW,OAAO,CAAC;IACpC,IAAI,UAAU,WAAW,WAAW,CAAC;IACrC,IAAI,WAAW,WAAW,OAAO,WAAW,OAAO,CAAC,WAAW;IAC/D,IAAI,cAAc,YAAY,SAAS,KAAK,GAAG,WAAW,KAAK,EAAE;QAC/D,IAAI,WAAW,CAAA,GAAA,4CAAY,EAAE,YAAY;QACzC,IAAI,YAAkC;QACtC,KAAK,IAAI,SAAS,SAChB,IAAI,MAAM,IAAI,KAAK,QACjB,YAAY;QAIhB,IAAI,WACF,OAAO;YACL,MAAM;YACN,KAAK,UAAU,GAAG;YAClB,cAAc;QAChB;IAEJ;IAEA,OAAO;AACT","sources":["packages/@react-aria/dnd/src/DropTargetKeyboardNavigation.ts"],"sourcesContent":["import {Collection, DropTarget, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes} from '@react-stately/collections';\n\nexport function navigate(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n direction: 'left' | 'right' | 'up' | 'down',\n rtl = false,\n wrap = false\n): DropTarget | null {\n switch (direction) {\n case 'left':\n return rtl \n ? nextDropTarget(keyboardDelegate, collection, target, wrap, 'left')\n : previousDropTarget(keyboardDelegate, collection, target, wrap, 'left');\n case 'right':\n return rtl \n ? previousDropTarget(keyboardDelegate, collection, target, wrap, 'right')\n : nextDropTarget(keyboardDelegate, collection, target, wrap, 'right');\n case 'up':\n return previousDropTarget(keyboardDelegate, collection, target, wrap);\n case 'down':\n return nextDropTarget(keyboardDelegate, collection, target, wrap);\n }\n}\n\nfunction nextDropTarget(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n wrap = false,\n horizontal: 'left' | 'right' | null = null\n): DropTarget | null {\n if (!target) {\n return {\n type: 'root'\n };\n }\n\n if (target.type === 'root') {\n let nextKey = keyboardDelegate.getFirstKey?.() ?? null;\n if (nextKey != null) {\n return {\n type: 'item',\n key: nextKey,\n dropPosition: 'before'\n };\n }\n\n return null;\n }\n\n if (target.type === 'item') {\n let nextKey: Key | null | undefined = null;\n if (horizontal) {\n nextKey = horizontal === 'right' ? keyboardDelegate.getKeyRightOf?.(target.key) : keyboardDelegate.getKeyLeftOf?.(target.key);\n } else {\n nextKey = keyboardDelegate.getKeyBelow?.(target.key);\n }\n let nextCollectionKey = collection.getKeyAfter(target.key);\n\n // If the keyboard delegate did not move to the next key in the collection,\n // jump to that key with the same drop position. Otherwise, try the other\n // drop positions on the current key first.\n if (nextKey != null && nextKey !== nextCollectionKey) {\n return {\n type: 'item',\n key: nextKey,\n dropPosition: target.dropPosition\n };\n }\n \n switch (target.dropPosition) {\n case 'before': {\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'on'\n };\n }\n case 'on': {\n // If there are nested items, traverse to them prior to the \"after\" position of this target.\n // If the next key is on the same level, then its \"before\" position is equivalent to this item's \"after\" position.\n let targetNode = collection.getItem(target.key);\n let nextNode = nextKey != null ? collection.getItem(nextKey) : null;\n if (targetNode && nextNode && nextNode.level >= targetNode.level) {\n return {\n type: 'item',\n key: nextNode.key,\n dropPosition: 'before'\n };\n }\n\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'after'\n };\n }\n case 'after': {\n // If this is the last sibling in a level, traverse to the parent.\n let targetNode = collection.getItem(target.key);\n let nextItemInSameLevel = targetNode?.nextKey != null ? collection.getItem(targetNode.nextKey) : null;\n while (nextItemInSameLevel != null && nextItemInSameLevel.type !== 'item') {\n nextItemInSameLevel = nextItemInSameLevel.nextKey != null ? collection.getItem(nextItemInSameLevel.nextKey) : null;\n }\n \n if (targetNode && nextItemInSameLevel == null && targetNode.parentKey != null) {\n // If the parent item has an item after it, use the \"before\" position.\n let parentNode = collection.getItem(targetNode.parentKey);\n const nextNode = parentNode?.nextKey != null ? collection.getItem(parentNode.nextKey) : null;\n if (nextNode?.type === 'item') {\n return {\n type: 'item',\n key: nextNode.key,\n dropPosition: 'before'\n };\n }\n\n if (parentNode?.type === 'item') {\n return {\n type: 'item',\n key: parentNode.key,\n dropPosition: 'after'\n };\n }\n }\n\n if (nextItemInSameLevel) {\n return {\n type: 'item',\n key: nextItemInSameLevel.key,\n dropPosition: 'on'\n };\n }\n }\n }\n }\n\n if (wrap) {\n return {\n type: 'root'\n };\n }\n\n return null;\n}\n\nfunction previousDropTarget(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n wrap = false,\n horizontal: 'left' | 'right' | null = null\n): DropTarget | null {\n // Start after the last root-level item.\n if (!target || (wrap && target.type === 'root')) {\n // Keyboard delegate gets the deepest item but we want the shallowest.\n let prevKey: Key | null = null;\n let lastKey = keyboardDelegate.getLastKey?.();\n while (lastKey != null) {\n let node = collection.getItem(lastKey);\n if (node?.type !== 'item') {\n break;\n }\n prevKey = lastKey;\n lastKey = node?.parentKey;\n }\n\n if (prevKey != null) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: 'after'\n };\n }\n\n return null;\n }\n\n if (target.type === 'item') {\n let prevKey: Key | null | undefined = null;\n if (horizontal) {\n prevKey = horizontal === 'left' ? keyboardDelegate.getKeyLeftOf?.(target.key) : keyboardDelegate.getKeyRightOf?.(target.key);\n } else {\n prevKey = keyboardDelegate.getKeyAbove?.(target.key);\n }\n let prevCollectionKey = collection.getKeyBefore(target.key);\n\n // If the keyboard delegate did not move to the next key in the collection,\n // jump to that key with the same drop position. Otherwise, try the other\n // drop positions on the current key first.\n if (prevKey != null && prevKey !== prevCollectionKey) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: target.dropPosition\n };\n }\n\n switch (target.dropPosition) {\n case 'before': {\n // Move after the last child of the previous item.\n let targetNode = collection.getItem(target.key);\n if (targetNode && targetNode.prevKey != null) {\n let lastChild = getLastChild(collection, targetNode.prevKey);\n if (lastChild) {\n return lastChild;\n }\n }\n\n if (prevKey != null) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: 'on'\n };\n }\n\n return {\n type: 'root'\n };\n }\n case 'on': {\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'before'\n };\n }\n case 'after': {\n // Move after the last child of this item.\n let lastChild = getLastChild(collection, target.key);\n if (lastChild) {\n return lastChild;\n }\n\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'on'\n };\n }\n }\n }\n\n if (target.type !== 'root') {\n return {\n type: 'root'\n };\n }\n\n return null;\n}\n\nfunction getLastChild(collection: Collection<Node<unknown>>, key: Key): DropTarget | null {\n // getChildNodes still returns child tree items even when the item is collapsed.\n // Checking if the next item has a greater level is a silly way to determine if the item is expanded.\n let targetNode = collection.getItem(key);\n let nextKey = collection.getKeyAfter(key);\n let nextNode = nextKey != null ? collection.getItem(nextKey) : null;\n if (targetNode && nextNode && nextNode.level > targetNode.level) {\n let children = getChildNodes(targetNode, collection);\n let lastChild: Node<unknown> | null = null;\n for (let child of children) {\n if (child.type === 'item') {\n lastChild = child;\n }\n }\n\n if (lastChild) {\n return {\n type: 'item',\n key: lastChild.key,\n dropPosition: 'after'\n };\n }\n }\n\n return null;\n}\n"],"names":[],"version":3,"file":"DropTargetKeyboardNavigation.main.js.map"}
|