@pyreon/dnd 0.25.1 → 0.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5386,7 +5386,7 @@ var drawChart = (function (exports) {
5386
5386
  </script>
5387
5387
  <script>
5388
5388
  /*<!--*/
5389
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"f701960a-1","name":"use-drag-monitor.ts"},{"uid":"f701960a-3","name":"use-draggable.ts"},{"uid":"f701960a-5","name":"use-droppable.ts"},{"uid":"f701960a-7","name":"use-file-drop.ts"},{"uid":"f701960a-9","name":"use-sortable.ts"},{"uid":"f701960a-11","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"f701960a-1":{"renderedLength":1307,"gzipLength":625,"brotliLength":0,"metaUid":"f701960a-0"},"f701960a-3":{"renderedLength":1312,"gzipLength":600,"brotliLength":0,"metaUid":"f701960a-2"},"f701960a-5":{"renderedLength":1361,"gzipLength":597,"brotliLength":0,"metaUid":"f701960a-4"},"f701960a-7":{"renderedLength":2300,"gzipLength":939,"brotliLength":0,"metaUid":"f701960a-6"},"f701960a-9":{"renderedLength":6160,"gzipLength":2095,"brotliLength":0,"metaUid":"f701960a-8"},"f701960a-11":{"renderedLength":97,"gzipLength":109,"brotliLength":0,"metaUid":"f701960a-10"}},"nodeMetas":{"f701960a-0":{"id":"/src/use-drag-monitor.ts","moduleParts":{"index.js":"f701960a-1"},"imported":[{"uid":"f701960a-13"},{"uid":"f701960a-12"}],"importedBy":[{"uid":"f701960a-10"}]},"f701960a-2":{"id":"/src/use-draggable.ts","moduleParts":{"index.js":"f701960a-3"},"imported":[{"uid":"f701960a-13"},{"uid":"f701960a-12"}],"importedBy":[{"uid":"f701960a-10"}]},"f701960a-4":{"id":"/src/use-droppable.ts","moduleParts":{"index.js":"f701960a-5"},"imported":[{"uid":"f701960a-13"},{"uid":"f701960a-12"}],"importedBy":[{"uid":"f701960a-10"}]},"f701960a-6":{"id":"/src/use-file-drop.ts","moduleParts":{"index.js":"f701960a-7"},"imported":[{"uid":"f701960a-14"},{"uid":"f701960a-15"},{"uid":"f701960a-12"}],"importedBy":[{"uid":"f701960a-10"}]},"f701960a-8":{"id":"/src/use-sortable.ts","moduleParts":{"index.js":"f701960a-9"},"imported":[{"uid":"f701960a-16"},{"uid":"f701960a-13"},{"uid":"f701960a-17"},{"uid":"f701960a-18"},{"uid":"f701960a-12"}],"importedBy":[{"uid":"f701960a-10"}]},"f701960a-10":{"id":"/src/index.ts","moduleParts":{"index.js":"f701960a-11"},"imported":[{"uid":"f701960a-12"},{"uid":"f701960a-0"},{"uid":"f701960a-2"},{"uid":"f701960a-4"},{"uid":"f701960a-6"},{"uid":"f701960a-8"}],"importedBy":[],"isEntry":true},"f701960a-12":{"id":"@pyreon/reactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"f701960a-10"},{"uid":"f701960a-0"},{"uid":"f701960a-2"},{"uid":"f701960a-4"},{"uid":"f701960a-6"},{"uid":"f701960a-8"}]},"f701960a-13":{"id":"@atlaskit/pragmatic-drag-and-drop/element/adapter","moduleParts":{},"imported":[],"importedBy":[{"uid":"f701960a-0"},{"uid":"f701960a-2"},{"uid":"f701960a-4"},{"uid":"f701960a-8"}]},"f701960a-14":{"id":"@atlaskit/pragmatic-drag-and-drop/external/adapter","moduleParts":{},"imported":[],"importedBy":[{"uid":"f701960a-6"}]},"f701960a-15":{"id":"@atlaskit/pragmatic-drag-and-drop/external/file","moduleParts":{},"imported":[],"importedBy":[{"uid":"f701960a-6"}]},"f701960a-16":{"id":"@atlaskit/pragmatic-drag-and-drop/combine","moduleParts":{},"imported":[],"importedBy":[{"uid":"f701960a-8"}]},"f701960a-17":{"id":"@atlaskit/pragmatic-drag-and-drop-auto-scroll/element","moduleParts":{},"imported":[],"importedBy":[{"uid":"f701960a-8"}]},"f701960a-18":{"id":"@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge","moduleParts":{},"imported":[],"importedBy":[{"uid":"f701960a-8"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
5389
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"d90167b3-1","name":"use-drag-monitor.ts"},{"uid":"d90167b3-3","name":"use-draggable.ts"},{"uid":"d90167b3-5","name":"use-droppable.ts"},{"uid":"d90167b3-7","name":"use-file-drop.ts"},{"uid":"d90167b3-9","name":"use-sortable.ts"},{"uid":"d90167b3-11","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"d90167b3-1":{"renderedLength":1359,"gzipLength":640,"brotliLength":0,"metaUid":"d90167b3-0"},"d90167b3-3":{"renderedLength":1378,"gzipLength":621,"brotliLength":0,"metaUid":"d90167b3-2"},"d90167b3-5":{"renderedLength":1427,"gzipLength":616,"brotliLength":0,"metaUid":"d90167b3-4"},"d90167b3-7":{"renderedLength":2394,"gzipLength":972,"brotliLength":0,"metaUid":"d90167b3-6"},"d90167b3-9":{"renderedLength":8560,"gzipLength":2716,"brotliLength":0,"metaUid":"d90167b3-8"},"d90167b3-11":{"renderedLength":97,"gzipLength":109,"brotliLength":0,"metaUid":"d90167b3-10"}},"nodeMetas":{"d90167b3-0":{"id":"/src/use-drag-monitor.ts","moduleParts":{"index.js":"d90167b3-1"},"imported":[{"uid":"d90167b3-13"},{"uid":"d90167b3-12"}],"importedBy":[{"uid":"d90167b3-10"}]},"d90167b3-2":{"id":"/src/use-draggable.ts","moduleParts":{"index.js":"d90167b3-3"},"imported":[{"uid":"d90167b3-13"},{"uid":"d90167b3-12"}],"importedBy":[{"uid":"d90167b3-10"}]},"d90167b3-4":{"id":"/src/use-droppable.ts","moduleParts":{"index.js":"d90167b3-5"},"imported":[{"uid":"d90167b3-13"},{"uid":"d90167b3-12"}],"importedBy":[{"uid":"d90167b3-10"}]},"d90167b3-6":{"id":"/src/use-file-drop.ts","moduleParts":{"index.js":"d90167b3-7"},"imported":[{"uid":"d90167b3-14"},{"uid":"d90167b3-15"},{"uid":"d90167b3-12"}],"importedBy":[{"uid":"d90167b3-10"}]},"d90167b3-8":{"id":"/src/use-sortable.ts","moduleParts":{"index.js":"d90167b3-9"},"imported":[{"uid":"d90167b3-16"},{"uid":"d90167b3-13"},{"uid":"d90167b3-17"},{"uid":"d90167b3-18"},{"uid":"d90167b3-12"}],"importedBy":[{"uid":"d90167b3-10"}]},"d90167b3-10":{"id":"/src/index.ts","moduleParts":{"index.js":"d90167b3-11"},"imported":[{"uid":"d90167b3-12"},{"uid":"d90167b3-0"},{"uid":"d90167b3-2"},{"uid":"d90167b3-4"},{"uid":"d90167b3-6"},{"uid":"d90167b3-8"}],"importedBy":[],"isEntry":true},"d90167b3-12":{"id":"@pyreon/reactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"d90167b3-10"},{"uid":"d90167b3-0"},{"uid":"d90167b3-2"},{"uid":"d90167b3-4"},{"uid":"d90167b3-6"},{"uid":"d90167b3-8"}]},"d90167b3-13":{"id":"@atlaskit/pragmatic-drag-and-drop/element/adapter","moduleParts":{},"imported":[],"importedBy":[{"uid":"d90167b3-0"},{"uid":"d90167b3-2"},{"uid":"d90167b3-4"},{"uid":"d90167b3-8"}]},"d90167b3-14":{"id":"@atlaskit/pragmatic-drag-and-drop/external/adapter","moduleParts":{},"imported":[],"importedBy":[{"uid":"d90167b3-6"}]},"d90167b3-15":{"id":"@atlaskit/pragmatic-drag-and-drop/external/file","moduleParts":{},"imported":[],"importedBy":[{"uid":"d90167b3-6"}]},"d90167b3-16":{"id":"@atlaskit/pragmatic-drag-and-drop/combine","moduleParts":{},"imported":[],"importedBy":[{"uid":"d90167b3-8"}]},"d90167b3-17":{"id":"@atlaskit/pragmatic-drag-and-drop-auto-scroll/element","moduleParts":{},"imported":[],"importedBy":[{"uid":"d90167b3-8"}]},"d90167b3-18":{"id":"@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge","moduleParts":{},"imported":[],"importedBy":[{"uid":"d90167b3-8"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
5390
5390
 
5391
5391
  const run = () => {
5392
5392
  const width = window.innerWidth;
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { onCleanup, registerSingleton, signal } from "@pyreon/reactivity";
1
+ import { batch, onCleanup, registerSingleton, signal } from "@pyreon/reactivity";
2
2
  import { draggable, dropTargetForElements, monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
3
3
  import { dropTargetForExternal, monitorForExternal } from "@atlaskit/pragmatic-drag-and-drop/external/adapter";
4
4
  import { containsFiles, getFiles } from "@atlaskit/pragmatic-drag-and-drop/external/file";
@@ -37,13 +37,17 @@ function useDragMonitor(options) {
37
37
  onCleanup(monitorForElements({
38
38
  ...canMonitorFn ? { canMonitor: canMonitorFn } : {},
39
39
  onDragStart: ({ source }) => {
40
- isDragging.set(true);
41
- dragData.set(source.data);
40
+ batch(() => {
41
+ isDragging.set(true);
42
+ dragData.set(source.data);
43
+ });
42
44
  options?.onDragStart?.(source.data);
43
45
  },
44
46
  onDrop: ({ source, location }) => {
45
- isDragging.set(false);
46
- dragData.set(null);
47
+ batch(() => {
48
+ isDragging.set(false);
49
+ dragData.set(null);
50
+ });
47
51
  const targetData = location.current.dropTargets[0]?.data ?? {};
48
52
  options?.onDrop?.(source.data, targetData);
49
53
  }
@@ -77,7 +81,9 @@ function useDraggable(options) {
77
81
  if (typeof document === "undefined") return { isDragging: () => false };
78
82
  const isDragging = signal(false);
79
83
  let cleanup;
84
+ let disposed = false;
80
85
  function setup() {
86
+ if (disposed) return;
81
87
  if (cleanup) cleanup();
82
88
  const el = options.element();
83
89
  if (!el) return;
@@ -104,6 +110,7 @@ function useDraggable(options) {
104
110
  }
105
111
  queueMicrotask(setup);
106
112
  onCleanup(() => {
113
+ disposed = true;
107
114
  if (cleanup) cleanup();
108
115
  });
109
116
  return { isDragging };
@@ -133,7 +140,9 @@ function useDroppable(options) {
133
140
  if (typeof document === "undefined") return { isOver: () => false };
134
141
  const isOver = signal(false);
135
142
  let cleanup;
143
+ let disposed = false;
136
144
  function setup() {
145
+ if (disposed) return;
137
146
  if (cleanup) cleanup();
138
147
  const el = options.element();
139
148
  if (!el) return;
@@ -163,6 +172,7 @@ function useDroppable(options) {
163
172
  }
164
173
  queueMicrotask(setup);
165
174
  onCleanup(() => {
175
+ disposed = true;
166
176
  if (cleanup) cleanup();
167
177
  });
168
178
  return { isOver };
@@ -201,6 +211,7 @@ function useFileDrop(options) {
201
211
  const isOver = signal(false);
202
212
  const isDraggingFiles = signal(false);
203
213
  let cleanup;
214
+ let disposed = false;
204
215
  function matchesAccept(file, accept) {
205
216
  return accept.some((pattern) => {
206
217
  if (pattern.startsWith(".")) return file.name.toLowerCase().endsWith(pattern.toLowerCase());
@@ -209,6 +220,7 @@ function useFileDrop(options) {
209
220
  });
210
221
  }
211
222
  function setup() {
223
+ if (disposed) return;
212
224
  if (cleanup) cleanup();
213
225
  const el = options.element();
214
226
  if (!el) return;
@@ -228,8 +240,10 @@ function useFileDrop(options) {
228
240
  onDragEnter: () => isOver.set(true),
229
241
  onDragLeave: () => isOver.set(false),
230
242
  onDrop: ({ source }) => {
231
- isOver.set(false);
232
- isDraggingFiles.set(false);
243
+ batch(() => {
244
+ isOver.set(false);
245
+ isDraggingFiles.set(false);
246
+ });
233
247
  let files = getFiles({ source });
234
248
  if (options.accept && options.accept.length > 0) files = files.filter((f) => matchesAccept(f, options.accept));
235
249
  if (options.maxFiles && files.length > options.maxFiles) files = files.slice(0, options.maxFiles);
@@ -242,6 +256,7 @@ function useFileDrop(options) {
242
256
  }
243
257
  queueMicrotask(setup);
244
258
  onCleanup(() => {
259
+ disposed = true;
245
260
  if (cleanup) cleanup();
246
261
  });
247
262
  return {
@@ -254,7 +269,10 @@ function useFileDrop(options) {
254
269
  //#region src/use-sortable.ts
255
270
  const SORT_KEY = "__pyreon_sortable_key";
256
271
  const SORT_ID = "__pyreon_sortable_id";
272
+ const SORT_GROUP = "__pyreon_sortable_group";
273
+ const SORT_PAYLOAD = "__pyreon_sortable_payload";
257
274
  let _sortableCounter = 0;
275
+ const _sortableRegistry = /* @__PURE__ */ new Map();
258
276
  /**
259
277
  * Sortable list with signal-driven state, auto-scroll, and edge detection.
260
278
  *
@@ -264,6 +282,11 @@ let _sortableCounter = 0;
264
282
  * - Closest-edge detection (drop above/below or left/right)
265
283
  * - Axis constraint (vertical/horizontal)
266
284
  * - Keyboard reordering (Alt+Arrow keys)
285
+ * - Optional cross-list `groupId` for Trello/Notion/Linear board layouts
286
+ * (W18) — share the same `groupId` between two
287
+ * sortable instances and items can be dragged between them. The
288
+ * source's `onCrossListDrop(item)` removes; the destination's
289
+ * `onCrossListReceive(item, index)` inserts.
267
290
  *
268
291
  * @example
269
292
  * ```tsx
@@ -310,6 +333,11 @@ function useSortable(options) {
310
333
  const overId = signal(null);
311
334
  const overEdge = signal(null);
312
335
  const axis = options.axis ?? "vertical";
336
+ const groupId = options.groupId;
337
+ _sortableRegistry.set(sortableId, {
338
+ groupId,
339
+ onCrossListDrop: options.onCrossListDrop
340
+ });
313
341
  const cleanups = [];
314
342
  const itemCleanups = /* @__PURE__ */ new Map();
315
343
  /** Perform the reorder based on current active/over/edge state. */
@@ -330,21 +358,41 @@ function useSortable(options) {
330
358
  reordered.splice(insertAt, 0, moved);
331
359
  options.onReorder(reordered);
332
360
  }
361
+ /** Returns true when `source` belongs to this sortable or to a sibling
362
+ * in the same `groupId`. */
363
+ function acceptsSource(source) {
364
+ if (source.data[SORT_ID] === sortableId) return true;
365
+ if (groupId && source.data[SORT_GROUP] === groupId) return true;
366
+ return false;
367
+ }
333
368
  function containerRef(el) {
334
369
  if (!el) return;
335
370
  cleanups.push(autoScrollForElements({
336
371
  element: el,
337
- canScroll: ({ source }) => source.data[SORT_ID] === sortableId
372
+ canScroll: ({ source }) => acceptsSource(source)
338
373
  }));
339
374
  cleanups.push(dropTargetForElements({
340
375
  element: el,
341
- getData: () => ({ [SORT_ID]: sortableId }),
342
- canDrop: ({ source }) => source.data[SORT_ID] === sortableId,
343
- onDrop: () => {
344
- performReorder();
345
- activeId.set(null);
346
- overId.set(null);
347
- overEdge.set(null);
376
+ getData: () => ({
377
+ [SORT_ID]: sortableId,
378
+ [SORT_GROUP]: groupId
379
+ }),
380
+ canDrop: ({ source }) => acceptsSource(source),
381
+ onDrop: ({ source }) => {
382
+ const handled = source.data.__pyreon_sortable_handled;
383
+ if (source.data[SORT_ID] === sortableId) performReorder();
384
+ else if (!handled && groupId && source.data[SORT_GROUP] === groupId && options.onCrossListReceive) {
385
+ const item = source.data[SORT_PAYLOAD];
386
+ const sourceSortableId = source.data[SORT_ID];
387
+ const targetIndex = options.items().length;
388
+ options.onCrossListReceive(item, targetIndex);
389
+ _sortableRegistry.get(sourceSortableId)?.onCrossListDrop?.(item);
390
+ }
391
+ batch(() => {
392
+ activeId.set(null);
393
+ overId.set(null);
394
+ overEdge.set(null);
395
+ });
348
396
  }
349
397
  }));
350
398
  const keyHandler = (e) => {
@@ -393,29 +441,37 @@ function useSortable(options) {
393
441
  const allowedEdges = axis === "vertical" ? ["top", "bottom"] : ["left", "right"];
394
442
  const cleanup = combine(draggable({
395
443
  element: el,
396
- getInitialData: () => ({
397
- [SORT_KEY]: key,
398
- [SORT_ID]: sortableId
399
- }),
444
+ getInitialData: () => {
445
+ const item = options.items().find((i) => options.by(i) === key);
446
+ return {
447
+ [SORT_KEY]: key,
448
+ [SORT_ID]: sortableId,
449
+ [SORT_GROUP]: groupId,
450
+ [SORT_PAYLOAD]: groupId ? item : void 0
451
+ };
452
+ },
400
453
  onDragStart: () => activeId.set(key),
401
454
  onDrop: () => {
402
455
  queueMicrotask(() => {
403
- activeId.set(null);
404
- overId.set(null);
405
- overEdge.set(null);
456
+ batch(() => {
457
+ activeId.set(null);
458
+ overId.set(null);
459
+ overEdge.set(null);
460
+ });
406
461
  });
407
462
  }
408
463
  }), dropTargetForElements({
409
464
  element: el,
410
465
  getData: ({ input, element }) => attachClosestEdge({
411
466
  [SORT_KEY]: key,
412
- [SORT_ID]: sortableId
467
+ [SORT_ID]: sortableId,
468
+ [SORT_GROUP]: groupId
413
469
  }, {
414
470
  input,
415
471
  element,
416
472
  allowedEdges
417
473
  }),
418
- canDrop: ({ source }) => source.data[SORT_ID] === sortableId,
474
+ canDrop: ({ source }) => acceptsSource(source),
419
475
  onDragEnter: ({ self }) => {
420
476
  overId.set(key);
421
477
  overEdge.set(extractClosestEdge(self.data));
@@ -428,6 +484,19 @@ function useSortable(options) {
428
484
  overId.set(null);
429
485
  overEdge.set(null);
430
486
  }
487
+ },
488
+ onDrop: ({ source, self }) => {
489
+ if (source.data[SORT_ID] === sortableId) return;
490
+ if (!groupId || source.data[SORT_GROUP] !== groupId || !options.onCrossListReceive) return;
491
+ const item = source.data[SORT_PAYLOAD];
492
+ const edge = extractClosestEdge(self.data);
493
+ const targetIndex = options.items().findIndex((i) => options.by(i) === key);
494
+ if (targetIndex === -1) return;
495
+ const insertAt = edge === "bottom" || edge === "right" ? targetIndex + 1 : Math.max(0, targetIndex);
496
+ options.onCrossListReceive(item, insertAt);
497
+ const sourceSortableId = source.data[SORT_ID];
498
+ _sortableRegistry.get(sourceSortableId)?.onCrossListDrop?.(item);
499
+ source.data.__pyreon_sortable_handled = true;
431
500
  }
432
501
  }));
433
502
  itemCleanups.set(key, cleanup);
@@ -438,9 +507,12 @@ function useSortable(options) {
438
507
  cleanups.length = 0;
439
508
  for (const cleanup of itemCleanups.values()) cleanup();
440
509
  itemCleanups.clear();
441
- activeId.set(null);
442
- overId.set(null);
443
- overEdge.set(null);
510
+ _sortableRegistry.delete(sortableId);
511
+ batch(() => {
512
+ activeId.set(null);
513
+ overId.set(null);
514
+ overEdge.set(null);
515
+ });
444
516
  });
445
517
  return {
446
518
  containerRef,
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/use-drag-monitor.ts","../src/use-draggable.ts","../src/use-droppable.ts","../src/use-file-drop.ts","../src/use-sortable.ts","../src/index.ts"],"sourcesContent":["import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'\nimport { onCleanup, signal } from '@pyreon/reactivity'\nimport type { DragData } from './types'\n\nexport interface UseDragMonitorOptions {\n /** Called on any drag start in the page. */\n onDragStart?: (data: DragData) => void\n /** Called on any drop in the page. */\n onDrop?: (sourceData: DragData, targetData: DragData) => void\n /** Filter which drags to monitor. */\n canMonitor?: (data: DragData) => boolean\n}\n\nexport interface UseDragMonitorResult {\n /** Whether any element is currently being dragged. */\n isDragging: () => boolean\n /** Data of the currently dragging element (null if not dragging). */\n dragData: () => DragData | null\n}\n\n/**\n * Monitor all drag operations on the page.\n * Useful for global drag indicators, analytics, or coordination between\n * multiple drag-and-drop areas.\n *\n * @example\n * ```tsx\n * const { isDragging, dragData } = useDragMonitor({\n * canMonitor: (data) => data.type === \"card\",\n * onDrop: (source, target) => logDrop(source, target),\n * })\n *\n * <Show when={isDragging()}>\n * <div class=\"global-drag-overlay\">\n * Dragging: {() => dragData()?.name}\n * </div>\n * </Show>\n * ```\n */\nexport function useDragMonitor(options?: UseDragMonitorOptions): UseDragMonitorResult {\n if (typeof document === 'undefined') return { isDragging: () => false, dragData: () => null }\n\n const isDragging = signal(false)\n const dragData = signal<DragData | null>(null)\n\n const canMonitorFn = options?.canMonitor\n ? ({ source }: { source: { data: Record<string, unknown> } }) =>\n options.canMonitor?.(source.data as DragData) ?? true\n : null\n\n const cleanup = monitorForElements({\n ...(canMonitorFn ? { canMonitor: canMonitorFn } : {}),\n onDragStart: ({ source }) => {\n isDragging.set(true)\n dragData.set(source.data as DragData)\n options?.onDragStart?.(source.data as DragData)\n },\n onDrop: ({ source, location }) => {\n isDragging.set(false)\n dragData.set(null)\n const targetData = location.current.dropTargets[0]?.data ?? {}\n options?.onDrop?.(source.data as DragData, targetData as DragData)\n },\n })\n\n onCleanup(cleanup)\n\n return { isDragging, dragData }\n}\n","import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'\nimport { onCleanup, signal } from '@pyreon/reactivity'\nimport type { DragData, UseDraggableOptions, UseDraggableResult } from './types'\n\n/**\n * Make an element draggable with signal-driven state.\n *\n * @example\n * ```tsx\n * let cardEl: HTMLElement | null = null\n *\n * const { isDragging } = useDraggable({\n * element: () => cardEl,\n * data: { id: card.id, type: \"card\" },\n * })\n *\n * <div ref={(el) => cardEl = el} class={isDragging() ? \"opacity-50\" : \"\"}>\n * {card.title}\n * </div>\n * ```\n */\nexport function useDraggable<T extends DragData = DragData>(\n options: UseDraggableOptions<T>,\n): UseDraggableResult {\n if (typeof document === 'undefined') return { isDragging: () => false }\n\n const isDragging = signal(false)\n let cleanup: (() => void) | undefined\n\n function setup() {\n if (cleanup) cleanup()\n\n const el = options.element()\n if (!el) return\n\n const resolveData = () =>\n typeof options.data === 'function' ? (options.data as () => T)() : options.data\n\n const handle = options.handle?.()\n cleanup = draggable({\n element: el,\n ...(handle ? { dragHandle: handle } : {}),\n getInitialData: resolveData,\n canDrag: () => {\n const disabled = options.disabled\n if (typeof disabled === 'function') return !disabled()\n return !disabled\n },\n onDragStart: () => {\n isDragging.set(true)\n options.onDragStart?.()\n },\n onDrop: () => {\n isDragging.set(false)\n options.onDragEnd?.()\n },\n })\n }\n\n // Defer setup to next microtask so refs are populated\n queueMicrotask(setup)\n\n onCleanup(() => {\n if (cleanup) cleanup()\n })\n\n return { isDragging }\n}\n","import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'\nimport { onCleanup, signal } from '@pyreon/reactivity'\nimport type { DragData, UseDroppableOptions, UseDroppableResult } from './types'\n\n/**\n * Make an element a drop target with signal-driven state.\n *\n * @example\n * ```tsx\n * let zoneEl: HTMLElement | null = null\n *\n * const { isOver } = useDroppable({\n * element: () => zoneEl,\n * onDrop: (data) => handleDrop(data),\n * canDrop: (data) => data.type === \"card\",\n * })\n *\n * <div ref={(el) => zoneEl = el} class={isOver() ? \"bg-blue-50\" : \"\"}>\n * Drop here\n * </div>\n * ```\n */\nexport function useDroppable<T extends DragData = DragData>(\n options: UseDroppableOptions<T>,\n): UseDroppableResult {\n if (typeof document === 'undefined') return { isOver: () => false }\n\n const isOver = signal(false)\n let cleanup: (() => void) | undefined\n\n function setup() {\n if (cleanup) cleanup()\n\n const el = options.element()\n if (!el) return\n\n cleanup = dropTargetForElements({\n element: el,\n getData: () => {\n if (!options.data) return {}\n return typeof options.data === 'function' ? (options.data as () => T)() : options.data\n },\n canDrop: ({ source }) => {\n if (!options.canDrop) return true\n return options.canDrop(source.data as DragData)\n },\n onDragEnter: ({ source }) => {\n isOver.set(true)\n options.onDragEnter?.(source.data as DragData)\n },\n onDragLeave: () => {\n isOver.set(false)\n options.onDragLeave?.()\n },\n onDrop: ({ source }) => {\n isOver.set(false)\n options.onDrop?.(source.data as DragData)\n },\n })\n }\n\n queueMicrotask(setup)\n\n onCleanup(() => {\n if (cleanup) cleanup()\n })\n\n return { isOver }\n}\n","import {\n dropTargetForExternal,\n monitorForExternal,\n} from '@atlaskit/pragmatic-drag-and-drop/external/adapter'\nimport { containsFiles, getFiles } from '@atlaskit/pragmatic-drag-and-drop/external/file'\nimport { onCleanup, signal } from '@pyreon/reactivity'\n\nexport interface UseFileDropOptions {\n /** Element getter for the drop zone. */\n element: () => HTMLElement | null\n /** Called when files are dropped. */\n onDrop: (files: File[]) => void\n /** Filter accepted file types (e.g. [\"image/*\", \".pdf\"]). */\n accept?: string[]\n /** Maximum number of files. */\n maxFiles?: number\n /** Whether drop is disabled. */\n disabled?: boolean | (() => boolean)\n}\n\nexport interface UseFileDropResult {\n /** Whether files are being dragged over the drop zone. */\n isOver: () => boolean\n /** Whether files are being dragged anywhere on the page. */\n isDraggingFiles: () => boolean\n}\n\n/**\n * File drop zone with signal-driven state.\n * Uses the native file drag events via pragmatic-drag-and-drop.\n *\n * @example\n * ```tsx\n * let dropZone: HTMLElement | null = null\n *\n * const { isOver, isDraggingFiles } = useFileDrop({\n * element: () => dropZone,\n * accept: [\"image/*\", \".pdf\"],\n * maxFiles: 5,\n * onDrop: (files) => upload(files),\n * })\n *\n * <div\n * ref={(el) => dropZone = el}\n * class={isOver() ? \"drop-active\" : isDraggingFiles() ? \"drop-ready\" : \"\"}\n * >\n * Drop files here\n * </div>\n * ```\n */\nexport function useFileDrop(options: UseFileDropOptions): UseFileDropResult {\n if (typeof document === 'undefined') return { isOver: () => false, isDraggingFiles: () => false }\n\n const isOver = signal(false)\n const isDraggingFiles = signal(false)\n let cleanup: (() => void) | undefined\n\n function matchesAccept(file: File, accept: string[]): boolean {\n return accept.some((pattern) => {\n if (pattern.startsWith('.')) {\n return file.name.toLowerCase().endsWith(pattern.toLowerCase())\n }\n if (pattern.endsWith('/*')) {\n return file.type.startsWith(pattern.slice(0, -1))\n }\n return file.type === pattern\n })\n }\n\n function setup() {\n if (cleanup) cleanup()\n\n const el = options.element()\n if (!el) return\n\n const cleanups: (() => void)[] = []\n\n // Monitor for file drags anywhere on the page\n cleanups.push(\n monitorForExternal({\n canMonitor: ({ source }) => containsFiles({ source }),\n onDragStart: () => isDraggingFiles.set(true),\n onDrop: () => isDraggingFiles.set(false),\n }),\n )\n\n // Drop target on the specific element\n cleanups.push(\n dropTargetForExternal({\n element: el,\n canDrop: ({ source }) => {\n const disabled = options.disabled\n if (typeof disabled === 'function' ? disabled() : disabled) return false\n return containsFiles({ source })\n },\n onDragEnter: () => isOver.set(true),\n onDragLeave: () => isOver.set(false),\n onDrop: ({ source }) => {\n isOver.set(false)\n isDraggingFiles.set(false)\n\n let files = getFiles({ source })\n\n // Filter by accept\n if (options.accept && options.accept.length > 0) {\n files = files.filter((f) => matchesAccept(f, options.accept as string[]))\n }\n\n // Limit count\n if (options.maxFiles && files.length > options.maxFiles) {\n files = files.slice(0, options.maxFiles)\n }\n\n if (files.length > 0) {\n options.onDrop(files)\n }\n },\n }),\n )\n\n cleanup = () => {\n for (const fn of cleanups) fn()\n }\n }\n\n queueMicrotask(setup)\n\n onCleanup(() => {\n if (cleanup) cleanup()\n })\n\n return { isOver, isDraggingFiles }\n}\n","import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine'\nimport { draggable, dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'\nimport { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element'\nimport {\n attachClosestEdge,\n type Edge,\n extractClosestEdge,\n} from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge'\nimport { onCleanup, signal } from '@pyreon/reactivity'\nimport type { DropEdge, UseSortableOptions, UseSortableResult } from './types'\n\nconst SORT_KEY = '__pyreon_sortable_key'\nconst SORT_ID = '__pyreon_sortable_id'\n\nlet _sortableCounter = 0\n\n/**\n * Sortable list with signal-driven state, auto-scroll, and edge detection.\n *\n * Features:\n * - Keyed drag items matching `<For by={...}>` pattern\n * - Auto-scroll when dragging near container edges\n * - Closest-edge detection (drop above/below or left/right)\n * - Axis constraint (vertical/horizontal)\n * - Keyboard reordering (Alt+Arrow keys)\n *\n * @example\n * ```tsx\n * const items = signal([\n * { id: \"1\", name: \"Alice\" },\n * { id: \"2\", name: \"Bob\" },\n * { id: \"3\", name: \"Charlie\" },\n * ])\n *\n * const { containerRef, itemRef, activeId, overId, overEdge } = useSortable({\n * items,\n * by: (item) => item.id,\n * onReorder: (newItems) => items.set(newItems),\n * })\n *\n * <ul ref={containerRef}>\n * <For each={items()} by={item => item.id}>\n * {(item) => (\n * <li\n * ref={itemRef(item.id)}\n * class={activeId() === item.id ? \"dragging\" : \"\"}\n * style={overId() === item.id ? `border-${overEdge()}: 2px solid blue` : \"\"}\n * >\n * {item.name}\n * </li>\n * )}\n * </For>\n * </ul>\n * ```\n */\nexport function useSortable<T>(options: UseSortableOptions<T>): UseSortableResult {\n if (typeof document === 'undefined') {\n const noop = (_el: HTMLElement | null) => {}\n return {\n containerRef: noop,\n itemRef: () => noop,\n activeId: () => null,\n overId: () => null,\n overEdge: () => null,\n }\n }\n\n const sortableId = `sortable-${++_sortableCounter}`\n const activeId = signal<string | number | null>(null)\n const overId = signal<string | number | null>(null)\n const overEdge = signal<DropEdge | null>(null)\n const axis = options.axis ?? 'vertical'\n\n // Shared (container-level) pdnd cleanups — drained once on unmount.\n const cleanups: (() => void)[] = []\n // Per-item pdnd cleanups, keyed by sort key. Disposed individually on\n // item unmount / re-register so a churning list doesn't accumulate\n // dead registrations for the sortable's whole lifetime.\n const itemCleanups = new Map<string | number, () => void>()\n\n /** Perform the reorder based on current active/over/edge state. */\n function performReorder() {\n const dragId = activeId.peek()\n const dropId = overId.peek()\n const edge = overEdge.peek()\n if (dragId == null || dropId == null || dragId === dropId) return\n\n const currentItems = options.items()\n const dragIndex = currentItems.findIndex((item) => options.by(item) === dragId)\n const dropIndex = currentItems.findIndex((item) => options.by(item) === dropId)\n if (dragIndex === -1 || dropIndex === -1) return\n\n const reordered = [...currentItems]\n const [moved] = reordered.splice(dragIndex, 1)\n if (!moved) return\n\n // Determine insert position based on closest edge\n const rawInsert =\n edge === 'bottom' || edge === 'right'\n ? dropIndex >= dragIndex\n ? dropIndex\n : dropIndex + 1\n : dropIndex <= dragIndex\n ? dropIndex\n : dropIndex - 1\n const insertAt = Math.max(0, Math.min(rawInsert, reordered.length))\n\n reordered.splice(insertAt, 0, moved)\n options.onReorder(reordered)\n }\n\n function containerRef(el: HTMLElement | null) {\n // Pyreon's runtime calls refs with `null` on unmount; the per-element\n // pdnd cleanups are already registered via `onCleanup` below, so we\n // can no-op the unmount-time call.\n if (!el) return\n // Auto-scroll when dragging near container edges\n cleanups.push(\n autoScrollForElements({\n element: el,\n canScroll: ({ source }) => source.data[SORT_ID] === sortableId,\n }),\n )\n\n // Container is a drop target for reorder finalization\n cleanups.push(\n dropTargetForElements({\n element: el,\n getData: () => ({ [SORT_ID]: sortableId }),\n canDrop: ({ source }) => source.data[SORT_ID] === sortableId,\n onDrop: () => {\n performReorder()\n activeId.set(null)\n overId.set(null)\n overEdge.set(null)\n },\n }),\n )\n\n // Keyboard reordering: Alt+Arrow keys\n const keyHandler = (e: KeyboardEvent) => {\n if (!e.altKey) return\n\n const isUp = axis === 'vertical' ? e.key === 'ArrowUp' : e.key === 'ArrowLeft'\n const isDown = axis === 'vertical' ? e.key === 'ArrowDown' : e.key === 'ArrowRight'\n if (!isUp && !isDown) return\n\n const focused = document.activeElement as HTMLElement | null\n if (!focused || !el.contains(focused)) return\n\n const focusedKey = focused.dataset.pyreonSortKey\n if (!focusedKey) return\n\n e.preventDefault()\n\n const currentItems = options.items()\n const currentIndex = currentItems.findIndex((item) => String(options.by(item)) === focusedKey)\n if (currentIndex === -1) return\n\n const targetIndex = isUp ? currentIndex - 1 : currentIndex + 1\n if (targetIndex < 0 || targetIndex >= currentItems.length) return\n\n const reordered = [...currentItems]\n const temp = reordered[currentIndex]\n reordered[currentIndex] = reordered[targetIndex] as T\n reordered[targetIndex] = temp as T\n options.onReorder(reordered)\n\n // Restore focus after DOM update\n requestAnimationFrame(() => {\n const items = el.querySelectorAll('[data-pyreon-sort-key]')\n for (const item of items) {\n if ((item as HTMLElement).dataset.pyreonSortKey === focusedKey) {\n ;(item as HTMLElement).focus()\n break\n }\n }\n })\n }\n\n el.addEventListener('keydown', keyHandler)\n cleanups.push(() => el.removeEventListener('keydown', keyHandler))\n }\n\n function itemRef(key: string | number): (el: HTMLElement | null) => void {\n return (el: HTMLElement | null) => {\n // Per-key disposal. The ref fires with the element on mount and\n // with `null` on unmount. The old code pushed every registration\n // onto the shared `cleanups[]` and made the null branch a pure\n // no-op — so for a `<For>`-rendered sortable (the documented usage:\n // todo list / kanban) every removed item's pdnd `draggable` /\n // `dropTargetForElements` registration (and its pointer/drag\n // listeners on the now-detached node) leaked until the WHOLE\n // sortable unmounted. Dispose the prior registration for this key\n // on BOTH unmount (el === null) and re-registration (same key,\n // new element) so the live set tracks live items, not all-ever.\n const prev = itemCleanups.get(key)\n if (prev) {\n prev()\n itemCleanups.delete(key)\n }\n if (!el) return\n el.dataset.pyreonSortKey = String(key)\n if (!el.hasAttribute('tabindex')) el.setAttribute('tabindex', '0')\n el.setAttribute('role', 'listitem')\n el.setAttribute('aria-roledescription', 'sortable item')\n\n const allowedEdges: Edge[] = axis === 'vertical' ? ['top', 'bottom'] : ['left', 'right']\n\n const cleanup = combine(\n draggable({\n element: el,\n getInitialData: () => ({\n [SORT_KEY]: key,\n [SORT_ID]: sortableId,\n }),\n onDragStart: () => activeId.set(key),\n onDrop: () => {\n queueMicrotask(() => {\n activeId.set(null)\n overId.set(null)\n overEdge.set(null)\n })\n },\n }),\n dropTargetForElements({\n element: el,\n getData: ({ input, element }) =>\n attachClosestEdge(\n { [SORT_KEY]: key, [SORT_ID]: sortableId },\n { input, element, allowedEdges },\n ),\n canDrop: ({ source }) => source.data[SORT_ID] === sortableId,\n onDragEnter: ({ self }) => {\n overId.set(key)\n overEdge.set(extractClosestEdge(self.data) as DropEdge | null)\n },\n onDrag: ({ self }) => {\n overEdge.set(extractClosestEdge(self.data) as DropEdge | null)\n },\n onDragLeave: () => {\n if (overId.peek() === key) {\n overId.set(null)\n overEdge.set(null)\n }\n },\n }),\n )\n\n itemCleanups.set(key, cleanup)\n }\n }\n\n onCleanup(() => {\n for (const cleanup of cleanups) cleanup()\n cleanups.length = 0\n for (const cleanup of itemCleanups.values()) cleanup()\n itemCleanups.clear()\n activeId.set(null)\n overId.set(null)\n overEdge.set(null)\n })\n\n return { containerRef, itemRef, activeId, overId, overEdge }\n}\n","import { registerSingleton } from '@pyreon/reactivity'\n\n// Singleton sentinel — fail-loud detection of duplicate @pyreon/dnd\n// instances in the same heap. See @pyreon/reactivity/singleton-sentinel for\n// full rationale. Hardcoded version is acceptable here — it's a diagnostic\n// aid, not a load-bearing identity check.\nregisterSingleton('@pyreon/dnd', '0.24.6', import.meta.url)\n\nexport type {\n DragData,\n DropEdge,\n DropLocation,\n UseDraggableOptions,\n UseDraggableResult,\n UseDroppableOptions,\n UseDroppableResult,\n UseSortableOptions,\n UseSortableResult,\n} from './types'\n\nexport type { UseDragMonitorOptions, UseDragMonitorResult } from './use-drag-monitor'\nexport { useDragMonitor } from './use-drag-monitor'\n\nexport { useDraggable } from './use-draggable'\nexport { useDroppable } from './use-droppable'\nexport type { UseFileDropOptions, UseFileDropResult } from './use-file-drop'\nexport { useFileDrop } from './use-file-drop'\nexport { useSortable } from './use-sortable'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,eAAe,SAAuD;CACpF,IAAI,OAAO,aAAa,aAAa,OAAO;EAAE,kBAAkB;EAAO,gBAAgB;CAAK;CAE5F,MAAM,aAAa,OAAO,KAAK;CAC/B,MAAM,WAAW,OAAwB,IAAI;CAE7C,MAAM,eAAe,SAAS,cACzB,EAAE,aACD,QAAQ,aAAa,OAAO,IAAgB,KAAK,OACnD;CAiBJ,UAfgB,mBAAmB;EACjC,GAAI,eAAe,EAAE,YAAY,aAAa,IAAI,CAAC;EACnD,cAAc,EAAE,aAAa;GAC3B,WAAW,IAAI,IAAI;GACnB,SAAS,IAAI,OAAO,IAAgB;GACpC,SAAS,cAAc,OAAO,IAAgB;EAChD;EACA,SAAS,EAAE,QAAQ,eAAe;GAChC,WAAW,IAAI,KAAK;GACpB,SAAS,IAAI,IAAI;GACjB,MAAM,aAAa,SAAS,QAAQ,YAAY,IAAI,QAAQ,CAAC;GAC7D,SAAS,SAAS,OAAO,MAAkB,UAAsB;EACnE;CACF,CAEgB,CAAC;CAEjB,OAAO;EAAE;EAAY;CAAS;AAChC;;;;;;;;;;;;;;;;;;;;;AC/CA,SAAgB,aACd,SACoB;CACpB,IAAI,OAAO,aAAa,aAAa,OAAO,EAAE,kBAAkB,MAAM;CAEtE,MAAM,aAAa,OAAO,KAAK;CAC/B,IAAI;CAEJ,SAAS,QAAQ;EACf,IAAI,SAAS,QAAQ;EAErB,MAAM,KAAK,QAAQ,QAAQ;EAC3B,IAAI,CAAC,IAAI;EAET,MAAM,oBACJ,OAAO,QAAQ,SAAS,aAAc,QAAQ,K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I;KACnB,CAAC;IACH;GACF,CAAC,GACD,sBAAsB;IACpB,SAAS;IACT,UAAU,EAAE,OAAO,cACjB,kBACE;MAAG,WAAW;MAAM,UAAU;IAAW,GACzC;KAAE;KAAO;KAAS;IAAa,CACjC;IACF,UAAU,EAAE,aAAa,OAAO,KAAK,aAAa;IAClD,cAAc,EAAE,WAAW;KACzB,OAAO,IAAI,GAAG;KACd,SAAS,IAAI,mBAAmB,KAAK,IAAI,CAAoB;IAC/D;IACA,SAAS,EAAE,WAAW;KACpB,SAAS,IAAI,mBAAmB,KAAK,IAAI,CAAoB;IAC/D;IACA,mBAAmB;KACjB,IAAI,OAAO,KAAK,MAAM,KAAK;MACzB,OAAO,IAAI,IAAI;MACf,SAAS,IAAI,IAAI;KACnB;IACF;GACF,CAAC,CACH;GAEA,aAAa,IAAI,KAAK,OAAO;EAC/B;CACF;CAEA,gBAAgB;EACd,KAAK,MAAM,WAAW,UAAU,QAAQ;EACxC,SAAS,SAAS;EAClB,KAAK,MAAM,WAAW,aAAa,OAAO,GAAG,QAAQ;EACrD,aAAa,MAAM;EACnB,SAAS,IAAI,IAAI;EACjB,OAAO,IAAI,IAAI;EACf,SAAS,IAAI,IAAI;CACnB,CAAC;CAED,OAAO;EAAE;EAAc;EAAS;EAAU;EAAQ;CAAS;AAC7D;;;;AClQA,kBAAkB,eAAe,UAAU,OAAO,KAAK,GAAG"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/use-drag-monitor.ts","../src/use-draggable.ts","../src/use-droppable.ts","../src/use-file-drop.ts","../src/use-sortable.ts","../src/index.ts"],"sourcesContent":["import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'\nimport { batch, onCleanup, signal } from '@pyreon/reactivity'\nimport type { DragData } from './types'\n\nexport interface UseDragMonitorOptions {\n /** Called on any drag start in the page. */\n onDragStart?: (data: DragData) => void\n /** Called on any drop in the page. */\n onDrop?: (sourceData: DragData, targetData: DragData) => void\n /** Filter which drags to monitor. */\n canMonitor?: (data: DragData) => boolean\n}\n\nexport interface UseDragMonitorResult {\n /** Whether any element is currently being dragged. */\n isDragging: () => boolean\n /** Data of the currently dragging element (null if not dragging). */\n dragData: () => DragData | null\n}\n\n/**\n * Monitor all drag operations on the page.\n * Useful for global drag indicators, analytics, or coordination between\n * multiple drag-and-drop areas.\n *\n * @example\n * ```tsx\n * const { isDragging, dragData } = useDragMonitor({\n * canMonitor: (data) => data.type === \"card\",\n * onDrop: (source, target) => logDrop(source, target),\n * })\n *\n * <Show when={isDragging()}>\n * <div class=\"global-drag-overlay\">\n * Dragging: {() => dragData()?.name}\n * </div>\n * </Show>\n * ```\n */\nexport function useDragMonitor(options?: UseDragMonitorOptions): UseDragMonitorResult {\n if (typeof document === 'undefined') return { isDragging: () => false, dragData: () => null }\n\n const isDragging = signal(false)\n const dragData = signal<DragData | null>(null)\n\n const canMonitorFn = options?.canMonitor\n ? ({ source }: { source: { data: Record<string, unknown> } }) =>\n options.canMonitor?.(source.data as DragData) ?? true\n : null\n\n const cleanup = monitorForElements({\n ...(canMonitorFn ? { canMonitor: canMonitorFn } : {}),\n onDragStart: ({ source }) => {\n // batch() so subscribers to isDragging + dragData get notified once,\n // not twice. Drag events fire frequently; doubling subscriber work\n // per event compounds visibly on UIs with many drag-monitor consumers.\n batch(() => {\n isDragging.set(true)\n dragData.set(source.data as DragData)\n })\n options?.onDragStart?.(source.data as DragData)\n },\n onDrop: ({ source, location }) => {\n batch(() => {\n isDragging.set(false)\n dragData.set(null)\n })\n const targetData = location.current.dropTargets[0]?.data ?? {}\n options?.onDrop?.(source.data as DragData, targetData as DragData)\n },\n })\n\n onCleanup(cleanup)\n\n return { isDragging, dragData }\n}\n","import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'\nimport { onCleanup, signal } from '@pyreon/reactivity'\nimport type { DragData, UseDraggableOptions, UseDraggableResult } from './types'\n\n/**\n * Make an element draggable with signal-driven state.\n *\n * @example\n * ```tsx\n * let cardEl: HTMLElement | null = null\n *\n * const { isDragging } = useDraggable({\n * element: () => cardEl,\n * data: { id: card.id, type: \"card\" },\n * })\n *\n * <div ref={(el) => cardEl = el} class={isDragging() ? \"opacity-50\" : \"\"}>\n * {card.title}\n * </div>\n * ```\n */\nexport function useDraggable<T extends DragData = DragData>(\n options: UseDraggableOptions<T>,\n): UseDraggableResult {\n if (typeof document === 'undefined') return { isDragging: () => false }\n\n const isDragging = signal(false)\n let cleanup: (() => void) | undefined\n let disposed = false\n\n function setup() {\n // The hook may have unmounted before this deferred (queueMicrotask) setup\n // ran. onCleanup fired with `cleanup` still undefined (a no-op), so a\n // registration created here would never be torn down — bail instead.\n if (disposed) return\n if (cleanup) cleanup()\n\n const el = options.element()\n if (!el) return\n\n const resolveData = () =>\n typeof options.data === 'function' ? (options.data as () => T)() : options.data\n\n const handle = options.handle?.()\n cleanup = draggable({\n element: el,\n ...(handle ? { dragHandle: handle } : {}),\n getInitialData: resolveData,\n canDrag: () => {\n const disabled = options.disabled\n if (typeof disabled === 'function') return !disabled()\n return !disabled\n },\n onDragStart: () => {\n isDragging.set(true)\n options.onDragStart?.()\n },\n onDrop: () => {\n isDragging.set(false)\n options.onDragEnd?.()\n },\n })\n }\n\n // Defer setup to next microtask so refs are populated\n queueMicrotask(setup)\n\n onCleanup(() => {\n disposed = true\n if (cleanup) cleanup()\n })\n\n return { isDragging }\n}\n","import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'\nimport { onCleanup, signal } from '@pyreon/reactivity'\nimport type { DragData, UseDroppableOptions, UseDroppableResult } from './types'\n\n/**\n * Make an element a drop target with signal-driven state.\n *\n * @example\n * ```tsx\n * let zoneEl: HTMLElement | null = null\n *\n * const { isOver } = useDroppable({\n * element: () => zoneEl,\n * onDrop: (data) => handleDrop(data),\n * canDrop: (data) => data.type === \"card\",\n * })\n *\n * <div ref={(el) => zoneEl = el} class={isOver() ? \"bg-blue-50\" : \"\"}>\n * Drop here\n * </div>\n * ```\n */\nexport function useDroppable<T extends DragData = DragData>(\n options: UseDroppableOptions<T>,\n): UseDroppableResult {\n if (typeof document === 'undefined') return { isOver: () => false }\n\n const isOver = signal(false)\n let cleanup: (() => void) | undefined\n let disposed = false\n\n function setup() {\n // Unmounted before this deferred setup ran — don't register a target that\n // onCleanup (already fired with `cleanup` undefined) can never tear down.\n if (disposed) return\n if (cleanup) cleanup()\n\n const el = options.element()\n if (!el) return\n\n cleanup = dropTargetForElements({\n element: el,\n getData: () => {\n if (!options.data) return {}\n return typeof options.data === 'function' ? (options.data as () => T)() : options.data\n },\n canDrop: ({ source }) => {\n if (!options.canDrop) return true\n return options.canDrop(source.data as DragData)\n },\n onDragEnter: ({ source }) => {\n isOver.set(true)\n options.onDragEnter?.(source.data as DragData)\n },\n onDragLeave: () => {\n isOver.set(false)\n options.onDragLeave?.()\n },\n onDrop: ({ source }) => {\n isOver.set(false)\n options.onDrop?.(source.data as DragData)\n },\n })\n }\n\n queueMicrotask(setup)\n\n onCleanup(() => {\n disposed = true\n if (cleanup) cleanup()\n })\n\n return { isOver }\n}\n","import {\n dropTargetForExternal,\n monitorForExternal,\n} from '@atlaskit/pragmatic-drag-and-drop/external/adapter'\nimport { containsFiles, getFiles } from '@atlaskit/pragmatic-drag-and-drop/external/file'\nimport { batch, onCleanup, signal } from '@pyreon/reactivity'\n\nexport interface UseFileDropOptions {\n /** Element getter for the drop zone. */\n element: () => HTMLElement | null\n /** Called when files are dropped. */\n onDrop: (files: File[]) => void\n /** Filter accepted file types (e.g. [\"image/*\", \".pdf\"]). */\n accept?: string[]\n /** Maximum number of files. */\n maxFiles?: number\n /** Whether drop is disabled. */\n disabled?: boolean | (() => boolean)\n}\n\nexport interface UseFileDropResult {\n /** Whether files are being dragged over the drop zone. */\n isOver: () => boolean\n /** Whether files are being dragged anywhere on the page. */\n isDraggingFiles: () => boolean\n}\n\n/**\n * File drop zone with signal-driven state.\n * Uses the native file drag events via pragmatic-drag-and-drop.\n *\n * @example\n * ```tsx\n * let dropZone: HTMLElement | null = null\n *\n * const { isOver, isDraggingFiles } = useFileDrop({\n * element: () => dropZone,\n * accept: [\"image/*\", \".pdf\"],\n * maxFiles: 5,\n * onDrop: (files) => upload(files),\n * })\n *\n * <div\n * ref={(el) => dropZone = el}\n * class={isOver() ? \"drop-active\" : isDraggingFiles() ? \"drop-ready\" : \"\"}\n * >\n * Drop files here\n * </div>\n * ```\n */\nexport function useFileDrop(options: UseFileDropOptions): UseFileDropResult {\n if (typeof document === 'undefined') return { isOver: () => false, isDraggingFiles: () => false }\n\n const isOver = signal(false)\n const isDraggingFiles = signal(false)\n let cleanup: (() => void) | undefined\n let disposed = false\n\n function matchesAccept(file: File, accept: string[]): boolean {\n return accept.some((pattern) => {\n if (pattern.startsWith('.')) {\n return file.name.toLowerCase().endsWith(pattern.toLowerCase())\n }\n if (pattern.endsWith('/*')) {\n return file.type.startsWith(pattern.slice(0, -1))\n }\n return file.type === pattern\n })\n }\n\n function setup() {\n // Unmounted before this deferred setup ran — don't register a drop target\n // that onCleanup (already fired with `cleanup` undefined) can never remove.\n if (disposed) return\n if (cleanup) cleanup()\n\n const el = options.element()\n if (!el) return\n\n const cleanups: (() => void)[] = []\n\n // Monitor for file drags anywhere on the page\n cleanups.push(\n monitorForExternal({\n canMonitor: ({ source }) => containsFiles({ source }),\n onDragStart: () => isDraggingFiles.set(true),\n onDrop: () => isDraggingFiles.set(false),\n }),\n )\n\n // Drop target on the specific element\n cleanups.push(\n dropTargetForExternal({\n element: el,\n canDrop: ({ source }) => {\n const disabled = options.disabled\n if (typeof disabled === 'function' ? disabled() : disabled) return false\n return containsFiles({ source })\n },\n onDragEnter: () => isOver.set(true),\n onDragLeave: () => isOver.set(false),\n onDrop: ({ source }) => {\n // batch() so onDrop subscribers don't get notified twice\n // (isOver + isDraggingFiles) per file-drop event.\n batch(() => {\n isOver.set(false)\n isDraggingFiles.set(false)\n })\n\n let files = getFiles({ source })\n\n // Filter by accept\n if (options.accept && options.accept.length > 0) {\n files = files.filter((f) => matchesAccept(f, options.accept as string[]))\n }\n\n // Limit count\n if (options.maxFiles && files.length > options.maxFiles) {\n files = files.slice(0, options.maxFiles)\n }\n\n if (files.length > 0) {\n options.onDrop(files)\n }\n },\n }),\n )\n\n cleanup = () => {\n for (const fn of cleanups) fn()\n }\n }\n\n queueMicrotask(setup)\n\n onCleanup(() => {\n disposed = true\n if (cleanup) cleanup()\n })\n\n return { isOver, isDraggingFiles }\n}\n","import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine'\nimport { draggable, dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'\nimport { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element'\nimport {\n attachClosestEdge,\n type Edge,\n extractClosestEdge,\n} from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge'\nimport { batch, onCleanup, signal } from '@pyreon/reactivity'\nimport type { DropEdge, UseSortableOptions, UseSortableResult } from './types'\n\nconst SORT_KEY = '__pyreon_sortable_key'\nconst SORT_ID = '__pyreon_sortable_id'\nconst SORT_GROUP = '__pyreon_sortable_group'\nconst SORT_PAYLOAD = '__pyreon_sortable_payload'\n\nlet _sortableCounter = 0\n\n// Module-level registry of live sortable instances — used to dispatch\n// cross-list drop notifications from the destination back to the source\n// (W18). Keyed by sortableId.\nconst _sortableRegistry = new Map<\n string,\n {\n groupId: string | undefined\n onCrossListDrop: ((item: unknown) => void) | undefined\n }\n>()\n\n/**\n * Sortable list with signal-driven state, auto-scroll, and edge detection.\n *\n * Features:\n * - Keyed drag items matching `<For by={...}>` pattern\n * - Auto-scroll when dragging near container edges\n * - Closest-edge detection (drop above/below or left/right)\n * - Axis constraint (vertical/horizontal)\n * - Keyboard reordering (Alt+Arrow keys)\n * - Optional cross-list `groupId` for Trello/Notion/Linear board layouts\n * (W18) — share the same `groupId` between two\n * sortable instances and items can be dragged between them. The\n * source's `onCrossListDrop(item)` removes; the destination's\n * `onCrossListReceive(item, index)` inserts.\n *\n * @example\n * ```tsx\n * const items = signal([\n * { id: \"1\", name: \"Alice\" },\n * { id: \"2\", name: \"Bob\" },\n * { id: \"3\", name: \"Charlie\" },\n * ])\n *\n * const { containerRef, itemRef, activeId, overId, overEdge } = useSortable({\n * items,\n * by: (item) => item.id,\n * onReorder: (newItems) => items.set(newItems),\n * })\n *\n * <ul ref={containerRef}>\n * <For each={items()} by={item => item.id}>\n * {(item) => (\n * <li\n * ref={itemRef(item.id)}\n * class={activeId() === item.id ? \"dragging\" : \"\"}\n * style={overId() === item.id ? `border-${overEdge()}: 2px solid blue` : \"\"}\n * >\n * {item.name}\n * </li>\n * )}\n * </For>\n * </ul>\n * ```\n */\nexport function useSortable<T>(options: UseSortableOptions<T>): UseSortableResult {\n if (typeof document === 'undefined') {\n const noop = (_el: HTMLElement | null) => {}\n return {\n containerRef: noop,\n itemRef: () => noop,\n activeId: () => null,\n overId: () => null,\n overEdge: () => null,\n }\n }\n\n const sortableId = `sortable-${++_sortableCounter}`\n const activeId = signal<string | number | null>(null)\n const overId = signal<string | number | null>(null)\n const overEdge = signal<DropEdge | null>(null)\n const axis = options.axis ?? 'vertical'\n const groupId = options.groupId\n\n // Register so siblings in the same group can call our onCrossListDrop\n // when they receive one of our items.\n _sortableRegistry.set(sortableId, {\n groupId,\n onCrossListDrop: options.onCrossListDrop as ((item: unknown) => void) | undefined,\n })\n\n // Shared (container-level) pdnd cleanups — drained once on unmount.\n const cleanups: (() => void)[] = []\n // Per-item pdnd cleanups, keyed by sort key. Disposed individually on\n // item unmount / re-register so a churning list doesn't accumulate\n // dead registrations for the sortable's whole lifetime.\n const itemCleanups = new Map<string | number, () => void>()\n\n /** Perform the reorder based on current active/over/edge state. */\n function performReorder() {\n const dragId = activeId.peek()\n const dropId = overId.peek()\n const edge = overEdge.peek()\n if (dragId == null || dropId == null || dragId === dropId) return\n\n const currentItems = options.items()\n const dragIndex = currentItems.findIndex((item) => options.by(item) === dragId)\n const dropIndex = currentItems.findIndex((item) => options.by(item) === dropId)\n if (dragIndex === -1 || dropIndex === -1) return\n\n const reordered = [...currentItems]\n const [moved] = reordered.splice(dragIndex, 1)\n if (!moved) return\n\n // Determine insert position based on closest edge\n const rawInsert =\n edge === 'bottom' || edge === 'right'\n ? dropIndex >= dragIndex\n ? dropIndex\n : dropIndex + 1\n : dropIndex <= dragIndex\n ? dropIndex\n : dropIndex - 1\n const insertAt = Math.max(0, Math.min(rawInsert, reordered.length))\n\n reordered.splice(insertAt, 0, moved)\n options.onReorder(reordered)\n }\n\n /** Returns true when `source` belongs to this sortable or to a sibling\n * in the same `groupId`. */\n function acceptsSource(source: { data: Record<string, unknown> }): boolean {\n if (source.data[SORT_ID] === sortableId) return true\n if (groupId && source.data[SORT_GROUP] === groupId) return true\n return false\n }\n\n function containerRef(el: HTMLElement | null) {\n // Pyreon's runtime calls refs with `null` on unmount; the per-element\n // pdnd cleanups are already registered via `onCleanup` below, so we\n // can no-op the unmount-time call.\n if (!el) return\n // Auto-scroll when dragging near container edges\n cleanups.push(\n autoScrollForElements({\n element: el,\n canScroll: ({ source }) => acceptsSource(source),\n }),\n )\n\n // Container is a drop target for reorder finalization OR for\n // appending a cross-list item at the end of this column.\n cleanups.push(\n dropTargetForElements({\n element: el,\n getData: () => ({ [SORT_ID]: sortableId, [SORT_GROUP]: groupId }),\n canDrop: ({ source }) => acceptsSource(source),\n onDrop: ({ source }) => {\n // Item-level dropTarget for cross-list drops marks the source\n // data as handled — container skips so we don't insert twice.\n const handled = (source.data as Record<string, unknown>)\n .__pyreon_sortable_handled\n if (source.data[SORT_ID] === sortableId) {\n // Same-list drop on container edge → reorder finalization.\n performReorder()\n } else if (\n !handled &&\n groupId &&\n source.data[SORT_GROUP] === groupId &&\n options.onCrossListReceive\n ) {\n // Cross-list drop on the container itself (not on an item) →\n // append to the end of this column.\n const item = source.data[SORT_PAYLOAD] as T\n const sourceSortableId = source.data[SORT_ID] as string\n const targetIndex = options.items().length\n options.onCrossListReceive(item, targetIndex)\n const sourceInstance = _sortableRegistry.get(sourceSortableId)\n sourceInstance?.onCrossListDrop?.(item)\n }\n // batch() the 3-signal reset so subscribers reading any of\n // activeId/overId/overEdge get notified once per drop, not\n // three times. Fires on every container-level drop.\n batch(() => {\n activeId.set(null)\n overId.set(null)\n overEdge.set(null)\n })\n },\n }),\n )\n\n // Keyboard reordering: Alt+Arrow keys\n const keyHandler = (e: KeyboardEvent) => {\n if (!e.altKey) return\n\n const isUp = axis === 'vertical' ? e.key === 'ArrowUp' : e.key === 'ArrowLeft'\n const isDown = axis === 'vertical' ? e.key === 'ArrowDown' : e.key === 'ArrowRight'\n if (!isUp && !isDown) return\n\n const focused = document.activeElement as HTMLElement | null\n if (!focused || !el.contains(focused)) return\n\n const focusedKey = focused.dataset.pyreonSortKey\n if (!focusedKey) return\n\n e.preventDefault()\n\n const currentItems = options.items()\n const currentIndex = currentItems.findIndex((item) => String(options.by(item)) === focusedKey)\n if (currentIndex === -1) return\n\n const targetIndex = isUp ? currentIndex - 1 : currentIndex + 1\n if (targetIndex < 0 || targetIndex >= currentItems.length) return\n\n const reordered = [...currentItems]\n const temp = reordered[currentIndex]\n reordered[currentIndex] = reordered[targetIndex] as T\n reordered[targetIndex] = temp as T\n options.onReorder(reordered)\n\n // Restore focus after DOM update\n requestAnimationFrame(() => {\n const items = el.querySelectorAll('[data-pyreon-sort-key]')\n for (const item of items) {\n if ((item as HTMLElement).dataset.pyreonSortKey === focusedKey) {\n ;(item as HTMLElement).focus()\n break\n }\n }\n })\n }\n\n el.addEventListener('keydown', keyHandler)\n cleanups.push(() => el.removeEventListener('keydown', keyHandler))\n }\n\n function itemRef(key: string | number): (el: HTMLElement | null) => void {\n return (el: HTMLElement | null) => {\n // Per-key disposal. The ref fires with the element on mount and\n // with `null` on unmount. The old code pushed every registration\n // onto the shared `cleanups[]` and made the null branch a pure\n // no-op — so for a `<For>`-rendered sortable (the documented usage:\n // todo list / kanban) every removed item's pdnd `draggable` /\n // `dropTargetForElements` registration (and its pointer/drag\n // listeners on the now-detached node) leaked until the WHOLE\n // sortable unmounted. Dispose the prior registration for this key\n // on BOTH unmount (el === null) and re-registration (same key,\n // new element) so the live set tracks live items, not all-ever.\n const prev = itemCleanups.get(key)\n if (prev) {\n prev()\n itemCleanups.delete(key)\n }\n if (!el) return\n el.dataset.pyreonSortKey = String(key)\n if (!el.hasAttribute('tabindex')) el.setAttribute('tabindex', '0')\n el.setAttribute('role', 'listitem')\n el.setAttribute('aria-roledescription', 'sortable item')\n\n const allowedEdges: Edge[] = axis === 'vertical' ? ['top', 'bottom'] : ['left', 'right']\n\n const cleanup = combine(\n draggable({\n element: el,\n getInitialData: () => {\n const currentItems = options.items()\n const item = currentItems.find((i) => options.by(i) === key)\n return {\n [SORT_KEY]: key,\n [SORT_ID]: sortableId,\n [SORT_GROUP]: groupId,\n // Carry the actual item value when groupId is set so a\n // sibling sortable's onDrop can receive it without a\n // separate registry lookup. Plain reference (pdnd doesn't\n // serialize) — safe within a single document.\n [SORT_PAYLOAD]: groupId ? item : undefined,\n }\n },\n onDragStart: () => activeId.set(key),\n onDrop: () => {\n queueMicrotask(() => {\n // batch() — same 3-signal reset shape as the container\n // onDrop above. Per-item drops fire this branch.\n batch(() => {\n activeId.set(null)\n overId.set(null)\n overEdge.set(null)\n })\n })\n },\n }),\n dropTargetForElements({\n element: el,\n getData: ({ input, element }) =>\n attachClosestEdge(\n { [SORT_KEY]: key, [SORT_ID]: sortableId, [SORT_GROUP]: groupId },\n { input, element, allowedEdges },\n ),\n canDrop: ({ source }) => acceptsSource(source),\n onDragEnter: ({ self }) => {\n overId.set(key)\n overEdge.set(extractClosestEdge(self.data) as DropEdge | null)\n },\n onDrag: ({ self }) => {\n overEdge.set(extractClosestEdge(self.data) as DropEdge | null)\n },\n onDragLeave: () => {\n if (overId.peek() === key) {\n overId.set(null)\n overEdge.set(null)\n }\n },\n onDrop: ({ source, self }) => {\n // Same-list drops are handled by the container's onDrop via\n // performReorder. Item-level onDrop fires for cross-list\n // shapes — insert at THIS item's index, then propagate to\n // the source to remove.\n if (source.data[SORT_ID] === sortableId) return\n if (\n !groupId ||\n source.data[SORT_GROUP] !== groupId ||\n !options.onCrossListReceive\n ) {\n return\n }\n const item = source.data[SORT_PAYLOAD] as T\n const edge = extractClosestEdge(self.data) as DropEdge | null\n const currentItems = options.items()\n const targetIndex = currentItems.findIndex(\n (i) => options.by(i) === key,\n )\n if (targetIndex === -1) return\n const insertAt =\n edge === 'bottom' || edge === 'right'\n ? targetIndex + 1\n : Math.max(0, targetIndex)\n options.onCrossListReceive(item, insertAt)\n const sourceSortableId = source.data[SORT_ID] as string\n const sourceInstance = _sortableRegistry.get(sourceSortableId)\n sourceInstance?.onCrossListDrop?.(item)\n // Mark so the container's onDrop (which also fires) skips\n // re-inserting at the end of the list.\n ;(source.data as Record<string, unknown>).__pyreon_sortable_handled =\n true\n },\n }),\n )\n\n itemCleanups.set(key, cleanup)\n }\n }\n\n onCleanup(() => {\n for (const cleanup of cleanups) cleanup()\n cleanups.length = 0\n for (const cleanup of itemCleanups.values()) cleanup()\n itemCleanups.clear()\n _sortableRegistry.delete(sortableId)\n // batch() the final 3-signal reset so any subscriber that survives\n // the dispose order (unusual but possible — e.g. an external store\n // holding refs) sees one notify, not three.\n batch(() => {\n activeId.set(null)\n overId.set(null)\n overEdge.set(null)\n })\n })\n\n return { containerRef, itemRef, activeId, overId, overEdge }\n}\n","import { registerSingleton } from '@pyreon/reactivity'\n\n// Singleton sentinel — fail-loud detection of duplicate @pyreon/dnd\n// instances in the same heap. See @pyreon/reactivity/singleton-sentinel for\n// full rationale. Hardcoded version is acceptable here — it's a diagnostic\n// aid, not a load-bearing identity check.\nregisterSingleton('@pyreon/dnd', '0.24.6', import.meta.url)\n\nexport type {\n DragData,\n DropEdge,\n DropLocation,\n UseDraggableOptions,\n UseDraggableResult,\n UseDroppableOptions,\n UseDroppableResult,\n UseSortableOptions,\n UseSortableResult,\n} from './types'\n\nexport type { UseDragMonitorOptions, UseDragMonitorResult } from './use-drag-monitor'\nexport { useDragMonitor } from './use-drag-monitor'\n\nexport { useDraggable } from './use-draggable'\nexport { useDroppable } from './use-droppable'\nexport type { UseFileDropOptions, UseFileDropResult } from './use-file-drop'\nexport { useFileDrop } from './use-file-drop'\nexport { useSortable } from './use-sortable'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,eAAe,SAAuD;CACpF,IAAI,OAAO,aAAa,aAAa,OAAO;EAAE,kBAAkB;EAAO,gBAAgB;CAAK;CAE5F,MAAM,aAAa,OAAO,KAAK;CAC/B,MAAM,WAAW,OAAwB,IAAI;CAE7C,MAAM,eAAe,SAAS,cACzB,EAAE,aACD,QAAQ,aAAa,OAAO,IAAgB,KAAK,OACnD;CAwBJ,UAtBgB,mBAAmB;EACjC,GAAI,eAAe,EAAE,YAAY,aAAa,IAAI,CAAC;EACnD,cAAc,EAAE,aAAa;GAI3B,YAAY;IACV,WAAW,IAAI,IAAI;IACnB,SAAS,IAAI,OAAO,IAAgB;GACtC,CAAC;GACD,SAAS,cAAc,OAAO,IAAgB;EAChD;EACA,SAAS,EAAE,QAAQ,eAAe;GAChC,YAAY;IACV,WAAW,IAAI,KAAK;IACpB,SAAS,IAAI,IAAI;GACnB,CAAC;GACD,MAAM,aAAa,SAAS,QAAQ,YAAY,IAAI,QAAQ,CAAC;GAC7D,SAAS,SAAS,OAAO,MAAkB,UAAsB;EACnE;CACF,CAEgB,CAAC;CAEjB,OAAO;EAAE;EAAY;CAAS;AAChC;;;;;;;;;;;;;;;;;;;;;ACtDA,SAAgB,aACd,SACoB;CACpB,IAAI,OAAO,aAAa,aAAa,OAAO,EAAE,kBAAkB,MAAM;CAEtE,MAAM,aAAa,OAAO,KAAK;CAC/B,IAAI;CACJ,IAAI,WAAW;CAEf,SAAS,QAAQ;EAIf,IAAI,UAAU;EACd,IAAI,SAAS,QAAQ;EAErB,MAAM,KAAK,QAAQ,QAAQ;EAC3B,IAAI,CAAC,IAAI;EAET,MAAM,oBACJ,OAAO,QAAQ,S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SortableOptions<T> {
55
55
  onReorder: (items: T[]) => void;
56
56
  /** Sort axis. Default: "vertical". */
57
57
  axis?: 'vertical' | 'horizontal';
58
+ /**
59
+ * Opt-in cross-list drop universe. When two `useSortable` instances
60
+ * declare the same `groupId`, drags between them are accepted (drops
61
+ * from list A onto list B fire). When omitted (the default), each
62
+ * sortable is a private universe — drops from other sortables are
63
+ * rejected. Use `groupId` for Trello / Notion / Linear board layouts
64
+ * (W18).
65
+ *
66
+ * The callback `onCrossListDrop` is invoked on the SOURCE sortable
67
+ * when an item is dragged out to a sibling group sortable. Wire it
68
+ * to remove the item from the source list. The DESTINATION sortable
69
+ * receives `onCrossListReceive` with the moved item + index.
70
+ */
71
+ groupId?: string;
72
+ /**
73
+ * Called on the SOURCE sortable when one of its items is dropped on
74
+ * a sibling sortable in the same `groupId`. Only invoked when
75
+ * `groupId` is set.
76
+ */
77
+ onCrossListDrop?: (item: T) => void;
78
+ /**
79
+ * Called on the DESTINATION sortable when an item from a sibling
80
+ * sortable in the same `groupId` is dropped on it. Receives the
81
+ * moved item and the target insert index. Only invoked when
82
+ * `groupId` is set.
83
+ */
84
+ onCrossListReceive?: (item: T, targetIndex: number) => void;
58
85
  }
59
86
  interface UseSortableResult {
60
87
  /**
@@ -209,6 +236,11 @@ declare function useFileDrop(options: UseFileDropOptions): UseFileDropResult;
209
236
  * - Closest-edge detection (drop above/below or left/right)
210
237
  * - Axis constraint (vertical/horizontal)
211
238
  * - Keyboard reordering (Alt+Arrow keys)
239
+ * - Optional cross-list `groupId` for Trello/Notion/Linear board layouts
240
+ * (W18) — share the same `groupId` between two
241
+ * sortable instances and items can be dragged between them. The
242
+ * source's `onCrossListDrop(item)` removes; the destination's
243
+ * `onCrossListReceive(item, index)` inserts.
212
244
  *
213
245
  * @example
214
246
  * ```tsx
@@ -1 +1 @@
1
- {"version":3,"file":"index2.d.ts","names":[],"sources":["../../../src/types.ts","../../../src/use-drag-monitor.ts","../../../src/use-draggable.ts","../../../src/use-droppable.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AY,QAAA,EAAU,UAAA,EAAY,QAAA;EDJlC;ECMV,UAAA,IAAc,IAAA,EAAM,QAAA;AAAA;AAAA,UAGL,oBAAA;EDTG;ECWlB,UAAA;EDR2B;ECU3B,QAAA,QAAgB,QAAQ;AAAA;;;;;;ADNV;AAKhB;;;;;;;;;;;;;iBCuBgB,cAAA,CAAe,OAAA,GAAU,qBAAA,GAAwB,oBAAoB;;;ADtCrF;;;;AAA6B;AAG7B;;;;AAAoB;AAGpB;;;;;;;AANA,iBEoBgB,YAAA,WAAuB,QAAA,GAAW,QAAA,CAAA,CAChD,OAAA,EAAS,mBAAA,CAAoB,CAAA,IAC5B,kBAAA;;;AFtBH;;;;AAA6B;AAG7B;;;;AAAoB;AAGpB;;;;;;;;AANA,iBGqBgB,YAAA,WAAuB,QAAA,GAAW,QAAA,CAAA,CAChD,OAAA,EAAS,mBAAA,CAAoB,CAAA,IAC5B,kBAAA;;;UCjBc,kBAAA;EJNL;EIQV,OAAA,QAAe,WAAA;;EAEf,MAAA,GAAS,KAAA,EAAO,IAAI;EJVO;EIY3B,MAAA;EJTkB;EIWlB,QAAA;EJXkB;EIalB,QAAA;AAAA;AAAA,UAGe,iBAAA;;EAEf,MAAA;EJbA;EIeA,eAAe;AAAA;;;AJbD;AAKhB;;;;;;;;;;;;;;;;;;;;iBIkCgB,WAAA,CAAY,OAAA,EAAS,kBAAA,GAAqB,iBAAiB;;;AJjD3E;;;;AAA6B;AAG7B;;;;AAAoB;AAGpB;;;;;;;;;AAIgB;AAKhB;;;;;;;;;;;;;;;;;;;AAfA,iBKsDgB,WAAA,GAAA,CAAe,OAAA,EAAS,kBAAA,CAAmB,CAAA,IAAK,iBAAA"}
1
+ {"version":3,"file":"index2.d.ts","names":[],"sources":["../../../src/types.ts","../../../src/use-drag-monitor.ts","../../../src/use-draggable.ts","../../../src/use-droppable.ts","../../../src/use-file-drop.ts","../../../src/use-sortable.ts"],"mappings":";;KACY,QAAA,GAAW,MAAM;;KAGjB,QAAA;;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4
  "description": "Signal-driven drag and drop for Pyreon — wraps @atlaskit/pragmatic-drag-and-drop",
5
5
  "bugs": {
6
6
  "url": "https://github.com/pyreon/pyreon/issues"
@@ -36,15 +36,18 @@
36
36
  "lint": "oxlint ."
37
37
  },
38
38
  "dependencies": {
39
- "@atlaskit/pragmatic-drag-and-drop": "^1.7.10",
40
- "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.0.0",
41
- "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
42
- "@pyreon/core": "^0.25.1",
43
- "@pyreon/reactivity": "^0.25.1"
39
+ "@atlaskit/pragmatic-drag-and-drop": "^1.8.1",
40
+ "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.5",
41
+ "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0"
44
42
  },
45
43
  "devDependencies": {
46
- "@pyreon/test-utils": "^0.13.12",
47
- "@pyreon/typescript": "^0.25.1",
48
- "@vitest/browser-playwright": "^4.1.4"
44
+ "@pyreon/test-utils": "^0.13.13",
45
+ "@pyreon/typescript": "^0.26.1",
46
+ "@pyreon/vitest-config": "0.13.1",
47
+ "@vitest/browser-playwright": "^4.1.7"
48
+ },
49
+ "peerDependencies": {
50
+ "@pyreon/core": "^0.26.1",
51
+ "@pyreon/reactivity": "^0.26.1"
49
52
  }
50
53
  }