@dnd-kit/abstract 0.0.2-beta-20240606132521 → 0.0.2-beta-20240606230134
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 +31 -19
- package/index.cjs.map +1 -1
- package/index.d.ts +27 -20
- package/index.js +31 -19
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -343,34 +343,36 @@ var Entity = class {
|
|
|
343
343
|
this.id = id;
|
|
344
344
|
this.data = data;
|
|
345
345
|
this.disabled = disabled;
|
|
346
|
-
|
|
347
|
-
|
|
346
|
+
this.effects = [
|
|
347
|
+
() => {
|
|
348
|
+
if (id === previousId) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
348
351
|
manager.registry.register(this);
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
);
|
|
360
|
-
this.destroy = () => {
|
|
361
|
-
manager.registry.unregister(this);
|
|
362
|
-
cleanupEffects();
|
|
363
|
-
};
|
|
364
|
-
});
|
|
352
|
+
return () => manager.registry.unregister(this);
|
|
353
|
+
},
|
|
354
|
+
...getEffects()
|
|
355
|
+
];
|
|
356
|
+
this.destroy = this.destroy.bind(this);
|
|
357
|
+
if (options?.register !== false) {
|
|
358
|
+
queueMicrotask(() => {
|
|
359
|
+
manager.registry.register(this);
|
|
360
|
+
});
|
|
361
|
+
}
|
|
365
362
|
}
|
|
366
363
|
id;
|
|
367
364
|
data;
|
|
368
365
|
disabled;
|
|
366
|
+
/**
|
|
367
|
+
* An array of effects that are applied to the entity.
|
|
368
|
+
*/
|
|
369
|
+
effects;
|
|
369
370
|
/**
|
|
370
371
|
* A method that cleans up the entity when it is no longer needed.
|
|
371
372
|
* @returns void
|
|
372
373
|
*/
|
|
373
374
|
destroy() {
|
|
375
|
+
this.manager.registry.unregister(this);
|
|
374
376
|
}
|
|
375
377
|
};
|
|
376
378
|
__decorateClass([
|
|
@@ -384,6 +386,7 @@ __decorateClass([
|
|
|
384
386
|
], Entity.prototype, "disabled", 2);
|
|
385
387
|
var EntityRegistry = class {
|
|
386
388
|
map = state.signal(/* @__PURE__ */ new Map());
|
|
389
|
+
cleanupFunctions = /* @__PURE__ */ new WeakMap();
|
|
387
390
|
/**
|
|
388
391
|
* Iterator for the EntityRegistry class.
|
|
389
392
|
* @returns An iterator for the values in the map.
|
|
@@ -424,6 +427,8 @@ var EntityRegistry = class {
|
|
|
424
427
|
const updatedMap = new Map(current);
|
|
425
428
|
updatedMap.set(key, value);
|
|
426
429
|
this.map.value = updatedMap;
|
|
430
|
+
const cleanup = state.effects(...value.effects);
|
|
431
|
+
this.cleanupFunctions.set(value, cleanup);
|
|
427
432
|
return () => this.unregister(key, value);
|
|
428
433
|
};
|
|
429
434
|
/**
|
|
@@ -436,6 +441,9 @@ var EntityRegistry = class {
|
|
|
436
441
|
if (current.get(key) !== value) {
|
|
437
442
|
return;
|
|
438
443
|
}
|
|
444
|
+
const cleanup = this.cleanupFunctions.get(value);
|
|
445
|
+
cleanup?.();
|
|
446
|
+
this.cleanupFunctions.delete(value);
|
|
439
447
|
const updatedMap = new Map(current);
|
|
440
448
|
updatedMap.delete(key);
|
|
441
449
|
this.map.value = updatedMap;
|
|
@@ -445,16 +453,19 @@ var EntityRegistry = class {
|
|
|
445
453
|
*/
|
|
446
454
|
destroy() {
|
|
447
455
|
for (const entry of this) {
|
|
456
|
+
const cleanup = this.cleanupFunctions.get(entry);
|
|
457
|
+
cleanup?.();
|
|
448
458
|
entry.destroy();
|
|
449
459
|
}
|
|
450
460
|
this.map.value = /* @__PURE__ */ new Map();
|
|
451
461
|
}
|
|
452
462
|
};
|
|
453
463
|
var Draggable = class extends Entity {
|
|
454
|
-
constructor({ modifiers, type, ...input }, manager) {
|
|
464
|
+
constructor({ modifiers, type, sensors, ...input }, manager) {
|
|
455
465
|
super(input, manager);
|
|
456
466
|
this.manager = manager;
|
|
457
467
|
this.type = type;
|
|
468
|
+
this.sensors = sensors;
|
|
458
469
|
if (modifiers?.length) {
|
|
459
470
|
this.modifiers = modifiers.map((modifier) => {
|
|
460
471
|
const { plugin, options } = descriptor(modifier);
|
|
@@ -462,6 +473,7 @@ var Draggable = class extends Entity {
|
|
|
462
473
|
});
|
|
463
474
|
}
|
|
464
475
|
}
|
|
476
|
+
sensors;
|
|
465
477
|
modifiers;
|
|
466
478
|
type;
|
|
467
479
|
get isDragSource() {
|
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;;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AAQ;AACtB,SAAK,kBAAkB,QAAQ;AAAA,EACjC;AACF","sourcesContent":["import {\n batch,\n computed,\n deepEqual,\n signal,\n untracked,\n type ReadonlySignal,\n effect,\n} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport {Plugin} from '../plugins/index.ts';\nimport type {Collision, CollisionDetector, Collisions} from './types.ts';\nimport {sortCollisions} from './utilities.ts';\n\nconst DEFAULT_VALUE: Collisions = [];\n\nexport class CollisionObserver<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n V extends DragDropManager<T, U> = DragDropManager<T, U>,\n> extends Plugin<V> {\n constructor(manager: V) {\n super(manager);\n\n this.computeCollisions = this.computeCollisions.bind(this);\n this.#collisions = computed(this.computeCollisions, deepEqual);\n\n this.destroy = effect(() => {\n const {dragOperation} = this.manager;\n\n if (dragOperation.status.initialized) {\n this.forceUpdate();\n }\n });\n }\n\n forceUpdateCount = signal(0);\n\n public forceUpdate(refresh = true) {\n untracked(() => {\n const {source} = this.manager.dragOperation;\n\n batch(() => {\n if (refresh) {\n for (const droppable of this.manager.registry.droppables) {\n if (source && !droppable.accepts(source)) {\n continue;\n }\n\n droppable.refreshShape();\n }\n }\n\n this.forceUpdateCount.value++;\n });\n });\n }\n\n public computeCollisions(\n entries?: Droppable[],\n collisionDetector?: CollisionDetector\n ) {\n const {registry, dragOperation} = this.manager;\n const {source, shape, status} = dragOperation;\n\n if (!status.initialized || !shape) {\n return DEFAULT_VALUE;\n }\n\n const collisions: Collision[] = [];\n\n this.forceUpdateCount.value;\n\n for (const entry of entries ?? registry.droppables) {\n if (entry.disabled) {\n continue;\n }\n\n if (source && !entry.accepts(source)) {\n continue;\n }\n\n const detectCollision = collisionDetector ?? entry.collisionDetector;\n\n if (!detectCollision) {\n continue;\n }\n\n const collision = untracked(() =>\n detectCollision({\n droppable: entry,\n dragOperation,\n })\n );\n\n if (collision) {\n if (entry.collisionPriority != null) {\n collision.priority = entry.collisionPriority;\n }\n\n collisions.push(collision);\n }\n }\n\n collisions.sort(sortCollisions);\n\n return collisions;\n }\n\n public get collisions() {\n return this.#collisions.value;\n }\n\n #collisions: ReadonlySignal<Collisions>;\n}\n","import {reactive, untracked} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {PluginOptions} from './types.ts';\nimport {configure} from './utilities.ts';\n\n/**\n * An abstract plugin class that can be extended to implement custom\n * functionality that augments the `DragDropManager`'s core capabilities.\n */\nexport abstract class Plugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> {\n constructor(\n public manager: T,\n public options?: U\n ) {}\n\n /**\n * Whether the plugin instance is disabled.\n * Triggers effects when accessed.\n */\n @reactive\n public disabled: boolean = false;\n\n /**\n * Enable a disabled plugin instance.\n * Triggers effects.\n */\n public enable() {\n this.disabled = false;\n }\n\n /**\n * Disable an enabled plugin instance.\n * Triggers effects.\n */\n public disable() {\n this.disabled = true;\n }\n\n /**\n * Whether the plugin instance is disabled.\n * Does not trigger effects when accessed.\n */\n public isDisabled() {\n return untracked(() => {\n return this.disabled;\n });\n }\n\n /**\n * Configure a plugin instance with new options.\n */\n public configure(options?: U) {\n this.options = options;\n }\n\n /**\n * Destroy a plugin instance.\n */\n public destroy() {\n /*\n * Each plugin is responsible for implementing its own\n * destroy method to clean up effects and listeners\n */\n }\n\n /**\n * Configure a plugin constructor with options.\n * This method is used to configure the options that the\n * plugin constructor will use to create plugin instances.\n */\n static configure(options: PluginOptions) {\n return configure(this as any, options);\n }\n}\n\nexport class CorePlugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> extends Plugin<T, U> {}\n","import type {\n PluginConstructor,\n PluginOptions,\n PluginDescriptor,\n InferPluginOptions,\n} from './types.ts';\n\nexport function configure<\n T extends PluginConstructor<any, any, any>,\n V extends PluginOptions = InferPluginOptions<T>,\n>(plugin: T, options: V): PluginDescriptor<any, any, T> {\n return {\n plugin,\n options,\n };\n}\n\nexport function configurator<T extends PluginConstructor<any, any, any>>(\n plugin: T\n) {\n return (options: InferPluginOptions<T>): PluginDescriptor<any, any, T> => {\n return configure(plugin, options);\n };\n}\n\nexport function descriptor<T extends PluginConstructor<any, any, any>>(\n plugin: T | PluginDescriptor<any, any, T>\n): PluginDescriptor<any, any, T> {\n if (typeof plugin === 'function') {\n return {\n plugin,\n options: undefined,\n };\n }\n\n return plugin;\n}\n","import {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin, type Plugin} from './plugin.ts';\nimport type {InferPluginOptions, PluginConstructor, Plugins} from './types.ts';\nimport {descriptor} from './utilities.ts';\n\nexport class PluginRegistry<\n T extends DragDropManager<any, any>,\n W extends PluginConstructor<T> = PluginConstructor<T>,\n U extends Plugin<T> = InstanceType<W>,\n> {\n private instances: Map<W, U> = new Map();\n\n constructor(private manager: T) {}\n\n public get values(): U[] {\n return Array.from(this.instances.values());\n }\n\n #previousValues: PluginConstructor<T>[] = [];\n\n public set values(entries: Plugins<T>) {\n const descriptors = entries.map(descriptor);\n const constructors = descriptors.map(({plugin}) => plugin);\n\n for (const plugin of this.#previousValues) {\n if (!constructors.includes(plugin)) {\n if (plugin.prototype instanceof CorePlugin) {\n continue;\n }\n\n this.unregister(plugin as W);\n }\n }\n\n for (const {plugin, options} of descriptors) {\n this.register(plugin as W, options as InferPluginOptions<W>);\n }\n\n this.#previousValues = constructors;\n }\n\n public get<X extends W>(plugin: X): InstanceType<X> | undefined {\n const instance = this.instances.get(plugin);\n\n return instance as any;\n }\n\n public register<X extends W>(\n plugin: X,\n options?: InferPluginOptions<X>\n ): InstanceType<X> {\n const existingInstance = this.instances.get(plugin);\n\n if (existingInstance) {\n return existingInstance as InstanceType<X>;\n }\n\n const instance = new plugin(this.manager, options) as U;\n\n this.instances.set(plugin, instance);\n\n return instance as InstanceType<X>;\n }\n\n public unregister<X extends W>(plugin: X) {\n const instance = this.instances.get(plugin);\n\n if (instance) {\n instance.destroy();\n this.instances.delete(plugin);\n }\n }\n\n public destroy() {\n for (const plugin of this.instances.values()) {\n plugin.destroy();\n }\n\n this.instances.clear();\n }\n}\n","import {Collision} from './types.ts';\n\n/**\n * Sort collisions from greatest to smallest priority\n * Collisions of equal priority are sorted from greatest to smallest value\n */\nexport function sortCollisions(a: Collision, b: Collision) {\n if (a.priority === b.priority) {\n return b.value - a.value;\n }\n\n return b.priority - a.priority;\n}\n","import {effect, untracked} from '@dnd-kit/state';\n\nimport {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin} from '../plugins/index.ts';\nimport {defaultPreventable} from '../manager/events.ts';\n\nexport class CollisionNotifier extends CorePlugin {\n constructor(manager: DragDropManager) {\n super(manager);\n\n this.destroy = effect(() => {\n const {collisionObserver, monitor} = manager;\n const {collisions} = collisionObserver;\n\n if (collisionObserver.isDisabled()) {\n return;\n }\n\n const event = defaultPreventable({\n collisions,\n });\n\n monitor.dispatch('collision', event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n const [firstCollision] = collisions;\n\n untracked(() => {\n if (firstCollision?.id !== manager.dragOperation.target?.id) {\n collisionObserver.disable();\n\n manager.actions.setDropTarget(firstCollision?.id).then(() => {\n collisionObserver.enable();\n });\n }\n });\n });\n }\n}\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport type {Collisions} from '../collision/index.ts';\nimport type {DragDropManager} from './manager.ts';\nimport type {DragOperation} from './dragOperation.ts';\n\nexport type Events = Record<string, (...args: any[]) => void>;\n\nexport type Preventable<T> = T & {\n cancelable: boolean;\n defaultPrevented: boolean;\n preventDefault(): void;\n};\n\nclass Monitor<T extends Events> {\n private registry = new Map<keyof T, Set<T[keyof T]>>();\n\n public addEventListener<U extends keyof T>(name: U, handler: T[U]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.add(handler);\n registry.set(name, listeners);\n\n return () => this.removeEventListener(name, handler);\n }\n\n public removeEventListener(name: keyof T, handler: T[keyof T]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.delete(handler);\n registry.set(name, listeners);\n }\n\n protected dispatch<U extends keyof T>(name: U, ...args: any[]) {\n const {registry} = this;\n const listeners = registry.get(name);\n\n if (!listeners) {\n return;\n }\n\n for (const listener of listeners) {\n listener(...args);\n }\n }\n}\n\nexport type DragDropEvents<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = {\n collision(\n event: Preventable<{\n collisions: Collisions;\n }>,\n manager: V\n ): void;\n beforedragstart(\n event: Preventable<{operation: DragOperation<T, U>}>,\n manager: V\n ): void;\n dragstart(\n event: {\n cancelable: false;\n operation: DragOperation<T, U>;\n },\n manager: V\n ): void;\n dragmove(\n event: Preventable<{\n operation: DragOperation<T, U>;\n to?: Coordinates;\n by?: Coordinates;\n }>,\n manager: V\n ): void;\n dragover(\n event: Preventable<{\n operation: DragOperation<T, U>;\n }>,\n manager: V\n ): void;\n dragend(\n event: {\n operation: DragOperation<T, U>;\n canceled: boolean;\n suspend(): {resume(): void; abort(): void};\n },\n manager: V\n ): void;\n};\n\nexport class DragDropMonitor<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> extends Monitor<DragDropEvents<T, U, V>> {\n constructor(private manager: V) {\n super();\n }\n\n public dispatch<Key extends keyof DragDropEvents<T, U, V>>(\n type: Key,\n event: Parameters<DragDropEvents<T, U, V>[Key]>[0]\n ) {\n const args = [event, this.manager] as any;\n\n super.dispatch(type, ...args);\n }\n}\n\nexport function defaultPreventable<T>(\n event: T,\n cancelable = true\n): Preventable<T> {\n let defaultPrevented = false;\n\n return {\n ...event,\n cancelable,\n get defaultPrevented() {\n return defaultPrevented;\n },\n preventDefault() {\n if (!cancelable) {\n return;\n }\n\n defaultPrevented = true;\n },\n };\n}\n","import type {DragOperation} from '../manager/index.ts';\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.ts';\n\nexport enum CollisionPriority {\n Lowest,\n Low,\n Normal,\n High,\n Highest,\n}\n\nexport interface Collision {\n id: UniqueIdentifier;\n priority: CollisionPriority | number;\n value: number;\n}\n\nexport type Collisions = Collision[];\n\nexport interface CollisionDetectorInput<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n droppable: U;\n dragOperation: DragOperation<T, U>;\n}\n\nexport type CollisionDetector = <\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n>(\n input: CollisionDetectorInput<T, U>\n) => Collision | null;\n","import {effects, reactive, type Effect} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../../manager/index.ts';\nimport type {Data, UniqueIdentifier} from './types.ts';\n\ninterface Options {\n /**\n * A boolean indicating whether the entity should automatically be registered with the manager.\n * @defaultValue true\n */\n register?: boolean;\n}\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 options?: Options;\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 options,\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 if (options?.register !== false) {\n manager.registry.register(this);\n }\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.ts';\nimport type {UniqueIdentifier} from './types.ts';\n\n/**\n * Reactive class representing a registry for entities.\n * @template T - The type of entries that the registry manages,\n * for example, `Draggable` or `Droppable` entities.\n */\nexport class EntityRegistry<T extends Entity> {\n private map = signal<Map<UniqueIdentifier, T>>(new Map());\n\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.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport {Modifier} from '../../modifiers/index.ts';\nimport type {Modifiers} from '../../modifiers/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport {descriptor} from '../../plugins/index.ts';\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.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport {\n CollisionPriority,\n type CollisionDetector,\n} from '../../collision/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport {Draggable} from '../draggable/draggable.ts';\n\nexport interface Input<\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.ts';\nimport type {Draggable} from '../entities/index.ts';\nimport {\n Plugin,\n type PluginConstructor,\n type PluginDescriptor,\n type PluginOptions,\n} from '../plugins/index.ts';\n\nexport type SensorOptions = PluginOptions;\n\nexport abstract class Sensor<\n T extends DragDropManager<any, any> = DragDropManager,\n U extends SensorOptions = SensorOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n /**\n * Bind the sensor to a draggable source, and optionally pass\n * in sensor options to override the default sensor options\n * for this draggable source only.\n */\n public abstract bind(source: Draggable, options?: U): CleanupFunction;\n}\n\nexport type SensorConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Sensor<T>>;\n\nexport type SensorDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Sensor<T>, SensorConstructor<T>>;\n\nexport type Sensors<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (SensorConstructor<T> | SensorDescriptor<T>)[];\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport {\n Plugin,\n type PluginOptions,\n type PluginConstructor,\n type PluginDescriptor,\n} from '../plugins/index.ts';\nimport type {DragDropManager} from '../manager/index.ts';\n\nexport type ModifierOptions = PluginOptions;\n\nexport class Modifier<\n T extends DragDropManager<any, any> = DragDropManager,\n U extends ModifierOptions = ModifierOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n public apply(operation: T['dragOperation']): Coordinates {\n return operation.transform;\n }\n}\n\nexport type ModifierConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Modifier<T, any>>;\n\nexport type ModifierDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Modifier<T, any>, ModifierConstructor<T>>;\n\nexport type Modifiers<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (ModifierConstructor<T> | ModifierDescriptor<T>)[];\n","import type {CleanupFunction} from '@dnd-kit/state';\n\nimport {\n Draggable,\n Droppable,\n Entity,\n EntityRegistry,\n} from '../entities/index.ts';\nimport {\n PluginRegistry,\n Plugin,\n type PluginConstructor,\n PluginOptions,\n} from '../plugins/index.ts';\nimport {\n Sensor,\n SensorOptions,\n type SensorConstructor,\n} from '../sensors/index.ts';\nimport {Modifier, type ModifierConstructor} from '../modifiers/index.ts';\nimport type {DragDropManager} from './manager.ts';\n\nexport class DragDropRegistry<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> {\n constructor(manager: V) {\n this.plugins = new PluginRegistry<V, PluginConstructor<V>>(manager);\n this.sensors = new PluginRegistry<V, SensorConstructor<V>>(manager);\n this.modifiers = new PluginRegistry<V, ModifierConstructor<V>>(manager);\n }\n\n public draggables = new EntityRegistry<T>();\n public droppables = new EntityRegistry<U>();\n public plugins: PluginRegistry<V, PluginConstructor<V>>;\n public sensors: PluginRegistry<V, SensorConstructor<V>>;\n public modifiers: PluginRegistry<V, ModifierConstructor<V>>;\n\n public register(input: Entity): 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.ts';\n\nimport type {DragDropManager} from './manager.ts';\nimport {defaultPreventable} from './events.ts';\n\nexport enum Status {\n Idle = 'idle',\n Initializing = 'initializing',\n Dragging = 'dragging',\n Dropped = 'dropped',\n}\n\nexport type Serializable = {\n [key: string]: string | number | null | Serializable | Serializable[];\n};\n\nexport interface DragOperation<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n activatorEvent: Event | null;\n canceled: boolean;\n position: Position;\n transform: Coordinates;\n status: {\n current: Status;\n initialized: boolean;\n initializing: boolean;\n dragging: boolean;\n dragended: boolean;\n dropped: boolean;\n idle: boolean;\n };\n get shape(): {\n initial: Shape;\n current: Shape;\n } | null;\n set shape(value: Shape | null);\n source: T | null;\n target: U | null;\n data?: Serializable;\n}\n\nexport type DragActions<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = ReturnType<typeof DragOperationManager<T, U, V>>['actions'];\n\nexport function DragOperationManager<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n>(manager: V) {\n const {\n registry: {draggables, droppables},\n monitor,\n } = manager;\n const status = signal<Status>(Status.Idle);\n const shape = {\n initial: signal<Shape | null>(null),\n current: signal<Shape | null>(null),\n };\n const canceled = signal<boolean>(false);\n const position = new Position({x: 0, y: 0});\n const activatorEvent = signal<Event | null>(null);\n const sourceIdentifier = signal<UniqueIdentifier | null>(null);\n const targetIdentifier = signal<UniqueIdentifier | null>(null);\n const dragging = computed(() => status.value === Status.Dragging);\n const initialized = computed(() => status.value !== Status.Idle);\n const initializing = computed(() => status.value === Status.Initializing);\n const idle = computed(() => status.value === Status.Idle);\n const dropped = computed(() => status.value === Status.Dropped);\n const dragended = signal<boolean>(true);\n let previousSource: T | undefined;\n const source = computed<T | null>(() => {\n const identifier = sourceIdentifier.value;\n\n if (identifier == null) return null;\n\n const value = draggables.get(identifier);\n\n if (value) {\n // It's possible for the source to unmount during the drag operation\n previousSource = value;\n }\n\n return value ?? previousSource ?? null;\n });\n const target = computed<U | null>(() => {\n const identifier = targetIdentifier.value;\n return identifier != null ? droppables.get(identifier) ?? null : null;\n });\n\n const transform = computed(() => {\n const {x, y} = position.delta;\n const modifiers = source?.value?.modifiers ?? manager.modifiers;\n\n let transform = {x, y};\n const initialShape = shape.initial.peek();\n const currentShape = shape.current.peek();\n const operation: Omit<DragOperation<T, U>, 'transform'> = {\n activatorEvent: activatorEvent.peek(),\n canceled: canceled.peek(),\n source: source.peek(),\n target: target.peek(),\n status: {\n current: status.peek(),\n idle: idle.peek(),\n initializing: initializing.peek(),\n initialized: initialized.peek(),\n dragging: dragging.peek(),\n dragended: dragended.peek(),\n dropped: dropped.peek(),\n },\n shape:\n initialShape && currentShape\n ? {initial: initialShape, current: currentShape}\n : null,\n position,\n };\n\n for (const modifier of modifiers) {\n transform = modifier.apply({...operation, transform});\n }\n\n return transform;\n });\n\n const operation: DragOperation<T, U> = {\n get activatorEvent() {\n return activatorEvent.value;\n },\n get canceled() {\n return canceled.value;\n },\n get source() {\n return source.value;\n },\n get target() {\n return target.value;\n },\n status: {\n get current() {\n return status.value;\n },\n get idle() {\n return idle.value;\n },\n get initializing() {\n return initializing.value;\n },\n get initialized() {\n return initialized.value;\n },\n get dragging() {\n return dragging.value;\n },\n get dragended() {\n return dragended.value;\n },\n get dropped() {\n return dropped.value;\n },\n },\n get shape(): DragOperation['shape'] {\n const initial = shape.initial.value;\n const current = shape.current.value;\n\n return initial && current ? {initial, current} : null;\n },\n set shape(value: Shape | null) {\n if (value && shape.current.peek()?.equals(value)) {\n return;\n }\n\n const initial = shape.initial.peek();\n\n if (!initial) {\n shape.initial.value = value;\n }\n\n shape.current.value = value;\n },\n get transform() {\n return transform.value;\n },\n position,\n };\n\n const reset = () => {\n batch(() => {\n status.value = Status.Idle;\n sourceIdentifier.value = null;\n targetIdentifier.value = null;\n shape.current.value = null;\n shape.initial.value = null;\n position.reset({x: 0, y: 0});\n });\n };\n\n return {\n operation,\n actions: {\n setDragSource(identifier: UniqueIdentifier) {\n sourceIdentifier.value = identifier;\n },\n setDropTarget(\n identifier: UniqueIdentifier | null | undefined\n ): Promise<void> {\n const id = identifier ?? null;\n\n if (targetIdentifier.peek() === id) {\n return Promise.resolve();\n }\n\n targetIdentifier.value = id;\n\n if (status.peek() === Status.Dragging) {\n monitor.dispatch(\n 'dragover',\n defaultPreventable({\n operation: snapshot(operation),\n })\n );\n }\n\n return manager.renderer.rendering;\n },\n start({event, coordinates}: {event: Event; coordinates: Coordinates}) {\n batch(() => {\n dragended.value = false;\n canceled.value = false;\n activatorEvent.value = event;\n position.reset(coordinates);\n });\n\n const beforeStartEvent = defaultPreventable({\n operation: snapshot(operation),\n });\n\n monitor.dispatch('beforedragstart', beforeStartEvent);\n\n manager.renderer.rendering.then(() => {\n if (beforeStartEvent.defaultPrevented) {\n reset();\n return;\n }\n\n status.value = Status.Initializing;\n\n requestAnimationFrame(() => {\n status.value = Status.Dragging;\n\n monitor.dispatch('dragstart', {\n operation: snapshot(operation),\n cancelable: false,\n });\n });\n });\n },\n move({\n by,\n to,\n cancelable = true,\n }:\n | {by: Coordinates; to?: undefined; cancelable?: boolean}\n | {by?: undefined; to: Coordinates; cancelable?: boolean}) {\n if (!dragging.peek()) {\n return;\n }\n\n const event = defaultPreventable(\n {\n operation: snapshot(operation),\n by,\n to,\n },\n cancelable\n );\n\n monitor.dispatch('dragmove', event);\n\n queueMicrotask(() => {\n if (event.defaultPrevented) {\n return;\n }\n\n const coordinates = to ?? {\n x: position.current.x + by.x,\n y: position.current.y + by.y,\n };\n\n position.update(coordinates);\n });\n },\n stop({canceled: eventCanceled = false}: {canceled?: boolean} = {}) {\n let promise: Promise<void> | undefined;\n const suspend = () => {\n const output = {\n resume: () => {},\n abort: () => {},\n };\n\n promise = new Promise<void>((resolve, reject) => {\n output.resume = resolve;\n output.abort = reject;\n });\n\n return output;\n };\n const end = () => {\n /* Wait for the renderer to finish rendering before finalizing the drag operation */\n manager.renderer.rendering.then(() => {\n status.value = Status.Dropped;\n manager.renderer.rendering.then(reset);\n });\n };\n\n batch(() => {\n dragended.value = true;\n canceled.value = eventCanceled;\n });\n\n monitor.dispatch('dragend', {\n operation: snapshot(operation),\n canceled: eventCanceled,\n suspend,\n });\n\n if (promise) {\n promise.then(end).catch(reset);\n } else {\n end();\n }\n },\n },\n };\n}\n\nfunction snapshot<T extends Record<string, any>>(obj: T): T {\n return {\n ...obj,\n };\n}\n","export interface Renderer {\n get rendering(): Promise<void>;\n}\n\nexport const defaultRenderer: Renderer = {\n get rendering() {\n return Promise.resolve();\n },\n};\n","import type {Draggable, Droppable} from '../entities/index.ts';\nimport {CollisionObserver, CollisionNotifier} from '../collision/index.ts';\nimport type {Plugins, Plugin} from '../plugins/index.ts';\nimport type {Sensor, Sensors} from '../sensors/index.ts';\nimport type {Modifier, Modifiers} from '../modifiers/index.ts';\n\nimport {DragDropRegistry} from './registry.ts';\nimport {\n DragOperationManager,\n type DragOperation,\n type DragActions,\n} from './dragOperation.ts';\nimport {DragDropMonitor} from './events.ts';\nimport {defaultRenderer, type Renderer} from './renderer.ts';\n\nexport 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","effects","signal","derived","batch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yB,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.ts';\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport {Plugin} from '../plugins/index.ts';\nimport type {Collision, CollisionDetector, Collisions} from './types.ts';\nimport {sortCollisions} from './utilities.ts';\n\nconst DEFAULT_VALUE: Collisions = [];\n\nexport class CollisionObserver<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n V extends DragDropManager<T, U> = DragDropManager<T, U>,\n> extends Plugin<V> {\n constructor(manager: V) {\n super(manager);\n\n this.computeCollisions = this.computeCollisions.bind(this);\n this.#collisions = computed(this.computeCollisions, deepEqual);\n\n this.destroy = effect(() => {\n const {dragOperation} = this.manager;\n\n if (dragOperation.status.initialized) {\n this.forceUpdate();\n }\n });\n }\n\n forceUpdateCount = signal(0);\n\n public forceUpdate(refresh = true) {\n untracked(() => {\n const {source} = this.manager.dragOperation;\n\n batch(() => {\n if (refresh) {\n for (const droppable of this.manager.registry.droppables) {\n if (source && !droppable.accepts(source)) {\n continue;\n }\n\n droppable.refreshShape();\n }\n }\n\n this.forceUpdateCount.value++;\n });\n });\n }\n\n public computeCollisions(\n entries?: Droppable[],\n collisionDetector?: CollisionDetector\n ) {\n const {registry, dragOperation} = this.manager;\n const {source, shape, status} = dragOperation;\n\n if (!status.initialized || !shape) {\n return DEFAULT_VALUE;\n }\n\n const collisions: Collision[] = [];\n\n this.forceUpdateCount.value;\n\n for (const entry of entries ?? registry.droppables) {\n if (entry.disabled) {\n continue;\n }\n\n if (source && !entry.accepts(source)) {\n continue;\n }\n\n const detectCollision = collisionDetector ?? entry.collisionDetector;\n\n if (!detectCollision) {\n continue;\n }\n\n const collision = untracked(() =>\n detectCollision({\n droppable: entry,\n dragOperation,\n })\n );\n\n if (collision) {\n if (entry.collisionPriority != null) {\n collision.priority = entry.collisionPriority;\n }\n\n collisions.push(collision);\n }\n }\n\n collisions.sort(sortCollisions);\n\n return collisions;\n }\n\n public get collisions() {\n return this.#collisions.value;\n }\n\n #collisions: ReadonlySignal<Collisions>;\n}\n","import {reactive, untracked} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {PluginOptions} from './types.ts';\nimport {configure} from './utilities.ts';\n\n/**\n * An abstract plugin class that can be extended to implement custom\n * functionality that augments the `DragDropManager`'s core capabilities.\n */\nexport abstract class Plugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> {\n constructor(\n public manager: T,\n public options?: U\n ) {}\n\n /**\n * Whether the plugin instance is disabled.\n * Triggers effects when accessed.\n */\n @reactive\n public disabled: boolean = false;\n\n /**\n * Enable a disabled plugin instance.\n * Triggers effects.\n */\n public enable() {\n this.disabled = false;\n }\n\n /**\n * Disable an enabled plugin instance.\n * Triggers effects.\n */\n public disable() {\n this.disabled = true;\n }\n\n /**\n * Whether the plugin instance is disabled.\n * Does not trigger effects when accessed.\n */\n public isDisabled() {\n return untracked(() => {\n return this.disabled;\n });\n }\n\n /**\n * Configure a plugin instance with new options.\n */\n public configure(options?: U) {\n this.options = options;\n }\n\n /**\n * Destroy a plugin instance.\n */\n public destroy() {\n /*\n * Each plugin is responsible for implementing its own\n * destroy method to clean up effects and listeners\n */\n }\n\n /**\n * Configure a plugin constructor with options.\n * This method is used to configure the options that the\n * plugin constructor will use to create plugin instances.\n */\n static configure(options: PluginOptions) {\n return configure(this as any, options);\n }\n}\n\nexport class CorePlugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> extends Plugin<T, U> {}\n","import type {\n PluginConstructor,\n PluginOptions,\n PluginDescriptor,\n InferPluginOptions,\n} from './types.ts';\n\nexport function configure<\n T extends PluginConstructor<any, any, any>,\n V extends PluginOptions = InferPluginOptions<T>,\n>(plugin: T, options: V): PluginDescriptor<any, any, T> {\n return {\n plugin,\n options,\n };\n}\n\nexport function configurator<T extends PluginConstructor<any, any, any>>(\n plugin: T\n) {\n return (options: InferPluginOptions<T>): PluginDescriptor<any, any, T> => {\n return configure(plugin, options);\n };\n}\n\nexport function descriptor<T extends PluginConstructor<any, any, any>>(\n plugin: T | PluginDescriptor<any, any, T>\n): PluginDescriptor<any, any, T> {\n if (typeof plugin === 'function') {\n return {\n plugin,\n options: undefined,\n };\n }\n\n return plugin;\n}\n","import {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin, type Plugin} from './plugin.ts';\nimport type {InferPluginOptions, PluginConstructor, Plugins} from './types.ts';\nimport {descriptor} from './utilities.ts';\n\nexport class PluginRegistry<\n T extends DragDropManager<any, any>,\n W extends PluginConstructor<T> = PluginConstructor<T>,\n U extends Plugin<T> = InstanceType<W>,\n> {\n private instances: Map<W, U> = new Map();\n\n constructor(private manager: T) {}\n\n public get values(): U[] {\n return Array.from(this.instances.values());\n }\n\n #previousValues: PluginConstructor<T>[] = [];\n\n public set values(entries: Plugins<T>) {\n const descriptors = entries.map(descriptor);\n const constructors = descriptors.map(({plugin}) => plugin);\n\n for (const plugin of this.#previousValues) {\n if (!constructors.includes(plugin)) {\n if (plugin.prototype instanceof CorePlugin) {\n continue;\n }\n\n this.unregister(plugin as W);\n }\n }\n\n for (const {plugin, options} of descriptors) {\n this.register(plugin as W, options as InferPluginOptions<W>);\n }\n\n this.#previousValues = constructors;\n }\n\n public get<X extends W>(plugin: X): InstanceType<X> | undefined {\n const instance = this.instances.get(plugin);\n\n return instance as any;\n }\n\n public register<X extends W>(\n plugin: X,\n options?: InferPluginOptions<X>\n ): InstanceType<X> {\n const existingInstance = this.instances.get(plugin);\n\n if (existingInstance) {\n return existingInstance as InstanceType<X>;\n }\n\n const instance = new plugin(this.manager, options) as U;\n\n this.instances.set(plugin, instance);\n\n return instance as InstanceType<X>;\n }\n\n public unregister<X extends W>(plugin: X) {\n const instance = this.instances.get(plugin);\n\n if (instance) {\n instance.destroy();\n this.instances.delete(plugin);\n }\n }\n\n public destroy() {\n for (const plugin of this.instances.values()) {\n plugin.destroy();\n }\n\n this.instances.clear();\n }\n}\n","import {Collision} from './types.ts';\n\n/**\n * Sort collisions from greatest to smallest priority\n * Collisions of equal priority are sorted from greatest to smallest value\n */\nexport function sortCollisions(a: Collision, b: Collision) {\n if (a.priority === b.priority) {\n return b.value - a.value;\n }\n\n return b.priority - a.priority;\n}\n","import {effect, untracked} from '@dnd-kit/state';\n\nimport {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin} from '../plugins/index.ts';\nimport {defaultPreventable} from '../manager/events.ts';\n\nexport class CollisionNotifier extends CorePlugin {\n constructor(manager: DragDropManager) {\n super(manager);\n\n this.destroy = effect(() => {\n const {collisionObserver, monitor} = manager;\n const {collisions} = collisionObserver;\n\n if (collisionObserver.isDisabled()) {\n return;\n }\n\n const event = defaultPreventable({\n collisions,\n });\n\n monitor.dispatch('collision', event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n const [firstCollision] = collisions;\n\n untracked(() => {\n if (firstCollision?.id !== manager.dragOperation.target?.id) {\n collisionObserver.disable();\n\n manager.actions.setDropTarget(firstCollision?.id).then(() => {\n collisionObserver.enable();\n });\n }\n });\n });\n }\n}\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport type {Collisions} from '../collision/index.ts';\nimport type {DragDropManager} from './manager.ts';\nimport type {DragOperation} from './dragOperation.ts';\n\nexport type Events = Record<string, (...args: any[]) => void>;\n\nexport type Preventable<T> = T & {\n cancelable: boolean;\n defaultPrevented: boolean;\n preventDefault(): void;\n};\n\nclass Monitor<T extends Events> {\n private registry = new Map<keyof T, Set<T[keyof T]>>();\n\n public addEventListener<U extends keyof T>(name: U, handler: T[U]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.add(handler);\n registry.set(name, listeners);\n\n return () => this.removeEventListener(name, handler);\n }\n\n public removeEventListener(name: keyof T, handler: T[keyof T]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.delete(handler);\n registry.set(name, listeners);\n }\n\n protected dispatch<U extends keyof T>(name: U, ...args: any[]) {\n const {registry} = this;\n const listeners = registry.get(name);\n\n if (!listeners) {\n return;\n }\n\n for (const listener of listeners) {\n listener(...args);\n }\n }\n}\n\nexport type DragDropEvents<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = {\n collision(\n event: Preventable<{\n collisions: Collisions;\n }>,\n manager: V\n ): void;\n beforedragstart(\n event: Preventable<{operation: DragOperation<T, U>}>,\n manager: V\n ): void;\n dragstart(\n event: {\n cancelable: false;\n operation: DragOperation<T, U>;\n },\n manager: V\n ): void;\n dragmove(\n event: Preventable<{\n operation: DragOperation<T, U>;\n to?: Coordinates;\n by?: Coordinates;\n }>,\n manager: V\n ): void;\n dragover(\n event: Preventable<{\n operation: DragOperation<T, U>;\n }>,\n manager: V\n ): void;\n dragend(\n event: {\n operation: DragOperation<T, U>;\n canceled: boolean;\n suspend(): {resume(): void; abort(): void};\n },\n manager: V\n ): void;\n};\n\nexport class DragDropMonitor<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> extends Monitor<DragDropEvents<T, U, V>> {\n constructor(private manager: V) {\n super();\n }\n\n public dispatch<Key extends keyof DragDropEvents<T, U, V>>(\n type: Key,\n event: Parameters<DragDropEvents<T, U, V>[Key]>[0]\n ) {\n const args = [event, this.manager] as any;\n\n super.dispatch(type, ...args);\n }\n}\n\nexport function defaultPreventable<T>(\n event: T,\n cancelable = true\n): Preventable<T> {\n let defaultPrevented = false;\n\n return {\n ...event,\n cancelable,\n get defaultPrevented() {\n return defaultPrevented;\n },\n preventDefault() {\n if (!cancelable) {\n return;\n }\n\n defaultPrevented = true;\n },\n };\n}\n","import type {DragOperation} from '../manager/index.ts';\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.ts';\n\nexport enum CollisionPriority {\n Lowest,\n Low,\n Normal,\n High,\n Highest,\n}\n\nexport interface Collision {\n id: UniqueIdentifier;\n priority: CollisionPriority | number;\n value: number;\n}\n\nexport type Collisions = Collision[];\n\nexport interface CollisionDetectorInput<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n droppable: U;\n dragOperation: DragOperation<T, U>;\n}\n\nexport type CollisionDetector = <\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n>(\n input: CollisionDetectorInput<T, U>\n) => Collision | null;\n","import {effects, reactive, type Effect} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../../manager/index.ts';\nimport type {Data, UniqueIdentifier} from './types.ts';\n\ninterface Options {\n /**\n * A boolean indicating whether the entity should automatically be registered with the manager.\n * @defaultValue true\n */\n register?: boolean;\n}\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 options?: Options;\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 options,\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 this.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 this.destroy = this.destroy.bind(this);\n\n if (options?.register !== false) {\n queueMicrotask(() => {\n manager.registry.register(this);\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 * An array of effects that are applied to the entity.\n */\n public effects: Effect[];\n\n /**\n * A method that cleans up the entity when it is no longer needed.\n * @returns void\n */\n public destroy(): void {\n this.manager.registry.unregister(this);\n }\n}\n","import {effects, signal} from '@dnd-kit/state';\n\nimport type {Entity} from './entity.ts';\nimport type {UniqueIdentifier} from './types.ts';\n\n/**\n * Reactive class representing a registry for entities.\n * @template T - The type of entries that the registry manages,\n * for example, `Draggable` or `Droppable` entities.\n */\nexport class EntityRegistry<T extends Entity> {\n private map = signal<Map<UniqueIdentifier, T>>(new Map());\n private cleanupFunctions = new WeakMap<T, () => void>();\n\n /**\n * Iterator for the EntityRegistry class.\n * @returns An iterator for the values in the map.\n */\n public [Symbol.iterator]() {\n return this.map.peek().values();\n }\n\n public get value() {\n return this.map.value.values();\n }\n\n /**\n * Checks if a entity with the given identifier exists in the registry.\n * @param identifier - The unique identifier of the entity.\n * @returns True if the entity exists, false otherwise.\n */\n public has(identifier: UniqueIdentifier): boolean {\n return this.map.value.has(identifier);\n }\n\n /**\n * Retrieves a entity from the registry using its identifier.\n * @param identifier - The unique identifier of the entity.\n * @returns The entity if it exists, undefined otherwise.\n */\n public get(identifier: UniqueIdentifier): T | undefined {\n return this.map.value.get(identifier);\n }\n\n /**\n * Registers a entity in the registry.\n * @param key - The unique identifier of the entity.\n * @param value - The entity to register.\n * @returns A function that unregisters the entity.\n */\n public register = (key: UniqueIdentifier, value: T) => {\n const current = this.map.peek();\n\n if (current.get(key) === value) {\n return;\n }\n\n const updatedMap = new Map(current);\n updatedMap.set(key, value);\n\n this.map.value = updatedMap;\n\n const cleanup = effects(...value.effects);\n this.cleanupFunctions.set(value, cleanup);\n\n return () => this.unregister(key, value);\n };\n\n /**\n * Unregisters an entity from the registry.\n * @param key - The unique identifier of the entity.\n * @param value - The entity instance to unregister.\n */\n public unregister = (key: UniqueIdentifier, value: T) => {\n const current = this.map.peek();\n\n if (current.get(key) !== value) {\n return;\n }\n\n const cleanup = this.cleanupFunctions.get(value);\n cleanup?.();\n this.cleanupFunctions.delete(value);\n\n const updatedMap = new Map(current);\n updatedMap.delete(key);\n\n this.map.value = updatedMap;\n };\n\n /**\n * Destroys all entries in the registry and clears the registry.\n */\n public destroy() {\n for (const entry of this) {\n const cleanup = this.cleanupFunctions.get(entry);\n cleanup?.();\n entry.destroy();\n }\n\n this.map.value = new Map();\n }\n}\n","import {derived, reactive} from '@dnd-kit/state';\n\nimport {Entity} from '../entity/index.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport {Modifier} from '../../modifiers/index.ts';\nimport type {Modifiers} from '../../modifiers/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport {descriptor} from '../../plugins/index.ts';\nimport type {Sensors} from '../../sensors/sensor.ts';\n\nexport interface Input<\n T extends Data = Data,\n U extends Draggable<T> = Draggable<T>,\n> extends EntityInput<T, U> {\n type?: Type;\n modifiers?: Modifiers;\n sensors?: Sensors;\n}\n\nexport class Draggable<T extends Data = Data> extends Entity<T> {\n constructor(\n {modifiers, type, sensors, ...input}: Input<T>,\n public manager: DragDropManager\n ) {\n super(input, manager);\n\n this.type = type;\n this.sensors = sensors;\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 sensors: Sensors | undefined;\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.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport {\n CollisionPriority,\n type CollisionDetector,\n} from '../../collision/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport {Draggable} from '../draggable/draggable.ts';\n\nexport interface Input<\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.ts';\nimport type {Draggable} from '../entities/index.ts';\nimport {\n Plugin,\n type PluginConstructor,\n type PluginDescriptor,\n type PluginOptions,\n} from '../plugins/index.ts';\n\nexport type SensorOptions = PluginOptions;\n\nexport abstract class Sensor<\n T extends DragDropManager<any, any> = DragDropManager,\n U extends SensorOptions = SensorOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n /**\n * Bind the sensor to a draggable source, and optionally pass\n * in sensor options to override the default sensor options\n * for this draggable source only.\n */\n public abstract bind(source: Draggable, options?: U): CleanupFunction;\n}\n\nexport type SensorConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Sensor<T>>;\n\nexport type SensorDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Sensor<T>, SensorConstructor<T>>;\n\nexport type Sensors<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (SensorConstructor<T> | SensorDescriptor<T>)[];\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport {\n Plugin,\n type PluginOptions,\n type PluginConstructor,\n type PluginDescriptor,\n} from '../plugins/index.ts';\nimport type {DragDropManager} from '../manager/index.ts';\n\nexport type ModifierOptions = PluginOptions;\n\nexport class Modifier<\n T extends DragDropManager<any, any> = DragDropManager,\n U extends ModifierOptions = ModifierOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n public apply(operation: T['dragOperation']): Coordinates {\n return operation.transform;\n }\n}\n\nexport type ModifierConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Modifier<T, any>>;\n\nexport type ModifierDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Modifier<T, any>, ModifierConstructor<T>>;\n\nexport type Modifiers<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (ModifierConstructor<T> | ModifierDescriptor<T>)[];\n","import type {CleanupFunction} from '@dnd-kit/state';\n\nimport {\n Draggable,\n Droppable,\n Entity,\n EntityRegistry,\n} from '../entities/index.ts';\nimport {\n PluginRegistry,\n Plugin,\n type PluginConstructor,\n PluginOptions,\n} from '../plugins/index.ts';\nimport {\n Sensor,\n SensorOptions,\n type SensorConstructor,\n} from '../sensors/index.ts';\nimport {Modifier, type ModifierConstructor} from '../modifiers/index.ts';\nimport type {DragDropManager} from './manager.ts';\n\nexport class DragDropRegistry<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> {\n constructor(manager: V) {\n this.plugins = new PluginRegistry<V, PluginConstructor<V>>(manager);\n this.sensors = new PluginRegistry<V, SensorConstructor<V>>(manager);\n this.modifiers = new PluginRegistry<V, ModifierConstructor<V>>(manager);\n }\n\n public draggables = new EntityRegistry<T>();\n public droppables = new EntityRegistry<U>();\n public plugins: PluginRegistry<V, PluginConstructor<V>>;\n public sensors: PluginRegistry<V, SensorConstructor<V>>;\n public modifiers: PluginRegistry<V, ModifierConstructor<V>>;\n\n public register(input: Entity): () => void;\n public register(input: Draggable): () => void;\n public register(input: Droppable): () => void;\n public register(input: SensorConstructor, options?: SensorOptions): Sensor;\n public register(input: ModifierConstructor): Modifier;\n public register(input: PluginConstructor, options?: PluginOptions): Plugin;\n public register(input: any, options?: Record<string, any>) {\n if (input instanceof Draggable) {\n return this.draggables.register(input.id, input as T);\n }\n\n if (input instanceof Droppable) {\n return this.droppables.register(input.id, input as U);\n }\n\n if (input.prototype instanceof Modifier) {\n return this.modifiers.register(input, options);\n }\n\n if (input.prototype instanceof Sensor) {\n return this.sensors.register(input, options);\n }\n\n if (input.prototype instanceof Plugin) {\n return this.plugins.register(input, options);\n }\n\n throw new Error('Invalid instance type');\n }\n\n public unregister(input: Entity): CleanupFunction;\n public unregister(input: Draggable): CleanupFunction;\n public unregister(input: Droppable): CleanupFunction;\n public unregister(input: SensorConstructor): CleanupFunction;\n public unregister(input: ModifierConstructor): CleanupFunction;\n public unregister(input: PluginConstructor): CleanupFunction;\n public unregister(input: any) {\n if (input instanceof Entity) {\n if (input instanceof Draggable) {\n return this.draggables.unregister(input.id, input as T);\n }\n\n if (input instanceof Droppable) {\n return this.droppables.unregister(input.id, input as U);\n }\n\n // no-op\n return () => {};\n }\n\n if (input.prototype instanceof Modifier) {\n return this.modifiers.unregister(input);\n }\n\n if (input.prototype instanceof Sensor) {\n return this.sensors.unregister(input);\n }\n\n if (input.prototype instanceof Plugin) {\n return this.plugins.unregister(input);\n }\n\n throw new Error('Invalid instance type');\n }\n\n destroy() {\n this.draggables.destroy();\n this.droppables.destroy();\n this.plugins.destroy();\n this.sensors.destroy();\n this.modifiers.destroy();\n }\n}\n","import {Position, type Shape} from '@dnd-kit/geometry';\nimport type {Coordinates} from '@dnd-kit/geometry';\nimport {batch, computed, signal} from '@dnd-kit/state';\n\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.ts';\n\nimport type {DragDropManager} from './manager.ts';\nimport {defaultPreventable} from './events.ts';\n\nexport enum Status {\n Idle = 'idle',\n Initializing = 'initializing',\n Dragging = 'dragging',\n Dropped = 'dropped',\n}\n\nexport type Serializable = {\n [key: string]: string | number | null | Serializable | Serializable[];\n};\n\nexport interface DragOperation<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n activatorEvent: Event | null;\n canceled: boolean;\n position: Position;\n transform: Coordinates;\n status: {\n current: Status;\n initialized: boolean;\n initializing: boolean;\n dragging: boolean;\n dragended: boolean;\n dropped: boolean;\n idle: boolean;\n };\n get shape(): {\n initial: Shape;\n current: Shape;\n } | null;\n set shape(value: Shape | null);\n source: T | null;\n target: U | null;\n data?: Serializable;\n}\n\nexport type DragActions<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = ReturnType<typeof DragOperationManager<T, U, V>>['actions'];\n\nexport function DragOperationManager<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n>(manager: V) {\n const {\n registry: {draggables, droppables},\n monitor,\n } = manager;\n const status = signal<Status>(Status.Idle);\n const shape = {\n initial: signal<Shape | null>(null),\n current: signal<Shape | null>(null),\n };\n const canceled = signal<boolean>(false);\n const position = new Position({x: 0, y: 0});\n const activatorEvent = signal<Event | null>(null);\n const sourceIdentifier = signal<UniqueIdentifier | null>(null);\n const targetIdentifier = signal<UniqueIdentifier | null>(null);\n const dragging = computed(() => status.value === Status.Dragging);\n const initialized = computed(() => status.value !== Status.Idle);\n const initializing = computed(() => status.value === Status.Initializing);\n const idle = computed(() => status.value === Status.Idle);\n const dropped = computed(() => status.value === Status.Dropped);\n const dragended = signal<boolean>(true);\n let previousSource: T | undefined;\n const source = computed<T | null>(() => {\n const identifier = sourceIdentifier.value;\n\n if (identifier == null) return null;\n\n const value = draggables.get(identifier);\n\n if (value) {\n // It's possible for the source to unmount during the drag operation\n previousSource = value;\n }\n\n return value ?? previousSource ?? null;\n });\n const target = computed<U | null>(() => {\n const identifier = targetIdentifier.value;\n return identifier != null ? droppables.get(identifier) ?? null : null;\n });\n\n const transform = computed(() => {\n const {x, y} = position.delta;\n const modifiers = source?.value?.modifiers ?? manager.modifiers;\n\n let transform = {x, y};\n const initialShape = shape.initial.peek();\n const currentShape = shape.current.peek();\n const operation: Omit<DragOperation<T, U>, 'transform'> = {\n activatorEvent: activatorEvent.peek(),\n canceled: canceled.peek(),\n source: source.peek(),\n target: target.peek(),\n status: {\n current: status.peek(),\n idle: idle.peek(),\n initializing: initializing.peek(),\n initialized: initialized.peek(),\n dragging: dragging.peek(),\n dragended: dragended.peek(),\n dropped: dropped.peek(),\n },\n shape:\n initialShape && currentShape\n ? {initial: initialShape, current: currentShape}\n : null,\n position,\n };\n\n for (const modifier of modifiers) {\n transform = modifier.apply({...operation, transform});\n }\n\n return transform;\n });\n\n const operation: DragOperation<T, U> = {\n get activatorEvent() {\n return activatorEvent.value;\n },\n get canceled() {\n return canceled.value;\n },\n get source() {\n return source.value;\n },\n get target() {\n return target.value;\n },\n status: {\n get current() {\n return status.value;\n },\n get idle() {\n return idle.value;\n },\n get initializing() {\n return initializing.value;\n },\n get initialized() {\n return initialized.value;\n },\n get dragging() {\n return dragging.value;\n },\n get dragended() {\n return dragended.value;\n },\n get dropped() {\n return dropped.value;\n },\n },\n get shape(): DragOperation['shape'] {\n const initial = shape.initial.value;\n const current = shape.current.value;\n\n return initial && current ? {initial, current} : null;\n },\n set shape(value: Shape | null) {\n if (value && shape.current.peek()?.equals(value)) {\n return;\n }\n\n const initial = shape.initial.peek();\n\n if (!initial) {\n shape.initial.value = value;\n }\n\n shape.current.value = value;\n },\n get transform() {\n return transform.value;\n },\n position,\n };\n\n const reset = () => {\n batch(() => {\n status.value = Status.Idle;\n sourceIdentifier.value = null;\n targetIdentifier.value = null;\n shape.current.value = null;\n shape.initial.value = null;\n position.reset({x: 0, y: 0});\n });\n };\n\n return {\n operation,\n actions: {\n setDragSource(identifier: UniqueIdentifier) {\n sourceIdentifier.value = identifier;\n },\n setDropTarget(\n identifier: UniqueIdentifier | null | undefined\n ): Promise<void> {\n const id = identifier ?? null;\n\n if (targetIdentifier.peek() === id) {\n return Promise.resolve();\n }\n\n targetIdentifier.value = id;\n\n if (status.peek() === Status.Dragging) {\n monitor.dispatch(\n 'dragover',\n defaultPreventable({\n operation: snapshot(operation),\n })\n );\n }\n\n return manager.renderer.rendering;\n },\n start({event, coordinates}: {event: Event; coordinates: Coordinates}) {\n batch(() => {\n dragended.value = false;\n canceled.value = false;\n activatorEvent.value = event;\n position.reset(coordinates);\n });\n\n const beforeStartEvent = defaultPreventable({\n operation: snapshot(operation),\n });\n\n monitor.dispatch('beforedragstart', beforeStartEvent);\n\n manager.renderer.rendering.then(() => {\n if (beforeStartEvent.defaultPrevented) {\n reset();\n return;\n }\n\n status.value = Status.Initializing;\n\n requestAnimationFrame(() => {\n status.value = Status.Dragging;\n\n monitor.dispatch('dragstart', {\n operation: snapshot(operation),\n cancelable: false,\n });\n });\n });\n },\n move({\n by,\n to,\n cancelable = true,\n }:\n | {by: Coordinates; to?: undefined; cancelable?: boolean}\n | {by?: undefined; to: Coordinates; cancelable?: boolean}) {\n if (!dragging.peek()) {\n return;\n }\n\n const event = defaultPreventable(\n {\n operation: snapshot(operation),\n by,\n to,\n },\n cancelable\n );\n\n monitor.dispatch('dragmove', event);\n\n queueMicrotask(() => {\n if (event.defaultPrevented) {\n return;\n }\n\n const coordinates = to ?? {\n x: position.current.x + by.x,\n y: position.current.y + by.y,\n };\n\n position.update(coordinates);\n });\n },\n stop({canceled: eventCanceled = false}: {canceled?: boolean} = {}) {\n let promise: Promise<void> | undefined;\n const suspend = () => {\n const output = {\n resume: () => {},\n abort: () => {},\n };\n\n promise = new Promise<void>((resolve, reject) => {\n output.resume = resolve;\n output.abort = reject;\n });\n\n return output;\n };\n const end = () => {\n /* Wait for the renderer to finish rendering before finalizing the drag operation */\n manager.renderer.rendering.then(() => {\n status.value = Status.Dropped;\n manager.renderer.rendering.then(reset);\n });\n };\n\n batch(() => {\n dragended.value = true;\n canceled.value = eventCanceled;\n });\n\n monitor.dispatch('dragend', {\n operation: snapshot(operation),\n canceled: eventCanceled,\n suspend,\n });\n\n if (promise) {\n promise.then(end).catch(reset);\n } else {\n end();\n }\n },\n },\n };\n}\n\nfunction snapshot<T extends Record<string, any>>(obj: T): T {\n return {\n ...obj,\n };\n}\n","export interface Renderer {\n get rendering(): Promise<void>;\n}\n\nexport const defaultRenderer: Renderer = {\n get rendering() {\n return Promise.resolve();\n },\n};\n","import type {Draggable, Droppable} from '../entities/index.ts';\nimport {CollisionObserver, CollisionNotifier} from '../collision/index.ts';\nimport type {Plugins, Plugin} from '../plugins/index.ts';\nimport type {Sensor, Sensors} from '../sensors/index.ts';\nimport type {Modifier, Modifiers} from '../modifiers/index.ts';\n\nimport {DragDropRegistry} from './registry.ts';\nimport {\n DragOperationManager,\n type DragOperation,\n type DragActions,\n} from './dragOperation.ts';\nimport {DragDropMonitor} from './events.ts';\nimport {defaultRenderer, type Renderer} from './renderer.ts';\n\nexport 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
|
@@ -47,6 +47,10 @@ declare class Entity<T extends Data = Data> {
|
|
|
47
47
|
* A boolean indicating whether the entity is disabled.
|
|
48
48
|
*/
|
|
49
49
|
disabled: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* An array of effects that are applied to the entity.
|
|
52
|
+
*/
|
|
53
|
+
effects: Effect[];
|
|
50
54
|
/**
|
|
51
55
|
* A method that cleans up the entity when it is no longer needed.
|
|
52
56
|
* @returns void
|
|
@@ -61,6 +65,7 @@ declare class Entity<T extends Data = Data> {
|
|
|
61
65
|
*/
|
|
62
66
|
declare class EntityRegistry<T extends Entity> {
|
|
63
67
|
private map;
|
|
68
|
+
private cleanupFunctions;
|
|
64
69
|
/**
|
|
65
70
|
* Iterator for the EntityRegistry class.
|
|
66
71
|
* @returns An iterator for the values in the map.
|
|
@@ -183,13 +188,31 @@ type ModifierConstructor<T extends DragDropManager<any, any> = DragDropManager<a
|
|
|
183
188
|
type ModifierDescriptor<T extends DragDropManager<any, any> = DragDropManager<any, any>> = PluginDescriptor<T, Modifier<T, any>, ModifierConstructor<T>>;
|
|
184
189
|
type Modifiers<T extends DragDropManager<any, any> = DragDropManager<any, any>> = (ModifierConstructor<T> | ModifierDescriptor<T>)[];
|
|
185
190
|
|
|
191
|
+
type SensorOptions = PluginOptions;
|
|
192
|
+
declare abstract class Sensor<T extends DragDropManager<any, any> = DragDropManager, U extends SensorOptions = SensorOptions> extends Plugin<T, U> {
|
|
193
|
+
manager: T;
|
|
194
|
+
options?: U | undefined;
|
|
195
|
+
constructor(manager: T, options?: U | undefined);
|
|
196
|
+
/**
|
|
197
|
+
* Bind the sensor to a draggable source, and optionally pass
|
|
198
|
+
* in sensor options to override the default sensor options
|
|
199
|
+
* for this draggable source only.
|
|
200
|
+
*/
|
|
201
|
+
abstract bind(source: Draggable, options?: U): CleanupFunction;
|
|
202
|
+
}
|
|
203
|
+
type SensorConstructor<T extends DragDropManager<any, any> = DragDropManager<any, any>> = PluginConstructor<T, Sensor<T>>;
|
|
204
|
+
type SensorDescriptor<T extends DragDropManager<any, any> = DragDropManager<any, any>> = PluginDescriptor<T, Sensor<T>, SensorConstructor<T>>;
|
|
205
|
+
type Sensors<T extends DragDropManager<any, any> = DragDropManager<any, any>> = (SensorConstructor<T> | SensorDescriptor<T>)[];
|
|
206
|
+
|
|
186
207
|
interface Input$1<T extends Data = Data, U extends Draggable<T> = Draggable<T>> extends Input$2<T, U> {
|
|
187
208
|
type?: Type;
|
|
188
209
|
modifiers?: Modifiers;
|
|
210
|
+
sensors?: Sensors;
|
|
189
211
|
}
|
|
190
212
|
declare class Draggable<T extends Data = Data> extends Entity<T> {
|
|
191
213
|
manager: DragDropManager;
|
|
192
|
-
constructor({ modifiers, type, ...input }: Input$1<T>, manager: DragDropManager);
|
|
214
|
+
constructor({ modifiers, type, sensors, ...input }: Input$1<T>, manager: DragDropManager);
|
|
215
|
+
sensors: Sensors | undefined;
|
|
193
216
|
modifiers: Modifier[] | undefined;
|
|
194
217
|
type: Type | undefined;
|
|
195
218
|
/**
|
|
@@ -263,22 +286,6 @@ declare class Droppable<T extends Data = Data> extends Entity<T> {
|
|
|
263
286
|
refreshShape(): void;
|
|
264
287
|
}
|
|
265
288
|
|
|
266
|
-
type SensorOptions = PluginOptions;
|
|
267
|
-
declare abstract class Sensor<T extends DragDropManager<any, any> = DragDropManager, U extends SensorOptions = SensorOptions> extends Plugin<T, U> {
|
|
268
|
-
manager: T;
|
|
269
|
-
options?: U | undefined;
|
|
270
|
-
constructor(manager: T, options?: U | undefined);
|
|
271
|
-
/**
|
|
272
|
-
* Bind the sensor to a draggable source, and optionally pass
|
|
273
|
-
* in sensor options to override the default sensor options
|
|
274
|
-
* for this draggable source only.
|
|
275
|
-
*/
|
|
276
|
-
abstract bind(source: Draggable, options?: U): CleanupFunction;
|
|
277
|
-
}
|
|
278
|
-
type SensorConstructor<T extends DragDropManager<any, any> = DragDropManager<any, any>> = PluginConstructor<T, Sensor<T>>;
|
|
279
|
-
type SensorDescriptor<T extends DragDropManager<any, any> = DragDropManager<any, any>> = PluginDescriptor<T, Sensor<T>, SensorConstructor<T>>;
|
|
280
|
-
type Sensors<T extends DragDropManager<any, any> = DragDropManager<any, any>> = (SensorConstructor<T> | SensorDescriptor<T>)[];
|
|
281
|
-
|
|
282
289
|
declare class DragDropRegistry<T extends Draggable, U extends Droppable, V extends DragDropManager<T, U>> {
|
|
283
290
|
constructor(manager: V);
|
|
284
291
|
draggables: EntityRegistry<T>;
|
|
@@ -286,9 +293,9 @@ declare class DragDropRegistry<T extends Draggable, U extends Droppable, V exten
|
|
|
286
293
|
plugins: PluginRegistry<V, PluginConstructor<V>>;
|
|
287
294
|
sensors: PluginRegistry<V, SensorConstructor<V>>;
|
|
288
295
|
modifiers: PluginRegistry<V, ModifierConstructor<V>>;
|
|
289
|
-
register(input: Entity):
|
|
290
|
-
register(input: Draggable):
|
|
291
|
-
register(input: Droppable):
|
|
296
|
+
register(input: Entity): () => void;
|
|
297
|
+
register(input: Draggable): () => void;
|
|
298
|
+
register(input: Droppable): () => void;
|
|
292
299
|
register(input: SensorConstructor, options?: SensorOptions): Sensor;
|
|
293
300
|
register(input: ModifierConstructor): Modifier;
|
|
294
301
|
register(input: PluginConstructor, options?: PluginOptions): Plugin;
|
package/index.js
CHANGED
|
@@ -341,34 +341,36 @@ var Entity = class {
|
|
|
341
341
|
this.id = id;
|
|
342
342
|
this.data = data;
|
|
343
343
|
this.disabled = disabled;
|
|
344
|
-
|
|
345
|
-
|
|
344
|
+
this.effects = [
|
|
345
|
+
() => {
|
|
346
|
+
if (id === previousId) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
346
349
|
manager.registry.register(this);
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
);
|
|
358
|
-
this.destroy = () => {
|
|
359
|
-
manager.registry.unregister(this);
|
|
360
|
-
cleanupEffects();
|
|
361
|
-
};
|
|
362
|
-
});
|
|
350
|
+
return () => manager.registry.unregister(this);
|
|
351
|
+
},
|
|
352
|
+
...getEffects()
|
|
353
|
+
];
|
|
354
|
+
this.destroy = this.destroy.bind(this);
|
|
355
|
+
if (options?.register !== false) {
|
|
356
|
+
queueMicrotask(() => {
|
|
357
|
+
manager.registry.register(this);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
363
360
|
}
|
|
364
361
|
id;
|
|
365
362
|
data;
|
|
366
363
|
disabled;
|
|
364
|
+
/**
|
|
365
|
+
* An array of effects that are applied to the entity.
|
|
366
|
+
*/
|
|
367
|
+
effects;
|
|
367
368
|
/**
|
|
368
369
|
* A method that cleans up the entity when it is no longer needed.
|
|
369
370
|
* @returns void
|
|
370
371
|
*/
|
|
371
372
|
destroy() {
|
|
373
|
+
this.manager.registry.unregister(this);
|
|
372
374
|
}
|
|
373
375
|
};
|
|
374
376
|
__decorateClass([
|
|
@@ -382,6 +384,7 @@ __decorateClass([
|
|
|
382
384
|
], Entity.prototype, "disabled", 2);
|
|
383
385
|
var EntityRegistry = class {
|
|
384
386
|
map = signal(/* @__PURE__ */ new Map());
|
|
387
|
+
cleanupFunctions = /* @__PURE__ */ new WeakMap();
|
|
385
388
|
/**
|
|
386
389
|
* Iterator for the EntityRegistry class.
|
|
387
390
|
* @returns An iterator for the values in the map.
|
|
@@ -422,6 +425,8 @@ var EntityRegistry = class {
|
|
|
422
425
|
const updatedMap = new Map(current);
|
|
423
426
|
updatedMap.set(key, value);
|
|
424
427
|
this.map.value = updatedMap;
|
|
428
|
+
const cleanup = effects(...value.effects);
|
|
429
|
+
this.cleanupFunctions.set(value, cleanup);
|
|
425
430
|
return () => this.unregister(key, value);
|
|
426
431
|
};
|
|
427
432
|
/**
|
|
@@ -434,6 +439,9 @@ var EntityRegistry = class {
|
|
|
434
439
|
if (current.get(key) !== value) {
|
|
435
440
|
return;
|
|
436
441
|
}
|
|
442
|
+
const cleanup = this.cleanupFunctions.get(value);
|
|
443
|
+
cleanup?.();
|
|
444
|
+
this.cleanupFunctions.delete(value);
|
|
437
445
|
const updatedMap = new Map(current);
|
|
438
446
|
updatedMap.delete(key);
|
|
439
447
|
this.map.value = updatedMap;
|
|
@@ -443,16 +451,19 @@ var EntityRegistry = class {
|
|
|
443
451
|
*/
|
|
444
452
|
destroy() {
|
|
445
453
|
for (const entry of this) {
|
|
454
|
+
const cleanup = this.cleanupFunctions.get(entry);
|
|
455
|
+
cleanup?.();
|
|
446
456
|
entry.destroy();
|
|
447
457
|
}
|
|
448
458
|
this.map.value = /* @__PURE__ */ new Map();
|
|
449
459
|
}
|
|
450
460
|
};
|
|
451
461
|
var Draggable = class extends Entity {
|
|
452
|
-
constructor({ modifiers, type, ...input }, manager) {
|
|
462
|
+
constructor({ modifiers, type, sensors, ...input }, manager) {
|
|
453
463
|
super(input, manager);
|
|
454
464
|
this.manager = manager;
|
|
455
465
|
this.type = type;
|
|
466
|
+
this.sensors = sensors;
|
|
456
467
|
if (modifiers?.length) {
|
|
457
468
|
this.modifiers = modifiers.map((modifier) => {
|
|
458
469
|
const { plugin, options } = descriptor(modifier);
|
|
@@ -460,6 +471,7 @@ var Draggable = class extends Entity {
|
|
|
460
471
|
});
|
|
461
472
|
}
|
|
462
473
|
}
|
|
474
|
+
sensors;
|
|
463
475
|
modifiers;
|
|
464
476
|
type;
|
|
465
477
|
get isDragSource() {
|
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,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;AAA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AAAA,EAEO,UAAU;AACf,SAAK,SAAS,QAAQ;AACtB,SAAK,kBAAkB,QAAQ;AAAA,EACjC;AACF","sourcesContent":["import {\n batch,\n computed,\n deepEqual,\n signal,\n untracked,\n type ReadonlySignal,\n effect,\n} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport {Plugin} from '../plugins/index.ts';\nimport type {Collision, CollisionDetector, Collisions} from './types.ts';\nimport {sortCollisions} from './utilities.ts';\n\nconst DEFAULT_VALUE: Collisions = [];\n\nexport class CollisionObserver<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n V extends DragDropManager<T, U> = DragDropManager<T, U>,\n> extends Plugin<V> {\n constructor(manager: V) {\n super(manager);\n\n this.computeCollisions = this.computeCollisions.bind(this);\n this.#collisions = computed(this.computeCollisions, deepEqual);\n\n this.destroy = effect(() => {\n const {dragOperation} = this.manager;\n\n if (dragOperation.status.initialized) {\n this.forceUpdate();\n }\n });\n }\n\n forceUpdateCount = signal(0);\n\n public forceUpdate(refresh = true) {\n untracked(() => {\n const {source} = this.manager.dragOperation;\n\n batch(() => {\n if (refresh) {\n for (const droppable of this.manager.registry.droppables) {\n if (source && !droppable.accepts(source)) {\n continue;\n }\n\n droppable.refreshShape();\n }\n }\n\n this.forceUpdateCount.value++;\n });\n });\n }\n\n public computeCollisions(\n entries?: Droppable[],\n collisionDetector?: CollisionDetector\n ) {\n const {registry, dragOperation} = this.manager;\n const {source, shape, status} = dragOperation;\n\n if (!status.initialized || !shape) {\n return DEFAULT_VALUE;\n }\n\n const collisions: Collision[] = [];\n\n this.forceUpdateCount.value;\n\n for (const entry of entries ?? registry.droppables) {\n if (entry.disabled) {\n continue;\n }\n\n if (source && !entry.accepts(source)) {\n continue;\n }\n\n const detectCollision = collisionDetector ?? entry.collisionDetector;\n\n if (!detectCollision) {\n continue;\n }\n\n const collision = untracked(() =>\n detectCollision({\n droppable: entry,\n dragOperation,\n })\n );\n\n if (collision) {\n if (entry.collisionPriority != null) {\n collision.priority = entry.collisionPriority;\n }\n\n collisions.push(collision);\n }\n }\n\n collisions.sort(sortCollisions);\n\n return collisions;\n }\n\n public get collisions() {\n return this.#collisions.value;\n }\n\n #collisions: ReadonlySignal<Collisions>;\n}\n","import {reactive, untracked} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {PluginOptions} from './types.ts';\nimport {configure} from './utilities.ts';\n\n/**\n * An abstract plugin class that can be extended to implement custom\n * functionality that augments the `DragDropManager`'s core capabilities.\n */\nexport abstract class Plugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> {\n constructor(\n public manager: T,\n public options?: U\n ) {}\n\n /**\n * Whether the plugin instance is disabled.\n * Triggers effects when accessed.\n */\n @reactive\n public disabled: boolean = false;\n\n /**\n * Enable a disabled plugin instance.\n * Triggers effects.\n */\n public enable() {\n this.disabled = false;\n }\n\n /**\n * Disable an enabled plugin instance.\n * Triggers effects.\n */\n public disable() {\n this.disabled = true;\n }\n\n /**\n * Whether the plugin instance is disabled.\n * Does not trigger effects when accessed.\n */\n public isDisabled() {\n return untracked(() => {\n return this.disabled;\n });\n }\n\n /**\n * Configure a plugin instance with new options.\n */\n public configure(options?: U) {\n this.options = options;\n }\n\n /**\n * Destroy a plugin instance.\n */\n public destroy() {\n /*\n * Each plugin is responsible for implementing its own\n * destroy method to clean up effects and listeners\n */\n }\n\n /**\n * Configure a plugin constructor with options.\n * This method is used to configure the options that the\n * plugin constructor will use to create plugin instances.\n */\n static configure(options: PluginOptions) {\n return configure(this as any, options);\n }\n}\n\nexport class CorePlugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> extends Plugin<T, U> {}\n","import type {\n PluginConstructor,\n PluginOptions,\n PluginDescriptor,\n InferPluginOptions,\n} from './types.ts';\n\nexport function configure<\n T extends PluginConstructor<any, any, any>,\n V extends PluginOptions = InferPluginOptions<T>,\n>(plugin: T, options: V): PluginDescriptor<any, any, T> {\n return {\n plugin,\n options,\n };\n}\n\nexport function configurator<T extends PluginConstructor<any, any, any>>(\n plugin: T\n) {\n return (options: InferPluginOptions<T>): PluginDescriptor<any, any, T> => {\n return configure(plugin, options);\n };\n}\n\nexport function descriptor<T extends PluginConstructor<any, any, any>>(\n plugin: T | PluginDescriptor<any, any, T>\n): PluginDescriptor<any, any, T> {\n if (typeof plugin === 'function') {\n return {\n plugin,\n options: undefined,\n };\n }\n\n return plugin;\n}\n","import {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin, type Plugin} from './plugin.ts';\nimport type {InferPluginOptions, PluginConstructor, Plugins} from './types.ts';\nimport {descriptor} from './utilities.ts';\n\nexport class PluginRegistry<\n T extends DragDropManager<any, any>,\n W extends PluginConstructor<T> = PluginConstructor<T>,\n U extends Plugin<T> = InstanceType<W>,\n> {\n private instances: Map<W, U> = new Map();\n\n constructor(private manager: T) {}\n\n public get values(): U[] {\n return Array.from(this.instances.values());\n }\n\n #previousValues: PluginConstructor<T>[] = [];\n\n public set values(entries: Plugins<T>) {\n const descriptors = entries.map(descriptor);\n const constructors = descriptors.map(({plugin}) => plugin);\n\n for (const plugin of this.#previousValues) {\n if (!constructors.includes(plugin)) {\n if (plugin.prototype instanceof CorePlugin) {\n continue;\n }\n\n this.unregister(plugin as W);\n }\n }\n\n for (const {plugin, options} of descriptors) {\n this.register(plugin as W, options as InferPluginOptions<W>);\n }\n\n this.#previousValues = constructors;\n }\n\n public get<X extends W>(plugin: X): InstanceType<X> | undefined {\n const instance = this.instances.get(plugin);\n\n return instance as any;\n }\n\n public register<X extends W>(\n plugin: X,\n options?: InferPluginOptions<X>\n ): InstanceType<X> {\n const existingInstance = this.instances.get(plugin);\n\n if (existingInstance) {\n return existingInstance as InstanceType<X>;\n }\n\n const instance = new plugin(this.manager, options) as U;\n\n this.instances.set(plugin, instance);\n\n return instance as InstanceType<X>;\n }\n\n public unregister<X extends W>(plugin: X) {\n const instance = this.instances.get(plugin);\n\n if (instance) {\n instance.destroy();\n this.instances.delete(plugin);\n }\n }\n\n public destroy() {\n for (const plugin of this.instances.values()) {\n plugin.destroy();\n }\n\n this.instances.clear();\n }\n}\n","import {Collision} from './types.ts';\n\n/**\n * Sort collisions from greatest to smallest priority\n * Collisions of equal priority are sorted from greatest to smallest value\n */\nexport function sortCollisions(a: Collision, b: Collision) {\n if (a.priority === b.priority) {\n return b.value - a.value;\n }\n\n return b.priority - a.priority;\n}\n","import {effect, untracked} from '@dnd-kit/state';\n\nimport {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin} from '../plugins/index.ts';\nimport {defaultPreventable} from '../manager/events.ts';\n\nexport class CollisionNotifier extends CorePlugin {\n constructor(manager: DragDropManager) {\n super(manager);\n\n this.destroy = effect(() => {\n const {collisionObserver, monitor} = manager;\n const {collisions} = collisionObserver;\n\n if (collisionObserver.isDisabled()) {\n return;\n }\n\n const event = defaultPreventable({\n collisions,\n });\n\n monitor.dispatch('collision', event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n const [firstCollision] = collisions;\n\n untracked(() => {\n if (firstCollision?.id !== manager.dragOperation.target?.id) {\n collisionObserver.disable();\n\n manager.actions.setDropTarget(firstCollision?.id).then(() => {\n collisionObserver.enable();\n });\n }\n });\n });\n }\n}\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport type {Collisions} from '../collision/index.ts';\nimport type {DragDropManager} from './manager.ts';\nimport type {DragOperation} from './dragOperation.ts';\n\nexport type Events = Record<string, (...args: any[]) => void>;\n\nexport type Preventable<T> = T & {\n cancelable: boolean;\n defaultPrevented: boolean;\n preventDefault(): void;\n};\n\nclass Monitor<T extends Events> {\n private registry = new Map<keyof T, Set<T[keyof T]>>();\n\n public addEventListener<U extends keyof T>(name: U, handler: T[U]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.add(handler);\n registry.set(name, listeners);\n\n return () => this.removeEventListener(name, handler);\n }\n\n public removeEventListener(name: keyof T, handler: T[keyof T]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.delete(handler);\n registry.set(name, listeners);\n }\n\n protected dispatch<U extends keyof T>(name: U, ...args: any[]) {\n const {registry} = this;\n const listeners = registry.get(name);\n\n if (!listeners) {\n return;\n }\n\n for (const listener of listeners) {\n listener(...args);\n }\n }\n}\n\nexport type DragDropEvents<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = {\n collision(\n event: Preventable<{\n collisions: Collisions;\n }>,\n manager: V\n ): void;\n beforedragstart(\n event: Preventable<{operation: DragOperation<T, U>}>,\n manager: V\n ): void;\n dragstart(\n event: {\n cancelable: false;\n operation: DragOperation<T, U>;\n },\n manager: V\n ): void;\n dragmove(\n event: Preventable<{\n operation: DragOperation<T, U>;\n to?: Coordinates;\n by?: Coordinates;\n }>,\n manager: V\n ): void;\n dragover(\n event: Preventable<{\n operation: DragOperation<T, U>;\n }>,\n manager: V\n ): void;\n dragend(\n event: {\n operation: DragOperation<T, U>;\n canceled: boolean;\n suspend(): {resume(): void; abort(): void};\n },\n manager: V\n ): void;\n};\n\nexport class DragDropMonitor<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> extends Monitor<DragDropEvents<T, U, V>> {\n constructor(private manager: V) {\n super();\n }\n\n public dispatch<Key extends keyof DragDropEvents<T, U, V>>(\n type: Key,\n event: Parameters<DragDropEvents<T, U, V>[Key]>[0]\n ) {\n const args = [event, this.manager] as any;\n\n super.dispatch(type, ...args);\n }\n}\n\nexport function defaultPreventable<T>(\n event: T,\n cancelable = true\n): Preventable<T> {\n let defaultPrevented = false;\n\n return {\n ...event,\n cancelable,\n get defaultPrevented() {\n return defaultPrevented;\n },\n preventDefault() {\n if (!cancelable) {\n return;\n }\n\n defaultPrevented = true;\n },\n };\n}\n","import type {DragOperation} from '../manager/index.ts';\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.ts';\n\nexport enum CollisionPriority {\n Lowest,\n Low,\n Normal,\n High,\n Highest,\n}\n\nexport interface Collision {\n id: UniqueIdentifier;\n priority: CollisionPriority | number;\n value: number;\n}\n\nexport type Collisions = Collision[];\n\nexport interface CollisionDetectorInput<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n droppable: U;\n dragOperation: DragOperation<T, U>;\n}\n\nexport type CollisionDetector = <\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n>(\n input: CollisionDetectorInput<T, U>\n) => Collision | null;\n","import {effects, reactive, type Effect} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../../manager/index.ts';\nimport type {Data, UniqueIdentifier} from './types.ts';\n\ninterface Options {\n /**\n * A boolean indicating whether the entity should automatically be registered with the manager.\n * @defaultValue true\n */\n register?: boolean;\n}\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 options?: Options;\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 options,\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 if (options?.register !== false) {\n manager.registry.register(this);\n }\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.ts';\nimport type {UniqueIdentifier} from './types.ts';\n\n/**\n * Reactive class representing a registry for entities.\n * @template T - The type of entries that the registry manages,\n * for example, `Draggable` or `Droppable` entities.\n */\nexport class EntityRegistry<T extends Entity> {\n private map = signal<Map<UniqueIdentifier, T>>(new Map());\n\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.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport {Modifier} from '../../modifiers/index.ts';\nimport type {Modifiers} from '../../modifiers/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport {descriptor} from '../../plugins/index.ts';\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.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport {\n CollisionPriority,\n type CollisionDetector,\n} from '../../collision/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport {Draggable} from '../draggable/draggable.ts';\n\nexport interface Input<\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.ts';\nimport type {Draggable} from '../entities/index.ts';\nimport {\n Plugin,\n type PluginConstructor,\n type PluginDescriptor,\n type PluginOptions,\n} from '../plugins/index.ts';\n\nexport type SensorOptions = PluginOptions;\n\nexport abstract class Sensor<\n T extends DragDropManager<any, any> = DragDropManager,\n U extends SensorOptions = SensorOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n /**\n * Bind the sensor to a draggable source, and optionally pass\n * in sensor options to override the default sensor options\n * for this draggable source only.\n */\n public abstract bind(source: Draggable, options?: U): CleanupFunction;\n}\n\nexport type SensorConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Sensor<T>>;\n\nexport type SensorDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Sensor<T>, SensorConstructor<T>>;\n\nexport type Sensors<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (SensorConstructor<T> | SensorDescriptor<T>)[];\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport {\n Plugin,\n type PluginOptions,\n type PluginConstructor,\n type PluginDescriptor,\n} from '../plugins/index.ts';\nimport type {DragDropManager} from '../manager/index.ts';\n\nexport type ModifierOptions = PluginOptions;\n\nexport class Modifier<\n T extends DragDropManager<any, any> = DragDropManager,\n U extends ModifierOptions = ModifierOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n public apply(operation: T['dragOperation']): Coordinates {\n return operation.transform;\n }\n}\n\nexport type ModifierConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Modifier<T, any>>;\n\nexport type ModifierDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Modifier<T, any>, ModifierConstructor<T>>;\n\nexport type Modifiers<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (ModifierConstructor<T> | ModifierDescriptor<T>)[];\n","import type {CleanupFunction} from '@dnd-kit/state';\n\nimport {\n Draggable,\n Droppable,\n Entity,\n EntityRegistry,\n} from '../entities/index.ts';\nimport {\n PluginRegistry,\n Plugin,\n type PluginConstructor,\n PluginOptions,\n} from '../plugins/index.ts';\nimport {\n Sensor,\n SensorOptions,\n type SensorConstructor,\n} from '../sensors/index.ts';\nimport {Modifier, type ModifierConstructor} from '../modifiers/index.ts';\nimport type {DragDropManager} from './manager.ts';\n\nexport class DragDropRegistry<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> {\n constructor(manager: V) {\n this.plugins = new PluginRegistry<V, PluginConstructor<V>>(manager);\n this.sensors = new PluginRegistry<V, SensorConstructor<V>>(manager);\n this.modifiers = new PluginRegistry<V, ModifierConstructor<V>>(manager);\n }\n\n public draggables = new EntityRegistry<T>();\n public droppables = new EntityRegistry<U>();\n public plugins: PluginRegistry<V, PluginConstructor<V>>;\n public sensors: PluginRegistry<V, SensorConstructor<V>>;\n public modifiers: PluginRegistry<V, ModifierConstructor<V>>;\n\n public register(input: Entity): 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.ts';\n\nimport type {DragDropManager} from './manager.ts';\nimport {defaultPreventable} from './events.ts';\n\nexport enum Status {\n Idle = 'idle',\n Initializing = 'initializing',\n Dragging = 'dragging',\n Dropped = 'dropped',\n}\n\nexport type Serializable = {\n [key: string]: string | number | null | Serializable | Serializable[];\n};\n\nexport interface DragOperation<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n activatorEvent: Event | null;\n canceled: boolean;\n position: Position;\n transform: Coordinates;\n status: {\n current: Status;\n initialized: boolean;\n initializing: boolean;\n dragging: boolean;\n dragended: boolean;\n dropped: boolean;\n idle: boolean;\n };\n get shape(): {\n initial: Shape;\n current: Shape;\n } | null;\n set shape(value: Shape | null);\n source: T | null;\n target: U | null;\n data?: Serializable;\n}\n\nexport type DragActions<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = ReturnType<typeof DragOperationManager<T, U, V>>['actions'];\n\nexport function DragOperationManager<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n>(manager: V) {\n const {\n registry: {draggables, droppables},\n monitor,\n } = manager;\n const status = signal<Status>(Status.Idle);\n const shape = {\n initial: signal<Shape | null>(null),\n current: signal<Shape | null>(null),\n };\n const canceled = signal<boolean>(false);\n const position = new Position({x: 0, y: 0});\n const activatorEvent = signal<Event | null>(null);\n const sourceIdentifier = signal<UniqueIdentifier | null>(null);\n const targetIdentifier = signal<UniqueIdentifier | null>(null);\n const dragging = computed(() => status.value === Status.Dragging);\n const initialized = computed(() => status.value !== Status.Idle);\n const initializing = computed(() => status.value === Status.Initializing);\n const idle = computed(() => status.value === Status.Idle);\n const dropped = computed(() => status.value === Status.Dropped);\n const dragended = signal<boolean>(true);\n let previousSource: T | undefined;\n const source = computed<T | null>(() => {\n const identifier = sourceIdentifier.value;\n\n if (identifier == null) return null;\n\n const value = draggables.get(identifier);\n\n if (value) {\n // It's possible for the source to unmount during the drag operation\n previousSource = value;\n }\n\n return value ?? previousSource ?? null;\n });\n const target = computed<U | null>(() => {\n const identifier = targetIdentifier.value;\n return identifier != null ? droppables.get(identifier) ?? null : null;\n });\n\n const transform = computed(() => {\n const {x, y} = position.delta;\n const modifiers = source?.value?.modifiers ?? manager.modifiers;\n\n let transform = {x, y};\n const initialShape = shape.initial.peek();\n const currentShape = shape.current.peek();\n const operation: Omit<DragOperation<T, U>, 'transform'> = {\n activatorEvent: activatorEvent.peek(),\n canceled: canceled.peek(),\n source: source.peek(),\n target: target.peek(),\n status: {\n current: status.peek(),\n idle: idle.peek(),\n initializing: initializing.peek(),\n initialized: initialized.peek(),\n dragging: dragging.peek(),\n dragended: dragended.peek(),\n dropped: dropped.peek(),\n },\n shape:\n initialShape && currentShape\n ? {initial: initialShape, current: currentShape}\n : null,\n position,\n };\n\n for (const modifier of modifiers) {\n transform = modifier.apply({...operation, transform});\n }\n\n return transform;\n });\n\n const operation: DragOperation<T, U> = {\n get activatorEvent() {\n return activatorEvent.value;\n },\n get canceled() {\n return canceled.value;\n },\n get source() {\n return source.value;\n },\n get target() {\n return target.value;\n },\n status: {\n get current() {\n return status.value;\n },\n get idle() {\n return idle.value;\n },\n get initializing() {\n return initializing.value;\n },\n get initialized() {\n return initialized.value;\n },\n get dragging() {\n return dragging.value;\n },\n get dragended() {\n return dragended.value;\n },\n get dropped() {\n return dropped.value;\n },\n },\n get shape(): DragOperation['shape'] {\n const initial = shape.initial.value;\n const current = shape.current.value;\n\n return initial && current ? {initial, current} : null;\n },\n set shape(value: Shape | null) {\n if (value && shape.current.peek()?.equals(value)) {\n return;\n }\n\n const initial = shape.initial.peek();\n\n if (!initial) {\n shape.initial.value = value;\n }\n\n shape.current.value = value;\n },\n get transform() {\n return transform.value;\n },\n position,\n };\n\n const reset = () => {\n batch(() => {\n status.value = Status.Idle;\n sourceIdentifier.value = null;\n targetIdentifier.value = null;\n shape.current.value = null;\n shape.initial.value = null;\n position.reset({x: 0, y: 0});\n });\n };\n\n return {\n operation,\n actions: {\n setDragSource(identifier: UniqueIdentifier) {\n sourceIdentifier.value = identifier;\n },\n setDropTarget(\n identifier: UniqueIdentifier | null | undefined\n ): Promise<void> {\n const id = identifier ?? null;\n\n if (targetIdentifier.peek() === id) {\n return Promise.resolve();\n }\n\n targetIdentifier.value = id;\n\n if (status.peek() === Status.Dragging) {\n monitor.dispatch(\n 'dragover',\n defaultPreventable({\n operation: snapshot(operation),\n })\n );\n }\n\n return manager.renderer.rendering;\n },\n start({event, coordinates}: {event: Event; coordinates: Coordinates}) {\n batch(() => {\n dragended.value = false;\n canceled.value = false;\n activatorEvent.value = event;\n position.reset(coordinates);\n });\n\n const beforeStartEvent = defaultPreventable({\n operation: snapshot(operation),\n });\n\n monitor.dispatch('beforedragstart', beforeStartEvent);\n\n manager.renderer.rendering.then(() => {\n if (beforeStartEvent.defaultPrevented) {\n reset();\n return;\n }\n\n status.value = Status.Initializing;\n\n requestAnimationFrame(() => {\n status.value = Status.Dragging;\n\n monitor.dispatch('dragstart', {\n operation: snapshot(operation),\n cancelable: false,\n });\n });\n });\n },\n move({\n by,\n to,\n cancelable = true,\n }:\n | {by: Coordinates; to?: undefined; cancelable?: boolean}\n | {by?: undefined; to: Coordinates; cancelable?: boolean}) {\n if (!dragging.peek()) {\n return;\n }\n\n const event = defaultPreventable(\n {\n operation: snapshot(operation),\n by,\n to,\n },\n cancelable\n );\n\n monitor.dispatch('dragmove', event);\n\n queueMicrotask(() => {\n if (event.defaultPrevented) {\n return;\n }\n\n const coordinates = to ?? {\n x: position.current.x + by.x,\n y: position.current.y + by.y,\n };\n\n position.update(coordinates);\n });\n },\n stop({canceled: eventCanceled = false}: {canceled?: boolean} = {}) {\n let promise: Promise<void> | undefined;\n const suspend = () => {\n const output = {\n resume: () => {},\n abort: () => {},\n };\n\n promise = new Promise<void>((resolve, reject) => {\n output.resume = resolve;\n output.abort = reject;\n });\n\n return output;\n };\n const end = () => {\n /* Wait for the renderer to finish rendering before finalizing the drag operation */\n manager.renderer.rendering.then(() => {\n status.value = Status.Dropped;\n manager.renderer.rendering.then(reset);\n });\n };\n\n batch(() => {\n dragended.value = true;\n canceled.value = eventCanceled;\n });\n\n monitor.dispatch('dragend', {\n operation: snapshot(operation),\n canceled: eventCanceled,\n suspend,\n });\n\n if (promise) {\n promise.then(end).catch(reset);\n } else {\n end();\n }\n },\n },\n };\n}\n\nfunction snapshot<T extends Record<string, any>>(obj: T): T {\n return {\n ...obj,\n };\n}\n","export interface Renderer {\n get rendering(): Promise<void>;\n}\n\nexport const defaultRenderer: Renderer = {\n get rendering() {\n return Promise.resolve();\n },\n};\n","import type {Draggable, Droppable} from '../entities/index.ts';\nimport {CollisionObserver, CollisionNotifier} from '../collision/index.ts';\nimport type {Plugins, Plugin} from '../plugins/index.ts';\nimport type {Sensor, Sensors} from '../sensors/index.ts';\nimport type {Modifier, Modifiers} from '../modifiers/index.ts';\n\nimport {DragDropRegistry} from './registry.ts';\nimport {\n DragOperationManager,\n type DragOperation,\n type DragActions,\n} from './dragOperation.ts';\nimport {DragDropMonitor} from './events.ts';\nimport {defaultRenderer, type Renderer} from './renderer.ts';\n\nexport 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","effects","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,EAGA,YAAoB,SAAY;AAAZ;AAAA,EAA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U,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.ts';\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport {Plugin} from '../plugins/index.ts';\nimport type {Collision, CollisionDetector, Collisions} from './types.ts';\nimport {sortCollisions} from './utilities.ts';\n\nconst DEFAULT_VALUE: Collisions = [];\n\nexport class CollisionObserver<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n V extends DragDropManager<T, U> = DragDropManager<T, U>,\n> extends Plugin<V> {\n constructor(manager: V) {\n super(manager);\n\n this.computeCollisions = this.computeCollisions.bind(this);\n this.#collisions = computed(this.computeCollisions, deepEqual);\n\n this.destroy = effect(() => {\n const {dragOperation} = this.manager;\n\n if (dragOperation.status.initialized) {\n this.forceUpdate();\n }\n });\n }\n\n forceUpdateCount = signal(0);\n\n public forceUpdate(refresh = true) {\n untracked(() => {\n const {source} = this.manager.dragOperation;\n\n batch(() => {\n if (refresh) {\n for (const droppable of this.manager.registry.droppables) {\n if (source && !droppable.accepts(source)) {\n continue;\n }\n\n droppable.refreshShape();\n }\n }\n\n this.forceUpdateCount.value++;\n });\n });\n }\n\n public computeCollisions(\n entries?: Droppable[],\n collisionDetector?: CollisionDetector\n ) {\n const {registry, dragOperation} = this.manager;\n const {source, shape, status} = dragOperation;\n\n if (!status.initialized || !shape) {\n return DEFAULT_VALUE;\n }\n\n const collisions: Collision[] = [];\n\n this.forceUpdateCount.value;\n\n for (const entry of entries ?? registry.droppables) {\n if (entry.disabled) {\n continue;\n }\n\n if (source && !entry.accepts(source)) {\n continue;\n }\n\n const detectCollision = collisionDetector ?? entry.collisionDetector;\n\n if (!detectCollision) {\n continue;\n }\n\n const collision = untracked(() =>\n detectCollision({\n droppable: entry,\n dragOperation,\n })\n );\n\n if (collision) {\n if (entry.collisionPriority != null) {\n collision.priority = entry.collisionPriority;\n }\n\n collisions.push(collision);\n }\n }\n\n collisions.sort(sortCollisions);\n\n return collisions;\n }\n\n public get collisions() {\n return this.#collisions.value;\n }\n\n #collisions: ReadonlySignal<Collisions>;\n}\n","import {reactive, untracked} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../manager/index.ts';\nimport type {PluginOptions} from './types.ts';\nimport {configure} from './utilities.ts';\n\n/**\n * An abstract plugin class that can be extended to implement custom\n * functionality that augments the `DragDropManager`'s core capabilities.\n */\nexport abstract class Plugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> {\n constructor(\n public manager: T,\n public options?: U\n ) {}\n\n /**\n * Whether the plugin instance is disabled.\n * Triggers effects when accessed.\n */\n @reactive\n public disabled: boolean = false;\n\n /**\n * Enable a disabled plugin instance.\n * Triggers effects.\n */\n public enable() {\n this.disabled = false;\n }\n\n /**\n * Disable an enabled plugin instance.\n * Triggers effects.\n */\n public disable() {\n this.disabled = true;\n }\n\n /**\n * Whether the plugin instance is disabled.\n * Does not trigger effects when accessed.\n */\n public isDisabled() {\n return untracked(() => {\n return this.disabled;\n });\n }\n\n /**\n * Configure a plugin instance with new options.\n */\n public configure(options?: U) {\n this.options = options;\n }\n\n /**\n * Destroy a plugin instance.\n */\n public destroy() {\n /*\n * Each plugin is responsible for implementing its own\n * destroy method to clean up effects and listeners\n */\n }\n\n /**\n * Configure a plugin constructor with options.\n * This method is used to configure the options that the\n * plugin constructor will use to create plugin instances.\n */\n static configure(options: PluginOptions) {\n return configure(this as any, options);\n }\n}\n\nexport class CorePlugin<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n U extends PluginOptions = PluginOptions,\n> extends Plugin<T, U> {}\n","import type {\n PluginConstructor,\n PluginOptions,\n PluginDescriptor,\n InferPluginOptions,\n} from './types.ts';\n\nexport function configure<\n T extends PluginConstructor<any, any, any>,\n V extends PluginOptions = InferPluginOptions<T>,\n>(plugin: T, options: V): PluginDescriptor<any, any, T> {\n return {\n plugin,\n options,\n };\n}\n\nexport function configurator<T extends PluginConstructor<any, any, any>>(\n plugin: T\n) {\n return (options: InferPluginOptions<T>): PluginDescriptor<any, any, T> => {\n return configure(plugin, options);\n };\n}\n\nexport function descriptor<T extends PluginConstructor<any, any, any>>(\n plugin: T | PluginDescriptor<any, any, T>\n): PluginDescriptor<any, any, T> {\n if (typeof plugin === 'function') {\n return {\n plugin,\n options: undefined,\n };\n }\n\n return plugin;\n}\n","import {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin, type Plugin} from './plugin.ts';\nimport type {InferPluginOptions, PluginConstructor, Plugins} from './types.ts';\nimport {descriptor} from './utilities.ts';\n\nexport class PluginRegistry<\n T extends DragDropManager<any, any>,\n W extends PluginConstructor<T> = PluginConstructor<T>,\n U extends Plugin<T> = InstanceType<W>,\n> {\n private instances: Map<W, U> = new Map();\n\n constructor(private manager: T) {}\n\n public get values(): U[] {\n return Array.from(this.instances.values());\n }\n\n #previousValues: PluginConstructor<T>[] = [];\n\n public set values(entries: Plugins<T>) {\n const descriptors = entries.map(descriptor);\n const constructors = descriptors.map(({plugin}) => plugin);\n\n for (const plugin of this.#previousValues) {\n if (!constructors.includes(plugin)) {\n if (plugin.prototype instanceof CorePlugin) {\n continue;\n }\n\n this.unregister(plugin as W);\n }\n }\n\n for (const {plugin, options} of descriptors) {\n this.register(plugin as W, options as InferPluginOptions<W>);\n }\n\n this.#previousValues = constructors;\n }\n\n public get<X extends W>(plugin: X): InstanceType<X> | undefined {\n const instance = this.instances.get(plugin);\n\n return instance as any;\n }\n\n public register<X extends W>(\n plugin: X,\n options?: InferPluginOptions<X>\n ): InstanceType<X> {\n const existingInstance = this.instances.get(plugin);\n\n if (existingInstance) {\n return existingInstance as InstanceType<X>;\n }\n\n const instance = new plugin(this.manager, options) as U;\n\n this.instances.set(plugin, instance);\n\n return instance as InstanceType<X>;\n }\n\n public unregister<X extends W>(plugin: X) {\n const instance = this.instances.get(plugin);\n\n if (instance) {\n instance.destroy();\n this.instances.delete(plugin);\n }\n }\n\n public destroy() {\n for (const plugin of this.instances.values()) {\n plugin.destroy();\n }\n\n this.instances.clear();\n }\n}\n","import {Collision} from './types.ts';\n\n/**\n * Sort collisions from greatest to smallest priority\n * Collisions of equal priority are sorted from greatest to smallest value\n */\nexport function sortCollisions(a: Collision, b: Collision) {\n if (a.priority === b.priority) {\n return b.value - a.value;\n }\n\n return b.priority - a.priority;\n}\n","import {effect, untracked} from '@dnd-kit/state';\n\nimport {DragDropManager} from '../manager/index.ts';\nimport {CorePlugin} from '../plugins/index.ts';\nimport {defaultPreventable} from '../manager/events.ts';\n\nexport class CollisionNotifier extends CorePlugin {\n constructor(manager: DragDropManager) {\n super(manager);\n\n this.destroy = effect(() => {\n const {collisionObserver, monitor} = manager;\n const {collisions} = collisionObserver;\n\n if (collisionObserver.isDisabled()) {\n return;\n }\n\n const event = defaultPreventable({\n collisions,\n });\n\n monitor.dispatch('collision', event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n const [firstCollision] = collisions;\n\n untracked(() => {\n if (firstCollision?.id !== manager.dragOperation.target?.id) {\n collisionObserver.disable();\n\n manager.actions.setDropTarget(firstCollision?.id).then(() => {\n collisionObserver.enable();\n });\n }\n });\n });\n }\n}\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport type {Draggable, Droppable} from '../entities/index.ts';\nimport type {Collisions} from '../collision/index.ts';\nimport type {DragDropManager} from './manager.ts';\nimport type {DragOperation} from './dragOperation.ts';\n\nexport type Events = Record<string, (...args: any[]) => void>;\n\nexport type Preventable<T> = T & {\n cancelable: boolean;\n defaultPrevented: boolean;\n preventDefault(): void;\n};\n\nclass Monitor<T extends Events> {\n private registry = new Map<keyof T, Set<T[keyof T]>>();\n\n public addEventListener<U extends keyof T>(name: U, handler: T[U]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.add(handler);\n registry.set(name, listeners);\n\n return () => this.removeEventListener(name, handler);\n }\n\n public removeEventListener(name: keyof T, handler: T[keyof T]) {\n const {registry} = this;\n const listeners = new Set(registry.get(name));\n\n listeners.delete(handler);\n registry.set(name, listeners);\n }\n\n protected dispatch<U extends keyof T>(name: U, ...args: any[]) {\n const {registry} = this;\n const listeners = registry.get(name);\n\n if (!listeners) {\n return;\n }\n\n for (const listener of listeners) {\n listener(...args);\n }\n }\n}\n\nexport type DragDropEvents<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = {\n collision(\n event: Preventable<{\n collisions: Collisions;\n }>,\n manager: V\n ): void;\n beforedragstart(\n event: Preventable<{operation: DragOperation<T, U>}>,\n manager: V\n ): void;\n dragstart(\n event: {\n cancelable: false;\n operation: DragOperation<T, U>;\n },\n manager: V\n ): void;\n dragmove(\n event: Preventable<{\n operation: DragOperation<T, U>;\n to?: Coordinates;\n by?: Coordinates;\n }>,\n manager: V\n ): void;\n dragover(\n event: Preventable<{\n operation: DragOperation<T, U>;\n }>,\n manager: V\n ): void;\n dragend(\n event: {\n operation: DragOperation<T, U>;\n canceled: boolean;\n suspend(): {resume(): void; abort(): void};\n },\n manager: V\n ): void;\n};\n\nexport class DragDropMonitor<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> extends Monitor<DragDropEvents<T, U, V>> {\n constructor(private manager: V) {\n super();\n }\n\n public dispatch<Key extends keyof DragDropEvents<T, U, V>>(\n type: Key,\n event: Parameters<DragDropEvents<T, U, V>[Key]>[0]\n ) {\n const args = [event, this.manager] as any;\n\n super.dispatch(type, ...args);\n }\n}\n\nexport function defaultPreventable<T>(\n event: T,\n cancelable = true\n): Preventable<T> {\n let defaultPrevented = false;\n\n return {\n ...event,\n cancelable,\n get defaultPrevented() {\n return defaultPrevented;\n },\n preventDefault() {\n if (!cancelable) {\n return;\n }\n\n defaultPrevented = true;\n },\n };\n}\n","import type {DragOperation} from '../manager/index.ts';\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.ts';\n\nexport enum CollisionPriority {\n Lowest,\n Low,\n Normal,\n High,\n Highest,\n}\n\nexport interface Collision {\n id: UniqueIdentifier;\n priority: CollisionPriority | number;\n value: number;\n}\n\nexport type Collisions = Collision[];\n\nexport interface CollisionDetectorInput<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n droppable: U;\n dragOperation: DragOperation<T, U>;\n}\n\nexport type CollisionDetector = <\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n>(\n input: CollisionDetectorInput<T, U>\n) => Collision | null;\n","import {effects, reactive, type Effect} from '@dnd-kit/state';\n\nimport type {DragDropManager} from '../../manager/index.ts';\nimport type {Data, UniqueIdentifier} from './types.ts';\n\ninterface Options {\n /**\n * A boolean indicating whether the entity should automatically be registered with the manager.\n * @defaultValue true\n */\n register?: boolean;\n}\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 options?: Options;\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 options,\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 this.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 this.destroy = this.destroy.bind(this);\n\n if (options?.register !== false) {\n queueMicrotask(() => {\n manager.registry.register(this);\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 * An array of effects that are applied to the entity.\n */\n public effects: Effect[];\n\n /**\n * A method that cleans up the entity when it is no longer needed.\n * @returns void\n */\n public destroy(): void {\n this.manager.registry.unregister(this);\n }\n}\n","import {effects, signal} from '@dnd-kit/state';\n\nimport type {Entity} from './entity.ts';\nimport type {UniqueIdentifier} from './types.ts';\n\n/**\n * Reactive class representing a registry for entities.\n * @template T - The type of entries that the registry manages,\n * for example, `Draggable` or `Droppable` entities.\n */\nexport class EntityRegistry<T extends Entity> {\n private map = signal<Map<UniqueIdentifier, T>>(new Map());\n private cleanupFunctions = new WeakMap<T, () => void>();\n\n /**\n * Iterator for the EntityRegistry class.\n * @returns An iterator for the values in the map.\n */\n public [Symbol.iterator]() {\n return this.map.peek().values();\n }\n\n public get value() {\n return this.map.value.values();\n }\n\n /**\n * Checks if a entity with the given identifier exists in the registry.\n * @param identifier - The unique identifier of the entity.\n * @returns True if the entity exists, false otherwise.\n */\n public has(identifier: UniqueIdentifier): boolean {\n return this.map.value.has(identifier);\n }\n\n /**\n * Retrieves a entity from the registry using its identifier.\n * @param identifier - The unique identifier of the entity.\n * @returns The entity if it exists, undefined otherwise.\n */\n public get(identifier: UniqueIdentifier): T | undefined {\n return this.map.value.get(identifier);\n }\n\n /**\n * Registers a entity in the registry.\n * @param key - The unique identifier of the entity.\n * @param value - The entity to register.\n * @returns A function that unregisters the entity.\n */\n public register = (key: UniqueIdentifier, value: T) => {\n const current = this.map.peek();\n\n if (current.get(key) === value) {\n return;\n }\n\n const updatedMap = new Map(current);\n updatedMap.set(key, value);\n\n this.map.value = updatedMap;\n\n const cleanup = effects(...value.effects);\n this.cleanupFunctions.set(value, cleanup);\n\n return () => this.unregister(key, value);\n };\n\n /**\n * Unregisters an entity from the registry.\n * @param key - The unique identifier of the entity.\n * @param value - The entity instance to unregister.\n */\n public unregister = (key: UniqueIdentifier, value: T) => {\n const current = this.map.peek();\n\n if (current.get(key) !== value) {\n return;\n }\n\n const cleanup = this.cleanupFunctions.get(value);\n cleanup?.();\n this.cleanupFunctions.delete(value);\n\n const updatedMap = new Map(current);\n updatedMap.delete(key);\n\n this.map.value = updatedMap;\n };\n\n /**\n * Destroys all entries in the registry and clears the registry.\n */\n public destroy() {\n for (const entry of this) {\n const cleanup = this.cleanupFunctions.get(entry);\n cleanup?.();\n entry.destroy();\n }\n\n this.map.value = new Map();\n }\n}\n","import {derived, reactive} from '@dnd-kit/state';\n\nimport {Entity} from '../entity/index.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport {Modifier} from '../../modifiers/index.ts';\nimport type {Modifiers} from '../../modifiers/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport {descriptor} from '../../plugins/index.ts';\nimport type {Sensors} from '../../sensors/sensor.ts';\n\nexport interface Input<\n T extends Data = Data,\n U extends Draggable<T> = Draggable<T>,\n> extends EntityInput<T, U> {\n type?: Type;\n modifiers?: Modifiers;\n sensors?: Sensors;\n}\n\nexport class Draggable<T extends Data = Data> extends Entity<T> {\n constructor(\n {modifiers, type, sensors, ...input}: Input<T>,\n public manager: DragDropManager\n ) {\n super(input, manager);\n\n this.type = type;\n this.sensors = sensors;\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 sensors: Sensors | undefined;\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.ts';\nimport type {EntityInput, Data, Type} from '../entity/index.ts';\nimport {\n CollisionPriority,\n type CollisionDetector,\n} from '../../collision/index.ts';\nimport type {DragDropManager} from '../../manager/index.ts';\nimport {Draggable} from '../draggable/draggable.ts';\n\nexport interface Input<\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.ts';\nimport type {Draggable} from '../entities/index.ts';\nimport {\n Plugin,\n type PluginConstructor,\n type PluginDescriptor,\n type PluginOptions,\n} from '../plugins/index.ts';\n\nexport type SensorOptions = PluginOptions;\n\nexport abstract class Sensor<\n T extends DragDropManager<any, any> = DragDropManager,\n U extends SensorOptions = SensorOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n /**\n * Bind the sensor to a draggable source, and optionally pass\n * in sensor options to override the default sensor options\n * for this draggable source only.\n */\n public abstract bind(source: Draggable, options?: U): CleanupFunction;\n}\n\nexport type SensorConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Sensor<T>>;\n\nexport type SensorDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Sensor<T>, SensorConstructor<T>>;\n\nexport type Sensors<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (SensorConstructor<T> | SensorDescriptor<T>)[];\n","import type {Coordinates} from '@dnd-kit/geometry';\n\nimport {\n Plugin,\n type PluginOptions,\n type PluginConstructor,\n type PluginDescriptor,\n} from '../plugins/index.ts';\nimport type {DragDropManager} from '../manager/index.ts';\n\nexport type ModifierOptions = PluginOptions;\n\nexport class Modifier<\n T extends DragDropManager<any, any> = DragDropManager,\n U extends ModifierOptions = ModifierOptions,\n> extends Plugin<T, U> {\n constructor(\n public manager: T,\n public options?: U\n ) {\n super(manager, options);\n }\n\n public apply(operation: T['dragOperation']): Coordinates {\n return operation.transform;\n }\n}\n\nexport type ModifierConstructor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginConstructor<T, Modifier<T, any>>;\n\nexport type ModifierDescriptor<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = PluginDescriptor<T, Modifier<T, any>, ModifierConstructor<T>>;\n\nexport type Modifiers<\n T extends DragDropManager<any, any> = DragDropManager<any, any>,\n> = (ModifierConstructor<T> | ModifierDescriptor<T>)[];\n","import type {CleanupFunction} from '@dnd-kit/state';\n\nimport {\n Draggable,\n Droppable,\n Entity,\n EntityRegistry,\n} from '../entities/index.ts';\nimport {\n PluginRegistry,\n Plugin,\n type PluginConstructor,\n PluginOptions,\n} from '../plugins/index.ts';\nimport {\n Sensor,\n SensorOptions,\n type SensorConstructor,\n} from '../sensors/index.ts';\nimport {Modifier, type ModifierConstructor} from '../modifiers/index.ts';\nimport type {DragDropManager} from './manager.ts';\n\nexport class DragDropRegistry<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> {\n constructor(manager: V) {\n this.plugins = new PluginRegistry<V, PluginConstructor<V>>(manager);\n this.sensors = new PluginRegistry<V, SensorConstructor<V>>(manager);\n this.modifiers = new PluginRegistry<V, ModifierConstructor<V>>(manager);\n }\n\n public draggables = new EntityRegistry<T>();\n public droppables = new EntityRegistry<U>();\n public plugins: PluginRegistry<V, PluginConstructor<V>>;\n public sensors: PluginRegistry<V, SensorConstructor<V>>;\n public modifiers: PluginRegistry<V, ModifierConstructor<V>>;\n\n public register(input: Entity): () => void;\n public register(input: Draggable): () => void;\n public register(input: Droppable): () => void;\n public register(input: SensorConstructor, options?: SensorOptions): Sensor;\n public register(input: ModifierConstructor): Modifier;\n public register(input: PluginConstructor, options?: PluginOptions): Plugin;\n public register(input: any, options?: Record<string, any>) {\n if (input instanceof Draggable) {\n return this.draggables.register(input.id, input as T);\n }\n\n if (input instanceof Droppable) {\n return this.droppables.register(input.id, input as U);\n }\n\n if (input.prototype instanceof Modifier) {\n return this.modifiers.register(input, options);\n }\n\n if (input.prototype instanceof Sensor) {\n return this.sensors.register(input, options);\n }\n\n if (input.prototype instanceof Plugin) {\n return this.plugins.register(input, options);\n }\n\n throw new Error('Invalid instance type');\n }\n\n public unregister(input: Entity): CleanupFunction;\n public unregister(input: Draggable): CleanupFunction;\n public unregister(input: Droppable): CleanupFunction;\n public unregister(input: SensorConstructor): CleanupFunction;\n public unregister(input: ModifierConstructor): CleanupFunction;\n public unregister(input: PluginConstructor): CleanupFunction;\n public unregister(input: any) {\n if (input instanceof Entity) {\n if (input instanceof Draggable) {\n return this.draggables.unregister(input.id, input as T);\n }\n\n if (input instanceof Droppable) {\n return this.droppables.unregister(input.id, input as U);\n }\n\n // no-op\n return () => {};\n }\n\n if (input.prototype instanceof Modifier) {\n return this.modifiers.unregister(input);\n }\n\n if (input.prototype instanceof Sensor) {\n return this.sensors.unregister(input);\n }\n\n if (input.prototype instanceof Plugin) {\n return this.plugins.unregister(input);\n }\n\n throw new Error('Invalid instance type');\n }\n\n destroy() {\n this.draggables.destroy();\n this.droppables.destroy();\n this.plugins.destroy();\n this.sensors.destroy();\n this.modifiers.destroy();\n }\n}\n","import {Position, type Shape} from '@dnd-kit/geometry';\nimport type {Coordinates} from '@dnd-kit/geometry';\nimport {batch, computed, signal} from '@dnd-kit/state';\n\nimport type {\n Draggable,\n Droppable,\n UniqueIdentifier,\n} from '../entities/index.ts';\n\nimport type {DragDropManager} from './manager.ts';\nimport {defaultPreventable} from './events.ts';\n\nexport enum Status {\n Idle = 'idle',\n Initializing = 'initializing',\n Dragging = 'dragging',\n Dropped = 'dropped',\n}\n\nexport type Serializable = {\n [key: string]: string | number | null | Serializable | Serializable[];\n};\n\nexport interface DragOperation<\n T extends Draggable = Draggable,\n U extends Droppable = Droppable,\n> {\n activatorEvent: Event | null;\n canceled: boolean;\n position: Position;\n transform: Coordinates;\n status: {\n current: Status;\n initialized: boolean;\n initializing: boolean;\n dragging: boolean;\n dragended: boolean;\n dropped: boolean;\n idle: boolean;\n };\n get shape(): {\n initial: Shape;\n current: Shape;\n } | null;\n set shape(value: Shape | null);\n source: T | null;\n target: U | null;\n data?: Serializable;\n}\n\nexport type DragActions<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n> = ReturnType<typeof DragOperationManager<T, U, V>>['actions'];\n\nexport function DragOperationManager<\n T extends Draggable,\n U extends Droppable,\n V extends DragDropManager<T, U>,\n>(manager: V) {\n const {\n registry: {draggables, droppables},\n monitor,\n } = manager;\n const status = signal<Status>(Status.Idle);\n const shape = {\n initial: signal<Shape | null>(null),\n current: signal<Shape | null>(null),\n };\n const canceled = signal<boolean>(false);\n const position = new Position({x: 0, y: 0});\n const activatorEvent = signal<Event | null>(null);\n const sourceIdentifier = signal<UniqueIdentifier | null>(null);\n const targetIdentifier = signal<UniqueIdentifier | null>(null);\n const dragging = computed(() => status.value === Status.Dragging);\n const initialized = computed(() => status.value !== Status.Idle);\n const initializing = computed(() => status.value === Status.Initializing);\n const idle = computed(() => status.value === Status.Idle);\n const dropped = computed(() => status.value === Status.Dropped);\n const dragended = signal<boolean>(true);\n let previousSource: T | undefined;\n const source = computed<T | null>(() => {\n const identifier = sourceIdentifier.value;\n\n if (identifier == null) return null;\n\n const value = draggables.get(identifier);\n\n if (value) {\n // It's possible for the source to unmount during the drag operation\n previousSource = value;\n }\n\n return value ?? previousSource ?? null;\n });\n const target = computed<U | null>(() => {\n const identifier = targetIdentifier.value;\n return identifier != null ? droppables.get(identifier) ?? null : null;\n });\n\n const transform = computed(() => {\n const {x, y} = position.delta;\n const modifiers = source?.value?.modifiers ?? manager.modifiers;\n\n let transform = {x, y};\n const initialShape = shape.initial.peek();\n const currentShape = shape.current.peek();\n const operation: Omit<DragOperation<T, U>, 'transform'> = {\n activatorEvent: activatorEvent.peek(),\n canceled: canceled.peek(),\n source: source.peek(),\n target: target.peek(),\n status: {\n current: status.peek(),\n idle: idle.peek(),\n initializing: initializing.peek(),\n initialized: initialized.peek(),\n dragging: dragging.peek(),\n dragended: dragended.peek(),\n dropped: dropped.peek(),\n },\n shape:\n initialShape && currentShape\n ? {initial: initialShape, current: currentShape}\n : null,\n position,\n };\n\n for (const modifier of modifiers) {\n transform = modifier.apply({...operation, transform});\n }\n\n return transform;\n });\n\n const operation: DragOperation<T, U> = {\n get activatorEvent() {\n return activatorEvent.value;\n },\n get canceled() {\n return canceled.value;\n },\n get source() {\n return source.value;\n },\n get target() {\n return target.value;\n },\n status: {\n get current() {\n return status.value;\n },\n get idle() {\n return idle.value;\n },\n get initializing() {\n return initializing.value;\n },\n get initialized() {\n return initialized.value;\n },\n get dragging() {\n return dragging.value;\n },\n get dragended() {\n return dragended.value;\n },\n get dropped() {\n return dropped.value;\n },\n },\n get shape(): DragOperation['shape'] {\n const initial = shape.initial.value;\n const current = shape.current.value;\n\n return initial && current ? {initial, current} : null;\n },\n set shape(value: Shape | null) {\n if (value && shape.current.peek()?.equals(value)) {\n return;\n }\n\n const initial = shape.initial.peek();\n\n if (!initial) {\n shape.initial.value = value;\n }\n\n shape.current.value = value;\n },\n get transform() {\n return transform.value;\n },\n position,\n };\n\n const reset = () => {\n batch(() => {\n status.value = Status.Idle;\n sourceIdentifier.value = null;\n targetIdentifier.value = null;\n shape.current.value = null;\n shape.initial.value = null;\n position.reset({x: 0, y: 0});\n });\n };\n\n return {\n operation,\n actions: {\n setDragSource(identifier: UniqueIdentifier) {\n sourceIdentifier.value = identifier;\n },\n setDropTarget(\n identifier: UniqueIdentifier | null | undefined\n ): Promise<void> {\n const id = identifier ?? null;\n\n if (targetIdentifier.peek() === id) {\n return Promise.resolve();\n }\n\n targetIdentifier.value = id;\n\n if (status.peek() === Status.Dragging) {\n monitor.dispatch(\n 'dragover',\n defaultPreventable({\n operation: snapshot(operation),\n })\n );\n }\n\n return manager.renderer.rendering;\n },\n start({event, coordinates}: {event: Event; coordinates: Coordinates}) {\n batch(() => {\n dragended.value = false;\n canceled.value = false;\n activatorEvent.value = event;\n position.reset(coordinates);\n });\n\n const beforeStartEvent = defaultPreventable({\n operation: snapshot(operation),\n });\n\n monitor.dispatch('beforedragstart', beforeStartEvent);\n\n manager.renderer.rendering.then(() => {\n if (beforeStartEvent.defaultPrevented) {\n reset();\n return;\n }\n\n status.value = Status.Initializing;\n\n requestAnimationFrame(() => {\n status.value = Status.Dragging;\n\n monitor.dispatch('dragstart', {\n operation: snapshot(operation),\n cancelable: false,\n });\n });\n });\n },\n move({\n by,\n to,\n cancelable = true,\n }:\n | {by: Coordinates; to?: undefined; cancelable?: boolean}\n | {by?: undefined; to: Coordinates; cancelable?: boolean}) {\n if (!dragging.peek()) {\n return;\n }\n\n const event = defaultPreventable(\n {\n operation: snapshot(operation),\n by,\n to,\n },\n cancelable\n );\n\n monitor.dispatch('dragmove', event);\n\n queueMicrotask(() => {\n if (event.defaultPrevented) {\n return;\n }\n\n const coordinates = to ?? {\n x: position.current.x + by.x,\n y: position.current.y + by.y,\n };\n\n position.update(coordinates);\n });\n },\n stop({canceled: eventCanceled = false}: {canceled?: boolean} = {}) {\n let promise: Promise<void> | undefined;\n const suspend = () => {\n const output = {\n resume: () => {},\n abort: () => {},\n };\n\n promise = new Promise<void>((resolve, reject) => {\n output.resume = resolve;\n output.abort = reject;\n });\n\n return output;\n };\n const end = () => {\n /* Wait for the renderer to finish rendering before finalizing the drag operation */\n manager.renderer.rendering.then(() => {\n status.value = Status.Dropped;\n manager.renderer.rendering.then(reset);\n });\n };\n\n batch(() => {\n dragended.value = true;\n canceled.value = eventCanceled;\n });\n\n monitor.dispatch('dragend', {\n operation: snapshot(operation),\n canceled: eventCanceled,\n suspend,\n });\n\n if (promise) {\n promise.then(end).catch(reset);\n } else {\n end();\n }\n },\n },\n };\n}\n\nfunction snapshot<T extends Record<string, any>>(obj: T): T {\n return {\n ...obj,\n };\n}\n","export interface Renderer {\n get rendering(): Promise<void>;\n}\n\nexport const defaultRenderer: Renderer = {\n get rendering() {\n return Promise.resolve();\n },\n};\n","import type {Draggable, Droppable} from '../entities/index.ts';\nimport {CollisionObserver, CollisionNotifier} from '../collision/index.ts';\nimport type {Plugins, Plugin} from '../plugins/index.ts';\nimport type {Sensor, Sensors} from '../sensors/index.ts';\nimport type {Modifier, Modifiers} from '../modifiers/index.ts';\n\nimport {DragDropRegistry} from './registry.ts';\nimport {\n DragOperationManager,\n type DragOperation,\n type DragActions,\n} from './dragOperation.ts';\nimport {DragDropMonitor} from './events.ts';\nimport {defaultRenderer, type Renderer} from './renderer.ts';\n\nexport 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"]}
|