@dnd-kit/abstract 0.0.4 → 0.0.5
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/index.cjs +26 -26
- package/index.cjs.map +1 -1
- package/index.d.cts +1 -4
- package/index.d.ts +1 -4
- package/index.js +26 -26
- package/index.js.map +1 -1
- package/package.json +3 -3
package/index.cjs
CHANGED
|
@@ -553,46 +553,29 @@ var EntityRegistry = class {
|
|
|
553
553
|
this.map.value = /* @__PURE__ */ new Map();
|
|
554
554
|
}
|
|
555
555
|
};
|
|
556
|
-
var _isDragSource_dec, _status_dec, _type_dec,
|
|
557
|
-
var Draggable = class extends (_c = Entity, _type_dec = [state.reactive], _status_dec = [state.reactive], _isDragSource_dec = [state.derived], _c) {
|
|
556
|
+
var _isDragSource_dec, _status_dec, _type_dec, _modifiers_dec, _c, _init3, _modifiers, _type, _status;
|
|
557
|
+
var Draggable = class extends (_c = Entity, _modifiers_dec = [state.reactive], _type_dec = [state.reactive], _status_dec = [state.reactive], _isDragSource_dec = [state.derived], _c) {
|
|
558
558
|
constructor(_a, manager) {
|
|
559
559
|
var _b = _a, { modifiers, type, sensors } = _b, input = __objRest(_b, ["modifiers", "type", "sensors"]);
|
|
560
560
|
super(input, manager);
|
|
561
561
|
__runInitializers(_init3, 5, this);
|
|
562
|
-
__privateAdd(this, _modifiers);
|
|
563
|
-
__privateAdd(this, _type, __runInitializers(_init3,
|
|
564
|
-
__privateAdd(this, _status, __runInitializers(_init3,
|
|
562
|
+
__privateAdd(this, _modifiers, __runInitializers(_init3, 8, this)), __runInitializers(_init3, 11, this);
|
|
563
|
+
__privateAdd(this, _type, __runInitializers(_init3, 12, this)), __runInitializers(_init3, 15, this);
|
|
564
|
+
__privateAdd(this, _status, __runInitializers(_init3, 16, this, "idle")), __runInitializers(_init3, 19, this);
|
|
565
565
|
this.type = type;
|
|
566
566
|
this.sensors = sensors;
|
|
567
567
|
this.modifiers = modifiers;
|
|
568
568
|
}
|
|
569
|
-
set modifiers(modifiers) {
|
|
570
|
-
var _a;
|
|
571
|
-
const { manager } = this;
|
|
572
|
-
(_a = __privateGet(this, _modifiers)) == null ? void 0 : _a.forEach((modifier) => modifier.destroy());
|
|
573
|
-
if (!manager) return;
|
|
574
|
-
__privateSet(this, _modifiers, modifiers == null ? void 0 : modifiers.map((modifier) => {
|
|
575
|
-
const { plugin, options } = descriptor(modifier);
|
|
576
|
-
return new plugin(manager, options);
|
|
577
|
-
}));
|
|
578
|
-
}
|
|
579
|
-
get modifiers() {
|
|
580
|
-
return __privateGet(this, _modifiers);
|
|
581
|
-
}
|
|
582
569
|
get isDragSource() {
|
|
583
570
|
var _a, _b;
|
|
584
571
|
return ((_b = (_a = this.manager) == null ? void 0 : _a.dragOperation.source) == null ? void 0 : _b.id) === this.id;
|
|
585
572
|
}
|
|
586
|
-
destroy() {
|
|
587
|
-
var _a;
|
|
588
|
-
super.destroy();
|
|
589
|
-
(_a = this.modifiers) == null ? void 0 : _a.forEach((modifier) => modifier.destroy());
|
|
590
|
-
}
|
|
591
573
|
};
|
|
592
574
|
_init3 = __decoratorStart(_c);
|
|
593
575
|
_modifiers = new WeakMap();
|
|
594
576
|
_type = new WeakMap();
|
|
595
577
|
_status = new WeakMap();
|
|
578
|
+
__decorateElement(_init3, 4, "modifiers", _modifiers_dec, Draggable, _modifiers);
|
|
596
579
|
__decorateElement(_init3, 4, "type", _type_dec, Draggable, _type);
|
|
597
580
|
__decorateElement(_init3, 4, "status", _status_dec, Draggable, _status);
|
|
598
581
|
__decorateElement(_init3, 2, "isDragSource", _isDragSource_dec, Draggable);
|
|
@@ -788,10 +771,20 @@ function DragOperationManager(manager) {
|
|
|
788
771
|
const identifier = targetIdentifier.value;
|
|
789
772
|
return identifier != null ? (_a = droppables.get(identifier)) != null ? _a : null : null;
|
|
790
773
|
});
|
|
774
|
+
const modifiers = state.signal([]);
|
|
775
|
+
state.effect(() => {
|
|
776
|
+
var _a, _b, _c3;
|
|
777
|
+
const currentModifiers = modifiers.peek();
|
|
778
|
+
if (currentModifiers !== manager.modifiers) {
|
|
779
|
+
currentModifiers.forEach((modifier) => modifier.destroy());
|
|
780
|
+
}
|
|
781
|
+
modifiers.value = (_c3 = (_b = (_a = source.value) == null ? void 0 : _a.modifiers) == null ? void 0 : _b.map((modifier) => {
|
|
782
|
+
const { plugin, options } = descriptor(modifier);
|
|
783
|
+
return new plugin(manager, options);
|
|
784
|
+
})) != null ? _c3 : manager.modifiers;
|
|
785
|
+
});
|
|
791
786
|
const transform = state.computed(() => {
|
|
792
|
-
var _a, _b;
|
|
793
787
|
const { x, y } = position.delta;
|
|
794
|
-
const modifiers = (_b = (_a = source == null ? void 0 : source.value) == null ? void 0 : _a.modifiers) != null ? _b : manager.modifiers;
|
|
795
788
|
let transform2 = { x, y };
|
|
796
789
|
const initialShape = shape.initial.peek();
|
|
797
790
|
const currentShape = shape.current.peek();
|
|
@@ -812,7 +805,7 @@ function DragOperationManager(manager) {
|
|
|
812
805
|
shape: initialShape && currentShape ? { initial: initialShape, current: currentShape } : null,
|
|
813
806
|
position
|
|
814
807
|
};
|
|
815
|
-
for (const modifier of modifiers) {
|
|
808
|
+
for (const modifier of modifiers.value) {
|
|
816
809
|
transform2 = modifier.apply(__spreadProps(__spreadValues({}, operation2), { transform: transform2 }));
|
|
817
810
|
}
|
|
818
811
|
return transform2;
|
|
@@ -882,6 +875,7 @@ function DragOperationManager(manager) {
|
|
|
882
875
|
shape.current.value = null;
|
|
883
876
|
shape.initial.value = null;
|
|
884
877
|
position.reset({ x: 0, y: 0 });
|
|
878
|
+
modifiers.value = [];
|
|
885
879
|
});
|
|
886
880
|
};
|
|
887
881
|
return {
|
|
@@ -907,6 +901,12 @@ function DragOperationManager(manager) {
|
|
|
907
901
|
return manager.renderer.rendering;
|
|
908
902
|
},
|
|
909
903
|
start({ event, coordinates }) {
|
|
904
|
+
const sourceInstance = source.peek();
|
|
905
|
+
if (!sourceInstance) {
|
|
906
|
+
throw new Error(
|
|
907
|
+
"Cannot start a drag operation without a drag source"
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
910
|
state.batch(() => {
|
|
911
911
|
dragended.value = false;
|
|
912
912
|
canceled.value = false;
|
package/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["src/core/collision/observer.ts","src/core/plugins/plugin.ts","src/core/plugins/utilities.ts","src/core/plugins/registry.ts","src/core/collision/utilities.ts","src/core/collision/notifier.ts","src/core/manager/events.ts","src/core/collision/types.ts","src/core/entities/entity/entity.ts","src/core/entities/entity/registry.ts","src/core/entities/draggable/draggable.ts","src/core/entities/droppable/droppable.ts","src/core/sensors/sensor.ts","src/core/modifiers/modifier.ts","src/core/manager/registry.ts","src/core/manager/dragOperation.ts","src/core/manager/renderer.ts","src/core/manager/manager.ts"],"names":["untracked","effect","CollisionPriority","reactive","_disabled_dec","_init","_disabled","effects","manager","signal","derived","_type_dec","_c","_type","batch","computed","Status","transform","operation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAAA;AAAA,EAEA;AAAA,OACK;;;ACRP,SAAQ,UAAU,iBAAgB;;;ACO3B,SAAS,UAGd,QAAW,SAA2C;AACtD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,aACd,QACA;AACA,SAAO,CAAC,YAAkE;AACxE,WAAO,UAAU,QAAQ,OAAO;AAAA,EAClC;AACF;AAEO,SAAS,WACd,QAC+B;AAC/B,MAAI,OAAO,WAAW,YAAY;AAChC,WAAO;AAAA,MACL;AAAA,MACA,SAAS;AAAA,IACX;AAAA,EACF;AAEA,SAAO;AACT;;;ADpCA;AAuBE,iBAAC;AAbI,IAAe,SAAf,MAGL;AAAA,EACA,YACS,SACA,SACP;AAFO;AACA;A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B;AACF;;;ACcO,IAAM,kBAAN,MAAgE;AAAA,EAQrE,YAAY,QAAoC;AAG9C,UAAM;AAAA,MACJ,UAAU,CAAC;AAAA,MACX,UAAU,CAAC;AAAA,MACX,YAAY,CAAC;AAAA,MACb,WAAW;AAAA,IACb,IAAI,0BAAU,CAAC;AACf,UAAM,UAAU,IAAI,gBAAyB,IAAI;AACjD,UAAM,WAAW,IAAI,iBAA0B,IAAI;AAEnD,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,WAAW;AAEhB,UAAM,EAAC,SAAS,UAAS,IAAI,qBAA8B,IAAI;AAE/D,SAAK,UAAU;AACf,SAAK,gBAAgB;AACrB,SAAK,oBAAoB,IAAI,kBAA2B,IAAI;AAC5D,SAAK,UAAU,CAAC,mBAAmB,GAAG,OAAO;AAC7C,SAAK,YAAY;AACjB,SAAK,UAAU;AACf,SAAK,UAAU,KAAK,QAAQ,KAAK,IAAI;AAAA,EACvC;AAAA,EAEA,IAAI,UAAyB;AAC3B,WAAO,KAAK,SAAS,QAAQ;AAAA,EAC/B;AAAA,EAEA,IAAI,QAAQ,SAAuB;AACjC,SAAK,SAAS,QAAQ,SAAS;AAAA,EACjC;AAAA,EAEA,IAAI,YAA6B;AAC/B,WAAO,KAAK,SAAS,UAAU;AAAA,EACjC;AAAA,EAEA,IAAI,UAAU,WAA2B;AACvC,SAAK,SAAS,UAAU,SAAS;AAAA,EACnC;AAAA,EAEA,IAAI,UAAyB;AAC3B,WAAO,KAAK,SAAS,QAAQ;AAAA,EAC/B;AAAA,EAEA,IAAI,QAAQ,SAAuB;AACjC,SAAK,SAAS,QAAQ,SAAS;AAAA,EACjC;AAAA,EAEO,UAAU;AACf,SAAK,SAAS,QAAQ;AACtB,SAAK,kBAAkB,QAAQ;AAAA,EACjC;AACF","sourcesContent":["import {\n batch,\n computed,\n deepEqual,\n signal,\n untracked,\n type ReadonlySignal,\n effect,\n} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport {Plugin} from '../plugins/index.ts';\nimport type {Collision, CollisionDetector, Collisions} from './types.ts';\nimport {sortCollisions} from './utilities.ts';\n\nconst DEFAULT_VALUE: Collisions = [];\n\nexport class CollisionObserver<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n V extends DragDropManager<T, U> = DragDropManager<T, U>,\n> extends Plugin<V> {\n constructor(manager: V) {\n super(manager);\n\n this.computeCollisions = this.computeCollisions.bind(this);\n this.#collisions = computed(this.computeCollisions, deepEqual);\n\n this.destroy = effect(() => {\n const {dragOperation} = this.manager;\n\n if (dragOperation.status.initialized) {\n this.forceUpdate();\n }\n });\n }\n\n forceUpdateCount = signal(0);\n\n public forceUpdate(refresh = true) {\n untracked(() => {\n const {source} = this.manager.dragOperation;\n\n batch(() => {\n if (refresh) {\n for (const droppable of this.manager.registry.droppables) {\n if (source && !droppable.accepts(source)) {\n continue;\n }\n\n droppable.refreshShape();\n }\n }\n\n this.forceUpdateCount.value++;\n });\n });\n }\n\n public computeCollisions(\n entries?: Droppable[],\n collisionDetector?: CollisionDetector\n ) {\n const {registry, dragOperation} = this.manager;\n const {source, shape, status} = dragOperation;\n\n if (!status.initialized || !shape) {\n return DEFAULT_VALUE;\n }\n\n const collisions: Collision[] = [];\n\n this.forceUpdateCount.value;\n\n for (const entry of entries ?? registry.droppables) {\n if (entry.disabled) {\n continue;\n }\n\n if (source && !entry.accepts(source)) {\n continue;\n }\n\n const detectCollision = collisionDetector ?? entry.collisionDetector;\n\n if (!detectCollision) {\n continue;\n }\n\n const collision = untracked(() =>\n detectCollision({\n droppable: entry,\n dragOperation,\n })\n );\n\n if (collision) {\n if (entry.collisionPriority != null) {\n collision.priority = entry.collisionPriority;\n }\n\n collisions.push(collision);\n }\n }\n\n collisions.sort(sortCollisions);\n\n return collisions;\n }\n\n public get collisions() {\n return this.#collisions.value;\n }\n\n #collisions: ReadonlySignal<Collisions>;\n}\n","import {reactive, untracked} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {PluginOptions} from './types.ts';\nimport {configure} from './utilities.ts';\n\n/**\n * An abstract plugin class that can be extended to implement custom\n * functionality that augments the `DragDropManager`'s core capabilities.\n */\nexport abstract class Plugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> {\n constructor(\n public manager: T,\n public options?: U\n ) {}\n\n /**\n * Whether the plugin instance is disabled.\n * Triggers effects when accessed.\n */\n @reactive\n public accessor disabled: boolean = false;\n\n /**\n * Enable a disabled plugin instance.\n * Triggers effects.\n */\n public enable() {\n this.disabled = false;\n }\n\n /**\n * Disable an enabled plugin instance.\n * Triggers effects.\n */\n public disable() {\n this.disabled = true;\n }\n\n /**\n * Whether the plugin instance is disabled.\n * Does not trigger effects when accessed.\n */\n public isDisabled() {\n return untracked(() => {\n return this.disabled;\n });\n }\n\n /**\n * Configure a plugin instance with new options.\n */\n public configure(options?: U) {\n this.options = options;\n }\n\n /**\n * Destroy a plugin instance.\n */\n public destroy() {\n /*\n * Each plugin is responsible for implementing its own\n * destroy method to clean up effects and listeners\n */\n }\n\n /**\n * Configure a plugin constructor with options.\n * This method is used to configure the options that the\n * plugin constructor will use to create plugin instances.\n */\n static configure(options: PluginOptions) {\n return configure(this as any, options);\n }\n}\n\nexport class CorePlugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> extends Plugin<T, U> {}\n","import type {\n PluginConstructor,\n PluginOptions,\n PluginDescriptor,\n InferPluginOptions,\n} from './types.ts';\n\nexport function configure<\n T extends PluginConstructor<any, any, any>,\n V extends PluginOptions = InferPluginOptions<T>,\n>(plugin: T, options: V): PluginDescriptor<any, any, T> {\n return {\n plugin,\n options,\n };\n}\n\nexport function configurator<T extends PluginConstructor<any, any, any>>(\n plugin: T\n) {\n return (options: InferPluginOptions<T>): PluginDescriptor<any, any, T> => {\n return configure(plugin, options);\n };\n}\n\nexport function descriptor<T extends PluginConstructor<any, any, any>>(\n plugin: T | PluginDescriptor<any, any, T>\n): PluginDescriptor<any, any, T> {\n if (typeof plugin === 'function') {\n return {\n plugin,\n options: undefined,\n };\n }\n\n return plugin;\n}\n","import {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin, type Plugin} from './plugin.ts';\nimport type {InferPluginOptions, PluginConstructor, Plugins} from './types.ts';\nimport {descriptor} from './utilities.ts';\n\nexport class PluginRegistry<\n T extends DragDropManager<any, any>,\n W extends PluginConstructor<T> = PluginConstructor<T>,\n U extends Plugin<T> = InstanceType<W>,\n> {\n private instances: Map<W, U> = new Map();\n\n constructor(private manager: T) {}\n\n public get values(): U[] {\n return Array.from(this.instances.values());\n }\n\n #previousValues: PluginConstructor<T>[] = [];\n\n public set values(entries: Plugins<T>) {\n const descriptors = entries.map(descriptor);\n const constructors = descriptors.map(({plugin}) => plugin);\n\n for (const plugin of this.#previousValues) {\n if (!constructors.includes(plugin)) {\n if (plugin.prototype instanceof CorePlugin) {\n continue;\n }\n\n this.unregister(plugin as W);\n }\n }\n\n for (const {plugin, options} of descriptors) {\n this.register(plugin as W, options as InferPluginOptions<W>);\n }\n\n this.#previousValues = constructors;\n }\n\n public get<X extends W>(plugin: X): InstanceType<X> | undefined {\n const instance = this.instances.get(plugin);\n\n return instance as any;\n }\n\n public register<X extends W>(\n plugin: X,\n options?: InferPluginOptions<X>\n ): InstanceType<X> {\n const existingInstance = this.instances.get(plugin);\n\n if (existingInstance) {\n return existingInstance as InstanceType<X>;\n }\n\n const instance = new plugin(this.manager, options) as U;\n\n this.instances.set(plugin, instance);\n\n return instance as InstanceType<X>;\n }\n\n public unregister<X extends W>(plugin: X) {\n const instance = this.instances.get(plugin);\n\n if (instance) {\n instance.destroy();\n this.instances.delete(plugin);\n }\n }\n\n public destroy() {\n for (const plugin of this.instances.values()) {\n plugin.destroy();\n }\n\n this.instances.clear();\n }\n}\n","import {Collision} from './types.ts';\n\n/**\n * Sort collisions from greatest to smallest priority\n * Collisions of equal priority are sorted from greatest to smallest value\n */\nexport function sortCollisions(a: Collision, b: Collision) {\n if (a.priority === b.priority) {\n return b.value - a.value;\n }\n\n return b.priority - a.priority;\n}\n","import {effect, untracked} from '@dnd-kit/state';\n\nimport {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin} from '../plugins/index.ts';\nimport {defaultPreventable} from '../manager/events.ts';\n\nexport class CollisionNotifier extends CorePlugin {\n constructor(manager: DragDropManager<any, any>) {\n super(manager);\n\n this.destroy = effect(() => {\n const {collisionObserver, monitor} = manager;\n const {collisions} = collisionObserver;\n\n if (collisionObserver.isDisabled()) {\n return;\n }\n\n const event = defaultPreventable({\n collisions,\n });\n\n monitor.dispatch('collision', event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n const [firstCollision] = collisions;\n\n untracked(() => {\n if (firstCollision?.id !== manager.dragOperation.target?.id) {\n collisionObserver.disable();\n\n manager.actions.setDropTarget(firstCollision?.id).then(() => {\n collisionObserver.enable();\n });\n }\n });\n });\n }\n}\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport type {Collisions} from '../collision/index.ts';\nimport type {DragDropManager} from './manager.ts';\nimport type {DragOperation} from './dragOperation.ts';\n\nexport type Events = Record<string, (...args: any[]) => void>;\n\nexport type Preventable<T> = T & {\n cancelable: boolean;\n defaultPrevented: boolean;\n preventDefault(): void;\n};\n\nclass Monitor<T extends Events> {\n private registry = new Map<keyof T, Set<T[keyof T]>>();\n\n public addEventListener<U extends keyof T>(name: U, handler: T[U]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.add(handler);\n registry.set(name, listeners);\n\n return () => this.removeEventListener(name, handler);\n }\n\n public removeEventListener(name: keyof T, handler: T[keyof T]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.delete(handler);\n registry.set(name, listeners);\n }\n\n protected dispatch<U extends keyof T>(name: U, ...args: any[]) {\n const {registry} = this;\n const listeners = registry.get(name);\n\n if (!listeners) {\n return;\n }\n\n for (const listener of listeners) {\n listener(...args);\n }\n }\n}\n\nexport type DragDropEvents<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = {\n collision(\n event: Preventable<{\n collisions: Collisions;\n }>,\n manager: V\n ): void;\n beforedragstart(\n event: Preventable<{operation: DragOperation<T, U>}>,\n manager: V\n ): void;\n dragstart(\n event: {\n cancelable: false;\n operation: DragOperation<T, U>;\n },\n manager: V\n ): void;\n dragmove(\n event: Preventable<{\n operation: DragOperation<T, U>;\n to?: Coordinates;\n by?: Coordinates;\n }>,\n manager: V\n ): void;\n dragover(\n event: Preventable<{\n operation: DragOperation<T, U>;\n }>,\n manager: V\n ): void;\n dragend(\n event: {\n operation: DragOperation<T, U>;\n canceled: boolean;\n suspend(): {resume(): void; abort(): void};\n },\n manager: V\n ): void;\n};\n\nexport class DragDropMonitor<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> extends Monitor<DragDropEvents<T, U, V>> {\n constructor(private manager: V) {\n super();\n }\n\n public dispatch<Key extends keyof DragDropEvents<T, U, V>>(\n type: Key,\n event: Parameters<DragDropEvents<T, U, V>[Key]>[0]\n ) {\n const args = [event, this.manager] as any;\n\n super.dispatch(type, ...args);\n }\n}\n\nexport function defaultPreventable<T>(\n event: T,\n cancelable = true\n): Preventable<T> {\n let defaultPrevented = false;\n\n return {\n ...event,\n cancelable,\n get defaultPrevented() {\n return defaultPrevented;\n },\n preventDefault() {\n if (!cancelable) {\n return;\n }\n\n defaultPrevented = true;\n },\n };\n}\n","import type {DragOperation} from '../manager/index.ts';\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.ts';\n\nexport enum CollisionPriority {\n Lowest,\n Low,\n Normal,\n High,\n Highest,\n}\n\nexport interface Collision {\n id: UniqueIdentifier;\n priority: CollisionPriority | number;\n value: number;\n}\n\nexport type Collisions = Collision[];\n\nexport interface CollisionDetectorInput<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n droppable: U;\n dragOperation: DragOperation<T, U>;\n}\n\nexport type CollisionDetector = <\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n>(\n input: CollisionDetectorInput<T, U>\n) => Collision | null;\n","import {CleanupFunction, reactive, type Effect} from '@dnd-kit/state';\n\nimport {DragDropManager} from '../../manager/index.ts';\nimport type {Data, UniqueIdentifier} from './types.ts';\n\nexport interface Input<T extends Data = Data> {\n id: UniqueIdentifier;\n data?: T;\n disabled?: boolean;\n effects?(): Effect[];\n}\n\n/**\n * The `Entity` class is an abstract representation of a distinct unit in the drag and drop system.\n * It is a base class that other concrete classes like `Draggable` and `Droppable` can extend.\n *\n * @template T - The type of data associated with the entity.\n */\nexport class Entity<\n T extends Data = Data,\n U extends DragDropManager<any, any> = DragDropManager<any, any>,\n> {\n /**\n * Creates a new instance of the `Entity` class.\n *\n * @param input - An object containing the initial properties of the entity.\n * @param manager - The manager that controls the drag and drop operations.\n */\n constructor(input: Input<T>, manager: U | undefined) {\n const {effects, id, data = {}, disabled = false} = input;\n\n let previousId = id;\n\n this.manager = manager;\n this.id = id;\n this.data = data;\n this.disabled = disabled;\n this.effects = () => [\n () => {\n // Re-run this effect whenever the `id` changes\n const {id: _, manager} = this;\n\n if (id === previousId) {\n return;\n }\n\n manager?.registry.register(this);\n\n return () => manager?.registry.unregister(this);\n },\n ...(effects?.() ?? []),\n ];\n this.destroy = this.destroy.bind(this);\n\n if (manager) {\n queueMicrotask(() => {\n this.manager?.registry.register(this);\n });\n }\n }\n\n /**\n * The manager that controls the drag and drop operations.\n */\n @reactive\n public accessor manager: U | undefined;\n\n /**\n * The unique identifier of the entity.\n */\n @reactive\n public accessor id: UniqueIdentifier;\n\n /**\n * The data associated with the entity.\n */\n @reactive\n public accessor data: Data;\n\n /**\n * A boolean indicating whether the entity is disabled.\n */\n @reactive\n public accessor disabled: boolean;\n\n /**\n * An array of effects that are applied to the entity.\n */\n public effects: () => Effect[];\n\n /**\n * A method that registers the entity with the manager.\n * @returns CleanupFunction | void\n */\n public register(): CleanupFunction | void {\n return this.manager?.registry.register(this);\n }\n\n /**\n * A method that unregisters the entity from the manager.\n * @returns void\n */\n public unregister(): void {\n this.manager?.registry.unregister(this);\n }\n\n /**\n * A method that cleans up the entity when it is no longer needed.\n * @returns void\n */\n public destroy(): void {\n this.manager?.registry.unregister(this);\n }\n}\n","import {effects, signal} from '@dnd-kit/state';\n\nimport type {Entity} from './entity.ts';\nimport type {UniqueIdentifier} from './types.ts';\n\n/**\n * Reactive class representing a registry for entities.\n * @template T - The type of entries that the registry manages,\n * for example, `Draggable` or `Droppable` entities.\n */\nexport class EntityRegistry<T extends Entity> {\n private map = signal<Map<UniqueIdentifier, T>>(new Map());\n private cleanupFunctions = new WeakMap<T, () => void>();\n\n /**\n * Iterator for the EntityRegistry class.\n * @returns An iterator for the values in the map.\n */\n public [Symbol.iterator]() {\n return this.map.peek().values();\n }\n\n public get value() {\n return this.map.value.values();\n }\n\n /**\n * Checks if a entity with the given identifier exists in the registry.\n * @param identifier - The unique identifier of the entity.\n * @returns True if the entity exists, false otherwise.\n */\n public has(identifier: UniqueIdentifier): boolean {\n return this.map.value.has(identifier);\n }\n\n /**\n * Retrieves a entity from the registry using its identifier.\n * @param identifier - The unique identifier of the entity.\n * @returns The entity if it exists, undefined otherwise.\n */\n public get(identifier: UniqueIdentifier): T | undefined {\n return this.map.value.get(identifier);\n }\n\n /**\n * Registers a entity in the registry.\n * @param key - The unique identifier of the entity.\n * @param value - The entity to register.\n * @returns A function that unregisters the entity.\n */\n public register = (key: UniqueIdentifier, value: T) => {\n const current = this.map.peek();\n\n if (current.get(key) === value) {\n return;\n }\n\n const updatedMap = new Map(current);\n updatedMap.set(key, value);\n\n this.map.value = updatedMap;\n\n const cleanup = effects(...value.effects());\n this.cleanupFunctions.set(value, cleanup);\n\n return () => this.unregister(key, value);\n };\n\n /**\n * Unregisters an entity from the registry.\n * @param key - The unique identifier of the entity.\n * @param value - The entity instance to unregister.\n */\n public unregister = (key: UniqueIdentifier, value: T) => {\n const current = this.map.peek();\n\n if (current.get(key) !== value) {\n return;\n }\n\n const cleanup = this.cleanupFunctions.get(value);\n cleanup?.();\n this.cleanupFunctions.delete(value);\n\n const updatedMap = new Map(current);\n updatedMap.delete(key);\n\n this.map.value = updatedMap;\n };\n\n /**\n * Destroys all entries in the registry and clears the registry.\n */\n public destroy() {\n for (const entry of this) {\n const cleanup = this.cleanupFunctions.get(entry);\n cleanup?.();\n entry.destroy();\n }\n\n this.map.value = new Map();\n }\n}\n","import {derived, reactive} from '@dnd-kit/state';\n\nimport {Entity} from '../entity/index.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport {Modifier} from '../../modifiers/index.ts';\nimport type {Modifiers} from '../../modifiers/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport {descriptor} from '../../plugins/index.ts';\nimport type {Sensors} from '../../sensors/sensor.ts';\n\nexport interface Input<T extends Data = Data> extends EntityInput<T> {\n type?: Type;\n modifiers?: Modifiers;\n sensors?: Sensors;\n}\n\nexport type DraggableStatus = 'idle' | 'dragging' | 'dropping';\n\nexport class Draggable<\n T extends Data = Data,\n U extends DragDropManager<any, any> = DragDropManager<any, any>,\n> extends Entity<T> {\n constructor(\n {modifiers, type, sensors, ...input}: Input<T>,\n manager: U | undefined\n ) {\n super(input, manager);\n\n this.type = type;\n this.sensors = sensors;\n this.modifiers = modifiers;\n }\n\n public sensors: Sensors | undefined;\n\n #modifiers: Modifier[] | undefined;\n\n public set modifiers(modifiers: Modifiers | undefined) {\n const {manager} = this;\n\n this.#modifiers?.forEach((modifier) => modifier.destroy());\n\n if (!manager) return;\n this.#modifiers = modifiers?.map((modifier) => {\n const {plugin, options} = descriptor(modifier);\n\n return new plugin(manager, options);\n });\n }\n\n public get modifiers(): Modifier[] | undefined {\n return this.#modifiers;\n }\n\n @reactive\n public accessor type: Type | undefined;\n\n @reactive\n public accessor status: DraggableStatus = 'idle';\n\n /**\n * A boolean indicating whether the draggable item is the source of a drag operation.\n */\n @derived\n public get isDragSource() {\n return this.manager?.dragOperation.source?.id === this.id;\n }\n\n public destroy() {\n super.destroy();\n\n this.modifiers?.forEach((modifier) => modifier.destroy());\n }\n}\n","import {derived, effects, reactive, type Effect} from '@dnd-kit/state';\nimport type {Shape} from '@dnd-kit/geometry';\n\nimport {Entity} from '../entity/index.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport {\n CollisionPriority,\n type CollisionDetector,\n} from '../../collision/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport {Draggable} from '../draggable/draggable.ts';\n\nexport interface Input<T extends Data = Data> extends EntityInput<T> {\n accept?: Type | Type[] | ((source: Draggable) => boolean);\n collisionPriority?: CollisionPriority | number;\n collisionDetector: CollisionDetector;\n type?: Type;\n}\n\nexport class Droppable<\n T extends Data = Data,\n U extends DragDropManager<any, any> = DragDropManager<any, any>,\n> extends Entity<T> {\n constructor(\n {\n accept,\n collisionDetector,\n collisionPriority = CollisionPriority.Normal,\n type,\n ...input\n }: Input<T>,\n manager: U | undefined\n ) {\n super(input, manager);\n\n this.accept = accept;\n this.collisionDetector = collisionDetector;\n this.collisionPriority = collisionPriority;\n this.type = type;\n }\n\n /**\n * An array of types that are compatible with the droppable.\n */\n @reactive\n public accessor accept:\n | Type\n | Type[]\n | ((draggable: Draggable) => boolean)\n | undefined;\n\n /**\n * The type of the droppable.\n */\n @reactive\n public accessor type: Type | undefined;\n\n /**\n * Checks whether or not the droppable accepts a given draggable.\n *\n * @param {Draggable} draggable\n * @returns {boolean}\n */\n public accepts(draggable: Draggable): boolean {\n const {accept} = this;\n\n if (!accept) {\n return true;\n }\n\n if (!draggable.type) {\n return false;\n }\n\n if (Array.isArray(accept)) {\n return accept.includes(draggable.type);\n }\n\n if (typeof accept === 'function') {\n return accept(draggable);\n }\n\n return draggable.type === accept;\n }\n\n @reactive\n public accessor collisionDetector: CollisionDetector;\n\n @reactive\n public accessor collisionPriority: number;\n\n @reactive\n public accessor shape: Shape | undefined;\n\n @derived\n public get isDropTarget() {\n return this.manager?.dragOperation.target?.id === this.id;\n }\n\n public refreshShape() {\n // To be implemented by subclasses\n }\n}\n","import {CleanupFunction} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport {\n Plugin,\n type PluginConstructor,\n type PluginDescriptor,\n type PluginOptions,\n} from '../plugins/index.ts';\n\nexport type SensorOptions = PluginOptions;\n\nexport abstract class Sensor<\n T extends DragDropManager<any, any> = DragDropManager<Draggable, Droppable>,\n U extends SensorOptions = SensorOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n /**\n * Bind the sensor to a draggable source, and optionally pass\n * in sensor options to override the default sensor options\n * for this draggable source only.\n */\n public abstract bind(source: Draggable, options?: U): CleanupFunction;\n}\n\nexport type SensorConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Sensor<T>>;\n\nexport type SensorDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Sensor<T>, SensorConstructor<T>>;\n\nexport type Sensors<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (SensorConstructor<T> | SensorDescriptor<T>)[];\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport {\n Plugin,\n type PluginOptions,\n type PluginConstructor,\n type PluginDescriptor,\n} from '../plugins/index.ts';\nimport type {DragDropManager} from '../manager/index.ts';\n\nexport type ModifierOptions = PluginOptions;\n\nexport class Modifier<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends ModifierOptions = ModifierOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n public apply(operation: T['dragOperation']): Coordinates {\n return operation.transform;\n }\n}\n\nexport type ModifierConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Modifier<T, any>>;\n\nexport type ModifierDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Modifier<T, any>, ModifierConstructor<T>>;\n\nexport type Modifiers<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (ModifierConstructor<T> | ModifierDescriptor<T>)[];\n","import type {CleanupFunction} from '@dnd-kit/state';\n\nimport {\n Draggable,\n Droppable,\n Entity,\n EntityRegistry,\n} from '../entities/index.ts';\nimport {\n PluginRegistry,\n Plugin,\n type PluginConstructor,\n PluginOptions,\n} from '../plugins/index.ts';\nimport {\n Sensor,\n SensorOptions,\n type SensorConstructor,\n} from '../sensors/index.ts';\nimport {Modifier, type ModifierConstructor} from '../modifiers/index.ts';\nimport type {DragDropManager} from './manager.ts';\n\nexport class DragDropRegistry<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> {\n constructor(manager: V) {\n this.plugins = new PluginRegistry<V, PluginConstructor<V>>(manager);\n this.sensors = new PluginRegistry<V, SensorConstructor<V>>(manager);\n this.modifiers = new PluginRegistry<V, ModifierConstructor<V>>(manager);\n }\n\n public draggables = new EntityRegistry<T>();\n public droppables = new EntityRegistry<U>();\n public plugins: PluginRegistry<V, PluginConstructor<V>>;\n public sensors: PluginRegistry<V, SensorConstructor<V>>;\n public modifiers: PluginRegistry<V, ModifierConstructor<V>>;\n\n public register(input: Entity): () => void;\n public register(input: Draggable): () => void;\n public register(input: Droppable): () => void;\n public register(input: SensorConstructor, options?: SensorOptions): Sensor;\n public register(input: ModifierConstructor): Modifier;\n public register(input: PluginConstructor, options?: PluginOptions): Plugin;\n public register(input: any, options?: Record<string, any>) {\n if (input instanceof Draggable) {\n return this.draggables.register(input.id, input as T);\n }\n\n if (input instanceof Droppable) {\n return this.droppables.register(input.id, input as U);\n }\n\n if (input.prototype instanceof Modifier) {\n return this.modifiers.register(input, options);\n }\n\n if (input.prototype instanceof Sensor) {\n return this.sensors.register(input, options);\n }\n\n if (input.prototype instanceof Plugin) {\n return this.plugins.register(input, options);\n }\n\n throw new Error('Invalid instance type');\n }\n\n public unregister(input: Entity): CleanupFunction;\n public unregister(input: Draggable): CleanupFunction;\n public unregister(input: Droppable): CleanupFunction;\n public unregister(input: SensorConstructor): CleanupFunction;\n public unregister(input: ModifierConstructor): CleanupFunction;\n public unregister(input: PluginConstructor): CleanupFunction;\n public unregister(input: any) {\n if (input instanceof Entity) {\n if (input instanceof Draggable) {\n return this.draggables.unregister(input.id, input as T);\n }\n\n if (input instanceof Droppable) {\n return this.droppables.unregister(input.id, input as U);\n }\n\n // no-op\n return () => {};\n }\n\n if (input.prototype instanceof Modifier) {\n return this.modifiers.unregister(input);\n }\n\n if (input.prototype instanceof Sensor) {\n return this.sensors.unregister(input);\n }\n\n if (input.prototype instanceof Plugin) {\n return this.plugins.unregister(input);\n }\n\n throw new Error('Invalid instance type');\n }\n\n destroy() {\n this.draggables.destroy();\n this.droppables.destroy();\n this.plugins.destroy();\n this.sensors.destroy();\n this.modifiers.destroy();\n }\n}\n","import {Position, type Shape} from '@dnd-kit/geometry';\nimport type {Coordinates} from '@dnd-kit/geometry';\nimport {batch, computed, signal} from '@dnd-kit/state';\n\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.ts';\n\nimport type {DragDropManager} from './manager.ts';\nimport {defaultPreventable} from './events.ts';\n\nexport enum Status {\n Idle = 'idle',\n Initializing = 'initializing',\n Dragging = 'dragging',\n Dropped = 'dropped',\n}\n\nexport type Serializable = {\n [key: string]: string | number | null | Serializable | Serializable[];\n};\n\nexport interface DragOperation<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n activatorEvent: Event | null;\n canceled: boolean;\n position: Position;\n transform: Coordinates;\n status: {\n current: Status;\n initialized: boolean;\n initializing: boolean;\n dragging: boolean;\n dragended: boolean;\n dropped: boolean;\n idle: boolean;\n };\n get shape(): {\n initial: Shape;\n current: Shape;\n } | null;\n set shape(value: Shape | null);\n source: T | null;\n target: U | null;\n data?: Serializable;\n}\n\nexport type DragActions<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = ReturnType<typeof DragOperationManager<T, U, V>>['actions'];\n\nexport function DragOperationManager<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n>(manager: V) {\n const {\n registry: {draggables, droppables},\n monitor,\n } = manager;\n const status = signal<Status>(Status.Idle);\n const shape = {\n initial: signal<Shape | null>(null),\n current: signal<Shape | null>(null),\n };\n const canceled = signal<boolean>(false);\n const position = new Position({x: 0, y: 0});\n const activatorEvent = signal<Event | null>(null);\n const sourceIdentifier = signal<UniqueIdentifier | null>(null);\n const targetIdentifier = signal<UniqueIdentifier | null>(null);\n const dragging = computed(() => status.value === Status.Dragging);\n const initialized = computed(() => status.value !== Status.Idle);\n const initializing = computed(() => status.value === Status.Initializing);\n const idle = computed(() => status.value === Status.Idle);\n const dropped = computed(() => status.value === Status.Dropped);\n const dragended = signal<boolean>(true);\n let previousSource: T | undefined;\n const source = computed<T | null>(() => {\n const identifier = sourceIdentifier.value;\n\n if (identifier == null) return null;\n\n const value = draggables.get(identifier);\n\n if (value) {\n // It's possible for the source to unmount during the drag operation\n previousSource = value;\n }\n\n return value ?? previousSource ?? null;\n });\n const target = computed<U | null>(() => {\n const identifier = targetIdentifier.value;\n return identifier != null ? droppables.get(identifier) ?? null : null;\n });\n\n const transform = computed(() => {\n const {x, y} = position.delta;\n const modifiers = source?.value?.modifiers ?? manager.modifiers;\n\n let transform = {x, y};\n const initialShape = shape.initial.peek();\n const currentShape = shape.current.peek();\n const operation: Omit<DragOperation<T, U>, 'transform'> = {\n activatorEvent: activatorEvent.peek(),\n canceled: canceled.peek(),\n source: source.peek(),\n target: target.peek(),\n status: {\n current: status.peek(),\n idle: idle.peek(),\n initializing: initializing.peek(),\n initialized: initialized.peek(),\n dragging: dragging.peek(),\n dragended: dragended.peek(),\n dropped: dropped.peek(),\n },\n shape:\n initialShape && currentShape\n ? {initial: initialShape, current: currentShape}\n : null,\n position,\n };\n\n for (const modifier of modifiers) {\n transform = modifier.apply({...operation, transform});\n }\n\n return transform;\n });\n\n const operation: DragOperation<T, U> = {\n get activatorEvent() {\n return activatorEvent.value;\n },\n get canceled() {\n return canceled.value;\n },\n get source() {\n return source.value;\n },\n get target() {\n return target.value;\n },\n status: {\n get current() {\n return status.value;\n },\n get idle() {\n return idle.value;\n },\n get initializing() {\n return initializing.value;\n },\n get initialized() {\n return initialized.value;\n },\n get dragging() {\n return dragging.value;\n },\n get dragended() {\n return dragended.value;\n },\n get dropped() {\n return dropped.value;\n },\n },\n get shape(): DragOperation['shape'] {\n const initial = shape.initial.value;\n const current = shape.current.value;\n\n return initial && current ? {initial, current} : null;\n },\n set shape(value: Shape | null) {\n if (value && shape.current.peek()?.equals(value)) {\n return;\n }\n\n const initial = shape.initial.peek();\n\n if (!initial) {\n shape.initial.value = value;\n }\n\n shape.current.value = value;\n },\n get transform() {\n return transform.value;\n },\n position,\n };\n\n const reset = () => {\n batch(() => {\n status.value = Status.Idle;\n sourceIdentifier.value = null;\n targetIdentifier.value = null;\n shape.current.value = null;\n shape.initial.value = null;\n position.reset({x: 0, y: 0});\n });\n };\n\n return {\n operation,\n actions: {\n setDragSource(identifier: UniqueIdentifier) {\n sourceIdentifier.value = identifier;\n },\n setDropTarget(\n identifier: UniqueIdentifier | null | undefined\n ): Promise<void> {\n const id = identifier ?? null;\n\n if (targetIdentifier.peek() === id) {\n return Promise.resolve();\n }\n\n targetIdentifier.value = id;\n\n if (status.peek() === Status.Dragging) {\n monitor.dispatch(\n 'dragover',\n defaultPreventable({\n operation: snapshot(operation),\n })\n );\n }\n\n return manager.renderer.rendering;\n },\n start({event, coordinates}: {event: Event; coordinates: Coordinates}) {\n batch(() => {\n dragended.value = false;\n canceled.value = false;\n activatorEvent.value = event;\n position.reset(coordinates);\n });\n\n const beforeStartEvent = defaultPreventable({\n operation: snapshot(operation),\n });\n\n monitor.dispatch('beforedragstart', beforeStartEvent);\n\n manager.renderer.rendering.then(() => {\n if (beforeStartEvent.defaultPrevented) {\n reset();\n return;\n }\n\n status.value = Status.Initializing;\n\n requestAnimationFrame(() => {\n status.value = Status.Dragging;\n\n monitor.dispatch('dragstart', {\n operation: snapshot(operation),\n cancelable: false,\n });\n });\n });\n },\n move({\n by,\n to,\n cancelable = true,\n }:\n | {by: Coordinates; to?: undefined; cancelable?: boolean}\n | {by?: undefined; to: Coordinates; cancelable?: boolean}) {\n if (!dragging.peek()) {\n return;\n }\n\n const event = defaultPreventable(\n {\n operation: snapshot(operation),\n by,\n to,\n },\n cancelable\n );\n\n monitor.dispatch('dragmove', event);\n\n queueMicrotask(() => {\n if (event.defaultPrevented) {\n return;\n }\n\n const coordinates = to ?? {\n x: position.current.x + by.x,\n y: position.current.y + by.y,\n };\n\n position.update(coordinates);\n });\n },\n stop({canceled: eventCanceled = false}: {canceled?: boolean} = {}) {\n let promise: Promise<void> | undefined;\n const suspend = () => {\n const output = {\n resume: () => {},\n abort: () => {},\n };\n\n promise = new Promise<void>((resolve, reject) => {\n output.resume = resolve;\n output.abort = reject;\n });\n\n return output;\n };\n const end = () => {\n /* Wait for the renderer to finish rendering before finalizing the drag operation */\n manager.renderer.rendering.then(() => {\n status.value = Status.Dropped;\n manager.renderer.rendering.then(reset);\n });\n };\n\n batch(() => {\n dragended.value = true;\n canceled.value = eventCanceled;\n });\n\n monitor.dispatch('dragend', {\n operation: snapshot(operation),\n canceled: eventCanceled,\n suspend,\n });\n\n if (promise) {\n promise.then(end).catch(reset);\n } else {\n end();\n }\n },\n },\n };\n}\n\nfunction snapshot<T extends Record<string, any>>(obj: T): T {\n return {\n ...obj,\n };\n}\n","export interface Renderer {\n get rendering(): Promise<void>;\n}\n\nexport const defaultRenderer: Renderer = {\n get rendering() {\n return Promise.resolve();\n },\n};\n","import type {Draggable, Droppable} from '../entities/index.ts';\nimport {CollisionObserver, CollisionNotifier} from '../collision/index.ts';\nimport type {Plugins, Plugin} from '../plugins/index.ts';\nimport type {Sensor, Sensors} from '../sensors/index.ts';\nimport type {Modifier, Modifiers} from '../modifiers/index.ts';\n\nimport {DragDropRegistry} from './registry.ts';\nimport {\n DragOperationManager,\n type DragOperation,\n type DragActions,\n} from './dragOperation.ts';\nimport {DragDropMonitor} from './events.ts';\nimport {defaultRenderer, type Renderer} from './renderer.ts';\n\nexport type DragDropManagerInput<T extends DragDropManager<any, any>> = {\n plugins?: Plugins<T>;\n sensors?: Sensors<T>;\n modifiers?: Modifiers<T>;\n renderer?: Renderer;\n};\n\nexport class DragDropManager<T extends Draggable, U extends Droppable> {\n public actions: DragActions<T, U, DragDropManager<T, U>>;\n public collisionObserver: CollisionObserver<T, U>;\n public dragOperation: DragOperation<T, U>;\n public monitor: DragDropMonitor<T, U, DragDropManager<T, U>>;\n public registry: DragDropRegistry<T, U, DragDropManager<T, U>>;\n public renderer: Renderer;\n\n constructor(config?: DragDropManagerInput<any>) {\n type V = DragDropManager<T, U>;\n\n const {\n plugins = [],\n sensors = [],\n modifiers = [],\n renderer = defaultRenderer,\n } = config ?? {};\n const monitor = new DragDropMonitor<T, U, V>(this);\n const registry = new DragDropRegistry<T, U, V>(this);\n\n this.registry = registry;\n this.monitor = monitor;\n this.renderer = renderer;\n\n const {actions, operation} = DragOperationManager<T, U, V>(this);\n\n this.actions = actions;\n this.dragOperation = operation;\n this.collisionObserver = new CollisionObserver<T, U, V>(this);\n this.plugins = [CollisionNotifier, ...plugins];\n this.modifiers = modifiers;\n this.sensors = sensors;\n this.destroy = this.destroy.bind(this);\n }\n\n get plugins(): Plugin<any>[] {\n return this.registry.plugins.values;\n }\n\n set plugins(plugins: Plugins<any>) {\n this.registry.plugins.values = plugins;\n }\n\n get modifiers(): Modifier<any>[] {\n return this.registry.modifiers.values;\n }\n\n set modifiers(modifiers: Modifiers<any>) {\n this.registry.modifiers.values = modifiers;\n }\n\n get sensors(): Sensor<any>[] {\n return this.registry.sensors.values;\n }\n\n set sensors(sensors: Sensors<any>) {\n this.registry.sensors.values = sensors;\n }\n\n public destroy() {\n this.registry.destroy();\n this.collisionObserver.destroy();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["src/core/collision/observer.ts","src/core/plugins/plugin.ts","src/core/plugins/utilities.ts","src/core/plugins/registry.ts","src/core/collision/utilities.ts","src/core/collision/notifier.ts","src/core/manager/events.ts","src/core/collision/types.ts","src/core/entities/entity/entity.ts","src/core/entities/entity/registry.ts","src/core/entities/draggable/draggable.ts","src/core/entities/droppable/droppable.ts","src/core/sensors/sensor.ts","src/core/modifiers/modifier.ts","src/core/manager/registry.ts","src/core/manager/dragOperation.ts","src/core/manager/renderer.ts","src/core/manager/manager.ts"],"names":["untracked","effect","CollisionPriority","reactive","_disabled_dec","_init","_disabled","effects","manager","signal","derived","_type_dec","_c","_type","batch","computed","Status","transform","operation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAAA;AAAA,EAEA;AAAA,OACK;;;ACRP,SAAQ,UAAU,iBAAgB;;;ACO3B,SAAS,UAGd,QAAW,SAA2C;AACtD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,aACd,QACA;AACA,SAAO,CAAC,YAAkE;AACxE,WAAO,UAAU,QAAQ,OAAO;AAAA,EAClC;AACF;AAEO,SAAS,WACd,QAC+B;AAC/B,MAAI,OAAO,WAAW,YAAY;AAChC,WAAO;AAAA,MACL;AAAA,MACA,SAAS;AAAA,IACX;AAAA,EACF;AAEA,SAAO;AACT;;;ADpCA;AAuBE,iBAAC;AAbI,IAAe,SAAf,MAGL;AAAA,EACA,YACS,SACA,SACP;AAFO;AACA;AAQT,uBAAgB,WAAoB,kBAApC,gBAAoC,SAApC;AAAA,EAPG;AAAA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al,\n untracked,\n type ReadonlySignal,\n effect,\n} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport {Plugin} from '../plugins/index.ts';\nimport type {Collision, CollisionDetector, Collisions} from './types.ts';\nimport {sortCollisions} from './utilities.ts';\n\nconst DEFAULT_VALUE: Collisions = [];\n\nexport class CollisionObserver<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n V extends DragDropManager<T, U> = DragDropManager<T, U>,\n> extends Plugin<V> {\n constructor(manager: V) {\n super(manager);\n\n this.computeCollisions = this.computeCollisions.bind(this);\n this.#collisions = computed(this.computeCollisions, deepEqual);\n\n this.destroy = effect(() => {\n const {dragOperation} = this.manager;\n\n if (dragOperation.status.initialized) {\n this.forceUpdate();\n }\n });\n }\n\n forceUpdateCount = signal(0);\n\n public forceUpdate(refresh = true) {\n untracked(() => {\n const {source} = this.manager.dragOperation;\n\n batch(() => {\n if (refresh) {\n for (const droppable of this.manager.registry.droppables) {\n if (source && !droppable.accepts(source)) {\n continue;\n }\n\n droppable.refreshShape();\n }\n }\n\n this.forceUpdateCount.value++;\n });\n });\n }\n\n public computeCollisions(\n entries?: Droppable[],\n collisionDetector?: CollisionDetector\n ) {\n const {registry, dragOperation} = this.manager;\n const {source, shape, status} = dragOperation;\n\n if (!status.initialized || !shape) {\n return DEFAULT_VALUE;\n }\n\n const collisions: Collision[] = [];\n\n this.forceUpdateCount.value;\n\n for (const entry of entries ?? registry.droppables) {\n if (entry.disabled) {\n continue;\n }\n\n if (source && !entry.accepts(source)) {\n continue;\n }\n\n const detectCollision = collisionDetector ?? entry.collisionDetector;\n\n if (!detectCollision) {\n continue;\n }\n\n const collision = untracked(() =>\n detectCollision({\n droppable: entry,\n dragOperation,\n })\n );\n\n if (collision) {\n if (entry.collisionPriority != null) {\n collision.priority = entry.collisionPriority;\n }\n\n collisions.push(collision);\n }\n }\n\n collisions.sort(sortCollisions);\n\n return collisions;\n }\n\n public get collisions() {\n return this.#collisions.value;\n }\n\n #collisions: ReadonlySignal<Collisions>;\n}\n","import {reactive, untracked} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {PluginOptions} from './types.ts';\nimport {configure} from './utilities.ts';\n\n/**\n * An abstract plugin class that can be extended to implement custom\n * functionality that augments the `DragDropManager`'s core capabilities.\n */\nexport abstract class Plugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> {\n constructor(\n public manager: T,\n public options?: U\n ) {}\n\n /**\n * Whether the plugin instance is disabled.\n * Triggers effects when accessed.\n */\n @reactive\n public accessor disabled: boolean = false;\n\n /**\n * Enable a disabled plugin instance.\n * Triggers effects.\n */\n public enable() {\n this.disabled = false;\n }\n\n /**\n * Disable an enabled plugin instance.\n * Triggers effects.\n */\n public disable() {\n this.disabled = true;\n }\n\n /**\n * Whether the plugin instance is disabled.\n * Does not trigger effects when accessed.\n */\n public isDisabled() {\n return untracked(() => {\n return this.disabled;\n });\n }\n\n /**\n * Configure a plugin instance with new options.\n */\n public configure(options?: U) {\n this.options = options;\n }\n\n /**\n * Destroy a plugin instance.\n */\n public destroy() {\n /*\n * Each plugin is responsible for implementing its own\n * destroy method to clean up effects and listeners\n */\n }\n\n /**\n * Configure a plugin constructor with options.\n * This method is used to configure the options that the\n * plugin constructor will use to create plugin instances.\n */\n static configure(options: PluginOptions) {\n return configure(this as any, options);\n }\n}\n\nexport class CorePlugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> extends Plugin<T, U> {}\n","import type {\n PluginConstructor,\n PluginOptions,\n PluginDescriptor,\n InferPluginOptions,\n} from './types.ts';\n\nexport function configure<\n T extends PluginConstructor<any, any, any>,\n V extends PluginOptions = InferPluginOptions<T>,\n>(plugin: T, options: V): PluginDescriptor<any, any, T> {\n return {\n plugin,\n options,\n };\n}\n\nexport function configurator<T extends PluginConstructor<any, any, any>>(\n plugin: T\n) {\n return (options: InferPluginOptions<T>): PluginDescriptor<any, any, T> => {\n return configure(plugin, options);\n };\n}\n\nexport function descriptor<T extends PluginConstructor<any, any, any>>(\n plugin: T | PluginDescriptor<any, any, T>\n): PluginDescriptor<any, any, T> {\n if (typeof plugin === 'function') {\n return {\n plugin,\n options: undefined,\n };\n }\n\n return plugin;\n}\n","import {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin, type Plugin} from './plugin.ts';\nimport type {InferPluginOptions, PluginConstructor, Plugins} from './types.ts';\nimport {descriptor} from './utilities.ts';\n\nexport class PluginRegistry<\n T extends DragDropManager<any, any>,\n W extends PluginConstructor<T> = PluginConstructor<T>,\n U extends Plugin<T> = InstanceType<W>,\n> {\n private instances: Map<W, U> = new Map();\n\n constructor(private manager: T) {}\n\n public get values(): U[] {\n return Array.from(this.instances.values());\n }\n\n #previousValues: PluginConstructor<T>[] = [];\n\n public set values(entries: Plugins<T>) {\n const descriptors = entries.map(descriptor);\n const constructors = descriptors.map(({plugin}) => plugin);\n\n for (const plugin of this.#previousValues) {\n if (!constructors.includes(plugin)) {\n if (plugin.prototype instanceof CorePlugin) {\n continue;\n }\n\n this.unregister(plugin as W);\n }\n }\n\n for (const {plugin, options} of descriptors) {\n this.register(plugin as W, options as InferPluginOptions<W>);\n }\n\n this.#previousValues = constructors;\n }\n\n public get<X extends W>(plugin: X): InstanceType<X> | undefined {\n const instance = this.instances.get(plugin);\n\n return instance as any;\n }\n\n public register<X extends W>(\n plugin: X,\n options?: InferPluginOptions<X>\n ): InstanceType<X> {\n const existingInstance = this.instances.get(plugin);\n\n if (existingInstance) {\n return existingInstance as InstanceType<X>;\n }\n\n const instance = new plugin(this.manager, options) as U;\n\n this.instances.set(plugin, instance);\n\n return instance as InstanceType<X>;\n }\n\n public unregister<X extends W>(plugin: X) {\n const instance = this.instances.get(plugin);\n\n if (instance) {\n instance.destroy();\n this.instances.delete(plugin);\n }\n }\n\n public destroy() {\n for (const plugin of this.instances.values()) {\n plugin.destroy();\n }\n\n this.instances.clear();\n }\n}\n","import {Collision} from './types.ts';\n\n/**\n * Sort collisions from greatest to smallest priority\n * Collisions of equal priority are sorted from greatest to smallest value\n */\nexport function sortCollisions(a: Collision, b: Collision) {\n if (a.priority === b.priority) {\n return b.value - a.value;\n }\n\n return b.priority - a.priority;\n}\n","import {effect, untracked} from '@dnd-kit/state';\n\nimport {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin} from '../plugins/index.ts';\nimport {defaultPreventable} from '../manager/events.ts';\n\nexport class CollisionNotifier extends CorePlugin {\n constructor(manager: DragDropManager<any, any>) {\n super(manager);\n\n this.destroy = effect(() => {\n const {collisionObserver, monitor} = manager;\n const {collisions} = collisionObserver;\n\n if (collisionObserver.isDisabled()) {\n return;\n }\n\n const event = defaultPreventable({\n collisions,\n });\n\n monitor.dispatch('collision', event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n const [firstCollision] = collisions;\n\n untracked(() => {\n if (firstCollision?.id !== manager.dragOperation.target?.id) {\n collisionObserver.disable();\n\n manager.actions.setDropTarget(firstCollision?.id).then(() => {\n collisionObserver.enable();\n });\n }\n });\n });\n }\n}\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport type {Collisions} from '../collision/index.ts';\nimport type {DragDropManager} from './manager.ts';\nimport type {DragOperation} from './dragOperation.ts';\n\nexport type Events = Record<string, (...args: any[]) => void>;\n\nexport type Preventable<T> = T & {\n cancelable: boolean;\n defaultPrevented: boolean;\n preventDefault(): void;\n};\n\nclass Monitor<T extends Events> {\n private registry = new Map<keyof T, Set<T[keyof T]>>();\n\n public addEventListener<U extends keyof T>(name: U, handler: T[U]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.add(handler);\n registry.set(name, listeners);\n\n return () => this.removeEventListener(name, handler);\n }\n\n public removeEventListener(name: keyof T, handler: T[keyof T]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.delete(handler);\n registry.set(name, listeners);\n }\n\n protected dispatch<U extends keyof T>(name: U, ...args: any[]) {\n const {registry} = this;\n const listeners = registry.get(name);\n\n if (!listeners) {\n return;\n }\n\n for (const listener of listeners) {\n listener(...args);\n }\n }\n}\n\nexport type DragDropEvents<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = {\n collision(\n event: Preventable<{\n collisions: Collisions;\n }>,\n manager: V\n ): void;\n beforedragstart(\n event: Preventable<{operation: DragOperation<T, U>}>,\n manager: V\n ): void;\n dragstart(\n event: {\n cancelable: false;\n operation: DragOperation<T, U>;\n },\n manager: V\n ): void;\n dragmove(\n event: Preventable<{\n operation: DragOperation<T, U>;\n to?: Coordinates;\n by?: Coordinates;\n }>,\n manager: V\n ): void;\n dragover(\n event: Preventable<{\n operation: DragOperation<T, U>;\n }>,\n manager: V\n ): void;\n dragend(\n event: {\n operation: DragOperation<T, U>;\n canceled: boolean;\n suspend(): {resume(): void; abort(): void};\n },\n manager: V\n ): void;\n};\n\nexport class DragDropMonitor<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> extends Monitor<DragDropEvents<T, U, V>> {\n constructor(private manager: V) {\n super();\n }\n\n public dispatch<Key extends keyof DragDropEvents<T, U, V>>(\n type: Key,\n event: Parameters<DragDropEvents<T, U, V>[Key]>[0]\n ) {\n const args = [event, this.manager] as any;\n\n super.dispatch(type, ...args);\n }\n}\n\nexport function defaultPreventable<T>(\n event: T,\n cancelable = true\n): Preventable<T> {\n let defaultPrevented = false;\n\n return {\n ...event,\n cancelable,\n get defaultPrevented() {\n return defaultPrevented;\n },\n preventDefault() {\n if (!cancelable) {\n return;\n }\n\n defaultPrevented = true;\n },\n };\n}\n","import type {DragOperation} from '../manager/index.ts';\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.ts';\n\nexport enum CollisionPriority {\n Lowest,\n Low,\n Normal,\n High,\n Highest,\n}\n\nexport interface Collision {\n id: UniqueIdentifier;\n priority: CollisionPriority | number;\n value: number;\n}\n\nexport type Collisions = Collision[];\n\nexport interface CollisionDetectorInput<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n droppable: U;\n dragOperation: DragOperation<T, U>;\n}\n\nexport type CollisionDetector = <\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n>(\n input: CollisionDetectorInput<T, U>\n) => Collision | null;\n","import {CleanupFunction, reactive, type Effect} from '@dnd-kit/state';\n\nimport {DragDropManager} from '../../manager/index.ts';\nimport type {Data, UniqueIdentifier} from './types.ts';\n\nexport interface Input<T extends Data = Data> {\n id: UniqueIdentifier;\n data?: T;\n disabled?: boolean;\n effects?(): Effect[];\n}\n\n/**\n * The `Entity` class is an abstract representation of a distinct unit in the drag and drop system.\n * It is a base class that other concrete classes like `Draggable` and `Droppable` can extend.\n *\n * @template T - The type of data associated with the entity.\n */\nexport class Entity<\n T extends Data = Data,\n U extends DragDropManager<any, any> = DragDropManager<any, any>,\n> {\n /**\n * Creates a new instance of the `Entity` class.\n *\n * @param input - An object containing the initial properties of the entity.\n * @param manager - The manager that controls the drag and drop operations.\n */\n constructor(input: Input<T>, manager: U | undefined) {\n const {effects, id, data = {}, disabled = false} = input;\n\n let previousId = id;\n\n this.manager = manager;\n this.id = id;\n this.data = data;\n this.disabled = disabled;\n this.effects = () => [\n () => {\n // Re-run this effect whenever the `id` changes\n const {id: _, manager} = this;\n\n if (id === previousId) {\n return;\n }\n\n manager?.registry.register(this);\n\n return () => manager?.registry.unregister(this);\n },\n ...(effects?.() ?? []),\n ];\n this.destroy = this.destroy.bind(this);\n\n if (manager) {\n queueMicrotask(() => {\n this.manager?.registry.register(this);\n });\n }\n }\n\n /**\n * The manager that controls the drag and drop operations.\n */\n @reactive\n public accessor manager: U | undefined;\n\n /**\n * The unique identifier of the entity.\n */\n @reactive\n public accessor id: UniqueIdentifier;\n\n /**\n * The data associated with the entity.\n */\n @reactive\n public accessor data: Data;\n\n /**\n * A boolean indicating whether the entity is disabled.\n */\n @reactive\n public accessor disabled: boolean;\n\n /**\n * An array of effects that are applied to the entity.\n */\n public effects: () => Effect[];\n\n /**\n * A method that registers the entity with the manager.\n * @returns CleanupFunction | void\n */\n public register(): CleanupFunction | void {\n return this.manager?.registry.register(this);\n }\n\n /**\n * A method that unregisters the entity from the manager.\n * @returns void\n */\n public unregister(): void {\n this.manager?.registry.unregister(this);\n }\n\n /**\n * A method that cleans up the entity when it is no longer needed.\n * @returns void\n */\n public destroy(): void {\n this.manager?.registry.unregister(this);\n }\n}\n","import {effects, signal} from '@dnd-kit/state';\n\nimport type {Entity} from './entity.ts';\nimport type {UniqueIdentifier} from './types.ts';\n\n/**\n * Reactive class representing a registry for entities.\n * @template T - The type of entries that the registry manages,\n * for example, `Draggable` or `Droppable` entities.\n */\nexport class EntityRegistry<T extends Entity> {\n private map = signal<Map<UniqueIdentifier, T>>(new Map());\n private cleanupFunctions = new WeakMap<T, () => void>();\n\n /**\n * Iterator for the EntityRegistry class.\n * @returns An iterator for the values in the map.\n */\n public [Symbol.iterator]() {\n return this.map.peek().values();\n }\n\n public get value() {\n return this.map.value.values();\n }\n\n /**\n * Checks if a entity with the given identifier exists in the registry.\n * @param identifier - The unique identifier of the entity.\n * @returns True if the entity exists, false otherwise.\n */\n public has(identifier: UniqueIdentifier): boolean {\n return this.map.value.has(identifier);\n }\n\n /**\n * Retrieves a entity from the registry using its identifier.\n * @param identifier - The unique identifier of the entity.\n * @returns The entity if it exists, undefined otherwise.\n */\n public get(identifier: UniqueIdentifier): T | undefined {\n return this.map.value.get(identifier);\n }\n\n /**\n * Registers a entity in the registry.\n * @param key - The unique identifier of the entity.\n * @param value - The entity to register.\n * @returns A function that unregisters the entity.\n */\n public register = (key: UniqueIdentifier, value: T) => {\n const current = this.map.peek();\n\n if (current.get(key) === value) {\n return;\n }\n\n const updatedMap = new Map(current);\n updatedMap.set(key, value);\n\n this.map.value = updatedMap;\n\n const cleanup = effects(...value.effects());\n this.cleanupFunctions.set(value, cleanup);\n\n return () => this.unregister(key, value);\n };\n\n /**\n * Unregisters an entity from the registry.\n * @param key - The unique identifier of the entity.\n * @param value - The entity instance to unregister.\n */\n public unregister = (key: UniqueIdentifier, value: T) => {\n const current = this.map.peek();\n\n if (current.get(key) !== value) {\n return;\n }\n\n const cleanup = this.cleanupFunctions.get(value);\n cleanup?.();\n this.cleanupFunctions.delete(value);\n\n const updatedMap = new Map(current);\n updatedMap.delete(key);\n\n this.map.value = updatedMap;\n };\n\n /**\n * Destroys all entries in the registry and clears the registry.\n */\n public destroy() {\n for (const entry of this) {\n const cleanup = this.cleanupFunctions.get(entry);\n cleanup?.();\n entry.destroy();\n }\n\n this.map.value = new Map();\n }\n}\n","import {derived, reactive} from '@dnd-kit/state';\n\nimport {Entity} from '../entity/index.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport type {Modifiers} from '../../modifiers/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport type {Sensors} from '../../sensors/sensor.ts';\n\nexport interface Input<T extends Data = Data> extends EntityInput<T> {\n type?: Type;\n modifiers?: Modifiers;\n sensors?: Sensors;\n}\n\nexport type DraggableStatus = 'idle' | 'dragging' | 'dropping';\n\nexport class Draggable<\n T extends Data = Data,\n U extends DragDropManager<any, any> = DragDropManager<any, any>,\n> extends Entity<T> {\n constructor(\n {modifiers, type, sensors, ...input}: Input<T>,\n manager: U | undefined\n ) {\n super(input, manager);\n\n this.type = type;\n this.sensors = sensors;\n this.modifiers = modifiers;\n }\n\n public sensors: Sensors | undefined;\n\n @reactive\n public accessor modifiers: Modifiers | undefined;\n\n @reactive\n public accessor type: Type | undefined;\n\n @reactive\n public accessor status: DraggableStatus = 'idle';\n\n /**\n * A boolean indicating whether the draggable item is the source of a drag operation.\n */\n @derived\n public get isDragSource() {\n return this.manager?.dragOperation.source?.id === this.id;\n }\n}\n","import {derived, effects, reactive, type Effect} from '@dnd-kit/state';\nimport type {Shape} from '@dnd-kit/geometry';\n\nimport {Entity} from '../entity/index.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport {\n CollisionPriority,\n type CollisionDetector,\n} from '../../collision/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport {Draggable} from '../draggable/draggable.ts';\n\nexport interface Input<T extends Data = Data> extends EntityInput<T> {\n accept?: Type | Type[] | ((source: Draggable) => boolean);\n collisionPriority?: CollisionPriority | number;\n collisionDetector: CollisionDetector;\n type?: Type;\n}\n\nexport class Droppable<\n T extends Data = Data,\n U extends DragDropManager<any, any> = DragDropManager<any, any>,\n> extends Entity<T> {\n constructor(\n {\n accept,\n collisionDetector,\n collisionPriority = CollisionPriority.Normal,\n type,\n ...input\n }: Input<T>,\n manager: U | undefined\n ) {\n super(input, manager);\n\n this.accept = accept;\n this.collisionDetector = collisionDetector;\n this.collisionPriority = collisionPriority;\n this.type = type;\n }\n\n /**\n * An array of types that are compatible with the droppable.\n */\n @reactive\n public accessor accept:\n | Type\n | Type[]\n | ((draggable: Draggable) => boolean)\n | undefined;\n\n /**\n * The type of the droppable.\n */\n @reactive\n public accessor type: Type | undefined;\n\n /**\n * Checks whether or not the droppable accepts a given draggable.\n *\n * @param {Draggable} draggable\n * @returns {boolean}\n */\n public accepts(draggable: Draggable): boolean {\n const {accept} = this;\n\n if (!accept) {\n return true;\n }\n\n if (!draggable.type) {\n return false;\n }\n\n if (Array.isArray(accept)) {\n return accept.includes(draggable.type);\n }\n\n if (typeof accept === 'function') {\n return accept(draggable);\n }\n\n return draggable.type === accept;\n }\n\n @reactive\n public accessor collisionDetector: CollisionDetector;\n\n @reactive\n public accessor collisionPriority: number;\n\n @reactive\n public accessor shape: Shape | undefined;\n\n @derived\n public get isDropTarget() {\n return this.manager?.dragOperation.target?.id === this.id;\n }\n\n public refreshShape() {\n // To be implemented by subclasses\n }\n}\n","import {CleanupFunction} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport {\n Plugin,\n type PluginConstructor,\n type PluginDescriptor,\n type PluginOptions,\n} from '../plugins/index.ts';\n\nexport type SensorOptions = PluginOptions;\n\nexport abstract class Sensor<\n T extends DragDropManager<any, any> = DragDropManager<Draggable, Droppable>,\n U extends SensorOptions = SensorOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n /**\n * Bind the sensor to a draggable source, and optionally pass\n * in sensor options to override the default sensor options\n * for this draggable source only.\n */\n public abstract bind(source: Draggable, options?: U): CleanupFunction;\n}\n\nexport type SensorConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Sensor<T>>;\n\nexport type SensorDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Sensor<T>, SensorConstructor<T>>;\n\nexport type Sensors<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (SensorConstructor<T> | SensorDescriptor<T>)[];\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport {\n Plugin,\n type PluginOptions,\n type PluginConstructor,\n type PluginDescriptor,\n} from '../plugins/index.ts';\nimport type {DragDropManager} from '../manager/index.ts';\n\nexport type ModifierOptions = PluginOptions;\n\nexport class Modifier<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends ModifierOptions = ModifierOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n public apply(operation: T['dragOperation']): Coordinates {\n return operation.transform;\n }\n}\n\nexport type ModifierConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Modifier<T, any>>;\n\nexport type ModifierDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Modifier<T, any>, ModifierConstructor<T>>;\n\nexport type Modifiers<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (ModifierConstructor<T> | ModifierDescriptor<T>)[];\n","import type {CleanupFunction} from '@dnd-kit/state';\n\nimport {\n Draggable,\n Droppable,\n Entity,\n EntityRegistry,\n} from '../entities/index.ts';\nimport {\n PluginRegistry,\n Plugin,\n type PluginConstructor,\n PluginOptions,\n} from '../plugins/index.ts';\nimport {\n Sensor,\n SensorOptions,\n type SensorConstructor,\n} from '../sensors/index.ts';\nimport {Modifier, type ModifierConstructor} from '../modifiers/index.ts';\nimport type {DragDropManager} from './manager.ts';\n\nexport class DragDropRegistry<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> {\n constructor(manager: V) {\n this.plugins = new PluginRegistry<V, PluginConstructor<V>>(manager);\n this.sensors = new PluginRegistry<V, SensorConstructor<V>>(manager);\n this.modifiers = new PluginRegistry<V, ModifierConstructor<V>>(manager);\n }\n\n public draggables = new EntityRegistry<T>();\n public droppables = new EntityRegistry<U>();\n public plugins: PluginRegistry<V, PluginConstructor<V>>;\n public sensors: PluginRegistry<V, SensorConstructor<V>>;\n public modifiers: PluginRegistry<V, ModifierConstructor<V>>;\n\n public register(input: Entity): () => void;\n public register(input: Draggable): () => void;\n public register(input: Droppable): () => void;\n public register(input: SensorConstructor, options?: SensorOptions): Sensor;\n public register(input: ModifierConstructor): Modifier;\n public register(input: PluginConstructor, options?: PluginOptions): Plugin;\n public register(input: any, options?: Record<string, any>) {\n if (input instanceof Draggable) {\n return this.draggables.register(input.id, input as T);\n }\n\n if (input instanceof Droppable) {\n return this.droppables.register(input.id, input as U);\n }\n\n if (input.prototype instanceof Modifier) {\n return this.modifiers.register(input, options);\n }\n\n if (input.prototype instanceof Sensor) {\n return this.sensors.register(input, options);\n }\n\n if (input.prototype instanceof Plugin) {\n return this.plugins.register(input, options);\n }\n\n throw new Error('Invalid instance type');\n }\n\n public unregister(input: Entity): CleanupFunction;\n public unregister(input: Draggable): CleanupFunction;\n public unregister(input: Droppable): CleanupFunction;\n public unregister(input: SensorConstructor): CleanupFunction;\n public unregister(input: ModifierConstructor): CleanupFunction;\n public unregister(input: PluginConstructor): CleanupFunction;\n public unregister(input: any) {\n if (input instanceof Entity) {\n if (input instanceof Draggable) {\n return this.draggables.unregister(input.id, input as T);\n }\n\n if (input instanceof Droppable) {\n return this.droppables.unregister(input.id, input as U);\n }\n\n // no-op\n return () => {};\n }\n\n if (input.prototype instanceof Modifier) {\n return this.modifiers.unregister(input);\n }\n\n if (input.prototype instanceof Sensor) {\n return this.sensors.unregister(input);\n }\n\n if (input.prototype instanceof Plugin) {\n return this.plugins.unregister(input);\n }\n\n throw new Error('Invalid instance type');\n }\n\n destroy() {\n this.draggables.destroy();\n this.droppables.destroy();\n this.plugins.destroy();\n this.sensors.destroy();\n this.modifiers.destroy();\n }\n}\n","import {Position, type Shape} from '@dnd-kit/geometry';\nimport type {Coordinates} from '@dnd-kit/geometry';\nimport {batch, computed, effect, signal} from '@dnd-kit/state';\n\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.ts';\nimport type {Modifier} from '../modifiers/index.ts';\nimport {descriptor} from '../plugins/index.ts';\n\nimport type {DragDropManager} from './manager.ts';\nimport {defaultPreventable} from './events.ts';\n\nexport enum Status {\n Idle = 'idle',\n Initializing = 'initializing',\n Dragging = 'dragging',\n Dropped = 'dropped',\n}\n\nexport type Serializable = {\n [key: string]: string | number | null | Serializable | Serializable[];\n};\n\nexport interface DragOperation<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n activatorEvent: Event | null;\n canceled: boolean;\n position: Position;\n transform: Coordinates;\n status: {\n current: Status;\n initialized: boolean;\n initializing: boolean;\n dragging: boolean;\n dragended: boolean;\n dropped: boolean;\n idle: boolean;\n };\n get shape(): {\n initial: Shape;\n current: Shape;\n } | null;\n set shape(value: Shape | null);\n source: T | null;\n target: U | null;\n data?: Serializable;\n}\n\nexport type DragActions<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = ReturnType<typeof DragOperationManager<T, U, V>>['actions'];\n\nexport function DragOperationManager<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n>(manager: V) {\n const {\n registry: {draggables, droppables},\n monitor,\n } = manager;\n const status = signal<Status>(Status.Idle);\n const shape = {\n initial: signal<Shape | null>(null),\n current: signal<Shape | null>(null),\n };\n const canceled = signal<boolean>(false);\n const position = new Position({x: 0, y: 0});\n const activatorEvent = signal<Event | null>(null);\n const sourceIdentifier = signal<UniqueIdentifier | null>(null);\n const targetIdentifier = signal<UniqueIdentifier | null>(null);\n const dragging = computed(() => status.value === Status.Dragging);\n const initialized = computed(() => status.value !== Status.Idle);\n const initializing = computed(() => status.value === Status.Initializing);\n const idle = computed(() => status.value === Status.Idle);\n const dropped = computed(() => status.value === Status.Dropped);\n const dragended = signal<boolean>(true);\n let previousSource: T | undefined;\n const source = computed<T | null>(() => {\n const identifier = sourceIdentifier.value;\n\n if (identifier == null) return null;\n\n const value = draggables.get(identifier);\n\n if (value) {\n // It's possible for the source to unmount during the drag operation\n previousSource = value;\n }\n\n return value ?? previousSource ?? null;\n });\n const target = computed<U | null>(() => {\n const identifier = targetIdentifier.value;\n return identifier != null ? droppables.get(identifier) ?? null : null;\n });\n\n const modifiers = signal<Modifier[]>([]);\n\n effect(() => {\n const currentModifiers = modifiers.peek();\n\n if (currentModifiers !== manager.modifiers) {\n currentModifiers.forEach((modifier) => modifier.destroy());\n }\n\n modifiers.value =\n source.value?.modifiers?.map((modifier) => {\n const {plugin, options} = descriptor(modifier);\n return new plugin(manager, options);\n }) ?? manager.modifiers;\n });\n\n const transform = computed(() => {\n const {x, y} = position.delta;\n\n let transform = {x, y};\n const initialShape = shape.initial.peek();\n const currentShape = shape.current.peek();\n const operation: Omit<DragOperation<T, U>, 'transform'> = {\n activatorEvent: activatorEvent.peek(),\n canceled: canceled.peek(),\n source: source.peek(),\n target: target.peek(),\n status: {\n current: status.peek(),\n idle: idle.peek(),\n initializing: initializing.peek(),\n initialized: initialized.peek(),\n dragging: dragging.peek(),\n dragended: dragended.peek(),\n dropped: dropped.peek(),\n },\n shape:\n initialShape && currentShape\n ? {initial: initialShape, current: currentShape}\n : null,\n position,\n };\n\n for (const modifier of modifiers.value) {\n transform = modifier.apply({...operation, transform});\n }\n\n return transform;\n });\n\n const operation: DragOperation<T, U> = {\n get activatorEvent() {\n return activatorEvent.value;\n },\n get canceled() {\n return canceled.value;\n },\n get source() {\n return source.value;\n },\n get target() {\n return target.value;\n },\n status: {\n get current() {\n return status.value;\n },\n get idle() {\n return idle.value;\n },\n get initializing() {\n return initializing.value;\n },\n get initialized() {\n return initialized.value;\n },\n get dragging() {\n return dragging.value;\n },\n get dragended() {\n return dragended.value;\n },\n get dropped() {\n return dropped.value;\n },\n },\n get shape(): DragOperation['shape'] {\n const initial = shape.initial.value;\n const current = shape.current.value;\n\n return initial && current ? {initial, current} : null;\n },\n set shape(value: Shape | null) {\n if (value && shape.current.peek()?.equals(value)) {\n return;\n }\n\n const initial = shape.initial.peek();\n\n if (!initial) {\n shape.initial.value = value;\n }\n\n shape.current.value = value;\n },\n get transform() {\n return transform.value;\n },\n position,\n };\n\n const reset = () => {\n batch(() => {\n status.value = Status.Idle;\n sourceIdentifier.value = null;\n targetIdentifier.value = null;\n shape.current.value = null;\n shape.initial.value = null;\n position.reset({x: 0, y: 0});\n modifiers.value = [];\n });\n };\n\n return {\n operation,\n actions: {\n setDragSource(identifier: UniqueIdentifier) {\n sourceIdentifier.value = identifier;\n },\n setDropTarget(\n identifier: UniqueIdentifier | null | undefined\n ): Promise<void> {\n const id = identifier ?? null;\n\n if (targetIdentifier.peek() === id) {\n return Promise.resolve();\n }\n\n targetIdentifier.value = id;\n\n if (status.peek() === Status.Dragging) {\n monitor.dispatch(\n 'dragover',\n defaultPreventable({\n operation: snapshot(operation),\n })\n );\n }\n\n return manager.renderer.rendering;\n },\n start({event, coordinates}: {event: Event; coordinates: Coordinates}) {\n const sourceInstance = source.peek();\n\n if (!sourceInstance) {\n throw new Error(\n 'Cannot start a drag operation without a drag source'\n );\n }\n\n batch(() => {\n dragended.value = false;\n canceled.value = false;\n activatorEvent.value = event;\n position.reset(coordinates);\n });\n\n const beforeStartEvent = defaultPreventable({\n operation: snapshot(operation),\n });\n\n monitor.dispatch('beforedragstart', beforeStartEvent);\n\n manager.renderer.rendering.then(() => {\n if (beforeStartEvent.defaultPrevented) {\n reset();\n return;\n }\n\n status.value = Status.Initializing;\n\n requestAnimationFrame(() => {\n status.value = Status.Dragging;\n\n monitor.dispatch('dragstart', {\n operation: snapshot(operation),\n cancelable: false,\n });\n });\n });\n },\n move({\n by,\n to,\n cancelable = true,\n }:\n | {by: Coordinates; to?: undefined; cancelable?: boolean}\n | {by?: undefined; to: Coordinates; cancelable?: boolean}) {\n if (!dragging.peek()) {\n return;\n }\n\n const event = defaultPreventable(\n {\n operation: snapshot(operation),\n by,\n to,\n },\n cancelable\n );\n\n monitor.dispatch('dragmove', event);\n\n queueMicrotask(() => {\n if (event.defaultPrevented) {\n return;\n }\n\n const coordinates = to ?? {\n x: position.current.x + by.x,\n y: position.current.y + by.y,\n };\n\n position.update(coordinates);\n });\n },\n stop({canceled: eventCanceled = false}: {canceled?: boolean} = {}) {\n let promise: Promise<void> | undefined;\n const suspend = () => {\n const output = {\n resume: () => {},\n abort: () => {},\n };\n\n promise = new Promise<void>((resolve, reject) => {\n output.resume = resolve;\n output.abort = reject;\n });\n\n return output;\n };\n const end = () => {\n /* Wait for the renderer to finish rendering before finalizing the drag operation */\n manager.renderer.rendering.then(() => {\n status.value = Status.Dropped;\n manager.renderer.rendering.then(reset);\n });\n };\n\n batch(() => {\n dragended.value = true;\n canceled.value = eventCanceled;\n });\n\n monitor.dispatch('dragend', {\n operation: snapshot(operation),\n canceled: eventCanceled,\n suspend,\n });\n\n if (promise) {\n promise.then(end).catch(reset);\n } else {\n end();\n }\n },\n },\n };\n}\n\nfunction snapshot<T extends Record<string, any>>(obj: T): T {\n return {\n ...obj,\n };\n}\n","export interface Renderer {\n get rendering(): Promise<void>;\n}\n\nexport const defaultRenderer: Renderer = {\n get rendering() {\n return Promise.resolve();\n },\n};\n","import type {Draggable, Droppable} from '../entities/index.ts';\nimport {CollisionObserver, CollisionNotifier} from '../collision/index.ts';\nimport type {Plugins, Plugin} from '../plugins/index.ts';\nimport type {Sensor, Sensors} from '../sensors/index.ts';\nimport type {Modifier, Modifiers} from '../modifiers/index.ts';\n\nimport {DragDropRegistry} from './registry.ts';\nimport {\n DragOperationManager,\n type DragOperation,\n type DragActions,\n} from './dragOperation.ts';\nimport {DragDropMonitor} from './events.ts';\nimport {defaultRenderer, type Renderer} from './renderer.ts';\n\nexport type DragDropManagerInput<T extends DragDropManager<any, any>> = {\n plugins?: Plugins<T>;\n sensors?: Sensors<T>;\n modifiers?: Modifiers<T>;\n renderer?: Renderer;\n};\n\nexport class DragDropManager<T extends Draggable, U extends Droppable> {\n public actions: DragActions<T, U, DragDropManager<T, U>>;\n public collisionObserver: CollisionObserver<T, U>;\n public dragOperation: DragOperation<T, U>;\n public monitor: DragDropMonitor<T, U, DragDropManager<T, U>>;\n public registry: DragDropRegistry<T, U, DragDropManager<T, U>>;\n public renderer: Renderer;\n\n constructor(config?: DragDropManagerInput<any>) {\n type V = DragDropManager<T, U>;\n\n const {\n plugins = [],\n sensors = [],\n modifiers = [],\n renderer = defaultRenderer,\n } = config ?? {};\n const monitor = new DragDropMonitor<T, U, V>(this);\n const registry = new DragDropRegistry<T, U, V>(this);\n\n this.registry = registry;\n this.monitor = monitor;\n this.renderer = renderer;\n\n const {actions, operation} = DragOperationManager<T, U, V>(this);\n\n this.actions = actions;\n this.dragOperation = operation;\n this.collisionObserver = new CollisionObserver<T, U, V>(this);\n this.plugins = [CollisionNotifier, ...plugins];\n this.modifiers = modifiers;\n this.sensors = sensors;\n this.destroy = this.destroy.bind(this);\n }\n\n get plugins(): Plugin<any>[] {\n return this.registry.plugins.values;\n }\n\n set plugins(plugins: Plugins<any>) {\n this.registry.plugins.values = plugins;\n }\n\n get modifiers(): Modifier<any>[] {\n return this.registry.modifiers.values;\n }\n\n set modifiers(modifiers: Modifiers<any>) {\n this.registry.modifiers.values = modifiers;\n }\n\n get sensors(): Sensor<any>[] {\n return this.registry.sensors.values;\n }\n\n set sensors(sensors: Sensors<any>) {\n this.registry.sensors.values = sensors;\n }\n\n public destroy() {\n this.registry.destroy();\n this.collisionObserver.destroy();\n }\n}\n"]}
|
package/index.d.cts
CHANGED
|
@@ -216,18 +216,15 @@ interface Input$1<T extends Data = Data> extends Input$2<T> {
|
|
|
216
216
|
}
|
|
217
217
|
type DraggableStatus = 'idle' | 'dragging' | 'dropping';
|
|
218
218
|
declare class Draggable<T extends Data = Data, U extends DragDropManager<any, any> = DragDropManager<any, any>> extends Entity<T> {
|
|
219
|
-
#private;
|
|
220
219
|
constructor({ modifiers, type, sensors, ...input }: Input$1<T>, manager: U | undefined);
|
|
221
220
|
sensors: Sensors | undefined;
|
|
222
|
-
|
|
223
|
-
get modifiers(): Modifier[] | undefined;
|
|
221
|
+
accessor modifiers: Modifiers | undefined;
|
|
224
222
|
accessor type: Type | undefined;
|
|
225
223
|
accessor status: DraggableStatus;
|
|
226
224
|
/**
|
|
227
225
|
* A boolean indicating whether the draggable item is the source of a drag operation.
|
|
228
226
|
*/
|
|
229
227
|
get isDragSource(): boolean;
|
|
230
|
-
destroy(): void;
|
|
231
228
|
}
|
|
232
229
|
|
|
233
230
|
declare enum CollisionPriority {
|
package/index.d.ts
CHANGED
|
@@ -216,18 +216,15 @@ interface Input$1<T extends Data = Data> extends Input$2<T> {
|
|
|
216
216
|
}
|
|
217
217
|
type DraggableStatus = 'idle' | 'dragging' | 'dropping';
|
|
218
218
|
declare class Draggable<T extends Data = Data, U extends DragDropManager<any, any> = DragDropManager<any, any>> extends Entity<T> {
|
|
219
|
-
#private;
|
|
220
219
|
constructor({ modifiers, type, sensors, ...input }: Input$1<T>, manager: U | undefined);
|
|
221
220
|
sensors: Sensors | undefined;
|
|
222
|
-
|
|
223
|
-
get modifiers(): Modifier[] | undefined;
|
|
221
|
+
accessor modifiers: Modifiers | undefined;
|
|
224
222
|
accessor type: Type | undefined;
|
|
225
223
|
accessor status: DraggableStatus;
|
|
226
224
|
/**
|
|
227
225
|
* A boolean indicating whether the draggable item is the source of a drag operation.
|
|
228
226
|
*/
|
|
229
227
|
get isDragSource(): boolean;
|
|
230
|
-
destroy(): void;
|
|
231
228
|
}
|
|
232
229
|
|
|
233
230
|
declare enum CollisionPriority {
|
package/index.js
CHANGED
|
@@ -551,46 +551,29 @@ var EntityRegistry = class {
|
|
|
551
551
|
this.map.value = /* @__PURE__ */ new Map();
|
|
552
552
|
}
|
|
553
553
|
};
|
|
554
|
-
var _isDragSource_dec, _status_dec, _type_dec,
|
|
555
|
-
var Draggable = class extends (_c = Entity, _type_dec = [reactive], _status_dec = [reactive], _isDragSource_dec = [derived], _c) {
|
|
554
|
+
var _isDragSource_dec, _status_dec, _type_dec, _modifiers_dec, _c, _init3, _modifiers, _type, _status;
|
|
555
|
+
var Draggable = class extends (_c = Entity, _modifiers_dec = [reactive], _type_dec = [reactive], _status_dec = [reactive], _isDragSource_dec = [derived], _c) {
|
|
556
556
|
constructor(_a, manager) {
|
|
557
557
|
var _b = _a, { modifiers, type, sensors } = _b, input = __objRest(_b, ["modifiers", "type", "sensors"]);
|
|
558
558
|
super(input, manager);
|
|
559
559
|
__runInitializers(_init3, 5, this);
|
|
560
|
-
__privateAdd(this, _modifiers);
|
|
561
|
-
__privateAdd(this, _type, __runInitializers(_init3,
|
|
562
|
-
__privateAdd(this, _status, __runInitializers(_init3,
|
|
560
|
+
__privateAdd(this, _modifiers, __runInitializers(_init3, 8, this)), __runInitializers(_init3, 11, this);
|
|
561
|
+
__privateAdd(this, _type, __runInitializers(_init3, 12, this)), __runInitializers(_init3, 15, this);
|
|
562
|
+
__privateAdd(this, _status, __runInitializers(_init3, 16, this, "idle")), __runInitializers(_init3, 19, this);
|
|
563
563
|
this.type = type;
|
|
564
564
|
this.sensors = sensors;
|
|
565
565
|
this.modifiers = modifiers;
|
|
566
566
|
}
|
|
567
|
-
set modifiers(modifiers) {
|
|
568
|
-
var _a;
|
|
569
|
-
const { manager } = this;
|
|
570
|
-
(_a = __privateGet(this, _modifiers)) == null ? void 0 : _a.forEach((modifier) => modifier.destroy());
|
|
571
|
-
if (!manager) return;
|
|
572
|
-
__privateSet(this, _modifiers, modifiers == null ? void 0 : modifiers.map((modifier) => {
|
|
573
|
-
const { plugin, options } = descriptor(modifier);
|
|
574
|
-
return new plugin(manager, options);
|
|
575
|
-
}));
|
|
576
|
-
}
|
|
577
|
-
get modifiers() {
|
|
578
|
-
return __privateGet(this, _modifiers);
|
|
579
|
-
}
|
|
580
567
|
get isDragSource() {
|
|
581
568
|
var _a, _b;
|
|
582
569
|
return ((_b = (_a = this.manager) == null ? void 0 : _a.dragOperation.source) == null ? void 0 : _b.id) === this.id;
|
|
583
570
|
}
|
|
584
|
-
destroy() {
|
|
585
|
-
var _a;
|
|
586
|
-
super.destroy();
|
|
587
|
-
(_a = this.modifiers) == null ? void 0 : _a.forEach((modifier) => modifier.destroy());
|
|
588
|
-
}
|
|
589
571
|
};
|
|
590
572
|
_init3 = __decoratorStart(_c);
|
|
591
573
|
_modifiers = new WeakMap();
|
|
592
574
|
_type = new WeakMap();
|
|
593
575
|
_status = new WeakMap();
|
|
576
|
+
__decorateElement(_init3, 4, "modifiers", _modifiers_dec, Draggable, _modifiers);
|
|
594
577
|
__decorateElement(_init3, 4, "type", _type_dec, Draggable, _type);
|
|
595
578
|
__decorateElement(_init3, 4, "status", _status_dec, Draggable, _status);
|
|
596
579
|
__decorateElement(_init3, 2, "isDragSource", _isDragSource_dec, Draggable);
|
|
@@ -786,10 +769,20 @@ function DragOperationManager(manager) {
|
|
|
786
769
|
const identifier = targetIdentifier.value;
|
|
787
770
|
return identifier != null ? (_a = droppables.get(identifier)) != null ? _a : null : null;
|
|
788
771
|
});
|
|
772
|
+
const modifiers = signal([]);
|
|
773
|
+
effect(() => {
|
|
774
|
+
var _a, _b, _c3;
|
|
775
|
+
const currentModifiers = modifiers.peek();
|
|
776
|
+
if (currentModifiers !== manager.modifiers) {
|
|
777
|
+
currentModifiers.forEach((modifier) => modifier.destroy());
|
|
778
|
+
}
|
|
779
|
+
modifiers.value = (_c3 = (_b = (_a = source.value) == null ? void 0 : _a.modifiers) == null ? void 0 : _b.map((modifier) => {
|
|
780
|
+
const { plugin, options } = descriptor(modifier);
|
|
781
|
+
return new plugin(manager, options);
|
|
782
|
+
})) != null ? _c3 : manager.modifiers;
|
|
783
|
+
});
|
|
789
784
|
const transform = computed(() => {
|
|
790
|
-
var _a, _b;
|
|
791
785
|
const { x, y } = position.delta;
|
|
792
|
-
const modifiers = (_b = (_a = source == null ? void 0 : source.value) == null ? void 0 : _a.modifiers) != null ? _b : manager.modifiers;
|
|
793
786
|
let transform2 = { x, y };
|
|
794
787
|
const initialShape = shape.initial.peek();
|
|
795
788
|
const currentShape = shape.current.peek();
|
|
@@ -810,7 +803,7 @@ function DragOperationManager(manager) {
|
|
|
810
803
|
shape: initialShape && currentShape ? { initial: initialShape, current: currentShape } : null,
|
|
811
804
|
position
|
|
812
805
|
};
|
|
813
|
-
for (const modifier of modifiers) {
|
|
806
|
+
for (const modifier of modifiers.value) {
|
|
814
807
|
transform2 = modifier.apply(__spreadProps(__spreadValues({}, operation2), { transform: transform2 }));
|
|
815
808
|
}
|
|
816
809
|
return transform2;
|
|
@@ -880,6 +873,7 @@ function DragOperationManager(manager) {
|
|
|
880
873
|
shape.current.value = null;
|
|
881
874
|
shape.initial.value = null;
|
|
882
875
|
position.reset({ x: 0, y: 0 });
|
|
876
|
+
modifiers.value = [];
|
|
883
877
|
});
|
|
884
878
|
};
|
|
885
879
|
return {
|
|
@@ -905,6 +899,12 @@ function DragOperationManager(manager) {
|
|
|
905
899
|
return manager.renderer.rendering;
|
|
906
900
|
},
|
|
907
901
|
start({ event, coordinates }) {
|
|
902
|
+
const sourceInstance = source.peek();
|
|
903
|
+
if (!sourceInstance) {
|
|
904
|
+
throw new Error(
|
|
905
|
+
"Cannot start a drag operation without a drag source"
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
908
|
batch(() => {
|
|
909
909
|
dragended.value = false;
|
|
910
910
|
canceled.value = false;
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["src/core/collision/observer.ts","src/core/plugins/plugin.ts","src/core/plugins/utilities.ts","src/core/plugins/registry.ts","src/core/collision/utilities.ts","src/core/collision/notifier.ts","src/core/manager/events.ts","src/core/collision/types.ts","src/core/entities/entity/entity.ts","src/core/entities/entity/registry.ts","src/core/entities/draggable/draggable.ts","src/core/entities/droppable/droppable.ts","src/core/sensors/sensor.ts","src/core/modifiers/modifier.ts","src/core/manager/registry.ts","src/core/manager/dragOperation.ts","src/core/manager/renderer.ts","src/core/manager/manager.ts"],"names":["untracked","effect","CollisionPriority","reactive","_disabled_dec","_init","_disabled","effects","manager","signal","derived","_type_dec","_c","_type","batch","computed","Status","transform","operation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAAA;AAAA,EAEA;AAAA,OACK;;;ACRP,SAAQ,UAAU,iBAAgB;;;ACO3B,SAAS,UAGd,QAAW,SAA2C;AACtD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,aACd,QACA;AACA,SAAO,CAAC,YAAkE;AACxE,WAAO,UAAU,QAAQ,OAAO;AAAA,EAClC;AACF;AAEO,SAAS,WACd,QAC+B;AAC/B,MAAI,OAAO,WAAW,YAAY;AAChC,WAAO;AAAA,MACL;AAAA,MACA,SAAS;AAAA,IACX;AAAA,EACF;AAEA,SAAO;AACT;;;ADpCA;AAuBE,iBAAC;AAbI,IAAe,SAAf,MAGL;AAAA,EACA,YACS,SACA,SACP;AAFO;AACA;AAQT,uBA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;ACcO,IAAM,kBAAN,MAAgE;AAAA,EAQrE,YAAY,QAAoC;AAG9C,UAAM;AAAA,MACJ,UAAU,CAAC;AAAA,MACX,UAAU,CAAC;AAAA,MACX,YAAY,CAAC;AAAA,MACb,WAAW;AAAA,IACb,IAAI,0BAAU,CAAC;AACf,UAAM,UAAU,IAAI,gBAAyB,IAAI;AACjD,UAAM,WAAW,IAAI,iBAA0B,IAAI;AAEnD,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,WAAW;AAEhB,UAAM,EAAC,SAAS,UAAS,IAAI,qBAA8B,IAAI;AAE/D,SAAK,UAAU;AACf,SAAK,gBAAgB;AACrB,SAAK,oBAAoB,IAAI,kBAA2B,IAAI;AAC5D,SAAK,UAAU,CAAC,mBAAmB,GAAG,OAAO;AAC7C,SAAK,YAAY;AACjB,SAAK,UAAU;AACf,SAAK,UAAU,KAAK,QAAQ,KAAK,IAAI;AAAA,EACvC;AAAA,EAEA,IAAI,UAAyB;AAC3B,WAAO,KAAK,SAAS,QAAQ;AAAA,EAC/B;AAAA,EAEA,IAAI,QAAQ,SAAuB;AACjC,SAAK,SAAS,QAAQ,SAAS;AAAA,EACjC;AAAA,EAEA,IAAI,YAA6B;AAC/B,WAAO,KAAK,SAAS,UAAU;AAAA,EACjC;AAAA,EAEA,IAAI,UAAU,WAA2B;AACvC,SAAK,SAAS,UAAU,SAAS;AAAA,EACnC;AAAA,EAEA,IAAI,UAAyB;AAC3B,WAAO,KAAK,SAAS,QAAQ;AAAA,EAC/B;AAAA,EAEA,IAAI,QAAQ,SAAuB;AACjC,SAAK,SAAS,QAAQ,SAAS;AAAA,EACjC;AAAA,EAEO,UAAU;AACf,SAAK,SAAS,QAAQ;AACtB,SAAK,kBAAkB,QAAQ;AAAA,EACjC;AACF","sourcesContent":["import {\n batch,\n computed,\n deepEqual,\n signal,\n untracked,\n type ReadonlySignal,\n effect,\n} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport {Plugin} from '../plugins/index.ts';\nimport type {Collision, CollisionDetector, Collisions} from './types.ts';\nimport {sortCollisions} from './utilities.ts';\n\nconst DEFAULT_VALUE: Collisions = [];\n\nexport class CollisionObserver<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n V extends DragDropManager<T, U> = DragDropManager<T, U>,\n> extends Plugin<V> {\n constructor(manager: V) {\n super(manager);\n\n this.computeCollisions = this.computeCollisions.bind(this);\n this.#collisions = computed(this.computeCollisions, deepEqual);\n\n this.destroy = effect(() => {\n const {dragOperation} = this.manager;\n\n if (dragOperation.status.initialized) {\n this.forceUpdate();\n }\n });\n }\n\n forceUpdateCount = signal(0);\n\n public forceUpdate(refresh = true) {\n untracked(() => {\n const {source} = this.manager.dragOperation;\n\n batch(() => {\n if (refresh) {\n for (const droppable of this.manager.registry.droppables) {\n if (source && !droppable.accepts(source)) {\n continue;\n }\n\n droppable.refreshShape();\n }\n }\n\n this.forceUpdateCount.value++;\n });\n });\n }\n\n public computeCollisions(\n entries?: Droppable[],\n collisionDetector?: CollisionDetector\n ) {\n const {registry, dragOperation} = this.manager;\n const {source, shape, status} = dragOperation;\n\n if (!status.initialized || !shape) {\n return DEFAULT_VALUE;\n }\n\n const collisions: Collision[] = [];\n\n this.forceUpdateCount.value;\n\n for (const entry of entries ?? registry.droppables) {\n if (entry.disabled) {\n continue;\n }\n\n if (source && !entry.accepts(source)) {\n continue;\n }\n\n const detectCollision = collisionDetector ?? entry.collisionDetector;\n\n if (!detectCollision) {\n continue;\n }\n\n const collision = untracked(() =>\n detectCollision({\n droppable: entry,\n dragOperation,\n })\n );\n\n if (collision) {\n if (entry.collisionPriority != null) {\n collision.priority = entry.collisionPriority;\n }\n\n collisions.push(collision);\n }\n }\n\n collisions.sort(sortCollisions);\n\n return collisions;\n }\n\n public get collisions() {\n return this.#collisions.value;\n }\n\n #collisions: ReadonlySignal<Collisions>;\n}\n","import {reactive, untracked} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {PluginOptions} from './types.ts';\nimport {configure} from './utilities.ts';\n\n/**\n * An abstract plugin class that can be extended to implement custom\n * functionality that augments the `DragDropManager`'s core capabilities.\n */\nexport abstract class Plugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> {\n constructor(\n public manager: T,\n public options?: U\n ) {}\n\n /**\n * Whether the plugin instance is disabled.\n * Triggers effects when accessed.\n */\n @reactive\n public accessor disabled: boolean = false;\n\n /**\n * Enable a disabled plugin instance.\n * Triggers effects.\n */\n public enable() {\n this.disabled = false;\n }\n\n /**\n * Disable an enabled plugin instance.\n * Triggers effects.\n */\n public disable() {\n this.disabled = true;\n }\n\n /**\n * Whether the plugin instance is disabled.\n * Does not trigger effects when accessed.\n */\n public isDisabled() {\n return untracked(() => {\n return this.disabled;\n });\n }\n\n /**\n * Configure a plugin instance with new options.\n */\n public configure(options?: U) {\n this.options = options;\n }\n\n /**\n * Destroy a plugin instance.\n */\n public destroy() {\n /*\n * Each plugin is responsible for implementing its own\n * destroy method to clean up effects and listeners\n */\n }\n\n /**\n * Configure a plugin constructor with options.\n * This method is used to configure the options that the\n * plugin constructor will use to create plugin instances.\n */\n static configure(options: PluginOptions) {\n return configure(this as any, options);\n }\n}\n\nexport class CorePlugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> extends Plugin<T, U> {}\n","import type {\n PluginConstructor,\n PluginOptions,\n PluginDescriptor,\n InferPluginOptions,\n} from './types.ts';\n\nexport function configure<\n T extends PluginConstructor<any, any, any>,\n V extends PluginOptions = InferPluginOptions<T>,\n>(plugin: T, options: V): PluginDescriptor<any, any, T> {\n return {\n plugin,\n options,\n };\n}\n\nexport function configurator<T extends PluginConstructor<any, any, any>>(\n plugin: T\n) {\n return (options: InferPluginOptions<T>): PluginDescriptor<any, any, T> => {\n return configure(plugin, options);\n };\n}\n\nexport function descriptor<T extends PluginConstructor<any, any, any>>(\n plugin: T | PluginDescriptor<any, any, T>\n): PluginDescriptor<any, any, T> {\n if (typeof plugin === 'function') {\n return {\n plugin,\n options: undefined,\n };\n }\n\n return plugin;\n}\n","import {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin, type Plugin} from './plugin.ts';\nimport type {InferPluginOptions, PluginConstructor, Plugins} from './types.ts';\nimport {descriptor} from './utilities.ts';\n\nexport class PluginRegistry<\n T extends DragDropManager<any, any>,\n W extends PluginConstructor<T> = PluginConstructor<T>,\n U extends Plugin<T> = InstanceType<W>,\n> {\n private instances: Map<W, U> = new Map();\n\n constructor(private manager: T) {}\n\n public get values(): U[] {\n return Array.from(this.instances.values());\n }\n\n #previousValues: PluginConstructor<T>[] = [];\n\n public set values(entries: Plugins<T>) {\n const descriptors = entries.map(descriptor);\n const constructors = descriptors.map(({plugin}) => plugin);\n\n for (const plugin of this.#previousValues) {\n if (!constructors.includes(plugin)) {\n if (plugin.prototype instanceof CorePlugin) {\n continue;\n }\n\n this.unregister(plugin as W);\n }\n }\n\n for (const {plugin, options} of descriptors) {\n this.register(plugin as W, options as InferPluginOptions<W>);\n }\n\n this.#previousValues = constructors;\n }\n\n public get<X extends W>(plugin: X): InstanceType<X> | undefined {\n const instance = this.instances.get(plugin);\n\n return instance as any;\n }\n\n public register<X extends W>(\n plugin: X,\n options?: InferPluginOptions<X>\n ): InstanceType<X> {\n const existingInstance = this.instances.get(plugin);\n\n if (existingInstance) {\n return existingInstance as InstanceType<X>;\n }\n\n const instance = new plugin(this.manager, options) as U;\n\n this.instances.set(plugin, instance);\n\n return instance as InstanceType<X>;\n }\n\n public unregister<X extends W>(plugin: X) {\n const instance = this.instances.get(plugin);\n\n if (instance) {\n instance.destroy();\n this.instances.delete(plugin);\n }\n }\n\n public destroy() {\n for (const plugin of this.instances.values()) {\n plugin.destroy();\n }\n\n this.instances.clear();\n }\n}\n","import {Collision} from './types.ts';\n\n/**\n * Sort collisions from greatest to smallest priority\n * Collisions of equal priority are sorted from greatest to smallest value\n */\nexport function sortCollisions(a: Collision, b: Collision) {\n if (a.priority === b.priority) {\n return b.value - a.value;\n }\n\n return b.priority - a.priority;\n}\n","import {effect, untracked} from '@dnd-kit/state';\n\nimport {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin} from '../plugins/index.ts';\nimport {defaultPreventable} from '../manager/events.ts';\n\nexport class CollisionNotifier extends CorePlugin {\n constructor(manager: DragDropManager<any, any>) {\n super(manager);\n\n this.destroy = effect(() => {\n const {collisionObserver, monitor} = manager;\n const {collisions} = collisionObserver;\n\n if (collisionObserver.isDisabled()) {\n return;\n }\n\n const event = defaultPreventable({\n collisions,\n });\n\n monitor.dispatch('collision', event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n const [firstCollision] = collisions;\n\n untracked(() => {\n if (firstCollision?.id !== manager.dragOperation.target?.id) {\n collisionObserver.disable();\n\n manager.actions.setDropTarget(firstCollision?.id).then(() => {\n collisionObserver.enable();\n });\n }\n });\n });\n }\n}\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport type {Collisions} from '../collision/index.ts';\nimport type {DragDropManager} from './manager.ts';\nimport type {DragOperation} from './dragOperation.ts';\n\nexport type Events = Record<string, (...args: any[]) => void>;\n\nexport type Preventable<T> = T & {\n cancelable: boolean;\n defaultPrevented: boolean;\n preventDefault(): void;\n};\n\nclass Monitor<T extends Events> {\n private registry = new Map<keyof T, Set<T[keyof T]>>();\n\n public addEventListener<U extends keyof T>(name: U, handler: T[U]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.add(handler);\n registry.set(name, listeners);\n\n return () => this.removeEventListener(name, handler);\n }\n\n public removeEventListener(name: keyof T, handler: T[keyof T]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.delete(handler);\n registry.set(name, listeners);\n }\n\n protected dispatch<U extends keyof T>(name: U, ...args: any[]) {\n const {registry} = this;\n const listeners = registry.get(name);\n\n if (!listeners) {\n return;\n }\n\n for (const listener of listeners) {\n listener(...args);\n }\n }\n}\n\nexport type DragDropEvents<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = {\n collision(\n event: Preventable<{\n collisions: Collisions;\n }>,\n manager: V\n ): void;\n beforedragstart(\n event: Preventable<{operation: DragOperation<T, U>}>,\n manager: V\n ): void;\n dragstart(\n event: {\n cancelable: false;\n operation: DragOperation<T, U>;\n },\n manager: V\n ): void;\n dragmove(\n event: Preventable<{\n operation: DragOperation<T, U>;\n to?: Coordinates;\n by?: Coordinates;\n }>,\n manager: V\n ): void;\n dragover(\n event: Preventable<{\n operation: DragOperation<T, U>;\n }>,\n manager: V\n ): void;\n dragend(\n event: {\n operation: DragOperation<T, U>;\n canceled: boolean;\n suspend(): {resume(): void; abort(): void};\n },\n manager: V\n ): void;\n};\n\nexport class DragDropMonitor<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> extends Monitor<DragDropEvents<T, U, V>> {\n constructor(private manager: V) {\n super();\n }\n\n public dispatch<Key extends keyof DragDropEvents<T, U, V>>(\n type: Key,\n event: Parameters<DragDropEvents<T, U, V>[Key]>[0]\n ) {\n const args = [event, this.manager] as any;\n\n super.dispatch(type, ...args);\n }\n}\n\nexport function defaultPreventable<T>(\n event: T,\n cancelable = true\n): Preventable<T> {\n let defaultPrevented = false;\n\n return {\n ...event,\n cancelable,\n get defaultPrevented() {\n return defaultPrevented;\n },\n preventDefault() {\n if (!cancelable) {\n return;\n }\n\n defaultPrevented = true;\n },\n };\n}\n","import type {DragOperation} from '../manager/index.ts';\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.ts';\n\nexport enum CollisionPriority {\n Lowest,\n Low,\n Normal,\n High,\n Highest,\n}\n\nexport interface Collision {\n id: UniqueIdentifier;\n priority: CollisionPriority | number;\n value: number;\n}\n\nexport type Collisions = Collision[];\n\nexport interface CollisionDetectorInput<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n droppable: U;\n dragOperation: DragOperation<T, U>;\n}\n\nexport type CollisionDetector = <\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n>(\n input: CollisionDetectorInput<T, U>\n) => Collision | null;\n","import {CleanupFunction, reactive, type Effect} from '@dnd-kit/state';\n\nimport {DragDropManager} from '../../manager/index.ts';\nimport type {Data, UniqueIdentifier} from './types.ts';\n\nexport interface Input<T extends Data = Data> {\n id: UniqueIdentifier;\n data?: T;\n disabled?: boolean;\n effects?(): Effect[];\n}\n\n/**\n * The `Entity` class is an abstract representation of a distinct unit in the drag and drop system.\n * It is a base class that other concrete classes like `Draggable` and `Droppable` can extend.\n *\n * @template T - The type of data associated with the entity.\n */\nexport class Entity<\n T extends Data = Data,\n U extends DragDropManager<any, any> = DragDropManager<any, any>,\n> {\n /**\n * Creates a new instance of the `Entity` class.\n *\n * @param input - An object containing the initial properties of the entity.\n * @param manager - The manager that controls the drag and drop operations.\n */\n constructor(input: Input<T>, manager: U | undefined) {\n const {effects, id, data = {}, disabled = false} = input;\n\n let previousId = id;\n\n this.manager = manager;\n this.id = id;\n this.data = data;\n this.disabled = disabled;\n this.effects = () => [\n () => {\n // Re-run this effect whenever the `id` changes\n const {id: _, manager} = this;\n\n if (id === previousId) {\n return;\n }\n\n manager?.registry.register(this);\n\n return () => manager?.registry.unregister(this);\n },\n ...(effects?.() ?? []),\n ];\n this.destroy = this.destroy.bind(this);\n\n if (manager) {\n queueMicrotask(() => {\n this.manager?.registry.register(this);\n });\n }\n }\n\n /**\n * The manager that controls the drag and drop operations.\n */\n @reactive\n public accessor manager: U | undefined;\n\n /**\n * The unique identifier of the entity.\n */\n @reactive\n public accessor id: UniqueIdentifier;\n\n /**\n * The data associated with the entity.\n */\n @reactive\n public accessor data: Data;\n\n /**\n * A boolean indicating whether the entity is disabled.\n */\n @reactive\n public accessor disabled: boolean;\n\n /**\n * An array of effects that are applied to the entity.\n */\n public effects: () => Effect[];\n\n /**\n * A method that registers the entity with the manager.\n * @returns CleanupFunction | void\n */\n public register(): CleanupFunction | void {\n return this.manager?.registry.register(this);\n }\n\n /**\n * A method that unregisters the entity from the manager.\n * @returns void\n */\n public unregister(): void {\n this.manager?.registry.unregister(this);\n }\n\n /**\n * A method that cleans up the entity when it is no longer needed.\n * @returns void\n */\n public destroy(): void {\n this.manager?.registry.unregister(this);\n }\n}\n","import {effects, signal} from '@dnd-kit/state';\n\nimport type {Entity} from './entity.ts';\nimport type {UniqueIdentifier} from './types.ts';\n\n/**\n * Reactive class representing a registry for entities.\n * @template T - The type of entries that the registry manages,\n * for example, `Draggable` or `Droppable` entities.\n */\nexport class EntityRegistry<T extends Entity> {\n private map = signal<Map<UniqueIdentifier, T>>(new Map());\n private cleanupFunctions = new WeakMap<T, () => void>();\n\n /**\n * Iterator for the EntityRegistry class.\n * @returns An iterator for the values in the map.\n */\n public [Symbol.iterator]() {\n return this.map.peek().values();\n }\n\n public get value() {\n return this.map.value.values();\n }\n\n /**\n * Checks if a entity with the given identifier exists in the registry.\n * @param identifier - The unique identifier of the entity.\n * @returns True if the entity exists, false otherwise.\n */\n public has(identifier: UniqueIdentifier): boolean {\n return this.map.value.has(identifier);\n }\n\n /**\n * Retrieves a entity from the registry using its identifier.\n * @param identifier - The unique identifier of the entity.\n * @returns The entity if it exists, undefined otherwise.\n */\n public get(identifier: UniqueIdentifier): T | undefined {\n return this.map.value.get(identifier);\n }\n\n /**\n * Registers a entity in the registry.\n * @param key - The unique identifier of the entity.\n * @param value - The entity to register.\n * @returns A function that unregisters the entity.\n */\n public register = (key: UniqueIdentifier, value: T) => {\n const current = this.map.peek();\n\n if (current.get(key) === value) {\n return;\n }\n\n const updatedMap = new Map(current);\n updatedMap.set(key, value);\n\n this.map.value = updatedMap;\n\n const cleanup = effects(...value.effects());\n this.cleanupFunctions.set(value, cleanup);\n\n return () => this.unregister(key, value);\n };\n\n /**\n * Unregisters an entity from the registry.\n * @param key - The unique identifier of the entity.\n * @param value - The entity instance to unregister.\n */\n public unregister = (key: UniqueIdentifier, value: T) => {\n const current = this.map.peek();\n\n if (current.get(key) !== value) {\n return;\n }\n\n const cleanup = this.cleanupFunctions.get(value);\n cleanup?.();\n this.cleanupFunctions.delete(value);\n\n const updatedMap = new Map(current);\n updatedMap.delete(key);\n\n this.map.value = updatedMap;\n };\n\n /**\n * Destroys all entries in the registry and clears the registry.\n */\n public destroy() {\n for (const entry of this) {\n const cleanup = this.cleanupFunctions.get(entry);\n cleanup?.();\n entry.destroy();\n }\n\n this.map.value = new Map();\n }\n}\n","import {derived, reactive} from '@dnd-kit/state';\n\nimport {Entity} from '../entity/index.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport {Modifier} from '../../modifiers/index.ts';\nimport type {Modifiers} from '../../modifiers/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport {descriptor} from '../../plugins/index.ts';\nimport type {Sensors} from '../../sensors/sensor.ts';\n\nexport interface Input<T extends Data = Data> extends EntityInput<T> {\n type?: Type;\n modifiers?: Modifiers;\n sensors?: Sensors;\n}\n\nexport type DraggableStatus = 'idle' | 'dragging' | 'dropping';\n\nexport class Draggable<\n T extends Data = Data,\n U extends DragDropManager<any, any> = DragDropManager<any, any>,\n> extends Entity<T> {\n constructor(\n {modifiers, type, sensors, ...input}: Input<T>,\n manager: U | undefined\n ) {\n super(input, manager);\n\n this.type = type;\n this.sensors = sensors;\n this.modifiers = modifiers;\n }\n\n public sensors: Sensors | undefined;\n\n #modifiers: Modifier[] | undefined;\n\n public set modifiers(modifiers: Modifiers | undefined) {\n const {manager} = this;\n\n this.#modifiers?.forEach((modifier) => modifier.destroy());\n\n if (!manager) return;\n this.#modifiers = modifiers?.map((modifier) => {\n const {plugin, options} = descriptor(modifier);\n\n return new plugin(manager, options);\n });\n }\n\n public get modifiers(): Modifier[] | undefined {\n return this.#modifiers;\n }\n\n @reactive\n public accessor type: Type | undefined;\n\n @reactive\n public accessor status: DraggableStatus = 'idle';\n\n /**\n * A boolean indicating whether the draggable item is the source of a drag operation.\n */\n @derived\n public get isDragSource() {\n return this.manager?.dragOperation.source?.id === this.id;\n }\n\n public destroy() {\n super.destroy();\n\n this.modifiers?.forEach((modifier) => modifier.destroy());\n }\n}\n","import {derived, effects, reactive, type Effect} from '@dnd-kit/state';\nimport type {Shape} from '@dnd-kit/geometry';\n\nimport {Entity} from '../entity/index.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport {\n CollisionPriority,\n type CollisionDetector,\n} from '../../collision/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport {Draggable} from '../draggable/draggable.ts';\n\nexport interface Input<T extends Data = Data> extends EntityInput<T> {\n accept?: Type | Type[] | ((source: Draggable) => boolean);\n collisionPriority?: CollisionPriority | number;\n collisionDetector: CollisionDetector;\n type?: Type;\n}\n\nexport class Droppable<\n T extends Data = Data,\n U extends DragDropManager<any, any> = DragDropManager<any, any>,\n> extends Entity<T> {\n constructor(\n {\n accept,\n collisionDetector,\n collisionPriority = CollisionPriority.Normal,\n type,\n ...input\n }: Input<T>,\n manager: U | undefined\n ) {\n super(input, manager);\n\n this.accept = accept;\n this.collisionDetector = collisionDetector;\n this.collisionPriority = collisionPriority;\n this.type = type;\n }\n\n /**\n * An array of types that are compatible with the droppable.\n */\n @reactive\n public accessor accept:\n | Type\n | Type[]\n | ((draggable: Draggable) => boolean)\n | undefined;\n\n /**\n * The type of the droppable.\n */\n @reactive\n public accessor type: Type | undefined;\n\n /**\n * Checks whether or not the droppable accepts a given draggable.\n *\n * @param {Draggable} draggable\n * @returns {boolean}\n */\n public accepts(draggable: Draggable): boolean {\n const {accept} = this;\n\n if (!accept) {\n return true;\n }\n\n if (!draggable.type) {\n return false;\n }\n\n if (Array.isArray(accept)) {\n return accept.includes(draggable.type);\n }\n\n if (typeof accept === 'function') {\n return accept(draggable);\n }\n\n return draggable.type === accept;\n }\n\n @reactive\n public accessor collisionDetector: CollisionDetector;\n\n @reactive\n public accessor collisionPriority: number;\n\n @reactive\n public accessor shape: Shape | undefined;\n\n @derived\n public get isDropTarget() {\n return this.manager?.dragOperation.target?.id === this.id;\n }\n\n public refreshShape() {\n // To be implemented by subclasses\n }\n}\n","import {CleanupFunction} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport {\n Plugin,\n type PluginConstructor,\n type PluginDescriptor,\n type PluginOptions,\n} from '../plugins/index.ts';\n\nexport type SensorOptions = PluginOptions;\n\nexport abstract class Sensor<\n T extends DragDropManager<any, any> = DragDropManager<Draggable, Droppable>,\n U extends SensorOptions = SensorOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n /**\n * Bind the sensor to a draggable source, and optionally pass\n * in sensor options to override the default sensor options\n * for this draggable source only.\n */\n public abstract bind(source: Draggable, options?: U): CleanupFunction;\n}\n\nexport type SensorConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Sensor<T>>;\n\nexport type SensorDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Sensor<T>, SensorConstructor<T>>;\n\nexport type Sensors<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (SensorConstructor<T> | SensorDescriptor<T>)[];\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport {\n Plugin,\n type PluginOptions,\n type PluginConstructor,\n type PluginDescriptor,\n} from '../plugins/index.ts';\nimport type {DragDropManager} from '../manager/index.ts';\n\nexport type ModifierOptions = PluginOptions;\n\nexport class Modifier<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends ModifierOptions = ModifierOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n public apply(operation: T['dragOperation']): Coordinates {\n return operation.transform;\n }\n}\n\nexport type ModifierConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Modifier<T, any>>;\n\nexport type ModifierDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Modifier<T, any>, ModifierConstructor<T>>;\n\nexport type Modifiers<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (ModifierConstructor<T> | ModifierDescriptor<T>)[];\n","import type {CleanupFunction} from '@dnd-kit/state';\n\nimport {\n Draggable,\n Droppable,\n Entity,\n EntityRegistry,\n} from '../entities/index.ts';\nimport {\n PluginRegistry,\n Plugin,\n type PluginConstructor,\n PluginOptions,\n} from '../plugins/index.ts';\nimport {\n Sensor,\n SensorOptions,\n type SensorConstructor,\n} from '../sensors/index.ts';\nimport {Modifier, type ModifierConstructor} from '../modifiers/index.ts';\nimport type {DragDropManager} from './manager.ts';\n\nexport class DragDropRegistry<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> {\n constructor(manager: V) {\n this.plugins = new PluginRegistry<V, PluginConstructor<V>>(manager);\n this.sensors = new PluginRegistry<V, SensorConstructor<V>>(manager);\n this.modifiers = new PluginRegistry<V, ModifierConstructor<V>>(manager);\n }\n\n public draggables = new EntityRegistry<T>();\n public droppables = new EntityRegistry<U>();\n public plugins: PluginRegistry<V, PluginConstructor<V>>;\n public sensors: PluginRegistry<V, SensorConstructor<V>>;\n public modifiers: PluginRegistry<V, ModifierConstructor<V>>;\n\n public register(input: Entity): () => void;\n public register(input: Draggable): () => void;\n public register(input: Droppable): () => void;\n public register(input: SensorConstructor, options?: SensorOptions): Sensor;\n public register(input: ModifierConstructor): Modifier;\n public register(input: PluginConstructor, options?: PluginOptions): Plugin;\n public register(input: any, options?: Record<string, any>) {\n if (input instanceof Draggable) {\n return this.draggables.register(input.id, input as T);\n }\n\n if (input instanceof Droppable) {\n return this.droppables.register(input.id, input as U);\n }\n\n if (input.prototype instanceof Modifier) {\n return this.modifiers.register(input, options);\n }\n\n if (input.prototype instanceof Sensor) {\n return this.sensors.register(input, options);\n }\n\n if (input.prototype instanceof Plugin) {\n return this.plugins.register(input, options);\n }\n\n throw new Error('Invalid instance type');\n }\n\n public unregister(input: Entity): CleanupFunction;\n public unregister(input: Draggable): CleanupFunction;\n public unregister(input: Droppable): CleanupFunction;\n public unregister(input: SensorConstructor): CleanupFunction;\n public unregister(input: ModifierConstructor): CleanupFunction;\n public unregister(input: PluginConstructor): CleanupFunction;\n public unregister(input: any) {\n if (input instanceof Entity) {\n if (input instanceof Draggable) {\n return this.draggables.unregister(input.id, input as T);\n }\n\n if (input instanceof Droppable) {\n return this.droppables.unregister(input.id, input as U);\n }\n\n // no-op\n return () => {};\n }\n\n if (input.prototype instanceof Modifier) {\n return this.modifiers.unregister(input);\n }\n\n if (input.prototype instanceof Sensor) {\n return this.sensors.unregister(input);\n }\n\n if (input.prototype instanceof Plugin) {\n return this.plugins.unregister(input);\n }\n\n throw new Error('Invalid instance type');\n }\n\n destroy() {\n this.draggables.destroy();\n this.droppables.destroy();\n this.plugins.destroy();\n this.sensors.destroy();\n this.modifiers.destroy();\n }\n}\n","import {Position, type Shape} from '@dnd-kit/geometry';\nimport type {Coordinates} from '@dnd-kit/geometry';\nimport {batch, computed, signal} from '@dnd-kit/state';\n\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.ts';\n\nimport type {DragDropManager} from './manager.ts';\nimport {defaultPreventable} from './events.ts';\n\nexport enum Status {\n Idle = 'idle',\n Initializing = 'initializing',\n Dragging = 'dragging',\n Dropped = 'dropped',\n}\n\nexport type Serializable = {\n [key: string]: string | number | null | Serializable | Serializable[];\n};\n\nexport interface DragOperation<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n activatorEvent: Event | null;\n canceled: boolean;\n position: Position;\n transform: Coordinates;\n status: {\n current: Status;\n initialized: boolean;\n initializing: boolean;\n dragging: boolean;\n dragended: boolean;\n dropped: boolean;\n idle: boolean;\n };\n get shape(): {\n initial: Shape;\n current: Shape;\n } | null;\n set shape(value: Shape | null);\n source: T | null;\n target: U | null;\n data?: Serializable;\n}\n\nexport type DragActions<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = ReturnType<typeof DragOperationManager<T, U, V>>['actions'];\n\nexport function DragOperationManager<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n>(manager: V) {\n const {\n registry: {draggables, droppables},\n monitor,\n } = manager;\n const status = signal<Status>(Status.Idle);\n const shape = {\n initial: signal<Shape | null>(null),\n current: signal<Shape | null>(null),\n };\n const canceled = signal<boolean>(false);\n const position = new Position({x: 0, y: 0});\n const activatorEvent = signal<Event | null>(null);\n const sourceIdentifier = signal<UniqueIdentifier | null>(null);\n const targetIdentifier = signal<UniqueIdentifier | null>(null);\n const dragging = computed(() => status.value === Status.Dragging);\n const initialized = computed(() => status.value !== Status.Idle);\n const initializing = computed(() => status.value === Status.Initializing);\n const idle = computed(() => status.value === Status.Idle);\n const dropped = computed(() => status.value === Status.Dropped);\n const dragended = signal<boolean>(true);\n let previousSource: T | undefined;\n const source = computed<T | null>(() => {\n const identifier = sourceIdentifier.value;\n\n if (identifier == null) return null;\n\n const value = draggables.get(identifier);\n\n if (value) {\n // It's possible for the source to unmount during the drag operation\n previousSource = value;\n }\n\n return value ?? previousSource ?? null;\n });\n const target = computed<U | null>(() => {\n const identifier = targetIdentifier.value;\n return identifier != null ? droppables.get(identifier) ?? null : null;\n });\n\n const transform = computed(() => {\n const {x, y} = position.delta;\n const modifiers = source?.value?.modifiers ?? manager.modifiers;\n\n let transform = {x, y};\n const initialShape = shape.initial.peek();\n const currentShape = shape.current.peek();\n const operation: Omit<DragOperation<T, U>, 'transform'> = {\n activatorEvent: activatorEvent.peek(),\n canceled: canceled.peek(),\n source: source.peek(),\n target: target.peek(),\n status: {\n current: status.peek(),\n idle: idle.peek(),\n initializing: initializing.peek(),\n initialized: initialized.peek(),\n dragging: dragging.peek(),\n dragended: dragended.peek(),\n dropped: dropped.peek(),\n },\n shape:\n initialShape && currentShape\n ? {initial: initialShape, current: currentShape}\n : null,\n position,\n };\n\n for (const modifier of modifiers) {\n transform = modifier.apply({...operation, transform});\n }\n\n return transform;\n });\n\n const operation: DragOperation<T, U> = {\n get activatorEvent() {\n return activatorEvent.value;\n },\n get canceled() {\n return canceled.value;\n },\n get source() {\n return source.value;\n },\n get target() {\n return target.value;\n },\n status: {\n get current() {\n return status.value;\n },\n get idle() {\n return idle.value;\n },\n get initializing() {\n return initializing.value;\n },\n get initialized() {\n return initialized.value;\n },\n get dragging() {\n return dragging.value;\n },\n get dragended() {\n return dragended.value;\n },\n get dropped() {\n return dropped.value;\n },\n },\n get shape(): DragOperation['shape'] {\n const initial = shape.initial.value;\n const current = shape.current.value;\n\n return initial && current ? {initial, current} : null;\n },\n set shape(value: Shape | null) {\n if (value && shape.current.peek()?.equals(value)) {\n return;\n }\n\n const initial = shape.initial.peek();\n\n if (!initial) {\n shape.initial.value = value;\n }\n\n shape.current.value = value;\n },\n get transform() {\n return transform.value;\n },\n position,\n };\n\n const reset = () => {\n batch(() => {\n status.value = Status.Idle;\n sourceIdentifier.value = null;\n targetIdentifier.value = null;\n shape.current.value = null;\n shape.initial.value = null;\n position.reset({x: 0, y: 0});\n });\n };\n\n return {\n operation,\n actions: {\n setDragSource(identifier: UniqueIdentifier) {\n sourceIdentifier.value = identifier;\n },\n setDropTarget(\n identifier: UniqueIdentifier | null | undefined\n ): Promise<void> {\n const id = identifier ?? null;\n\n if (targetIdentifier.peek() === id) {\n return Promise.resolve();\n }\n\n targetIdentifier.value = id;\n\n if (status.peek() === Status.Dragging) {\n monitor.dispatch(\n 'dragover',\n defaultPreventable({\n operation: snapshot(operation),\n })\n );\n }\n\n return manager.renderer.rendering;\n },\n start({event, coordinates}: {event: Event; coordinates: Coordinates}) {\n batch(() => {\n dragended.value = false;\n canceled.value = false;\n activatorEvent.value = event;\n position.reset(coordinates);\n });\n\n const beforeStartEvent = defaultPreventable({\n operation: snapshot(operation),\n });\n\n monitor.dispatch('beforedragstart', beforeStartEvent);\n\n manager.renderer.rendering.then(() => {\n if (beforeStartEvent.defaultPrevented) {\n reset();\n return;\n }\n\n status.value = Status.Initializing;\n\n requestAnimationFrame(() => {\n status.value = Status.Dragging;\n\n monitor.dispatch('dragstart', {\n operation: snapshot(operation),\n cancelable: false,\n });\n });\n });\n },\n move({\n by,\n to,\n cancelable = true,\n }:\n | {by: Coordinates; to?: undefined; cancelable?: boolean}\n | {by?: undefined; to: Coordinates; cancelable?: boolean}) {\n if (!dragging.peek()) {\n return;\n }\n\n const event = defaultPreventable(\n {\n operation: snapshot(operation),\n by,\n to,\n },\n cancelable\n );\n\n monitor.dispatch('dragmove', event);\n\n queueMicrotask(() => {\n if (event.defaultPrevented) {\n return;\n }\n\n const coordinates = to ?? {\n x: position.current.x + by.x,\n y: position.current.y + by.y,\n };\n\n position.update(coordinates);\n });\n },\n stop({canceled: eventCanceled = false}: {canceled?: boolean} = {}) {\n let promise: Promise<void> | undefined;\n const suspend = () => {\n const output = {\n resume: () => {},\n abort: () => {},\n };\n\n promise = new Promise<void>((resolve, reject) => {\n output.resume = resolve;\n output.abort = reject;\n });\n\n return output;\n };\n const end = () => {\n /* Wait for the renderer to finish rendering before finalizing the drag operation */\n manager.renderer.rendering.then(() => {\n status.value = Status.Dropped;\n manager.renderer.rendering.then(reset);\n });\n };\n\n batch(() => {\n dragended.value = true;\n canceled.value = eventCanceled;\n });\n\n monitor.dispatch('dragend', {\n operation: snapshot(operation),\n canceled: eventCanceled,\n suspend,\n });\n\n if (promise) {\n promise.then(end).catch(reset);\n } else {\n end();\n }\n },\n },\n };\n}\n\nfunction snapshot<T extends Record<string, any>>(obj: T): T {\n return {\n ...obj,\n };\n}\n","export interface Renderer {\n get rendering(): Promise<void>;\n}\n\nexport const defaultRenderer: Renderer = {\n get rendering() {\n return Promise.resolve();\n },\n};\n","import type {Draggable, Droppable} from '../entities/index.ts';\nimport {CollisionObserver, CollisionNotifier} from '../collision/index.ts';\nimport type {Plugins, Plugin} from '../plugins/index.ts';\nimport type {Sensor, Sensors} from '../sensors/index.ts';\nimport type {Modifier, Modifiers} from '../modifiers/index.ts';\n\nimport {DragDropRegistry} from './registry.ts';\nimport {\n DragOperationManager,\n type DragOperation,\n type DragActions,\n} from './dragOperation.ts';\nimport {DragDropMonitor} from './events.ts';\nimport {defaultRenderer, type Renderer} from './renderer.ts';\n\nexport type DragDropManagerInput<T extends DragDropManager<any, any>> = {\n plugins?: Plugins<T>;\n sensors?: Sensors<T>;\n modifiers?: Modifiers<T>;\n renderer?: Renderer;\n};\n\nexport class DragDropManager<T extends Draggable, U extends Droppable> {\n public actions: DragActions<T, U, DragDropManager<T, U>>;\n public collisionObserver: CollisionObserver<T, U>;\n public dragOperation: DragOperation<T, U>;\n public monitor: DragDropMonitor<T, U, DragDropManager<T, U>>;\n public registry: DragDropRegistry<T, U, DragDropManager<T, U>>;\n public renderer: Renderer;\n\n constructor(config?: DragDropManagerInput<any>) {\n type V = DragDropManager<T, U>;\n\n const {\n plugins = [],\n sensors = [],\n modifiers = [],\n renderer = defaultRenderer,\n } = config ?? {};\n const monitor = new DragDropMonitor<T, U, V>(this);\n const registry = new DragDropRegistry<T, U, V>(this);\n\n this.registry = registry;\n this.monitor = monitor;\n this.renderer = renderer;\n\n const {actions, operation} = DragOperationManager<T, U, V>(this);\n\n this.actions = actions;\n this.dragOperation = operation;\n this.collisionObserver = new CollisionObserver<T, U, V>(this);\n this.plugins = [CollisionNotifier, ...plugins];\n this.modifiers = modifiers;\n this.sensors = sensors;\n this.destroy = this.destroy.bind(this);\n }\n\n get plugins(): Plugin<any>[] {\n return this.registry.plugins.values;\n }\n\n set plugins(plugins: Plugins<any>) {\n this.registry.plugins.values = plugins;\n }\n\n get modifiers(): Modifier<any>[] {\n return this.registry.modifiers.values;\n }\n\n set modifiers(modifiers: Modifiers<any>) {\n this.registry.modifiers.values = modifiers;\n }\n\n get sensors(): Sensor<any>[] {\n return this.registry.sensors.values;\n }\n\n set sensors(sensors: Sensors<any>) {\n this.registry.sensors.values = sensors;\n }\n\n public destroy() {\n this.registry.destroy();\n this.collisionObserver.destroy();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["src/core/collision/observer.ts","src/core/plugins/plugin.ts","src/core/plugins/utilities.ts","src/core/plugins/registry.ts","src/core/collision/utilities.ts","src/core/collision/notifier.ts","src/core/manager/events.ts","src/core/collision/types.ts","src/core/entities/entity/entity.ts","src/core/entities/entity/registry.ts","src/core/entities/draggable/draggable.ts","src/core/entities/droppable/droppable.ts","src/core/sensors/sensor.ts","src/core/modifiers/modifier.ts","src/core/manager/registry.ts","src/core/manager/dragOperation.ts","src/core/manager/renderer.ts","src/core/manager/manager.ts"],"names":["untracked","effect","CollisionPriority","reactive","_disabled_dec","_init","_disabled","effects","manager","signal","derived","_type_dec","_c","_type","batch","computed","Status","transform","operation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAAA;AAAA,EAEA;AAAA,OACK;;;ACRP,SAAQ,UAAU,iBAAgB;;;ACO3B,SAAS,UAGd,QAAW,SAA2C;AACtD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,aACd,QACA;AACA,SAAO,CAAC,YAAkE;AACxE,WAAO,UAAU,QAAQ,OAAO;AAAA,EAClC;AACF;AAEO,SAAS,WACd,QAC+B;AAC/B,MAAI,OAAO,WAAW,YAAY;AAChC,WAAO;AAAA,MACL;AAAA,MACA,SAAS;AAAA,IACX;AAAA,EACF;AAEA,SAAO;AACT;;;ADpCA;AAuBE,iBAAC;AAbI,IAAe,SAAf,MAGL;AAAA,EACA,YACS,SACA,SACP;AAFO;AACA;AAQT,uBAAgB,WAAoB,kBAApC,gBAAoC,SAApC;AAAA,EAPG;AAAA;AAAA;A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,\n type ReadonlySignal,\n effect,\n} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport {Plugin} from '../plugins/index.ts';\nimport type {Collision, CollisionDetector, Collisions} from './types.ts';\nimport {sortCollisions} from './utilities.ts';\n\nconst DEFAULT_VALUE: Collisions = [];\n\nexport class CollisionObserver<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n V extends DragDropManager<T, U> = DragDropManager<T, U>,\n> extends Plugin<V> {\n constructor(manager: V) {\n super(manager);\n\n this.computeCollisions = this.computeCollisions.bind(this);\n this.#collisions = computed(this.computeCollisions, deepEqual);\n\n this.destroy = effect(() => {\n const {dragOperation} = this.manager;\n\n if (dragOperation.status.initialized) {\n this.forceUpdate();\n }\n });\n }\n\n forceUpdateCount = signal(0);\n\n public forceUpdate(refresh = true) {\n untracked(() => {\n const {source} = this.manager.dragOperation;\n\n batch(() => {\n if (refresh) {\n for (const droppable of this.manager.registry.droppables) {\n if (source && !droppable.accepts(source)) {\n continue;\n }\n\n droppable.refreshShape();\n }\n }\n\n this.forceUpdateCount.value++;\n });\n });\n }\n\n public computeCollisions(\n entries?: Droppable[],\n collisionDetector?: CollisionDetector\n ) {\n const {registry, dragOperation} = this.manager;\n const {source, shape, status} = dragOperation;\n\n if (!status.initialized || !shape) {\n return DEFAULT_VALUE;\n }\n\n const collisions: Collision[] = [];\n\n this.forceUpdateCount.value;\n\n for (const entry of entries ?? registry.droppables) {\n if (entry.disabled) {\n continue;\n }\n\n if (source && !entry.accepts(source)) {\n continue;\n }\n\n const detectCollision = collisionDetector ?? entry.collisionDetector;\n\n if (!detectCollision) {\n continue;\n }\n\n const collision = untracked(() =>\n detectCollision({\n droppable: entry,\n dragOperation,\n })\n );\n\n if (collision) {\n if (entry.collisionPriority != null) {\n collision.priority = entry.collisionPriority;\n }\n\n collisions.push(collision);\n }\n }\n\n collisions.sort(sortCollisions);\n\n return collisions;\n }\n\n public get collisions() {\n return this.#collisions.value;\n }\n\n #collisions: ReadonlySignal<Collisions>;\n}\n","import {reactive, untracked} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {PluginOptions} from './types.ts';\nimport {configure} from './utilities.ts';\n\n/**\n * An abstract plugin class that can be extended to implement custom\n * functionality that augments the `DragDropManager`'s core capabilities.\n */\nexport abstract class Plugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> {\n constructor(\n public manager: T,\n public options?: U\n ) {}\n\n /**\n * Whether the plugin instance is disabled.\n * Triggers effects when accessed.\n */\n @reactive\n public accessor disabled: boolean = false;\n\n /**\n * Enable a disabled plugin instance.\n * Triggers effects.\n */\n public enable() {\n this.disabled = false;\n }\n\n /**\n * Disable an enabled plugin instance.\n * Triggers effects.\n */\n public disable() {\n this.disabled = true;\n }\n\n /**\n * Whether the plugin instance is disabled.\n * Does not trigger effects when accessed.\n */\n public isDisabled() {\n return untracked(() => {\n return this.disabled;\n });\n }\n\n /**\n * Configure a plugin instance with new options.\n */\n public configure(options?: U) {\n this.options = options;\n }\n\n /**\n * Destroy a plugin instance.\n */\n public destroy() {\n /*\n * Each plugin is responsible for implementing its own\n * destroy method to clean up effects and listeners\n */\n }\n\n /**\n * Configure a plugin constructor with options.\n * This method is used to configure the options that the\n * plugin constructor will use to create plugin instances.\n */\n static configure(options: PluginOptions) {\n return configure(this as any, options);\n }\n}\n\nexport class CorePlugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> extends Plugin<T, U> {}\n","import type {\n PluginConstructor,\n PluginOptions,\n PluginDescriptor,\n InferPluginOptions,\n} from './types.ts';\n\nexport function configure<\n T extends PluginConstructor<any, any, any>,\n V extends PluginOptions = InferPluginOptions<T>,\n>(plugin: T, options: V): PluginDescriptor<any, any, T> {\n return {\n plugin,\n options,\n };\n}\n\nexport function configurator<T extends PluginConstructor<any, any, any>>(\n plugin: T\n) {\n return (options: InferPluginOptions<T>): PluginDescriptor<any, any, T> => {\n return configure(plugin, options);\n };\n}\n\nexport function descriptor<T extends PluginConstructor<any, any, any>>(\n plugin: T | PluginDescriptor<any, any, T>\n): PluginDescriptor<any, any, T> {\n if (typeof plugin === 'function') {\n return {\n plugin,\n options: undefined,\n };\n }\n\n return plugin;\n}\n","import {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin, type Plugin} from './plugin.ts';\nimport type {InferPluginOptions, PluginConstructor, Plugins} from './types.ts';\nimport {descriptor} from './utilities.ts';\n\nexport class PluginRegistry<\n T extends DragDropManager<any, any>,\n W extends PluginConstructor<T> = PluginConstructor<T>,\n U extends Plugin<T> = InstanceType<W>,\n> {\n private instances: Map<W, U> = new Map();\n\n constructor(private manager: T) {}\n\n public get values(): U[] {\n return Array.from(this.instances.values());\n }\n\n #previousValues: PluginConstructor<T>[] = [];\n\n public set values(entries: Plugins<T>) {\n const descriptors = entries.map(descriptor);\n const constructors = descriptors.map(({plugin}) => plugin);\n\n for (const plugin of this.#previousValues) {\n if (!constructors.includes(plugin)) {\n if (plugin.prototype instanceof CorePlugin) {\n continue;\n }\n\n this.unregister(plugin as W);\n }\n }\n\n for (const {plugin, options} of descriptors) {\n this.register(plugin as W, options as InferPluginOptions<W>);\n }\n\n this.#previousValues = constructors;\n }\n\n public get<X extends W>(plugin: X): InstanceType<X> | undefined {\n const instance = this.instances.get(plugin);\n\n return instance as any;\n }\n\n public register<X extends W>(\n plugin: X,\n options?: InferPluginOptions<X>\n ): InstanceType<X> {\n const existingInstance = this.instances.get(plugin);\n\n if (existingInstance) {\n return existingInstance as InstanceType<X>;\n }\n\n const instance = new plugin(this.manager, options) as U;\n\n this.instances.set(plugin, instance);\n\n return instance as InstanceType<X>;\n }\n\n public unregister<X extends W>(plugin: X) {\n const instance = this.instances.get(plugin);\n\n if (instance) {\n instance.destroy();\n this.instances.delete(plugin);\n }\n }\n\n public destroy() {\n for (const plugin of this.instances.values()) {\n plugin.destroy();\n }\n\n this.instances.clear();\n }\n}\n","import {Collision} from './types.ts';\n\n/**\n * Sort collisions from greatest to smallest priority\n * Collisions of equal priority are sorted from greatest to smallest value\n */\nexport function sortCollisions(a: Collision, b: Collision) {\n if (a.priority === b.priority) {\n return b.value - a.value;\n }\n\n return b.priority - a.priority;\n}\n","import {effect, untracked} from '@dnd-kit/state';\n\nimport {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin} from '../plugins/index.ts';\nimport {defaultPreventable} from '../manager/events.ts';\n\nexport class CollisionNotifier extends CorePlugin {\n constructor(manager: DragDropManager<any, any>) {\n super(manager);\n\n this.destroy = effect(() => {\n const {collisionObserver, monitor} = manager;\n const {collisions} = collisionObserver;\n\n if (collisionObserver.isDisabled()) {\n return;\n }\n\n const event = defaultPreventable({\n collisions,\n });\n\n monitor.dispatch('collision', event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n const [firstCollision] = collisions;\n\n untracked(() => {\n if (firstCollision?.id !== manager.dragOperation.target?.id) {\n collisionObserver.disable();\n\n manager.actions.setDropTarget(firstCollision?.id).then(() => {\n collisionObserver.enable();\n });\n }\n });\n });\n }\n}\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport type {Collisions} from '../collision/index.ts';\nimport type {DragDropManager} from './manager.ts';\nimport type {DragOperation} from './dragOperation.ts';\n\nexport type Events = Record<string, (...args: any[]) => void>;\n\nexport type Preventable<T> = T & {\n cancelable: boolean;\n defaultPrevented: boolean;\n preventDefault(): void;\n};\n\nclass Monitor<T extends Events> {\n private registry = new Map<keyof T, Set<T[keyof T]>>();\n\n public addEventListener<U extends keyof T>(name: U, handler: T[U]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.add(handler);\n registry.set(name, listeners);\n\n return () => this.removeEventListener(name, handler);\n }\n\n public removeEventListener(name: keyof T, handler: T[keyof T]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.delete(handler);\n registry.set(name, listeners);\n }\n\n protected dispatch<U extends keyof T>(name: U, ...args: any[]) {\n const {registry} = this;\n const listeners = registry.get(name);\n\n if (!listeners) {\n return;\n }\n\n for (const listener of listeners) {\n listener(...args);\n }\n }\n}\n\nexport type DragDropEvents<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = {\n collision(\n event: Preventable<{\n collisions: Collisions;\n }>,\n manager: V\n ): void;\n beforedragstart(\n event: Preventable<{operation: DragOperation<T, U>}>,\n manager: V\n ): void;\n dragstart(\n event: {\n cancelable: false;\n operation: DragOperation<T, U>;\n },\n manager: V\n ): void;\n dragmove(\n event: Preventable<{\n operation: DragOperation<T, U>;\n to?: Coordinates;\n by?: Coordinates;\n }>,\n manager: V\n ): void;\n dragover(\n event: Preventable<{\n operation: DragOperation<T, U>;\n }>,\n manager: V\n ): void;\n dragend(\n event: {\n operation: DragOperation<T, U>;\n canceled: boolean;\n suspend(): {resume(): void; abort(): void};\n },\n manager: V\n ): void;\n};\n\nexport class DragDropMonitor<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> extends Monitor<DragDropEvents<T, U, V>> {\n constructor(private manager: V) {\n super();\n }\n\n public dispatch<Key extends keyof DragDropEvents<T, U, V>>(\n type: Key,\n event: Parameters<DragDropEvents<T, U, V>[Key]>[0]\n ) {\n const args = [event, this.manager] as any;\n\n super.dispatch(type, ...args);\n }\n}\n\nexport function defaultPreventable<T>(\n event: T,\n cancelable = true\n): Preventable<T> {\n let defaultPrevented = false;\n\n return {\n ...event,\n cancelable,\n get defaultPrevented() {\n return defaultPrevented;\n },\n preventDefault() {\n if (!cancelable) {\n return;\n }\n\n defaultPrevented = true;\n },\n };\n}\n","import type {DragOperation} from '../manager/index.ts';\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.ts';\n\nexport enum CollisionPriority {\n Lowest,\n Low,\n Normal,\n High,\n Highest,\n}\n\nexport interface Collision {\n id: UniqueIdentifier;\n priority: CollisionPriority | number;\n value: number;\n}\n\nexport type Collisions = Collision[];\n\nexport interface CollisionDetectorInput<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n droppable: U;\n dragOperation: DragOperation<T, U>;\n}\n\nexport type CollisionDetector = <\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n>(\n input: CollisionDetectorInput<T, U>\n) => Collision | null;\n","import {CleanupFunction, reactive, type Effect} from '@dnd-kit/state';\n\nimport {DragDropManager} from '../../manager/index.ts';\nimport type {Data, UniqueIdentifier} from './types.ts';\n\nexport interface Input<T extends Data = Data> {\n id: UniqueIdentifier;\n data?: T;\n disabled?: boolean;\n effects?(): Effect[];\n}\n\n/**\n * The `Entity` class is an abstract representation of a distinct unit in the drag and drop system.\n * It is a base class that other concrete classes like `Draggable` and `Droppable` can extend.\n *\n * @template T - The type of data associated with the entity.\n */\nexport class Entity<\n T extends Data = Data,\n U extends DragDropManager<any, any> = DragDropManager<any, any>,\n> {\n /**\n * Creates a new instance of the `Entity` class.\n *\n * @param input - An object containing the initial properties of the entity.\n * @param manager - The manager that controls the drag and drop operations.\n */\n constructor(input: Input<T>, manager: U | undefined) {\n const {effects, id, data = {}, disabled = false} = input;\n\n let previousId = id;\n\n this.manager = manager;\n this.id = id;\n this.data = data;\n this.disabled = disabled;\n this.effects = () => [\n () => {\n // Re-run this effect whenever the `id` changes\n const {id: _, manager} = this;\n\n if (id === previousId) {\n return;\n }\n\n manager?.registry.register(this);\n\n return () => manager?.registry.unregister(this);\n },\n ...(effects?.() ?? []),\n ];\n this.destroy = this.destroy.bind(this);\n\n if (manager) {\n queueMicrotask(() => {\n this.manager?.registry.register(this);\n });\n }\n }\n\n /**\n * The manager that controls the drag and drop operations.\n */\n @reactive\n public accessor manager: U | undefined;\n\n /**\n * The unique identifier of the entity.\n */\n @reactive\n public accessor id: UniqueIdentifier;\n\n /**\n * The data associated with the entity.\n */\n @reactive\n public accessor data: Data;\n\n /**\n * A boolean indicating whether the entity is disabled.\n */\n @reactive\n public accessor disabled: boolean;\n\n /**\n * An array of effects that are applied to the entity.\n */\n public effects: () => Effect[];\n\n /**\n * A method that registers the entity with the manager.\n * @returns CleanupFunction | void\n */\n public register(): CleanupFunction | void {\n return this.manager?.registry.register(this);\n }\n\n /**\n * A method that unregisters the entity from the manager.\n * @returns void\n */\n public unregister(): void {\n this.manager?.registry.unregister(this);\n }\n\n /**\n * A method that cleans up the entity when it is no longer needed.\n * @returns void\n */\n public destroy(): void {\n this.manager?.registry.unregister(this);\n }\n}\n","import {effects, signal} from '@dnd-kit/state';\n\nimport type {Entity} from './entity.ts';\nimport type {UniqueIdentifier} from './types.ts';\n\n/**\n * Reactive class representing a registry for entities.\n * @template T - The type of entries that the registry manages,\n * for example, `Draggable` or `Droppable` entities.\n */\nexport class EntityRegistry<T extends Entity> {\n private map = signal<Map<UniqueIdentifier, T>>(new Map());\n private cleanupFunctions = new WeakMap<T, () => void>();\n\n /**\n * Iterator for the EntityRegistry class.\n * @returns An iterator for the values in the map.\n */\n public [Symbol.iterator]() {\n return this.map.peek().values();\n }\n\n public get value() {\n return this.map.value.values();\n }\n\n /**\n * Checks if a entity with the given identifier exists in the registry.\n * @param identifier - The unique identifier of the entity.\n * @returns True if the entity exists, false otherwise.\n */\n public has(identifier: UniqueIdentifier): boolean {\n return this.map.value.has(identifier);\n }\n\n /**\n * Retrieves a entity from the registry using its identifier.\n * @param identifier - The unique identifier of the entity.\n * @returns The entity if it exists, undefined otherwise.\n */\n public get(identifier: UniqueIdentifier): T | undefined {\n return this.map.value.get(identifier);\n }\n\n /**\n * Registers a entity in the registry.\n * @param key - The unique identifier of the entity.\n * @param value - The entity to register.\n * @returns A function that unregisters the entity.\n */\n public register = (key: UniqueIdentifier, value: T) => {\n const current = this.map.peek();\n\n if (current.get(key) === value) {\n return;\n }\n\n const updatedMap = new Map(current);\n updatedMap.set(key, value);\n\n this.map.value = updatedMap;\n\n const cleanup = effects(...value.effects());\n this.cleanupFunctions.set(value, cleanup);\n\n return () => this.unregister(key, value);\n };\n\n /**\n * Unregisters an entity from the registry.\n * @param key - The unique identifier of the entity.\n * @param value - The entity instance to unregister.\n */\n public unregister = (key: UniqueIdentifier, value: T) => {\n const current = this.map.peek();\n\n if (current.get(key) !== value) {\n return;\n }\n\n const cleanup = this.cleanupFunctions.get(value);\n cleanup?.();\n this.cleanupFunctions.delete(value);\n\n const updatedMap = new Map(current);\n updatedMap.delete(key);\n\n this.map.value = updatedMap;\n };\n\n /**\n * Destroys all entries in the registry and clears the registry.\n */\n public destroy() {\n for (const entry of this) {\n const cleanup = this.cleanupFunctions.get(entry);\n cleanup?.();\n entry.destroy();\n }\n\n this.map.value = new Map();\n }\n}\n","import {derived, reactive} from '@dnd-kit/state';\n\nimport {Entity} from '../entity/index.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport type {Modifiers} from '../../modifiers/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport type {Sensors} from '../../sensors/sensor.ts';\n\nexport interface Input<T extends Data = Data> extends EntityInput<T> {\n type?: Type;\n modifiers?: Modifiers;\n sensors?: Sensors;\n}\n\nexport type DraggableStatus = 'idle' | 'dragging' | 'dropping';\n\nexport class Draggable<\n T extends Data = Data,\n U extends DragDropManager<any, any> = DragDropManager<any, any>,\n> extends Entity<T> {\n constructor(\n {modifiers, type, sensors, ...input}: Input<T>,\n manager: U | undefined\n ) {\n super(input, manager);\n\n this.type = type;\n this.sensors = sensors;\n this.modifiers = modifiers;\n }\n\n public sensors: Sensors | undefined;\n\n @reactive\n public accessor modifiers: Modifiers | undefined;\n\n @reactive\n public accessor type: Type | undefined;\n\n @reactive\n public accessor status: DraggableStatus = 'idle';\n\n /**\n * A boolean indicating whether the draggable item is the source of a drag operation.\n */\n @derived\n public get isDragSource() {\n return this.manager?.dragOperation.source?.id === this.id;\n }\n}\n","import {derived, effects, reactive, type Effect} from '@dnd-kit/state';\nimport type {Shape} from '@dnd-kit/geometry';\n\nimport {Entity} from '../entity/index.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport {\n CollisionPriority,\n type CollisionDetector,\n} from '../../collision/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport {Draggable} from '../draggable/draggable.ts';\n\nexport interface Input<T extends Data = Data> extends EntityInput<T> {\n accept?: Type | Type[] | ((source: Draggable) => boolean);\n collisionPriority?: CollisionPriority | number;\n collisionDetector: CollisionDetector;\n type?: Type;\n}\n\nexport class Droppable<\n T extends Data = Data,\n U extends DragDropManager<any, any> = DragDropManager<any, any>,\n> extends Entity<T> {\n constructor(\n {\n accept,\n collisionDetector,\n collisionPriority = CollisionPriority.Normal,\n type,\n ...input\n }: Input<T>,\n manager: U | undefined\n ) {\n super(input, manager);\n\n this.accept = accept;\n this.collisionDetector = collisionDetector;\n this.collisionPriority = collisionPriority;\n this.type = type;\n }\n\n /**\n * An array of types that are compatible with the droppable.\n */\n @reactive\n public accessor accept:\n | Type\n | Type[]\n | ((draggable: Draggable) => boolean)\n | undefined;\n\n /**\n * The type of the droppable.\n */\n @reactive\n public accessor type: Type | undefined;\n\n /**\n * Checks whether or not the droppable accepts a given draggable.\n *\n * @param {Draggable} draggable\n * @returns {boolean}\n */\n public accepts(draggable: Draggable): boolean {\n const {accept} = this;\n\n if (!accept) {\n return true;\n }\n\n if (!draggable.type) {\n return false;\n }\n\n if (Array.isArray(accept)) {\n return accept.includes(draggable.type);\n }\n\n if (typeof accept === 'function') {\n return accept(draggable);\n }\n\n return draggable.type === accept;\n }\n\n @reactive\n public accessor collisionDetector: CollisionDetector;\n\n @reactive\n public accessor collisionPriority: number;\n\n @reactive\n public accessor shape: Shape | undefined;\n\n @derived\n public get isDropTarget() {\n return this.manager?.dragOperation.target?.id === this.id;\n }\n\n public refreshShape() {\n // To be implemented by subclasses\n }\n}\n","import {CleanupFunction} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport {\n Plugin,\n type PluginConstructor,\n type PluginDescriptor,\n type PluginOptions,\n} from '../plugins/index.ts';\n\nexport type SensorOptions = PluginOptions;\n\nexport abstract class Sensor<\n T extends DragDropManager<any, any> = DragDropManager<Draggable, Droppable>,\n U extends SensorOptions = SensorOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n /**\n * Bind the sensor to a draggable source, and optionally pass\n * in sensor options to override the default sensor options\n * for this draggable source only.\n */\n public abstract bind(source: Draggable, options?: U): CleanupFunction;\n}\n\nexport type SensorConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Sensor<T>>;\n\nexport type SensorDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Sensor<T>, SensorConstructor<T>>;\n\nexport type Sensors<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (SensorConstructor<T> | SensorDescriptor<T>)[];\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport {\n Plugin,\n type PluginOptions,\n type PluginConstructor,\n type PluginDescriptor,\n} from '../plugins/index.ts';\nimport type {DragDropManager} from '../manager/index.ts';\n\nexport type ModifierOptions = PluginOptions;\n\nexport class Modifier<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends ModifierOptions = ModifierOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n public apply(operation: T['dragOperation']): Coordinates {\n return operation.transform;\n }\n}\n\nexport type ModifierConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Modifier<T, any>>;\n\nexport type ModifierDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Modifier<T, any>, ModifierConstructor<T>>;\n\nexport type Modifiers<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (ModifierConstructor<T> | ModifierDescriptor<T>)[];\n","import type {CleanupFunction} from '@dnd-kit/state';\n\nimport {\n Draggable,\n Droppable,\n Entity,\n EntityRegistry,\n} from '../entities/index.ts';\nimport {\n PluginRegistry,\n Plugin,\n type PluginConstructor,\n PluginOptions,\n} from '../plugins/index.ts';\nimport {\n Sensor,\n SensorOptions,\n type SensorConstructor,\n} from '../sensors/index.ts';\nimport {Modifier, type ModifierConstructor} from '../modifiers/index.ts';\nimport type {DragDropManager} from './manager.ts';\n\nexport class DragDropRegistry<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> {\n constructor(manager: V) {\n this.plugins = new PluginRegistry<V, PluginConstructor<V>>(manager);\n this.sensors = new PluginRegistry<V, SensorConstructor<V>>(manager);\n this.modifiers = new PluginRegistry<V, ModifierConstructor<V>>(manager);\n }\n\n public draggables = new EntityRegistry<T>();\n public droppables = new EntityRegistry<U>();\n public plugins: PluginRegistry<V, PluginConstructor<V>>;\n public sensors: PluginRegistry<V, SensorConstructor<V>>;\n public modifiers: PluginRegistry<V, ModifierConstructor<V>>;\n\n public register(input: Entity): () => void;\n public register(input: Draggable): () => void;\n public register(input: Droppable): () => void;\n public register(input: SensorConstructor, options?: SensorOptions): Sensor;\n public register(input: ModifierConstructor): Modifier;\n public register(input: PluginConstructor, options?: PluginOptions): Plugin;\n public register(input: any, options?: Record<string, any>) {\n if (input instanceof Draggable) {\n return this.draggables.register(input.id, input as T);\n }\n\n if (input instanceof Droppable) {\n return this.droppables.register(input.id, input as U);\n }\n\n if (input.prototype instanceof Modifier) {\n return this.modifiers.register(input, options);\n }\n\n if (input.prototype instanceof Sensor) {\n return this.sensors.register(input, options);\n }\n\n if (input.prototype instanceof Plugin) {\n return this.plugins.register(input, options);\n }\n\n throw new Error('Invalid instance type');\n }\n\n public unregister(input: Entity): CleanupFunction;\n public unregister(input: Draggable): CleanupFunction;\n public unregister(input: Droppable): CleanupFunction;\n public unregister(input: SensorConstructor): CleanupFunction;\n public unregister(input: ModifierConstructor): CleanupFunction;\n public unregister(input: PluginConstructor): CleanupFunction;\n public unregister(input: any) {\n if (input instanceof Entity) {\n if (input instanceof Draggable) {\n return this.draggables.unregister(input.id, input as T);\n }\n\n if (input instanceof Droppable) {\n return this.droppables.unregister(input.id, input as U);\n }\n\n // no-op\n return () => {};\n }\n\n if (input.prototype instanceof Modifier) {\n return this.modifiers.unregister(input);\n }\n\n if (input.prototype instanceof Sensor) {\n return this.sensors.unregister(input);\n }\n\n if (input.prototype instanceof Plugin) {\n return this.plugins.unregister(input);\n }\n\n throw new Error('Invalid instance type');\n }\n\n destroy() {\n this.draggables.destroy();\n this.droppables.destroy();\n this.plugins.destroy();\n this.sensors.destroy();\n this.modifiers.destroy();\n }\n}\n","import {Position, type Shape} from '@dnd-kit/geometry';\nimport type {Coordinates} from '@dnd-kit/geometry';\nimport {batch, computed, effect, signal} from '@dnd-kit/state';\n\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.ts';\nimport type {Modifier} from '../modifiers/index.ts';\nimport {descriptor} from '../plugins/index.ts';\n\nimport type {DragDropManager} from './manager.ts';\nimport {defaultPreventable} from './events.ts';\n\nexport enum Status {\n Idle = 'idle',\n Initializing = 'initializing',\n Dragging = 'dragging',\n Dropped = 'dropped',\n}\n\nexport type Serializable = {\n [key: string]: string | number | null | Serializable | Serializable[];\n};\n\nexport interface DragOperation<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n activatorEvent: Event | null;\n canceled: boolean;\n position: Position;\n transform: Coordinates;\n status: {\n current: Status;\n initialized: boolean;\n initializing: boolean;\n dragging: boolean;\n dragended: boolean;\n dropped: boolean;\n idle: boolean;\n };\n get shape(): {\n initial: Shape;\n current: Shape;\n } | null;\n set shape(value: Shape | null);\n source: T | null;\n target: U | null;\n data?: Serializable;\n}\n\nexport type DragActions<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = ReturnType<typeof DragOperationManager<T, U, V>>['actions'];\n\nexport function DragOperationManager<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n>(manager: V) {\n const {\n registry: {draggables, droppables},\n monitor,\n } = manager;\n const status = signal<Status>(Status.Idle);\n const shape = {\n initial: signal<Shape | null>(null),\n current: signal<Shape | null>(null),\n };\n const canceled = signal<boolean>(false);\n const position = new Position({x: 0, y: 0});\n const activatorEvent = signal<Event | null>(null);\n const sourceIdentifier = signal<UniqueIdentifier | null>(null);\n const targetIdentifier = signal<UniqueIdentifier | null>(null);\n const dragging = computed(() => status.value === Status.Dragging);\n const initialized = computed(() => status.value !== Status.Idle);\n const initializing = computed(() => status.value === Status.Initializing);\n const idle = computed(() => status.value === Status.Idle);\n const dropped = computed(() => status.value === Status.Dropped);\n const dragended = signal<boolean>(true);\n let previousSource: T | undefined;\n const source = computed<T | null>(() => {\n const identifier = sourceIdentifier.value;\n\n if (identifier == null) return null;\n\n const value = draggables.get(identifier);\n\n if (value) {\n // It's possible for the source to unmount during the drag operation\n previousSource = value;\n }\n\n return value ?? previousSource ?? null;\n });\n const target = computed<U | null>(() => {\n const identifier = targetIdentifier.value;\n return identifier != null ? droppables.get(identifier) ?? null : null;\n });\n\n const modifiers = signal<Modifier[]>([]);\n\n effect(() => {\n const currentModifiers = modifiers.peek();\n\n if (currentModifiers !== manager.modifiers) {\n currentModifiers.forEach((modifier) => modifier.destroy());\n }\n\n modifiers.value =\n source.value?.modifiers?.map((modifier) => {\n const {plugin, options} = descriptor(modifier);\n return new plugin(manager, options);\n }) ?? manager.modifiers;\n });\n\n const transform = computed(() => {\n const {x, y} = position.delta;\n\n let transform = {x, y};\n const initialShape = shape.initial.peek();\n const currentShape = shape.current.peek();\n const operation: Omit<DragOperation<T, U>, 'transform'> = {\n activatorEvent: activatorEvent.peek(),\n canceled: canceled.peek(),\n source: source.peek(),\n target: target.peek(),\n status: {\n current: status.peek(),\n idle: idle.peek(),\n initializing: initializing.peek(),\n initialized: initialized.peek(),\n dragging: dragging.peek(),\n dragended: dragended.peek(),\n dropped: dropped.peek(),\n },\n shape:\n initialShape && currentShape\n ? {initial: initialShape, current: currentShape}\n : null,\n position,\n };\n\n for (const modifier of modifiers.value) {\n transform = modifier.apply({...operation, transform});\n }\n\n return transform;\n });\n\n const operation: DragOperation<T, U> = {\n get activatorEvent() {\n return activatorEvent.value;\n },\n get canceled() {\n return canceled.value;\n },\n get source() {\n return source.value;\n },\n get target() {\n return target.value;\n },\n status: {\n get current() {\n return status.value;\n },\n get idle() {\n return idle.value;\n },\n get initializing() {\n return initializing.value;\n },\n get initialized() {\n return initialized.value;\n },\n get dragging() {\n return dragging.value;\n },\n get dragended() {\n return dragended.value;\n },\n get dropped() {\n return dropped.value;\n },\n },\n get shape(): DragOperation['shape'] {\n const initial = shape.initial.value;\n const current = shape.current.value;\n\n return initial && current ? {initial, current} : null;\n },\n set shape(value: Shape | null) {\n if (value && shape.current.peek()?.equals(value)) {\n return;\n }\n\n const initial = shape.initial.peek();\n\n if (!initial) {\n shape.initial.value = value;\n }\n\n shape.current.value = value;\n },\n get transform() {\n return transform.value;\n },\n position,\n };\n\n const reset = () => {\n batch(() => {\n status.value = Status.Idle;\n sourceIdentifier.value = null;\n targetIdentifier.value = null;\n shape.current.value = null;\n shape.initial.value = null;\n position.reset({x: 0, y: 0});\n modifiers.value = [];\n });\n };\n\n return {\n operation,\n actions: {\n setDragSource(identifier: UniqueIdentifier) {\n sourceIdentifier.value = identifier;\n },\n setDropTarget(\n identifier: UniqueIdentifier | null | undefined\n ): Promise<void> {\n const id = identifier ?? null;\n\n if (targetIdentifier.peek() === id) {\n return Promise.resolve();\n }\n\n targetIdentifier.value = id;\n\n if (status.peek() === Status.Dragging) {\n monitor.dispatch(\n 'dragover',\n defaultPreventable({\n operation: snapshot(operation),\n })\n );\n }\n\n return manager.renderer.rendering;\n },\n start({event, coordinates}: {event: Event; coordinates: Coordinates}) {\n const sourceInstance = source.peek();\n\n if (!sourceInstance) {\n throw new Error(\n 'Cannot start a drag operation without a drag source'\n );\n }\n\n batch(() => {\n dragended.value = false;\n canceled.value = false;\n activatorEvent.value = event;\n position.reset(coordinates);\n });\n\n const beforeStartEvent = defaultPreventable({\n operation: snapshot(operation),\n });\n\n monitor.dispatch('beforedragstart', beforeStartEvent);\n\n manager.renderer.rendering.then(() => {\n if (beforeStartEvent.defaultPrevented) {\n reset();\n return;\n }\n\n status.value = Status.Initializing;\n\n requestAnimationFrame(() => {\n status.value = Status.Dragging;\n\n monitor.dispatch('dragstart', {\n operation: snapshot(operation),\n cancelable: false,\n });\n });\n });\n },\n move({\n by,\n to,\n cancelable = true,\n }:\n | {by: Coordinates; to?: undefined; cancelable?: boolean}\n | {by?: undefined; to: Coordinates; cancelable?: boolean}) {\n if (!dragging.peek()) {\n return;\n }\n\n const event = defaultPreventable(\n {\n operation: snapshot(operation),\n by,\n to,\n },\n cancelable\n );\n\n monitor.dispatch('dragmove', event);\n\n queueMicrotask(() => {\n if (event.defaultPrevented) {\n return;\n }\n\n const coordinates = to ?? {\n x: position.current.x + by.x,\n y: position.current.y + by.y,\n };\n\n position.update(coordinates);\n });\n },\n stop({canceled: eventCanceled = false}: {canceled?: boolean} = {}) {\n let promise: Promise<void> | undefined;\n const suspend = () => {\n const output = {\n resume: () => {},\n abort: () => {},\n };\n\n promise = new Promise<void>((resolve, reject) => {\n output.resume = resolve;\n output.abort = reject;\n });\n\n return output;\n };\n const end = () => {\n /* Wait for the renderer to finish rendering before finalizing the drag operation */\n manager.renderer.rendering.then(() => {\n status.value = Status.Dropped;\n manager.renderer.rendering.then(reset);\n });\n };\n\n batch(() => {\n dragended.value = true;\n canceled.value = eventCanceled;\n });\n\n monitor.dispatch('dragend', {\n operation: snapshot(operation),\n canceled: eventCanceled,\n suspend,\n });\n\n if (promise) {\n promise.then(end).catch(reset);\n } else {\n end();\n }\n },\n },\n };\n}\n\nfunction snapshot<T extends Record<string, any>>(obj: T): T {\n return {\n ...obj,\n };\n}\n","export interface Renderer {\n get rendering(): Promise<void>;\n}\n\nexport const defaultRenderer: Renderer = {\n get rendering() {\n return Promise.resolve();\n },\n};\n","import type {Draggable, Droppable} from '../entities/index.ts';\nimport {CollisionObserver, CollisionNotifier} from '../collision/index.ts';\nimport type {Plugins, Plugin} from '../plugins/index.ts';\nimport type {Sensor, Sensors} from '../sensors/index.ts';\nimport type {Modifier, Modifiers} from '../modifiers/index.ts';\n\nimport {DragDropRegistry} from './registry.ts';\nimport {\n DragOperationManager,\n type DragOperation,\n type DragActions,\n} from './dragOperation.ts';\nimport {DragDropMonitor} from './events.ts';\nimport {defaultRenderer, type Renderer} from './renderer.ts';\n\nexport type DragDropManagerInput<T extends DragDropManager<any, any>> = {\n plugins?: Plugins<T>;\n sensors?: Sensors<T>;\n modifiers?: Modifiers<T>;\n renderer?: Renderer;\n};\n\nexport class DragDropManager<T extends Draggable, U extends Droppable> {\n public actions: DragActions<T, U, DragDropManager<T, U>>;\n public collisionObserver: CollisionObserver<T, U>;\n public dragOperation: DragOperation<T, U>;\n public monitor: DragDropMonitor<T, U, DragDropManager<T, U>>;\n public registry: DragDropRegistry<T, U, DragDropManager<T, U>>;\n public renderer: Renderer;\n\n constructor(config?: DragDropManagerInput<any>) {\n type V = DragDropManager<T, U>;\n\n const {\n plugins = [],\n sensors = [],\n modifiers = [],\n renderer = defaultRenderer,\n } = config ?? {};\n const monitor = new DragDropMonitor<T, U, V>(this);\n const registry = new DragDropRegistry<T, U, V>(this);\n\n this.registry = registry;\n this.monitor = monitor;\n this.renderer = renderer;\n\n const {actions, operation} = DragOperationManager<T, U, V>(this);\n\n this.actions = actions;\n this.dragOperation = operation;\n this.collisionObserver = new CollisionObserver<T, U, V>(this);\n this.plugins = [CollisionNotifier, ...plugins];\n this.modifiers = modifiers;\n this.sensors = sensors;\n this.destroy = this.destroy.bind(this);\n }\n\n get plugins(): Plugin<any>[] {\n return this.registry.plugins.values;\n }\n\n set plugins(plugins: Plugins<any>) {\n this.registry.plugins.values = plugins;\n }\n\n get modifiers(): Modifier<any>[] {\n return this.registry.modifiers.values;\n }\n\n set modifiers(modifiers: Modifiers<any>) {\n this.registry.modifiers.values = modifiers;\n }\n\n get sensors(): Sensor<any>[] {\n return this.registry.sensors.values;\n }\n\n set sensors(sensors: Sensors<any>) {\n this.registry.sensors.values = sensors;\n }\n\n public destroy() {\n this.registry.destroy();\n this.collisionObserver.destroy();\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dnd-kit/abstract",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.cjs",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@dnd-kit/geometry": "^0.0.
|
|
48
|
-
"@dnd-kit/state": "^0.0.
|
|
47
|
+
"@dnd-kit/geometry": "^0.0.5",
|
|
48
|
+
"@dnd-kit/state": "^0.0.5",
|
|
49
49
|
"tslib": "^2.6.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|