@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.
- package/package.json +11 -12
- package/src/column-utils.js +16 -6
- package/src/component-registry.js +2 -2
- package/src/event-emitter.js +3 -1
- package/src/feature-utils.js +7 -7
- package/src/index.js +1 -0
- package/src/react-utils.js +2 -8
- package/src/table-schema-utils.js +5 -6
- package/src/tree-utils.js +2 -2
- package/src/vendor/@dnd-kit/abstract/index.d.ts +114 -32
- package/src/vendor/@dnd-kit/abstract/index.js +430 -280
- package/src/vendor/@dnd-kit/abstract/index.js.map +1 -1
- package/src/vendor/@dnd-kit/abstract/modifiers.d.ts +7 -7
- package/src/vendor/@dnd-kit/abstract/modifiers.js.map +1 -1
- package/src/vendor/@dnd-kit/abstract/package.json +8 -3
- package/src/vendor/@dnd-kit/collision/dist/index.js +10 -3
- package/src/vendor/@dnd-kit/collision/package.json +8 -3
- package/src/vendor/@dnd-kit/dom/index.d.ts +225 -126
- package/src/vendor/@dnd-kit/dom/index.js +998 -484
- package/src/vendor/@dnd-kit/dom/index.js.map +1 -1
- package/src/vendor/@dnd-kit/dom/modifiers.d.ts +1 -1
- package/src/vendor/@dnd-kit/dom/package.json +11 -5
- package/src/vendor/@dnd-kit/dom/plugins/debug.js +10 -7
- package/src/vendor/@dnd-kit/dom/plugins/debug.js.map +1 -1
- package/src/vendor/@dnd-kit/dom/sortable.d.ts +45 -11
- package/src/vendor/@dnd-kit/dom/sortable.js +203 -54
- package/src/vendor/@dnd-kit/dom/sortable.js.map +1 -1
- package/src/vendor/@dnd-kit/dom/utilities.d.ts +82 -10
- package/src/vendor/@dnd-kit/dom/utilities.js +249 -95
- package/src/vendor/@dnd-kit/dom/utilities.js.map +1 -1
- package/src/vendor/@dnd-kit/geometry/package.json +7 -2
- package/src/vendor/@dnd-kit/react/hooks.js +61 -38
- package/src/vendor/@dnd-kit/react/hooks.js.map +1 -0
- package/src/vendor/@dnd-kit/react/index.d.ts +18 -9
- package/src/vendor/@dnd-kit/react/index.js +100 -59
- package/src/vendor/@dnd-kit/react/index.js.map +1 -0
- package/src/vendor/@dnd-kit/react/package.json +17 -5
- package/src/vendor/@dnd-kit/react/sortable.d.ts +1 -1
- package/src/vendor/@dnd-kit/react/sortable.js +24 -10
- package/src/vendor/@dnd-kit/react/sortable.js.map +1 -0
- package/src/vendor/@dnd-kit/react/utilities.js.map +1 -0
- package/src/vendor/@dnd-kit/state/dist/index.js +1 -1
- package/src/vendor/@dnd-kit/state/package.json +6 -1
- package/src/vendor/@preact/signals-core/dist/signals-core.js +1 -1
- package/src/vendor/@preact/signals-core/dist/signals-core.js.map +1 -1
- package/types/ThemeProvider.d.ts +1 -1
- package/types/column-utils.d.ts +5 -3
- package/types/component-registry.d.ts +4 -4
- package/types/context-definitions/DataProvider.d.ts +1 -1
- package/types/context-definitions/DataSourceProvider.d.ts +1 -1
- package/types/feature-utils.d.ts +29 -19
- package/types/filters/filter-utils.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/react-utils.d.ts +1 -1
- package/types/sort-utils.d.ts +2 -2
- package/types/table-schema-utils.d.ts +2 -2
- package/types/tree-types.d.ts +5 -0
- package/types/src/Clock.d.ts +0 -20
- package/types/src/PageVisibilityObserver.d.ts +0 -36
- package/types/src/ScaledDecimal.d.ts +0 -12
- package/types/src/ShellContext.d.ts +0 -11
- package/types/src/ThemeProvider.d.ts +0 -32
- package/types/src/array-utils.d.ts +0 -16
- package/types/src/box-utils.d.ts +0 -24
- package/types/src/broadcast-channel.d.ts +0 -16
- package/types/src/column-utils.d.ts +0 -243
- package/types/src/common-types.d.ts +0 -6
- package/types/src/component-registry.d.ts +0 -65
- package/types/src/context-definitions/DataContext.d.ts +0 -21
- package/types/src/context-definitions/DataProvider.d.ts +0 -7
- package/types/src/context-definitions/DataSourceProvider.d.ts +0 -12
- package/types/src/context-definitions/WorkspaceContext.d.ts +0 -17
- package/types/src/cookie-utils.d.ts +0 -9
- package/types/src/css-utils.d.ts +0 -1
- package/types/src/data-utils.d.ts +0 -33
- package/types/src/datasource/BaseDataSource.d.ts +0 -63
- package/types/src/datasource/datasource-action-utils.d.ts +0 -7
- package/types/src/datasource/datasource-filter-utils.d.ts +0 -2
- package/types/src/datasource/datasource-utils.d.ts +0 -61
- package/types/src/date/date-utils.d.ts +0 -39
- package/types/src/date/dateTimePattern.d.ts +0 -8
- package/types/src/date/formatter.d.ts +0 -9
- package/types/src/date/index.d.ts +0 -4
- package/types/src/date/types.d.ts +0 -29
- package/types/src/debug-utils.d.ts +0 -9
- package/types/src/edit-utils.d.ts +0 -2
- package/types/src/errors.d.ts +0 -2
- package/types/src/event-emitter.d.ts +0 -21
- package/types/src/feature-utils.d.ts +0 -110
- package/types/src/filters/filter-utils.d.ts +0 -75
- package/types/src/filters/filterAsQuery.d.ts +0 -8
- package/types/src/filters/index.d.ts +0 -2
- package/types/src/form-utils.d.ts +0 -37
- package/types/src/formatting-utils.d.ts +0 -14
- package/types/src/getUniqueId.d.ts +0 -1
- package/types/src/group-utils.d.ts +0 -10
- package/types/src/html-utils.d.ts +0 -21
- package/types/src/index.d.ts +0 -76
- package/types/src/input-utils.d.ts +0 -2
- package/types/src/invariant.d.ts +0 -1
- package/types/src/itemToString.d.ts +0 -2
- package/types/src/json-types.d.ts +0 -52
- package/types/src/json-utils.d.ts +0 -6
- package/types/src/keyboard-utils.d.ts +0 -15
- package/types/src/keyset.d.ts +0 -16
- package/types/src/layout-types.d.ts +0 -22
- package/types/src/list-utils.d.ts +0 -2
- package/types/src/local-storage-utils.d.ts +0 -4
- package/types/src/logging-utils.d.ts +0 -45
- package/types/src/module-utils.d.ts +0 -8
- package/types/src/nanoid/index.d.ts +0 -1
- package/types/src/perf-utils.d.ts +0 -5
- package/types/src/promise-utils.d.ts +0 -8
- package/types/src/protocol-message-utils.d.ts +0 -43
- package/types/src/range-utils.d.ts +0 -29
- package/types/src/react-utils.d.ts +0 -15
- package/types/src/round-decimal.d.ts +0 -4
- package/types/src/row-utils.d.ts +0 -28
- package/types/src/selection-utils.d.ts +0 -9
- package/types/src/shell-layout-types.d.ts +0 -15
- package/types/src/sort-utils.d.ts +0 -11
- package/types/src/table-schema-utils.d.ts +0 -5
- package/types/src/text-utils.d.ts +0 -10
- package/types/src/theme-utils.d.ts +0 -14
- package/types/src/tree-types.d.ts +0 -9
- package/types/src/tree-utils.d.ts +0 -9
- package/types/src/ts-utils.d.ts +0 -20
- package/types/src/typeahead-utils.d.ts +0 -1
- package/types/src/url-utils.d.ts +0 -3
- package/types/src/useId.d.ts +0 -1
- package/types/src/useLayoutEffectSkipFirst.d.ts +0 -2
- package/types/src/useResizeObserver.d.ts +0 -15
- package/types/src/useStateRef.d.ts +0 -2
- package/types/src/user-types.d.ts +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { untracked, effect, effects, reactive, derived, ValueHistory, snapshot
|
|
1
|
+
import { signal, untracked, effect, batch, effects, reactive, derived, ValueHistory, snapshot } from '../state/dist/index.js';
|
|
2
2
|
import { Position } from '../geometry/dist/index.js';
|
|
3
3
|
|
|
4
4
|
var __create = Object.create;
|
|
@@ -234,11 +234,13 @@ var PluginRegistry = class {
|
|
|
234
234
|
* - Registers new plugins with their options
|
|
235
235
|
*/
|
|
236
236
|
set values(entries) {
|
|
237
|
-
const descriptors = entries.map(descriptor).
|
|
238
|
-
|
|
237
|
+
const descriptors = entries.map(descriptor).reduce((acc, descriptor2) => {
|
|
238
|
+
const existing = acc.find(({ plugin }) => plugin === descriptor2.plugin);
|
|
239
|
+
if (existing) {
|
|
240
|
+
existing.options = descriptor2.options;
|
|
239
241
|
return acc;
|
|
240
242
|
}
|
|
241
|
-
return [
|
|
243
|
+
return [...acc, descriptor2];
|
|
242
244
|
}, []);
|
|
243
245
|
const constructors = descriptors.map(({ plugin }) => plugin);
|
|
244
246
|
for (const plugin of __privateGet(this, _previousValues)) {
|
|
@@ -440,6 +442,336 @@ var CollisionObserver = class extends Plugin {
|
|
|
440
442
|
};
|
|
441
443
|
_previousCoordinates = new WeakMap();
|
|
442
444
|
_collisions = new WeakMap();
|
|
445
|
+
var _disabled_dec2, _data_dec, _manager_dec, _Entity_static, flushIdChanges_fn, _init2, _manager, _idSignal, _data, _disabled2;
|
|
446
|
+
_manager_dec = [reactive], _data_dec = [reactive], _disabled_dec2 = [reactive];
|
|
447
|
+
var _Entity = class _Entity {
|
|
448
|
+
/**
|
|
449
|
+
* Creates a new instance of the `Entity` class.
|
|
450
|
+
*
|
|
451
|
+
* @param input - An object containing the initial properties of the entity.
|
|
452
|
+
* @param manager - The manager that controls the drag and drop operations.
|
|
453
|
+
*/
|
|
454
|
+
constructor(input, manager) {
|
|
455
|
+
__privateAdd(this, _manager, __runInitializers(_init2, 8, this)), __runInitializers(_init2, 11, this);
|
|
456
|
+
/**
|
|
457
|
+
* The unique identifier of the entity.
|
|
458
|
+
*
|
|
459
|
+
* Setting this property defers the signal update to a microtask,
|
|
460
|
+
* batching multiple id changes together atomically. This ensures
|
|
461
|
+
* that when entities swap ids (e.g. during sorting with virtualization),
|
|
462
|
+
* all registry updates happen in a single transaction.
|
|
463
|
+
*/
|
|
464
|
+
__privateAdd(this, _idSignal);
|
|
465
|
+
__privateAdd(this, _data, __runInitializers(_init2, 12, this)), __runInitializers(_init2, 15, this);
|
|
466
|
+
__privateAdd(this, _disabled2, __runInitializers(_init2, 16, this)), __runInitializers(_init2, 19, this);
|
|
467
|
+
const { effects: effects6, id, data = {}, disabled = false, register = true } = input;
|
|
468
|
+
let previousId = id;
|
|
469
|
+
__privateSet(this, _idSignal, signal(id));
|
|
470
|
+
this.manager = manager;
|
|
471
|
+
this.data = data;
|
|
472
|
+
this.disabled = disabled;
|
|
473
|
+
this.effects = () => {
|
|
474
|
+
var _a;
|
|
475
|
+
return [
|
|
476
|
+
() => {
|
|
477
|
+
const { id: id2, manager: manager2 } = this;
|
|
478
|
+
if (id2 === previousId) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
previousId = id2;
|
|
482
|
+
manager2 == null ? void 0 : manager2.registry.register(this);
|
|
483
|
+
return () => manager2 == null ? void 0 : manager2.registry.unregister(this);
|
|
484
|
+
},
|
|
485
|
+
...(_a = effects6 == null ? void 0 : effects6()) != null ? _a : []
|
|
486
|
+
];
|
|
487
|
+
};
|
|
488
|
+
this.register = this.register.bind(this);
|
|
489
|
+
this.unregister = this.unregister.bind(this);
|
|
490
|
+
this.destroy = this.destroy.bind(this);
|
|
491
|
+
if (manager && register) {
|
|
492
|
+
queueMicrotask(this.register);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
get id() {
|
|
496
|
+
var _a, _b;
|
|
497
|
+
const signalValue = __privateGet(this, _idSignal).value;
|
|
498
|
+
return (_b = (_a = _Entity.pendingIdChanges) == null ? void 0 : _a.get(this)) != null ? _b : signalValue;
|
|
499
|
+
}
|
|
500
|
+
set id(value) {
|
|
501
|
+
var _a, _b;
|
|
502
|
+
const current = (_b = (_a = _Entity.pendingIdChanges) == null ? void 0 : _a.get(this)) != null ? _b : __privateGet(this, _idSignal).peek();
|
|
503
|
+
if (value === current) return;
|
|
504
|
+
if (!_Entity.pendingIdChanges) {
|
|
505
|
+
_Entity.pendingIdChanges = /* @__PURE__ */ new Map();
|
|
506
|
+
queueMicrotask(() => {
|
|
507
|
+
var _a2;
|
|
508
|
+
return __privateMethod(_a2 = _Entity, _Entity_static, flushIdChanges_fn).call(_a2);
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
_Entity.pendingIdChanges.set(this, value);
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* A method that registers the entity with the manager.
|
|
515
|
+
* @returns CleanupFunction | void
|
|
516
|
+
*/
|
|
517
|
+
register() {
|
|
518
|
+
var _a;
|
|
519
|
+
return (_a = this.manager) == null ? void 0 : _a.registry.register(this);
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* A method that unregisters the entity from the manager.
|
|
523
|
+
* @returns void
|
|
524
|
+
*/
|
|
525
|
+
unregister() {
|
|
526
|
+
var _a;
|
|
527
|
+
(_a = this.manager) == null ? void 0 : _a.registry.unregister(this);
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* A method that cleans up the entity when it is no longer needed.
|
|
531
|
+
* @returns void
|
|
532
|
+
*/
|
|
533
|
+
destroy() {
|
|
534
|
+
var _a;
|
|
535
|
+
(_a = this.manager) == null ? void 0 : _a.registry.unregister(this);
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
_init2 = __decoratorStart(null);
|
|
539
|
+
_Entity_static = new WeakSet();
|
|
540
|
+
flushIdChanges_fn = function() {
|
|
541
|
+
const changes = _Entity.pendingIdChanges;
|
|
542
|
+
_Entity.pendingIdChanges = null;
|
|
543
|
+
if (changes) {
|
|
544
|
+
batch(() => {
|
|
545
|
+
for (const [entity, id] of changes) {
|
|
546
|
+
__privateGet(entity, _idSignal).value = id;
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
_manager = new WeakMap();
|
|
552
|
+
_idSignal = new WeakMap();
|
|
553
|
+
_data = new WeakMap();
|
|
554
|
+
_disabled2 = new WeakMap();
|
|
555
|
+
__decorateElement(_init2, 4, "manager", _manager_dec, _Entity, _manager);
|
|
556
|
+
__decorateElement(_init2, 4, "data", _data_dec, _Entity, _data);
|
|
557
|
+
__decorateElement(_init2, 4, "disabled", _disabled_dec2, _Entity, _disabled2);
|
|
558
|
+
__privateAdd(_Entity, _Entity_static);
|
|
559
|
+
__decoratorMetadata(_init2, _Entity);
|
|
560
|
+
_Entity.pendingIdChanges = null;
|
|
561
|
+
var Entity = _Entity;
|
|
562
|
+
var EntityRegistry = class {
|
|
563
|
+
constructor() {
|
|
564
|
+
this.map = signal(/* @__PURE__ */ new Map());
|
|
565
|
+
this.cleanupFunctions = /* @__PURE__ */ new WeakMap();
|
|
566
|
+
/**
|
|
567
|
+
* Registers a entity in the registry.
|
|
568
|
+
* @param key - The unique identifier of the entity.
|
|
569
|
+
* @param value - The entity to register.
|
|
570
|
+
* @returns A function that unregisters the entity.
|
|
571
|
+
*/
|
|
572
|
+
this.register = (key, value) => {
|
|
573
|
+
const current = this.map.peek();
|
|
574
|
+
const currentValue = current.get(key);
|
|
575
|
+
const unregister = () => this.unregister(key, value);
|
|
576
|
+
if (currentValue === value) return unregister;
|
|
577
|
+
if (currentValue) {
|
|
578
|
+
if (currentValue.id === key) {
|
|
579
|
+
const cleanup2 = this.cleanupFunctions.get(currentValue);
|
|
580
|
+
cleanup2 == null ? void 0 : cleanup2();
|
|
581
|
+
this.cleanupFunctions.delete(currentValue);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
const updatedMap = new Map(current);
|
|
585
|
+
for (const [existingKey, existingValue] of current) {
|
|
586
|
+
if (existingValue === value && existingKey !== key) {
|
|
587
|
+
updatedMap.delete(existingKey);
|
|
588
|
+
break;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
updatedMap.set(key, value);
|
|
592
|
+
this.map.value = updatedMap;
|
|
593
|
+
const cleanup = effects(...value.effects());
|
|
594
|
+
this.cleanupFunctions.set(value, cleanup);
|
|
595
|
+
return unregister;
|
|
596
|
+
};
|
|
597
|
+
/**
|
|
598
|
+
* Unregisters an entity from the registry.
|
|
599
|
+
* @param key - The unique identifier of the entity.
|
|
600
|
+
* @param value - The entity instance to unregister.
|
|
601
|
+
*/
|
|
602
|
+
this.unregister = (key, value) => {
|
|
603
|
+
const current = this.map.peek();
|
|
604
|
+
if (current.get(key) !== value) {
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
const cleanup = this.cleanupFunctions.get(value);
|
|
608
|
+
cleanup == null ? void 0 : cleanup();
|
|
609
|
+
this.cleanupFunctions.delete(value);
|
|
610
|
+
const updatedMap = new Map(current);
|
|
611
|
+
updatedMap.delete(key);
|
|
612
|
+
this.map.value = updatedMap;
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Iterator for the EntityRegistry class.
|
|
617
|
+
* @returns An iterator for the values in the map.
|
|
618
|
+
*/
|
|
619
|
+
[Symbol.iterator]() {
|
|
620
|
+
return this.map.peek().values();
|
|
621
|
+
}
|
|
622
|
+
get value() {
|
|
623
|
+
return this.map.value.values();
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Checks if a entity with the given identifier exists in the registry.
|
|
627
|
+
* @param identifier - The unique identifier of the entity.
|
|
628
|
+
* @returns True if the entity exists, false otherwise.
|
|
629
|
+
*/
|
|
630
|
+
has(identifier) {
|
|
631
|
+
return this.map.value.has(identifier);
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Retrieves a entity from the registry using its identifier.
|
|
635
|
+
* @param identifier - The unique identifier of the entity.
|
|
636
|
+
* @returns The entity if it exists, undefined otherwise.
|
|
637
|
+
*/
|
|
638
|
+
get(identifier) {
|
|
639
|
+
return this.map.value.get(identifier);
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Destroys all entries in the registry and clears the registry.
|
|
643
|
+
*/
|
|
644
|
+
destroy() {
|
|
645
|
+
for (const entry of this) {
|
|
646
|
+
const cleanup = this.cleanupFunctions.get(entry);
|
|
647
|
+
cleanup == null ? void 0 : cleanup();
|
|
648
|
+
entry.destroy();
|
|
649
|
+
}
|
|
650
|
+
this.map.value = /* @__PURE__ */ new Map();
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
var _isDragSource_dec, _isDragging_dec, _isDropping_dec, _status_dec, _modifiers_dec, _type_dec, _c, _init3, _type, _modifiers, _status;
|
|
654
|
+
var Draggable = class extends (_c = Entity, _type_dec = [reactive], _modifiers_dec = [reactive], _status_dec = [reactive], _isDropping_dec = [derived], _isDragging_dec = [derived], _isDragSource_dec = [derived], _c) {
|
|
655
|
+
constructor(_a, manager) {
|
|
656
|
+
var _b = _a, { modifiers, type, sensors, plugins, effects: effects6 } = _b, input = __objRest(_b, ["modifiers", "type", "sensors", "plugins", "effects"]);
|
|
657
|
+
super(
|
|
658
|
+
__spreadProps(__spreadValues({}, input), {
|
|
659
|
+
effects: () => {
|
|
660
|
+
var _a2;
|
|
661
|
+
return [
|
|
662
|
+
...(_a2 = effects6 == null ? void 0 : effects6()) != null ? _a2 : [],
|
|
663
|
+
() => {
|
|
664
|
+
const { manager: manager2, plugins: plugins2 } = this;
|
|
665
|
+
if (!manager2 || !plugins2) return;
|
|
666
|
+
for (const entry of plugins2) {
|
|
667
|
+
const { plugin } = descriptor(entry);
|
|
668
|
+
manager2.registry.plugins.register(plugin);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
];
|
|
672
|
+
}
|
|
673
|
+
}),
|
|
674
|
+
manager
|
|
675
|
+
);
|
|
676
|
+
__runInitializers(_init3, 5, this);
|
|
677
|
+
__privateAdd(this, _type, __runInitializers(_init3, 8, this)), __runInitializers(_init3, 11, this);
|
|
678
|
+
__privateAdd(this, _modifiers, __runInitializers(_init3, 12, this)), __runInitializers(_init3, 15, this);
|
|
679
|
+
__privateAdd(this, _status, __runInitializers(_init3, 16, this, this.isDragSource ? "dragging" : "idle")), __runInitializers(_init3, 19, this);
|
|
680
|
+
this.type = type;
|
|
681
|
+
this.sensors = sensors;
|
|
682
|
+
this.modifiers = modifiers;
|
|
683
|
+
this.alignment = input.alignment;
|
|
684
|
+
this.plugins = plugins;
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Look up per-entity options for a given plugin constructor.
|
|
688
|
+
*/
|
|
689
|
+
pluginConfig(plugin) {
|
|
690
|
+
if (!this.plugins) return void 0;
|
|
691
|
+
for (const entry of this.plugins) {
|
|
692
|
+
const desc = descriptor(entry);
|
|
693
|
+
if (desc.plugin === plugin) return desc.options;
|
|
694
|
+
}
|
|
695
|
+
return void 0;
|
|
696
|
+
}
|
|
697
|
+
get isDropping() {
|
|
698
|
+
return this.status === "dropping" && this.isDragSource;
|
|
699
|
+
}
|
|
700
|
+
get isDragging() {
|
|
701
|
+
return this.status === "dragging" && this.isDragSource;
|
|
702
|
+
}
|
|
703
|
+
get isDragSource() {
|
|
704
|
+
var _a, _b;
|
|
705
|
+
return ((_b = (_a = this.manager) == null ? void 0 : _a.dragOperation.source) == null ? void 0 : _b.id) === this.id;
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
_init3 = __decoratorStart(_c);
|
|
709
|
+
_type = new WeakMap();
|
|
710
|
+
_modifiers = new WeakMap();
|
|
711
|
+
_status = new WeakMap();
|
|
712
|
+
__decorateElement(_init3, 4, "type", _type_dec, Draggable, _type);
|
|
713
|
+
__decorateElement(_init3, 4, "modifiers", _modifiers_dec, Draggable, _modifiers);
|
|
714
|
+
__decorateElement(_init3, 4, "status", _status_dec, Draggable, _status);
|
|
715
|
+
__decorateElement(_init3, 2, "isDropping", _isDropping_dec, Draggable);
|
|
716
|
+
__decorateElement(_init3, 2, "isDragging", _isDragging_dec, Draggable);
|
|
717
|
+
__decorateElement(_init3, 2, "isDragSource", _isDragSource_dec, Draggable);
|
|
718
|
+
__decoratorMetadata(_init3, Draggable);
|
|
719
|
+
var _isDropTarget_dec, _shape_dec, _collisionPriority_dec, _collisionDetector_dec, _type_dec2, _accept_dec, _c2, _init4, _accept, _type2, _collisionDetector, _collisionPriority, _shape;
|
|
720
|
+
var Droppable = class extends (_c2 = Entity, _accept_dec = [reactive], _type_dec2 = [reactive], _collisionDetector_dec = [reactive], _collisionPriority_dec = [reactive], _shape_dec = [reactive], _isDropTarget_dec = [derived], _c2) {
|
|
721
|
+
constructor(_a, manager) {
|
|
722
|
+
var _b = _a, { accept, collisionDetector, collisionPriority, type } = _b, input = __objRest(_b, ["accept", "collisionDetector", "collisionPriority", "type"]);
|
|
723
|
+
super(input, manager);
|
|
724
|
+
__runInitializers(_init4, 5, this);
|
|
725
|
+
__privateAdd(this, _accept, __runInitializers(_init4, 8, this)), __runInitializers(_init4, 11, this);
|
|
726
|
+
__privateAdd(this, _type2, __runInitializers(_init4, 12, this)), __runInitializers(_init4, 15, this);
|
|
727
|
+
__privateAdd(this, _collisionDetector, __runInitializers(_init4, 16, this)), __runInitializers(_init4, 19, this);
|
|
728
|
+
__privateAdd(this, _collisionPriority, __runInitializers(_init4, 20, this)), __runInitializers(_init4, 23, this);
|
|
729
|
+
__privateAdd(this, _shape, __runInitializers(_init4, 24, this)), __runInitializers(_init4, 27, this);
|
|
730
|
+
this.accept = accept;
|
|
731
|
+
this.collisionDetector = collisionDetector;
|
|
732
|
+
this.collisionPriority = collisionPriority;
|
|
733
|
+
this.type = type;
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Checks whether or not the droppable accepts a given draggable.
|
|
737
|
+
*
|
|
738
|
+
* @param draggable - The draggable to check
|
|
739
|
+
* @returns true if the draggable can be dropped here
|
|
740
|
+
*/
|
|
741
|
+
accepts(draggable) {
|
|
742
|
+
const { accept } = this;
|
|
743
|
+
if (!accept) {
|
|
744
|
+
return true;
|
|
745
|
+
}
|
|
746
|
+
if (typeof accept === "function") {
|
|
747
|
+
return accept(draggable);
|
|
748
|
+
}
|
|
749
|
+
if (!draggable.type) {
|
|
750
|
+
return false;
|
|
751
|
+
}
|
|
752
|
+
if (Array.isArray(accept)) {
|
|
753
|
+
return accept.includes(draggable.type);
|
|
754
|
+
}
|
|
755
|
+
return draggable.type === accept;
|
|
756
|
+
}
|
|
757
|
+
get isDropTarget() {
|
|
758
|
+
var _a, _b;
|
|
759
|
+
return ((_b = (_a = this.manager) == null ? void 0 : _a.dragOperation.target) == null ? void 0 : _b.id) === this.id;
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
_init4 = __decoratorStart(_c2);
|
|
763
|
+
_accept = new WeakMap();
|
|
764
|
+
_type2 = new WeakMap();
|
|
765
|
+
_collisionDetector = new WeakMap();
|
|
766
|
+
_collisionPriority = new WeakMap();
|
|
767
|
+
_shape = new WeakMap();
|
|
768
|
+
__decorateElement(_init4, 4, "accept", _accept_dec, Droppable, _accept);
|
|
769
|
+
__decorateElement(_init4, 4, "type", _type_dec2, Droppable, _type2);
|
|
770
|
+
__decorateElement(_init4, 4, "collisionDetector", _collisionDetector_dec, Droppable, _collisionDetector);
|
|
771
|
+
__decorateElement(_init4, 4, "collisionPriority", _collisionPriority_dec, Droppable, _collisionPriority);
|
|
772
|
+
__decorateElement(_init4, 4, "shape", _shape_dec, Droppable, _shape);
|
|
773
|
+
__decorateElement(_init4, 2, "isDropTarget", _isDropTarget_dec, Droppable);
|
|
774
|
+
__decoratorMetadata(_init4, Droppable);
|
|
443
775
|
|
|
444
776
|
// src/core/manager/events.ts
|
|
445
777
|
var Monitor = class {
|
|
@@ -546,6 +878,9 @@ var CollisionNotifier = class extends CorePlugin {
|
|
|
546
878
|
if (collisionObserver.isDisabled()) {
|
|
547
879
|
return;
|
|
548
880
|
}
|
|
881
|
+
if (Entity.pendingIdChanges) {
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
549
884
|
const event = defaultPreventable({
|
|
550
885
|
collisions
|
|
551
886
|
});
|
|
@@ -588,12 +923,12 @@ var CollisionType = /* @__PURE__ */ ((CollisionType2) => {
|
|
|
588
923
|
CollisionType2[CollisionType2["PointerIntersection"] = 2] = "PointerIntersection";
|
|
589
924
|
return CollisionType2;
|
|
590
925
|
})(CollisionType || {});
|
|
591
|
-
var _dropped_dec, _dragging_dec, _initialized_dec, _initializing_dec, _idle_dec, _current_dec, _value_dec,
|
|
592
|
-
_value_dec = [reactive], _current_dec = [derived], _idle_dec = [derived], _initializing_dec = [derived], _initialized_dec = [derived], _dragging_dec = [derived], _dropped_dec = [derived];
|
|
926
|
+
var _dropped_dec, _dragging_dec, _initialized_dec, _initializing_dec, _initializationPending_dec, _idle_dec, _current_dec, _value_dec, _init5, _value;
|
|
927
|
+
_value_dec = [reactive], _current_dec = [derived], _idle_dec = [derived], _initializationPending_dec = [derived], _initializing_dec = [derived], _initialized_dec = [derived], _dragging_dec = [derived], _dropped_dec = [derived];
|
|
593
928
|
var Status = class {
|
|
594
929
|
constructor() {
|
|
595
|
-
__runInitializers(
|
|
596
|
-
__privateAdd(this, _value, __runInitializers(
|
|
930
|
+
__runInitializers(_init5, 5, this);
|
|
931
|
+
__privateAdd(this, _value, __runInitializers(_init5, 8, this, "idle" /* Idle */)), __runInitializers(_init5, 11, this);
|
|
597
932
|
}
|
|
598
933
|
get current() {
|
|
599
934
|
return this.value;
|
|
@@ -601,6 +936,9 @@ var Status = class {
|
|
|
601
936
|
get idle() {
|
|
602
937
|
return this.value === "idle" /* Idle */;
|
|
603
938
|
}
|
|
939
|
+
get initializationPending() {
|
|
940
|
+
return this.value === "initialization-pending" /* InitializationPending */;
|
|
941
|
+
}
|
|
604
942
|
get initializing() {
|
|
605
943
|
return this.value === "initializing" /* Initializing */;
|
|
606
944
|
}
|
|
@@ -623,16 +961,17 @@ var Status = class {
|
|
|
623
961
|
this.value = value;
|
|
624
962
|
}
|
|
625
963
|
};
|
|
626
|
-
|
|
964
|
+
_init5 = __decoratorStart(null);
|
|
627
965
|
_value = new WeakMap();
|
|
628
|
-
__decorateElement(
|
|
629
|
-
__decorateElement(
|
|
630
|
-
__decorateElement(
|
|
631
|
-
__decorateElement(
|
|
632
|
-
__decorateElement(
|
|
633
|
-
__decorateElement(
|
|
634
|
-
__decorateElement(
|
|
635
|
-
|
|
966
|
+
__decorateElement(_init5, 4, "value", _value_dec, Status, _value);
|
|
967
|
+
__decorateElement(_init5, 2, "current", _current_dec, Status);
|
|
968
|
+
__decorateElement(_init5, 2, "idle", _idle_dec, Status);
|
|
969
|
+
__decorateElement(_init5, 2, "initializationPending", _initializationPending_dec, Status);
|
|
970
|
+
__decorateElement(_init5, 2, "initializing", _initializing_dec, Status);
|
|
971
|
+
__decorateElement(_init5, 2, "initialized", _initialized_dec, Status);
|
|
972
|
+
__decorateElement(_init5, 2, "dragging", _dragging_dec, Status);
|
|
973
|
+
__decorateElement(_init5, 2, "dropped", _dropped_dec, Status);
|
|
974
|
+
__decoratorMetadata(_init5, Status);
|
|
636
975
|
|
|
637
976
|
// src/core/manager/actions.ts
|
|
638
977
|
var DragActions = class {
|
|
@@ -725,11 +1064,13 @@ var DragActions = class {
|
|
|
725
1064
|
if (controller.signal.aborted) return;
|
|
726
1065
|
const { status } = dragOperation;
|
|
727
1066
|
if (status.current !== "initializing" /* Initializing */) return;
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
1067
|
+
batch(() => {
|
|
1068
|
+
dragOperation.status.set("dragging" /* Dragging */);
|
|
1069
|
+
this.manager.monitor.dispatch("dragstart", {
|
|
1070
|
+
nativeEvent,
|
|
1071
|
+
operation: dragOperation.snapshot(),
|
|
1072
|
+
cancelable: false
|
|
1073
|
+
});
|
|
733
1074
|
});
|
|
734
1075
|
});
|
|
735
1076
|
return controller;
|
|
@@ -854,272 +1195,73 @@ var DragActions = class {
|
|
|
854
1195
|
});
|
|
855
1196
|
}
|
|
856
1197
|
};
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
var
|
|
1198
|
+
|
|
1199
|
+
// src/core/sensors/sensor.ts
|
|
1200
|
+
var Sensor = class extends Plugin {
|
|
860
1201
|
/**
|
|
861
|
-
* Creates a new instance
|
|
1202
|
+
* Creates a new sensor instance.
|
|
862
1203
|
*
|
|
863
|
-
* @param
|
|
864
|
-
* @param
|
|
1204
|
+
* @param manager - The drag drop manager instance
|
|
1205
|
+
* @param options - Optional sensor configuration
|
|
865
1206
|
*/
|
|
866
|
-
constructor(
|
|
867
|
-
|
|
868
|
-
__privateAdd(this, _id, __runInitializers(_init3, 12, this)), __runInitializers(_init3, 15, this);
|
|
869
|
-
__privateAdd(this, _data, __runInitializers(_init3, 16, this)), __runInitializers(_init3, 19, this);
|
|
870
|
-
__privateAdd(this, _disabled2, __runInitializers(_init3, 20, this)), __runInitializers(_init3, 23, this);
|
|
871
|
-
const { effects: effects6, id, data = {}, disabled = false, register = true } = input;
|
|
872
|
-
let previousId = id;
|
|
1207
|
+
constructor(manager, options) {
|
|
1208
|
+
super(manager, options);
|
|
873
1209
|
this.manager = manager;
|
|
874
|
-
this.
|
|
875
|
-
this.data = data;
|
|
876
|
-
this.disabled = disabled;
|
|
877
|
-
this.effects = () => {
|
|
878
|
-
var _a;
|
|
879
|
-
return [
|
|
880
|
-
() => {
|
|
881
|
-
const { id: id2, manager: manager2 } = this;
|
|
882
|
-
if (id2 === previousId) {
|
|
883
|
-
return;
|
|
884
|
-
}
|
|
885
|
-
manager2 == null ? void 0 : manager2.registry.register(this);
|
|
886
|
-
return () => manager2 == null ? void 0 : manager2.registry.unregister(this);
|
|
887
|
-
},
|
|
888
|
-
...(_a = effects6 == null ? void 0 : effects6()) != null ? _a : []
|
|
889
|
-
];
|
|
890
|
-
};
|
|
891
|
-
this.register = this.register.bind(this);
|
|
892
|
-
this.unregister = this.unregister.bind(this);
|
|
893
|
-
this.destroy = this.destroy.bind(this);
|
|
894
|
-
if (manager && register) {
|
|
895
|
-
queueMicrotask(this.register);
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* A method that registers the entity with the manager.
|
|
900
|
-
* @returns CleanupFunction | void
|
|
901
|
-
*/
|
|
902
|
-
register() {
|
|
903
|
-
var _a;
|
|
904
|
-
return (_a = this.manager) == null ? void 0 : _a.registry.register(this);
|
|
1210
|
+
this.options = options;
|
|
905
1211
|
}
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1214
|
+
// src/core/sensors/activation.ts
|
|
1215
|
+
var ActivationController = class extends AbortController {
|
|
1216
|
+
constructor(constraints, onActivate) {
|
|
1217
|
+
super();
|
|
1218
|
+
this.constraints = constraints;
|
|
1219
|
+
this.onActivate = onActivate;
|
|
1220
|
+
this.activated = false;
|
|
1221
|
+
for (const constraint of constraints != null ? constraints : []) {
|
|
1222
|
+
constraint.controller = this;
|
|
1223
|
+
}
|
|
913
1224
|
}
|
|
914
|
-
|
|
915
|
-
* A method that cleans up the entity when it is no longer needed.
|
|
916
|
-
* @returns void
|
|
917
|
-
*/
|
|
918
|
-
destroy() {
|
|
1225
|
+
onEvent(event) {
|
|
919
1226
|
var _a;
|
|
920
|
-
(
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
_manager = new WeakMap();
|
|
925
|
-
_id = new WeakMap();
|
|
926
|
-
_data = new WeakMap();
|
|
927
|
-
_disabled2 = new WeakMap();
|
|
928
|
-
__decorateElement(_init3, 4, "manager", _manager_dec, Entity, _manager);
|
|
929
|
-
__decorateElement(_init3, 4, "id", _id_dec, Entity, _id);
|
|
930
|
-
__decorateElement(_init3, 4, "data", _data_dec, Entity, _data);
|
|
931
|
-
__decorateElement(_init3, 4, "disabled", _disabled_dec2, Entity, _disabled2);
|
|
932
|
-
__decoratorMetadata(_init3, Entity);
|
|
933
|
-
var EntityRegistry = class {
|
|
934
|
-
constructor() {
|
|
935
|
-
this.map = signal(/* @__PURE__ */ new Map());
|
|
936
|
-
this.cleanupFunctions = /* @__PURE__ */ new WeakMap();
|
|
937
|
-
/**
|
|
938
|
-
* Registers a entity in the registry.
|
|
939
|
-
* @param key - The unique identifier of the entity.
|
|
940
|
-
* @param value - The entity to register.
|
|
941
|
-
* @returns A function that unregisters the entity.
|
|
942
|
-
*/
|
|
943
|
-
this.register = (key, value) => {
|
|
944
|
-
const current = this.map.peek();
|
|
945
|
-
const currentValue = current.get(key);
|
|
946
|
-
const unregister = () => this.unregister(key, value);
|
|
947
|
-
if (currentValue === value) return unregister;
|
|
948
|
-
if (currentValue) {
|
|
949
|
-
const cleanup2 = this.cleanupFunctions.get(currentValue);
|
|
950
|
-
cleanup2 == null ? void 0 : cleanup2();
|
|
951
|
-
this.cleanupFunctions.delete(currentValue);
|
|
952
|
-
}
|
|
953
|
-
const updatedMap = new Map(current);
|
|
954
|
-
updatedMap.set(key, value);
|
|
955
|
-
this.map.value = updatedMap;
|
|
956
|
-
const cleanup = effects(...value.effects());
|
|
957
|
-
this.cleanupFunctions.set(value, cleanup);
|
|
958
|
-
return unregister;
|
|
959
|
-
};
|
|
960
|
-
/**
|
|
961
|
-
* Unregisters an entity from the registry.
|
|
962
|
-
* @param key - The unique identifier of the entity.
|
|
963
|
-
* @param value - The entity instance to unregister.
|
|
964
|
-
*/
|
|
965
|
-
this.unregister = (key, value) => {
|
|
966
|
-
const current = this.map.peek();
|
|
967
|
-
if (current.get(key) !== value) {
|
|
968
|
-
return;
|
|
1227
|
+
if (this.activated) return;
|
|
1228
|
+
if ((_a = this.constraints) == null ? void 0 : _a.length) {
|
|
1229
|
+
for (const constraint of this.constraints) {
|
|
1230
|
+
constraint.onEvent(event);
|
|
969
1231
|
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
this.cleanupFunctions.delete(value);
|
|
973
|
-
const updatedMap = new Map(current);
|
|
974
|
-
updatedMap.delete(key);
|
|
975
|
-
this.map.value = updatedMap;
|
|
976
|
-
};
|
|
977
|
-
}
|
|
978
|
-
/**
|
|
979
|
-
* Iterator for the EntityRegistry class.
|
|
980
|
-
* @returns An iterator for the values in the map.
|
|
981
|
-
*/
|
|
982
|
-
[Symbol.iterator]() {
|
|
983
|
-
return this.map.peek().values();
|
|
984
|
-
}
|
|
985
|
-
get value() {
|
|
986
|
-
return this.map.value.values();
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
* Checks if a entity with the given identifier exists in the registry.
|
|
990
|
-
* @param identifier - The unique identifier of the entity.
|
|
991
|
-
* @returns True if the entity exists, false otherwise.
|
|
992
|
-
*/
|
|
993
|
-
has(identifier) {
|
|
994
|
-
return this.map.value.has(identifier);
|
|
995
|
-
}
|
|
996
|
-
/**
|
|
997
|
-
* Retrieves a entity from the registry using its identifier.
|
|
998
|
-
* @param identifier - The unique identifier of the entity.
|
|
999
|
-
* @returns The entity if it exists, undefined otherwise.
|
|
1000
|
-
*/
|
|
1001
|
-
get(identifier) {
|
|
1002
|
-
return this.map.value.get(identifier);
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* Destroys all entries in the registry and clears the registry.
|
|
1006
|
-
*/
|
|
1007
|
-
destroy() {
|
|
1008
|
-
for (const entry of this) {
|
|
1009
|
-
const cleanup = this.cleanupFunctions.get(entry);
|
|
1010
|
-
cleanup == null ? void 0 : cleanup();
|
|
1011
|
-
entry.destroy();
|
|
1232
|
+
} else {
|
|
1233
|
+
this.activate(event);
|
|
1012
1234
|
}
|
|
1013
|
-
this.map.value = /* @__PURE__ */ new Map();
|
|
1014
|
-
}
|
|
1015
|
-
};
|
|
1016
|
-
var _isDragSource_dec, _isDragging_dec, _isDropping_dec, _status_dec, _modifiers_dec, _type_dec, _c, _init4, _type, _modifiers, _status;
|
|
1017
|
-
var Draggable = class extends (_c = Entity, _type_dec = [reactive], _modifiers_dec = [reactive], _status_dec = [reactive], _isDropping_dec = [derived], _isDragging_dec = [derived], _isDragSource_dec = [derived], _c) {
|
|
1018
|
-
constructor(_a, manager) {
|
|
1019
|
-
var _b = _a, { modifiers, type, sensors } = _b, input = __objRest(_b, ["modifiers", "type", "sensors"]);
|
|
1020
|
-
super(input, manager);
|
|
1021
|
-
__runInitializers(_init4, 5, this);
|
|
1022
|
-
__privateAdd(this, _type, __runInitializers(_init4, 8, this)), __runInitializers(_init4, 11, this);
|
|
1023
|
-
__privateAdd(this, _modifiers, __runInitializers(_init4, 12, this)), __runInitializers(_init4, 15, this);
|
|
1024
|
-
__privateAdd(this, _status, __runInitializers(_init4, 16, this, this.isDragSource ? "dragging" : "idle")), __runInitializers(_init4, 19, this);
|
|
1025
|
-
this.type = type;
|
|
1026
|
-
this.sensors = sensors;
|
|
1027
|
-
this.modifiers = modifiers;
|
|
1028
|
-
this.alignment = input.alignment;
|
|
1029
1235
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
return this.status === "dragging" && this.isDragSource;
|
|
1236
|
+
activate(event) {
|
|
1237
|
+
if (this.activated) return;
|
|
1238
|
+
this.activated = true;
|
|
1239
|
+
this.onActivate(event);
|
|
1035
1240
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1241
|
+
abort(event) {
|
|
1242
|
+
this.activated = false;
|
|
1243
|
+
super.abort(event);
|
|
1039
1244
|
}
|
|
1040
1245
|
};
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
__decorateElement(_init4, 4, "modifiers", _modifiers_dec, Draggable, _modifiers);
|
|
1047
|
-
__decorateElement(_init4, 4, "status", _status_dec, Draggable, _status);
|
|
1048
|
-
__decorateElement(_init4, 2, "isDropping", _isDropping_dec, Draggable);
|
|
1049
|
-
__decorateElement(_init4, 2, "isDragging", _isDragging_dec, Draggable);
|
|
1050
|
-
__decorateElement(_init4, 2, "isDragSource", _isDragSource_dec, Draggable);
|
|
1051
|
-
__decoratorMetadata(_init4, Draggable);
|
|
1052
|
-
var _isDropTarget_dec, _shape_dec, _collisionPriority_dec, _collisionDetector_dec, _type_dec2, _accept_dec, _c2, _init5, _accept, _type2, _collisionDetector, _collisionPriority, _shape;
|
|
1053
|
-
var Droppable = class extends (_c2 = Entity, _accept_dec = [reactive], _type_dec2 = [reactive], _collisionDetector_dec = [reactive], _collisionPriority_dec = [reactive], _shape_dec = [reactive], _isDropTarget_dec = [derived], _c2) {
|
|
1054
|
-
constructor(_a, manager) {
|
|
1055
|
-
var _b = _a, { accept, collisionDetector, collisionPriority, type } = _b, input = __objRest(_b, ["accept", "collisionDetector", "collisionPriority", "type"]);
|
|
1056
|
-
super(input, manager);
|
|
1057
|
-
__runInitializers(_init5, 5, this);
|
|
1058
|
-
__privateAdd(this, _accept, __runInitializers(_init5, 8, this)), __runInitializers(_init5, 11, this);
|
|
1059
|
-
__privateAdd(this, _type2, __runInitializers(_init5, 12, this)), __runInitializers(_init5, 15, this);
|
|
1060
|
-
__privateAdd(this, _collisionDetector, __runInitializers(_init5, 16, this)), __runInitializers(_init5, 19, this);
|
|
1061
|
-
__privateAdd(this, _collisionPriority, __runInitializers(_init5, 20, this)), __runInitializers(_init5, 23, this);
|
|
1062
|
-
__privateAdd(this, _shape, __runInitializers(_init5, 24, this)), __runInitializers(_init5, 27, this);
|
|
1063
|
-
this.accept = accept;
|
|
1064
|
-
this.collisionDetector = collisionDetector;
|
|
1065
|
-
this.collisionPriority = collisionPriority;
|
|
1066
|
-
this.type = type;
|
|
1067
|
-
}
|
|
1068
|
-
/**
|
|
1069
|
-
* Checks whether or not the droppable accepts a given draggable.
|
|
1070
|
-
*
|
|
1071
|
-
* @param draggable - The draggable to check
|
|
1072
|
-
* @returns true if the draggable can be dropped here
|
|
1073
|
-
*/
|
|
1074
|
-
accepts(draggable) {
|
|
1075
|
-
const { accept } = this;
|
|
1076
|
-
if (!accept) {
|
|
1077
|
-
return true;
|
|
1078
|
-
}
|
|
1079
|
-
if (typeof accept === "function") {
|
|
1080
|
-
return accept(draggable);
|
|
1081
|
-
}
|
|
1082
|
-
if (!draggable.type) {
|
|
1083
|
-
return false;
|
|
1084
|
-
}
|
|
1085
|
-
if (Array.isArray(accept)) {
|
|
1086
|
-
return accept.includes(draggable.type);
|
|
1087
|
-
}
|
|
1088
|
-
return draggable.type === accept;
|
|
1246
|
+
var _controller;
|
|
1247
|
+
var ActivationConstraint = class {
|
|
1248
|
+
constructor(options) {
|
|
1249
|
+
this.options = options;
|
|
1250
|
+
__privateAdd(this, _controller);
|
|
1089
1251
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1252
|
+
set controller(controller) {
|
|
1253
|
+
__privateSet(this, _controller, controller);
|
|
1254
|
+
controller.signal.addEventListener("abort", () => this.abort());
|
|
1093
1255
|
}
|
|
1094
|
-
};
|
|
1095
|
-
_init5 = __decoratorStart(_c2);
|
|
1096
|
-
_accept = new WeakMap();
|
|
1097
|
-
_type2 = new WeakMap();
|
|
1098
|
-
_collisionDetector = new WeakMap();
|
|
1099
|
-
_collisionPriority = new WeakMap();
|
|
1100
|
-
_shape = new WeakMap();
|
|
1101
|
-
__decorateElement(_init5, 4, "accept", _accept_dec, Droppable, _accept);
|
|
1102
|
-
__decorateElement(_init5, 4, "type", _type_dec2, Droppable, _type2);
|
|
1103
|
-
__decorateElement(_init5, 4, "collisionDetector", _collisionDetector_dec, Droppable, _collisionDetector);
|
|
1104
|
-
__decorateElement(_init5, 4, "collisionPriority", _collisionPriority_dec, Droppable, _collisionPriority);
|
|
1105
|
-
__decorateElement(_init5, 4, "shape", _shape_dec, Droppable, _shape);
|
|
1106
|
-
__decorateElement(_init5, 2, "isDropTarget", _isDropTarget_dec, Droppable);
|
|
1107
|
-
__decoratorMetadata(_init5, Droppable);
|
|
1108
|
-
|
|
1109
|
-
// src/core/sensors/sensor.ts
|
|
1110
|
-
var Sensor = class extends Plugin {
|
|
1111
1256
|
/**
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
* @param manager - The drag drop manager instance
|
|
1115
|
-
* @param options - Optional sensor configuration
|
|
1257
|
+
* Called when the activation is triggered.
|
|
1116
1258
|
*/
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
this.options = options;
|
|
1259
|
+
activate(event) {
|
|
1260
|
+
var _a;
|
|
1261
|
+
(_a = __privateGet(this, _controller)) == null ? void 0 : _a.activate(event);
|
|
1121
1262
|
}
|
|
1122
1263
|
};
|
|
1264
|
+
_controller = new WeakMap();
|
|
1123
1265
|
|
|
1124
1266
|
// src/core/modifiers/modifier.ts
|
|
1125
1267
|
var Modifier = class extends Plugin {
|
|
@@ -1364,6 +1506,12 @@ var defaultRenderer = {
|
|
|
1364
1506
|
};
|
|
1365
1507
|
|
|
1366
1508
|
// src/core/manager/manager.ts
|
|
1509
|
+
function resolveCustomizable(value, defaults) {
|
|
1510
|
+
if (typeof value === "function") {
|
|
1511
|
+
return value(defaults);
|
|
1512
|
+
}
|
|
1513
|
+
return value != null ? value : defaults;
|
|
1514
|
+
}
|
|
1367
1515
|
var DragDropManager = class {
|
|
1368
1516
|
/**
|
|
1369
1517
|
* Creates a new drag and drop manager instance.
|
|
@@ -1382,12 +1530,12 @@ var DragDropManager = class {
|
|
|
1382
1530
|
this.registry.destroy();
|
|
1383
1531
|
this.collisionObserver.destroy();
|
|
1384
1532
|
};
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1533
|
+
var _a;
|
|
1534
|
+
const raw = config != null ? config : {};
|
|
1535
|
+
const plugins = resolveCustomizable(raw.plugins, []);
|
|
1536
|
+
const sensors = resolveCustomizable(raw.sensors, []);
|
|
1537
|
+
const modifiers = resolveCustomizable(raw.modifiers, []);
|
|
1538
|
+
const renderer = (_a = raw.renderer) != null ? _a : defaultRenderer;
|
|
1391
1539
|
const monitor = new DragDropMonitor(this);
|
|
1392
1540
|
const registry = new DragDropRegistry(this);
|
|
1393
1541
|
this.registry = registry;
|
|
@@ -1401,13 +1549,15 @@ var DragDropManager = class {
|
|
|
1401
1549
|
this.sensors = sensors;
|
|
1402
1550
|
const { destroy } = this;
|
|
1403
1551
|
const cleanup = effects(() => {
|
|
1404
|
-
var
|
|
1552
|
+
var _a2, _b, _c3;
|
|
1405
1553
|
const currentModifiers = untracked(() => this.dragOperation.modifiers);
|
|
1406
1554
|
const managerModifiers = this.modifiers;
|
|
1407
|
-
|
|
1408
|
-
|
|
1555
|
+
for (const modifier of currentModifiers) {
|
|
1556
|
+
if (!managerModifiers.includes(modifier)) {
|
|
1557
|
+
modifier.destroy();
|
|
1558
|
+
}
|
|
1409
1559
|
}
|
|
1410
|
-
this.dragOperation.modifiers = (_c3 = (_b = (
|
|
1560
|
+
this.dragOperation.modifiers = (_c3 = (_b = (_a2 = this.dragOperation.source) == null ? void 0 : _a2.modifiers) == null ? void 0 : _b.map((modifier) => {
|
|
1411
1561
|
const { plugin, options } = descriptor(modifier);
|
|
1412
1562
|
return new plugin(this, options);
|
|
1413
1563
|
})) != null ? _c3 : managerModifiers;
|
|
@@ -1467,6 +1617,6 @@ var DragDropManager = class {
|
|
|
1467
1617
|
}
|
|
1468
1618
|
};
|
|
1469
1619
|
|
|
1470
|
-
export { CollisionPriority, CollisionType, CorePlugin, DragDropManager, Status as DragOperationStatus, Draggable, Droppable, Modifier, Plugin, PluginRegistry, Sensor, configurator, configure, descriptor, sortCollisions };
|
|
1620
|
+
export { ActivationConstraint, ActivationController, CollisionPriority, CollisionType, CorePlugin, DragDropManager, Status as DragOperationStatus, Draggable, Droppable, Modifier, Plugin, PluginRegistry, Sensor, configurator, configure, descriptor, resolveCustomizable, sortCollisions };
|
|
1471
1621
|
//# sourceMappingURL=index.js.map
|
|
1472
1622
|
//# sourceMappingURL=index.js.map
|