svelte-dnd-action 0.9.30 → 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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +13 -4
- package/dist/index.mjs +13 -4
- package/package.json +1 -1
- package/src/action.js +5 -0
- package/src/keyboardAction.js +6 -3
package/README.md
CHANGED
|
@@ -112,6 +112,7 @@ An options-object with the following attributes:
|
|
|
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
|
@@ -2118,6 +2118,7 @@
|
|
|
2118
2118
|
type: undefined,
|
|
2119
2119
|
dragDisabled: false,
|
|
2120
2120
|
zoneTabIndex: 0,
|
|
2121
|
+
zoneItemTabIndex: 0,
|
|
2121
2122
|
dropFromOthersDisabled: false,
|
|
2122
2123
|
dropTargetStyle: DEFAULT_DROP_TARGET_STYLE$1,
|
|
2123
2124
|
dropTargetClasses: [],
|
|
@@ -2247,7 +2248,7 @@
|
|
|
2247
2248
|
var children = Array.from(node.children);
|
|
2248
2249
|
var focusedItemIdx = children.indexOf(draggableEl);
|
|
2249
2250
|
focusedItem = draggableEl;
|
|
2250
|
-
focusedItem.tabIndex =
|
|
2251
|
+
focusedItem.tabIndex = config.zoneItemTabIndex;
|
|
2251
2252
|
focusedItemId = items[focusedItemIdx][ITEM_ID_KEY];
|
|
2252
2253
|
focusedItemLabel = children[focusedItemIdx].getAttribute("aria-label") || "";
|
|
2253
2254
|
}
|
|
@@ -2260,6 +2261,8 @@
|
|
|
2260
2261
|
dragDisabled = _ref2$dragDisabled === void 0 ? false : _ref2$dragDisabled,
|
|
2261
2262
|
_ref2$zoneTabIndex = _ref2.zoneTabIndex,
|
|
2262
2263
|
zoneTabIndex = _ref2$zoneTabIndex === void 0 ? 0 : _ref2$zoneTabIndex,
|
|
2264
|
+
_ref2$zoneItemTabInde = _ref2.zoneItemTabIndex,
|
|
2265
|
+
zoneItemTabIndex = _ref2$zoneItemTabInde === void 0 ? 0 : _ref2$zoneItemTabInde,
|
|
2263
2266
|
_ref2$dropFromOthersD = _ref2.dropFromOthersDisabled,
|
|
2264
2267
|
dropFromOthersDisabled = _ref2$dropFromOthersD === void 0 ? false : _ref2$dropFromOthersD,
|
|
2265
2268
|
_ref2$dropTargetStyle = _ref2.dropTargetStyle,
|
|
@@ -2272,6 +2275,7 @@
|
|
|
2272
2275
|
config.dragDisabled = dragDisabled;
|
|
2273
2276
|
config.dropFromOthersDisabled = dropFromOthersDisabled;
|
|
2274
2277
|
config.zoneTabIndex = zoneTabIndex;
|
|
2278
|
+
config.zoneItemTabIndex = zoneItemTabIndex;
|
|
2275
2279
|
config.dropTargetStyle = dropTargetStyle;
|
|
2276
2280
|
config.dropTargetClasses = dropTargetClasses;
|
|
2277
2281
|
config.autoAriaDisabled = autoAriaDisabled;
|
|
@@ -2295,7 +2299,7 @@
|
|
|
2295
2299
|
var _loop = function _loop(i) {
|
|
2296
2300
|
var draggableEl = node.children[i];
|
|
2297
2301
|
allDragTargets.add(draggableEl);
|
|
2298
|
-
draggableEl.tabIndex = isDragging ? -1 :
|
|
2302
|
+
draggableEl.tabIndex = isDragging ? -1 : config.zoneItemTabIndex;
|
|
2299
2303
|
if (!autoAriaDisabled) {
|
|
2300
2304
|
draggableEl.setAttribute("role", "listitem");
|
|
2301
2305
|
}
|
|
@@ -2316,7 +2320,7 @@
|
|
|
2316
2320
|
});
|
|
2317
2321
|
// if it is a nested dropzone, it was re-rendered and we need to refresh our pointer
|
|
2318
2322
|
focusedItem = draggableEl;
|
|
2319
|
-
focusedItem.tabIndex =
|
|
2323
|
+
focusedItem.tabIndex = config.zoneItemTabIndex;
|
|
2320
2324
|
// without this the element loses focus if it moves backwards in the list
|
|
2321
2325
|
draggableEl.focus();
|
|
2322
2326
|
}
|
|
@@ -2346,7 +2350,7 @@
|
|
|
2346
2350
|
return handles;
|
|
2347
2351
|
}
|
|
2348
2352
|
|
|
2349
|
-
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"];
|
|
2350
2354
|
|
|
2351
2355
|
/**
|
|
2352
2356
|
* A custom action to turn any container to a dnd zone and all of its direct children to draggables
|
|
@@ -2362,6 +2366,7 @@
|
|
|
2362
2366
|
* @property {boolean} [morphDisabled] - whether dragged element should morph to zone dimensions
|
|
2363
2367
|
* @property {boolean} [dropFromOthersDisabled]
|
|
2364
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
|
|
2365
2370
|
* @property {object} [dropTargetStyle]
|
|
2366
2371
|
* @property {string[]} [dropTargetClasses]
|
|
2367
2372
|
* @property {function} [transformDraggedElement]
|
|
@@ -2410,6 +2415,7 @@
|
|
|
2410
2415
|
morphDisabled = options.morphDisabled,
|
|
2411
2416
|
dropFromOthersDisabled = options.dropFromOthersDisabled,
|
|
2412
2417
|
zoneTabIndex = options.zoneTabIndex,
|
|
2418
|
+
zoneItemTabIndex = options.zoneItemTabIndex,
|
|
2413
2419
|
dropTargetStyle = options.dropTargetStyle,
|
|
2414
2420
|
dropTargetClasses = options.dropTargetClasses,
|
|
2415
2421
|
transformDraggedElement = options.transformDraggedElement,
|
|
@@ -2435,6 +2441,9 @@
|
|
|
2435
2441
|
if (zoneTabIndex && !isInt(zoneTabIndex)) {
|
|
2436
2442
|
throw new Error("zoneTabIndex should be a number but instead it is a ".concat(_typeof(zoneTabIndex), ", ").concat(toString(zoneTabIndex)));
|
|
2437
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
|
+
}
|
|
2438
2447
|
}
|
|
2439
2448
|
function isInt(value) {
|
|
2440
2449
|
return !isNaN(value) && function (x) {
|
package/dist/index.mjs
CHANGED
|
@@ -2112,6 +2112,7 @@ function dndzone$1(node, options) {
|
|
|
2112
2112
|
type: undefined,
|
|
2113
2113
|
dragDisabled: false,
|
|
2114
2114
|
zoneTabIndex: 0,
|
|
2115
|
+
zoneItemTabIndex: 0,
|
|
2115
2116
|
dropFromOthersDisabled: false,
|
|
2116
2117
|
dropTargetStyle: DEFAULT_DROP_TARGET_STYLE$1,
|
|
2117
2118
|
dropTargetClasses: [],
|
|
@@ -2241,7 +2242,7 @@ function dndzone$1(node, options) {
|
|
|
2241
2242
|
var children = Array.from(node.children);
|
|
2242
2243
|
var focusedItemIdx = children.indexOf(draggableEl);
|
|
2243
2244
|
focusedItem = draggableEl;
|
|
2244
|
-
focusedItem.tabIndex =
|
|
2245
|
+
focusedItem.tabIndex = config.zoneItemTabIndex;
|
|
2245
2246
|
focusedItemId = items[focusedItemIdx][ITEM_ID_KEY];
|
|
2246
2247
|
focusedItemLabel = children[focusedItemIdx].getAttribute("aria-label") || "";
|
|
2247
2248
|
}
|
|
@@ -2254,6 +2255,8 @@ function dndzone$1(node, options) {
|
|
|
2254
2255
|
dragDisabled = _ref2$dragDisabled === void 0 ? false : _ref2$dragDisabled,
|
|
2255
2256
|
_ref2$zoneTabIndex = _ref2.zoneTabIndex,
|
|
2256
2257
|
zoneTabIndex = _ref2$zoneTabIndex === void 0 ? 0 : _ref2$zoneTabIndex,
|
|
2258
|
+
_ref2$zoneItemTabInde = _ref2.zoneItemTabIndex,
|
|
2259
|
+
zoneItemTabIndex = _ref2$zoneItemTabInde === void 0 ? 0 : _ref2$zoneItemTabInde,
|
|
2257
2260
|
_ref2$dropFromOthersD = _ref2.dropFromOthersDisabled,
|
|
2258
2261
|
dropFromOthersDisabled = _ref2$dropFromOthersD === void 0 ? false : _ref2$dropFromOthersD,
|
|
2259
2262
|
_ref2$dropTargetStyle = _ref2.dropTargetStyle,
|
|
@@ -2266,6 +2269,7 @@ function dndzone$1(node, options) {
|
|
|
2266
2269
|
config.dragDisabled = dragDisabled;
|
|
2267
2270
|
config.dropFromOthersDisabled = dropFromOthersDisabled;
|
|
2268
2271
|
config.zoneTabIndex = zoneTabIndex;
|
|
2272
|
+
config.zoneItemTabIndex = zoneItemTabIndex;
|
|
2269
2273
|
config.dropTargetStyle = dropTargetStyle;
|
|
2270
2274
|
config.dropTargetClasses = dropTargetClasses;
|
|
2271
2275
|
config.autoAriaDisabled = autoAriaDisabled;
|
|
@@ -2289,7 +2293,7 @@ function dndzone$1(node, options) {
|
|
|
2289
2293
|
var _loop = function _loop(i) {
|
|
2290
2294
|
var draggableEl = node.children[i];
|
|
2291
2295
|
allDragTargets.add(draggableEl);
|
|
2292
|
-
draggableEl.tabIndex = isDragging ? -1 :
|
|
2296
|
+
draggableEl.tabIndex = isDragging ? -1 : config.zoneItemTabIndex;
|
|
2293
2297
|
if (!autoAriaDisabled) {
|
|
2294
2298
|
draggableEl.setAttribute("role", "listitem");
|
|
2295
2299
|
}
|
|
@@ -2310,7 +2314,7 @@ function dndzone$1(node, options) {
|
|
|
2310
2314
|
});
|
|
2311
2315
|
// if it is a nested dropzone, it was re-rendered and we need to refresh our pointer
|
|
2312
2316
|
focusedItem = draggableEl;
|
|
2313
|
-
focusedItem.tabIndex =
|
|
2317
|
+
focusedItem.tabIndex = config.zoneItemTabIndex;
|
|
2314
2318
|
// without this the element loses focus if it moves backwards in the list
|
|
2315
2319
|
draggableEl.focus();
|
|
2316
2320
|
}
|
|
@@ -2340,7 +2344,7 @@ function dndzone$1(node, options) {
|
|
|
2340
2344
|
return handles;
|
|
2341
2345
|
}
|
|
2342
2346
|
|
|
2343
|
-
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"];
|
|
2344
2348
|
|
|
2345
2349
|
/**
|
|
2346
2350
|
* A custom action to turn any container to a dnd zone and all of its direct children to draggables
|
|
@@ -2356,6 +2360,7 @@ var _excluded = ["items", "flipDurationMs", "type", "dragDisabled", "morphDisabl
|
|
|
2356
2360
|
* @property {boolean} [morphDisabled] - whether dragged element should morph to zone dimensions
|
|
2357
2361
|
* @property {boolean} [dropFromOthersDisabled]
|
|
2358
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
|
|
2359
2364
|
* @property {object} [dropTargetStyle]
|
|
2360
2365
|
* @property {string[]} [dropTargetClasses]
|
|
2361
2366
|
* @property {function} [transformDraggedElement]
|
|
@@ -2404,6 +2409,7 @@ function validateOptions(options) {
|
|
|
2404
2409
|
morphDisabled = options.morphDisabled,
|
|
2405
2410
|
dropFromOthersDisabled = options.dropFromOthersDisabled,
|
|
2406
2411
|
zoneTabIndex = options.zoneTabIndex,
|
|
2412
|
+
zoneItemTabIndex = options.zoneItemTabIndex,
|
|
2407
2413
|
dropTargetStyle = options.dropTargetStyle,
|
|
2408
2414
|
dropTargetClasses = options.dropTargetClasses,
|
|
2409
2415
|
transformDraggedElement = options.transformDraggedElement,
|
|
@@ -2429,6 +2435,9 @@ function validateOptions(options) {
|
|
|
2429
2435
|
if (zoneTabIndex && !isInt(zoneTabIndex)) {
|
|
2430
2436
|
throw new Error("zoneTabIndex should be a number but instead it is a ".concat(_typeof(zoneTabIndex), ", ").concat(toString(zoneTabIndex)));
|
|
2431
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
|
+
}
|
|
2432
2441
|
}
|
|
2433
2442
|
function isInt(value) {
|
|
2434
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
|
}
|