svelte-dnd-action 0.9.8 → 0.9.12
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/README.md +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +30 -4
- package/dist/index.mjs +30 -4
- package/package.json +1 -1
- package/src/action.js +9 -0
- package/src/keyboardAction.js +11 -4
- package/src/pointerAction.js +5 -2
package/README.md
CHANGED
|
@@ -111,6 +111,7 @@ An options-object with the following attributes:
|
|
|
111
111
|
| `dragDisabled` | Boolean | No | `false` | Setting it to true will make it impossible to drag elements out of the dnd-zone. You can change it at any time, and the zone will adjust on the fly |
|
|
112
112
|
| `morphDisabled` | Boolean | No | `false` | By default, when dragging over a zone, the dragged element is morphed to look like it would if dropped. You can prevent it by setting this option. |
|
|
113
113
|
| `dropFromOthersDisabled` | Boolean | No | `false` | Setting it to true will make it impossible to drop elements from other dnd-zones of the same type. Can be useful if you want to limit the max number of items for example. You can change it at any time, and the zone will adjust on the fly |
|
|
114
|
+
| `zoneTabIndex` | Number | No | `0` | Allow user to set custom tabindex to the list container when not dragging. Can be useful if you want to make the screen reader to skip the list container. You can change it at any time. |
|
|
114
115
|
| `dropTargetStyle` | Object<String> | No | `{outline: 'rgba(255, 255, 102, 0.7) solid 2px'}` | An object of styles to apply to the dnd-zone when items can be dragged into it. Note: the styles override any inline styles applied to the dnd-zone. When the styles are removed, any original inline styles will be lost |
|
|
115
116
|
| `dropTargetClasses`| Array<String> | No | `[]` | A list of classes to apply to the dnd-zone when items can be dragged into it. Note: make sure the classes you use are global. |
|
|
116
117
|
| `transformDraggedElement` | Function | No | `() => {}` | A function that is invoked when the draggable element enters the dnd-zone or hover overs a new index in the current dnd-zone. <br />Signature:<br />function(element, data, index) {}<br />**element**: The dragged element. <br />**data**: The data of the item from the items array.<br />**index**: The index the dragged element will become in the new dnd-zone.<br /><br />This allows you to override properties on the dragged element, such as innerHTML to change how it displays. If what you are after is altering styles, do it to the children, not to the dragged element itself |
|
|
@@ -188,6 +189,7 @@ If you want to implement your own custom screen-reader alerts, roles and instruc
|
|
|
188
189
|
- [Generic List Component (Alternative to Slots)](https://svelte.dev/repl/028674733f67409c94bd52995d5906f1?version=3.31.0)
|
|
189
190
|
- [Maitaining internal scroll poisition on scrollable dragabble](https://svelte.dev/repl/eb2f5988bd2f46488810606c1fb13392?version=3.29.4)
|
|
190
191
|
- [Scrabble like board using over a 100 single slot dnd-zones](https://svelte.dev/repl/ed2e138417094281be6db1aef23d7859?version=3.37.0)
|
|
192
|
+
- [Select multiple elements to drag (multi-drag) with mouse or keyboard](https://svelte.dev/repl/c4eb917bb8df42c4b17402a7dda54856?version=3.24.1)
|
|
191
193
|
|
|
192
194
|
- [Fade in/out but without using Svelte transitions](https://svelte.dev/repl/3f1e68203ef140969a8240eba3475a8d?version=3.24.1)
|
|
193
195
|
- [Nested fade in/out without using Svelte transitions](https://svelte.dev/repl/49b09aedfe0543b4bc8f575c8dbf9a53?version=3.24.1)
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export interface Options {
|
|
|
26
26
|
dragDisabled?: boolean;
|
|
27
27
|
morphDisabled?: boolean;
|
|
28
28
|
dropFromOthersDisabled?: boolean;
|
|
29
|
+
zoneTabIndex?: number; // set the tabindex of the list container when not dragging
|
|
29
30
|
dropTargetClasses?: [string];
|
|
30
31
|
dropTargetStyle?: Record<string, string>;
|
|
31
32
|
transformDraggedElement?: TransformDraggedElementFunction;
|
package/dist/index.js
CHANGED
|
@@ -1743,6 +1743,10 @@
|
|
|
1743
1743
|
var currentIdx = elToIdx.get(originalDragTarget);
|
|
1744
1744
|
originIndex = currentIdx;
|
|
1745
1745
|
originDropZone = originalDragTarget.parentElement;
|
|
1746
|
+
/** @type {ShadowRoot | HTMLDocument} */
|
|
1747
|
+
|
|
1748
|
+
var rootNode = originDropZone.getRootNode();
|
|
1749
|
+
var originDropZoneRoot = rootNode.body || rootNode;
|
|
1746
1750
|
var items = config.items,
|
|
1747
1751
|
type = config.type,
|
|
1748
1752
|
centreDraggedOnCursor = config.centreDraggedOnCursor;
|
|
@@ -1757,12 +1761,12 @@
|
|
|
1757
1761
|
|
|
1758
1762
|
function keepOriginalElementInDom() {
|
|
1759
1763
|
if (!draggedEl.parentElement) {
|
|
1760
|
-
|
|
1764
|
+
originDropZoneRoot.appendChild(draggedEl); // to prevent the outline from disappearing
|
|
1761
1765
|
|
|
1762
1766
|
draggedEl.focus();
|
|
1763
1767
|
watchDraggedElement();
|
|
1764
1768
|
hideOriginalDragTarget(originalDragTarget);
|
|
1765
|
-
|
|
1769
|
+
originDropZoneRoot.appendChild(originalDragTarget);
|
|
1766
1770
|
} else {
|
|
1767
1771
|
window.requestAnimationFrame(keepOriginalElementInDom);
|
|
1768
1772
|
}
|
|
@@ -2203,6 +2207,7 @@
|
|
|
2203
2207
|
items: undefined,
|
|
2204
2208
|
type: undefined,
|
|
2205
2209
|
dragDisabled: false,
|
|
2210
|
+
zoneTabIndex: 0,
|
|
2206
2211
|
dropFromOthersDisabled: false,
|
|
2207
2212
|
dropTargetStyle: DEFAULT_DROP_TARGET_STYLE$1,
|
|
2208
2213
|
dropTargetClasses: [],
|
|
@@ -2375,6 +2380,8 @@
|
|
|
2375
2380
|
newType = _ref2$type === void 0 ? DEFAULT_DROP_ZONE_TYPE$1 : _ref2$type,
|
|
2376
2381
|
_ref2$dragDisabled = _ref2.dragDisabled,
|
|
2377
2382
|
dragDisabled = _ref2$dragDisabled === void 0 ? false : _ref2$dragDisabled,
|
|
2383
|
+
_ref2$zoneTabIndex = _ref2.zoneTabIndex,
|
|
2384
|
+
zoneTabIndex = _ref2$zoneTabIndex === void 0 ? 0 : _ref2$zoneTabIndex,
|
|
2378
2385
|
_ref2$dropFromOthersD = _ref2.dropFromOthersDisabled,
|
|
2379
2386
|
dropFromOthersDisabled = _ref2$dropFromOthersD === void 0 ? false : _ref2$dropFromOthersD,
|
|
2380
2387
|
_ref2$dropTargetStyle = _ref2.dropTargetStyle,
|
|
@@ -2386,6 +2393,7 @@
|
|
|
2386
2393
|
config.items = _toConsumableArray(items);
|
|
2387
2394
|
config.dragDisabled = dragDisabled;
|
|
2388
2395
|
config.dropFromOthersDisabled = dropFromOthersDisabled;
|
|
2396
|
+
config.zoneTabIndex = zoneTabIndex;
|
|
2389
2397
|
config.dropTargetStyle = dropTargetStyle;
|
|
2390
2398
|
config.dropTargetClasses = dropTargetClasses;
|
|
2391
2399
|
config.autoAriaDisabled = autoAriaDisabled;
|
|
@@ -2403,7 +2411,13 @@
|
|
|
2403
2411
|
config.type = newType;
|
|
2404
2412
|
registerDropZone$1(node, newType);
|
|
2405
2413
|
dzToConfig$1.set(node, config);
|
|
2406
|
-
|
|
2414
|
+
|
|
2415
|
+
if (isDragging) {
|
|
2416
|
+
node.tabIndex = node === focusedDz || focusedItem.contains(node) || config.dropFromOthersDisabled || focusedDz && config.type !== dzToConfig$1.get(focusedDz).type ? -1 : 0;
|
|
2417
|
+
} else {
|
|
2418
|
+
node.tabIndex = config.zoneTabIndex;
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2407
2421
|
node.addEventListener("focus", handleZoneFocus);
|
|
2408
2422
|
|
|
2409
2423
|
var _loop = function _loop(i) {
|
|
@@ -2479,6 +2493,7 @@
|
|
|
2479
2493
|
* @property {boolean} [dragDisabled]
|
|
2480
2494
|
* @property {boolean} [morphDisabled] - whether dragged element should morph to zone dimensions
|
|
2481
2495
|
* @property {boolean} [dropFromOthersDisabled]
|
|
2496
|
+
* @property {number} [zoneTabIndex] - set the tabindex of the list container when not dragging
|
|
2482
2497
|
* @property {object} [dropTargetStyle]
|
|
2483
2498
|
* @property {string[]} [dropTargetClasses]
|
|
2484
2499
|
* @property {function} [transformDraggedElement]
|
|
@@ -2512,12 +2527,13 @@
|
|
|
2512
2527
|
dragDisabled = options.dragDisabled,
|
|
2513
2528
|
morphDisabled = options.morphDisabled,
|
|
2514
2529
|
dropFromOthersDisabled = options.dropFromOthersDisabled,
|
|
2530
|
+
zoneTabIndex = options.zoneTabIndex,
|
|
2515
2531
|
dropTargetStyle = options.dropTargetStyle,
|
|
2516
2532
|
dropTargetClasses = options.dropTargetClasses,
|
|
2517
2533
|
transformDraggedElement = options.transformDraggedElement,
|
|
2518
2534
|
autoAriaDisabled = options.autoAriaDisabled,
|
|
2519
2535
|
centreDraggedOnCursor = options.centreDraggedOnCursor,
|
|
2520
|
-
rest = _objectWithoutProperties(options, ["items", "flipDurationMs", "type", "dragDisabled", "morphDisabled", "dropFromOthersDisabled", "dropTargetStyle", "dropTargetClasses", "transformDraggedElement", "autoAriaDisabled", "centreDraggedOnCursor"]);
|
|
2536
|
+
rest = _objectWithoutProperties(options, ["items", "flipDurationMs", "type", "dragDisabled", "morphDisabled", "dropFromOthersDisabled", "zoneTabIndex", "dropTargetStyle", "dropTargetClasses", "transformDraggedElement", "autoAriaDisabled", "centreDraggedOnCursor"]);
|
|
2521
2537
|
/*eslint-enable*/
|
|
2522
2538
|
|
|
2523
2539
|
|
|
@@ -2540,6 +2556,16 @@
|
|
|
2540
2556
|
if (dropTargetClasses && !Array.isArray(dropTargetClasses)) {
|
|
2541
2557
|
throw new Error("dropTargetClasses should be an array but instead it is a ".concat(_typeof(dropTargetClasses), ", ").concat(toString(dropTargetClasses)));
|
|
2542
2558
|
}
|
|
2559
|
+
|
|
2560
|
+
if (zoneTabIndex && !isInt(zoneTabIndex)) {
|
|
2561
|
+
throw new Error("zoneTabIndex should be a number but instead it is a ".concat(_typeof(zoneTabIndex), ", ").concat(toString(zoneTabIndex)));
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
function isInt(value) {
|
|
2566
|
+
return !isNaN(value) && function (x) {
|
|
2567
|
+
return (x | 0) === x;
|
|
2568
|
+
}(parseFloat(value));
|
|
2543
2569
|
}
|
|
2544
2570
|
|
|
2545
2571
|
exports.DRAGGED_ELEMENT_ID = DRAGGED_ELEMENT_ID;
|
package/dist/index.mjs
CHANGED
|
@@ -1737,6 +1737,10 @@ function dndzone(node, options) {
|
|
|
1737
1737
|
var currentIdx = elToIdx.get(originalDragTarget);
|
|
1738
1738
|
originIndex = currentIdx;
|
|
1739
1739
|
originDropZone = originalDragTarget.parentElement;
|
|
1740
|
+
/** @type {ShadowRoot | HTMLDocument} */
|
|
1741
|
+
|
|
1742
|
+
var rootNode = originDropZone.getRootNode();
|
|
1743
|
+
var originDropZoneRoot = rootNode.body || rootNode;
|
|
1740
1744
|
var items = config.items,
|
|
1741
1745
|
type = config.type,
|
|
1742
1746
|
centreDraggedOnCursor = config.centreDraggedOnCursor;
|
|
@@ -1751,12 +1755,12 @@ function dndzone(node, options) {
|
|
|
1751
1755
|
|
|
1752
1756
|
function keepOriginalElementInDom() {
|
|
1753
1757
|
if (!draggedEl.parentElement) {
|
|
1754
|
-
|
|
1758
|
+
originDropZoneRoot.appendChild(draggedEl); // to prevent the outline from disappearing
|
|
1755
1759
|
|
|
1756
1760
|
draggedEl.focus();
|
|
1757
1761
|
watchDraggedElement();
|
|
1758
1762
|
hideOriginalDragTarget(originalDragTarget);
|
|
1759
|
-
|
|
1763
|
+
originDropZoneRoot.appendChild(originalDragTarget);
|
|
1760
1764
|
} else {
|
|
1761
1765
|
window.requestAnimationFrame(keepOriginalElementInDom);
|
|
1762
1766
|
}
|
|
@@ -2197,6 +2201,7 @@ function dndzone$1(node, options) {
|
|
|
2197
2201
|
items: undefined,
|
|
2198
2202
|
type: undefined,
|
|
2199
2203
|
dragDisabled: false,
|
|
2204
|
+
zoneTabIndex: 0,
|
|
2200
2205
|
dropFromOthersDisabled: false,
|
|
2201
2206
|
dropTargetStyle: DEFAULT_DROP_TARGET_STYLE$1,
|
|
2202
2207
|
dropTargetClasses: [],
|
|
@@ -2369,6 +2374,8 @@ function dndzone$1(node, options) {
|
|
|
2369
2374
|
newType = _ref2$type === void 0 ? DEFAULT_DROP_ZONE_TYPE$1 : _ref2$type,
|
|
2370
2375
|
_ref2$dragDisabled = _ref2.dragDisabled,
|
|
2371
2376
|
dragDisabled = _ref2$dragDisabled === void 0 ? false : _ref2$dragDisabled,
|
|
2377
|
+
_ref2$zoneTabIndex = _ref2.zoneTabIndex,
|
|
2378
|
+
zoneTabIndex = _ref2$zoneTabIndex === void 0 ? 0 : _ref2$zoneTabIndex,
|
|
2372
2379
|
_ref2$dropFromOthersD = _ref2.dropFromOthersDisabled,
|
|
2373
2380
|
dropFromOthersDisabled = _ref2$dropFromOthersD === void 0 ? false : _ref2$dropFromOthersD,
|
|
2374
2381
|
_ref2$dropTargetStyle = _ref2.dropTargetStyle,
|
|
@@ -2380,6 +2387,7 @@ function dndzone$1(node, options) {
|
|
|
2380
2387
|
config.items = _toConsumableArray(items);
|
|
2381
2388
|
config.dragDisabled = dragDisabled;
|
|
2382
2389
|
config.dropFromOthersDisabled = dropFromOthersDisabled;
|
|
2390
|
+
config.zoneTabIndex = zoneTabIndex;
|
|
2383
2391
|
config.dropTargetStyle = dropTargetStyle;
|
|
2384
2392
|
config.dropTargetClasses = dropTargetClasses;
|
|
2385
2393
|
config.autoAriaDisabled = autoAriaDisabled;
|
|
@@ -2397,7 +2405,13 @@ function dndzone$1(node, options) {
|
|
|
2397
2405
|
config.type = newType;
|
|
2398
2406
|
registerDropZone$1(node, newType);
|
|
2399
2407
|
dzToConfig$1.set(node, config);
|
|
2400
|
-
|
|
2408
|
+
|
|
2409
|
+
if (isDragging) {
|
|
2410
|
+
node.tabIndex = node === focusedDz || focusedItem.contains(node) || config.dropFromOthersDisabled || focusedDz && config.type !== dzToConfig$1.get(focusedDz).type ? -1 : 0;
|
|
2411
|
+
} else {
|
|
2412
|
+
node.tabIndex = config.zoneTabIndex;
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2401
2415
|
node.addEventListener("focus", handleZoneFocus);
|
|
2402
2416
|
|
|
2403
2417
|
var _loop = function _loop(i) {
|
|
@@ -2473,6 +2487,7 @@ function dndzone$1(node, options) {
|
|
|
2473
2487
|
* @property {boolean} [dragDisabled]
|
|
2474
2488
|
* @property {boolean} [morphDisabled] - whether dragged element should morph to zone dimensions
|
|
2475
2489
|
* @property {boolean} [dropFromOthersDisabled]
|
|
2490
|
+
* @property {number} [zoneTabIndex] - set the tabindex of the list container when not dragging
|
|
2476
2491
|
* @property {object} [dropTargetStyle]
|
|
2477
2492
|
* @property {string[]} [dropTargetClasses]
|
|
2478
2493
|
* @property {function} [transformDraggedElement]
|
|
@@ -2506,12 +2521,13 @@ function validateOptions(options) {
|
|
|
2506
2521
|
dragDisabled = options.dragDisabled,
|
|
2507
2522
|
morphDisabled = options.morphDisabled,
|
|
2508
2523
|
dropFromOthersDisabled = options.dropFromOthersDisabled,
|
|
2524
|
+
zoneTabIndex = options.zoneTabIndex,
|
|
2509
2525
|
dropTargetStyle = options.dropTargetStyle,
|
|
2510
2526
|
dropTargetClasses = options.dropTargetClasses,
|
|
2511
2527
|
transformDraggedElement = options.transformDraggedElement,
|
|
2512
2528
|
autoAriaDisabled = options.autoAriaDisabled,
|
|
2513
2529
|
centreDraggedOnCursor = options.centreDraggedOnCursor,
|
|
2514
|
-
rest = _objectWithoutProperties(options, ["items", "flipDurationMs", "type", "dragDisabled", "morphDisabled", "dropFromOthersDisabled", "dropTargetStyle", "dropTargetClasses", "transformDraggedElement", "autoAriaDisabled", "centreDraggedOnCursor"]);
|
|
2530
|
+
rest = _objectWithoutProperties(options, ["items", "flipDurationMs", "type", "dragDisabled", "morphDisabled", "dropFromOthersDisabled", "zoneTabIndex", "dropTargetStyle", "dropTargetClasses", "transformDraggedElement", "autoAriaDisabled", "centreDraggedOnCursor"]);
|
|
2515
2531
|
/*eslint-enable*/
|
|
2516
2532
|
|
|
2517
2533
|
|
|
@@ -2534,6 +2550,16 @@ function validateOptions(options) {
|
|
|
2534
2550
|
if (dropTargetClasses && !Array.isArray(dropTargetClasses)) {
|
|
2535
2551
|
throw new Error("dropTargetClasses should be an array but instead it is a ".concat(_typeof(dropTargetClasses), ", ").concat(toString(dropTargetClasses)));
|
|
2536
2552
|
}
|
|
2553
|
+
|
|
2554
|
+
if (zoneTabIndex && !isInt(zoneTabIndex)) {
|
|
2555
|
+
throw new Error("zoneTabIndex should be a number but instead it is a ".concat(_typeof(zoneTabIndex), ", ").concat(toString(zoneTabIndex)));
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
function isInt(value) {
|
|
2560
|
+
return !isNaN(value) && function (x) {
|
|
2561
|
+
return (x | 0) === x;
|
|
2562
|
+
}(parseFloat(value));
|
|
2537
2563
|
}
|
|
2538
2564
|
|
|
2539
2565
|
export { DRAGGED_ELEMENT_ID, SHADOW_ITEM_MARKER_PROPERTY_NAME, SHADOW_PLACEHOLDER_ITEM_ID, SOURCES, TRIGGERS, alertToScreenReader, dndzone$2 as dndzone, overrideItemIdKeyNameBeforeInitialisingDndZones, setDebugMode };
|
package/package.json
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dist"
|
|
41
41
|
],
|
|
42
42
|
"description": "*An awesome drag and drop library for Svelte 3 (not using the browser's built-in dnd, thanks god): Rich animations, nested containers, touch support and more *",
|
|
43
|
-
"version": "0.9.
|
|
43
|
+
"version": "0.9.12",
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|
|
46
46
|
"url": "git+https://github.com/isaacHagoel/svelte-dnd-action.git"
|
package/src/action.js
CHANGED
|
@@ -16,6 +16,7 @@ import {toString} from "./helpers/util";
|
|
|
16
16
|
* @property {boolean} [dragDisabled]
|
|
17
17
|
* @property {boolean} [morphDisabled] - whether dragged element should morph to zone dimensions
|
|
18
18
|
* @property {boolean} [dropFromOthersDisabled]
|
|
19
|
+
* @property {number} [zoneTabIndex] - set the tabindex of the list container when not dragging
|
|
19
20
|
* @property {object} [dropTargetStyle]
|
|
20
21
|
* @property {string[]} [dropTargetClasses]
|
|
21
22
|
* @property {function} [transformDraggedElement]
|
|
@@ -49,6 +50,7 @@ function validateOptions(options) {
|
|
|
49
50
|
dragDisabled,
|
|
50
51
|
morphDisabled,
|
|
51
52
|
dropFromOthersDisabled,
|
|
53
|
+
zoneTabIndex,
|
|
52
54
|
dropTargetStyle,
|
|
53
55
|
dropTargetClasses,
|
|
54
56
|
transformDraggedElement,
|
|
@@ -70,4 +72,11 @@ function validateOptions(options) {
|
|
|
70
72
|
if (dropTargetClasses && !Array.isArray(dropTargetClasses)) {
|
|
71
73
|
throw new Error(`dropTargetClasses should be an array but instead it is a ${typeof dropTargetClasses}, ${toString(dropTargetClasses)}`);
|
|
72
74
|
}
|
|
75
|
+
if (zoneTabIndex && !isInt(zoneTabIndex)) {
|
|
76
|
+
throw new Error(`zoneTabIndex should be a number but instead it is a ${typeof zoneTabIndex}, ${toString(zoneTabIndex)}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function isInt(value) {
|
|
81
|
+
return !isNaN(value) && (function(x) { return (x | 0) === x; })(parseFloat(value));
|
|
73
82
|
}
|
package/src/keyboardAction.js
CHANGED
|
@@ -153,6 +153,7 @@ export function dndzone(node, options) {
|
|
|
153
153
|
items: undefined,
|
|
154
154
|
type: undefined,
|
|
155
155
|
dragDisabled: false,
|
|
156
|
+
zoneTabIndex: 0,
|
|
156
157
|
dropFromOthersDisabled: false,
|
|
157
158
|
dropTargetStyle: DEFAULT_DROP_TARGET_STYLE,
|
|
158
159
|
dropTargetClasses: [],
|
|
@@ -266,6 +267,7 @@ export function dndzone(node, options) {
|
|
|
266
267
|
items = [],
|
|
267
268
|
type: newType = DEFAULT_DROP_ZONE_TYPE,
|
|
268
269
|
dragDisabled = false,
|
|
270
|
+
zoneTabIndex = 0,
|
|
269
271
|
dropFromOthersDisabled = false,
|
|
270
272
|
dropTargetStyle = DEFAULT_DROP_TARGET_STYLE,
|
|
271
273
|
dropTargetClasses = [],
|
|
@@ -274,6 +276,7 @@ export function dndzone(node, options) {
|
|
|
274
276
|
config.items = [...items];
|
|
275
277
|
config.dragDisabled = dragDisabled;
|
|
276
278
|
config.dropFromOthersDisabled = dropFromOthersDisabled;
|
|
279
|
+
config.zoneTabIndex = zoneTabIndex;
|
|
277
280
|
config.dropTargetStyle = dropTargetStyle;
|
|
278
281
|
config.dropTargetClasses = dropTargetClasses;
|
|
279
282
|
config.autoAriaDisabled = autoAriaDisabled;
|
|
@@ -289,14 +292,18 @@ export function dndzone(node, options) {
|
|
|
289
292
|
registerDropZone(node, newType);
|
|
290
293
|
dzToConfig.set(node, config);
|
|
291
294
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
+
if (isDragging) {
|
|
296
|
+
node.tabIndex =
|
|
297
|
+
node === focusedDz ||
|
|
295
298
|
focusedItem.contains(node) ||
|
|
296
299
|
config.dropFromOthersDisabled ||
|
|
297
|
-
(focusedDz && config.type !== dzToConfig.get(focusedDz).type)
|
|
300
|
+
(focusedDz && config.type !== dzToConfig.get(focusedDz).type)
|
|
298
301
|
? -1
|
|
299
302
|
: 0;
|
|
303
|
+
} else {
|
|
304
|
+
node.tabIndex = config.zoneTabIndex;
|
|
305
|
+
}
|
|
306
|
+
|
|
300
307
|
node.addEventListener("focus", handleZoneFocus);
|
|
301
308
|
|
|
302
309
|
for (let i = 0; i < node.children.length; i++) {
|
package/src/pointerAction.js
CHANGED
|
@@ -378,6 +378,9 @@ export function dndzone(node, options) {
|
|
|
378
378
|
const currentIdx = elToIdx.get(originalDragTarget);
|
|
379
379
|
originIndex = currentIdx;
|
|
380
380
|
originDropZone = originalDragTarget.parentElement;
|
|
381
|
+
/** @type {ShadowRoot | HTMLDocument} */
|
|
382
|
+
const rootNode = originDropZone.getRootNode();
|
|
383
|
+
const originDropZoneRoot = rootNode.body || rootNode;
|
|
381
384
|
const {items, type, centreDraggedOnCursor} = config;
|
|
382
385
|
draggedElData = {...items[currentIdx]};
|
|
383
386
|
draggedElType = type;
|
|
@@ -390,12 +393,12 @@ export function dndzone(node, options) {
|
|
|
390
393
|
// We will keep the original dom node in the dom because touch events keep firing on it, we want to re-add it after the framework removes it
|
|
391
394
|
function keepOriginalElementInDom() {
|
|
392
395
|
if (!draggedEl.parentElement) {
|
|
393
|
-
|
|
396
|
+
originDropZoneRoot.appendChild(draggedEl);
|
|
394
397
|
// to prevent the outline from disappearing
|
|
395
398
|
draggedEl.focus();
|
|
396
399
|
watchDraggedElement();
|
|
397
400
|
hideOriginalDragTarget(originalDragTarget);
|
|
398
|
-
|
|
401
|
+
originDropZoneRoot.appendChild(originalDragTarget);
|
|
399
402
|
} else {
|
|
400
403
|
window.requestAnimationFrame(keepOriginalElementInDom);
|
|
401
404
|
}
|