@vuu-ui/vuu-utils 4.0.1 → 5.0.0-alpha.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.
Files changed (134) hide show
  1. package/package.json +11 -12
  2. package/src/column-utils.js +16 -6
  3. package/src/component-registry.js +2 -2
  4. package/src/event-emitter.js +3 -1
  5. package/src/feature-utils.js +7 -7
  6. package/src/index.js +1 -0
  7. package/src/react-utils.js +2 -8
  8. package/src/table-schema-utils.js +5 -6
  9. package/src/tree-utils.js +2 -2
  10. package/src/vendor/@dnd-kit/abstract/index.d.ts +114 -32
  11. package/src/vendor/@dnd-kit/abstract/index.js +430 -280
  12. package/src/vendor/@dnd-kit/abstract/index.js.map +1 -1
  13. package/src/vendor/@dnd-kit/abstract/modifiers.d.ts +7 -7
  14. package/src/vendor/@dnd-kit/abstract/modifiers.js.map +1 -1
  15. package/src/vendor/@dnd-kit/abstract/package.json +8 -3
  16. package/src/vendor/@dnd-kit/collision/dist/index.js +10 -3
  17. package/src/vendor/@dnd-kit/collision/package.json +8 -3
  18. package/src/vendor/@dnd-kit/dom/index.d.ts +225 -126
  19. package/src/vendor/@dnd-kit/dom/index.js +998 -484
  20. package/src/vendor/@dnd-kit/dom/index.js.map +1 -1
  21. package/src/vendor/@dnd-kit/dom/modifiers.d.ts +1 -1
  22. package/src/vendor/@dnd-kit/dom/package.json +11 -5
  23. package/src/vendor/@dnd-kit/dom/plugins/debug.js +10 -7
  24. package/src/vendor/@dnd-kit/dom/plugins/debug.js.map +1 -1
  25. package/src/vendor/@dnd-kit/dom/sortable.d.ts +45 -11
  26. package/src/vendor/@dnd-kit/dom/sortable.js +203 -54
  27. package/src/vendor/@dnd-kit/dom/sortable.js.map +1 -1
  28. package/src/vendor/@dnd-kit/dom/utilities.d.ts +82 -10
  29. package/src/vendor/@dnd-kit/dom/utilities.js +249 -95
  30. package/src/vendor/@dnd-kit/dom/utilities.js.map +1 -1
  31. package/src/vendor/@dnd-kit/geometry/package.json +7 -2
  32. package/src/vendor/@dnd-kit/react/hooks.js +61 -38
  33. package/src/vendor/@dnd-kit/react/hooks.js.map +1 -0
  34. package/src/vendor/@dnd-kit/react/index.d.ts +18 -9
  35. package/src/vendor/@dnd-kit/react/index.js +100 -59
  36. package/src/vendor/@dnd-kit/react/index.js.map +1 -0
  37. package/src/vendor/@dnd-kit/react/package.json +17 -5
  38. package/src/vendor/@dnd-kit/react/sortable.d.ts +1 -1
  39. package/src/vendor/@dnd-kit/react/sortable.js +24 -10
  40. package/src/vendor/@dnd-kit/react/sortable.js.map +1 -0
  41. package/src/vendor/@dnd-kit/react/utilities.js.map +1 -0
  42. package/src/vendor/@dnd-kit/state/dist/index.js +1 -1
  43. package/src/vendor/@dnd-kit/state/package.json +6 -1
  44. package/src/vendor/@preact/signals-core/dist/signals-core.js +1 -1
  45. package/src/vendor/@preact/signals-core/dist/signals-core.js.map +1 -1
  46. package/types/ThemeProvider.d.ts +1 -1
  47. package/types/column-utils.d.ts +5 -3
  48. package/types/component-registry.d.ts +4 -4
  49. package/types/context-definitions/DataProvider.d.ts +1 -1
  50. package/types/context-definitions/DataSourceProvider.d.ts +1 -1
  51. package/types/feature-utils.d.ts +29 -19
  52. package/types/filters/filter-utils.d.ts +1 -0
  53. package/types/index.d.ts +1 -0
  54. package/types/react-utils.d.ts +1 -1
  55. package/types/sort-utils.d.ts +2 -2
  56. package/types/table-schema-utils.d.ts +2 -2
  57. package/types/tree-types.d.ts +5 -0
  58. package/types/src/Clock.d.ts +0 -20
  59. package/types/src/PageVisibilityObserver.d.ts +0 -36
  60. package/types/src/ScaledDecimal.d.ts +0 -12
  61. package/types/src/ShellContext.d.ts +0 -11
  62. package/types/src/ThemeProvider.d.ts +0 -32
  63. package/types/src/array-utils.d.ts +0 -16
  64. package/types/src/box-utils.d.ts +0 -24
  65. package/types/src/broadcast-channel.d.ts +0 -16
  66. package/types/src/column-utils.d.ts +0 -243
  67. package/types/src/common-types.d.ts +0 -6
  68. package/types/src/component-registry.d.ts +0 -65
  69. package/types/src/context-definitions/DataContext.d.ts +0 -21
  70. package/types/src/context-definitions/DataProvider.d.ts +0 -7
  71. package/types/src/context-definitions/DataSourceProvider.d.ts +0 -12
  72. package/types/src/context-definitions/WorkspaceContext.d.ts +0 -17
  73. package/types/src/cookie-utils.d.ts +0 -9
  74. package/types/src/css-utils.d.ts +0 -1
  75. package/types/src/data-utils.d.ts +0 -33
  76. package/types/src/datasource/BaseDataSource.d.ts +0 -63
  77. package/types/src/datasource/datasource-action-utils.d.ts +0 -7
  78. package/types/src/datasource/datasource-filter-utils.d.ts +0 -2
  79. package/types/src/datasource/datasource-utils.d.ts +0 -61
  80. package/types/src/date/date-utils.d.ts +0 -39
  81. package/types/src/date/dateTimePattern.d.ts +0 -8
  82. package/types/src/date/formatter.d.ts +0 -9
  83. package/types/src/date/index.d.ts +0 -4
  84. package/types/src/date/types.d.ts +0 -29
  85. package/types/src/debug-utils.d.ts +0 -9
  86. package/types/src/edit-utils.d.ts +0 -2
  87. package/types/src/errors.d.ts +0 -2
  88. package/types/src/event-emitter.d.ts +0 -21
  89. package/types/src/feature-utils.d.ts +0 -110
  90. package/types/src/filters/filter-utils.d.ts +0 -75
  91. package/types/src/filters/filterAsQuery.d.ts +0 -8
  92. package/types/src/filters/index.d.ts +0 -2
  93. package/types/src/form-utils.d.ts +0 -37
  94. package/types/src/formatting-utils.d.ts +0 -14
  95. package/types/src/getUniqueId.d.ts +0 -1
  96. package/types/src/group-utils.d.ts +0 -10
  97. package/types/src/html-utils.d.ts +0 -21
  98. package/types/src/index.d.ts +0 -76
  99. package/types/src/input-utils.d.ts +0 -2
  100. package/types/src/invariant.d.ts +0 -1
  101. package/types/src/itemToString.d.ts +0 -2
  102. package/types/src/json-types.d.ts +0 -52
  103. package/types/src/json-utils.d.ts +0 -6
  104. package/types/src/keyboard-utils.d.ts +0 -15
  105. package/types/src/keyset.d.ts +0 -16
  106. package/types/src/layout-types.d.ts +0 -22
  107. package/types/src/list-utils.d.ts +0 -2
  108. package/types/src/local-storage-utils.d.ts +0 -4
  109. package/types/src/logging-utils.d.ts +0 -45
  110. package/types/src/module-utils.d.ts +0 -8
  111. package/types/src/nanoid/index.d.ts +0 -1
  112. package/types/src/perf-utils.d.ts +0 -5
  113. package/types/src/promise-utils.d.ts +0 -8
  114. package/types/src/protocol-message-utils.d.ts +0 -43
  115. package/types/src/range-utils.d.ts +0 -29
  116. package/types/src/react-utils.d.ts +0 -15
  117. package/types/src/round-decimal.d.ts +0 -4
  118. package/types/src/row-utils.d.ts +0 -28
  119. package/types/src/selection-utils.d.ts +0 -9
  120. package/types/src/shell-layout-types.d.ts +0 -15
  121. package/types/src/sort-utils.d.ts +0 -11
  122. package/types/src/table-schema-utils.d.ts +0 -5
  123. package/types/src/text-utils.d.ts +0 -10
  124. package/types/src/theme-utils.d.ts +0 -14
  125. package/types/src/tree-types.d.ts +0 -9
  126. package/types/src/tree-utils.d.ts +0 -9
  127. package/types/src/ts-utils.d.ts +0 -20
  128. package/types/src/typeahead-utils.d.ts +0 -1
  129. package/types/src/url-utils.d.ts +0 -3
  130. package/types/src/useId.d.ts +0 -1
  131. package/types/src/useLayoutEffectSkipFirst.d.ts +0 -2
  132. package/types/src/useResizeObserver.d.ts +0 -15
  133. package/types/src/useStateRef.d.ts +0 -2
  134. package/types/src/user-types.d.ts +0 -3
@@ -1,8 +1,8 @@
1
1
  import { WeakStore, effect, batch, untracked, reactive } from '../state/dist/index.js';
2
+ import { Plugin, resolveCustomizable } from '../abstract/index.js';
2
3
  import { closestCorners, defaultCollisionDetection } from '../collision/dist/index.js';
3
- import { Scroller, Draggable, Droppable } from './index.js';
4
- import { isKeyboardEvent, DOMRectangle, getVisibleBoundingRectangle, scrollIntoViewIfNeeded, getComputedStyles, computeTranslate, animateTransform, ProxiedElements } from './utilities.js';
5
- import { Plugin } from '../abstract/index.js';
4
+ import { Scroller, Draggable, Droppable, Feedback } from './index.js';
5
+ import { isKeyboardEvent, DOMRectangle, getVisibleBoundingRectangle, scrollIntoViewIfNeeded, getComputedStyles, computeTranslate, prefersReducedMotion, getWindow, animateTransform, ProxiedElements } from './utilities.js';
6
6
  import { Rectangle } from '../geometry/dist/index.js';
7
7
 
8
8
  var __create = Object.create;
@@ -86,6 +86,9 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
86
86
  function isSortable(element) {
87
87
  return element instanceof SortableDroppable || element instanceof SortableDraggable;
88
88
  }
89
+ function isSortableOperation(operation) {
90
+ return isSortable(operation.source) && isSortable(operation.target);
91
+ }
89
92
 
90
93
  // src/sortable/plugins/SortableKeyboardPlugin.ts
91
94
  var TOLERANCE = 10;
@@ -248,6 +251,13 @@ function arrayMove(array, from, to) {
248
251
  newArray.splice(to, 0, newArray.splice(from, 1)[0]);
249
252
  return newArray;
250
253
  }
254
+ function getRecordKey(items, id) {
255
+ const key = String(id);
256
+ return Object.prototype.hasOwnProperty.call(items, key) ? key : void 0;
257
+ }
258
+ function hasSortableIndices(source) {
259
+ return "initialIndex" in source && typeof source.initialIndex === "number" && "index" in source && typeof source.index === "number";
260
+ }
251
261
  function mutate(items, event, mutation) {
252
262
  var _a, _b;
253
263
  const { source, target, canceled } = event.operation;
@@ -255,11 +265,20 @@ function mutate(items, event, mutation) {
255
265
  if ("preventDefault" in event) event.preventDefault();
256
266
  return items;
257
267
  }
258
- const findIndex = (item, id) => item === id || typeof item === "object" && "id" in item && item.id === id;
268
+ const findIndex = (item, id) => item === id || item !== null && typeof item === "object" && "id" in item && item.id === id;
259
269
  if (Array.isArray(items)) {
260
270
  const sourceIndex2 = items.findIndex((item) => findIndex(item, source.id));
261
271
  const targetIndex2 = items.findIndex((item) => findIndex(item, target.id));
262
272
  if (sourceIndex2 === -1 || targetIndex2 === -1) {
273
+ if (hasSortableIndices(source)) {
274
+ const from = source.initialIndex;
275
+ const to = source.index;
276
+ if (from === to || from < 0 || from >= items.length) {
277
+ if ("preventDefault" in event) event.preventDefault();
278
+ return items;
279
+ }
280
+ return mutation(items, from, to);
281
+ }
263
282
  return items;
264
283
  }
265
284
  if (!canceled && "index" in source && typeof source.index === "number") {
@@ -292,17 +311,80 @@ function mutate(items, event, mutation) {
292
311
  break;
293
312
  }
294
313
  }
314
+ if (sourceIndex === -1 && hasSortableIndices(source)) {
315
+ const srcParent = source.initialGroup == null ? void 0 : getRecordKey(items, source.initialGroup);
316
+ const srcIndex = source.initialIndex;
317
+ const tgtParent = source.group == null ? void 0 : getRecordKey(items, source.group);
318
+ const tgtIndex = source.index;
319
+ if (srcParent == null || tgtParent == null) {
320
+ if ("preventDefault" in event) event.preventDefault();
321
+ return items;
322
+ }
323
+ if (srcParent === tgtParent && srcIndex === tgtIndex) {
324
+ if ("preventDefault" in event) event.preventDefault();
325
+ return items;
326
+ }
327
+ if (srcParent === tgtParent) {
328
+ return __spreadProps2(__spreadValues2({}, items), {
329
+ [srcParent]: mutation(items[srcParent], srcIndex, tgtIndex)
330
+ });
331
+ }
332
+ const sourceItem2 = items[srcParent][srcIndex];
333
+ return __spreadProps2(__spreadValues2({}, items), {
334
+ [srcParent]: [
335
+ ...items[srcParent].slice(0, srcIndex),
336
+ ...items[srcParent].slice(srcIndex + 1)
337
+ ],
338
+ [tgtParent]: [
339
+ ...items[tgtParent].slice(0, tgtIndex),
340
+ sourceItem2,
341
+ ...items[tgtParent].slice(tgtIndex)
342
+ ]
343
+ });
344
+ }
295
345
  if (!source.manager) return items;
296
346
  const { dragOperation } = source.manager;
297
347
  const position = (_b = (_a = dragOperation.shape) == null ? void 0 : _a.current.center) != null ? _b : dragOperation.position.current;
298
348
  if (targetParent == null) {
299
- if (target.id in items) {
300
- const insertionIndex = target.shape && position.y > target.shape.center.y ? items[target.id].length : 0;
301
- targetParent = target.id;
349
+ const targetKey = getRecordKey(items, target.id);
350
+ if (targetKey != null) {
351
+ const insertionIndex = target.shape && position.y > target.shape.center.y ? items[targetKey].length : 0;
352
+ targetParent = targetKey;
302
353
  targetIndex = insertionIndex;
303
354
  }
304
355
  }
305
356
  if (sourceParent == null || targetParent == null || sourceParent === targetParent && sourceIndex === targetIndex) {
357
+ if (sourceParent != null && sourceParent === targetParent && sourceIndex === targetIndex && hasSortableIndices(source)) {
358
+ const sourceGroupParent = source.group == null ? void 0 : getRecordKey(items, source.group);
359
+ const hasGroupChanged = source.group != null && sourceGroupParent !== sourceParent;
360
+ const hasIndexChanged = source.index !== sourceIndex;
361
+ if (hasGroupChanged || hasIndexChanged) {
362
+ const reconciledTargetParent = source.group == null ? sourceParent : sourceGroupParent;
363
+ if (reconciledTargetParent != null) {
364
+ if (sourceParent === reconciledTargetParent) {
365
+ return __spreadProps2(__spreadValues2({}, items), {
366
+ [sourceParent]: mutation(
367
+ items[sourceParent],
368
+ sourceIndex,
369
+ source.index
370
+ )
371
+ });
372
+ }
373
+ const sourceItem2 = items[sourceParent][sourceIndex];
374
+ return __spreadProps2(__spreadValues2({}, items), {
375
+ [sourceParent]: [
376
+ ...items[sourceParent].slice(0, sourceIndex),
377
+ ...items[sourceParent].slice(sourceIndex + 1)
378
+ ],
379
+ [reconciledTargetParent]: [
380
+ ...items[reconciledTargetParent].slice(0, source.index),
381
+ sourceItem2,
382
+ ...items[reconciledTargetParent].slice(source.index)
383
+ ]
384
+ });
385
+ }
386
+ }
387
+ }
306
388
  if ("preventDefault" in event) event.preventDefault();
307
389
  return items;
308
390
  }
@@ -329,6 +411,31 @@ function mutate(items, event, mutation) {
329
411
  function move(items, event) {
330
412
  return mutate(items, event, arrayMove);
331
413
  }
414
+
415
+ // src/sortable/plugins/OptimisticSortingPlugin.helpers.ts
416
+ function getSortableIndices(instances) {
417
+ const sortableIndices = /* @__PURE__ */ new Map();
418
+ for (const [, group] of instances) {
419
+ for (const sortable of group) {
420
+ sortableIndices.set(sortable.id, sortable.index);
421
+ }
422
+ }
423
+ return sortableIndices;
424
+ }
425
+ function hasChanged(snapshotIndices, instances, newInstances) {
426
+ var _a;
427
+ for (const [group, sortables] of instances) {
428
+ for (const sortable of sortables) {
429
+ const index = snapshotIndices.get(sortable.id);
430
+ if (sortable.index !== index || sortable.group !== group || !((_a = newInstances.get(group)) == null ? void 0 : _a.has(sortable))) {
431
+ return true;
432
+ }
433
+ }
434
+ }
435
+ return false;
436
+ }
437
+
438
+ // src/sortable/plugins/OptimisticSortingPlugin.ts
332
439
  var defaultGroup = "__default__";
333
440
  var OptimisticSortingPlugin = class extends Plugin {
334
441
  constructor(manager) {
@@ -347,9 +454,6 @@ var OptimisticSortingPlugin = class extends Plugin {
347
454
  instances.add(sortable);
348
455
  }
349
456
  }
350
- for (const [group, instances] of sortableInstances) {
351
- sortableInstances.set(group, new Set(sort(instances)));
352
- }
353
457
  return sortableInstances;
354
458
  };
355
459
  const unsubscribe = [
@@ -366,6 +470,7 @@ var OptimisticSortingPlugin = class extends Plugin {
366
470
  return;
367
471
  }
368
472
  const instances = getSortableInstances();
473
+ const sortableIndices = getSortableIndices(instances);
369
474
  const sameGroup = source.sortable.group === target.sortable.group;
370
475
  const sourceInstances = instances.get(source.sortable.group);
371
476
  const targetInstances = sameGroup ? sourceInstances : instances.get(target.sortable.group);
@@ -373,15 +478,10 @@ var OptimisticSortingPlugin = class extends Plugin {
373
478
  queueMicrotask(() => {
374
479
  if (event.defaultPrevented) return;
375
480
  manager2.renderer.rendering.then(() => {
376
- var _a, _b, _c;
481
+ var _a, _b;
377
482
  const newInstances = getSortableInstances();
378
- for (const [group, sortableInstances] of instances.entries()) {
379
- const entries = Array.from(sortableInstances).entries();
380
- for (const [index, sortable] of entries) {
381
- if (sortable.index !== index || sortable.group !== group || !((_a = newInstances.get(group)) == null ? void 0 : _a.has(sortable))) {
382
- return;
383
- }
384
- }
483
+ if (hasChanged(sortableIndices, instances, newInstances)) {
484
+ return;
385
485
  }
386
486
  const sourceElement = source.sortable.element;
387
487
  const targetElement = target.sortable.element;
@@ -393,8 +493,8 @@ var OptimisticSortingPlugin = class extends Plugin {
393
493
  }
394
494
  const orderedSourceSortables = sort(sourceInstances);
395
495
  const orderedTargetSortables = sameGroup ? orderedSourceSortables : sort(targetInstances);
396
- const sourceGroup = (_b = source.sortable.group) != null ? _b : defaultGroup;
397
- const targetGroup = (_c = target.sortable.group) != null ? _c : defaultGroup;
496
+ const sourceGroup = (_a = source.sortable.group) != null ? _a : defaultGroup;
497
+ const targetGroup = (_b = target.sortable.group) != null ? _b : defaultGroup;
398
498
  const state = {
399
499
  [sourceGroup]: orderedSourceSortables,
400
500
  [targetGroup]: orderedTargetSortables
@@ -434,29 +534,31 @@ var OptimisticSortingPlugin = class extends Plugin {
434
534
  }
435
535
  queueMicrotask(() => {
436
536
  const instances = getSortableInstances();
537
+ const sortableIndices = getSortableIndices(instances);
437
538
  const initialGroupInstances = instances.get(
438
539
  source.sortable.initialGroup
439
540
  );
440
541
  if (!initialGroupInstances) return;
441
542
  manager2.renderer.rendering.then(() => {
442
- for (const [group, sortableInstances] of instances.entries()) {
443
- const entries = Array.from(sortableInstances).entries();
444
- for (const [index, sortable] of entries) {
445
- if (sortable.index !== index || sortable.group !== group) {
446
- return;
447
- }
448
- }
543
+ const newInstances = getSortableInstances();
544
+ if (hasChanged(sortableIndices, instances, newInstances)) {
545
+ return;
449
546
  }
450
- const initialGroup = sort(initialGroupInstances);
547
+ const currentSortables = sort(initialGroupInstances);
548
+ const initialSortables = sort(
549
+ initialGroupInstances,
550
+ sortByInitialIndex
551
+ );
451
552
  const sourceElement = source.sortable.element;
452
- const target = initialGroup[source.sortable.initialIndex];
553
+ const initialPosition = initialSortables.indexOf(source.sortable);
554
+ const target = currentSortables[initialPosition];
453
555
  const targetElement = target == null ? void 0 : target.element;
454
556
  if (!target || !targetElement || !sourceElement) {
455
557
  return;
456
558
  }
457
559
  reorder(sourceElement, target.index, targetElement, source.index);
458
560
  batch(() => {
459
- for (const [_, sortableInstances] of instances.entries()) {
561
+ for (const sortableInstances of instances.values()) {
460
562
  const entries = Array.from(sortableInstances).values();
461
563
  for (const sortable of entries) {
462
564
  sortable.index = sortable.initialIndex;
@@ -482,8 +584,11 @@ function reorder(sourceElement, sourceIndex, targetElement, targetIndex) {
482
584
  function sortByIndex(a, b) {
483
585
  return a.index - b.index;
484
586
  }
485
- function sort(instances) {
486
- return Array.from(instances).sort(sortByIndex);
587
+ function sortByInitialIndex(a, b) {
588
+ return a.initialIndex - b.initialIndex;
589
+ }
590
+ function sort(instances, sortFn = sortByIndex) {
591
+ return Array.from(instances).sort(sortFn);
487
592
  }
488
593
 
489
594
  // src/sortable/sortable.ts
@@ -496,6 +601,22 @@ var defaultSortableTransition = {
496
601
  easing: "cubic-bezier(0.25, 1, 0.5, 1)",
497
602
  idle: false
498
603
  };
604
+ function resolveSortableTransition(transition) {
605
+ return transition === null ? null : __spreadValues(__spreadValues({}, defaultSortableTransition), transition);
606
+ }
607
+ function normalizeDisabled(disabled) {
608
+ var _a, _b;
609
+ if (typeof disabled === "boolean") {
610
+ return {
611
+ draggable: disabled,
612
+ droppable: disabled
613
+ };
614
+ }
615
+ return {
616
+ draggable: (_a = disabled == null ? void 0 : disabled.draggable) != null ? _a : false,
617
+ droppable: (_b = disabled == null ? void 0 : disabled.droppable) != null ? _b : false
618
+ };
619
+ }
499
620
  var store = new WeakStore();
500
621
  var _group_dec, _index_dec, _init, _index, _previousGroup, _previousIndex, _group, _element;
501
622
  _index_dec = [reactive], _group_dec = [reactive];
@@ -529,14 +650,16 @@ var Sortable2 = class {
529
650
  };
530
651
  var _b = _a, {
531
652
  effects: inputEffects = () => [],
653
+ disabled,
532
654
  group,
533
655
  index,
534
656
  sensors,
535
657
  type,
536
658
  transition = defaultSortableTransition,
537
- plugins = defaultPlugins
659
+ plugins: pluginsInput
538
660
  } = _b, input = __objRest(_b, [
539
661
  "effects",
662
+ "disabled",
540
663
  "group",
541
664
  "index",
542
665
  "sensors",
@@ -544,14 +667,22 @@ var Sortable2 = class {
544
667
  "transition",
545
668
  "plugins"
546
669
  ]);
547
- this.droppable = new SortableDroppable(input, manager, this);
670
+ const plugins = resolveCustomizable(pluginsInput, defaultPlugins);
671
+ const disabledState = normalizeDisabled(disabled);
672
+ this.droppable = new SortableDroppable(
673
+ __spreadProps(__spreadValues({}, input), { disabled: disabledState.droppable }),
674
+ manager,
675
+ this
676
+ );
548
677
  this.draggable = new SortableDraggable(
549
678
  __spreadProps(__spreadValues({}, input), {
679
+ disabled: disabledState.draggable,
680
+ plugins,
550
681
  effects: () => [
551
682
  () => {
552
683
  var _a2, _b2, _c;
553
684
  const status = (_a2 = this.manager) == null ? void 0 : _a2.dragOperation.status;
554
- if ((status == null ? void 0 : status.initializing) && this.id === ((_c = (_b2 = this.manager) == null ? void 0 : _b2.dragOperation.source) == null ? void 0 : _c.id)) {
685
+ if ((status == null ? void 0 : status.initializationPending) && this.id === ((_c = (_b2 = this.manager) == null ? void 0 : _b2.dragOperation.source) == null ? void 0 : _c.id)) {
555
686
  store.clear(this.manager);
556
687
  }
557
688
  if (status == null ? void 0 : status.dragging) {
@@ -576,18 +707,14 @@ var Sortable2 = class {
576
707
  }
577
708
  },
578
709
  () => {
710
+ var _a2, _b2;
579
711
  const { target } = this;
580
- const { feedback, isDragSource } = this.draggable;
581
- if (feedback == "move" && isDragSource) {
712
+ const { isDragSource } = this.draggable;
713
+ const feedback = (_b2 = (_a2 = this.draggable.pluginConfig(Feedback)) == null ? void 0 : _a2.feedback) != null ? _b2 : "default";
714
+ if (feedback === "move" && isDragSource) {
582
715
  this.droppable.disabled = !target;
583
716
  }
584
717
  },
585
- () => {
586
- const { manager: manager2 } = this;
587
- for (const plugin of plugins) {
588
- manager2 == null ? void 0 : manager2.registry.register(plugin);
589
- }
590
- },
591
718
  ...inputEffects()
592
719
  ],
593
720
  type,
@@ -627,6 +754,11 @@ var Sortable2 = class {
627
754
  if (!element) {
628
755
  return;
629
756
  }
757
+ for (const animation of element.getAnimations()) {
758
+ if ("transitionProperty" in animation && (animation.transitionProperty === "transform" || animation.transitionProperty === "translate" || animation.transitionProperty === "scale")) {
759
+ animation.cancel();
760
+ }
761
+ }
630
762
  const updatedShape = this.refreshShape();
631
763
  if (!updatedShape) {
632
764
  return;
@@ -639,6 +771,7 @@ var Sortable2 = class {
639
771
  const currentTranslate = computeTranslate(element, translate, false);
640
772
  const finalTranslate = computeTranslate(element, translate);
641
773
  if (delta.x || delta.y) {
774
+ const resolvedTransition = prefersReducedMotion(getWindow(element)) ? __spreadProps(__spreadValues({}, transition), { duration: 0 }) : transition;
642
775
  animateTransform({
643
776
  element,
644
777
  keyframes: {
@@ -647,7 +780,7 @@ var Sortable2 = class {
647
780
  `${finalTranslate.x}px ${finalTranslate.y}px ${finalTranslate.z}`
648
781
  ]
649
782
  },
650
- options: transition
783
+ options: resolvedTransition
651
784
  }).then(() => {
652
785
  if (!manager.dragOperation.status.dragging) {
653
786
  this.droppable.shape = void 0;
@@ -699,15 +832,18 @@ var Sortable2 = class {
699
832
  return this.draggable.element;
700
833
  }
701
834
  get disabled() {
702
- return this.draggable.disabled && this.droppable.disabled;
835
+ const { disabled: draggable } = this.draggable;
836
+ const { disabled: droppable } = this.droppable;
837
+ return draggable === droppable ? draggable : { draggable, droppable };
703
838
  }
704
- set feedback(value) {
705
- this.draggable.feedback = value;
839
+ set plugins(value) {
840
+ this.draggable.plugins = resolveCustomizable(value, defaultPlugins);
706
841
  }
707
842
  set disabled(value) {
843
+ const disabled = normalizeDisabled(value);
708
844
  batch(() => {
709
- this.droppable.disabled = value;
710
- this.draggable.disabled = value;
845
+ this.droppable.disabled = disabled.droppable;
846
+ this.draggable.disabled = disabled.draggable;
711
847
  });
712
848
  }
713
849
  set data(data) {
@@ -720,10 +856,8 @@ var Sortable2 = class {
720
856
  this.draggable.handle = handle;
721
857
  }
722
858
  set id(id) {
723
- batch(() => {
724
- this.droppable.id = id;
725
- this.draggable.id = id;
726
- });
859
+ this.droppable.id = id;
860
+ this.draggable.id = id;
727
861
  }
728
862
  get id() {
729
863
  return this.droppable.id;
@@ -809,14 +943,29 @@ var SortableDraggable = class extends Draggable {
809
943
  get index() {
810
944
  return this.sortable.index;
811
945
  }
946
+ get initialIndex() {
947
+ return this.sortable.initialIndex;
948
+ }
949
+ get group() {
950
+ return this.sortable.group;
951
+ }
952
+ get initialGroup() {
953
+ return this.sortable.initialGroup;
954
+ }
812
955
  };
813
956
  var SortableDroppable = class extends Droppable {
814
957
  constructor(input, manager, sortable) {
815
958
  super(input, manager);
816
959
  this.sortable = sortable;
817
960
  }
961
+ get index() {
962
+ return this.sortable.index;
963
+ }
964
+ get group() {
965
+ return this.sortable.group;
966
+ }
818
967
  };
819
968
 
820
- export { OptimisticSortingPlugin, Sortable2 as Sortable, SortableKeyboardPlugin, defaultSortableTransition, isSortable };
969
+ export { OptimisticSortingPlugin, Sortable2 as Sortable, SortableDraggable, SortableDroppable, SortableKeyboardPlugin, defaultSortableTransition, isSortable, isSortableOperation, resolveSortableTransition };
821
970
  //# sourceMappingURL=sortable.js.map
822
971
  //# sourceMappingURL=sortable.js.map