@react-aria/dnd 3.5.4-nightly.4555 → 3.5.4-nightly.4558
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/DragManager.main.js +444 -0
- package/dist/DragManager.main.js.map +1 -0
- package/dist/DragManager.mjs +435 -0
- package/dist/DragManager.module.js +435 -0
- package/dist/DragManager.module.js.map +1 -0
- package/dist/DragPreview.main.js +59 -0
- package/dist/DragPreview.main.js.map +1 -0
- package/dist/DragPreview.mjs +50 -0
- package/dist/DragPreview.module.js +50 -0
- package/dist/DragPreview.module.js.map +1 -0
- package/dist/ListDropTargetDelegate.main.js +119 -0
- package/dist/ListDropTargetDelegate.main.js.map +1 -0
- package/dist/ListDropTargetDelegate.mjs +114 -0
- package/dist/ListDropTargetDelegate.module.js +114 -0
- package/dist/ListDropTargetDelegate.module.js.map +1 -0
- package/dist/ar-AE.mjs +1 -1
- package/dist/bg-BG.mjs +1 -1
- package/dist/constants.main.js +65 -0
- package/dist/constants.main.js.map +1 -0
- package/dist/constants.mjs +53 -0
- package/dist/constants.module.js +53 -0
- package/dist/constants.module.js.map +1 -0
- package/dist/cs-CZ.mjs +1 -1
- package/dist/da-DK.mjs +1 -1
- package/dist/de-DE.mjs +1 -1
- package/dist/el-GR.mjs +1 -1
- package/dist/en-US.mjs +1 -1
- package/dist/es-ES.mjs +1 -1
- package/dist/et-EE.mjs +1 -1
- package/dist/fi-FI.mjs +1 -1
- package/dist/fr-FR.mjs +1 -1
- package/dist/he-IL.mjs +1 -1
- package/dist/hr-HR.mjs +1 -1
- package/dist/hu-HU.mjs +1 -1
- package/dist/import.mjs +12 -2582
- package/dist/intlStrings.main.js +108 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +110 -0
- package/dist/intlStrings.module.js +110 -0
- package/dist/intlStrings.module.js.map +1 -0
- package/dist/it-IT.mjs +1 -1
- package/dist/ja-JP.mjs +1 -1
- package/dist/ko-KR.mjs +1 -1
- package/dist/lt-LT.mjs +1 -1
- package/dist/lv-LV.mjs +1 -1
- package/dist/main.js +27 -2597
- package/dist/main.js.map +1 -1
- package/dist/module.js +12 -2582
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.mjs +1 -1
- package/dist/nl-NL.mjs +1 -1
- package/dist/pl-PL.mjs +1 -1
- package/dist/pt-BR.mjs +1 -1
- package/dist/pt-PT.mjs +1 -1
- package/dist/ro-RO.mjs +1 -1
- package/dist/ru-RU.mjs +1 -1
- package/dist/sk-SK.mjs +1 -1
- package/dist/sl-SI.mjs +1 -1
- package/dist/sr-SP.mjs +1 -1
- package/dist/sv-SE.mjs +1 -1
- package/dist/tr-TR.mjs +1 -1
- package/dist/uk-UA.mjs +1 -1
- package/dist/useAutoScroll.main.js +89 -0
- package/dist/useAutoScroll.main.js.map +1 -0
- package/dist/useAutoScroll.mjs +84 -0
- package/dist/useAutoScroll.module.js +84 -0
- package/dist/useAutoScroll.module.js.map +1 -0
- package/dist/useClipboard.main.js +107 -0
- package/dist/useClipboard.main.js.map +1 -0
- package/dist/useClipboard.mjs +102 -0
- package/dist/useClipboard.module.js +102 -0
- package/dist/useClipboard.module.js.map +1 -0
- package/dist/useDrag.main.js +279 -0
- package/dist/useDrag.main.js.map +1 -0
- package/dist/useDrag.mjs +274 -0
- package/dist/useDrag.module.js +274 -0
- package/dist/useDrag.module.js.map +1 -0
- package/dist/useDraggableCollection.main.js +27 -0
- package/dist/useDraggableCollection.main.js.map +1 -0
- package/dist/useDraggableCollection.mjs +22 -0
- package/dist/useDraggableCollection.module.js +22 -0
- package/dist/useDraggableCollection.module.js.map +1 -0
- package/dist/useDraggableItem.main.js +128 -0
- package/dist/useDraggableItem.main.js.map +1 -0
- package/dist/useDraggableItem.mjs +123 -0
- package/dist/useDraggableItem.module.js +123 -0
- package/dist/useDraggableItem.module.js.map +1 -0
- package/dist/useDrop.main.js +299 -0
- package/dist/useDrop.main.js.map +1 -0
- package/dist/useDrop.mjs +294 -0
- package/dist/useDrop.module.js +294 -0
- package/dist/useDrop.module.js.map +1 -0
- package/dist/useDropIndicator.main.js +93 -0
- package/dist/useDropIndicator.main.js.map +1 -0
- package/dist/useDropIndicator.mjs +88 -0
- package/dist/useDropIndicator.module.js +88 -0
- package/dist/useDropIndicator.module.js.map +1 -0
- package/dist/useDroppableCollection.main.js +583 -0
- package/dist/useDroppableCollection.main.js.map +1 -0
- package/dist/useDroppableCollection.mjs +578 -0
- package/dist/useDroppableCollection.module.js +578 -0
- package/dist/useDroppableCollection.module.js.map +1 -0
- package/dist/useDroppableItem.main.js +79 -0
- package/dist/useDroppableItem.main.js.map +1 -0
- package/dist/useDroppableItem.mjs +74 -0
- package/dist/useDroppableItem.module.js +74 -0
- package/dist/useDroppableItem.module.js.map +1 -0
- package/dist/useVirtualDrop.main.js +56 -0
- package/dist/useVirtualDrop.main.js.map +1 -0
- package/dist/useVirtualDrop.mjs +51 -0
- package/dist/useVirtualDrop.module.js +51 -0
- package/dist/useVirtualDrop.module.js.map +1 -0
- package/dist/utils.main.js +283 -0
- package/dist/utils.main.js.map +1 -0
- package/dist/utils.mjs +255 -0
- package/dist/utils.module.js +255 -0
- package/dist/utils.module.js.map +1 -0
- package/dist/zh-CN.mjs +1 -1
- package/dist/zh-TW.mjs +1 -1
- package/package.json +11 -11
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var $28e10663603f5ea1$exports = require("./DragManager.main.js");
|
|
2
|
+
var $4620ae0dc40f0031$exports = require("./utils.main.js");
|
|
3
|
+
var $7c8adf3925a26206$exports = require("./intlStrings.main.js");
|
|
4
|
+
var $fc1876157e07bcec$exports = require("./useDroppableItem.main.js");
|
|
5
|
+
var $Zlq1e$reactariautils = require("@react-aria/utils");
|
|
6
|
+
var $Zlq1e$reactariai18n = require("@react-aria/i18n");
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
function $parcel$interopDefault(a) {
|
|
10
|
+
return a && a.__esModule ? a.default : a;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function $parcel$export(e, n, v, s) {
|
|
14
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
$parcel$export(module.exports, "useDropIndicator", () => $c5557edbed563ebf$export$8d0e41d2815afac5);
|
|
18
|
+
/*
|
|
19
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
20
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
21
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
22
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
23
|
+
*
|
|
24
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
25
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
26
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
27
|
+
* governing permissions and limitations under the License.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
function $c5557edbed563ebf$export$8d0e41d2815afac5(props, state, ref) {
|
|
35
|
+
let { target: target } = props;
|
|
36
|
+
let { collection: collection } = state;
|
|
37
|
+
let stringFormatter = (0, $Zlq1e$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($7c8adf3925a26206$exports))), "@react-aria/dnd");
|
|
38
|
+
let dragSession = $28e10663603f5ea1$exports.useDragSession();
|
|
39
|
+
let { dropProps: dropProps } = (0, $fc1876157e07bcec$exports.useDroppableItem)(props, state, ref);
|
|
40
|
+
let id = (0, $Zlq1e$reactariautils.useId)();
|
|
41
|
+
let getText = (key)=>{
|
|
42
|
+
var _collection_getTextValue, _collection_getItem;
|
|
43
|
+
var _collection_getTextValue1;
|
|
44
|
+
return (_collection_getTextValue1 = (_collection_getTextValue = collection.getTextValue) === null || _collection_getTextValue === void 0 ? void 0 : _collection_getTextValue.call(collection, key)) !== null && _collection_getTextValue1 !== void 0 ? _collection_getTextValue1 : (_collection_getItem = collection.getItem(key)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue;
|
|
45
|
+
};
|
|
46
|
+
let label = "";
|
|
47
|
+
let labelledBy;
|
|
48
|
+
if (target.type === "root") {
|
|
49
|
+
label = stringFormatter.format("dropOnRoot");
|
|
50
|
+
labelledBy = `${id} ${(0, $4620ae0dc40f0031$exports.getDroppableCollectionId)(state)}`;
|
|
51
|
+
} else if (target.dropPosition === "on") label = stringFormatter.format("dropOnItem", {
|
|
52
|
+
itemText: getText(target.key)
|
|
53
|
+
});
|
|
54
|
+
else {
|
|
55
|
+
let before;
|
|
56
|
+
let after;
|
|
57
|
+
if (collection.getFirstKey() === target.key && target.dropPosition === "before") before = null;
|
|
58
|
+
else before = target.dropPosition === "before" ? collection.getKeyBefore(target.key) : target.key;
|
|
59
|
+
if (collection.getLastKey() === target.key && target.dropPosition === "after") after = null;
|
|
60
|
+
else after = target.dropPosition === "after" ? collection.getKeyAfter(target.key) : target.key;
|
|
61
|
+
if (before && after) label = stringFormatter.format("insertBetween", {
|
|
62
|
+
beforeItemText: getText(before),
|
|
63
|
+
afterItemText: getText(after)
|
|
64
|
+
});
|
|
65
|
+
else if (before) label = stringFormatter.format("insertAfter", {
|
|
66
|
+
itemText: getText(before)
|
|
67
|
+
});
|
|
68
|
+
else if (after) label = stringFormatter.format("insertBefore", {
|
|
69
|
+
itemText: getText(after)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
let isDropTarget = state.isDropTarget(target);
|
|
73
|
+
let ariaHidden = !dragSession ? "true" : dropProps["aria-hidden"];
|
|
74
|
+
return {
|
|
75
|
+
dropIndicatorProps: {
|
|
76
|
+
...dropProps,
|
|
77
|
+
id: id,
|
|
78
|
+
"aria-roledescription": stringFormatter.format("dropIndicator"),
|
|
79
|
+
"aria-label": label,
|
|
80
|
+
"aria-labelledby": labelledBy,
|
|
81
|
+
"aria-hidden": ariaHidden,
|
|
82
|
+
tabIndex: -1
|
|
83
|
+
},
|
|
84
|
+
isDropTarget: isDropTarget,
|
|
85
|
+
// If aria-hidden, we are either not in a drag session or the drop target is invalid.
|
|
86
|
+
// In that case, there's no need to render anything at all unless we need to show the indicator visually.
|
|
87
|
+
// This can happen when dragging using the native DnD API as opposed to keyboard dragging.
|
|
88
|
+
isHidden: !isDropTarget && !!ariaHidden
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=useDropIndicator.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAiCM,SAAS,0CAAiB,KAAyB,EAAE,KAA+B,EAAE,GAA2B;IACtH,IAAI,UAAC,MAAM,EAAC,GAAG;IACf,IAAI,cAAC,UAAU,EAAC,GAAG;IAEnB,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,cAAc;IAClB,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,0CAAe,EAAE,OAAO,OAAO;IACjD,IAAI,KAAK,CAAA,GAAA,2BAAI;IACb,IAAI,UAAU,CAAC;YAAa,0BAAkC;YAAlC;eAAA,CAAA,6BAAA,2BAAA,WAAW,YAAY,cAAvB,+CAAA,8BAAA,YAA0B,kBAA1B,uCAAA,6BAAkC,sBAAA,WAAW,OAAO,CAAC,kBAAnB,0CAAA,oBAAyB,SAAS;IAAD;IAE/F,IAAI,QAAQ;IACZ,IAAI;IACJ,IAAI,OAAO,IAAI,KAAK,QAAQ;QAC1B,QAAQ,gBAAgB,MAAM,CAAC;QAC/B,aAAa,CAAC,EAAE,GAAG,CAAC,EAAE,CAAA,GAAA,kDAAuB,EAAE,OAAO,CAAC;IACzD,OAAO,IAAI,OAAO,YAAY,KAAK,MACjC,QAAQ,gBAAgB,MAAM,CAAC,cAAc;QAC3C,UAAU,QAAQ,OAAO,GAAG;IAC9B;SACK;QACL,IAAI;QACJ,IAAI;QACJ,IAAI,WAAW,WAAW,OAAO,OAAO,GAAG,IAAI,OAAO,YAAY,KAAK,UACrE,SAAS;aAET,SAAS,OAAO,YAAY,KAAK,WAAW,WAAW,YAAY,CAAC,OAAO,GAAG,IAAI,OAAO,GAAG;QAG9F,IAAI,WAAW,UAAU,OAAO,OAAO,GAAG,IAAI,OAAO,YAAY,KAAK,SACpE,QAAQ;aAER,QAAQ,OAAO,YAAY,KAAK,UAAU,WAAW,WAAW,CAAC,OAAO,GAAG,IAAI,OAAO,GAAG;QAG3F,IAAI,UAAU,OACZ,QAAQ,gBAAgB,MAAM,CAAC,iBAAiB;YAC9C,gBAAgB,QAAQ;YACxB,eAAe,QAAQ;QACzB;aACK,IAAI,QACT,QAAQ,gBAAgB,MAAM,CAAC,eAAe;YAC5C,UAAU,QAAQ;QACpB;aACK,IAAI,OACT,QAAQ,gBAAgB,MAAM,CAAC,gBAAgB;YAC7C,UAAU,QAAQ;QACpB;IAEJ;IAEA,IAAI,eAAe,MAAM,YAAY,CAAC;IACtC,IAAI,aAAa,CAAC,cAAc,SAAS,SAAS,CAAC,cAAc;IACjE,OAAO;QACL,oBAAoB;YAClB,GAAG,SAAS;gBACZ;YACA,wBAAwB,gBAAgB,MAAM,CAAC;YAC/C,cAAc;YACd,mBAAmB;YACnB,eAAe;YACf,UAAU;QACZ;sBACA;QACA,qFAAqF;QACrF,yGAAyG;QACzG,0FAA0F;QAC1F,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC/B;AACF","sources":["packages/@react-aria/dnd/src/useDropIndicator.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 * as DragManager from './DragManager';\nimport {DroppableCollectionState} from '@react-stately/dnd';\nimport {DropTarget, Key} from '@react-types/shared';\nimport {getDroppableCollectionId} from './utils';\nimport {HTMLAttributes, RefObject} from 'react';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useDroppableItem} from './useDroppableItem';\nimport {useId} from '@react-aria/utils';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface DropIndicatorProps {\n /** The drop target that the drop indicator represents. */\n target: DropTarget\n}\n\nexport interface DropIndicatorAria {\n /** Props for the drop indicator element. */\n dropIndicatorProps: HTMLAttributes<HTMLElement>,\n /** Whether the drop indicator is currently the active drop target. */\n isDropTarget: boolean,\n /**\n * Whether the drop indicator is hidden, both visually and from assistive technology.\n * Use this to determine whether to omit the element from the DOM entirely.\n */\n isHidden: boolean\n}\n\n/**\n * Handles drop interactions for a target within a droppable collection.\n */\nexport function useDropIndicator(props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement>): DropIndicatorAria {\n let {target} = props;\n let {collection} = state;\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/dnd');\n let dragSession = DragManager.useDragSession();\n let {dropProps} = useDroppableItem(props, state, ref);\n let id = useId();\n let getText = (key: Key) => collection.getTextValue?.(key) ?? collection.getItem(key)?.textValue;\n\n let label = '';\n let labelledBy: string;\n if (target.type === 'root') {\n label = stringFormatter.format('dropOnRoot');\n labelledBy = `${id} ${getDroppableCollectionId(state)}`;\n } else if (target.dropPosition === 'on') {\n label = stringFormatter.format('dropOnItem', {\n itemText: getText(target.key)\n });\n } else {\n let before: Key | null;\n let after: Key | null;\n if (collection.getFirstKey() === target.key && target.dropPosition === 'before') {\n before = null;\n } else {\n before = target.dropPosition === 'before' ? collection.getKeyBefore(target.key) : target.key;\n }\n\n if (collection.getLastKey() === target.key && target.dropPosition === 'after') {\n after = null;\n } else {\n after = target.dropPosition === 'after' ? collection.getKeyAfter(target.key) : target.key;\n }\n\n if (before && after) {\n label = stringFormatter.format('insertBetween', {\n beforeItemText: getText(before),\n afterItemText: getText(after)\n });\n } else if (before) {\n label = stringFormatter.format('insertAfter', {\n itemText: getText(before)\n });\n } else if (after) {\n label = stringFormatter.format('insertBefore', {\n itemText: getText(after)\n });\n }\n }\n\n let isDropTarget = state.isDropTarget(target);\n let ariaHidden = !dragSession ? 'true' : dropProps['aria-hidden'];\n return {\n dropIndicatorProps: {\n ...dropProps,\n id,\n 'aria-roledescription': stringFormatter.format('dropIndicator'),\n 'aria-label': label,\n 'aria-labelledby': labelledBy,\n 'aria-hidden': ariaHidden,\n tabIndex: -1\n },\n isDropTarget,\n // If aria-hidden, we are either not in a drag session or the drop target is invalid.\n // In that case, there's no need to render anything at all unless we need to show the indicator visually.\n // This can happen when dragging using the native DnD API as opposed to keyboard dragging.\n isHidden: !isDropTarget && !!ariaHidden\n };\n}\n"],"names":[],"version":3,"file":"useDropIndicator.main.js.map"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {useDragSession as $67560de7c78cb232$export$418e185dd3f1b968} from "./DragManager.mjs";
|
|
2
|
+
import {getDroppableCollectionId as $7252cd45fc48c07c$export$3093291712f09a77} from "./utils.mjs";
|
|
3
|
+
import $8HwJV$intlStringsmodulejs from "./intlStrings.mjs";
|
|
4
|
+
import {useDroppableItem as $bfaab576ce1c580e$export$f7b0c5d28b66b6a5} from "./useDroppableItem.mjs";
|
|
5
|
+
import {useId as $8HwJV$useId} from "@react-aria/utils";
|
|
6
|
+
import {useLocalizedStringFormatter as $8HwJV$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
function $parcel$interopDefault(a) {
|
|
10
|
+
return a && a.__esModule ? a.default : a;
|
|
11
|
+
}
|
|
12
|
+
/*
|
|
13
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
14
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
15
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
16
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
19
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
20
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
21
|
+
* governing permissions and limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
function $ddf25448c71fc93a$export$8d0e41d2815afac5(props, state, ref) {
|
|
29
|
+
let { target: target } = props;
|
|
30
|
+
let { collection: collection } = state;
|
|
31
|
+
let stringFormatter = (0, $8HwJV$useLocalizedStringFormatter)((0, ($parcel$interopDefault($8HwJV$intlStringsmodulejs))), "@react-aria/dnd");
|
|
32
|
+
let dragSession = $67560de7c78cb232$export$418e185dd3f1b968();
|
|
33
|
+
let { dropProps: dropProps } = (0, $bfaab576ce1c580e$export$f7b0c5d28b66b6a5)(props, state, ref);
|
|
34
|
+
let id = (0, $8HwJV$useId)();
|
|
35
|
+
let getText = (key)=>{
|
|
36
|
+
var _collection_getTextValue, _collection_getItem;
|
|
37
|
+
var _collection_getTextValue1;
|
|
38
|
+
return (_collection_getTextValue1 = (_collection_getTextValue = collection.getTextValue) === null || _collection_getTextValue === void 0 ? void 0 : _collection_getTextValue.call(collection, key)) !== null && _collection_getTextValue1 !== void 0 ? _collection_getTextValue1 : (_collection_getItem = collection.getItem(key)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue;
|
|
39
|
+
};
|
|
40
|
+
let label = "";
|
|
41
|
+
let labelledBy;
|
|
42
|
+
if (target.type === "root") {
|
|
43
|
+
label = stringFormatter.format("dropOnRoot");
|
|
44
|
+
labelledBy = `${id} ${(0, $7252cd45fc48c07c$export$3093291712f09a77)(state)}`;
|
|
45
|
+
} else if (target.dropPosition === "on") label = stringFormatter.format("dropOnItem", {
|
|
46
|
+
itemText: getText(target.key)
|
|
47
|
+
});
|
|
48
|
+
else {
|
|
49
|
+
let before;
|
|
50
|
+
let after;
|
|
51
|
+
if (collection.getFirstKey() === target.key && target.dropPosition === "before") before = null;
|
|
52
|
+
else before = target.dropPosition === "before" ? collection.getKeyBefore(target.key) : target.key;
|
|
53
|
+
if (collection.getLastKey() === target.key && target.dropPosition === "after") after = null;
|
|
54
|
+
else after = target.dropPosition === "after" ? collection.getKeyAfter(target.key) : target.key;
|
|
55
|
+
if (before && after) label = stringFormatter.format("insertBetween", {
|
|
56
|
+
beforeItemText: getText(before),
|
|
57
|
+
afterItemText: getText(after)
|
|
58
|
+
});
|
|
59
|
+
else if (before) label = stringFormatter.format("insertAfter", {
|
|
60
|
+
itemText: getText(before)
|
|
61
|
+
});
|
|
62
|
+
else if (after) label = stringFormatter.format("insertBefore", {
|
|
63
|
+
itemText: getText(after)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
let isDropTarget = state.isDropTarget(target);
|
|
67
|
+
let ariaHidden = !dragSession ? "true" : dropProps["aria-hidden"];
|
|
68
|
+
return {
|
|
69
|
+
dropIndicatorProps: {
|
|
70
|
+
...dropProps,
|
|
71
|
+
id: id,
|
|
72
|
+
"aria-roledescription": stringFormatter.format("dropIndicator"),
|
|
73
|
+
"aria-label": label,
|
|
74
|
+
"aria-labelledby": labelledBy,
|
|
75
|
+
"aria-hidden": ariaHidden,
|
|
76
|
+
tabIndex: -1
|
|
77
|
+
},
|
|
78
|
+
isDropTarget: isDropTarget,
|
|
79
|
+
// If aria-hidden, we are either not in a drag session or the drop target is invalid.
|
|
80
|
+
// In that case, there's no need to render anything at all unless we need to show the indicator visually.
|
|
81
|
+
// This can happen when dragging using the native DnD API as opposed to keyboard dragging.
|
|
82
|
+
isHidden: !isDropTarget && !!ariaHidden
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
export {$ddf25448c71fc93a$export$8d0e41d2815afac5 as useDropIndicator};
|
|
88
|
+
//# sourceMappingURL=useDropIndicator.mjs.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {useDragSession as $67560de7c78cb232$export$418e185dd3f1b968} from "./DragManager.module.js";
|
|
2
|
+
import {getDroppableCollectionId as $7252cd45fc48c07c$export$3093291712f09a77} from "./utils.module.js";
|
|
3
|
+
import $8HwJV$intlStringsmodulejs from "./intlStrings.module.js";
|
|
4
|
+
import {useDroppableItem as $bfaab576ce1c580e$export$f7b0c5d28b66b6a5} from "./useDroppableItem.module.js";
|
|
5
|
+
import {useId as $8HwJV$useId} from "@react-aria/utils";
|
|
6
|
+
import {useLocalizedStringFormatter as $8HwJV$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
function $parcel$interopDefault(a) {
|
|
10
|
+
return a && a.__esModule ? a.default : a;
|
|
11
|
+
}
|
|
12
|
+
/*
|
|
13
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
14
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
15
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
16
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
19
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
20
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
21
|
+
* governing permissions and limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
function $ddf25448c71fc93a$export$8d0e41d2815afac5(props, state, ref) {
|
|
29
|
+
let { target: target } = props;
|
|
30
|
+
let { collection: collection } = state;
|
|
31
|
+
let stringFormatter = (0, $8HwJV$useLocalizedStringFormatter)((0, ($parcel$interopDefault($8HwJV$intlStringsmodulejs))), "@react-aria/dnd");
|
|
32
|
+
let dragSession = $67560de7c78cb232$export$418e185dd3f1b968();
|
|
33
|
+
let { dropProps: dropProps } = (0, $bfaab576ce1c580e$export$f7b0c5d28b66b6a5)(props, state, ref);
|
|
34
|
+
let id = (0, $8HwJV$useId)();
|
|
35
|
+
let getText = (key)=>{
|
|
36
|
+
var _collection_getTextValue, _collection_getItem;
|
|
37
|
+
var _collection_getTextValue1;
|
|
38
|
+
return (_collection_getTextValue1 = (_collection_getTextValue = collection.getTextValue) === null || _collection_getTextValue === void 0 ? void 0 : _collection_getTextValue.call(collection, key)) !== null && _collection_getTextValue1 !== void 0 ? _collection_getTextValue1 : (_collection_getItem = collection.getItem(key)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue;
|
|
39
|
+
};
|
|
40
|
+
let label = "";
|
|
41
|
+
let labelledBy;
|
|
42
|
+
if (target.type === "root") {
|
|
43
|
+
label = stringFormatter.format("dropOnRoot");
|
|
44
|
+
labelledBy = `${id} ${(0, $7252cd45fc48c07c$export$3093291712f09a77)(state)}`;
|
|
45
|
+
} else if (target.dropPosition === "on") label = stringFormatter.format("dropOnItem", {
|
|
46
|
+
itemText: getText(target.key)
|
|
47
|
+
});
|
|
48
|
+
else {
|
|
49
|
+
let before;
|
|
50
|
+
let after;
|
|
51
|
+
if (collection.getFirstKey() === target.key && target.dropPosition === "before") before = null;
|
|
52
|
+
else before = target.dropPosition === "before" ? collection.getKeyBefore(target.key) : target.key;
|
|
53
|
+
if (collection.getLastKey() === target.key && target.dropPosition === "after") after = null;
|
|
54
|
+
else after = target.dropPosition === "after" ? collection.getKeyAfter(target.key) : target.key;
|
|
55
|
+
if (before && after) label = stringFormatter.format("insertBetween", {
|
|
56
|
+
beforeItemText: getText(before),
|
|
57
|
+
afterItemText: getText(after)
|
|
58
|
+
});
|
|
59
|
+
else if (before) label = stringFormatter.format("insertAfter", {
|
|
60
|
+
itemText: getText(before)
|
|
61
|
+
});
|
|
62
|
+
else if (after) label = stringFormatter.format("insertBefore", {
|
|
63
|
+
itemText: getText(after)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
let isDropTarget = state.isDropTarget(target);
|
|
67
|
+
let ariaHidden = !dragSession ? "true" : dropProps["aria-hidden"];
|
|
68
|
+
return {
|
|
69
|
+
dropIndicatorProps: {
|
|
70
|
+
...dropProps,
|
|
71
|
+
id: id,
|
|
72
|
+
"aria-roledescription": stringFormatter.format("dropIndicator"),
|
|
73
|
+
"aria-label": label,
|
|
74
|
+
"aria-labelledby": labelledBy,
|
|
75
|
+
"aria-hidden": ariaHidden,
|
|
76
|
+
tabIndex: -1
|
|
77
|
+
},
|
|
78
|
+
isDropTarget: isDropTarget,
|
|
79
|
+
// If aria-hidden, we are either not in a drag session or the drop target is invalid.
|
|
80
|
+
// In that case, there's no need to render anything at all unless we need to show the indicator visually.
|
|
81
|
+
// This can happen when dragging using the native DnD API as opposed to keyboard dragging.
|
|
82
|
+
isHidden: !isDropTarget && !!ariaHidden
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
export {$ddf25448c71fc93a$export$8d0e41d2815afac5 as useDropIndicator};
|
|
88
|
+
//# sourceMappingURL=useDropIndicator.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAiCM,SAAS,0CAAiB,KAAyB,EAAE,KAA+B,EAAE,GAA2B;IACtH,IAAI,UAAC,MAAM,EAAC,GAAG;IACf,IAAI,cAAC,UAAU,EAAC,GAAG;IAEnB,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,IAAI,cAAc;IAClB,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,yCAAe,EAAE,OAAO,OAAO;IACjD,IAAI,KAAK,CAAA,GAAA,YAAI;IACb,IAAI,UAAU,CAAC;YAAa,0BAAkC;YAAlC;eAAA,CAAA,6BAAA,2BAAA,WAAW,YAAY,cAAvB,+CAAA,8BAAA,YAA0B,kBAA1B,uCAAA,6BAAkC,sBAAA,WAAW,OAAO,CAAC,kBAAnB,0CAAA,oBAAyB,SAAS;IAAD;IAE/F,IAAI,QAAQ;IACZ,IAAI;IACJ,IAAI,OAAO,IAAI,KAAK,QAAQ;QAC1B,QAAQ,gBAAgB,MAAM,CAAC;QAC/B,aAAa,CAAC,EAAE,GAAG,CAAC,EAAE,CAAA,GAAA,yCAAuB,EAAE,OAAO,CAAC;IACzD,OAAO,IAAI,OAAO,YAAY,KAAK,MACjC,QAAQ,gBAAgB,MAAM,CAAC,cAAc;QAC3C,UAAU,QAAQ,OAAO,GAAG;IAC9B;SACK;QACL,IAAI;QACJ,IAAI;QACJ,IAAI,WAAW,WAAW,OAAO,OAAO,GAAG,IAAI,OAAO,YAAY,KAAK,UACrE,SAAS;aAET,SAAS,OAAO,YAAY,KAAK,WAAW,WAAW,YAAY,CAAC,OAAO,GAAG,IAAI,OAAO,GAAG;QAG9F,IAAI,WAAW,UAAU,OAAO,OAAO,GAAG,IAAI,OAAO,YAAY,KAAK,SACpE,QAAQ;aAER,QAAQ,OAAO,YAAY,KAAK,UAAU,WAAW,WAAW,CAAC,OAAO,GAAG,IAAI,OAAO,GAAG;QAG3F,IAAI,UAAU,OACZ,QAAQ,gBAAgB,MAAM,CAAC,iBAAiB;YAC9C,gBAAgB,QAAQ;YACxB,eAAe,QAAQ;QACzB;aACK,IAAI,QACT,QAAQ,gBAAgB,MAAM,CAAC,eAAe;YAC5C,UAAU,QAAQ;QACpB;aACK,IAAI,OACT,QAAQ,gBAAgB,MAAM,CAAC,gBAAgB;YAC7C,UAAU,QAAQ;QACpB;IAEJ;IAEA,IAAI,eAAe,MAAM,YAAY,CAAC;IACtC,IAAI,aAAa,CAAC,cAAc,SAAS,SAAS,CAAC,cAAc;IACjE,OAAO;QACL,oBAAoB;YAClB,GAAG,SAAS;gBACZ;YACA,wBAAwB,gBAAgB,MAAM,CAAC;YAC/C,cAAc;YACd,mBAAmB;YACnB,eAAe;YACf,UAAU;QACZ;sBACA;QACA,qFAAqF;QACrF,yGAAyG;QACzG,0FAA0F;QAC1F,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC/B;AACF","sources":["packages/@react-aria/dnd/src/useDropIndicator.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 * as DragManager from './DragManager';\nimport {DroppableCollectionState} from '@react-stately/dnd';\nimport {DropTarget, Key} from '@react-types/shared';\nimport {getDroppableCollectionId} from './utils';\nimport {HTMLAttributes, RefObject} from 'react';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useDroppableItem} from './useDroppableItem';\nimport {useId} from '@react-aria/utils';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface DropIndicatorProps {\n /** The drop target that the drop indicator represents. */\n target: DropTarget\n}\n\nexport interface DropIndicatorAria {\n /** Props for the drop indicator element. */\n dropIndicatorProps: HTMLAttributes<HTMLElement>,\n /** Whether the drop indicator is currently the active drop target. */\n isDropTarget: boolean,\n /**\n * Whether the drop indicator is hidden, both visually and from assistive technology.\n * Use this to determine whether to omit the element from the DOM entirely.\n */\n isHidden: boolean\n}\n\n/**\n * Handles drop interactions for a target within a droppable collection.\n */\nexport function useDropIndicator(props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement>): DropIndicatorAria {\n let {target} = props;\n let {collection} = state;\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/dnd');\n let dragSession = DragManager.useDragSession();\n let {dropProps} = useDroppableItem(props, state, ref);\n let id = useId();\n let getText = (key: Key) => collection.getTextValue?.(key) ?? collection.getItem(key)?.textValue;\n\n let label = '';\n let labelledBy: string;\n if (target.type === 'root') {\n label = stringFormatter.format('dropOnRoot');\n labelledBy = `${id} ${getDroppableCollectionId(state)}`;\n } else if (target.dropPosition === 'on') {\n label = stringFormatter.format('dropOnItem', {\n itemText: getText(target.key)\n });\n } else {\n let before: Key | null;\n let after: Key | null;\n if (collection.getFirstKey() === target.key && target.dropPosition === 'before') {\n before = null;\n } else {\n before = target.dropPosition === 'before' ? collection.getKeyBefore(target.key) : target.key;\n }\n\n if (collection.getLastKey() === target.key && target.dropPosition === 'after') {\n after = null;\n } else {\n after = target.dropPosition === 'after' ? collection.getKeyAfter(target.key) : target.key;\n }\n\n if (before && after) {\n label = stringFormatter.format('insertBetween', {\n beforeItemText: getText(before),\n afterItemText: getText(after)\n });\n } else if (before) {\n label = stringFormatter.format('insertAfter', {\n itemText: getText(before)\n });\n } else if (after) {\n label = stringFormatter.format('insertBefore', {\n itemText: getText(after)\n });\n }\n }\n\n let isDropTarget = state.isDropTarget(target);\n let ariaHidden = !dragSession ? 'true' : dropProps['aria-hidden'];\n return {\n dropIndicatorProps: {\n ...dropProps,\n id,\n 'aria-roledescription': stringFormatter.format('dropIndicator'),\n 'aria-label': label,\n 'aria-labelledby': labelledBy,\n 'aria-hidden': ariaHidden,\n tabIndex: -1\n },\n isDropTarget,\n // If aria-hidden, we are either not in a drag session or the drop target is invalid.\n // In that case, there's no need to render anything at all unless we need to show the indicator visually.\n // This can happen when dragging using the native DnD API as opposed to keyboard dragging.\n isHidden: !isDropTarget && !!ariaHidden\n };\n}\n"],"names":[],"version":3,"file":"useDropIndicator.module.js.map"}
|