svelte-dnd-action 0.9.29 → 0.9.31
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 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -6
- package/dist/index.mjs +17 -6
- package/package.json +1 -1
- package/src/action.js +5 -0
- package/src/keyboardAction.js +6 -3
- package/src/pointerAction.js +3 -4
package/README.md
CHANGED
|
@@ -106,12 +106,13 @@ An options-object with the following attributes:
|
|
|
106
106
|
| Name | Type | Required? | Default Value | Description |
|
|
107
107
|
| ------------------------- | -------------- | ------------------------------------------------------------ | ------------------------------------------------- | ------------------------------------------------------------ |
|
|
108
108
|
| `items` | Array<Object> | Yes. Each object in the array **has to have** an `id` property (key name can be overridden globally) with a unique value (within all dnd-zones of the same type) | N/A | The data array that is used to produce the list with the draggable items (the same thing you run your #each block on). The dndzone should not have children that don't originate in `items` |
|
|
109
|
-
| `flipDurationMs` | Number | No | `0` | The same value you give the flip animation on the items (to make them animated as they "make space" for the dragged item). Set to zero
|
|
109
|
+
| `flipDurationMs` | Number | No | `0` | The same value you give the flip animation on the items (to make them animated as they "make space" for the dragged item). Set to zero if you dont want animations, if unset it defaults to 100ms |
|
|
110
110
|
| `type` | String | No | Internal | dnd-zones that share the same type can have elements from one dragged into another. By default, all dnd-zones have the same type |
|
|
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
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. |
|
|
115
|
+
| `zoneItemTabIndex` | Number | No | `0` | Allow user to set custom tabindex to the list container items when not dragging. Can be useful if you use [Drag handles](https://github.com/isaacHagoel/svelte-dnd-action#examples-and-recipes). You can change it at any time. |
|
|
115
116
|
| `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 |
|
|
116
117
|
| `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. |
|
|
117
118
|
| `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 |
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export interface Options {
|
|
|
27
27
|
morphDisabled?: boolean;
|
|
28
28
|
dropFromOthersDisabled?: boolean;
|
|
29
29
|
zoneTabIndex?: number; // set the tabindex of the list container when not dragging
|
|
30
|
+
zoneItemTabIndex?: number; // set the tabindex of the list container items when not dragging
|
|
30
31
|
dropTargetClasses?: string[];
|
|
31
32
|
dropTargetStyle?: Record<string, string>;
|
|
32
33
|
transformDraggedElement?: TransformDraggedElementFunction;
|
package/dist/index.js
CHANGED
|
@@ -1226,6 +1226,7 @@
|
|
|
1226
1226
|
|
|
1227
1227
|
var DEFAULT_DROP_ZONE_TYPE = "--any--";
|
|
1228
1228
|
var MIN_OBSERVATION_INTERVAL_MS = 100;
|
|
1229
|
+
var DISABLED_OBSERVATION_INTERVAL_MS = 20;
|
|
1229
1230
|
var MIN_MOVEMENT_BEFORE_DRAG_START_PX = 3;
|
|
1230
1231
|
var DEFAULT_DROP_TARGET_STYLE = {
|
|
1231
1232
|
outline: "rgba(255, 255, 102, 0.7) solid 2px"
|
|
@@ -1298,9 +1299,10 @@
|
|
|
1298
1299
|
}
|
|
1299
1300
|
window.addEventListener(DRAGGED_LEFT_DOCUMENT_EVENT_NAME, handleDrop);
|
|
1300
1301
|
// it is important that we don't have an interval that is faster than the flip duration because it can cause elements to jump bach and forth
|
|
1301
|
-
var
|
|
1302
|
+
var setIntervalMs = Math.max.apply(Math, _toConsumableArray(Array.from(dropZones.keys()).map(function (dz) {
|
|
1302
1303
|
return dzToConfig.get(dz).dropAnimationDurationMs;
|
|
1303
|
-
})))
|
|
1304
|
+
})));
|
|
1305
|
+
var observationIntervalMs = setIntervalMs === 0 ? DISABLED_OBSERVATION_INTERVAL_MS : Math.max(setIntervalMs, MIN_OBSERVATION_INTERVAL_MS); //if setintervalms is 0 it goes to 20, otherwise it is max between it and min observation.
|
|
1304
1306
|
observe(draggedEl, dropZones, observationIntervalMs * 1.07);
|
|
1305
1307
|
}
|
|
1306
1308
|
function unWatchDraggedElement() {
|
|
@@ -2116,6 +2118,7 @@
|
|
|
2116
2118
|
type: undefined,
|
|
2117
2119
|
dragDisabled: false,
|
|
2118
2120
|
zoneTabIndex: 0,
|
|
2121
|
+
zoneItemTabIndex: 0,
|
|
2119
2122
|
dropFromOthersDisabled: false,
|
|
2120
2123
|
dropTargetStyle: DEFAULT_DROP_TARGET_STYLE$1,
|
|
2121
2124
|
dropTargetClasses: [],
|
|
@@ -2245,7 +2248,7 @@
|
|
|
2245
2248
|
var children = Array.from(node.children);
|
|
2246
2249
|
var focusedItemIdx = children.indexOf(draggableEl);
|
|
2247
2250
|
focusedItem = draggableEl;
|
|
2248
|
-
focusedItem.tabIndex =
|
|
2251
|
+
focusedItem.tabIndex = config.zoneItemTabIndex;
|
|
2249
2252
|
focusedItemId = items[focusedItemIdx][ITEM_ID_KEY];
|
|
2250
2253
|
focusedItemLabel = children[focusedItemIdx].getAttribute("aria-label") || "";
|
|
2251
2254
|
}
|
|
@@ -2258,6 +2261,8 @@
|
|
|
2258
2261
|
dragDisabled = _ref2$dragDisabled === void 0 ? false : _ref2$dragDisabled,
|
|
2259
2262
|
_ref2$zoneTabIndex = _ref2.zoneTabIndex,
|
|
2260
2263
|
zoneTabIndex = _ref2$zoneTabIndex === void 0 ? 0 : _ref2$zoneTabIndex,
|
|
2264
|
+
_ref2$zoneItemTabInde = _ref2.zoneItemTabIndex,
|
|
2265
|
+
zoneItemTabIndex = _ref2$zoneItemTabInde === void 0 ? 0 : _ref2$zoneItemTabInde,
|
|
2261
2266
|
_ref2$dropFromOthersD = _ref2.dropFromOthersDisabled,
|
|
2262
2267
|
dropFromOthersDisabled = _ref2$dropFromOthersD === void 0 ? false : _ref2$dropFromOthersD,
|
|
2263
2268
|
_ref2$dropTargetStyle = _ref2.dropTargetStyle,
|
|
@@ -2270,6 +2275,7 @@
|
|
|
2270
2275
|
config.dragDisabled = dragDisabled;
|
|
2271
2276
|
config.dropFromOthersDisabled = dropFromOthersDisabled;
|
|
2272
2277
|
config.zoneTabIndex = zoneTabIndex;
|
|
2278
|
+
config.zoneItemTabIndex = zoneItemTabIndex;
|
|
2273
2279
|
config.dropTargetStyle = dropTargetStyle;
|
|
2274
2280
|
config.dropTargetClasses = dropTargetClasses;
|
|
2275
2281
|
config.autoAriaDisabled = autoAriaDisabled;
|
|
@@ -2293,7 +2299,7 @@
|
|
|
2293
2299
|
var _loop = function _loop(i) {
|
|
2294
2300
|
var draggableEl = node.children[i];
|
|
2295
2301
|
allDragTargets.add(draggableEl);
|
|
2296
|
-
draggableEl.tabIndex = isDragging ? -1 :
|
|
2302
|
+
draggableEl.tabIndex = isDragging ? -1 : config.zoneItemTabIndex;
|
|
2297
2303
|
if (!autoAriaDisabled) {
|
|
2298
2304
|
draggableEl.setAttribute("role", "listitem");
|
|
2299
2305
|
}
|
|
@@ -2314,7 +2320,7 @@
|
|
|
2314
2320
|
});
|
|
2315
2321
|
// if it is a nested dropzone, it was re-rendered and we need to refresh our pointer
|
|
2316
2322
|
focusedItem = draggableEl;
|
|
2317
|
-
focusedItem.tabIndex =
|
|
2323
|
+
focusedItem.tabIndex = config.zoneItemTabIndex;
|
|
2318
2324
|
// without this the element loses focus if it moves backwards in the list
|
|
2319
2325
|
draggableEl.focus();
|
|
2320
2326
|
}
|
|
@@ -2344,7 +2350,7 @@
|
|
|
2344
2350
|
return handles;
|
|
2345
2351
|
}
|
|
2346
2352
|
|
|
2347
|
-
var _excluded = ["items", "flipDurationMs", "type", "dragDisabled", "morphDisabled", "dropFromOthersDisabled", "zoneTabIndex", "dropTargetStyle", "dropTargetClasses", "transformDraggedElement", "autoAriaDisabled", "centreDraggedOnCursor"];
|
|
2353
|
+
var _excluded = ["items", "flipDurationMs", "type", "dragDisabled", "morphDisabled", "dropFromOthersDisabled", "zoneTabIndex", "zoneItemTabIndex", "dropTargetStyle", "dropTargetClasses", "transformDraggedElement", "autoAriaDisabled", "centreDraggedOnCursor"];
|
|
2348
2354
|
|
|
2349
2355
|
/**
|
|
2350
2356
|
* A custom action to turn any container to a dnd zone and all of its direct children to draggables
|
|
@@ -2360,6 +2366,7 @@
|
|
|
2360
2366
|
* @property {boolean} [morphDisabled] - whether dragged element should morph to zone dimensions
|
|
2361
2367
|
* @property {boolean} [dropFromOthersDisabled]
|
|
2362
2368
|
* @property {number} [zoneTabIndex] - set the tabindex of the list container when not dragging
|
|
2369
|
+
* @property {number} [zoneItemTabIndex] - set the tabindex of the list container items when not dragging
|
|
2363
2370
|
* @property {object} [dropTargetStyle]
|
|
2364
2371
|
* @property {string[]} [dropTargetClasses]
|
|
2365
2372
|
* @property {function} [transformDraggedElement]
|
|
@@ -2408,6 +2415,7 @@
|
|
|
2408
2415
|
morphDisabled = options.morphDisabled,
|
|
2409
2416
|
dropFromOthersDisabled = options.dropFromOthersDisabled,
|
|
2410
2417
|
zoneTabIndex = options.zoneTabIndex,
|
|
2418
|
+
zoneItemTabIndex = options.zoneItemTabIndex,
|
|
2411
2419
|
dropTargetStyle = options.dropTargetStyle,
|
|
2412
2420
|
dropTargetClasses = options.dropTargetClasses,
|
|
2413
2421
|
transformDraggedElement = options.transformDraggedElement,
|
|
@@ -2433,6 +2441,9 @@
|
|
|
2433
2441
|
if (zoneTabIndex && !isInt(zoneTabIndex)) {
|
|
2434
2442
|
throw new Error("zoneTabIndex should be a number but instead it is a ".concat(_typeof(zoneTabIndex), ", ").concat(toString(zoneTabIndex)));
|
|
2435
2443
|
}
|
|
2444
|
+
if (zoneItemTabIndex && !isInt(zoneItemTabIndex)) {
|
|
2445
|
+
throw new Error("zoneItemTabIndex should be a number but instead it is a ".concat(_typeof(zoneItemTabIndex), ", ").concat(toString(zoneItemTabIndex)));
|
|
2446
|
+
}
|
|
2436
2447
|
}
|
|
2437
2448
|
function isInt(value) {
|
|
2438
2449
|
return !isNaN(value) && function (x) {
|
package/dist/index.mjs
CHANGED
|
@@ -1220,6 +1220,7 @@ function preventShrinking(el) {
|
|
|
1220
1220
|
|
|
1221
1221
|
var DEFAULT_DROP_ZONE_TYPE = "--any--";
|
|
1222
1222
|
var MIN_OBSERVATION_INTERVAL_MS = 100;
|
|
1223
|
+
var DISABLED_OBSERVATION_INTERVAL_MS = 20;
|
|
1223
1224
|
var MIN_MOVEMENT_BEFORE_DRAG_START_PX = 3;
|
|
1224
1225
|
var DEFAULT_DROP_TARGET_STYLE = {
|
|
1225
1226
|
outline: "rgba(255, 255, 102, 0.7) solid 2px"
|
|
@@ -1292,9 +1293,10 @@ function watchDraggedElement() {
|
|
|
1292
1293
|
}
|
|
1293
1294
|
window.addEventListener(DRAGGED_LEFT_DOCUMENT_EVENT_NAME, handleDrop);
|
|
1294
1295
|
// it is important that we don't have an interval that is faster than the flip duration because it can cause elements to jump bach and forth
|
|
1295
|
-
var
|
|
1296
|
+
var setIntervalMs = Math.max.apply(Math, _toConsumableArray(Array.from(dropZones.keys()).map(function (dz) {
|
|
1296
1297
|
return dzToConfig.get(dz).dropAnimationDurationMs;
|
|
1297
|
-
})))
|
|
1298
|
+
})));
|
|
1299
|
+
var observationIntervalMs = setIntervalMs === 0 ? DISABLED_OBSERVATION_INTERVAL_MS : Math.max(setIntervalMs, MIN_OBSERVATION_INTERVAL_MS); //if setintervalms is 0 it goes to 20, otherwise it is max between it and min observation.
|
|
1298
1300
|
observe(draggedEl, dropZones, observationIntervalMs * 1.07);
|
|
1299
1301
|
}
|
|
1300
1302
|
function unWatchDraggedElement() {
|
|
@@ -2110,6 +2112,7 @@ function dndzone$1(node, options) {
|
|
|
2110
2112
|
type: undefined,
|
|
2111
2113
|
dragDisabled: false,
|
|
2112
2114
|
zoneTabIndex: 0,
|
|
2115
|
+
zoneItemTabIndex: 0,
|
|
2113
2116
|
dropFromOthersDisabled: false,
|
|
2114
2117
|
dropTargetStyle: DEFAULT_DROP_TARGET_STYLE$1,
|
|
2115
2118
|
dropTargetClasses: [],
|
|
@@ -2239,7 +2242,7 @@ function dndzone$1(node, options) {
|
|
|
2239
2242
|
var children = Array.from(node.children);
|
|
2240
2243
|
var focusedItemIdx = children.indexOf(draggableEl);
|
|
2241
2244
|
focusedItem = draggableEl;
|
|
2242
|
-
focusedItem.tabIndex =
|
|
2245
|
+
focusedItem.tabIndex = config.zoneItemTabIndex;
|
|
2243
2246
|
focusedItemId = items[focusedItemIdx][ITEM_ID_KEY];
|
|
2244
2247
|
focusedItemLabel = children[focusedItemIdx].getAttribute("aria-label") || "";
|
|
2245
2248
|
}
|
|
@@ -2252,6 +2255,8 @@ function dndzone$1(node, options) {
|
|
|
2252
2255
|
dragDisabled = _ref2$dragDisabled === void 0 ? false : _ref2$dragDisabled,
|
|
2253
2256
|
_ref2$zoneTabIndex = _ref2.zoneTabIndex,
|
|
2254
2257
|
zoneTabIndex = _ref2$zoneTabIndex === void 0 ? 0 : _ref2$zoneTabIndex,
|
|
2258
|
+
_ref2$zoneItemTabInde = _ref2.zoneItemTabIndex,
|
|
2259
|
+
zoneItemTabIndex = _ref2$zoneItemTabInde === void 0 ? 0 : _ref2$zoneItemTabInde,
|
|
2255
2260
|
_ref2$dropFromOthersD = _ref2.dropFromOthersDisabled,
|
|
2256
2261
|
dropFromOthersDisabled = _ref2$dropFromOthersD === void 0 ? false : _ref2$dropFromOthersD,
|
|
2257
2262
|
_ref2$dropTargetStyle = _ref2.dropTargetStyle,
|
|
@@ -2264,6 +2269,7 @@ function dndzone$1(node, options) {
|
|
|
2264
2269
|
config.dragDisabled = dragDisabled;
|
|
2265
2270
|
config.dropFromOthersDisabled = dropFromOthersDisabled;
|
|
2266
2271
|
config.zoneTabIndex = zoneTabIndex;
|
|
2272
|
+
config.zoneItemTabIndex = zoneItemTabIndex;
|
|
2267
2273
|
config.dropTargetStyle = dropTargetStyle;
|
|
2268
2274
|
config.dropTargetClasses = dropTargetClasses;
|
|
2269
2275
|
config.autoAriaDisabled = autoAriaDisabled;
|
|
@@ -2287,7 +2293,7 @@ function dndzone$1(node, options) {
|
|
|
2287
2293
|
var _loop = function _loop(i) {
|
|
2288
2294
|
var draggableEl = node.children[i];
|
|
2289
2295
|
allDragTargets.add(draggableEl);
|
|
2290
|
-
draggableEl.tabIndex = isDragging ? -1 :
|
|
2296
|
+
draggableEl.tabIndex = isDragging ? -1 : config.zoneItemTabIndex;
|
|
2291
2297
|
if (!autoAriaDisabled) {
|
|
2292
2298
|
draggableEl.setAttribute("role", "listitem");
|
|
2293
2299
|
}
|
|
@@ -2308,7 +2314,7 @@ function dndzone$1(node, options) {
|
|
|
2308
2314
|
});
|
|
2309
2315
|
// if it is a nested dropzone, it was re-rendered and we need to refresh our pointer
|
|
2310
2316
|
focusedItem = draggableEl;
|
|
2311
|
-
focusedItem.tabIndex =
|
|
2317
|
+
focusedItem.tabIndex = config.zoneItemTabIndex;
|
|
2312
2318
|
// without this the element loses focus if it moves backwards in the list
|
|
2313
2319
|
draggableEl.focus();
|
|
2314
2320
|
}
|
|
@@ -2338,7 +2344,7 @@ function dndzone$1(node, options) {
|
|
|
2338
2344
|
return handles;
|
|
2339
2345
|
}
|
|
2340
2346
|
|
|
2341
|
-
var _excluded = ["items", "flipDurationMs", "type", "dragDisabled", "morphDisabled", "dropFromOthersDisabled", "zoneTabIndex", "dropTargetStyle", "dropTargetClasses", "transformDraggedElement", "autoAriaDisabled", "centreDraggedOnCursor"];
|
|
2347
|
+
var _excluded = ["items", "flipDurationMs", "type", "dragDisabled", "morphDisabled", "dropFromOthersDisabled", "zoneTabIndex", "zoneItemTabIndex", "dropTargetStyle", "dropTargetClasses", "transformDraggedElement", "autoAriaDisabled", "centreDraggedOnCursor"];
|
|
2342
2348
|
|
|
2343
2349
|
/**
|
|
2344
2350
|
* A custom action to turn any container to a dnd zone and all of its direct children to draggables
|
|
@@ -2354,6 +2360,7 @@ var _excluded = ["items", "flipDurationMs", "type", "dragDisabled", "morphDisabl
|
|
|
2354
2360
|
* @property {boolean} [morphDisabled] - whether dragged element should morph to zone dimensions
|
|
2355
2361
|
* @property {boolean} [dropFromOthersDisabled]
|
|
2356
2362
|
* @property {number} [zoneTabIndex] - set the tabindex of the list container when not dragging
|
|
2363
|
+
* @property {number} [zoneItemTabIndex] - set the tabindex of the list container items when not dragging
|
|
2357
2364
|
* @property {object} [dropTargetStyle]
|
|
2358
2365
|
* @property {string[]} [dropTargetClasses]
|
|
2359
2366
|
* @property {function} [transformDraggedElement]
|
|
@@ -2402,6 +2409,7 @@ function validateOptions(options) {
|
|
|
2402
2409
|
morphDisabled = options.morphDisabled,
|
|
2403
2410
|
dropFromOthersDisabled = options.dropFromOthersDisabled,
|
|
2404
2411
|
zoneTabIndex = options.zoneTabIndex,
|
|
2412
|
+
zoneItemTabIndex = options.zoneItemTabIndex,
|
|
2405
2413
|
dropTargetStyle = options.dropTargetStyle,
|
|
2406
2414
|
dropTargetClasses = options.dropTargetClasses,
|
|
2407
2415
|
transformDraggedElement = options.transformDraggedElement,
|
|
@@ -2427,6 +2435,9 @@ function validateOptions(options) {
|
|
|
2427
2435
|
if (zoneTabIndex && !isInt(zoneTabIndex)) {
|
|
2428
2436
|
throw new Error("zoneTabIndex should be a number but instead it is a ".concat(_typeof(zoneTabIndex), ", ").concat(toString(zoneTabIndex)));
|
|
2429
2437
|
}
|
|
2438
|
+
if (zoneItemTabIndex && !isInt(zoneItemTabIndex)) {
|
|
2439
|
+
throw new Error("zoneItemTabIndex should be a number but instead it is a ".concat(_typeof(zoneItemTabIndex), ", ").concat(toString(zoneItemTabIndex)));
|
|
2440
|
+
}
|
|
2430
2441
|
}
|
|
2431
2442
|
function isInt(value) {
|
|
2432
2443
|
return !isNaN(value) && function (x) {
|
package/package.json
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"dist"
|
|
44
44
|
],
|
|
45
45
|
"description": "*An awesome drag and drop library for Svelte 3 and 4 (not using the browser's built-in dnd, thanks god): Rich animations, nested containers, touch support and more *",
|
|
46
|
-
"version": "0.9.
|
|
46
|
+
"version": "0.9.31",
|
|
47
47
|
"repository": {
|
|
48
48
|
"type": "git",
|
|
49
49
|
"url": "git+https://github.com/isaacHagoel/svelte-dnd-action.git"
|
package/src/action.js
CHANGED
|
@@ -17,6 +17,7 @@ import {toString} from "./helpers/util";
|
|
|
17
17
|
* @property {boolean} [morphDisabled] - whether dragged element should morph to zone dimensions
|
|
18
18
|
* @property {boolean} [dropFromOthersDisabled]
|
|
19
19
|
* @property {number} [zoneTabIndex] - set the tabindex of the list container when not dragging
|
|
20
|
+
* @property {number} [zoneItemTabIndex] - set the tabindex of the list container items when not dragging
|
|
20
21
|
* @property {object} [dropTargetStyle]
|
|
21
22
|
* @property {string[]} [dropTargetClasses]
|
|
22
23
|
* @property {function} [transformDraggedElement]
|
|
@@ -67,6 +68,7 @@ function validateOptions(options) {
|
|
|
67
68
|
morphDisabled,
|
|
68
69
|
dropFromOthersDisabled,
|
|
69
70
|
zoneTabIndex,
|
|
71
|
+
zoneItemTabIndex,
|
|
70
72
|
dropTargetStyle,
|
|
71
73
|
dropTargetClasses,
|
|
72
74
|
transformDraggedElement,
|
|
@@ -91,6 +93,9 @@ function validateOptions(options) {
|
|
|
91
93
|
if (zoneTabIndex && !isInt(zoneTabIndex)) {
|
|
92
94
|
throw new Error(`zoneTabIndex should be a number but instead it is a ${typeof zoneTabIndex}, ${toString(zoneTabIndex)}`);
|
|
93
95
|
}
|
|
96
|
+
if (zoneItemTabIndex && !isInt(zoneItemTabIndex)) {
|
|
97
|
+
throw new Error(`zoneItemTabIndex should be a number but instead it is a ${typeof zoneItemTabIndex}, ${toString(zoneItemTabIndex)}`);
|
|
98
|
+
}
|
|
94
99
|
}
|
|
95
100
|
|
|
96
101
|
function isInt(value) {
|
package/src/keyboardAction.js
CHANGED
|
@@ -157,6 +157,7 @@ export function dndzone(node, options) {
|
|
|
157
157
|
type: undefined,
|
|
158
158
|
dragDisabled: false,
|
|
159
159
|
zoneTabIndex: 0,
|
|
160
|
+
zoneItemTabIndex: 0,
|
|
160
161
|
dropFromOthersDisabled: false,
|
|
161
162
|
dropTargetStyle: DEFAULT_DROP_TARGET_STYLE,
|
|
162
163
|
dropTargetClasses: [],
|
|
@@ -261,7 +262,7 @@ export function dndzone(node, options) {
|
|
|
261
262
|
const children = Array.from(node.children);
|
|
262
263
|
const focusedItemIdx = children.indexOf(draggableEl);
|
|
263
264
|
focusedItem = draggableEl;
|
|
264
|
-
focusedItem.tabIndex =
|
|
265
|
+
focusedItem.tabIndex = config.zoneItemTabIndex;
|
|
265
266
|
focusedItemId = items[focusedItemIdx][ITEM_ID_KEY];
|
|
266
267
|
focusedItemLabel = children[focusedItemIdx].getAttribute("aria-label") || "";
|
|
267
268
|
}
|
|
@@ -271,6 +272,7 @@ export function dndzone(node, options) {
|
|
|
271
272
|
type: newType = DEFAULT_DROP_ZONE_TYPE,
|
|
272
273
|
dragDisabled = false,
|
|
273
274
|
zoneTabIndex = 0,
|
|
275
|
+
zoneItemTabIndex = 0,
|
|
274
276
|
dropFromOthersDisabled = false,
|
|
275
277
|
dropTargetStyle = DEFAULT_DROP_TARGET_STYLE,
|
|
276
278
|
dropTargetClasses = [],
|
|
@@ -280,6 +282,7 @@ export function dndzone(node, options) {
|
|
|
280
282
|
config.dragDisabled = dragDisabled;
|
|
281
283
|
config.dropFromOthersDisabled = dropFromOthersDisabled;
|
|
282
284
|
config.zoneTabIndex = zoneTabIndex;
|
|
285
|
+
config.zoneItemTabIndex = zoneItemTabIndex;
|
|
283
286
|
config.dropTargetStyle = dropTargetStyle;
|
|
284
287
|
config.dropTargetClasses = dropTargetClasses;
|
|
285
288
|
config.autoAriaDisabled = autoAriaDisabled;
|
|
@@ -312,7 +315,7 @@ export function dndzone(node, options) {
|
|
|
312
315
|
for (let i = 0; i < node.children.length; i++) {
|
|
313
316
|
const draggableEl = node.children[i];
|
|
314
317
|
allDragTargets.add(draggableEl);
|
|
315
|
-
draggableEl.tabIndex = isDragging ? -1 :
|
|
318
|
+
draggableEl.tabIndex = isDragging ? -1 : config.zoneItemTabIndex;
|
|
316
319
|
if (!autoAriaDisabled) {
|
|
317
320
|
draggableEl.setAttribute("role", "listitem");
|
|
318
321
|
}
|
|
@@ -328,7 +331,7 @@ export function dndzone(node, options) {
|
|
|
328
331
|
printDebug(() => ["focusing on", {i, focusedItemId}]);
|
|
329
332
|
// if it is a nested dropzone, it was re-rendered and we need to refresh our pointer
|
|
330
333
|
focusedItem = draggableEl;
|
|
331
|
-
focusedItem.tabIndex =
|
|
334
|
+
focusedItem.tabIndex = config.zoneItemTabIndex;
|
|
332
335
|
// without this the element loses focus if it moves backwards in the list
|
|
333
336
|
draggableEl.focus();
|
|
334
337
|
}
|
package/src/pointerAction.js
CHANGED
|
@@ -36,6 +36,7 @@ import {getBoundingRectNoTransforms} from "./helpers/intersection";
|
|
|
36
36
|
|
|
37
37
|
const DEFAULT_DROP_ZONE_TYPE = "--any--";
|
|
38
38
|
const MIN_OBSERVATION_INTERVAL_MS = 100;
|
|
39
|
+
const DISABLED_OBSERVATION_INTERVAL_MS = 20;
|
|
39
40
|
const MIN_MOVEMENT_BEFORE_DRAG_START_PX = 3;
|
|
40
41
|
const DEFAULT_DROP_TARGET_STYLE = {
|
|
41
42
|
outline: "rgba(255, 255, 102, 0.7) solid 2px"
|
|
@@ -96,10 +97,8 @@ function watchDraggedElement() {
|
|
|
96
97
|
}
|
|
97
98
|
window.addEventListener(DRAGGED_LEFT_DOCUMENT_EVENT_NAME, handleDrop);
|
|
98
99
|
// it is important that we don't have an interval that is faster than the flip duration because it can cause elements to jump bach and forth
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
...Array.from(dropZones.keys()).map(dz => dzToConfig.get(dz).dropAnimationDurationMs)
|
|
102
|
-
);
|
|
100
|
+
const setIntervalMs = Math.max(...Array.from(dropZones.keys()).map(dz => dzToConfig.get(dz).dropAnimationDurationMs));
|
|
101
|
+
const observationIntervalMs = setIntervalMs === 0 ? DISABLED_OBSERVATION_INTERVAL_MS : Math.max(setIntervalMs, MIN_OBSERVATION_INTERVAL_MS); //if setintervalms is 0 it goes to 20, otherwise it is max between it and min observation.
|
|
103
102
|
observe(draggedEl, dropZones, observationIntervalMs * 1.07);
|
|
104
103
|
}
|
|
105
104
|
function unWatchDraggedElement() {
|