@dnd-kit/svelte 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +64 -0
  2. package/dist/core/context/DragDropProvider.svelte +107 -0
  3. package/dist/core/context/DragDropProvider.svelte.d.ts +18 -0
  4. package/dist/core/context/DragDropProvider.svelte.d.ts.map +1 -0
  5. package/dist/core/context/context.d.ts +5 -0
  6. package/dist/core/context/context.d.ts.map +1 -0
  7. package/dist/core/context/context.js +13 -0
  8. package/dist/core/context/renderer.svelte.d.ts +8 -0
  9. package/dist/core/context/renderer.svelte.d.ts.map +1 -0
  10. package/dist/core/context/renderer.svelte.js +32 -0
  11. package/dist/core/draggable/DragOverlay.svelte +88 -0
  12. package/dist/core/draggable/DragOverlay.svelte.d.ts +26 -0
  13. package/dist/core/draggable/DragOverlay.svelte.d.ts.map +1 -0
  14. package/dist/core/draggable/createDraggable.svelte.d.ts +13 -0
  15. package/dist/core/draggable/createDraggable.svelte.d.ts.map +1 -0
  16. package/dist/core/draggable/createDraggable.svelte.js +46 -0
  17. package/dist/core/droppable/createDroppable.svelte.d.ts +10 -0
  18. package/dist/core/droppable/createDroppable.svelte.d.ts.map +1 -0
  19. package/dist/core/droppable/createDroppable.svelte.js +35 -0
  20. package/dist/core/hooks/createDragDropMonitor.svelte.d.ts +13 -0
  21. package/dist/core/hooks/createDragDropMonitor.svelte.d.ts.map +1 -0
  22. package/dist/core/hooks/createDragDropMonitor.svelte.js +24 -0
  23. package/dist/core/hooks/createDragOperation.d.ts +6 -0
  24. package/dist/core/hooks/createDragOperation.d.ts.map +1 -0
  25. package/dist/core/hooks/createDragOperation.js +17 -0
  26. package/dist/core/hooks/createInstance.svelte.d.ts +8 -0
  27. package/dist/core/hooks/createInstance.svelte.d.ts.map +1 -0
  28. package/dist/core/hooks/createInstance.svelte.js +14 -0
  29. package/dist/core/hooks/getDragDropManager.d.ts +2 -0
  30. package/dist/core/hooks/getDragDropManager.d.ts.map +1 -0
  31. package/dist/core/hooks/getDragDropManager.js +4 -0
  32. package/dist/core/index.d.ts +11 -0
  33. package/dist/core/index.d.ts.map +1 -0
  34. package/dist/core/index.js +9 -0
  35. package/dist/hooks/index.d.ts +2 -0
  36. package/dist/hooks/index.d.ts.map +1 -0
  37. package/dist/hooks/index.js +1 -0
  38. package/dist/hooks/useDeepSignal.svelte.d.ts +14 -0
  39. package/dist/hooks/useDeepSignal.svelte.d.ts.map +1 -0
  40. package/dist/hooks/useDeepSignal.svelte.js +54 -0
  41. package/dist/sortable/createSortable.svelte.d.ts +16 -0
  42. package/dist/sortable/createSortable.svelte.d.ts.map +1 -0
  43. package/dist/sortable/createSortable.svelte.js +87 -0
  44. package/dist/sortable/index.d.ts +4 -0
  45. package/dist/sortable/index.d.ts.map +1 -0
  46. package/dist/sortable/index.js +2 -0
  47. package/dist/utilities/index.d.ts +2 -0
  48. package/dist/utilities/index.d.ts.map +1 -0
  49. package/dist/utilities/index.js +3 -0
  50. package/package.json +62 -0
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @dnd-kit/svelte
2
+
3
+ [![Stable release](https://img.shields.io/npm/v/@dnd-kit/svelte.svg)](https://npm.im/@dnd-kit/svelte)
4
+
5
+ The Svelte adapter for **@dnd-kit** — a lightweight, performant, and extensible drag and drop toolkit. Built on top of `@dnd-kit/dom`, it provides idiomatic Svelte 5 primitives using runes and [attachments](https://svelte.dev/docs/svelte/@attach).
6
+
7
+ ## Requirements
8
+
9
+ - Svelte **5.29** or later
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install @dnd-kit/svelte
15
+ ```
16
+
17
+ ## Quick start
18
+
19
+ ```svelte
20
+ <script>
21
+ import {DragDropProvider, createDraggable, createDroppable} from '@dnd-kit/svelte';
22
+
23
+ let droppedIn = $state(false);
24
+
25
+ const draggable = createDraggable({id: 'draggable'});
26
+ const droppable = createDroppable({id: 'droppable'});
27
+
28
+ function onDragEnd(event) {
29
+ if (event.canceled) return;
30
+ droppedIn = event.operation.target?.id === 'droppable';
31
+ }
32
+ </script>
33
+
34
+ <DragDropProvider {onDragEnd}>
35
+ {#if !droppedIn}
36
+ <button {@attach draggable.attach}>Drag me</button>
37
+ {/if}
38
+
39
+ <div {@attach droppable.attach}>
40
+ {#if droppedIn}
41
+ <button {@attach draggable.attach}>Dropped!</button>
42
+ {/if}
43
+ </div>
44
+ </DragDropProvider>
45
+ ```
46
+
47
+ ## Primitives
48
+
49
+ | Primitive | Import | Description |
50
+ | ----------------- | -------------------------- | ---------------------------------- |
51
+ | `createDraggable` | `@dnd-kit/svelte` | Make an element draggable |
52
+ | `createDroppable` | `@dnd-kit/svelte` | Create a drop target |
53
+ | `createSortable` | `@dnd-kit/svelte/sortable` | Combine drag and drop with sorting |
54
+
55
+ Each primitive returns an object with reactive state (e.g. `isDragging`, `isDropTarget`) and `attach` / `attachHandle` functions for use with the `{@attach}` directive.
56
+
57
+ ## Components
58
+
59
+ - **`<DragDropProvider>`** — Wraps your drag and drop interface, manages sensors, plugins, and events.
60
+ - **`<DragOverlay>`** — Renders a custom overlay element during drag operations.
61
+
62
+ ## Documentation
63
+
64
+ Visit [next.dndkit.com](https://next.dndkit.com/svelte) for full documentation, guides, and interactive examples.
@@ -0,0 +1,107 @@
1
+ <script lang="ts">
2
+ import type {Snippet} from 'svelte';
3
+ import {onDestroy} from 'svelte';
4
+ import type {DragDropEvents} from '@dnd-kit/abstract';
5
+ import {
6
+ DragDropManager,
7
+ defaultPreset,
8
+ type DragDropManagerInput,
9
+ type Draggable,
10
+ type Droppable,
11
+ } from '@dnd-kit/dom';
12
+
13
+ import {useRenderer} from './renderer.svelte.js';
14
+ import {setDragDropContext} from './context.js';
15
+
16
+ type Events = DragDropEvents<Draggable, Droppable, DragDropManager>;
17
+
18
+ interface Props extends DragDropManagerInput {
19
+ manager?: DragDropManager;
20
+ children?: Snippet;
21
+ onBeforeDragStart?: Events['beforedragstart'];
22
+ onDragStart?: Events['dragstart'];
23
+ onDragMove?: Events['dragmove'];
24
+ onDragOver?: Events['dragover'];
25
+ onDragEnd?: Events['dragend'];
26
+ onCollision?: Events['collision'];
27
+ }
28
+
29
+ let {
30
+ manager: managerProp,
31
+ plugins,
32
+ sensors,
33
+ modifiers,
34
+ children,
35
+ onBeforeDragStart,
36
+ onDragStart,
37
+ onDragMove,
38
+ onDragOver,
39
+ onDragEnd,
40
+ onCollision,
41
+ }: Props = $props();
42
+
43
+ const {renderer, trackRendering} = useRenderer();
44
+
45
+ // Create manager once; plugins/sensors/modifiers are synced reactively via $effect below
46
+ const manager = managerProp ?? new DragDropManager({});
47
+
48
+ manager.renderer = renderer;
49
+
50
+ setDragDropContext(manager);
51
+
52
+ $effect(() => {
53
+ manager.plugins = plugins ?? defaultPreset.plugins;
54
+ manager.sensors = sensors ?? defaultPreset.sensors;
55
+ manager.modifiers = modifiers ?? defaultPreset.modifiers;
56
+ });
57
+
58
+ $effect(() => {
59
+ const cleanupFns: (() => void)[] = [];
60
+
61
+ cleanupFns.push(
62
+ manager.monitor.addEventListener('beforedragstart', (event, mgr) =>
63
+ trackRendering(() => onBeforeDragStart?.(event, mgr))
64
+ )
65
+ );
66
+
67
+ cleanupFns.push(
68
+ manager.monitor.addEventListener('dragstart', (event, mgr) =>
69
+ onDragStart?.(event, mgr)
70
+ )
71
+ );
72
+
73
+ cleanupFns.push(
74
+ manager.monitor.addEventListener('dragover', (event, mgr) =>
75
+ trackRendering(() => onDragOver?.(event, mgr))
76
+ )
77
+ );
78
+
79
+ cleanupFns.push(
80
+ manager.monitor.addEventListener('dragmove', (event, mgr) =>
81
+ trackRendering(() => onDragMove?.(event, mgr))
82
+ )
83
+ );
84
+
85
+ cleanupFns.push(
86
+ manager.monitor.addEventListener('dragend', (event, mgr) =>
87
+ trackRendering(() => onDragEnd?.(event, mgr))
88
+ )
89
+ );
90
+
91
+ cleanupFns.push(
92
+ manager.monitor.addEventListener('collision', (event, mgr) =>
93
+ onCollision?.(event, mgr)
94
+ )
95
+ );
96
+
97
+ return () => cleanupFns.forEach((fn) => fn());
98
+ });
99
+
100
+ onDestroy(() => {
101
+ if (!managerProp) {
102
+ manager.destroy();
103
+ }
104
+ });
105
+ </script>
106
+
107
+ {@render children?.()}
@@ -0,0 +1,18 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { DragDropEvents } from '@dnd-kit/abstract';
3
+ import { DragDropManager, type DragDropManagerInput, type Draggable, type Droppable } from '@dnd-kit/dom';
4
+ type Events = DragDropEvents<Draggable, Droppable, DragDropManager>;
5
+ interface Props extends DragDropManagerInput {
6
+ manager?: DragDropManager;
7
+ children?: Snippet;
8
+ onBeforeDragStart?: Events['beforedragstart'];
9
+ onDragStart?: Events['dragstart'];
10
+ onDragMove?: Events['dragmove'];
11
+ onDragOver?: Events['dragover'];
12
+ onDragEnd?: Events['dragend'];
13
+ onCollision?: Events['collision'];
14
+ }
15
+ declare const DragDropProvider: import("svelte").Component<Props, {}, "">;
16
+ type DragDropProvider = ReturnType<typeof DragDropProvider>;
17
+ export default DragDropProvider;
18
+ //# sourceMappingURL=DragDropProvider.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DragDropProvider.svelte.d.ts","sourceRoot":"","sources":["../../../src/core/context/DragDropProvider.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,QAAQ,CAAC;AAEpC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACH,eAAe,EAEf,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAMtB,KAAK,MAAM,GAAG,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;AAEpE,UAAU,KAAM,SAAQ,oBAAoB;IAC1C,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;CACnC;AA8FH,QAAA,MAAM,gBAAgB,2CAAwC,CAAC;AAC/D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5D,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { DragDropManager } from '@dnd-kit/dom';
2
+ export declare const DND_CONTEXT_KEY: unique symbol;
3
+ export declare function setDragDropContext(manager: DragDropManager): void;
4
+ export declare function getDragDropContext(): DragDropManager;
5
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/core/context/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAElD,eAAO,MAAM,eAAe,eAA6B,CAAC;AAE1D,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,QAE1D;AAED,wBAAgB,kBAAkB,IAAI,eAAe,CAWpD"}
@@ -0,0 +1,13 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ export const DND_CONTEXT_KEY = Symbol('DragDropProvider');
3
+ export function setDragDropContext(manager) {
4
+ setContext(DND_CONTEXT_KEY, manager);
5
+ }
6
+ export function getDragDropContext() {
7
+ const manager = getContext(DND_CONTEXT_KEY);
8
+ if (!manager) {
9
+ throw new Error('getDragDropManager was called outside of a DragDropProvider. ' +
10
+ 'Make sure your component is wrapped in a DragDropProvider.');
11
+ }
12
+ return manager;
13
+ }
@@ -0,0 +1,8 @@
1
+ import type { DragDropManager } from '@dnd-kit/dom';
2
+ type Renderer = DragDropManager['renderer'];
3
+ export declare function useRenderer(): {
4
+ renderer: Renderer;
5
+ trackRendering: (callback: () => void) => void;
6
+ };
7
+ export {};
8
+ //# sourceMappingURL=renderer.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.svelte.d.ts","sourceRoot":"","sources":["../../../src/core/context/renderer.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAGlD,KAAK,QAAQ,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;AAE5C,wBAAgB,WAAW,IAAI;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;CAChD,CAoCA"}
@@ -0,0 +1,32 @@
1
+ import { tick } from 'svelte';
2
+ export function useRenderer() {
3
+ let transitionCount = $state(0);
4
+ let rendering = null;
5
+ let resolver = null;
6
+ $effect(() => {
7
+ // Track transitionCount so this effect re-runs after DOM updates
8
+ void transitionCount;
9
+ resolver === null || resolver === void 0 ? void 0 : resolver();
10
+ rendering = null;
11
+ });
12
+ const renderer = {
13
+ get rendering() {
14
+ return rendering !== null && rendering !== void 0 ? rendering : Promise.resolve();
15
+ },
16
+ };
17
+ function trackRendering(callback) {
18
+ if (!rendering) {
19
+ rendering = new Promise((resolve) => {
20
+ resolver = resolve;
21
+ });
22
+ }
23
+ callback();
24
+ tick().then(() => {
25
+ transitionCount++;
26
+ });
27
+ }
28
+ return {
29
+ renderer,
30
+ trackRendering,
31
+ };
32
+ }
@@ -0,0 +1,88 @@
1
+ <script lang="ts">
2
+ import type {Snippet} from 'svelte';
3
+ import type {DragDropManager, Draggable, DropAnimation} from '@dnd-kit/dom';
4
+ import {Feedback} from '@dnd-kit/dom';
5
+
6
+ import {useDeepSignal} from '../../hooks/useDeepSignal.svelte.js';
7
+ import {getDragDropManager} from '../hooks/getDragDropManager.js';
8
+ import {DND_CONTEXT_KEY, setDragDropContext} from '../context/context.js';
9
+
10
+ interface Props {
11
+ /**
12
+ * Whether the drag overlay is disabled.
13
+ */
14
+ disabled?: boolean;
15
+ /**
16
+ * Customize or disable the drop animation that plays when a drag operation ends.
17
+ *
18
+ * - `undefined` – use the default animation (250ms ease)
19
+ * - `null` – disable the drop animation entirely
20
+ * - `{duration, easing}` – customize the animation timing
21
+ * - `(context) => Promise<void> | void` – provide a fully custom animation function
22
+ */
23
+ dropAnimation?: DropAnimation | null;
24
+ /**
25
+ * Content to render inside the overlay.
26
+ * Receives the drag source as a snippet parameter.
27
+ */
28
+ children?: Snippet<[Draggable]>;
29
+ }
30
+
31
+ let {disabled = false, dropAnimation, children}: Props = $props();
32
+
33
+ const manager = getDragDropManager();
34
+ let overlayElement = $state<HTMLElement | null>(null);
35
+
36
+ const trackedDragOperation = useDeepSignal(() => manager.dragOperation);
37
+
38
+ // Provide a patched manager that prevents children from registering
39
+ const noop = () => () => {};
40
+
41
+ const patchedRegistry = new Proxy(manager.registry, {
42
+ get(target, property) {
43
+ if (property === 'register' || property === 'unregister') {
44
+ return noop;
45
+ }
46
+
47
+ return target[property as keyof typeof target];
48
+ },
49
+ });
50
+
51
+ const patchedManager = new Proxy(manager, {
52
+ get(target, property) {
53
+ if (property === 'registry') {
54
+ return patchedRegistry;
55
+ }
56
+
57
+ return target[property as keyof typeof target];
58
+ },
59
+ }) as DragDropManager;
60
+
61
+ setDragDropContext(patchedManager);
62
+
63
+ // Register overlay element and dropAnimation with the Feedback plugin
64
+ $effect(() => {
65
+ const el = overlayElement;
66
+ if (!el || disabled) return;
67
+
68
+ const feedback = manager.plugins.find(
69
+ (plugin): plugin is Feedback => plugin instanceof Feedback
70
+ );
71
+
72
+ if (!feedback) return;
73
+
74
+ feedback.overlay = el;
75
+ feedback.dropAnimation = dropAnimation;
76
+
77
+ return () => {
78
+ feedback.overlay = undefined;
79
+ feedback.dropAnimation = undefined;
80
+ };
81
+ });
82
+ </script>
83
+
84
+ <div bind:this={overlayElement} data-dnd-overlay>
85
+ {#if !disabled && trackedDragOperation.current.source}
86
+ {@render children?.(trackedDragOperation.current.source)}
87
+ {/if}
88
+ </div>
@@ -0,0 +1,26 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { Draggable, DropAnimation } from '@dnd-kit/dom';
3
+ interface Props {
4
+ /**
5
+ * Whether the drag overlay is disabled.
6
+ */
7
+ disabled?: boolean;
8
+ /**
9
+ * Customize or disable the drop animation that plays when a drag operation ends.
10
+ *
11
+ * - `undefined` – use the default animation (250ms ease)
12
+ * - `null` – disable the drop animation entirely
13
+ * - `{duration, easing}` – customize the animation timing
14
+ * - `(context) => Promise<void> | void` – provide a fully custom animation function
15
+ */
16
+ dropAnimation?: DropAnimation | null;
17
+ /**
18
+ * Content to render inside the overlay.
19
+ * Receives the drag source as a snippet parameter.
20
+ */
21
+ children?: Snippet<[Draggable]>;
22
+ }
23
+ declare const DragOverlay: import("svelte").Component<Props, {}, "">;
24
+ type DragOverlay = ReturnType<typeof DragOverlay>;
25
+ export default DragOverlay;
26
+ //# sourceMappingURL=DragOverlay.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DragOverlay.svelte.d.ts","sourceRoot":"","sources":["../../../src/core/draggable/DragOverlay.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,EAAkB,SAAS,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAQ1E,UAAU,KAAK;IACb;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;CACjC;AAwEH,QAAA,MAAM,WAAW,2CAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Data } from '@dnd-kit/abstract';
2
+ import type { DraggableInput } from '@dnd-kit/dom';
3
+ import { Draggable } from '@dnd-kit/dom';
4
+ export type CreateDraggableInput<T extends Data = Data> = Omit<DraggableInput<T>, 'handle' | 'element' | 'register'>;
5
+ export declare function createDraggable<T extends Data = Data>(input: CreateDraggableInput<T>): {
6
+ readonly draggable: Draggable<T>;
7
+ readonly isDragging: boolean;
8
+ readonly isDropping: boolean;
9
+ readonly isDragSource: boolean;
10
+ attach(node: HTMLElement): () => void;
11
+ attachHandle(node: HTMLElement): () => void;
12
+ };
13
+ //# sourceMappingURL=createDraggable.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDraggable.svelte.d.ts","sourceRoot":"","sources":["../../../src/core/draggable/createDraggable.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AACjD,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAKvC,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,IAAI,IAAI,CAC5D,cAAc,CAAC,CAAC,CAAC,EACjB,QAAQ,GAAG,SAAS,GAAG,UAAU,CAClC,CAAC;AAEF,wBAAgB,eAAe,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,EACnD,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;;;;iBA0Cf,WAAW;uBAOL,WAAW;EAQjC"}
@@ -0,0 +1,46 @@
1
+ import { Draggable } from '@dnd-kit/dom';
2
+ import { useDeepSignal } from '../../hooks/useDeepSignal.svelte.js';
3
+ import { createInstance } from '../hooks/createInstance.svelte.js';
4
+ export function createDraggable(input) {
5
+ const draggable = createInstance((manager) => new Draggable(Object.assign(Object.assign({}, input), { register: false }), manager));
6
+ const tracked = useDeepSignal(() => draggable);
7
+ // Sync reactive properties from input getters
8
+ $effect(() => {
9
+ var _a, _b;
10
+ draggable.id = input.id;
11
+ draggable.disabled = (_a = input.disabled) !== null && _a !== void 0 ? _a : false;
12
+ draggable.feedback = (_b = input.feedback) !== null && _b !== void 0 ? _b : 'default';
13
+ draggable.alignment = input.alignment;
14
+ draggable.modifiers = input.modifiers;
15
+ draggable.sensors = input.sensors;
16
+ if (input.data) {
17
+ draggable.data = input.data;
18
+ }
19
+ });
20
+ return {
21
+ get draggable() {
22
+ return draggable;
23
+ },
24
+ get isDragging() {
25
+ return tracked.current.isDragging;
26
+ },
27
+ get isDropping() {
28
+ return tracked.current.isDropping;
29
+ },
30
+ get isDragSource() {
31
+ return tracked.current.isDragSource;
32
+ },
33
+ attach(node) {
34
+ draggable.element = node;
35
+ return () => {
36
+ draggable.element = undefined;
37
+ };
38
+ },
39
+ attachHandle(node) {
40
+ draggable.handle = node;
41
+ return () => {
42
+ draggable.handle = undefined;
43
+ };
44
+ },
45
+ };
46
+ }
@@ -0,0 +1,10 @@
1
+ import type { Data } from '@dnd-kit/abstract';
2
+ import type { DroppableInput } from '@dnd-kit/dom';
3
+ import { Droppable } from '@dnd-kit/dom';
4
+ export type CreateDroppableInput<T extends Data = Data> = Omit<DroppableInput<T>, 'element' | 'register'>;
5
+ export declare function createDroppable<T extends Data = Data>(input: CreateDroppableInput<T>): {
6
+ readonly droppable: Droppable<T>;
7
+ readonly isDropTarget: boolean;
8
+ attach(node: HTMLElement): () => void;
9
+ };
10
+ //# sourceMappingURL=createDroppable.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDroppable.svelte.d.ts","sourceRoot":"","sources":["../../../src/core/droppable/createDroppable.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AACjD,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAKvC,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,IAAI,IAAI,CAC5D,cAAc,CAAC,CAAC,CAAC,EACjB,SAAS,GAAG,UAAU,CACvB,CAAC;AAEF,wBAAgB,eAAe,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,EACnD,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;;iBAsCf,WAAW;EAQ3B"}
@@ -0,0 +1,35 @@
1
+ import { Droppable } from '@dnd-kit/dom';
2
+ import { useDeepSignal } from '../../hooks/useDeepSignal.svelte.js';
3
+ import { createInstance } from '../hooks/createInstance.svelte.js';
4
+ export function createDroppable(input) {
5
+ const droppable = createInstance((manager) => new Droppable(Object.assign(Object.assign({}, input), { register: false }), manager));
6
+ const tracked = useDeepSignal(() => droppable);
7
+ // Sync reactive properties from input getters
8
+ $effect(() => {
9
+ var _a;
10
+ droppable.id = input.id;
11
+ droppable.accept = input.accept;
12
+ droppable.type = input.type;
13
+ droppable.disabled = (_a = input.disabled) !== null && _a !== void 0 ? _a : false;
14
+ if (input.collisionDetector) {
15
+ droppable.collisionDetector = input.collisionDetector;
16
+ }
17
+ if (input.data) {
18
+ droppable.data = input.data;
19
+ }
20
+ });
21
+ return {
22
+ get droppable() {
23
+ return droppable;
24
+ },
25
+ get isDropTarget() {
26
+ return tracked.current.isDropTarget;
27
+ },
28
+ attach(node) {
29
+ droppable.element = node;
30
+ return () => {
31
+ droppable.element = undefined;
32
+ };
33
+ },
34
+ };
35
+ }
@@ -0,0 +1,13 @@
1
+ import type { DragDropEvents, Data } from '@dnd-kit/abstract';
2
+ import type { Draggable, Droppable, DragDropManager } from '@dnd-kit/dom';
3
+ type DragDropEventMap = {
4
+ beforedragstart: 'onBeforeDragStart';
5
+ };
6
+ type EventHandlerName<T extends string> = T extends keyof DragDropEventMap ? DragDropEventMap[T] : T extends `drag${infer Second}${infer Rest}` ? `onDrag${Uppercase<Second>}${Rest}` : `on${Capitalize<T>}`;
7
+ type Events<T extends Data, U extends Draggable<T>, V extends Droppable<T>, W extends DragDropManager<T, U, V>> = DragDropEvents<U, V, W>;
8
+ export type EventHandlers<T extends Data = Data, U extends Draggable<T> = Draggable<T>, V extends Droppable<T> = Droppable<T>, W extends DragDropManager<T, U, V> = DragDropManager<T, U, V>> = {
9
+ [K in keyof Events<T, U, V, W> as EventHandlerName<K>]?: Events<T, U, V, W>[K];
10
+ };
11
+ export declare function createDragDropMonitor<T extends Data = Data, U extends Draggable<T> = Draggable<T>, V extends Droppable<T> = Droppable<T>, W extends DragDropManager<T, U, V> = DragDropManager<T, U, V>>(handlers: EventHandlers<T, U, V, W>): void;
12
+ export {};
13
+ //# sourceMappingURL=createDragDropMonitor.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDragDropMonitor.svelte.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/createDragDropMonitor.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAE,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAC,SAAS,EAAE,SAAS,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAKxE,KAAK,gBAAgB,GAAG;IACtB,eAAe,EAAE,mBAAmB,CAAC;CACtC,CAAC;AAEF,KAAK,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,MAAM,gBAAgB,GACtE,gBAAgB,CAAC,CAAC,CAAC,GACnB,CAAC,SAAS,OAAO,MAAM,MAAM,GAAG,MAAM,IAAI,EAAE,GAC1C,SAAS,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,GACnC,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;AAE3B,KAAK,MAAM,CACT,CAAC,SAAS,IAAI,EACd,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EACtB,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EACtB,CAAC,SAAS,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAChC,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE5B,MAAM,MAAM,aAAa,CACvB,CAAC,SAAS,IAAI,GAAG,IAAI,EACrB,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EACrC,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EACrC,CAAC,SAAS,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAC3D;KACD,CAAC,IAAI,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAC7D,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,CACF,CAAC,CAAC,CAAC;CACL,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,IAAI,GAAG,IAAI,EACrB,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EACrC,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EACrC,CAAC,SAAS,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC7D,QAAQ,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAoC3C"}
@@ -0,0 +1,24 @@
1
+ import { getDragDropManager } from './getDragDropManager.js';
2
+ export function createDragDropMonitor(handlers) {
3
+ const manager = getDragDropManager();
4
+ $effect(() => {
5
+ if (!manager) {
6
+ if (process.env.NODE_ENV !== 'production') {
7
+ console.warn('createDragDropMonitor was called outside of a DragDropProvider. ' +
8
+ 'Make sure your app is wrapped in a DragDropProvider component.');
9
+ }
10
+ return;
11
+ }
12
+ const cleanupFns = Object.entries(handlers).reduce((acc, [handlerName, handler]) => {
13
+ if (handler) {
14
+ const eventName = handlerName
15
+ .replace(/^on/, '')
16
+ .toLowerCase();
17
+ const unsubscribe = manager.monitor.addEventListener(eventName, handler);
18
+ acc.push(unsubscribe);
19
+ }
20
+ return acc;
21
+ }, []);
22
+ return () => cleanupFns.forEach((cleanup) => cleanup());
23
+ });
24
+ }
@@ -0,0 +1,6 @@
1
+ export declare function createDragOperation(): {
2
+ readonly source: import("@dnd-kit/dom").Draggable<import("@dnd-kit/abstract").Data> | null;
3
+ readonly target: import("@dnd-kit/dom").Droppable<import("@dnd-kit/abstract").Data> | null;
4
+ readonly status: import("@dnd-kit/abstract").DragOperationStatus;
5
+ };
6
+ //# sourceMappingURL=createDragOperation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDragOperation.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/createDragOperation.ts"],"names":[],"mappings":"AAGA,wBAAgB,mBAAmB;;;;EAelC"}
@@ -0,0 +1,17 @@
1
+ import { useDeepSignal } from '../../hooks/useDeepSignal.svelte.js';
2
+ import { getDragDropManager } from './getDragDropManager.js';
3
+ export function createDragOperation() {
4
+ const manager = getDragDropManager();
5
+ const trackedDragOperation = useDeepSignal(() => manager.dragOperation);
6
+ return {
7
+ get source() {
8
+ return trackedDragOperation.current.source;
9
+ },
10
+ get target() {
11
+ return trackedDragOperation.current.target;
12
+ },
13
+ get status() {
14
+ return trackedDragOperation.current.status;
15
+ },
16
+ };
17
+ }
@@ -0,0 +1,8 @@
1
+ import type { DragDropManager } from '@dnd-kit/dom';
2
+ import type { CleanupFunction } from '@dnd-kit/state';
3
+ export interface Instance<T extends DragDropManager = DragDropManager> {
4
+ manager: T | undefined;
5
+ register(): CleanupFunction | void;
6
+ }
7
+ export declare function createInstance<T extends Instance>(initializer: (manager: DragDropManager | undefined) => T): T;
8
+ //# sourceMappingURL=createInstance.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createInstance.svelte.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/createInstance.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAIpD,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe;IACnE,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC;IACvB,QAAQ,IAAI,eAAe,GAAG,IAAI,CAAC;CACpC;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,QAAQ,EAC/C,WAAW,EAAE,CAAC,OAAO,EAAE,eAAe,GAAG,SAAS,KAAK,CAAC,GACvD,CAAC,CAcH"}
@@ -0,0 +1,14 @@
1
+ import { getDragDropManager } from './getDragDropManager.js';
2
+ export function createInstance(initializer) {
3
+ const manager = getDragDropManager();
4
+ const instance = initializer(manager);
5
+ $effect(() => {
6
+ instance.manager = manager;
7
+ const cleanup = instance.register();
8
+ return () => {
9
+ if (typeof cleanup === 'function')
10
+ cleanup();
11
+ };
12
+ });
13
+ return instance;
14
+ }
@@ -0,0 +1,2 @@
1
+ export declare function getDragDropManager(): import("@dnd-kit/dom").DragDropManager<import("@dnd-kit/abstract").Data, import("@dnd-kit/dom").Draggable<import("@dnd-kit/abstract").Data>, import("@dnd-kit/dom").Droppable<import("@dnd-kit/abstract").Data>>;
2
+ //# sourceMappingURL=getDragDropManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDragDropManager.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/getDragDropManager.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,qNAEjC"}
@@ -0,0 +1,4 @@
1
+ import { getDragDropContext } from '../context/context.js';
2
+ export function getDragDropManager() {
3
+ return getDragDropContext();
4
+ }
@@ -0,0 +1,11 @@
1
+ export { default as DragDropProvider } from './context/DragDropProvider.svelte';
2
+ export { default as DragOverlay } from './draggable/DragOverlay.svelte';
3
+ export { createDraggable, type CreateDraggableInput, } from './draggable/createDraggable.svelte.js';
4
+ export { createDroppable, type CreateDroppableInput, } from './droppable/createDroppable.svelte.js';
5
+ export { getDragDropManager } from './hooks/getDragDropManager.js';
6
+ export { createDragDropMonitor, type EventHandlers as DragDropEventHandlers, } from './hooks/createDragDropMonitor.svelte.js';
7
+ export { createDragOperation } from './hooks/createDragOperation.js';
8
+ export { createInstance } from './hooks/createInstance.svelte.js';
9
+ export { KeyboardSensor, PointerSensor } from '@dnd-kit/dom';
10
+ export type { DragDropManager } from '@dnd-kit/dom';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AAE9E,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAEtE,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,GAC1B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,GAC1B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EACL,qBAAqB,EACrB,KAAK,aAAa,IAAI,qBAAqB,GAC5C,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAC,mBAAmB,EAAC,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAC,cAAc,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAC3D,YAAY,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC"}
@@ -0,0 +1,9 @@
1
+ export { default as DragDropProvider } from './context/DragDropProvider.svelte';
2
+ export { default as DragOverlay } from './draggable/DragOverlay.svelte';
3
+ export { createDraggable, } from './draggable/createDraggable.svelte.js';
4
+ export { createDroppable, } from './droppable/createDroppable.svelte.js';
5
+ export { getDragDropManager } from './hooks/getDragDropManager.js';
6
+ export { createDragDropMonitor, } from './hooks/createDragDropMonitor.svelte.js';
7
+ export { createDragOperation } from './hooks/createDragOperation.js';
8
+ export { createInstance } from './hooks/createInstance.svelte.js';
9
+ export { KeyboardSensor, PointerSensor } from '@dnd-kit/dom';
@@ -0,0 +1,2 @@
1
+ export { useDeepSignal } from './useDeepSignal.svelte.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1 @@
1
+ export { useDeepSignal } from './useDeepSignal.svelte.js';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Bridge between @dnd-kit/state (Preact signals) and Svelte 5 reactivity.
3
+ *
4
+ * Uses a hybrid push-pull strategy:
5
+ * - Pull: A Proxy tracks which properties the template actually reads
6
+ * - Push: A single @dnd-kit/state effect watches only tracked properties
7
+ * and bumps a single $state dirty counter when any change
8
+ * - Read: Getters read `dirty` (so Svelte subscribes) then return
9
+ * the current value from the instance
10
+ */
11
+ export declare function useDeepSignal<T extends object | null | undefined>(getTarget: () => T): {
12
+ readonly current: T;
13
+ };
14
+ //# sourceMappingURL=useDeepSignal.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDeepSignal.svelte.d.ts","sourceRoot":"","sources":["../../src/hooks/useDeepSignal.svelte.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/D,SAAS,EAAE,MAAM,CAAC,GACjB;IAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;CAAC,CAoDvB"}
@@ -0,0 +1,54 @@
1
+ import { effect, untracked } from '@dnd-kit/state';
2
+ /**
3
+ * Bridge between @dnd-kit/state (Preact signals) and Svelte 5 reactivity.
4
+ *
5
+ * Uses a hybrid push-pull strategy:
6
+ * - Pull: A Proxy tracks which properties the template actually reads
7
+ * - Push: A single @dnd-kit/state effect watches only tracked properties
8
+ * and bumps a single $state dirty counter when any change
9
+ * - Read: Getters read `dirty` (so Svelte subscribes) then return
10
+ * the current value from the instance
11
+ */
12
+ export function useDeepSignal(getTarget) {
13
+ const tracked = new Map();
14
+ let dirty = $state(0);
15
+ $effect(() => {
16
+ const target = getTarget();
17
+ if (!target) {
18
+ tracked.clear();
19
+ return;
20
+ }
21
+ const dispose = effect(() => {
22
+ let stale = false;
23
+ for (const entry of tracked) {
24
+ const [key] = entry;
25
+ const value = untracked(() => entry[1]);
26
+ const latestValue = target[key];
27
+ if (value !== latestValue) {
28
+ stale = true;
29
+ tracked.set(key, latestValue);
30
+ }
31
+ }
32
+ if (stale) {
33
+ dirty++;
34
+ }
35
+ });
36
+ return dispose;
37
+ });
38
+ return {
39
+ get current() {
40
+ const target = getTarget();
41
+ // Reading dirty subscribes the Svelte template/effect to changes
42
+ void dirty;
43
+ return target
44
+ ? new Proxy(target, {
45
+ get(obj, key) {
46
+ const value = obj[key];
47
+ tracked.set(key, value);
48
+ return value;
49
+ },
50
+ })
51
+ : target;
52
+ },
53
+ };
54
+ }
@@ -0,0 +1,16 @@
1
+ import { type Data } from '@dnd-kit/abstract';
2
+ import type { SortableInput } from '@dnd-kit/dom/sortable';
3
+ import { Sortable } from '@dnd-kit/dom/sortable';
4
+ export type CreateSortableInput<T extends Data = Data> = Omit<SortableInput<T>, 'handle' | 'element' | 'source' | 'target' | 'register'>;
5
+ export declare function createSortable<T extends Data = Data>(input: CreateSortableInput<T>): {
6
+ readonly sortable: Sortable<T>;
7
+ readonly isDragging: boolean;
8
+ readonly isDropping: boolean;
9
+ readonly isDragSource: boolean;
10
+ readonly isDropTarget: boolean;
11
+ attach(node: HTMLElement): () => void;
12
+ attachHandle(node: HTMLElement): () => void;
13
+ attachSource(node: HTMLElement): () => void;
14
+ attachTarget(node: HTMLElement): () => void;
15
+ };
16
+ //# sourceMappingURL=createSortable.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSortable.svelte.d.ts","sourceRoot":"","sources":["../../src/sortable/createSortable.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAA4B,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAM1E,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,IAAI,IAAI,CAC3D,aAAa,CAAC,CAAC,CAAC,EAChB,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CACxD,CAAC;AAEF,wBAAgB,cAAc,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,EAClD,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC;;;;;;iBA8Ed,WAAW;uBAOL,WAAW;uBAOX,WAAW;uBAOX,WAAW;EAQjC"}
@@ -0,0 +1,87 @@
1
+ import {} from '@dnd-kit/abstract';
2
+ import { defaultSortableTransition, Sortable } from '@dnd-kit/dom/sortable';
3
+ import { batch } from '@dnd-kit/state';
4
+ import { useDeepSignal } from '../hooks/useDeepSignal.svelte.js';
5
+ import { createInstance } from '../core/hooks/createInstance.svelte.js';
6
+ export function createSortable(input) {
7
+ const sortable = createInstance((manager) => {
8
+ return new Sortable(Object.assign(Object.assign({}, input), { register: false, transition: Object.assign(Object.assign({}, defaultSortableTransition), input.transition) }), manager);
9
+ });
10
+ const tracked = useDeepSignal(() => sortable);
11
+ // Sync reactive properties from input getters
12
+ $effect(() => {
13
+ var _a, _b;
14
+ sortable.id = input.id;
15
+ sortable.disabled = (_a = input.disabled) !== null && _a !== void 0 ? _a : false;
16
+ sortable.feedback = (_b = input.feedback) !== null && _b !== void 0 ? _b : 'default';
17
+ sortable.alignment = input.alignment;
18
+ sortable.modifiers = input.modifiers;
19
+ sortable.sensors = input.sensors;
20
+ sortable.accept = input.accept;
21
+ sortable.type = input.type;
22
+ sortable.collisionPriority = input.collisionPriority;
23
+ sortable.transition = Object.assign(Object.assign({}, defaultSortableTransition), input.transition);
24
+ if (input.data) {
25
+ sortable.data = input.data;
26
+ }
27
+ });
28
+ // Batch group/index updates to ensure atomic state changes
29
+ $effect.pre(() => {
30
+ const group = input.group;
31
+ const index = input.index;
32
+ batch(() => {
33
+ sortable.group = group;
34
+ sortable.index = index;
35
+ });
36
+ });
37
+ // Refresh shape when index changes while idle
38
+ $effect(() => {
39
+ var _a, _b;
40
+ void input.index;
41
+ if (((_a = sortable.manager) === null || _a === void 0 ? void 0 : _a.dragOperation.status.idle) &&
42
+ ((_b = sortable.transition) === null || _b === void 0 ? void 0 : _b.idle)) {
43
+ sortable.refreshShape();
44
+ }
45
+ });
46
+ return {
47
+ get sortable() {
48
+ return sortable;
49
+ },
50
+ get isDragging() {
51
+ return tracked.current.isDragging;
52
+ },
53
+ get isDropping() {
54
+ return tracked.current.isDropping;
55
+ },
56
+ get isDragSource() {
57
+ return tracked.current.isDragSource;
58
+ },
59
+ get isDropTarget() {
60
+ return tracked.current.isDropTarget;
61
+ },
62
+ attach(node) {
63
+ sortable.element = node;
64
+ return () => {
65
+ sortable.element = undefined;
66
+ };
67
+ },
68
+ attachHandle(node) {
69
+ sortable.handle = node;
70
+ return () => {
71
+ sortable.handle = undefined;
72
+ };
73
+ },
74
+ attachSource(node) {
75
+ sortable.source = node;
76
+ return () => {
77
+ sortable.source = undefined;
78
+ };
79
+ },
80
+ attachTarget(node) {
81
+ sortable.target = node;
82
+ return () => {
83
+ sortable.target = undefined;
84
+ };
85
+ },
86
+ };
87
+ }
@@ -0,0 +1,4 @@
1
+ export { createSortable } from './createSortable.svelte.js';
2
+ export type { CreateSortableInput } from './createSortable.svelte.js';
3
+ export { isSortable } from '@dnd-kit/dom/sortable';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sortable/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAC1D,YAAY,EAAC,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { createSortable } from './createSortable.svelte.js';
2
+ export { isSortable } from '@dnd-kit/dom/sortable';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // Utilities for @dnd-kit/svelte
3
+ // Currently empty — reserved for future utility exports.
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@dnd-kit/svelte",
3
+ "version": "0.2.3",
4
+ "type": "module",
5
+ "svelte": "./dist/core/index.js",
6
+ "types": "./dist/core/index.d.ts",
7
+ "sideEffects": false,
8
+ "license": "MIT",
9
+ "files": [
10
+ "LICENSE",
11
+ "README.md",
12
+ "dist"
13
+ ],
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/core/index.d.ts",
17
+ "svelte": "./dist/core/index.js",
18
+ "default": "./dist/core/index.js"
19
+ },
20
+ "./hooks": {
21
+ "types": "./dist/hooks/index.d.ts",
22
+ "svelte": "./dist/hooks/index.js",
23
+ "default": "./dist/hooks/index.js"
24
+ },
25
+ "./sortable": {
26
+ "types": "./dist/sortable/index.d.ts",
27
+ "svelte": "./dist/sortable/index.js",
28
+ "default": "./dist/sortable/index.js"
29
+ },
30
+ "./utilities": {
31
+ "types": "./dist/utilities/index.d.ts",
32
+ "svelte": "./dist/utilities/index.js",
33
+ "default": "./dist/utilities/index.js"
34
+ }
35
+ },
36
+ "scripts": {
37
+ "build": "svelte-package -i src -o dist",
38
+ "dev": "svelte-package -i src -o dist --watch",
39
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
40
+ },
41
+ "dependencies": {
42
+ "@dnd-kit/abstract": "^0.2.3",
43
+ "@dnd-kit/dom": "^0.2.3",
44
+ "@dnd-kit/state": "^0.2.3",
45
+ "tslib": "^2.6.2"
46
+ },
47
+ "peerDependencies": {
48
+ "svelte": "^5.29.0"
49
+ },
50
+ "devDependencies": {
51
+ "@sveltejs/package": "^2.5.7",
52
+ "svelte": "^5.29.0",
53
+ "typescript": "^5.5.2"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "https://github.com/clauderic/dnd-kit"
61
+ }
62
+ }