bits-ui 2.8.1 → 2.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/bits/accordion/accordion.svelte.d.ts +6 -1
  2. package/dist/bits/accordion/accordion.svelte.js +15 -5
  3. package/dist/bits/aspect-ratio/aspect-ratio.svelte.d.ts +2 -1
  4. package/dist/bits/aspect-ratio/aspect-ratio.svelte.js +3 -1
  5. package/dist/bits/avatar/avatar.svelte.d.ts +4 -1
  6. package/dist/bits/avatar/avatar.svelte.js +9 -3
  7. package/dist/bits/calendar/calendar.svelte.d.ts +15 -1
  8. package/dist/bits/calendar/calendar.svelte.js +42 -14
  9. package/dist/bits/checkbox/checkbox.svelte.d.ts +4 -1
  10. package/dist/bits/checkbox/checkbox.svelte.js +13 -3
  11. package/dist/bits/collapsible/collapsible.svelte.d.ts +5 -1
  12. package/dist/bits/collapsible/collapsible.svelte.js +15 -4
  13. package/dist/bits/command/command.svelte.d.ts +13 -1
  14. package/dist/bits/command/command.svelte.js +36 -12
  15. package/dist/bits/date-field/date-field.svelte.d.ts +8 -2
  16. package/dist/bits/date-field/date-field.svelte.js +18 -6
  17. package/dist/bits/date-range-field/date-range-field.svelte.d.ts +3 -1
  18. package/dist/bits/date-range-field/date-range-field.svelte.js +6 -2
  19. package/dist/bits/dialog/dialog.svelte.d.ts +9 -1
  20. package/dist/bits/dialog/dialog.svelte.js +41 -19
  21. package/dist/bits/label/label.svelte.d.ts +2 -1
  22. package/dist/bits/label/label.svelte.js +3 -1
  23. package/dist/bits/link-preview/link-preview.svelte.d.ts +3 -1
  24. package/dist/bits/link-preview/link-preview.svelte.js +6 -2
  25. package/dist/bits/menu/menu.svelte.d.ts +12 -1
  26. package/dist/bits/menu/menu.svelte.js +37 -15
  27. package/dist/bits/menubar/components/menubar-trigger.svelte +4 -3
  28. package/dist/bits/menubar/menubar.svelte.d.ts +4 -1
  29. package/dist/bits/menubar/menubar.svelte.js +9 -3
  30. package/dist/bits/meter/meter.svelte.d.ts +2 -1
  31. package/dist/bits/meter/meter.svelte.js +3 -1
  32. package/dist/bits/navigation-menu/navigation-menu.svelte.d.ts +14 -3
  33. package/dist/bits/navigation-menu/navigation-menu.svelte.js +33 -13
  34. package/dist/bits/pagination/pagination.svelte.d.ts +4 -1
  35. package/dist/bits/pagination/pagination.svelte.js +9 -3
  36. package/dist/bits/pin-input/pin-input.svelte.d.ts +4 -1
  37. package/dist/bits/pin-input/pin-input.svelte.js +8 -3
  38. package/dist/bits/popover/popover.svelte.d.ts +4 -1
  39. package/dist/bits/popover/popover.svelte.js +9 -3
  40. package/dist/bits/progress/progress.svelte.d.ts +2 -1
  41. package/dist/bits/progress/progress.svelte.js +3 -1
  42. package/dist/bits/radio-group/radio-group.svelte.d.ts +3 -1
  43. package/dist/bits/radio-group/radio-group.svelte.js +6 -2
  44. package/dist/bits/range-calendar/range-calendar.svelte.d.ts +4 -1
  45. package/dist/bits/range-calendar/range-calendar.svelte.js +9 -3
  46. package/dist/bits/rating-group/rating-group.svelte.d.ts +3 -1
  47. package/dist/bits/rating-group/rating-group.svelte.js +6 -2
  48. package/dist/bits/scroll-area/scroll-area.svelte.d.ts +8 -1
  49. package/dist/bits/scroll-area/scroll-area.svelte.js +20 -7
  50. package/dist/bits/select/select.svelte.d.ts +10 -1
  51. package/dist/bits/select/select.svelte.js +27 -9
  52. package/dist/bits/separator/separator.svelte.d.ts +2 -1
  53. package/dist/bits/separator/separator.svelte.js +3 -1
  54. package/dist/bits/slider/slider.svelte.d.ts +7 -1
  55. package/dist/bits/slider/slider.svelte.js +18 -6
  56. package/dist/bits/switch/switch.svelte.d.ts +3 -1
  57. package/dist/bits/switch/switch.svelte.js +6 -2
  58. package/dist/bits/tabs/tabs.svelte.d.ts +5 -1
  59. package/dist/bits/tabs/tabs.svelte.js +12 -4
  60. package/dist/bits/time-field/time-field.svelte.d.ts +7 -1
  61. package/dist/bits/time-field/time-field.svelte.js +18 -6
  62. package/dist/bits/time-range-field/time-range-field.svelte.d.ts +3 -1
  63. package/dist/bits/time-range-field/time-range-field.svelte.js +6 -2
  64. package/dist/bits/toggle/toggle.svelte.d.ts +2 -1
  65. package/dist/bits/toggle/toggle.svelte.js +3 -1
  66. package/dist/bits/toggle-group/toggle-group.svelte.d.ts +3 -1
  67. package/dist/bits/toggle-group/toggle-group.svelte.js +6 -2
  68. package/dist/bits/toolbar/toolbar.svelte.d.ts +6 -1
  69. package/dist/bits/toolbar/toolbar.svelte.js +15 -5
  70. package/dist/bits/tooltip/tooltip.svelte.d.ts +3 -1
  71. package/dist/bits/tooltip/tooltip.svelte.js +6 -2
  72. package/dist/bits/utilities/floating-layer/use-floating-layer.svelte.d.ts +9 -0
  73. package/dist/bits/utilities/floating-layer/use-floating-layer.svelte.js +6 -3
  74. package/dist/internal/types.d.ts +2 -1
  75. package/package.json +9 -12
@@ -15,6 +15,7 @@ export class RangeCalendarRootState {
15
15
  return CalendarRootContext.set(new RangeCalendarRootState(opts));
16
16
  }
17
17
  opts;
18
+ attachment;
18
19
  visibleMonths = $derived.by(() => this.months.map((month) => month.value));
19
20
  months = $state([]);
20
21
  announcer;
@@ -109,6 +110,7 @@ export class RangeCalendarRootState {
109
110
  });
110
111
  constructor(opts) {
111
112
  this.opts = opts;
113
+ this.attachment = attachRef(opts.ref);
112
114
  this.domContext = new DOMContext(opts.ref);
113
115
  this.announcer = getAnnouncer(null);
114
116
  this.formatter = createFormatter({
@@ -519,7 +521,7 @@ export class RangeCalendarRootState {
519
521
  [this.getBitsAttr("root")]: "",
520
522
  //
521
523
  onkeydown: this.onkeydown,
522
- ...attachRef(this.opts.ref),
524
+ ...this.attachment,
523
525
  }));
524
526
  #hasDisabledDatesInRange(start, end) {
525
527
  for (let date = start; isBefore(date, end) || isSameDay(date, end); date = date.add({ days: 1 })) {
@@ -535,6 +537,7 @@ export class RangeCalendarCellState {
535
537
  }
536
538
  opts;
537
539
  root;
540
+ attachment;
538
541
  cellDate = $derived.by(() => toDate(this.opts.date.current));
539
542
  isDisabled = $derived.by(() => this.root.isDateDisabled(this.opts.date.current));
540
543
  isUnavailable = $derived.by(() => this.root.opts.isDateUnavailable.current(this.opts.date.current));
@@ -567,6 +570,7 @@ export class RangeCalendarCellState {
567
570
  constructor(opts, root) {
568
571
  this.opts = opts;
569
572
  this.root = root;
573
+ this.attachment = attachRef(opts.ref);
570
574
  }
571
575
  snippetProps = $derived.by(() => ({
572
576
  disabled: this.isDisabled,
@@ -603,7 +607,7 @@ export class RangeCalendarCellState {
603
607
  "aria-disabled": getAriaDisabled(this.ariaDisabled),
604
608
  ...this.sharedDataAttrs,
605
609
  [this.root.getBitsAttr("cell")]: "",
606
- ...attachRef(this.opts.ref),
610
+ ...this.attachment,
607
611
  }));
608
612
  }
609
613
  export class RangeCalendarDayState {
@@ -612,9 +616,11 @@ export class RangeCalendarDayState {
612
616
  }
613
617
  opts;
614
618
  cell;
619
+ attachment;
615
620
  constructor(opts, cell) {
616
621
  this.opts = opts;
617
622
  this.cell = cell;
623
+ this.attachment = attachRef(opts.ref);
618
624
  this.onclick = this.onclick.bind(this);
619
625
  this.onmouseenter = this.onmouseenter.bind(this);
620
626
  this.onfocusin = this.onfocusin.bind(this);
@@ -660,6 +666,6 @@ export class RangeCalendarDayState {
660
666
  onclick: this.onclick,
661
667
  onmouseenter: this.onmouseenter,
662
668
  onfocusin: this.onfocusin,
663
- ...attachRef(this.opts.ref),
669
+ ...this.attachment,
664
670
  }));
665
671
  }
@@ -1,5 +1,5 @@
1
1
  import { DOMContext, type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
2
- import type { BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, WithRefOpts } from "../../internal/types.js";
2
+ import type { BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, RefAttachment, WithRefOpts } from "../../internal/types.js";
3
3
  import type { RatingGroupAriaValuetext, RatingGroupItemState as RatingGroupItemStateType } from "./types.js";
4
4
  import type { Orientation } from "../../shared/index.js";
5
5
  interface RatingGroupRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
@@ -21,6 +21,7 @@ export declare class RatingGroupRootState {
21
21
  #private;
22
22
  static create(opts: RatingGroupRootStateOpts): RatingGroupRootState;
23
23
  readonly opts: RatingGroupRootStateOpts;
24
+ readonly attachment: RefAttachment;
24
25
  domContext: DOMContext;
25
26
  readonly hasValue: boolean;
26
27
  readonly valueToUse: number;
@@ -80,6 +81,7 @@ export declare class RatingGroupItemState {
80
81
  static create(opts: RatingGroupItemStateOpts): RatingGroupItemState;
81
82
  readonly opts: RatingGroupItemStateOpts;
82
83
  readonly root: RatingGroupRootState;
84
+ readonly attachment: RefAttachment;
83
85
  constructor(opts: RatingGroupItemStateOpts, root: RatingGroupRootState);
84
86
  onclick(e: BitsMouseEvent): void;
85
87
  onpointermove(e: BitsPointerEvent): void;
@@ -12,6 +12,7 @@ export class RatingGroupRootState {
12
12
  return RatingGroupRootContext.set(new RatingGroupRootState(opts));
13
13
  }
14
14
  opts;
15
+ attachment;
15
16
  #hoverValue = $state(null);
16
17
  #keySequence = $state("");
17
18
  #keySequenceTimeout = null;
@@ -45,6 +46,7 @@ export class RatingGroupRootState {
45
46
  });
46
47
  constructor(opts) {
47
48
  this.opts = opts;
49
+ this.attachment = attachRef(opts.ref);
48
50
  this.onkeydown = this.onkeydown.bind(this);
49
51
  this.onpointerleave = this.onpointerleave.bind(this);
50
52
  this.domContext = new DOMContext(this.opts.ref);
@@ -216,7 +218,7 @@ export class RatingGroupRootState {
216
218
  [ratingGroupAttrs.root]: "",
217
219
  onkeydown: this.onkeydown,
218
220
  onpointerleave: this.onpointerleave,
219
- ...attachRef(this.opts.ref),
221
+ ...this.attachment,
220
222
  };
221
223
  });
222
224
  }
@@ -226,6 +228,7 @@ export class RatingGroupItemState {
226
228
  }
227
229
  opts;
228
230
  root;
231
+ attachment;
229
232
  #isDisabled = $derived.by(() => this.opts.disabled.current || this.root.opts.disabled.current);
230
233
  #isActive = $derived.by(() => this.root.isActive(this.opts.index.current));
231
234
  #isPartial = $derived.by(() => this.root.isPartial(this.opts.index.current));
@@ -239,6 +242,7 @@ export class RatingGroupItemState {
239
242
  constructor(opts, root) {
240
243
  this.opts = opts;
241
244
  this.root = root;
245
+ this.attachment = attachRef(opts.ref);
242
246
  this.onclick = this.onclick.bind(this);
243
247
  this.onpointermove = this.onpointermove.bind(this);
244
248
  }
@@ -295,7 +299,7 @@ export class RatingGroupItemState {
295
299
  //
296
300
  onclick: this.onclick,
297
301
  onpointermove: this.onpointermove,
298
- ...attachRef(this.opts.ref),
302
+ ...this.attachment,
299
303
  }));
300
304
  }
301
305
  export class RatingGroupHiddenInputState {
@@ -7,7 +7,7 @@
7
7
  import { Context } from "runed";
8
8
  import { DOMContext, type ReadableBoxedValues } from "svelte-toolbelt";
9
9
  import type { ScrollAreaType } from "./types.js";
10
- import type { BitsPointerEvent, WithRefOpts } from "../../internal/types.js";
10
+ import type { BitsPointerEvent, RefAttachment, WithRefOpts } from "../../internal/types.js";
11
11
  import { type Direction, type Orientation } from "../../shared/index.js";
12
12
  import { StateMachine } from "../../internal/state-machine.js";
13
13
  export declare const ScrollAreaRootContext: Context<ScrollAreaRootState>;
@@ -33,6 +33,7 @@ interface ScrollAreaRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
33
33
  export declare class ScrollAreaRootState {
34
34
  static create(opts: ScrollAreaRootStateOpts): ScrollAreaRootState;
35
35
  readonly opts: ScrollAreaRootStateOpts;
36
+ readonly attachment: RefAttachment;
36
37
  scrollAreaNode: HTMLElement | null;
37
38
  viewportNode: HTMLElement | null;
38
39
  contentNode: HTMLElement | null;
@@ -61,6 +62,8 @@ export declare class ScrollAreaViewportState {
61
62
  static create(opts: ScrollAreaViewportStateOpts): ScrollAreaViewportState;
62
63
  readonly opts: ScrollAreaViewportStateOpts;
63
64
  readonly root: ScrollAreaRootState;
65
+ readonly attachment: RefAttachment;
66
+ readonly contentAttachment: RefAttachment;
64
67
  constructor(opts: ScrollAreaViewportStateOpts, root: ScrollAreaRootState);
65
68
  readonly props: {
66
69
  readonly id: string;
@@ -199,6 +202,7 @@ export declare class ScrollAreaScrollbarXState implements ScrollbarAxisState {
199
202
  readonly scrollbarVis: ScrollAreaScrollbarVisibleState;
200
203
  readonly root: ScrollAreaRootState;
201
204
  readonly scrollbar: ScrollAreaScrollbarState;
205
+ readonly attachment: RefAttachment;
202
206
  computedStyle: CSSStyleDeclaration | undefined;
203
207
  constructor(opts: ScrollbarAxisStateOpts, scrollbarVis: ScrollAreaScrollbarVisibleState);
204
208
  onThumbPointerDown: (pointerPos: {
@@ -231,6 +235,7 @@ export declare class ScrollAreaScrollbarYState implements ScrollbarAxisState {
231
235
  readonly scrollbarVis: ScrollAreaScrollbarVisibleState;
232
236
  readonly root: ScrollAreaRootState;
233
237
  readonly scrollbar: ScrollAreaScrollbarState;
238
+ readonly attachment: RefAttachment;
234
239
  computedStyle: CSSStyleDeclaration | undefined;
235
240
  constructor(opts: ScrollbarAxisStateOpts, scrollbarVis: ScrollAreaScrollbarVisibleState);
236
241
  onThumbPointerDown(pointerPos: {
@@ -292,6 +297,7 @@ export declare class ScrollAreaThumbImplState {
292
297
  static create(opts: ScrollAreaThumbImplStateOpts): ScrollAreaThumbImplState;
293
298
  readonly opts: ScrollAreaThumbImplStateOpts;
294
299
  readonly scrollbarState: ScrollAreaScrollbarSharedState;
300
+ readonly attachment: RefAttachment;
295
301
  constructor(opts: ScrollAreaThumbImplStateOpts, scrollbarState: ScrollAreaScrollbarSharedState);
296
302
  onpointerdowncapture(e: BitsPointerEvent): void;
297
303
  onpointerup(_: BitsPointerEvent): void;
@@ -314,6 +320,7 @@ export declare class ScrollAreaCornerImplState {
314
320
  static create(opts: ScrollAreaCornerImplStateOpts): ScrollAreaCornerImplState;
315
321
  readonly opts: ScrollAreaCornerImplStateOpts;
316
322
  readonly root: ScrollAreaRootState;
323
+ readonly attachment: RefAttachment;
317
324
  readonly hasSize: boolean;
318
325
  constructor(opts: ScrollAreaCornerImplStateOpts, root: ScrollAreaRootState);
319
326
  readonly props: {
@@ -28,6 +28,7 @@ export class ScrollAreaRootState {
28
28
  return ScrollAreaRootContext.set(new ScrollAreaRootState(opts));
29
29
  }
30
30
  opts;
31
+ attachment;
31
32
  scrollAreaNode = $state(null);
32
33
  viewportNode = $state(null);
33
34
  contentNode = $state(null);
@@ -40,6 +41,7 @@ export class ScrollAreaRootState {
40
41
  domContext;
41
42
  constructor(opts) {
42
43
  this.opts = opts;
44
+ this.attachment = attachRef(opts.ref, (v) => (this.scrollAreaNode = v));
43
45
  this.domContext = new DOMContext(opts.ref);
44
46
  }
45
47
  props = $derived.by(() => ({
@@ -51,7 +53,7 @@ export class ScrollAreaRootState {
51
53
  "--bits-scroll-area-corner-width": `${this.cornerWidth}px`,
52
54
  },
53
55
  [scrollAreaAttrs.root]: "",
54
- ...attachRef(this.opts.ref, (v) => (this.scrollAreaNode = v)),
56
+ ...this.attachment,
55
57
  }));
56
58
  }
57
59
  export class ScrollAreaViewportState {
@@ -60,11 +62,14 @@ export class ScrollAreaViewportState {
60
62
  }
61
63
  opts;
62
64
  root;
65
+ attachment;
63
66
  #contentId = box(useId());
64
67
  #contentRef = box(null);
68
+ contentAttachment = attachRef(this.#contentRef, (v) => (this.root.contentNode = v));
65
69
  constructor(opts, root) {
66
70
  this.opts = opts;
67
71
  this.root = root;
72
+ this.attachment = attachRef(opts.ref, (v) => (this.root.viewportNode = v));
68
73
  }
69
74
  props = $derived.by(() => ({
70
75
  id: this.opts.id.current,
@@ -73,7 +78,7 @@ export class ScrollAreaViewportState {
73
78
  overflowY: this.root.scrollbarYEnabled ? "scroll" : "hidden",
74
79
  },
75
80
  [scrollAreaAttrs.viewport]: "",
76
- ...attachRef(this.opts.ref, (v) => (this.root.viewportNode = v)),
81
+ ...this.attachment,
77
82
  }));
78
83
  contentProps = $derived.by(() => ({
79
84
  id: this.#contentId.current,
@@ -86,7 +91,7 @@ export class ScrollAreaViewportState {
86
91
  * be constrained by the parent container to enable `text-overflow: ellipsis`
87
92
  */
88
93
  style: { minWidth: this.root.scrollbarXEnabled ? "fit-content" : undefined },
89
- ...attachRef(this.#contentRef, (v) => (this.root.contentNode = v)),
94
+ ...this.contentAttachment,
90
95
  }));
91
96
  }
92
97
  export class ScrollAreaScrollbarState {
@@ -351,12 +356,14 @@ export class ScrollAreaScrollbarXState {
351
356
  scrollbarVis;
352
357
  root;
353
358
  scrollbar;
359
+ attachment;
354
360
  computedStyle = $state();
355
361
  constructor(opts, scrollbarVis) {
356
362
  this.opts = opts;
357
363
  this.scrollbarVis = scrollbarVis;
358
364
  this.root = scrollbarVis.root;
359
365
  this.scrollbar = scrollbarVis.scrollbar;
366
+ this.attachment = attachRef(this.scrollbar.opts.ref, (v) => (this.root.scrollbarXNode = v));
360
367
  $effect(() => {
361
368
  if (!this.scrollbar.opts.ref.current)
362
369
  return;
@@ -421,7 +428,7 @@ export class ScrollAreaScrollbarXState {
421
428
  : 0,
422
429
  "--bits-scroll-area-thumb-width": `${this.thumbSize}px`,
423
430
  },
424
- ...attachRef(this.scrollbar.opts.ref, (v) => (this.root.scrollbarXNode = v)),
431
+ ...this.attachment,
425
432
  }));
426
433
  }
427
434
  export class ScrollAreaScrollbarYState {
@@ -432,12 +439,14 @@ export class ScrollAreaScrollbarYState {
432
439
  scrollbarVis;
433
440
  root;
434
441
  scrollbar;
442
+ attachment;
435
443
  computedStyle = $state();
436
444
  constructor(opts, scrollbarVis) {
437
445
  this.opts = opts;
438
446
  this.scrollbarVis = scrollbarVis;
439
447
  this.root = scrollbarVis.root;
440
448
  this.scrollbar = scrollbarVis.scrollbar;
449
+ this.attachment = attachRef(this.scrollbar.opts.ref, (v) => (this.root.scrollbarYNode = v));
441
450
  $effect(() => {
442
451
  if (!this.scrollbar.opts.ref.current)
443
452
  return;
@@ -505,7 +514,7 @@ export class ScrollAreaScrollbarYState {
505
514
  bottom: "var(--bits-scroll-area-corner-height)",
506
515
  "--bits-scroll-area-thumb-height": `${this.thumbSize}px`,
507
516
  },
508
- ...attachRef(this.scrollbar.opts.ref, (v) => (this.root.scrollbarYNode = v)),
517
+ ...this.attachment,
509
518
  }));
510
519
  }
511
520
  export class ScrollAreaScrollbarSharedState {
@@ -616,6 +625,7 @@ export class ScrollAreaThumbImplState {
616
625
  }
617
626
  opts;
618
627
  scrollbarState;
628
+ attachment;
619
629
  #root;
620
630
  #removeUnlinkedScrollListener = $state();
621
631
  #debounceScrollEnd = useDebounce(() => {
@@ -628,6 +638,7 @@ export class ScrollAreaThumbImplState {
628
638
  this.opts = opts;
629
639
  this.scrollbarState = scrollbarState;
630
640
  this.#root = scrollbarState.root;
641
+ this.attachment = attachRef(this.scrollbarState.scrollbar.opts.ref, (v) => (this.scrollbarState.scrollbarVis.thumbNode = v));
631
642
  $effect(() => {
632
643
  const viewportNode = this.#root.viewportNode;
633
644
  if (!viewportNode)
@@ -670,7 +681,7 @@ export class ScrollAreaThumbImplState {
670
681
  onpointerdowncapture: this.onpointerdowncapture,
671
682
  onpointerup: this.onpointerup,
672
683
  [scrollAreaAttrs.thumb]: "",
673
- ...attachRef(this.opts.ref, (v) => (this.scrollbarState.scrollbarVis.thumbNode = v)),
684
+ ...this.attachment,
674
685
  }));
675
686
  }
676
687
  export class ScrollAreaCornerImplState {
@@ -679,12 +690,14 @@ export class ScrollAreaCornerImplState {
679
690
  }
680
691
  opts;
681
692
  root;
693
+ attachment;
682
694
  #width = $state(0);
683
695
  #height = $state(0);
684
696
  hasSize = $derived(Boolean(this.#width && this.#height));
685
697
  constructor(opts, root) {
686
698
  this.opts = opts;
687
699
  this.root = root;
700
+ this.attachment = attachRef(this.opts.ref);
688
701
  new SvelteResizeObserver(() => this.root.scrollbarXNode, () => {
689
702
  const height = this.root.scrollbarXNode?.offsetHeight || 0;
690
703
  this.root.cornerHeight = height;
@@ -707,7 +720,7 @@ export class ScrollAreaCornerImplState {
707
720
  bottom: 0,
708
721
  },
709
722
  [scrollAreaAttrs.corner]: "",
710
- ...attachRef(this.opts.ref),
723
+ ...this.attachment,
711
724
  }));
712
725
  }
713
726
  function toInt(value) {
@@ -1,6 +1,6 @@
1
1
  import { Previous } from "runed";
2
2
  import { DOMContext, type ReadableBoxedValues, type WritableBoxedValues, type Box } from "svelte-toolbelt";
3
- import type { BitsEvent, BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, OnChangeFn, WithRefOpts } from "../../internal/types.js";
3
+ import type { BitsEvent, BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, OnChangeFn, WithRefOpts, RefAttachment } from "../../internal/types.js";
4
4
  export declare const INTERACTION_KEYS: string[];
5
5
  export declare const FIRST_KEYS: string[];
6
6
  export declare const LAST_KEYS: string[];
@@ -115,6 +115,7 @@ export declare class SelectInputState {
115
115
  static create(opts: SelectInputStateOpts): SelectInputState;
116
116
  readonly opts: SelectInputStateOpts;
117
117
  readonly root: SelectRoot;
118
+ readonly attachment: RefAttachment;
118
119
  constructor(opts: SelectInputStateOpts, root: SelectRoot);
119
120
  onkeydown(e: BitsKeyboardEvent): void;
120
121
  oninput(e: BitsEvent<Event, HTMLInputElement>): void;
@@ -137,6 +138,7 @@ export declare class SelectComboTriggerState {
137
138
  static create(opts: SelectComboTriggerStateOpts): SelectComboTriggerState;
138
139
  readonly opts: SelectComboTriggerStateOpts;
139
140
  readonly root: SelectBaseRootState;
141
+ readonly attachment: RefAttachment;
140
142
  constructor(opts: SelectComboTriggerStateOpts, root: SelectBaseRootState);
141
143
  onkeydown(e: BitsKeyboardEvent): void;
142
144
  /**
@@ -161,6 +163,7 @@ export declare class SelectTriggerState {
161
163
  static create(opts: SelectTriggerStateOpts): SelectTriggerState;
162
164
  readonly opts: SelectTriggerStateOpts;
163
165
  readonly root: SelectRoot;
166
+ readonly attachment: RefAttachment;
164
167
  constructor(opts: SelectTriggerStateOpts, root: SelectRoot);
165
168
  onkeydown(e: BitsKeyboardEvent): void;
166
169
  onclick(e: BitsMouseEvent): void;
@@ -191,6 +194,7 @@ export declare class SelectContentState {
191
194
  static create(opts: SelectContentStateOpts): SelectContentState;
192
195
  readonly opts: SelectContentStateOpts;
193
196
  readonly root: SelectRoot;
197
+ readonly attachment: RefAttachment;
194
198
  viewportNode: HTMLElement | null;
195
199
  isPositioned: boolean;
196
200
  domContext: DOMContext;
@@ -239,6 +243,7 @@ export declare class SelectItemState {
239
243
  static create(opts: SelectItemStateOpts): SelectItemState;
240
244
  readonly opts: SelectItemStateOpts;
241
245
  readonly root: SelectRoot;
246
+ readonly attachment: RefAttachment;
242
247
  readonly isSelected: boolean;
243
248
  readonly isHighlighted: boolean;
244
249
  readonly prevHighlighted: Previous<boolean>;
@@ -278,6 +283,7 @@ export declare class SelectGroupState {
278
283
  readonly opts: SelectGroupStateOpts;
279
284
  readonly root: SelectBaseRootState;
280
285
  labelNode: HTMLElement | null;
286
+ readonly attachment: RefAttachment;
281
287
  constructor(opts: SelectGroupStateOpts, root: SelectBaseRootState);
282
288
  readonly props: {
283
289
  readonly id: string;
@@ -291,6 +297,7 @@ export declare class SelectGroupHeadingState {
291
297
  static create(opts: SelectGroupHeadingStateOpts): SelectGroupHeadingState;
292
298
  readonly opts: SelectGroupHeadingStateOpts;
293
299
  readonly group: SelectGroupState;
300
+ readonly attachment: RefAttachment;
294
301
  constructor(opts: SelectGroupHeadingStateOpts, group: SelectGroupState);
295
302
  readonly props: {
296
303
  readonly id: string;
@@ -322,6 +329,7 @@ export declare class SelectViewportState {
322
329
  readonly opts: SelectViewportStateOpts;
323
330
  readonly content: SelectContentState;
324
331
  readonly root: SelectBaseRootState;
332
+ readonly attachment: RefAttachment;
325
333
  prevScrollTop: number;
326
334
  constructor(opts: SelectViewportStateOpts, content: SelectContentState);
327
335
  readonly props: {
@@ -342,6 +350,7 @@ export declare class SelectScrollButtonImplState {
342
350
  readonly opts: SelectScrollButtonImplStateOpts;
343
351
  readonly content: SelectContentState;
344
352
  readonly root: SelectBaseRootState;
353
+ readonly attachment: RefAttachment;
345
354
  autoScrollTimer: number | null;
346
355
  userScrollTimer: number;
347
356
  isUserScrolling: boolean;
@@ -256,9 +256,11 @@ export class SelectInputState {
256
256
  }
257
257
  opts;
258
258
  root;
259
+ attachment;
259
260
  constructor(opts, root) {
260
261
  this.opts = opts;
261
262
  this.root = root;
263
+ this.attachment = attachRef(opts.ref, (v) => (this.root.inputNode = v));
262
264
  this.root.domContext = new DOMContext(opts.ref);
263
265
  this.onkeydown = this.onkeydown.bind(this);
264
266
  this.oninput = this.oninput.bind(this);
@@ -384,7 +386,7 @@ export class SelectInputState {
384
386
  onkeydown: this.onkeydown,
385
387
  oninput: this.oninput,
386
388
  [this.root.getBitsAttr("input")]: "",
387
- ...attachRef(this.opts.ref, (v) => (this.root.inputNode = v)),
389
+ ...this.attachment,
388
390
  }));
389
391
  }
390
392
  export class SelectComboTriggerState {
@@ -393,9 +395,11 @@ export class SelectComboTriggerState {
393
395
  }
394
396
  opts;
395
397
  root;
398
+ attachment;
396
399
  constructor(opts, root) {
397
400
  this.opts = opts;
398
401
  this.root = root;
402
+ this.attachment = attachRef(opts.ref);
399
403
  this.onkeydown = this.onkeydown.bind(this);
400
404
  this.onpointerdown = this.onpointerdown.bind(this);
401
405
  }
@@ -432,7 +436,7 @@ export class SelectComboTriggerState {
432
436
  [this.root.getBitsAttr("trigger")]: "",
433
437
  onpointerdown: this.onpointerdown,
434
438
  onkeydown: this.onkeydown,
435
- ...attachRef(this.opts.ref),
439
+ ...this.attachment,
436
440
  }));
437
441
  }
438
442
  export class SelectTriggerState {
@@ -441,11 +445,13 @@ export class SelectTriggerState {
441
445
  }
442
446
  opts;
443
447
  root;
448
+ attachment;
444
449
  #domTypeahead;
445
450
  #dataTypeahead;
446
451
  constructor(opts, root) {
447
452
  this.opts = opts;
448
453
  this.root = root;
454
+ this.attachment = attachRef(opts.ref, (v) => (this.root.triggerNode = v));
449
455
  this.root.domContext = new DOMContext(opts.ref);
450
456
  this.#domTypeahead = new DOMTypeahead({
451
457
  getCurrentItem: () => this.root.highlightedNode,
@@ -670,7 +676,7 @@ export class SelectTriggerState {
670
676
  onkeydown: this.onkeydown,
671
677
  onclick: this.onclick,
672
678
  onpointerup: this.onpointerup,
673
- ...attachRef(this.opts.ref, (v) => (this.root.triggerNode = v)),
679
+ ...this.attachment,
674
680
  }));
675
681
  }
676
682
  export class SelectContentState {
@@ -679,12 +685,14 @@ export class SelectContentState {
679
685
  }
680
686
  opts;
681
687
  root;
688
+ attachment;
682
689
  viewportNode = $state(null);
683
690
  isPositioned = $state(false);
684
691
  domContext;
685
692
  constructor(opts, root) {
686
693
  this.opts = opts;
687
694
  this.root = root;
695
+ this.attachment = attachRef(opts.ref, (v) => (this.root.contentNode = v));
688
696
  this.domContext = new DOMContext(this.opts.ref);
689
697
  if (this.root.domContext === null) {
690
698
  this.root.domContext = this.domContext;
@@ -744,7 +752,7 @@ export class SelectContentState {
744
752
  ...this.#styles,
745
753
  },
746
754
  onpointermove: this.onpointermove,
747
- ...attachRef(this.opts.ref, (v) => (this.root.contentNode = v)),
755
+ ...this.attachment,
748
756
  }));
749
757
  popperProps = {
750
758
  onInteractOutside: this.onInteractOutside,
@@ -768,6 +776,7 @@ export class SelectItemState {
768
776
  }
769
777
  opts;
770
778
  root;
779
+ attachment;
771
780
  isSelected = $derived.by(() => this.root.includesItem(this.opts.value.current));
772
781
  isHighlighted = $derived.by(() => this.root.highlightedValue === this.opts.value.current);
773
782
  prevHighlighted = new Previous(() => this.isHighlighted);
@@ -775,6 +784,7 @@ export class SelectItemState {
775
784
  constructor(opts, root) {
776
785
  this.opts = opts;
777
786
  this.root = root;
787
+ this.attachment = attachRef(opts.ref);
778
788
  watch([() => this.isHighlighted, () => this.prevHighlighted.current], () => {
779
789
  if (this.isHighlighted) {
780
790
  this.opts.onHighlight.current();
@@ -878,7 +888,7 @@ export class SelectItemState {
878
888
  onpointermove: this.onpointermove,
879
889
  onpointerdown: this.onpointerdown,
880
890
  onpointerup: this.onpointerup,
881
- ...attachRef(this.opts.ref),
891
+ ...this.attachment,
882
892
  }));
883
893
  }
884
894
  export class SelectGroupState {
@@ -888,16 +898,18 @@ export class SelectGroupState {
888
898
  opts;
889
899
  root;
890
900
  labelNode = $state(null);
901
+ attachment;
891
902
  constructor(opts, root) {
892
903
  this.opts = opts;
893
904
  this.root = root;
905
+ this.attachment = attachRef(opts.ref);
894
906
  }
895
907
  props = $derived.by(() => ({
896
908
  id: this.opts.id.current,
897
909
  role: "group",
898
910
  [this.root.getBitsAttr("group")]: "",
899
911
  "aria-labelledby": this.labelNode?.id ?? undefined,
900
- ...attachRef(this.opts.ref),
912
+ ...this.attachment,
901
913
  }));
902
914
  }
903
915
  export class SelectGroupHeadingState {
@@ -906,14 +918,16 @@ export class SelectGroupHeadingState {
906
918
  }
907
919
  opts;
908
920
  group;
921
+ attachment;
909
922
  constructor(opts, group) {
910
923
  this.opts = opts;
911
924
  this.group = group;
925
+ this.attachment = attachRef(opts.ref, (v) => (this.group.labelNode = v));
912
926
  }
913
927
  props = $derived.by(() => ({
914
928
  id: this.opts.id.current,
915
929
  [this.group.root.getBitsAttr("group-label")]: "",
916
- ...attachRef(this.opts.ref, (v) => (this.group.labelNode = v)),
930
+ ...this.attachment,
917
931
  }));
918
932
  }
919
933
  export class SelectHiddenInputState {
@@ -952,11 +966,13 @@ export class SelectViewportState {
952
966
  opts;
953
967
  content;
954
968
  root;
969
+ attachment;
955
970
  prevScrollTop = $state(0);
956
971
  constructor(opts, content) {
957
972
  this.opts = opts;
958
973
  this.content = content;
959
974
  this.root = content.root;
975
+ this.attachment = attachRef(opts.ref, (v) => (this.content.viewportNode = v));
960
976
  }
961
977
  props = $derived.by(() => ({
962
978
  id: this.opts.id.current,
@@ -970,13 +986,14 @@ export class SelectViewportState {
970
986
  flex: 1,
971
987
  overflow: "auto",
972
988
  },
973
- ...attachRef(this.opts.ref, (v) => (this.content.viewportNode = v)),
989
+ ...this.attachment,
974
990
  }));
975
991
  }
976
992
  export class SelectScrollButtonImplState {
977
993
  opts;
978
994
  content;
979
995
  root;
996
+ attachment;
980
997
  autoScrollTimer = null;
981
998
  userScrollTimer = -1;
982
999
  isUserScrolling = false;
@@ -986,6 +1003,7 @@ export class SelectScrollButtonImplState {
986
1003
  this.opts = opts;
987
1004
  this.content = content;
988
1005
  this.root = content.root;
1006
+ this.attachment = attachRef(opts.ref);
989
1007
  watch([() => this.mounted], () => {
990
1008
  if (!this.mounted) {
991
1009
  this.isUserScrolling = false;
@@ -1040,7 +1058,7 @@ export class SelectScrollButtonImplState {
1040
1058
  onpointerdown: this.onpointerdown,
1041
1059
  onpointermove: this.onpointermove,
1042
1060
  onpointerleave: this.onpointerleave,
1043
- ...attachRef(this.opts.ref),
1061
+ ...this.attachment,
1044
1062
  }));
1045
1063
  }
1046
1064
  export class SelectScrollDownButtonState {
@@ -1,5 +1,5 @@
1
1
  import { type ReadableBoxedValues } from "svelte-toolbelt";
2
- import type { WithRefOpts } from "../../internal/types.js";
2
+ import type { RefAttachment, WithRefOpts } from "../../internal/types.js";
3
3
  import type { Orientation } from "../../shared/index.js";
4
4
  interface SeparatorRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
5
5
  orientation: Orientation;
@@ -9,6 +9,7 @@ interface SeparatorRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
9
9
  export declare class SeparatorRootState {
10
10
  static create(opts: SeparatorRootStateOpts): SeparatorRootState;
11
11
  readonly opts: SeparatorRootStateOpts;
12
+ readonly attachment: RefAttachment;
12
13
  constructor(opts: SeparatorRootStateOpts);
13
14
  readonly props: {
14
15
  readonly id: string;
@@ -9,8 +9,10 @@ export class SeparatorRootState {
9
9
  return new SeparatorRootState(opts);
10
10
  }
11
11
  opts;
12
+ attachment;
12
13
  constructor(opts) {
13
14
  this.opts = opts;
15
+ this.attachment = attachRef(opts.ref);
14
16
  }
15
17
  props = $derived.by(() => ({
16
18
  id: this.opts.id.current,
@@ -19,6 +21,6 @@ export class SeparatorRootState {
19
21
  "aria-hidden": getAriaHidden(this.opts.decorative.current),
20
22
  "data-orientation": getDataOrientation(this.opts.orientation.current),
21
23
  [separatorAttrs.root]: "",
22
- ...attachRef(this.opts.ref),
24
+ ...this.attachment,
23
25
  }));
24
26
  }