svelte-dnd-action 0.9.18 → 0.9.19
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 +29 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +43 -53
- package/dist/index.mjs +43 -53
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -285,6 +285,35 @@ Then you will be able to use the library with type safety as follows (Typescript
|
|
|
285
285
|
</section>
|
|
286
286
|
```
|
|
287
287
|
|
|
288
|
+
#### Custom types with `DndEvent<T>`
|
|
289
|
+
|
|
290
|
+
You can use generics to set the type of `items` you are expecting in `DndEvent`. Simply add a type to it like so: `DndEvent<Dog>`. For example:
|
|
291
|
+
|
|
292
|
+
```html
|
|
293
|
+
<script lang="ts">
|
|
294
|
+
import {dndzone} from "svelte-dnd-action";
|
|
295
|
+
import {flip} from "svelte/animate";
|
|
296
|
+
|
|
297
|
+
interface Dog {
|
|
298
|
+
id: number;
|
|
299
|
+
name: string;
|
|
300
|
+
breed: string;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function handleSort(e: CustomEvent<DndEvent<Dog>>) {
|
|
304
|
+
//e.detail.items now evaluates to type Dog.
|
|
305
|
+
items = e.detail.items;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
let items: Dog[] = [
|
|
309
|
+
{ id: 1, name: 'Fido', breed: 'bulldog' },
|
|
310
|
+
{ id: 2, name: 'Spot', breed: 'labrador' },
|
|
311
|
+
{ id: 3, name: 'Jacky', breed: 'golden retriever' }
|
|
312
|
+
];
|
|
313
|
+
</script>
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
|
|
288
317
|
### Contributing [](https://github.com/isaacHagoel/svelte-dnd-action/issues)
|
|
289
318
|
|
|
290
319
|
There is still quite a lot to do. If you'd like to contribute please get in touch (raise an issue or comment on an existing one).
|
package/dist/index.d.ts
CHANGED
|
@@ -70,8 +70,8 @@ export interface DndEventInfo {
|
|
|
70
70
|
source: SOURCES; // the type of interaction that the user used to perform the dnd operation
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export type DndEvent = {
|
|
74
|
-
items:
|
|
73
|
+
export type DndEvent<T = Item> = {
|
|
74
|
+
items: T[];
|
|
75
75
|
info: DndEventInfo;
|
|
76
76
|
};
|
|
77
77
|
|
package/dist/index.js
CHANGED
|
@@ -4,20 +4,40 @@
|
|
|
4
4
|
(global = global || self, factory(global.DndAction = {}));
|
|
5
5
|
}(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
|
|
7
|
+
function ownKeys(object, enumerableOnly) {
|
|
8
|
+
var keys = Object.keys(object);
|
|
9
9
|
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
_typeof = function (obj) {
|
|
16
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
17
|
-
};
|
|
10
|
+
if (Object.getOwnPropertySymbols) {
|
|
11
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
12
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
13
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
14
|
+
})), keys.push.apply(keys, symbols);
|
|
18
15
|
}
|
|
19
16
|
|
|
20
|
-
return
|
|
17
|
+
return keys;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function _objectSpread2(target) {
|
|
21
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
22
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
23
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
24
|
+
_defineProperty(target, key, source[key]);
|
|
25
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
26
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return target;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function _typeof(obj) {
|
|
34
|
+
"@babel/helpers - typeof";
|
|
35
|
+
|
|
36
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
37
|
+
return typeof obj;
|
|
38
|
+
} : function (obj) {
|
|
39
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
40
|
+
}, _typeof(obj);
|
|
21
41
|
}
|
|
22
42
|
|
|
23
43
|
function _defineProperty(obj, key, value) {
|
|
@@ -35,40 +55,6 @@
|
|
|
35
55
|
return obj;
|
|
36
56
|
}
|
|
37
57
|
|
|
38
|
-
function ownKeys(object, enumerableOnly) {
|
|
39
|
-
var keys = Object.keys(object);
|
|
40
|
-
|
|
41
|
-
if (Object.getOwnPropertySymbols) {
|
|
42
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
43
|
-
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
44
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
45
|
-
});
|
|
46
|
-
keys.push.apply(keys, symbols);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return keys;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function _objectSpread2(target) {
|
|
53
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
54
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
55
|
-
|
|
56
|
-
if (i % 2) {
|
|
57
|
-
ownKeys(Object(source), true).forEach(function (key) {
|
|
58
|
-
_defineProperty(target, key, source[key]);
|
|
59
|
-
});
|
|
60
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
61
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
62
|
-
} else {
|
|
63
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
64
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return target;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
58
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
73
59
|
if (source == null) return {};
|
|
74
60
|
var target = {};
|
|
@@ -122,18 +108,21 @@
|
|
|
122
108
|
}
|
|
123
109
|
|
|
124
110
|
function _iterableToArray(iter) {
|
|
125
|
-
if (typeof Symbol !== "undefined" && Symbol.iterator
|
|
111
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
126
112
|
}
|
|
127
113
|
|
|
128
114
|
function _iterableToArrayLimit(arr, i) {
|
|
129
|
-
|
|
115
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
116
|
+
|
|
117
|
+
if (_i == null) return;
|
|
130
118
|
var _arr = [];
|
|
131
119
|
var _n = true;
|
|
132
120
|
var _d = false;
|
|
133
|
-
|
|
121
|
+
|
|
122
|
+
var _s, _e;
|
|
134
123
|
|
|
135
124
|
try {
|
|
136
|
-
for (
|
|
125
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
137
126
|
_arr.push(_s.value);
|
|
138
127
|
|
|
139
128
|
if (i && _arr.length === i) break;
|
|
@@ -178,9 +167,9 @@
|
|
|
178
167
|
}
|
|
179
168
|
|
|
180
169
|
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
181
|
-
var it;
|
|
170
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
182
171
|
|
|
183
|
-
if (
|
|
172
|
+
if (!it) {
|
|
184
173
|
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
185
174
|
if (it) o = it;
|
|
186
175
|
var i = 0;
|
|
@@ -213,7 +202,7 @@
|
|
|
213
202
|
err;
|
|
214
203
|
return {
|
|
215
204
|
s: function () {
|
|
216
|
-
it =
|
|
205
|
+
it = it.call(o);
|
|
217
206
|
},
|
|
218
207
|
n: function () {
|
|
219
208
|
var step = it.next();
|
|
@@ -2612,6 +2601,7 @@
|
|
|
2612
2601
|
return handles;
|
|
2613
2602
|
}
|
|
2614
2603
|
|
|
2604
|
+
var _excluded = ["items", "flipDurationMs", "type", "dragDisabled", "morphDisabled", "dropFromOthersDisabled", "zoneTabIndex", "dropTargetStyle", "dropTargetClasses", "transformDraggedElement", "autoAriaDisabled", "centreDraggedOnCursor"];
|
|
2615
2605
|
/**
|
|
2616
2606
|
* A custom action to turn any container to a dnd zone and all of its direct children to draggables
|
|
2617
2607
|
* Supports mouse, touch and keyboard interactions.
|
|
@@ -2665,7 +2655,7 @@
|
|
|
2665
2655
|
transformDraggedElement = options.transformDraggedElement,
|
|
2666
2656
|
autoAriaDisabled = options.autoAriaDisabled,
|
|
2667
2657
|
centreDraggedOnCursor = options.centreDraggedOnCursor,
|
|
2668
|
-
rest = _objectWithoutProperties(options,
|
|
2658
|
+
rest = _objectWithoutProperties(options, _excluded);
|
|
2669
2659
|
/*eslint-enable*/
|
|
2670
2660
|
|
|
2671
2661
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
1
|
+
function ownKeys(object, enumerableOnly) {
|
|
2
|
+
var keys = Object.keys(object);
|
|
3
3
|
|
|
4
|
-
if (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
_typeof = function (obj) {
|
|
10
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
11
|
-
};
|
|
4
|
+
if (Object.getOwnPropertySymbols) {
|
|
5
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
6
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
7
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
8
|
+
})), keys.push.apply(keys, symbols);
|
|
12
9
|
}
|
|
13
10
|
|
|
14
|
-
return
|
|
11
|
+
return keys;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function _objectSpread2(target) {
|
|
15
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
16
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
17
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
18
|
+
_defineProperty(target, key, source[key]);
|
|
19
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
20
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return target;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function _typeof(obj) {
|
|
28
|
+
"@babel/helpers - typeof";
|
|
29
|
+
|
|
30
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
31
|
+
return typeof obj;
|
|
32
|
+
} : function (obj) {
|
|
33
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
34
|
+
}, _typeof(obj);
|
|
15
35
|
}
|
|
16
36
|
|
|
17
37
|
function _defineProperty(obj, key, value) {
|
|
@@ -29,40 +49,6 @@ function _defineProperty(obj, key, value) {
|
|
|
29
49
|
return obj;
|
|
30
50
|
}
|
|
31
51
|
|
|
32
|
-
function ownKeys(object, enumerableOnly) {
|
|
33
|
-
var keys = Object.keys(object);
|
|
34
|
-
|
|
35
|
-
if (Object.getOwnPropertySymbols) {
|
|
36
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
37
|
-
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
38
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
39
|
-
});
|
|
40
|
-
keys.push.apply(keys, symbols);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return keys;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function _objectSpread2(target) {
|
|
47
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
48
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
49
|
-
|
|
50
|
-
if (i % 2) {
|
|
51
|
-
ownKeys(Object(source), true).forEach(function (key) {
|
|
52
|
-
_defineProperty(target, key, source[key]);
|
|
53
|
-
});
|
|
54
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
55
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
56
|
-
} else {
|
|
57
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
58
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return target;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
52
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
67
53
|
if (source == null) return {};
|
|
68
54
|
var target = {};
|
|
@@ -116,18 +102,21 @@ function _arrayWithHoles(arr) {
|
|
|
116
102
|
}
|
|
117
103
|
|
|
118
104
|
function _iterableToArray(iter) {
|
|
119
|
-
if (typeof Symbol !== "undefined" && Symbol.iterator
|
|
105
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
120
106
|
}
|
|
121
107
|
|
|
122
108
|
function _iterableToArrayLimit(arr, i) {
|
|
123
|
-
|
|
109
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
110
|
+
|
|
111
|
+
if (_i == null) return;
|
|
124
112
|
var _arr = [];
|
|
125
113
|
var _n = true;
|
|
126
114
|
var _d = false;
|
|
127
|
-
|
|
115
|
+
|
|
116
|
+
var _s, _e;
|
|
128
117
|
|
|
129
118
|
try {
|
|
130
|
-
for (
|
|
119
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
131
120
|
_arr.push(_s.value);
|
|
132
121
|
|
|
133
122
|
if (i && _arr.length === i) break;
|
|
@@ -172,9 +161,9 @@ function _nonIterableRest() {
|
|
|
172
161
|
}
|
|
173
162
|
|
|
174
163
|
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
175
|
-
var it;
|
|
164
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
176
165
|
|
|
177
|
-
if (
|
|
166
|
+
if (!it) {
|
|
178
167
|
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
179
168
|
if (it) o = it;
|
|
180
169
|
var i = 0;
|
|
@@ -207,7 +196,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
|
207
196
|
err;
|
|
208
197
|
return {
|
|
209
198
|
s: function () {
|
|
210
|
-
it =
|
|
199
|
+
it = it.call(o);
|
|
211
200
|
},
|
|
212
201
|
n: function () {
|
|
213
202
|
var step = it.next();
|
|
@@ -2606,6 +2595,7 @@ function dndzone$1(node, options) {
|
|
|
2606
2595
|
return handles;
|
|
2607
2596
|
}
|
|
2608
2597
|
|
|
2598
|
+
var _excluded = ["items", "flipDurationMs", "type", "dragDisabled", "morphDisabled", "dropFromOthersDisabled", "zoneTabIndex", "dropTargetStyle", "dropTargetClasses", "transformDraggedElement", "autoAriaDisabled", "centreDraggedOnCursor"];
|
|
2609
2599
|
/**
|
|
2610
2600
|
* A custom action to turn any container to a dnd zone and all of its direct children to draggables
|
|
2611
2601
|
* Supports mouse, touch and keyboard interactions.
|
|
@@ -2659,7 +2649,7 @@ function validateOptions(options) {
|
|
|
2659
2649
|
transformDraggedElement = options.transformDraggedElement,
|
|
2660
2650
|
autoAriaDisabled = options.autoAriaDisabled,
|
|
2661
2651
|
centreDraggedOnCursor = options.centreDraggedOnCursor,
|
|
2662
|
-
rest = _objectWithoutProperties(options,
|
|
2652
|
+
rest = _objectWithoutProperties(options, _excluded);
|
|
2663
2653
|
/*eslint-enable*/
|
|
2664
2654
|
|
|
2665
2655
|
|
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.19",
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|
|
46
46
|
"url": "git+https://github.com/isaacHagoel/svelte-dnd-action.git"
|