@dnd-kit/abstract 0.0.1 → 0.0.2-beta-20240604230258

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 CHANGED
@@ -320,6 +320,9 @@ var CollisionPriority = /* @__PURE__ */ ((CollisionPriority2) => {
320
320
  CollisionPriority2[CollisionPriority2["Highest"] = 4] = "Highest";
321
321
  return CollisionPriority2;
322
322
  })(CollisionPriority || {});
323
+ function getDefaultEffects() {
324
+ return [];
325
+ }
323
326
  var Entity = class {
324
327
  /**
325
328
  * Creates a new instance of the `Entity` class.
@@ -329,19 +332,32 @@ var Entity = class {
329
332
  */
330
333
  constructor(input, manager) {
331
334
  this.manager = manager;
332
- const { effects: getInputEffects, id, data = null, disabled = false } = input;
335
+ const {
336
+ effects: getEffects = getDefaultEffects,
337
+ id,
338
+ data = null,
339
+ disabled = false
340
+ } = input;
341
+ let previousId = id;
333
342
  this.id = id;
334
343
  this.data = data;
335
344
  this.disabled = disabled;
336
345
  queueMicrotask(() => {
337
- const inputEffects = getInputEffects?.(this) ?? [];
338
- this.destroy = state.effects(
346
+ manager.registry.register(this);
347
+ const cleanupEffects = state.effects(
339
348
  () => {
349
+ if (id === previousId) {
350
+ return;
351
+ }
340
352
  manager.registry.register(this);
341
353
  return () => manager.registry.unregister(this);
342
354
  },
343
- ...inputEffects
355
+ ...getEffects()
344
356
  );
357
+ this.destroy = () => {
358
+ manager.registry.unregister(this);
359
+ cleanupEffects();
360
+ };
345
361
  });
346
362
  }
347
363
  id;
@@ -608,7 +624,7 @@ var Status = /* @__PURE__ */ ((Status2) => {
608
624
  Status2["Idle"] = "idle";
609
625
  Status2["Initializing"] = "initializing";
610
626
  Status2["Dragging"] = "dragging";
611
- Status2["Dropping"] = "dropping";
627
+ Status2["Dropped"] = "dropped";
612
628
  return Status2;
613
629
  })(Status || {});
614
630
  function DragOperationManager(manager) {
@@ -630,7 +646,8 @@ function DragOperationManager(manager) {
630
646
  const initialized = state.computed(() => status.value !== "idle" /* Idle */);
631
647
  const initializing = state.computed(() => status.value === "initializing" /* Initializing */);
632
648
  const idle = state.computed(() => status.value === "idle" /* Idle */);
633
- const dropping = state.computed(() => status.value === "dropping" /* Dropping */);
649
+ const dropped = state.computed(() => status.value === "dropped" /* Dropped */);
650
+ const dragended = state.signal(true);
634
651
  let previousSource;
635
652
  const source = state.computed(() => {
636
653
  const identifier = sourceIdentifier.value;
@@ -663,7 +680,8 @@ function DragOperationManager(manager) {
663
680
  initializing: initializing.peek(),
664
681
  initialized: initialized.peek(),
665
682
  dragging: dragging.peek(),
666
- dropping: dropping.peek()
683
+ dragended: dragended.peek(),
684
+ dropped: dropped.peek()
667
685
  },
668
686
  shape: initialShape && currentShape ? { initial: initialShape, current: currentShape } : null,
669
687
  position
@@ -702,8 +720,11 @@ function DragOperationManager(manager) {
702
720
  get dragging() {
703
721
  return dragging.value;
704
722
  },
705
- get dropping() {
706
- return dropping.value;
723
+ get dragended() {
724
+ return dragended.value;
725
+ },
726
+ get dropped() {
727
+ return dropped.value;
707
728
  }
708
729
  },
709
730
  get shape() {
@@ -748,16 +769,19 @@ function DragOperationManager(manager) {
748
769
  return Promise.resolve();
749
770
  }
750
771
  targetIdentifier.value = id;
751
- monitor.dispatch(
752
- "dragover",
753
- defaultPreventable({
754
- operation: snapshot(operation)
755
- })
756
- );
772
+ if (status.peek() === "dragging" /* Dragging */) {
773
+ monitor.dispatch(
774
+ "dragover",
775
+ defaultPreventable({
776
+ operation: snapshot(operation)
777
+ })
778
+ );
779
+ }
757
780
  return manager.renderer.rendering;
758
781
  },
759
782
  start({ event, coordinates }) {
760
783
  state.batch(() => {
784
+ dragended.value = false;
761
785
  canceled.value = false;
762
786
  activatorEvent.value = event;
763
787
  position.reset(coordinates);
@@ -826,11 +850,14 @@ function DragOperationManager(manager) {
826
850
  };
827
851
  const end = () => {
828
852
  manager.renderer.rendering.then(() => {
829
- status.value = "dropping" /* Dropping */;
853
+ status.value = "dropped" /* Dropped */;
830
854
  manager.renderer.rendering.then(reset);
831
855
  });
832
856
  };
833
- canceled.value = eventCanceled;
857
+ state.batch(() => {
858
+ dragended.value = true;
859
+ canceled.value = eventCanceled;
860
+ });
834
861
  monitor.dispatch("dragend", {
835
862
  operation: snapshot(operation),
836
863
  canceled: eventCanceled,
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","signal","derived","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;;;AD1BO,IAAe,SAAf,MAGL;AAAA,EACA,YACS,SACA,SACP;AAFO;AACA;AAAA,EACN;AAAA,EAOI,WAAoB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpB,SAAS;AACd,SAAK,WAAW;AAAA,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AU,CAAC,mBAAmB,GAAG,OAAO;AAC7C,SAAK,YAAY;AACjB,SAAK,UAAU;AAAA,EACjB;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.js';\nimport type {Draggable, Droppable} from '../entities/index.js';\nimport {Plugin} from '../plugins/index.js';\nimport type {Collision, CollisionDetector, Collisions} from './types.js';\nimport {sortCollisions} from './utilities.js';\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.js';\nimport type {PluginOptions} from './types.js';\nimport {configure} from './utilities.js';\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 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.js';\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.js';\nimport {CorePlugin, type Plugin} from './plugin.js';\nimport type {InferPluginOptions, PluginConstructor, Plugins} from './types.js';\nimport {descriptor} from './utilities.js';\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 descriptos = entries.map(descriptor);\n const constructors = descriptos.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 descriptos) {\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.js';\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.js';\nimport {CorePlugin} from '../plugins/index.js';\nimport {defaultPreventable} from '../manager/events.js';\n\nexport class CollisionNotifier extends CorePlugin {\n constructor(manager: DragDropManager) {\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.js';\nimport type {Collisions} from '../collision/index.js';\nimport type {DragDropManager} from './manager.js';\nimport type {DragOperation} from './dragOperation.js';\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.js';\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.js';\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 {effects, reactive, type Effect} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../../manager/index.js';\nimport type {Data, UniqueIdentifier} from './types.js';\n\nexport interface Input<T extends Data = Data, U extends Entity<T> = Entity<T>> {\n id: UniqueIdentifier;\n data?: T | null;\n disabled?: boolean;\n effects?: <Instance extends U>(instance: Instance) => 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<T extends Data = Data> {\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(\n input: Input<T>,\n public manager: DragDropManager\n ) {\n const {effects: getInputEffects, id, data = null, disabled = false} = input;\n\n this.id = id;\n this.data = data;\n this.disabled = disabled;\n\n queueMicrotask(() => {\n const inputEffects = getInputEffects?.(this) ?? [];\n\n this.destroy = effects(\n () => {\n // Re-run this effect whenever the `id` changes\n const {id: _} = this;\n manager.registry.register(this);\n\n return () => manager.registry.unregister(this);\n },\n ...inputEffects\n );\n });\n }\n\n /**\n * The unique identifier of the entity.\n */\n @reactive\n public id: UniqueIdentifier;\n\n /**\n * The data associated with the entity.\n */\n @reactive\n public data: Data | null;\n\n /**\n * A boolean indicating whether the entity is disabled.\n */\n @reactive\n public disabled: boolean;\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}\n","import {signal} from '@dnd-kit/state';\n\nimport type {Entity} from './entity.js';\nimport type {UniqueIdentifier} from './types.js';\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\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 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 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 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.js';\nimport type {EntityInput, Data, Type} from '../entity/index.js';\nimport {Modifier} from '../../modifiers/index.js';\nimport type {Modifiers} from '../../modifiers/index.js';\nimport type {DragDropManager} from '../../manager/index.js';\nimport {descriptor} from '../../plugins/index.js';\n\nexport interface Input<\n T extends Data = Data,\n U extends Draggable<T> = Draggable<T>,\n> extends EntityInput<T, U> {\n type?: Type;\n modifiers?: Modifiers;\n}\n\nexport class Draggable<T extends Data = Data> extends Entity<T> {\n constructor(\n {modifiers, type, ...input}: Input<T>,\n public manager: DragDropManager\n ) {\n super(input, manager);\n\n this.type = type;\n\n if (modifiers?.length) {\n this.modifiers = modifiers.map((modifier) => {\n const {plugin, options} = descriptor(modifier);\n\n return new plugin(manager, options);\n });\n }\n }\n\n public modifiers: Modifier[] | undefined;\n\n @reactive\n public type: Type | undefined;\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 const {dragOperation} = this.manager;\n\n return 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.js';\nimport type {EntityInput, Data, Type} from '../entity/index.js';\nimport {\n CollisionPriority,\n type CollisionDetector,\n} from '../../collision/index.js';\nimport type {DragDropManager} from '../../manager/index.js';\nimport {Draggable} from '../draggable/draggable.js';\n\nexport interface Input<\n T extends Data = Data,\n U extends Droppable<T> = Droppable<T>,\n> extends EntityInput<T, U> {\n accept?: Type | Type[] | ((source: Draggable) => boolean);\n collisionPriority?: CollisionPriority | number;\n collisionDetector: CollisionDetector;\n type?: Type;\n}\n\nexport class Droppable<T extends Data = Data> extends Entity<T> {\n constructor(\n {\n accept,\n collisionDetector,\n collisionPriority = CollisionPriority.Normal,\n type,\n ...input\n }: Input<T>,\n public manager: DragDropManager\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 accept:\n | Type\n | Type[]\n | ((draggable: Draggable) => boolean)\n | undefined;\n\n /**\n * The type of the droppable.\n */\n @reactive\n public 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 collisionDetector: CollisionDetector;\n\n @reactive\n public collisionPriority: number;\n\n @reactive\n public 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.js';\nimport type {Draggable} from '../entities/index.js';\nimport {\n Plugin,\n type PluginConstructor,\n type PluginDescriptor,\n type PluginOptions,\n} from '../plugins/index.js';\n\nexport type SensorOptions = PluginOptions;\n\nexport abstract class Sensor<\n T extends DragDropManager<any, any> = DragDropManager,\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.js';\nimport type {DragDropManager} from '../manager/index.js';\n\nexport type ModifierOptions = PluginOptions;\n\nexport class Modifier<\n T extends DragDropManager<any, any> = DragDropManager,\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.js';\nimport {\n PluginRegistry,\n Plugin,\n type PluginConstructor,\n PluginOptions,\n} from '../plugins/index.js';\nimport {\n Sensor,\n SensorOptions,\n type SensorConstructor,\n} from '../sensors/index.js';\nimport {Modifier, type ModifierConstructor} from '../modifiers/index.js';\nimport type {DragDropManager} from './manager.js';\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): Entity;\n public register(input: Draggable): Draggable;\n public register(input: Droppable): Droppable;\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.js';\n\nimport type {DragDropManager} from './manager.js';\nimport {defaultPreventable} from './events.js';\n\nexport enum Status {\n Idle = 'idle',\n Initializing = 'initializing',\n Dragging = 'dragging',\n Dropping = 'dropping',\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 dropping: 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 dropping = computed(() => status.value === Status.Dropping);\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 dropping: dropping.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 dropping() {\n return dropping.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 monitor.dispatch(\n 'dragover',\n defaultPreventable({\n operation: snapshot(operation),\n })\n );\n\n return manager.renderer.rendering;\n },\n start({event, coordinates}: {event: Event; coordinates: Coordinates}) {\n batch(() => {\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 manager.renderer.rendering.then(() => {\n status.value = Status.Dropping;\n\n manager.renderer.rendering.then(reset);\n });\n };\n\n canceled.value = eventCanceled;\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.js';\nimport {CollisionObserver, CollisionNotifier} from '../collision/index.js';\nimport type {Plugins, Plugin} from '../plugins/index.js';\nimport type {Sensor, Sensors} from '../sensors/index.js';\nimport type {Modifier, Modifiers} from '../modifiers/index.js';\n\nimport {DragDropRegistry} from './registry.js';\nimport {\n DragOperationManager,\n type DragOperation,\n type DragActions,\n} from './dragOperation.js';\nimport {DragDropMonitor} from './events.js';\nimport {defaultRenderer, type Renderer} from './renderer.js';\n\nexport interface DragDropConfiguration<T extends DragDropManager> {\n core?: {\n plugins: Plugins<T>;\n };\n plugins: Plugins<T>;\n sensors: Sensors<T>;\n modifiers: Modifiers<T>;\n renderer: Renderer;\n}\n\nexport type DragDropManagerInput<T extends DragDropManager<any, any>> = Partial<\n DragDropConfiguration<T>\n>;\n\nexport class DragDropManager<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\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 }\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","signal","derived","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;;;AD1BO,IAAe,SAAf,MAGL;AAAA,EACA,YACS,SACA,SACP;AAFO;AACA;AAAA,EACN;AAAA,EAOI,WAAoB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpB,SAAS;AACd,SAAK,WAAW;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,UAAU;AACf,SAAK,WAAW;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,aAAa;AAClB,WAAO,UAAU,MAAM;AACrB,aAAO,KAAK;AAAA,IACd,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKO,UAAU,SAAa;AAC5B,SAAK,UAAU;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKO,UAAU;AAAA,EAKjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,UAAU,SAAwB;AACvC,WAAO,UAAU,MAAa,OAAO;AAAA,EACvC;AACF;AArDS;AAAA,EADN;AAAA,GAbmB,OAcb;AAuDF,IAAM,aAAN,cAGG,OAAa;AAAC;;;AE7EjB,IAAM,iBAAN,MAIL;AAAA,EA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AAAA,EACjB;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.js';\nimport type {Draggable, Droppable} from '../entities/index.js';\nimport {Plugin} from '../plugins/index.js';\nimport type {Collision, CollisionDetector, Collisions} from './types.js';\nimport {sortCollisions} from './utilities.js';\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.js';\nimport type {PluginOptions} from './types.js';\nimport {configure} from './utilities.js';\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 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.js';\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.js';\nimport {CorePlugin, type Plugin} from './plugin.js';\nimport type {InferPluginOptions, PluginConstructor, Plugins} from './types.js';\nimport {descriptor} from './utilities.js';\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 descriptos = entries.map(descriptor);\n const constructors = descriptos.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 descriptos) {\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.js';\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.js';\nimport {CorePlugin} from '../plugins/index.js';\nimport {defaultPreventable} from '../manager/events.js';\n\nexport class CollisionNotifier extends CorePlugin {\n constructor(manager: DragDropManager) {\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.js';\nimport type {Collisions} from '../collision/index.js';\nimport type {DragDropManager} from './manager.js';\nimport type {DragOperation} from './dragOperation.js';\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.js';\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.js';\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 {effects, reactive, type Effect} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../../manager/index.js';\nimport type {Data, UniqueIdentifier} from './types.js';\n\nexport interface Input<T extends Data = Data, U extends Entity<T> = Entity<T>> {\n id: UniqueIdentifier;\n data?: T | null;\n disabled?: boolean;\n effects?(): Effect[];\n}\n\nfunction getDefaultEffects(): Effect[] {\n return [];\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<T extends Data = Data> {\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(\n input: Input<T>,\n public manager: DragDropManager\n ) {\n const {\n effects: getEffects = getDefaultEffects,\n id,\n data = null,\n disabled = false,\n } = input;\n\n let previousId = id;\n\n this.id = id;\n this.data = data;\n this.disabled = disabled;\n\n queueMicrotask(() => {\n manager.registry.register(this);\n\n const cleanupEffects = effects(\n () => {\n // Re-run this effect whenever the `id` changes\n const {id: _} = this;\n\n if (id === previousId) {\n return;\n }\n\n manager.registry.register(this);\n\n return () => manager.registry.unregister(this);\n },\n ...getEffects()\n );\n\n this.destroy = () => {\n manager.registry.unregister(this);\n cleanupEffects();\n };\n });\n }\n\n /**\n * The unique identifier of the entity.\n */\n @reactive\n public id: UniqueIdentifier;\n\n /**\n * The data associated with the entity.\n */\n @reactive\n public data: Data | null;\n\n /**\n * A boolean indicating whether the entity is disabled.\n */\n @reactive\n public disabled: boolean;\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}\n","import {signal} from '@dnd-kit/state';\n\nimport type {Entity} from './entity.js';\nimport type {UniqueIdentifier} from './types.js';\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\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 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 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 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.js';\nimport type {EntityInput, Data, Type} from '../entity/index.js';\nimport {Modifier} from '../../modifiers/index.js';\nimport type {Modifiers} from '../../modifiers/index.js';\nimport type {DragDropManager} from '../../manager/index.js';\nimport {descriptor} from '../../plugins/index.js';\n\nexport interface Input<\n T extends Data = Data,\n U extends Draggable<T> = Draggable<T>,\n> extends EntityInput<T, U> {\n type?: Type;\n modifiers?: Modifiers;\n}\n\nexport class Draggable<T extends Data = Data> extends Entity<T> {\n constructor(\n {modifiers, type, ...input}: Input<T>,\n public manager: DragDropManager\n ) {\n super(input, manager);\n\n this.type = type;\n\n if (modifiers?.length) {\n this.modifiers = modifiers.map((modifier) => {\n const {plugin, options} = descriptor(modifier);\n\n return new plugin(manager, options);\n });\n }\n }\n\n public modifiers: Modifier[] | undefined;\n\n @reactive\n public type: Type | undefined;\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 const {dragOperation} = this.manager;\n\n return 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.js';\nimport type {EntityInput, Data, Type} from '../entity/index.js';\nimport {\n CollisionPriority,\n type CollisionDetector,\n} from '../../collision/index.js';\nimport type {DragDropManager} from '../../manager/index.js';\nimport {Draggable} from '../draggable/draggable.js';\n\nexport interface Input<\n T extends Data = Data,\n U extends Droppable<T> = Droppable<T>,\n> extends EntityInput<T, U> {\n accept?: Type | Type[] | ((source: Draggable) => boolean);\n collisionPriority?: CollisionPriority | number;\n collisionDetector: CollisionDetector;\n type?: Type;\n}\n\nexport class Droppable<T extends Data = Data> extends Entity<T> {\n constructor(\n {\n accept,\n collisionDetector,\n collisionPriority = CollisionPriority.Normal,\n type,\n ...input\n }: Input<T>,\n public manager: DragDropManager\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 accept:\n | Type\n | Type[]\n | ((draggable: Draggable) => boolean)\n | undefined;\n\n /**\n * The type of the droppable.\n */\n @reactive\n public 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 collisionDetector: CollisionDetector;\n\n @reactive\n public collisionPriority: number;\n\n @reactive\n public 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.js';\nimport type {Draggable} from '../entities/index.js';\nimport {\n Plugin,\n type PluginConstructor,\n type PluginDescriptor,\n type PluginOptions,\n} from '../plugins/index.js';\n\nexport type SensorOptions = PluginOptions;\n\nexport abstract class Sensor<\n T extends DragDropManager<any, any> = DragDropManager,\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.js';\nimport type {DragDropManager} from '../manager/index.js';\n\nexport type ModifierOptions = PluginOptions;\n\nexport class Modifier<\n T extends DragDropManager<any, any> = DragDropManager,\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.js';\nimport {\n PluginRegistry,\n Plugin,\n type PluginConstructor,\n PluginOptions,\n} from '../plugins/index.js';\nimport {\n Sensor,\n SensorOptions,\n type SensorConstructor,\n} from '../sensors/index.js';\nimport {Modifier, type ModifierConstructor} from '../modifiers/index.js';\nimport type {DragDropManager} from './manager.js';\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): Entity;\n public register(input: Draggable): Draggable;\n public register(input: Droppable): Droppable;\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.js';\n\nimport type {DragDropManager} from './manager.js';\nimport {defaultPreventable} from './events.js';\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.js';\nimport {CollisionObserver, CollisionNotifier} from '../collision/index.js';\nimport type {Plugins, Plugin} from '../plugins/index.js';\nimport type {Sensor, Sensors} from '../sensors/index.js';\nimport type {Modifier, Modifiers} from '../modifiers/index.js';\n\nimport {DragDropRegistry} from './registry.js';\nimport {\n DragOperationManager,\n type DragOperation,\n type DragActions,\n} from './dragOperation.js';\nimport {DragDropMonitor} from './events.js';\nimport {defaultRenderer, type Renderer} from './renderer.js';\n\nexport interface DragDropConfiguration<T extends DragDropManager> {\n core?: {\n plugins: Plugins<T>;\n };\n plugins: Plugins<T>;\n sensors: Sensors<T>;\n modifiers: Modifiers<T>;\n renderer: Renderer;\n}\n\nexport type DragDropManagerInput<T extends DragDropManager<any, any>> = Partial<\n DragDropConfiguration<T>\n>;\n\nexport class DragDropManager<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\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 }\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.ts CHANGED
@@ -10,7 +10,7 @@ interface Input$2<T extends Data = Data, U extends Entity<T> = Entity<T>> {
10
10
  id: UniqueIdentifier;
11
11
  data?: T | null;
12
12
  disabled?: boolean;
13
- effects?: <Instance extends U>(instance: Instance) => Effect[];
13
+ effects?(): Effect[];
14
14
  }
15
15
  /**
16
16
  * The `Entity` class is an abstract representation of a distinct unit in the drag and drop system.
@@ -297,7 +297,7 @@ declare enum Status {
297
297
  Idle = "idle",
298
298
  Initializing = "initializing",
299
299
  Dragging = "dragging",
300
- Dropping = "dropping"
300
+ Dropped = "dropped"
301
301
  }
302
302
  type Serializable = {
303
303
  [key: string]: string | number | null | Serializable | Serializable[];
@@ -312,7 +312,8 @@ interface DragOperation<T extends Draggable = Draggable, U extends Droppable = D
312
312
  initialized: boolean;
313
313
  initializing: boolean;
314
314
  dragging: boolean;
315
- dropping: boolean;
315
+ dragended: boolean;
316
+ dropped: boolean;
316
317
  idle: boolean;
317
318
  };
318
319
  get shape(): {
package/index.js CHANGED
@@ -318,6 +318,9 @@ var CollisionPriority = /* @__PURE__ */ ((CollisionPriority2) => {
318
318
  CollisionPriority2[CollisionPriority2["Highest"] = 4] = "Highest";
319
319
  return CollisionPriority2;
320
320
  })(CollisionPriority || {});
321
+ function getDefaultEffects() {
322
+ return [];
323
+ }
321
324
  var Entity = class {
322
325
  /**
323
326
  * Creates a new instance of the `Entity` class.
@@ -327,19 +330,32 @@ var Entity = class {
327
330
  */
328
331
  constructor(input, manager) {
329
332
  this.manager = manager;
330
- const { effects: getInputEffects, id, data = null, disabled = false } = input;
333
+ const {
334
+ effects: getEffects = getDefaultEffects,
335
+ id,
336
+ data = null,
337
+ disabled = false
338
+ } = input;
339
+ let previousId = id;
331
340
  this.id = id;
332
341
  this.data = data;
333
342
  this.disabled = disabled;
334
343
  queueMicrotask(() => {
335
- const inputEffects = getInputEffects?.(this) ?? [];
336
- this.destroy = effects(
344
+ manager.registry.register(this);
345
+ const cleanupEffects = effects(
337
346
  () => {
347
+ if (id === previousId) {
348
+ return;
349
+ }
338
350
  manager.registry.register(this);
339
351
  return () => manager.registry.unregister(this);
340
352
  },
341
- ...inputEffects
353
+ ...getEffects()
342
354
  );
355
+ this.destroy = () => {
356
+ manager.registry.unregister(this);
357
+ cleanupEffects();
358
+ };
343
359
  });
344
360
  }
345
361
  id;
@@ -606,7 +622,7 @@ var Status = /* @__PURE__ */ ((Status2) => {
606
622
  Status2["Idle"] = "idle";
607
623
  Status2["Initializing"] = "initializing";
608
624
  Status2["Dragging"] = "dragging";
609
- Status2["Dropping"] = "dropping";
625
+ Status2["Dropped"] = "dropped";
610
626
  return Status2;
611
627
  })(Status || {});
612
628
  function DragOperationManager(manager) {
@@ -628,7 +644,8 @@ function DragOperationManager(manager) {
628
644
  const initialized = computed(() => status.value !== "idle" /* Idle */);
629
645
  const initializing = computed(() => status.value === "initializing" /* Initializing */);
630
646
  const idle = computed(() => status.value === "idle" /* Idle */);
631
- const dropping = computed(() => status.value === "dropping" /* Dropping */);
647
+ const dropped = computed(() => status.value === "dropped" /* Dropped */);
648
+ const dragended = signal(true);
632
649
  let previousSource;
633
650
  const source = computed(() => {
634
651
  const identifier = sourceIdentifier.value;
@@ -661,7 +678,8 @@ function DragOperationManager(manager) {
661
678
  initializing: initializing.peek(),
662
679
  initialized: initialized.peek(),
663
680
  dragging: dragging.peek(),
664
- dropping: dropping.peek()
681
+ dragended: dragended.peek(),
682
+ dropped: dropped.peek()
665
683
  },
666
684
  shape: initialShape && currentShape ? { initial: initialShape, current: currentShape } : null,
667
685
  position
@@ -700,8 +718,11 @@ function DragOperationManager(manager) {
700
718
  get dragging() {
701
719
  return dragging.value;
702
720
  },
703
- get dropping() {
704
- return dropping.value;
721
+ get dragended() {
722
+ return dragended.value;
723
+ },
724
+ get dropped() {
725
+ return dropped.value;
705
726
  }
706
727
  },
707
728
  get shape() {
@@ -746,16 +767,19 @@ function DragOperationManager(manager) {
746
767
  return Promise.resolve();
747
768
  }
748
769
  targetIdentifier.value = id;
749
- monitor.dispatch(
750
- "dragover",
751
- defaultPreventable({
752
- operation: snapshot(operation)
753
- })
754
- );
770
+ if (status.peek() === "dragging" /* Dragging */) {
771
+ monitor.dispatch(
772
+ "dragover",
773
+ defaultPreventable({
774
+ operation: snapshot(operation)
775
+ })
776
+ );
777
+ }
755
778
  return manager.renderer.rendering;
756
779
  },
757
780
  start({ event, coordinates }) {
758
781
  batch(() => {
782
+ dragended.value = false;
759
783
  canceled.value = false;
760
784
  activatorEvent.value = event;
761
785
  position.reset(coordinates);
@@ -824,11 +848,14 @@ function DragOperationManager(manager) {
824
848
  };
825
849
  const end = () => {
826
850
  manager.renderer.rendering.then(() => {
827
- status.value = "dropping" /* Dropping */;
851
+ status.value = "dropped" /* Dropped */;
828
852
  manager.renderer.rendering.then(reset);
829
853
  });
830
854
  };
831
- canceled.value = eventCanceled;
855
+ batch(() => {
856
+ dragended.value = true;
857
+ canceled.value = eventCanceled;
858
+ });
832
859
  monitor.dispatch("dragend", {
833
860
  operation: snapshot(operation),
834
861
  canceled: eventCanceled,
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","signal","derived","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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U,CAAC;AAAA,MACX,UAAU,CAAC;AAAA,MACX,YAAY,CAAC;AAAA,MACb,WAAW;AAAA,IACb,IAAI,UAAU,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;AAAA,EACjB;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.js';\nimport type {Draggable, Droppable} from '../entities/index.js';\nimport {Plugin} from '../plugins/index.js';\nimport type {Collision, CollisionDetector, Collisions} from './types.js';\nimport {sortCollisions} from './utilities.js';\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.js';\nimport type {PluginOptions} from './types.js';\nimport {configure} from './utilities.js';\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 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.js';\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.js';\nimport {CorePlugin, type Plugin} from './plugin.js';\nimport type {InferPluginOptions, PluginConstructor, Plugins} from './types.js';\nimport {descriptor} from './utilities.js';\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 descriptos = entries.map(descriptor);\n const constructors = descriptos.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 descriptos) {\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.js';\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.js';\nimport {CorePlugin} from '../plugins/index.js';\nimport {defaultPreventable} from '../manager/events.js';\n\nexport class CollisionNotifier extends CorePlugin {\n constructor(manager: DragDropManager) {\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.js';\nimport type {Collisions} from '../collision/index.js';\nimport type {DragDropManager} from './manager.js';\nimport type {DragOperation} from './dragOperation.js';\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.js';\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.js';\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 {effects, reactive, type Effect} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../../manager/index.js';\nimport type {Data, UniqueIdentifier} from './types.js';\n\nexport interface Input<T extends Data = Data, U extends Entity<T> = Entity<T>> {\n id: UniqueIdentifier;\n data?: T | null;\n disabled?: boolean;\n effects?: <Instance extends U>(instance: Instance) => 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<T extends Data = Data> {\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(\n input: Input<T>,\n public manager: DragDropManager\n ) {\n const {effects: getInputEffects, id, data = null, disabled = false} = input;\n\n this.id = id;\n this.data = data;\n this.disabled = disabled;\n\n queueMicrotask(() => {\n const inputEffects = getInputEffects?.(this) ?? [];\n\n this.destroy = effects(\n () => {\n // Re-run this effect whenever the `id` changes\n const {id: _} = this;\n manager.registry.register(this);\n\n return () => manager.registry.unregister(this);\n },\n ...inputEffects\n );\n });\n }\n\n /**\n * The unique identifier of the entity.\n */\n @reactive\n public id: UniqueIdentifier;\n\n /**\n * The data associated with the entity.\n */\n @reactive\n public data: Data | null;\n\n /**\n * A boolean indicating whether the entity is disabled.\n */\n @reactive\n public disabled: boolean;\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}\n","import {signal} from '@dnd-kit/state';\n\nimport type {Entity} from './entity.js';\nimport type {UniqueIdentifier} from './types.js';\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\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 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 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 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.js';\nimport type {EntityInput, Data, Type} from '../entity/index.js';\nimport {Modifier} from '../../modifiers/index.js';\nimport type {Modifiers} from '../../modifiers/index.js';\nimport type {DragDropManager} from '../../manager/index.js';\nimport {descriptor} from '../../plugins/index.js';\n\nexport interface Input<\n T extends Data = Data,\n U extends Draggable<T> = Draggable<T>,\n> extends EntityInput<T, U> {\n type?: Type;\n modifiers?: Modifiers;\n}\n\nexport class Draggable<T extends Data = Data> extends Entity<T> {\n constructor(\n {modifiers, type, ...input}: Input<T>,\n public manager: DragDropManager\n ) {\n super(input, manager);\n\n this.type = type;\n\n if (modifiers?.length) {\n this.modifiers = modifiers.map((modifier) => {\n const {plugin, options} = descriptor(modifier);\n\n return new plugin(manager, options);\n });\n }\n }\n\n public modifiers: Modifier[] | undefined;\n\n @reactive\n public type: Type | undefined;\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 const {dragOperation} = this.manager;\n\n return 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.js';\nimport type {EntityInput, Data, Type} from '../entity/index.js';\nimport {\n CollisionPriority,\n type CollisionDetector,\n} from '../../collision/index.js';\nimport type {DragDropManager} from '../../manager/index.js';\nimport {Draggable} from '../draggable/draggable.js';\n\nexport interface Input<\n T extends Data = Data,\n U extends Droppable<T> = Droppable<T>,\n> extends EntityInput<T, U> {\n accept?: Type | Type[] | ((source: Draggable) => boolean);\n collisionPriority?: CollisionPriority | number;\n collisionDetector: CollisionDetector;\n type?: Type;\n}\n\nexport class Droppable<T extends Data = Data> extends Entity<T> {\n constructor(\n {\n accept,\n collisionDetector,\n collisionPriority = CollisionPriority.Normal,\n type,\n ...input\n }: Input<T>,\n public manager: DragDropManager\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 accept:\n | Type\n | Type[]\n | ((draggable: Draggable) => boolean)\n | undefined;\n\n /**\n * The type of the droppable.\n */\n @reactive\n public 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 collisionDetector: CollisionDetector;\n\n @reactive\n public collisionPriority: number;\n\n @reactive\n public 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.js';\nimport type {Draggable} from '../entities/index.js';\nimport {\n Plugin,\n type PluginConstructor,\n type PluginDescriptor,\n type PluginOptions,\n} from '../plugins/index.js';\n\nexport type SensorOptions = PluginOptions;\n\nexport abstract class Sensor<\n T extends DragDropManager<any, any> = DragDropManager,\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.js';\nimport type {DragDropManager} from '../manager/index.js';\n\nexport type ModifierOptions = PluginOptions;\n\nexport class Modifier<\n T extends DragDropManager<any, any> = DragDropManager,\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.js';\nimport {\n PluginRegistry,\n Plugin,\n type PluginConstructor,\n PluginOptions,\n} from '../plugins/index.js';\nimport {\n Sensor,\n SensorOptions,\n type SensorConstructor,\n} from '../sensors/index.js';\nimport {Modifier, type ModifierConstructor} from '../modifiers/index.js';\nimport type {DragDropManager} from './manager.js';\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): Entity;\n public register(input: Draggable): Draggable;\n public register(input: Droppable): Droppable;\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.js';\n\nimport type {DragDropManager} from './manager.js';\nimport {defaultPreventable} from './events.js';\n\nexport enum Status {\n Idle = 'idle',\n Initializing = 'initializing',\n Dragging = 'dragging',\n Dropping = 'dropping',\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 dropping: 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 dropping = computed(() => status.value === Status.Dropping);\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 dropping: dropping.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 dropping() {\n return dropping.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 monitor.dispatch(\n 'dragover',\n defaultPreventable({\n operation: snapshot(operation),\n })\n );\n\n return manager.renderer.rendering;\n },\n start({event, coordinates}: {event: Event; coordinates: Coordinates}) {\n batch(() => {\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 manager.renderer.rendering.then(() => {\n status.value = Status.Dropping;\n\n manager.renderer.rendering.then(reset);\n });\n };\n\n canceled.value = eventCanceled;\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.js';\nimport {CollisionObserver, CollisionNotifier} from '../collision/index.js';\nimport type {Plugins, Plugin} from '../plugins/index.js';\nimport type {Sensor, Sensors} from '../sensors/index.js';\nimport type {Modifier, Modifiers} from '../modifiers/index.js';\n\nimport {DragDropRegistry} from './registry.js';\nimport {\n DragOperationManager,\n type DragOperation,\n type DragActions,\n} from './dragOperation.js';\nimport {DragDropMonitor} from './events.js';\nimport {defaultRenderer, type Renderer} from './renderer.js';\n\nexport interface DragDropConfiguration<T extends DragDropManager> {\n core?: {\n plugins: Plugins<T>;\n };\n plugins: Plugins<T>;\n sensors: Sensors<T>;\n modifiers: Modifiers<T>;\n renderer: Renderer;\n}\n\nexport type DragDropManagerInput<T extends DragDropManager<any, any>> = Partial<\n DragDropConfiguration<T>\n>;\n\nexport class DragDropManager<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\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 }\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","signal","derived","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;;;AD1BO,IAAe,SAAf,MAGL;AAAA,EACA,YACS,SACA,SACP;AAFO;AACA;AAAA,EACN;AAAA,EAOI,WAAoB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpB,SAAS;AACd,SAAK,WAAW;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,UAAU;AACf,SAAK,WAAW;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,aAAa;AAClB,WAAO,UAAU,MAAM;AACrB,aAAO,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AW;AAAA,IACb,IAAI,UAAU,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;AAAA,EACjB;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.js';\nimport type {Draggable, Droppable} from '../entities/index.js';\nimport {Plugin} from '../plugins/index.js';\nimport type {Collision, CollisionDetector, Collisions} from './types.js';\nimport {sortCollisions} from './utilities.js';\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.js';\nimport type {PluginOptions} from './types.js';\nimport {configure} from './utilities.js';\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 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.js';\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.js';\nimport {CorePlugin, type Plugin} from './plugin.js';\nimport type {InferPluginOptions, PluginConstructor, Plugins} from './types.js';\nimport {descriptor} from './utilities.js';\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 descriptos = entries.map(descriptor);\n const constructors = descriptos.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 descriptos) {\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.js';\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.js';\nimport {CorePlugin} from '../plugins/index.js';\nimport {defaultPreventable} from '../manager/events.js';\n\nexport class CollisionNotifier extends CorePlugin {\n constructor(manager: DragDropManager) {\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.js';\nimport type {Collisions} from '../collision/index.js';\nimport type {DragDropManager} from './manager.js';\nimport type {DragOperation} from './dragOperation.js';\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.js';\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.js';\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 {effects, reactive, type Effect} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../../manager/index.js';\nimport type {Data, UniqueIdentifier} from './types.js';\n\nexport interface Input<T extends Data = Data, U extends Entity<T> = Entity<T>> {\n id: UniqueIdentifier;\n data?: T | null;\n disabled?: boolean;\n effects?(): Effect[];\n}\n\nfunction getDefaultEffects(): Effect[] {\n return [];\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<T extends Data = Data> {\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(\n input: Input<T>,\n public manager: DragDropManager\n ) {\n const {\n effects: getEffects = getDefaultEffects,\n id,\n data = null,\n disabled = false,\n } = input;\n\n let previousId = id;\n\n this.id = id;\n this.data = data;\n this.disabled = disabled;\n\n queueMicrotask(() => {\n manager.registry.register(this);\n\n const cleanupEffects = effects(\n () => {\n // Re-run this effect whenever the `id` changes\n const {id: _} = this;\n\n if (id === previousId) {\n return;\n }\n\n manager.registry.register(this);\n\n return () => manager.registry.unregister(this);\n },\n ...getEffects()\n );\n\n this.destroy = () => {\n manager.registry.unregister(this);\n cleanupEffects();\n };\n });\n }\n\n /**\n * The unique identifier of the entity.\n */\n @reactive\n public id: UniqueIdentifier;\n\n /**\n * The data associated with the entity.\n */\n @reactive\n public data: Data | null;\n\n /**\n * A boolean indicating whether the entity is disabled.\n */\n @reactive\n public disabled: boolean;\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}\n","import {signal} from '@dnd-kit/state';\n\nimport type {Entity} from './entity.js';\nimport type {UniqueIdentifier} from './types.js';\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\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 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 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 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.js';\nimport type {EntityInput, Data, Type} from '../entity/index.js';\nimport {Modifier} from '../../modifiers/index.js';\nimport type {Modifiers} from '../../modifiers/index.js';\nimport type {DragDropManager} from '../../manager/index.js';\nimport {descriptor} from '../../plugins/index.js';\n\nexport interface Input<\n T extends Data = Data,\n U extends Draggable<T> = Draggable<T>,\n> extends EntityInput<T, U> {\n type?: Type;\n modifiers?: Modifiers;\n}\n\nexport class Draggable<T extends Data = Data> extends Entity<T> {\n constructor(\n {modifiers, type, ...input}: Input<T>,\n public manager: DragDropManager\n ) {\n super(input, manager);\n\n this.type = type;\n\n if (modifiers?.length) {\n this.modifiers = modifiers.map((modifier) => {\n const {plugin, options} = descriptor(modifier);\n\n return new plugin(manager, options);\n });\n }\n }\n\n public modifiers: Modifier[] | undefined;\n\n @reactive\n public type: Type | undefined;\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 const {dragOperation} = this.manager;\n\n return 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.js';\nimport type {EntityInput, Data, Type} from '../entity/index.js';\nimport {\n CollisionPriority,\n type CollisionDetector,\n} from '../../collision/index.js';\nimport type {DragDropManager} from '../../manager/index.js';\nimport {Draggable} from '../draggable/draggable.js';\n\nexport interface Input<\n T extends Data = Data,\n U extends Droppable<T> = Droppable<T>,\n> extends EntityInput<T, U> {\n accept?: Type | Type[] | ((source: Draggable) => boolean);\n collisionPriority?: CollisionPriority | number;\n collisionDetector: CollisionDetector;\n type?: Type;\n}\n\nexport class Droppable<T extends Data = Data> extends Entity<T> {\n constructor(\n {\n accept,\n collisionDetector,\n collisionPriority = CollisionPriority.Normal,\n type,\n ...input\n }: Input<T>,\n public manager: DragDropManager\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 accept:\n | Type\n | Type[]\n | ((draggable: Draggable) => boolean)\n | undefined;\n\n /**\n * The type of the droppable.\n */\n @reactive\n public 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 collisionDetector: CollisionDetector;\n\n @reactive\n public collisionPriority: number;\n\n @reactive\n public 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.js';\nimport type {Draggable} from '../entities/index.js';\nimport {\n Plugin,\n type PluginConstructor,\n type PluginDescriptor,\n type PluginOptions,\n} from '../plugins/index.js';\n\nexport type SensorOptions = PluginOptions;\n\nexport abstract class Sensor<\n T extends DragDropManager<any, any> = DragDropManager,\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.js';\nimport type {DragDropManager} from '../manager/index.js';\n\nexport type ModifierOptions = PluginOptions;\n\nexport class Modifier<\n T extends DragDropManager<any, any> = DragDropManager,\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.js';\nimport {\n PluginRegistry,\n Plugin,\n type PluginConstructor,\n PluginOptions,\n} from '../plugins/index.js';\nimport {\n Sensor,\n SensorOptions,\n type SensorConstructor,\n} from '../sensors/index.js';\nimport {Modifier, type ModifierConstructor} from '../modifiers/index.js';\nimport type {DragDropManager} from './manager.js';\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): Entity;\n public register(input: Draggable): Draggable;\n public register(input: Droppable): Droppable;\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.js';\n\nimport type {DragDropManager} from './manager.js';\nimport {defaultPreventable} from './events.js';\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.js';\nimport {CollisionObserver, CollisionNotifier} from '../collision/index.js';\nimport type {Plugins, Plugin} from '../plugins/index.js';\nimport type {Sensor, Sensors} from '../sensors/index.js';\nimport type {Modifier, Modifiers} from '../modifiers/index.js';\n\nimport {DragDropRegistry} from './registry.js';\nimport {\n DragOperationManager,\n type DragOperation,\n type DragActions,\n} from './dragOperation.js';\nimport {DragDropMonitor} from './events.js';\nimport {defaultRenderer, type Renderer} from './renderer.js';\n\nexport interface DragDropConfiguration<T extends DragDropManager> {\n core?: {\n plugins: Plugins<T>;\n };\n plugins: Plugins<T>;\n sensors: Sensors<T>;\n modifiers: Modifiers<T>;\n renderer: Renderer;\n}\n\nexport type DragDropManagerInput<T extends DragDropManager<any, any>> = Partial<\n DragDropConfiguration<T>\n>;\n\nexport class DragDropManager<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\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 }\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.1",
3
+ "version": "0.0.2-beta-20240604230258",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",