@dnd-kit/dom 0.0.3 → 0.0.4-beta-20240621030124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,19 +1,85 @@
1
- import { Sensor, configurator, Plugin, CorePlugin, DragDropManager as DragDropManager$1, Draggable as Draggable$1, descriptor, Droppable as Droppable$1 } from '@dnd-kit/abstract';
2
- import { effect, batch, effects, untracked, reactive, computed, deepEqual, signal } from '@dnd-kit/state';
3
- import { ScrollDirection, Listeners, getDocument, DOMRectangle, Styles, getComputedStyles, createPlaceholder, isKeyboardEvent, parseTranslate, supportsPopover, showPopover, supportsStyle, animateTransform, canScroll, detectScrollIntent, scheduler, getScrollableAncestors, scrollIntoViewIfNeeded, getWindow, getFirstScrollableAncestor } from '@dnd-kit/dom/utilities';
4
- import { exceedsDistance, Axes } from '@dnd-kit/geometry';
1
+ import { configurator, Plugin, CorePlugin, Sensor, DragDropManager as DragDropManager$1, Draggable as Draggable$1, descriptor, Droppable as Droppable$1 } from '@dnd-kit/abstract';
2
+ import { effects, effect, untracked, computed, deepEqual, batch, signal, reactive } from '@dnd-kit/state';
3
+ import { ScrollDirection, DOMRectangle, Styles, getComputedStyles, createPlaceholder, isKeyboardEvent, parseTranslate, supportsPopover, showPopover, supportsStyle, animateTransform, canScroll, detectScrollIntent, scheduler, getScrollableAncestors, Listeners, scrollIntoViewIfNeeded, getDocument, getWindow, getFirstScrollableAncestor } from '@dnd-kit/dom/utilities';
4
+ import { Axes, exceedsDistance } from '@dnd-kit/geometry';
5
5
  import { defaultCollisionDetection } from '@dnd-kit/collision';
6
6
 
7
+ var __create = Object.create;
7
8
  var __defProp = Object.defineProperty;
8
- var __decorateClass = (decorators, target, key, kind) => {
9
- var result = void 0 ;
10
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
11
- if (decorator = decorators[i])
12
- result = (decorator(target, key, result) ) || result;
13
- if (result)
14
- __defProp(target, key, result);
15
- return result;
9
+ var __defProps = Object.defineProperties;
10
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
12
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
15
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
16
+ var __typeError = (msg) => {
17
+ throw TypeError(msg);
16
18
  };
19
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
20
+ var __spreadValues = (a, b) => {
21
+ for (var prop in b || (b = {}))
22
+ if (__hasOwnProp.call(b, prop))
23
+ __defNormalProp(a, prop, b[prop]);
24
+ if (__getOwnPropSymbols)
25
+ for (var prop of __getOwnPropSymbols(b)) {
26
+ if (__propIsEnum.call(b, prop))
27
+ __defNormalProp(a, prop, b[prop]);
28
+ }
29
+ return a;
30
+ };
31
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
32
+ var __objRest = (source, exclude) => {
33
+ var target = {};
34
+ for (var prop in source)
35
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
36
+ target[prop] = source[prop];
37
+ if (source != null && __getOwnPropSymbols)
38
+ for (var prop of __getOwnPropSymbols(source)) {
39
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
40
+ target[prop] = source[prop];
41
+ }
42
+ return target;
43
+ };
44
+ var __decoratorStart = (base) => {
45
+ var _a3;
46
+ return [, , , __create((_a3 = base == null ? void 0 : base[__knownSymbol("metadata")]) != null ? _a3 : null)];
47
+ };
48
+ var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
49
+ var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
50
+ var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
51
+ var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
52
+ var __runInitializers = (array, flags, self, value) => {
53
+ for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
54
+ return value;
55
+ };
56
+ var __decorateElement = (array, flags, name, decorators, target, extra) => {
57
+ var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
58
+ var j = array.length + 1 , key = __decoratorStrings[k + 5];
59
+ var initializers = (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
60
+ var desc = ((target = target.prototype), __getOwnPropDesc({ get [name]() {
61
+ return __privateGet(this, extra);
62
+ }, set [name](x) {
63
+ return __privateSet(this, extra, x);
64
+ } }, name));
65
+ for (var i = decorators.length - 1; i >= 0; i--) {
66
+ ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
67
+ {
68
+ ctx.static = s, ctx.private = p, access = ctx.access = { has: (x) => name in x };
69
+ access.get = (x) => x[name];
70
+ access.set = (x, y) => x[name] = y;
71
+ }
72
+ it = (0, decorators[i])({ get: desc.get, set: desc.set } , ctx), done._ = 1;
73
+ if (it === void 0) __expectFn(it) && (desc[key] = it );
74
+ else if (typeof it !== "object" || it === null) __typeError("Object expected");
75
+ else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
76
+ }
77
+ return desc && __defProp(target, name, desc), target;
78
+ };
79
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
80
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), member.get(obj));
81
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
82
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
17
83
 
18
84
  // src/core/plugins/accessibility/defaults.ts
19
85
  var defaultAttributes = {
@@ -28,21 +94,18 @@ var defaultScreenReaderInstructions = {
28
94
  };
29
95
  var defaultAnnouncements = {
30
96
  dragstart({ operation: { source } }) {
31
- if (!source)
32
- return;
97
+ if (!source) return;
33
98
  return `Picked up draggable item ${source.id}.`;
34
99
  },
35
100
  dragover({ operation: { source, target } }) {
36
- if (!source)
37
- return;
101
+ if (!source) return;
38
102
  if (target) {
39
103
  return `Draggable item ${source.id} was moved over droppable target ${target.id}.`;
40
104
  }
41
105
  return `Draggable item ${source.id} is no longer over a droppable target.`;
42
106
  },
43
107
  dragend({ operation: { source, target }, canceled }) {
44
- if (!source)
45
- return;
108
+ if (!source) return;
46
109
  if (canceled) {
47
110
  return `Dragging was cancelled. Draggable item ${source.id} was dropped.`;
48
111
  }
@@ -105,7 +168,7 @@ var Accessibility = class extends Plugin {
105
168
  } = {},
106
169
  announcements = defaultAnnouncements,
107
170
  screenReaderInstructions = defaultScreenReaderInstructions
108
- } = options ?? {};
171
+ } = options != null ? options : {};
109
172
  const descriptionId = id ? `${descriptionPrefix}-${id}` : generateUniqueId(descriptionPrefix);
110
173
  const announcementId = id ? `${announcementPrefix}-${id}` : generateUniqueId(announcementPrefix);
111
174
  let hiddenTextElement;
@@ -115,7 +178,7 @@ var Accessibility = class extends Plugin {
115
178
  return this.manager.monitor.addEventListener(
116
179
  eventName,
117
180
  (event, manager2) => {
118
- const announcement = getAnnouncement?.(event, manager2);
181
+ const announcement = getAnnouncement == null ? void 0 : getAnnouncement(event, manager2);
119
182
  if (announcement && liveRegionElement) {
120
183
  liveRegionElement.innerText = announcement;
121
184
  }
@@ -134,7 +197,7 @@ var Accessibility = class extends Plugin {
134
197
  const cleanupEffects = effects(() => {
135
198
  for (const draggable of manager.registry.draggables.value) {
136
199
  const { element, handle } = draggable;
137
- const activator = handle ?? element;
200
+ const activator = handle != null ? handle : element;
138
201
  if (activator) {
139
202
  if (!hiddenTextElement || !liveRegionElement) {
140
203
  initialize();
@@ -162,8 +225,8 @@ var Accessibility = class extends Plugin {
162
225
  }
163
226
  }
164
227
  this.destroy = () => {
165
- hiddenTextElement?.remove();
166
- liveRegionElement?.remove();
228
+ hiddenTextElement == null ? void 0 : hiddenTextElement.remove();
229
+ liveRegionElement == null ? void 0 : liveRegionElement.remove();
167
230
  eventListeners.forEach((unsubscribe) => unsubscribe());
168
231
  cleanupEffects();
169
232
  };
@@ -175,8 +238,9 @@ var Cursor = class extends Plugin {
175
238
  super(manager, options);
176
239
  this.manager = manager;
177
240
  this.destroy = effect(() => {
241
+ var _a3;
178
242
  const { dragOperation } = this.manager;
179
- const { cursor = "grabbing" } = this.options ?? {};
243
+ const { cursor = "grabbing" } = (_a3 = this.options) != null ? _a3 : {};
180
244
  if (dragOperation.status.initialized) {
181
245
  const style = document.createElement("style");
182
246
  style.innerText = `* { cursor: ${cursor} !important; }`;
@@ -213,6 +277,7 @@ var Feedback = class extends Plugin {
213
277
  }
214
278
  });
215
279
  const cleanupEffect = effect(() => {
280
+ var _a3;
216
281
  const { dragOperation } = manager;
217
282
  const { position, source, status } = dragOperation;
218
283
  if (status.idle) {
@@ -222,11 +287,9 @@ var Feedback = class extends Plugin {
222
287
  initialTranslate = { x: 0, y: 0 };
223
288
  return;
224
289
  }
225
- if (!source)
226
- return;
290
+ if (!source) return;
227
291
  const { element, feedback } = source;
228
- if (!element || feedback === "none")
229
- return;
292
+ if (!element || feedback === "none") return;
230
293
  const shape = new DOMRectangle(element, true);
231
294
  const { width, height, top, left } = shape;
232
295
  const styles = new Styles(element);
@@ -279,8 +342,7 @@ var Feedback = class extends Plugin {
279
342
  },
280
343
  CSS_PREFIX
281
344
  );
282
- if (placeholder)
283
- element.insertAdjacentElement("afterend", placeholder);
345
+ if (placeholder) element.insertAdjacentElement("afterend", placeholder);
284
346
  if (supportsPopover(element)) {
285
347
  if (!element.hasAttribute("popover")) {
286
348
  element.setAttribute("popover", "");
@@ -305,10 +367,9 @@ var Feedback = class extends Plugin {
305
367
  offset.top = 0;
306
368
  }
307
369
  const resizeObserver = new ResizeObserver(() => {
308
- if (!placeholder)
309
- return;
370
+ if (!placeholder) return;
310
371
  const placeholderShape = new DOMRectangle(placeholder, true);
311
- const origin = transformOrigin ?? { x: 1, y: 1 };
372
+ const origin = transformOrigin != null ? transformOrigin : { x: 1, y: 1 };
312
373
  const dX = (width - placeholderShape.width) * origin.x + delta.x;
313
374
  const dY = (height - placeholderShape.height) * origin.y + delta.y;
314
375
  styles.set(
@@ -385,6 +446,7 @@ var Feedback = class extends Plugin {
385
446
  });
386
447
  }
387
448
  const cleanupEffect2 = effect(function updateTransform() {
449
+ var _a4, _b2;
388
450
  const { transform, status: status2 } = dragOperation;
389
451
  if (!transform.x && !transform.y && !moved) {
390
452
  return;
@@ -405,8 +467,8 @@ var Feedback = class extends Plugin {
405
467
  CSS_PREFIX
406
468
  );
407
469
  dragOperation.shape = shape2.translate(
408
- x - (currentTransform?.x ?? 0),
409
- y - (currentTransform?.y ?? 0)
470
+ x - ((_a4 = currentTransform == null ? void 0 : currentTransform.x) != null ? _a4 : 0),
471
+ y - ((_b2 = currentTransform == null ? void 0 : currentTransform.y) != null ? _b2 : 0)
410
472
  );
411
473
  currentTransform = {
412
474
  x,
@@ -417,26 +479,27 @@ var Feedback = class extends Plugin {
417
479
  };
418
480
  }
419
481
  });
420
- const id = manager.dragOperation.source?.id;
482
+ const id = (_a3 = manager.dragOperation.source) == null ? void 0 : _a3.id;
421
483
  const restoreFocus = () => {
484
+ var _a4;
422
485
  if (!isKeyboardOperation || id == null) {
423
486
  return;
424
487
  }
425
488
  const draggable = manager.registry.draggables.get(id);
426
- const element2 = draggable?.handle ?? draggable?.element;
489
+ const element2 = (_a4 = draggable == null ? void 0 : draggable.handle) != null ? _a4 : draggable == null ? void 0 : draggable.element;
427
490
  if (element2 instanceof HTMLElement) {
428
491
  element2.focus();
429
492
  }
430
493
  };
431
494
  let cleanup = () => {
432
- elementMutationObserver?.disconnect();
433
- documentMutationObserver?.disconnect();
495
+ elementMutationObserver == null ? void 0 : elementMutationObserver.disconnect();
496
+ documentMutationObserver == null ? void 0 : documentMutationObserver.disconnect();
434
497
  resizeObserver.disconnect();
435
498
  styles.reset();
436
499
  if (moved && element.isConnected) {
437
- placeholder?.replaceWith(element);
500
+ placeholder == null ? void 0 : placeholder.replaceWith(element);
438
501
  }
439
- placeholder?.remove();
502
+ placeholder == null ? void 0 : placeholder.remove();
440
503
  element.removeAttribute(ATTRIBUTE);
441
504
  if (supportsPopover(element)) {
442
505
  element.removeAttribute("popover");
@@ -454,12 +517,13 @@ var Feedback = class extends Plugin {
454
517
  cleanup = void 0;
455
518
  const transform = currentTransform;
456
519
  if (!transform) {
457
- onComplete?.();
520
+ onComplete == null ? void 0 : onComplete();
458
521
  return;
459
522
  }
460
523
  manager.renderer.rendering.then(() => {
524
+ var _a4;
461
525
  showPopover(element);
462
- const target = placeholder ?? element;
526
+ const target = placeholder != null ? placeholder : element;
463
527
  styles.remove(["translate"], CSS_PREFIX);
464
528
  const shape2 = new DOMRectangle(target);
465
529
  const currentShape = new DOMRectangle(element, true).translate(
@@ -479,7 +543,7 @@ var Feedback = class extends Plugin {
479
543
  element,
480
544
  keyframes: {
481
545
  translate: [
482
- `${transform.x}px ${transform.y}px ${transform.z ?? 0}`,
546
+ `${transform.x}px ${transform.y}px ${(_a4 = transform.z) != null ? _a4 : 0}`,
483
547
  `${final.x}px ${final.y}px ${final.z}`
484
548
  ]
485
549
  },
@@ -489,31 +553,29 @@ var Feedback = class extends Plugin {
489
553
  },
490
554
  onFinish() {
491
555
  requestAnimationFrame(restoreFocus);
492
- onComplete?.();
556
+ onComplete == null ? void 0 : onComplete();
493
557
  }
494
558
  });
495
559
  });
496
560
  }
497
561
  });
498
- return () => cleanup?.();
562
+ return () => cleanup == null ? void 0 : cleanup();
499
563
  });
500
564
  this.destroy = () => {
501
565
  styleInjectionCleanup();
502
566
  cleanupEffect();
503
- style?.remove();
567
+ style == null ? void 0 : style.remove();
504
568
  };
505
569
  }
506
570
  };
507
571
  var LOCKED = true;
508
572
  var UNLOCKED = false;
509
- var _a, _b;
573
+ var _dec, _a, _dec2, _b, _init, __b, __a;
574
+ _b = (_dec2 = [reactive], ScrollDirection.Forward), _a = (_dec = [reactive], ScrollDirection.Reverse);
510
575
  var ScrollLock = class {
511
576
  constructor() {
512
- this[_a] = LOCKED;
513
- this[_b] = LOCKED;
514
- }
515
- static {
516
- _a = ScrollDirection.Forward, _b = ScrollDirection.Reverse;
577
+ __privateAdd(this, __b, __runInitializers(_init, 8, this, LOCKED)), __runInitializers(_init, 11, this);
578
+ __privateAdd(this, __a, __runInitializers(_init, 12, this, LOCKED)), __runInitializers(_init, 15, this);
517
579
  }
518
580
  isLocked(direction) {
519
581
  if (direction === ScrollDirection.Idle) {
@@ -531,12 +593,12 @@ var ScrollLock = class {
531
593
  this[direction] = UNLOCKED;
532
594
  }
533
595
  };
534
- __decorateClass([
535
- reactive
536
- ], ScrollLock.prototype, _a);
537
- __decorateClass([
538
- reactive
539
- ], ScrollLock.prototype, _b);
596
+ _init = __decoratorStart(null);
597
+ __b = new WeakMap();
598
+ __a = new WeakMap();
599
+ __decorateElement(_init, 4, _b, _dec2, ScrollLock, __b);
600
+ __decorateElement(_init, 4, _a, _dec, ScrollLock, __a);
601
+ __decoratorMetadata(_init, ScrollLock);
540
602
 
541
603
  // src/core/plugins/scrolling/ScrollIntent.ts
542
604
  var DIRECTIONS = [ScrollDirection.Forward, ScrollDirection.Reverse];
@@ -592,36 +654,39 @@ function getDirection(a, b) {
592
654
  }
593
655
 
594
656
  // src/core/plugins/scrolling/Scroller.ts
595
- var Scroller = class extends CorePlugin {
657
+ var _autoScrolling_dec, _a2, _init2, _autoScrolling, _meta, _scroll;
658
+ var Scroller = class extends (_a2 = CorePlugin, _autoScrolling_dec = [reactive], _a2) {
596
659
  constructor(manager) {
597
660
  super(manager);
598
- this.autoScrolling = false;
599
- this.#scroll = () => {
600
- if (!this.#meta) {
661
+ __privateAdd(this, _autoScrolling, __runInitializers(_init2, 8, this, false)), __runInitializers(_init2, 11, this);
662
+ __privateAdd(this, _meta);
663
+ __privateAdd(this, _scroll, () => {
664
+ if (!__privateGet(this, _meta)) {
601
665
  return;
602
666
  }
603
- const { element, by } = this.#meta;
667
+ const { element, by } = __privateGet(this, _meta);
604
668
  element.scrollBy(by.x, by.y);
605
- };
669
+ });
606
670
  this.scroll = (options) => {
671
+ var _a3;
607
672
  if (this.disabled) {
608
673
  return false;
609
674
  }
610
675
  const elements = this.getScrollableElements();
611
676
  if (!elements) {
612
- this.#meta = void 0;
677
+ __privateSet(this, _meta, void 0);
613
678
  return false;
614
679
  }
615
680
  const { position } = this.manager.dragOperation;
616
- const currentPosition = position?.current;
681
+ const currentPosition = position == null ? void 0 : position.current;
617
682
  if (currentPosition) {
618
- const { by } = options ?? {};
683
+ const { by } = options != null ? options : {};
619
684
  const intent = by ? {
620
685
  x: getScrollIntent(by.x),
621
686
  y: getScrollIntent(by.y)
622
687
  } : void 0;
623
688
  const scrollIntent = intent ? void 0 : this.scrollIntentTracker.current;
624
- if (scrollIntent?.isLocked()) {
689
+ if (scrollIntent == null ? void 0 : scrollIntent.isLocked()) {
625
690
  return false;
626
691
  }
627
692
  for (const scrollableElement of elements) {
@@ -641,36 +706,36 @@ var Scroller = class extends CorePlugin {
641
706
  }
642
707
  }
643
708
  if (direction.x || direction.y) {
644
- const { x, y } = by ?? direction;
709
+ const { x, y } = by != null ? by : direction;
645
710
  const scrollLeftBy = x * speed.x;
646
711
  const scrollTopBy = y * speed.y;
647
712
  if (scrollLeftBy || scrollTopBy) {
648
- const previousScrollBy = this.#meta?.by;
713
+ const previousScrollBy = (_a3 = __privateGet(this, _meta)) == null ? void 0 : _a3.by;
649
714
  if (this.autoScrolling && previousScrollBy) {
650
715
  const scrollIntentMismatch = previousScrollBy.x && !scrollLeftBy || previousScrollBy.y && !scrollTopBy;
651
- if (scrollIntentMismatch)
652
- continue;
716
+ if (scrollIntentMismatch) continue;
653
717
  }
654
- this.#meta = {
718
+ __privateSet(this, _meta, {
655
719
  element: scrollableElement,
656
720
  by: {
657
721
  x: scrollLeftBy,
658
722
  y: scrollTopBy
659
723
  }
660
- };
661
- scheduler.schedule(this.#scroll);
724
+ });
725
+ scheduler.schedule(__privateGet(this, _scroll));
662
726
  return true;
663
727
  }
664
728
  }
665
729
  }
666
730
  }
667
731
  }
668
- this.#meta = void 0;
732
+ __privateSet(this, _meta, void 0);
669
733
  return false;
670
734
  };
671
735
  let previousElementFromPoint = null;
672
736
  let previousScrollableElements = null;
673
737
  const elementFromPoint = computed(() => {
738
+ var _a3;
674
739
  const { position } = manager.dragOperation;
675
740
  if (!position) {
676
741
  return null;
@@ -680,13 +745,13 @@ var Scroller = class extends CorePlugin {
680
745
  if (element) {
681
746
  previousElementFromPoint = element;
682
747
  }
683
- return document.elementFromPoint(x, y) ?? previousElementFromPoint;
748
+ return (_a3 = document.elementFromPoint(x, y)) != null ? _a3 : previousElementFromPoint;
684
749
  });
685
750
  const scrollableElements = computed(() => {
686
751
  const element = elementFromPoint.value;
687
752
  if (!element || element === document.documentElement) {
688
753
  const { target } = manager.dragOperation;
689
- const targetElement = target?.element;
754
+ const targetElement = target == null ? void 0 : target.element;
690
755
  if (targetElement) {
691
756
  const elements = getScrollableAncestors(targetElement, {
692
757
  excludeElement: false
@@ -699,7 +764,7 @@ var Scroller = class extends CorePlugin {
699
764
  const elements = getScrollableAncestors(element, {
700
765
  excludeElement: false
701
766
  });
702
- if (this.autoScrolling && previousScrollableElements && elements.size < previousScrollableElements?.size) {
767
+ if (this.autoScrolling && previousScrollableElements && elements.size < (previousScrollableElements == null ? void 0 : previousScrollableElements.size)) {
703
768
  return previousScrollableElements;
704
769
  }
705
770
  previousScrollableElements = elements;
@@ -721,12 +786,13 @@ var Scroller = class extends CorePlugin {
721
786
  }
722
787
  });
723
788
  }
724
- #meta;
725
- #scroll;
726
789
  };
727
- __decorateClass([
728
- reactive
729
- ], Scroller.prototype, "autoScrolling");
790
+ _init2 = __decoratorStart(_a2);
791
+ _autoScrolling = new WeakMap();
792
+ _meta = new WeakMap();
793
+ _scroll = new WeakMap();
794
+ __decorateElement(_init2, 4, "autoScrolling", _autoScrolling_dec, Scroller, _autoScrolling);
795
+ __decoratorMetadata(_init2, Scroller);
730
796
  function getScrollIntent(value) {
731
797
  if (value > 0) {
732
798
  return ScrollDirection.Forward;
@@ -768,15 +834,17 @@ var listenerOptions = {
768
834
  capture: true,
769
835
  passive: true
770
836
  };
837
+ var _timeout;
771
838
  var ScrollListener = class extends CorePlugin {
772
839
  constructor(manager) {
773
840
  super(manager);
841
+ __privateAdd(this, _timeout);
774
842
  this.handleScroll = () => {
775
- if (this.#timeout == null) {
776
- this.#timeout = setTimeout(() => {
843
+ if (__privateGet(this, _timeout) == null) {
844
+ __privateSet(this, _timeout, setTimeout(() => {
777
845
  this.manager.collisionObserver.forceUpdate();
778
- this.#timeout = void 0;
779
- }, 50);
846
+ __privateSet(this, _timeout, void 0);
847
+ }, 50));
780
848
  }
781
849
  };
782
850
  const { dragOperation } = this.manager;
@@ -794,8 +862,8 @@ var ScrollListener = class extends CorePlugin {
794
862
  }
795
863
  });
796
864
  }
797
- #timeout;
798
865
  };
866
+ _timeout = new WeakMap();
799
867
  var PreventSelection = class extends Plugin {
800
868
  constructor(manager) {
801
869
  super(manager);
@@ -820,7 +888,8 @@ var PreventSelection = class extends Plugin {
820
888
  }
821
889
  };
822
890
  function removeSelection() {
823
- document.getSelection()?.removeAllRanges();
891
+ var _a3;
892
+ (_a3 = document.getSelection()) == null ? void 0 : _a3.removeAllRanges();
824
893
  }
825
894
  var DEFAULT_KEYBOARD_CODES = {
826
895
  start: ["Space", "Enter"],
@@ -832,12 +901,13 @@ var DEFAULT_KEYBOARD_CODES = {
832
901
  right: ["ArrowRight"]
833
902
  };
834
903
  var DEFAULT_OFFSET = 10;
904
+ var _cleanupFunctions;
835
905
  var KeyboardSensor = class extends Sensor {
836
906
  constructor(manager, options) {
837
907
  super(manager);
838
908
  this.manager = manager;
839
909
  this.options = options;
840
- this.#cleanupFunctions = [];
910
+ __privateAdd(this, _cleanupFunctions, []);
841
911
  this.listeners = new Listeners();
842
912
  this.handleSourceKeyDown = (event, source, options) => {
843
913
  if (this.disabled || event.defaultPrevented) {
@@ -849,7 +919,7 @@ var KeyboardSensor = class extends Sensor {
849
919
  if (source.disabled || !source.element) {
850
920
  return;
851
921
  }
852
- const { keyboardCodes = DEFAULT_KEYBOARD_CODES } = options ?? {};
922
+ const { keyboardCodes = DEFAULT_KEYBOARD_CODES } = options != null ? options : {};
853
923
  if (!keyboardCodes.start.includes(event.code)) {
854
924
  return;
855
925
  }
@@ -859,10 +929,10 @@ var KeyboardSensor = class extends Sensor {
859
929
  this.handleStart(event, source, options);
860
930
  };
861
931
  }
862
- #cleanupFunctions;
863
932
  bind(source, options = this.options) {
864
933
  const unbind = effect(() => {
865
- const target = source.handle ?? source.element;
934
+ var _a3;
935
+ const target = (_a3 = source.handle) != null ? _a3 : source.element;
866
936
  const listener = (event) => {
867
937
  if (event instanceof KeyboardEvent) {
868
938
  this.handleSourceKeyDown(event, source, options);
@@ -911,10 +981,10 @@ var KeyboardSensor = class extends Sensor {
911
981
  { type: "resize", listener: () => this.handleEnd(true) }
912
982
  ])
913
983
  ];
914
- this.#cleanupFunctions.push(...listeners);
984
+ __privateGet(this, _cleanupFunctions).push(...listeners);
915
985
  }
916
986
  handleKeyDown(event, _source, options) {
917
- const { keyboardCodes = DEFAULT_KEYBOARD_CODES } = options ?? {};
987
+ const { keyboardCodes = DEFAULT_KEYBOARD_CODES } = options != null ? options : {};
918
988
  if (isKeycode(event, [...keyboardCodes.end, ...keyboardCodes.cancel])) {
919
989
  event.preventDefault();
920
990
  const canceled = isKeycode(event, keyboardCodes.cancel);
@@ -962,7 +1032,7 @@ var KeyboardSensor = class extends Sensor {
962
1032
  offset = { x: DEFAULT_OFFSET * factor, y: 0 };
963
1033
  break;
964
1034
  }
965
- if (offset?.x || offset?.y) {
1035
+ if ((offset == null ? void 0 : offset.x) || (offset == null ? void 0 : offset.y)) {
966
1036
  event.preventDefault();
967
1037
  this.manager.actions.move({
968
1038
  by: offset
@@ -971,36 +1041,39 @@ var KeyboardSensor = class extends Sensor {
971
1041
  }
972
1042
  sideEffects() {
973
1043
  const autoScroller = this.manager.registry.plugins.get(AutoScroller);
974
- if (autoScroller?.disabled === false) {
1044
+ if ((autoScroller == null ? void 0 : autoScroller.disabled) === false) {
975
1045
  autoScroller.disable();
976
- this.#cleanupFunctions.push(() => {
1046
+ __privateGet(this, _cleanupFunctions).push(() => {
977
1047
  autoScroller.enable();
978
1048
  });
979
1049
  }
980
1050
  }
981
1051
  cleanup() {
982
- this.#cleanupFunctions.forEach((cleanup) => cleanup());
1052
+ __privateGet(this, _cleanupFunctions).forEach((cleanup) => cleanup());
983
1053
  }
984
1054
  destroy() {
985
1055
  this.cleanup();
986
1056
  this.listeners.clear();
987
1057
  }
988
1058
  };
1059
+ _cleanupFunctions = new WeakMap();
989
1060
  function isKeycode(event, codes) {
990
1061
  return codes.includes(event.code);
991
1062
  }
992
- var PointerSensor = class _PointerSensor extends Sensor {
1063
+ var _clearTimeout;
1064
+ var _PointerSensor = class _PointerSensor extends Sensor {
993
1065
  constructor(manager, options) {
994
1066
  super(manager);
995
1067
  this.manager = manager;
996
1068
  this.options = options;
997
1069
  this.listeners = new Listeners();
998
1070
  this.cleanup = /* @__PURE__ */ new Set();
1071
+ __privateAdd(this, _clearTimeout);
999
1072
  }
1000
- #clearTimeout;
1001
1073
  bind(source, options = this.options) {
1002
1074
  const unbind = effect(() => {
1003
- const target = source.handle ?? source.element;
1075
+ var _a3;
1076
+ const target = (_a3 = source.handle) != null ? _a3 : source.element;
1004
1077
  const listener = (event) => {
1005
1078
  if (event instanceof PointerEvent) {
1006
1079
  this.handlePointerDown(event, source, options);
@@ -1033,7 +1106,7 @@ var PointerSensor = class _PointerSensor extends Sensor {
1033
1106
  const { activationConstraints } = options;
1034
1107
  const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
1035
1108
  event.stopImmediatePropagation();
1036
- if (!constraints?.delay && !constraints?.distance) {
1109
+ if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
1037
1110
  this.handleStart(source, event);
1038
1111
  } else {
1039
1112
  const { delay } = constraints;
@@ -1042,10 +1115,10 @@ var PointerSensor = class _PointerSensor extends Sensor {
1042
1115
  () => this.handleStart(source, event),
1043
1116
  delay.value
1044
1117
  );
1045
- this.#clearTimeout = () => {
1118
+ __privateSet(this, _clearTimeout, () => {
1046
1119
  clearTimeout(timeout);
1047
- this.#clearTimeout = void 0;
1048
- };
1120
+ __privateSet(this, _clearTimeout, void 0);
1121
+ });
1049
1122
  }
1050
1123
  }
1051
1124
  const ownerDocument = getDocument(event.target);
@@ -1077,8 +1150,9 @@ var PointerSensor = class _PointerSensor extends Sensor {
1077
1150
  }
1078
1151
  ]);
1079
1152
  const cleanup = () => {
1153
+ var _a3;
1080
1154
  unbindListeners();
1081
- this.#clearTimeout?.();
1155
+ (_a3 = __privateGet(this, _clearTimeout)) == null ? void 0 : _a3.call(this);
1082
1156
  this.initialCoordinates = void 0;
1083
1157
  this.cleanup.delete(cleanup);
1084
1158
  };
@@ -1104,7 +1178,7 @@ var PointerSensor = class _PointerSensor extends Sensor {
1104
1178
  };
1105
1179
  const { activationConstraints } = options;
1106
1180
  const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
1107
- const { distance, delay } = constraints ?? {};
1181
+ const { distance, delay } = constraints != null ? constraints : {};
1108
1182
  if (distance) {
1109
1183
  if (distance.tolerance != null && exceedsDistance(delta, distance.tolerance)) {
1110
1184
  return this.handleCancel();
@@ -1136,8 +1210,9 @@ var PointerSensor = class _PointerSensor extends Sensor {
1136
1210
  }
1137
1211
  }
1138
1212
  handleStart(source, event) {
1213
+ var _a3;
1139
1214
  const { manager, initialCoordinates } = this;
1140
- this.#clearTimeout?.();
1215
+ (_a3 = __privateGet(this, _clearTimeout)) == null ? void 0 : _a3.call(this);
1141
1216
  if (!initialCoordinates || manager.dragOperation.status.initialized) {
1142
1217
  return;
1143
1218
  }
@@ -1160,10 +1235,10 @@ var PointerSensor = class _PointerSensor extends Sensor {
1160
1235
  destroy() {
1161
1236
  this.listeners.clear();
1162
1237
  }
1163
- static {
1164
- this.configure = configurator(_PointerSensor);
1165
- }
1166
1238
  };
1239
+ _clearTimeout = new WeakMap();
1240
+ _PointerSensor.configure = configurator(_PointerSensor);
1241
+ var PointerSensor = _PointerSensor;
1167
1242
  function preventDefault(event) {
1168
1243
  event.preventDefault();
1169
1244
  }
@@ -1187,8 +1262,9 @@ var defaultPreset = {
1187
1262
  sensors: [
1188
1263
  PointerSensor.configure({
1189
1264
  activationConstraints(event, source) {
1265
+ var _a3;
1190
1266
  const { pointerType, target } = event;
1191
- if (pointerType === "mouse" && target instanceof Element && (source.handle === target || source.handle?.contains(target))) {
1267
+ if (pointerType === "mouse" && target instanceof Element && (source.handle === target || ((_a3 = source.handle) == null ? void 0 : _a3.contains(target)))) {
1192
1268
  return void 0;
1193
1269
  }
1194
1270
  return {
@@ -1207,29 +1283,36 @@ var DragDropManager = class extends DragDropManager$1 {
1207
1283
  sensors = defaultPreset.sensors,
1208
1284
  modifiers = []
1209
1285
  } = input;
1210
- super({
1211
- ...input,
1286
+ super(__spreadProps(__spreadValues({}, input), {
1212
1287
  plugins: [ScrollListener, Scroller, ...plugins],
1213
1288
  sensors,
1214
1289
  modifiers
1215
- });
1290
+ }));
1216
1291
  }
1217
1292
  };
1218
- var Draggable = class extends Draggable$1 {
1219
- constructor({
1220
- element,
1221
- effects: effects2 = () => [],
1222
- handle,
1223
- feedback = "default",
1224
- ...input
1225
- }, manager) {
1293
+ var _feedback_dec, _element_dec, _handle_dec, _c, _init3, _handle, _element, _feedback;
1294
+ var Draggable = class extends (_c = Draggable$1, _handle_dec = [reactive], _element_dec = [reactive], _feedback_dec = [reactive], _c) {
1295
+ constructor(_a3, manager) {
1296
+ var _b2 = _a3, {
1297
+ element,
1298
+ effects: effects2 = () => [],
1299
+ handle,
1300
+ feedback = "default"
1301
+ } = _b2, input = __objRest(_b2, [
1302
+ "element",
1303
+ "effects",
1304
+ "handle",
1305
+ "feedback"
1306
+ ]);
1226
1307
  super(
1227
- {
1308
+ __spreadValues({
1228
1309
  effects: () => [
1229
1310
  ...effects2(),
1230
1311
  () => {
1312
+ var _a4, _b3;
1231
1313
  const { manager: manager2 } = this;
1232
- const sensors = this.sensors?.map(descriptor) ?? [
1314
+ if (!manager2) return;
1315
+ const sensors = (_b3 = (_a4 = this.sensors) == null ? void 0 : _a4.map(descriptor)) != null ? _b3 : [
1233
1316
  ...manager2.sensors
1234
1317
  ];
1235
1318
  const unbindFunctions = sensors.map((entry) => {
@@ -1242,37 +1325,40 @@ var Draggable = class extends Draggable$1 {
1242
1325
  unbindFunctions.forEach((unbind) => unbind());
1243
1326
  };
1244
1327
  }
1245
- ],
1246
- ...input
1247
- },
1328
+ ]
1329
+ }, input),
1248
1330
  manager
1249
1331
  );
1250
- this.manager = manager;
1332
+ __privateAdd(this, _handle, __runInitializers(_init3, 8, this)), __runInitializers(_init3, 11, this);
1333
+ __privateAdd(this, _element, __runInitializers(_init3, 12, this)), __runInitializers(_init3, 15, this);
1334
+ __privateAdd(this, _feedback, __runInitializers(_init3, 16, this)), __runInitializers(_init3, 19, this);
1251
1335
  this.element = element;
1252
1336
  this.handle = handle;
1253
1337
  this.feedback = feedback;
1254
1338
  }
1255
1339
  };
1256
- __decorateClass([
1257
- reactive
1258
- ], Draggable.prototype, "handle");
1259
- __decorateClass([
1260
- reactive
1261
- ], Draggable.prototype, "element");
1262
- __decorateClass([
1263
- reactive
1264
- ], Draggable.prototype, "feedback");
1265
- var Droppable = class extends Droppable$1 {
1266
- constructor({ element, effects: effects2 = () => [], ...input }, manager) {
1340
+ _init3 = __decoratorStart(_c);
1341
+ _handle = new WeakMap();
1342
+ _element = new WeakMap();
1343
+ _feedback = new WeakMap();
1344
+ __decorateElement(_init3, 4, "handle", _handle_dec, Draggable, _handle);
1345
+ __decorateElement(_init3, 4, "element", _element_dec, Draggable, _element);
1346
+ __decorateElement(_init3, 4, "feedback", _feedback_dec, Draggable, _feedback);
1347
+ __decoratorMetadata(_init3, Draggable);
1348
+ var _placeholder_dec, _visible_dec, _c2, _init4, _visible, _placeholder;
1349
+ var Droppable = class extends (_c2 = Droppable$1, _visible_dec = [reactive], _placeholder_dec = [reactive], _c2) {
1350
+ constructor(_a3, manager) {
1351
+ var _b2 = _a3, { element, effects: effects2 = () => [] } = _b2, input = __objRest(_b2, ["element", "effects"]);
1352
+ var _a4;
1267
1353
  const { collisionDetector = defaultCollisionDetection } = input;
1268
1354
  super(
1269
- {
1270
- ...input,
1355
+ __spreadProps(__spreadValues({}, input), {
1271
1356
  collisionDetector,
1272
1357
  effects: () => [
1273
1358
  ...effects2(),
1274
1359
  () => {
1275
1360
  const { element: element2, manager: manager2 } = this;
1361
+ if (!manager2) return;
1276
1362
  const { dragOperation } = manager2;
1277
1363
  if (element2 && dragOperation.status.initialized) {
1278
1364
  const scrollableAncestor = getFirstScrollableAncestor(element2);
@@ -1288,7 +1374,7 @@ var Droppable = class extends Droppable$1 {
1288
1374
  this.visible = entry.isIntersecting;
1289
1375
  },
1290
1376
  {
1291
- root: root ?? doc,
1377
+ root: root != null ? root : doc,
1292
1378
  rootMargin: "40%"
1293
1379
  }
1294
1380
  );
@@ -1316,34 +1402,36 @@ var Droppable = class extends Droppable$1 {
1316
1402
  },
1317
1403
  () => {
1318
1404
  const { manager: manager2 } = this;
1405
+ if (!manager2) return;
1319
1406
  const { dragOperation } = manager2;
1320
1407
  const { status } = dragOperation;
1321
1408
  const source = untracked(() => dragOperation.source);
1322
1409
  if (status.initialized) {
1323
- if (source?.type != null && !this.accepts(source)) {
1410
+ if ((source == null ? void 0 : source.type) != null && !this.accepts(source)) {
1324
1411
  return;
1325
1412
  }
1326
1413
  scheduler.schedule(this.refreshShape);
1327
1414
  }
1328
1415
  },
1329
1416
  () => {
1330
- const { manager: manager2 } = this;
1331
- if (manager2.dragOperation.status.initialized) {
1417
+ var _a5;
1418
+ if ((_a5 = this.manager) == null ? void 0 : _a5.dragOperation.status.initialized) {
1332
1419
  return () => {
1333
1420
  this.shape = void 0;
1334
1421
  };
1335
1422
  }
1336
1423
  }
1337
1424
  ]
1338
- },
1425
+ }),
1339
1426
  manager
1340
1427
  );
1341
- this.manager = manager;
1428
+ __privateAdd(this, _visible, __runInitializers(_init4, 8, this)), __runInitializers(_init4, 11, this);
1429
+ __privateAdd(this, _placeholder, __runInitializers(_init4, 12, this)), __runInitializers(_init4, 15, this);
1342
1430
  this.internal = {
1343
1431
  element: signal(element)
1344
1432
  };
1345
1433
  this.refreshShape = this.refreshShape.bind(this);
1346
- if (manager.dragOperation.status.initialized) {
1434
+ if ((_a4 = this.manager) == null ? void 0 : _a4.dragOperation.status.initialized) {
1347
1435
  this.visible = true;
1348
1436
  }
1349
1437
  }
@@ -1351,7 +1439,8 @@ var Droppable = class extends Droppable$1 {
1351
1439
  this.internal.element.value = value;
1352
1440
  }
1353
1441
  get element() {
1354
- return this.placeholder ?? this.internal?.element.value;
1442
+ var _a3, _b2;
1443
+ return (_b2 = this.placeholder) != null ? _b2 : (_a3 = this.internal) == null ? void 0 : _a3.element.value;
1355
1444
  }
1356
1445
  refreshShape(ignoreTransform) {
1357
1446
  const { element, shape } = this;
@@ -1360,19 +1449,19 @@ var Droppable = class extends Droppable$1 {
1360
1449
  return void 0;
1361
1450
  }
1362
1451
  const updatedShape = new DOMRectangle(element, ignoreTransform);
1363
- if (updatedShape && shape?.equals(updatedShape)) {
1452
+ if (updatedShape && (shape == null ? void 0 : shape.equals(updatedShape))) {
1364
1453
  return shape;
1365
1454
  }
1366
1455
  this.shape = updatedShape;
1367
1456
  return updatedShape;
1368
1457
  }
1369
1458
  };
1370
- __decorateClass([
1371
- reactive
1372
- ], Droppable.prototype, "visible");
1373
- __decorateClass([
1374
- reactive
1375
- ], Droppable.prototype, "placeholder");
1459
+ _init4 = __decoratorStart(_c2);
1460
+ _visible = new WeakMap();
1461
+ _placeholder = new WeakMap();
1462
+ __decorateElement(_init4, 4, "visible", _visible_dec, Droppable, _visible);
1463
+ __decorateElement(_init4, 4, "placeholder", _placeholder_dec, Droppable, _placeholder);
1464
+ __decoratorMetadata(_init4, Droppable);
1376
1465
 
1377
1466
  export { Accessibility, AutoScroller, DragDropManager, Draggable, Droppable, Feedback, KeyboardSensor, PointerSensor, ScrollListener, Scroller, defaultPreset };
1378
1467
  //# sourceMappingURL=out.js.map