@dnd-kit/dom 0.0.1
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 +17 -0
- package/index.cjs +1307 -0
- package/index.cjs.map +1 -0
- package/index.d.cts +189 -0
- package/index.d.ts +189 -0
- package/index.js +1295 -0
- package/index.js.map +1 -0
- package/modifiers.cjs +120 -0
- package/modifiers.d.cts +23 -0
- package/modifiers.d.ts +23 -0
- package/modifiers.js +117 -0
- package/modifiers.js.map +1 -0
- package/package.json +92 -0
- package/plugins/debug.cjs +95 -0
- package/plugins/debug.cjs.map +1 -0
- package/plugins/debug.d.cts +8 -0
- package/plugins/debug.d.ts +8 -0
- package/plugins/debug.js +93 -0
- package/plugins/debug.js.map +1 -0
- package/sortable.cjs +531 -0
- package/sortable.cjs.map +1 -0
- package/sortable.d.cts +85 -0
- package/sortable.d.ts +85 -0
- package/sortable.js +528 -0
- package/sortable.js.map +1 -0
- package/utilities.cjs +655 -0
- package/utilities.cjs.map +1 -0
- package/utilities.d.cts +131 -0
- package/utilities.d.ts +131 -0
- package/utilities.js +626 -0
- package/utilities.js.map +1 -0
package/sortable.cjs
ADDED
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var state = require('@dnd-kit/state');
|
|
4
|
+
var abstract = require('@dnd-kit/abstract');
|
|
5
|
+
var collision = require('@dnd-kit/collision');
|
|
6
|
+
var dom = require('@dnd-kit/dom');
|
|
7
|
+
var utilities = require('@dnd-kit/dom/utilities');
|
|
8
|
+
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
11
|
+
var result = void 0 ;
|
|
12
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
13
|
+
if (decorator = decorators[i])
|
|
14
|
+
result = (decorator(target, key, result) ) || result;
|
|
15
|
+
if (result)
|
|
16
|
+
__defProp(target, key, result);
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// src/sortable/utilities.ts
|
|
21
|
+
function isSortable(element) {
|
|
22
|
+
return element instanceof SortableDroppable || element instanceof SortableDraggable;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/sortable/SortableKeyboardPlugin.ts
|
|
26
|
+
var TOLERANCE = 10;
|
|
27
|
+
var SortableKeyboardPlugin = class extends abstract.Plugin {
|
|
28
|
+
constructor(manager) {
|
|
29
|
+
super(manager);
|
|
30
|
+
const cleanupEffect = state.effect(() => {
|
|
31
|
+
const { dragOperation } = manager;
|
|
32
|
+
if (!utilities.isKeyboardEvent(dragOperation.activatorEvent)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!isSortable(dragOperation.source)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (dragOperation.status.initialized) {
|
|
39
|
+
const scroller = manager.registry.plugins.get(dom.Scroller);
|
|
40
|
+
if (scroller) {
|
|
41
|
+
scroller.disable();
|
|
42
|
+
return () => scroller.enable();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const unsubscribe = manager.monitor.addEventListener(
|
|
47
|
+
"dragmove",
|
|
48
|
+
(event, manager2) => {
|
|
49
|
+
queueMicrotask(() => {
|
|
50
|
+
if (this.disabled || event.defaultPrevented) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const { dragOperation } = manager2;
|
|
54
|
+
if (!utilities.isKeyboardEvent(dragOperation.activatorEvent)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (!isSortable(dragOperation.source)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (!dragOperation.shape) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const { actions, collisionObserver, registry } = manager2;
|
|
64
|
+
const { by } = event;
|
|
65
|
+
if (!by) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const direction = getDirection(by);
|
|
69
|
+
const { source } = dragOperation;
|
|
70
|
+
const { center } = dragOperation.shape.current;
|
|
71
|
+
const potentialTargets = [];
|
|
72
|
+
for (const droppable of registry.droppables) {
|
|
73
|
+
const { shape, id: id2 } = droppable;
|
|
74
|
+
if (!shape || id2 === source?.id && isSortable(droppable) || source?.type != null && !droppable.accepts(source)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
switch (direction) {
|
|
78
|
+
case "down":
|
|
79
|
+
if (center.y + TOLERANCE < shape.center.y) {
|
|
80
|
+
potentialTargets.push(droppable);
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
case "up":
|
|
84
|
+
if (center.y - TOLERANCE > shape.center.y) {
|
|
85
|
+
potentialTargets.push(droppable);
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
case "left":
|
|
89
|
+
if (center.x - TOLERANCE > shape.center.x) {
|
|
90
|
+
potentialTargets.push(droppable);
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
case "right":
|
|
94
|
+
if (center.x + TOLERANCE < shape.center.x) {
|
|
95
|
+
potentialTargets.push(droppable);
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
collisionObserver.disable();
|
|
102
|
+
const collisions = collisionObserver.computeCollisions(
|
|
103
|
+
potentialTargets,
|
|
104
|
+
collision.closestCenter
|
|
105
|
+
);
|
|
106
|
+
const [firstCollision] = collisions;
|
|
107
|
+
if (!firstCollision) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const { id } = firstCollision;
|
|
111
|
+
actions.setDropTarget(id).then(() => {
|
|
112
|
+
const { source: source2 } = dragOperation;
|
|
113
|
+
if (!source2) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const droppable = registry.droppables.get(source2.id);
|
|
117
|
+
if (!droppable?.element) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const { element } = droppable;
|
|
121
|
+
utilities.scrollIntoViewIfNeeded(element);
|
|
122
|
+
utilities.scheduler.schedule(() => {
|
|
123
|
+
const shape = droppable.refreshShape();
|
|
124
|
+
if (!shape) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
actions.move({
|
|
128
|
+
to: {
|
|
129
|
+
x: shape.center.x,
|
|
130
|
+
y: shape.center.y
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
actions.setDropTarget(source2.id).then(() => {
|
|
134
|
+
dragOperation.shape = shape;
|
|
135
|
+
collisionObserver.enable();
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
this.destroy = () => {
|
|
143
|
+
unsubscribe();
|
|
144
|
+
cleanupEffect();
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
function getDirection(delta) {
|
|
149
|
+
const { x, y } = delta;
|
|
150
|
+
if (x > 0) {
|
|
151
|
+
return "right";
|
|
152
|
+
} else if (x < 0) {
|
|
153
|
+
return "left";
|
|
154
|
+
} else if (y > 0) {
|
|
155
|
+
return "down";
|
|
156
|
+
} else if (y < 0) {
|
|
157
|
+
return "up";
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// ../helpers/dist/index.js
|
|
162
|
+
function arrayMove(array, from, to) {
|
|
163
|
+
if (from === to) {
|
|
164
|
+
return array;
|
|
165
|
+
}
|
|
166
|
+
const newArray = array.slice();
|
|
167
|
+
newArray.splice(to, 0, newArray.splice(from, 1)[0]);
|
|
168
|
+
return newArray;
|
|
169
|
+
}
|
|
170
|
+
var OptimisticSortingPlugin = class extends abstract.Plugin {
|
|
171
|
+
constructor(manager) {
|
|
172
|
+
super(manager);
|
|
173
|
+
const getSortableInstances = (group) => {
|
|
174
|
+
const sortableInstances = /* @__PURE__ */ new Map();
|
|
175
|
+
for (const droppable of manager.registry.droppables) {
|
|
176
|
+
if (droppable instanceof SortableDroppable) {
|
|
177
|
+
const { sortable } = droppable;
|
|
178
|
+
if (sortable.group !== group) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (sortableInstances.has(sortable.index)) {
|
|
182
|
+
throw new Error(
|
|
183
|
+
"Duplicate sortable index found for same sortable group. Make sure each sortable item has a unique index. Use the `group` attribute to separate sortables into different groups."
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
sortableInstances.set(sortable.index, sortable);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return sortableInstances;
|
|
190
|
+
};
|
|
191
|
+
const unsubscribe = [
|
|
192
|
+
manager.monitor.addEventListener("dragover", (event, manager2) => {
|
|
193
|
+
queueMicrotask(() => {
|
|
194
|
+
if (this.disabled || event.defaultPrevented) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const { dragOperation } = manager2;
|
|
198
|
+
const { source, target } = dragOperation;
|
|
199
|
+
if (!isSortable(source) || !isSortable(target)) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (source.sortable === target.sortable) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (source.sortable.group !== target.sortable.group) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const sortableInstances = getSortableInstances(source.sortable.group);
|
|
209
|
+
manager2.renderer.rendering.then(() => {
|
|
210
|
+
for (const [index, sortable] of sortableInstances.entries()) {
|
|
211
|
+
if (sortable.index !== index) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const orderedSortables = Array.from(
|
|
216
|
+
sortableInstances.values()
|
|
217
|
+
).sort((a, b) => a.index - b.index);
|
|
218
|
+
const newOrder = arrayMove(
|
|
219
|
+
orderedSortables,
|
|
220
|
+
source.sortable.index,
|
|
221
|
+
target.sortable.index
|
|
222
|
+
);
|
|
223
|
+
const sourceElement = source.sortable.droppable.element;
|
|
224
|
+
const targetElement = target.element;
|
|
225
|
+
if (!targetElement || !sourceElement) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
reorder(
|
|
229
|
+
sourceElement,
|
|
230
|
+
source.sortable.index,
|
|
231
|
+
targetElement,
|
|
232
|
+
target.sortable.index
|
|
233
|
+
);
|
|
234
|
+
const position = target.sortable.index < source.sortable.index ? "beforebegin" : "afterend";
|
|
235
|
+
targetElement.insertAdjacentElement(position, sourceElement);
|
|
236
|
+
state.batch(() => {
|
|
237
|
+
for (const [index, sortable] of newOrder.entries()) {
|
|
238
|
+
sortable.index = index;
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
}),
|
|
244
|
+
manager.monitor.addEventListener("dragend", (event, manager2) => {
|
|
245
|
+
if (!event.canceled) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const { dragOperation } = manager2;
|
|
249
|
+
const { source } = dragOperation;
|
|
250
|
+
if (!isSortable(source)) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (source.sortable.initialIndex === source.sortable.index) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
queueMicrotask(() => {
|
|
257
|
+
const sortableInstances = getSortableInstances(source.sortable.group);
|
|
258
|
+
manager2.renderer.rendering.then(() => {
|
|
259
|
+
for (const [index, sortable] of sortableInstances.entries()) {
|
|
260
|
+
if (sortable.index !== index) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
const orderedSortables = Array.from(
|
|
265
|
+
sortableInstances.values()
|
|
266
|
+
).sort((a, b) => a.index - b.index);
|
|
267
|
+
const sourceElement = source.sortable.droppable.element;
|
|
268
|
+
const targetElement = orderedSortables[source.sortable.initialIndex].element;
|
|
269
|
+
if (!targetElement || !sourceElement) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
reorder(
|
|
273
|
+
sourceElement,
|
|
274
|
+
source.sortable.index,
|
|
275
|
+
targetElement,
|
|
276
|
+
source.sortable.initialIndex
|
|
277
|
+
);
|
|
278
|
+
state.batch(() => {
|
|
279
|
+
for (const sortable of orderedSortables.values()) {
|
|
280
|
+
sortable.index = sortable.initialIndex;
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
})
|
|
286
|
+
];
|
|
287
|
+
this.destroy = () => {
|
|
288
|
+
for (const unsubscribeListener of unsubscribe) {
|
|
289
|
+
unsubscribeListener();
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
function reorder(sourceElement, sourceIndex, targetElement, targetIndex) {
|
|
295
|
+
const position = targetIndex < sourceIndex ? "beforebegin" : "afterend";
|
|
296
|
+
targetElement.insertAdjacentElement(position, sourceElement);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// src/sortable/sortable.ts
|
|
300
|
+
var defaultPlugins = [
|
|
301
|
+
SortableKeyboardPlugin,
|
|
302
|
+
OptimisticSortingPlugin
|
|
303
|
+
];
|
|
304
|
+
var defaultSortableTransition = {
|
|
305
|
+
duration: 250,
|
|
306
|
+
easing: "cubic-bezier(0.25, 1, 0.5, 1)",
|
|
307
|
+
idle: false
|
|
308
|
+
};
|
|
309
|
+
var Sortable2 = class {
|
|
310
|
+
constructor({
|
|
311
|
+
effects: inputEffects,
|
|
312
|
+
group,
|
|
313
|
+
index,
|
|
314
|
+
sensors,
|
|
315
|
+
type,
|
|
316
|
+
transition = defaultSortableTransition,
|
|
317
|
+
plugins = defaultPlugins,
|
|
318
|
+
...input
|
|
319
|
+
}, manager) {
|
|
320
|
+
this.manager = manager;
|
|
321
|
+
this.draggable = new SortableDraggable(
|
|
322
|
+
{ ...input, type, sensors },
|
|
323
|
+
manager,
|
|
324
|
+
this
|
|
325
|
+
);
|
|
326
|
+
this.droppable = new SortableDroppable(input, manager, this);
|
|
327
|
+
for (const plugin of plugins) {
|
|
328
|
+
manager.registry.register(plugin);
|
|
329
|
+
}
|
|
330
|
+
this.index = index;
|
|
331
|
+
this.previousIndex = index;
|
|
332
|
+
this.initialIndex = index;
|
|
333
|
+
this.group = group;
|
|
334
|
+
this.type = type;
|
|
335
|
+
this.transition = transition;
|
|
336
|
+
const { destroy } = this;
|
|
337
|
+
const unsubscribe = this.manager.monitor.addEventListener(
|
|
338
|
+
"dragstart",
|
|
339
|
+
() => {
|
|
340
|
+
this.initialIndex = this.index;
|
|
341
|
+
this.previousIndex = this.index;
|
|
342
|
+
}
|
|
343
|
+
);
|
|
344
|
+
const cleanup = state.effects(
|
|
345
|
+
() => {
|
|
346
|
+
const { index: index2, previousIndex } = this;
|
|
347
|
+
if (index2 === previousIndex) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
this.previousIndex = index2;
|
|
351
|
+
this.animate();
|
|
352
|
+
},
|
|
353
|
+
() => {
|
|
354
|
+
const { target } = this;
|
|
355
|
+
const { feedback, isDragSource } = this.draggable;
|
|
356
|
+
if (feedback == "move" && isDragSource) {
|
|
357
|
+
this.droppable.disabled = !target;
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
() => {
|
|
361
|
+
const { element } = this;
|
|
362
|
+
this.droppable.element = element;
|
|
363
|
+
this.draggable.element = element;
|
|
364
|
+
},
|
|
365
|
+
() => {
|
|
366
|
+
const { target } = this;
|
|
367
|
+
const element = state.untracked(() => this.element);
|
|
368
|
+
this.droppable.element = !target && element ? element : target;
|
|
369
|
+
},
|
|
370
|
+
() => {
|
|
371
|
+
const { source } = this;
|
|
372
|
+
const element = state.untracked(() => this.element);
|
|
373
|
+
this.draggable.element = !source && element ? element : source;
|
|
374
|
+
},
|
|
375
|
+
...inputEffects?.(this) ?? []
|
|
376
|
+
);
|
|
377
|
+
this.destroy = () => {
|
|
378
|
+
destroy.bind(this)();
|
|
379
|
+
unsubscribe();
|
|
380
|
+
cleanup();
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
animate() {
|
|
384
|
+
state.untracked(() => {
|
|
385
|
+
const { manager, transition } = this;
|
|
386
|
+
const { shape } = this.droppable;
|
|
387
|
+
const { idle } = manager.dragOperation.status;
|
|
388
|
+
if (!shape || !transition || idle && !transition.idle) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
utilities.scheduler.schedule(() => {
|
|
392
|
+
const { element } = this.droppable;
|
|
393
|
+
if (!element) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
this.refreshShape();
|
|
397
|
+
const updatedShape = this.droppable.shape;
|
|
398
|
+
if (!updatedShape) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
const delta = {
|
|
402
|
+
x: shape.boundingRectangle.left - updatedShape.boundingRectangle.left,
|
|
403
|
+
y: shape.boundingRectangle.top - updatedShape.boundingRectangle.top
|
|
404
|
+
};
|
|
405
|
+
if (delta.x || delta.y) {
|
|
406
|
+
utilities.animateTransform({
|
|
407
|
+
element,
|
|
408
|
+
keyframes: {
|
|
409
|
+
translate: [`${delta.x}px ${delta.y}px 0`, "0px 0px 0"]
|
|
410
|
+
},
|
|
411
|
+
options: transition,
|
|
412
|
+
onFinish: () => {
|
|
413
|
+
if (idle) {
|
|
414
|
+
this.droppable.shape = void 0;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
get disabled() {
|
|
423
|
+
return this.draggable.disabled && this.droppable.disabled;
|
|
424
|
+
}
|
|
425
|
+
set feedback(value) {
|
|
426
|
+
this.draggable.feedback = value;
|
|
427
|
+
}
|
|
428
|
+
set disabled(value) {
|
|
429
|
+
state.batch(() => {
|
|
430
|
+
this.draggable.disabled = value;
|
|
431
|
+
this.droppable.disabled = value;
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
set data(data) {
|
|
435
|
+
state.batch(() => {
|
|
436
|
+
this.draggable.data = data;
|
|
437
|
+
this.droppable.data = data;
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
set handle(handle) {
|
|
441
|
+
this.draggable.handle = handle;
|
|
442
|
+
}
|
|
443
|
+
set id(id) {
|
|
444
|
+
state.batch(() => {
|
|
445
|
+
this.draggable.id = id;
|
|
446
|
+
this.droppable.id = id;
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
set sensors(value) {
|
|
450
|
+
this.draggable.sensors = value;
|
|
451
|
+
}
|
|
452
|
+
set collisionPriority(value) {
|
|
453
|
+
this.droppable.collisionPriority = value ?? abstract.CollisionPriority.Normal;
|
|
454
|
+
}
|
|
455
|
+
set collisionDetector(value) {
|
|
456
|
+
this.droppable.collisionDetector = value ?? collision.defaultCollisionDetection;
|
|
457
|
+
}
|
|
458
|
+
set type(type) {
|
|
459
|
+
this.draggable.type = type;
|
|
460
|
+
this.droppable.type = type;
|
|
461
|
+
}
|
|
462
|
+
get type() {
|
|
463
|
+
return this.draggable.type;
|
|
464
|
+
}
|
|
465
|
+
set accept(value) {
|
|
466
|
+
this.droppable.accept = value;
|
|
467
|
+
}
|
|
468
|
+
get accept() {
|
|
469
|
+
return this.droppable.accept;
|
|
470
|
+
}
|
|
471
|
+
get isDropTarget() {
|
|
472
|
+
return this.droppable.isDropTarget;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* A boolean indicating whether the sortable item is the source of a drag operation.
|
|
476
|
+
*/
|
|
477
|
+
get isDragSource() {
|
|
478
|
+
return this.draggable.isDragSource;
|
|
479
|
+
}
|
|
480
|
+
refreshShape(ignoreTransforms = true) {
|
|
481
|
+
this.droppable.refreshShape(ignoreTransforms);
|
|
482
|
+
}
|
|
483
|
+
accepts(draggable) {
|
|
484
|
+
return this.droppable.accepts(draggable);
|
|
485
|
+
}
|
|
486
|
+
destroy() {
|
|
487
|
+
this.draggable.destroy();
|
|
488
|
+
this.droppable.destroy();
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
__decorateClass([
|
|
492
|
+
state.reactive
|
|
493
|
+
], Sortable2.prototype, "index");
|
|
494
|
+
__decorateClass([
|
|
495
|
+
state.reactive
|
|
496
|
+
], Sortable2.prototype, "group");
|
|
497
|
+
__decorateClass([
|
|
498
|
+
state.reactive
|
|
499
|
+
], Sortable2.prototype, "element");
|
|
500
|
+
__decorateClass([
|
|
501
|
+
state.reactive
|
|
502
|
+
], Sortable2.prototype, "source");
|
|
503
|
+
__decorateClass([
|
|
504
|
+
state.reactive
|
|
505
|
+
], Sortable2.prototype, "target");
|
|
506
|
+
var SortableDraggable = class extends dom.Draggable {
|
|
507
|
+
constructor(input, manager, sortable) {
|
|
508
|
+
super(input, manager);
|
|
509
|
+
this.sortable = sortable;
|
|
510
|
+
}
|
|
511
|
+
get index() {
|
|
512
|
+
return this.sortable.index;
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
var SortableDroppable = class extends dom.Droppable {
|
|
516
|
+
constructor(input, manager, sortable) {
|
|
517
|
+
super(input, manager);
|
|
518
|
+
this.sortable = sortable;
|
|
519
|
+
}
|
|
520
|
+
refreshShape(ignoreTransforms = true) {
|
|
521
|
+
return super.refreshShape(ignoreTransforms);
|
|
522
|
+
}
|
|
523
|
+
get index() {
|
|
524
|
+
return this.sortable.index;
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
exports.Sortable = Sortable2;
|
|
529
|
+
exports.defaultSortableTransition = defaultSortableTransition;
|
|
530
|
+
//# sourceMappingURL=out.js.map
|
|
531
|
+
//# sourceMappingURL=sortable.cjs.map
|
package/sortable.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["src/sortable/sortable.ts","src/sortable/SortableKeyboardPlugin.ts","src/sortable/utilities.ts","src/sortable/OptimisticSortingPlugin.ts","../helpers/dist/index.js"],"names":["batch","scheduler","manager","id","source","Plugin","Sortable","index"],"mappings":";;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BAAN,cAAgD,UAAa;AAAA,EAClE,YACE,OACA,SACO,UACP;AACA,UAAM,OAAO,OAAO;AAFb;AAAA,EAGT;AAAA,EAEA,IAAW,QAAQ;AACjB,WAAO,KAAK,SAAS;AAAA,EACvB;AACF;AAEO,IAAM,oBAAN,cAAgD,UAAa;AAAA,EAClE,YACE,OACA,SACO,UACP;AACA,UAAM,OAAO,OAAO;AAFb;AAAA,EAGT;AAAA,EAEO,aAAa,mBAAmB,MAAyB;AAC9D,WAAO,MAAM,aAAa,gBAAgB;AAAA,EAC5C;AAAA,EAEA,IAAW,QAAQ;AACjB,WAAO,KAAK,SAAS;AAAA,EACvB;AACF","sourcesContent":["import {batch, effects, reactive, untracked, type Effect} from '@dnd-kit/state';\nimport {CollisionPriority} from '@dnd-kit/abstract';\nimport type {\n Data,\n PluginConstructor,\n Type,\n UniqueIdentifier,\n} from '@dnd-kit/abstract';\nimport {\n defaultCollisionDetection,\n type CollisionDetector,\n} from '@dnd-kit/collision';\nimport {Draggable, Droppable} from '@dnd-kit/dom';\nimport type {\n DraggableInput,\n FeedbackType,\n DroppableInput,\n Sensors,\n DragDropManager,\n} from '@dnd-kit/dom';\nimport {animateTransform, scheduler} from '@dnd-kit/dom/utilities';\nimport {Shape} from '@dnd-kit/geometry';\n\nimport {SortableKeyboardPlugin} from './SortableKeyboardPlugin.js';\nimport {OptimisticSortingPlugin} from './OptimisticSortingPlugin.js';\n\nexport interface SortableTransition {\n /**\n * The duration of the transition in milliseconds.\n * @default 300\n */\n duration?: number;\n /**\n * The easing function to use for the transition.\n * @default 'cubic-bezier(0.25, 1, 0.5, 1)'\n */\n easing?: string;\n /**\n * Whether the sortable item should transition when its index changes,\n * but there is no drag operation in progress.\n * @default false\n **/\n idle?: boolean;\n}\n\nconst defaultPlugins: PluginConstructor[] = [\n SortableKeyboardPlugin,\n OptimisticSortingPlugin,\n];\n\nexport interface SortableInput<T extends Data>\n extends Omit<DraggableInput<T>, 'effects'>,\n Omit<DroppableInput<T>, 'effects'> {\n /**\n * The index of the sortable item within its group.\n */\n index: number;\n /**\n * The optional unique identifier of the group that the sortable item belongs to.\n */\n group?: UniqueIdentifier;\n /**\n * The transition configuration to use when the index of the sortable item changes.\n */\n transition?: SortableTransition | null;\n /**\n * Additional effects to set up when sortable item is instantiated.\n */\n effects?: (instance: Sortable<T>) => Effect[];\n /**\n * Plugins to register when sortable item is instantiated.\n * @default [SortableKeyboardPlugin, OptimisticSortingPlugin]\n */\n plugins?: PluginConstructor[];\n}\n\nexport const defaultSortableTransition: SortableTransition = {\n duration: 250,\n easing: 'cubic-bezier(0.25, 1, 0.5, 1)',\n idle: false,\n};\n\nexport class Sortable<T extends Data = Data> {\n public draggable: Draggable<T>;\n public droppable: Droppable<T>;\n\n @reactive\n index: number;\n\n previousIndex: number;\n\n initialIndex: number;\n\n @reactive\n group: UniqueIdentifier | undefined;\n\n @reactive\n element: Element | undefined;\n\n @reactive\n source: Element | undefined;\n\n @reactive\n target: Element | undefined;\n\n transition: SortableTransition | null;\n\n constructor(\n {\n effects: inputEffects,\n group,\n index,\n sensors,\n type,\n transition = defaultSortableTransition,\n plugins = defaultPlugins,\n ...input\n }: SortableInput<T>,\n public manager: DragDropManager<any, any>\n ) {\n this.draggable = new SortableDraggable<T>(\n {...input, type, sensors},\n manager,\n this\n );\n this.droppable = new SortableDroppable<T>(input, manager, this);\n\n for (const plugin of plugins) {\n manager.registry.register(plugin);\n }\n\n this.index = index;\n this.previousIndex = index;\n this.initialIndex = index;\n this.group = group;\n this.type = type;\n this.transition = transition;\n\n const {destroy} = this;\n\n const unsubscribe = this.manager.monitor.addEventListener(\n 'dragstart',\n () => {\n this.initialIndex = this.index;\n this.previousIndex = this.index;\n }\n );\n\n const cleanup = effects(\n () => {\n const {index, previousIndex} = this;\n\n // Re-run this effect whenever the index changes\n if (index === previousIndex) {\n return;\n }\n\n this.previousIndex = index;\n\n this.animate();\n },\n () => {\n const {target} = this;\n const {feedback, isDragSource} = this.draggable;\n\n if (feedback == 'move' && isDragSource) {\n this.droppable.disabled = !target;\n }\n },\n () => {\n const {element} = this;\n\n this.droppable.element = element;\n this.draggable.element = element;\n },\n () => {\n const {target} = this;\n const element = untracked(() => this.element);\n\n this.droppable.element = !target && element ? element : target;\n },\n () => {\n const {source} = this;\n const element = untracked(() => this.element);\n\n this.draggable.element = !source && element ? element : source;\n },\n ...(inputEffects?.(this) ?? [])\n );\n\n this.destroy = () => {\n destroy.bind(this)();\n unsubscribe();\n cleanup();\n };\n }\n\n protected animate() {\n untracked(() => {\n const {manager, transition} = this;\n const {shape} = this.droppable;\n const {idle} = manager.dragOperation.status;\n\n if (!shape || !transition || (idle && !transition.idle)) {\n return;\n }\n\n scheduler.schedule(() => {\n const {element} = this.droppable;\n\n if (!element) {\n return;\n }\n\n this.refreshShape();\n\n const updatedShape = this.droppable.shape;\n\n if (!updatedShape) {\n return;\n }\n\n const delta = {\n x: shape.boundingRectangle.left - updatedShape.boundingRectangle.left,\n y: shape.boundingRectangle.top - updatedShape.boundingRectangle.top,\n };\n\n if (delta.x || delta.y) {\n animateTransform({\n element,\n keyframes: {\n translate: [`${delta.x}px ${delta.y}px 0`, '0px 0px 0'],\n },\n options: transition,\n onFinish: () => {\n if (idle) {\n this.droppable.shape = undefined;\n }\n },\n });\n }\n });\n });\n }\n\n public get disabled() {\n return this.draggable.disabled && this.droppable.disabled;\n }\n\n public set feedback(value: FeedbackType) {\n this.draggable.feedback = value;\n }\n\n public set disabled(value: boolean) {\n batch(() => {\n this.draggable.disabled = value;\n this.droppable.disabled = value;\n });\n }\n\n public set data(data: T | null) {\n batch(() => {\n this.draggable.data = data;\n this.droppable.data = data;\n });\n }\n\n public set handle(handle: Element | undefined) {\n this.draggable.handle = handle;\n }\n\n public set id(id: UniqueIdentifier) {\n batch(() => {\n this.draggable.id = id;\n this.droppable.id = id;\n });\n }\n\n public set sensors(value: Sensors | undefined) {\n this.draggable.sensors = value;\n }\n\n public set collisionPriority(value: CollisionPriority | number | undefined) {\n this.droppable.collisionPriority = value ?? CollisionPriority.Normal;\n }\n\n public set collisionDetector(value: CollisionDetector | undefined) {\n this.droppable.collisionDetector = value ?? defaultCollisionDetection;\n }\n\n public set type(type: Type | undefined) {\n this.draggable.type = type;\n this.droppable.type = type;\n }\n\n public get type() {\n return this.draggable.type;\n }\n\n public set accept(value: Droppable['accept']) {\n this.droppable.accept = value;\n }\n\n public get accept() {\n return this.droppable.accept;\n }\n\n public get isDropTarget() {\n return this.droppable.isDropTarget;\n }\n\n /**\n * A boolean indicating whether the sortable item is the source of a drag operation.\n */\n public get isDragSource() {\n return this.draggable.isDragSource;\n }\n\n public refreshShape(ignoreTransforms = true) {\n this.droppable.refreshShape(ignoreTransforms);\n }\n\n public accepts(draggable: Draggable): boolean {\n return this.droppable.accepts(draggable);\n }\n\n public destroy() {\n this.draggable.destroy();\n this.droppable.destroy();\n }\n}\n\nexport class SortableDraggable<T extends Data> extends Draggable<T> {\n constructor(\n input: DraggableInput<T>,\n manager: DragDropManager,\n public sortable: Sortable<T>\n ) {\n super(input, manager);\n }\n\n public get index() {\n return this.sortable.index;\n }\n}\n\nexport class SortableDroppable<T extends Data> extends Droppable<T> {\n constructor(\n input: DraggableInput<T>,\n manager: DragDropManager,\n public sortable: Sortable<T>\n ) {\n super(input, manager);\n }\n\n public refreshShape(ignoreTransforms = true): Shape | undefined {\n return super.refreshShape(ignoreTransforms);\n }\n\n public get index() {\n return this.sortable.index;\n }\n}\n","import {effect} from '@dnd-kit/state';\nimport {Plugin} from '@dnd-kit/abstract';\nimport {closestCenter} from '@dnd-kit/collision';\nimport {\n isKeyboardEvent,\n scheduler,\n scrollIntoViewIfNeeded,\n} from '@dnd-kit/dom/utilities';\nimport type {Coordinates} from '@dnd-kit/geometry';\n\nimport {Scroller} from '@dnd-kit/dom';\nimport type {DragDropManager, Droppable} from '@dnd-kit/dom';\n\nimport {isSortable} from './utilities.js';\n\nconst TOLERANCE = 10;\n\nexport class SortableKeyboardPlugin extends Plugin<DragDropManager> {\n constructor(manager: DragDropManager) {\n super(manager);\n\n const cleanupEffect = effect(() => {\n const {dragOperation} = manager;\n\n if (!isKeyboardEvent(dragOperation.activatorEvent)) {\n return;\n }\n\n if (!isSortable(dragOperation.source)) {\n return;\n }\n\n if (dragOperation.status.initialized) {\n const scroller = manager.registry.plugins.get(Scroller);\n\n if (scroller) {\n scroller.disable();\n\n return () => scroller.enable();\n }\n }\n });\n\n const unsubscribe = manager.monitor.addEventListener(\n 'dragmove',\n (event, manager) => {\n queueMicrotask(() => {\n if (this.disabled || event.defaultPrevented) {\n return;\n }\n\n const {dragOperation} = manager;\n\n if (!isKeyboardEvent(dragOperation.activatorEvent)) {\n return;\n }\n\n if (!isSortable(dragOperation.source)) {\n return;\n }\n\n if (!dragOperation.shape) {\n return;\n }\n\n const {actions, collisionObserver, registry} = manager;\n const {by} = event;\n\n if (!by) {\n return;\n }\n\n const direction = getDirection(by);\n const {source} = dragOperation;\n const {center} = dragOperation.shape.current;\n const potentialTargets: Droppable[] = [];\n\n for (const droppable of registry.droppables) {\n const {shape, id} = droppable;\n\n if (\n !shape ||\n (id === source?.id && isSortable(droppable)) ||\n (source?.type != null && !droppable.accepts(source))\n ) {\n continue;\n }\n\n switch (direction) {\n case 'down':\n if (center.y + TOLERANCE < shape.center.y) {\n potentialTargets.push(droppable);\n }\n break;\n case 'up':\n if (center.y - TOLERANCE > shape.center.y) {\n potentialTargets.push(droppable);\n }\n break;\n case 'left':\n if (center.x - TOLERANCE > shape.center.x) {\n potentialTargets.push(droppable);\n }\n break;\n case 'right':\n if (center.x + TOLERANCE < shape.center.x) {\n potentialTargets.push(droppable);\n }\n break;\n }\n }\n\n event.preventDefault();\n collisionObserver.disable();\n\n const collisions = collisionObserver.computeCollisions(\n potentialTargets,\n closestCenter\n );\n const [firstCollision] = collisions;\n\n if (!firstCollision) {\n return;\n }\n\n const {id} = firstCollision;\n\n actions.setDropTarget(id).then(() => {\n const {source} = dragOperation;\n\n if (!source) {\n return;\n }\n\n const droppable = registry.droppables.get(source.id);\n\n if (!droppable?.element) {\n return;\n }\n\n const {element} = droppable;\n scrollIntoViewIfNeeded(element);\n\n scheduler.schedule(() => {\n const shape = droppable.refreshShape();\n\n if (!shape) {\n return;\n }\n\n actions.move({\n to: {\n x: shape.center.x,\n y: shape.center.y,\n },\n });\n\n actions.setDropTarget(source.id).then(() => {\n dragOperation.shape = shape;\n collisionObserver.enable();\n });\n });\n });\n });\n }\n );\n\n this.destroy = () => {\n unsubscribe();\n cleanupEffect();\n };\n }\n}\n\nfunction getDirection(delta: Coordinates) {\n const {x, y} = delta;\n\n if (x > 0) {\n return 'right';\n } else if (x < 0) {\n return 'left';\n } else if (y > 0) {\n return 'down';\n } else if (y < 0) {\n return 'up';\n }\n}\n","import type {Droppable, Draggable} from '@dnd-kit/dom';\n\nimport {SortableDroppable, SortableDraggable} from './sortable.js';\n\nexport function isSortable(\n element: Draggable | Droppable | null\n): element is SortableDroppable<any> | SortableDraggable<any> {\n return (\n element instanceof SortableDroppable || element instanceof SortableDraggable\n );\n}\n","import {Plugin, UniqueIdentifier} from '@dnd-kit/abstract';\nimport type {DragDropManager} from '@dnd-kit/dom';\nimport {arrayMove} from '@dnd-kit/helpers';\n\nimport {isSortable} from './utilities.js';\nimport {Sortable, SortableDroppable} from './sortable.js';\nimport {batch} from '@dnd-kit/state';\n\nexport class OptimisticSortingPlugin extends Plugin<DragDropManager> {\n constructor(manager: DragDropManager) {\n super(manager);\n\n const getSortableInstances = (group: UniqueIdentifier | undefined) => {\n const sortableInstances = new Map<number, Sortable>();\n\n for (const droppable of manager.registry.droppables) {\n if (droppable instanceof SortableDroppable) {\n const {sortable} = droppable;\n\n if (sortable.group !== group) {\n continue;\n }\n\n if (sortableInstances.has(sortable.index)) {\n throw new Error(\n 'Duplicate sortable index found for same sortable group. Make sure each sortable item has a unique index. Use the `group` attribute to separate sortables into different groups.'\n );\n }\n\n sortableInstances.set(sortable.index, sortable);\n }\n }\n\n return sortableInstances;\n };\n\n const unsubscribe = [\n manager.monitor.addEventListener('dragover', (event, manager) => {\n queueMicrotask(() => {\n if (this.disabled || event.defaultPrevented) {\n return;\n }\n\n const {dragOperation} = manager;\n const {source, target} = dragOperation;\n\n if (!isSortable(source) || !isSortable(target)) {\n return;\n }\n\n if (source.sortable === target.sortable) {\n return;\n }\n\n if (source.sortable.group !== target.sortable.group) {\n return;\n }\n\n const sortableInstances = getSortableInstances(source.sortable.group);\n\n // Wait for the renderer to handle the event before attempting to optimistically update\n manager.renderer.rendering.then(() => {\n for (const [index, sortable] of sortableInstances.entries()) {\n if (sortable.index !== index) {\n // At least one index was changed so we should abort optimistic updates\n return;\n }\n }\n\n const orderedSortables = Array.from(\n sortableInstances.values()\n ).sort((a, b) => a.index - b.index);\n const newOrder = arrayMove(\n orderedSortables,\n source.sortable.index,\n target.sortable.index\n );\n\n const sourceElement = source.sortable.droppable.element;\n const targetElement = target.element;\n\n if (!targetElement || !sourceElement) {\n return;\n }\n\n reorder(\n sourceElement,\n source.sortable.index,\n targetElement,\n target.sortable.index\n );\n\n const position =\n target.sortable.index < source.sortable.index\n ? 'beforebegin'\n : 'afterend';\n\n targetElement.insertAdjacentElement(position, sourceElement);\n\n batch(() => {\n for (const [index, sortable] of newOrder.entries()) {\n sortable.index = index;\n }\n });\n });\n });\n }),\n manager.monitor.addEventListener('dragend', (event, manager) => {\n if (!event.canceled) {\n return;\n }\n\n const {dragOperation} = manager;\n const {source} = dragOperation;\n\n if (!isSortable(source)) {\n return;\n }\n\n if (source.sortable.initialIndex === source.sortable.index) {\n return;\n }\n\n queueMicrotask(() => {\n const sortableInstances = getSortableInstances(source.sortable.group);\n\n // Wait for the renderer to handle the event before attempting to optimistically update\n manager.renderer.rendering.then(() => {\n for (const [index, sortable] of sortableInstances.entries()) {\n if (sortable.index !== index) {\n // At least one index was changed so we should abort optimistic updates\n return;\n }\n }\n\n const orderedSortables = Array.from(\n sortableInstances.values()\n ).sort((a, b) => a.index - b.index);\n\n const sourceElement = source.sortable.droppable.element;\n const targetElement =\n orderedSortables[source.sortable.initialIndex].element;\n\n if (!targetElement || !sourceElement) {\n return;\n }\n\n reorder(\n sourceElement,\n source.sortable.index,\n targetElement,\n source.sortable.initialIndex\n );\n\n batch(() => {\n for (const sortable of orderedSortables.values()) {\n sortable.index = sortable.initialIndex;\n }\n });\n });\n });\n }),\n ];\n\n this.destroy = () => {\n for (const unsubscribeListener of unsubscribe) {\n unsubscribeListener();\n }\n };\n }\n}\n\nfunction reorder(\n sourceElement: Element,\n sourceIndex: number,\n targetElement: Element,\n targetIndex: number\n) {\n const position = targetIndex < sourceIndex ? 'beforebegin' : 'afterend';\n\n targetElement.insertAdjacentElement(position, sourceElement);\n}\n","var __defProp = Object.defineProperty;\nvar __defProps = Object.defineProperties;\nvar __getOwnPropDescs = Object.getOwnPropertyDescriptors;\nvar __getOwnPropSymbols = Object.getOwnPropertySymbols;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __propIsEnum = Object.prototype.propertyIsEnumerable;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __spreadValues = (a, b) => {\n for (var prop in b || (b = {}))\n if (__hasOwnProp.call(b, prop))\n __defNormalProp(a, prop, b[prop]);\n if (__getOwnPropSymbols)\n for (var prop of __getOwnPropSymbols(b)) {\n if (__propIsEnum.call(b, prop))\n __defNormalProp(a, prop, b[prop]);\n }\n return a;\n};\nvar __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));\n\n// src/move.ts\nfunction arrayMove(array, from, to) {\n if (from === to) {\n return array;\n }\n const newArray = array.slice();\n newArray.splice(to, 0, newArray.splice(from, 1)[0]);\n return newArray;\n}\nfunction arraySwap(array, from, to) {\n if (from === to) {\n return array;\n }\n const newArray = array.slice();\n const item = newArray[from];\n newArray[from] = newArray[to];\n newArray[to] = item;\n return newArray;\n}\nfunction mutate(items, source, target, mutation) {\n if (!source || !target) {\n return items;\n }\n const findIndex = (item, id) => item === id || typeof item === \"object\" && \"id\" in item && item.id === id;\n if (Array.isArray(items)) {\n const sourceIndex2 = items.findIndex((item) => findIndex(item, source.id));\n const targetIndex2 = items.findIndex((item) => findIndex(item, target.id));\n if (sourceIndex2 === -1 || targetIndex2 === -1) {\n return items;\n }\n const { dragOperation: dragOperation2 } = source.manager;\n if (!dragOperation2.canceled && \"index\" in source && typeof source.index === \"number\") {\n const projectedSourceIndex = source.index;\n if (projectedSourceIndex !== sourceIndex2) {\n return mutation(items, sourceIndex2, projectedSourceIndex);\n }\n }\n return mutation(items, sourceIndex2, targetIndex2);\n }\n if (source.id === target.id) {\n return items;\n }\n const entries = Object.entries(items);\n let sourceIndex = -1;\n let sourceParent;\n let targetIndex = -1;\n let targetParent;\n for (const [id, children] of entries) {\n if (sourceIndex === -1) {\n sourceIndex = children.findIndex((item) => findIndex(item, source.id));\n if (sourceIndex !== -1) {\n sourceParent = id;\n }\n }\n if (targetIndex === -1) {\n targetIndex = children.findIndex((item) => findIndex(item, target.id));\n if (targetIndex !== -1) {\n targetParent = id;\n }\n }\n if (sourceIndex !== -1 && targetIndex !== -1) {\n break;\n }\n }\n const { dragOperation } = source.manager;\n const position = dragOperation.position.current;\n if (targetParent == null) {\n if (target.id in items) {\n const insertionIndex = target.shape && position.y > target.shape.center.y ? items[target.id].length : 0;\n targetParent = target.id;\n targetIndex = insertionIndex;\n }\n }\n if (sourceParent == null || targetParent == null) {\n return items;\n }\n if (sourceParent === targetParent) {\n return __spreadProps(__spreadValues({}, items), {\n [sourceParent]: mutation(items[sourceParent], sourceIndex, targetIndex)\n });\n }\n const isBelowTarget = target.shape && position.y > target.shape.boundingRectangle.bottom;\n const modifier = isBelowTarget ? 1 : 0;\n const sourceItem = items[sourceParent][sourceIndex];\n return __spreadProps(__spreadValues({}, items), {\n [sourceParent]: [\n ...items[sourceParent].slice(0, sourceIndex),\n ...items[sourceParent].slice(sourceIndex + 1)\n ],\n [targetParent]: [\n ...items[targetParent].slice(0, targetIndex + modifier),\n sourceItem,\n ...items[targetParent].slice(targetIndex + modifier)\n ]\n });\n}\nfunction move(items, source, target) {\n return mutate(items, source, target, arrayMove);\n}\nfunction swap(items, source, target) {\n return mutate(items, source, target, arraySwap);\n}\nexport {\n arrayMove,\n arraySwap,\n move,\n swap\n};\n"]}
|
package/sortable.d.cts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Effect } from '@dnd-kit/state';
|
|
2
|
+
import { Data, UniqueIdentifier, PluginConstructor, CollisionPriority, Type } from '@dnd-kit/abstract';
|
|
3
|
+
import { CollisionDetector } from '@dnd-kit/collision';
|
|
4
|
+
import { DraggableInput, DroppableInput, DragDropManager, Draggable, Droppable, FeedbackType, Sensors } from '@dnd-kit/dom';
|
|
5
|
+
|
|
6
|
+
interface SortableTransition {
|
|
7
|
+
/**
|
|
8
|
+
* The duration of the transition in milliseconds.
|
|
9
|
+
* @default 300
|
|
10
|
+
*/
|
|
11
|
+
duration?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The easing function to use for the transition.
|
|
14
|
+
* @default 'cubic-bezier(0.25, 1, 0.5, 1)'
|
|
15
|
+
*/
|
|
16
|
+
easing?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the sortable item should transition when its index changes,
|
|
19
|
+
* but there is no drag operation in progress.
|
|
20
|
+
* @default false
|
|
21
|
+
**/
|
|
22
|
+
idle?: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface SortableInput<T extends Data> extends Omit<DraggableInput<T>, 'effects'>, Omit<DroppableInput<T>, 'effects'> {
|
|
25
|
+
/**
|
|
26
|
+
* The index of the sortable item within its group.
|
|
27
|
+
*/
|
|
28
|
+
index: number;
|
|
29
|
+
/**
|
|
30
|
+
* The optional unique identifier of the group that the sortable item belongs to.
|
|
31
|
+
*/
|
|
32
|
+
group?: UniqueIdentifier;
|
|
33
|
+
/**
|
|
34
|
+
* The transition configuration to use when the index of the sortable item changes.
|
|
35
|
+
*/
|
|
36
|
+
transition?: SortableTransition | null;
|
|
37
|
+
/**
|
|
38
|
+
* Additional effects to set up when sortable item is instantiated.
|
|
39
|
+
*/
|
|
40
|
+
effects?: (instance: Sortable<T>) => Effect[];
|
|
41
|
+
/**
|
|
42
|
+
* Plugins to register when sortable item is instantiated.
|
|
43
|
+
* @default [SortableKeyboardPlugin, OptimisticSortingPlugin]
|
|
44
|
+
*/
|
|
45
|
+
plugins?: PluginConstructor[];
|
|
46
|
+
}
|
|
47
|
+
declare const defaultSortableTransition: SortableTransition;
|
|
48
|
+
declare class Sortable<T extends Data = Data> {
|
|
49
|
+
manager: DragDropManager<any, any>;
|
|
50
|
+
draggable: Draggable<T>;
|
|
51
|
+
droppable: Droppable<T>;
|
|
52
|
+
index: number;
|
|
53
|
+
previousIndex: number;
|
|
54
|
+
initialIndex: number;
|
|
55
|
+
group: UniqueIdentifier | undefined;
|
|
56
|
+
element: Element | undefined;
|
|
57
|
+
source: Element | undefined;
|
|
58
|
+
target: Element | undefined;
|
|
59
|
+
transition: SortableTransition | null;
|
|
60
|
+
constructor({ effects: inputEffects, group, index, sensors, type, transition, plugins, ...input }: SortableInput<T>, manager: DragDropManager<any, any>);
|
|
61
|
+
protected animate(): void;
|
|
62
|
+
get disabled(): boolean;
|
|
63
|
+
set feedback(value: FeedbackType);
|
|
64
|
+
set disabled(value: boolean);
|
|
65
|
+
set data(data: T | null);
|
|
66
|
+
set handle(handle: Element | undefined);
|
|
67
|
+
set id(id: UniqueIdentifier);
|
|
68
|
+
set sensors(value: Sensors | undefined);
|
|
69
|
+
set collisionPriority(value: CollisionPriority | number | undefined);
|
|
70
|
+
set collisionDetector(value: CollisionDetector | undefined);
|
|
71
|
+
set type(type: Type | undefined);
|
|
72
|
+
get type(): Type | undefined;
|
|
73
|
+
set accept(value: Droppable['accept']);
|
|
74
|
+
get accept(): Droppable['accept'];
|
|
75
|
+
get isDropTarget(): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* A boolean indicating whether the sortable item is the source of a drag operation.
|
|
78
|
+
*/
|
|
79
|
+
get isDragSource(): boolean;
|
|
80
|
+
refreshShape(ignoreTransforms?: boolean): void;
|
|
81
|
+
accepts(draggable: Draggable): boolean;
|
|
82
|
+
destroy(): void;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { Sortable, type SortableInput, type SortableTransition, defaultSortableTransition };
|