bits-ui 2.8.0 → 2.8.2

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 (99) 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/alert-dialog/components/alert-dialog-content.svelte +6 -9
  4. package/dist/bits/aspect-ratio/aspect-ratio.svelte.d.ts +2 -1
  5. package/dist/bits/aspect-ratio/aspect-ratio.svelte.js +3 -1
  6. package/dist/bits/avatar/avatar.svelte.d.ts +4 -1
  7. package/dist/bits/avatar/avatar.svelte.js +9 -3
  8. package/dist/bits/calendar/calendar.svelte.d.ts +15 -1
  9. package/dist/bits/calendar/calendar.svelte.js +42 -14
  10. package/dist/bits/calendar/components/calendar-next-button.svelte +3 -1
  11. package/dist/bits/calendar/components/calendar-prev-button.svelte +3 -1
  12. package/dist/bits/checkbox/checkbox.svelte.d.ts +4 -1
  13. package/dist/bits/checkbox/checkbox.svelte.js +9 -3
  14. package/dist/bits/collapsible/collapsible.svelte.d.ts +4 -1
  15. package/dist/bits/collapsible/collapsible.svelte.js +9 -3
  16. package/dist/bits/command/command.svelte.d.ts +13 -1
  17. package/dist/bits/command/command.svelte.js +36 -12
  18. package/dist/bits/context-menu/components/context-menu-content.svelte +1 -1
  19. package/dist/bits/date-field/date-field.svelte.d.ts +8 -2
  20. package/dist/bits/date-field/date-field.svelte.js +18 -6
  21. package/dist/bits/date-range-field/date-range-field.svelte.d.ts +3 -1
  22. package/dist/bits/date-range-field/date-range-field.svelte.js +6 -2
  23. package/dist/bits/dialog/components/dialog-content.svelte +5 -7
  24. package/dist/bits/dialog/dialog.svelte.d.ts +9 -1
  25. package/dist/bits/dialog/dialog.svelte.js +33 -18
  26. package/dist/bits/dropdown-menu/components/dropdown-menu-content.svelte +3 -2
  27. package/dist/bits/label/label.svelte.d.ts +2 -1
  28. package/dist/bits/label/label.svelte.js +3 -1
  29. package/dist/bits/link-preview/link-preview.svelte.d.ts +3 -1
  30. package/dist/bits/link-preview/link-preview.svelte.js +6 -2
  31. package/dist/bits/menu/menu.svelte.d.ts +12 -1
  32. package/dist/bits/menu/menu.svelte.js +38 -26
  33. package/dist/bits/menubar/components/menubar-trigger.svelte +4 -3
  34. package/dist/bits/menubar/menubar.svelte.d.ts +4 -3
  35. package/dist/bits/menubar/menubar.svelte.js +9 -6
  36. package/dist/bits/meter/meter.svelte.d.ts +2 -1
  37. package/dist/bits/meter/meter.svelte.js +3 -1
  38. package/dist/bits/navigation-menu/components/navigation-menu-link.svelte +2 -1
  39. package/dist/bits/navigation-menu/components/navigation-menu-trigger.svelte +2 -1
  40. package/dist/bits/navigation-menu/navigation-menu.svelte.d.ts +14 -3
  41. package/dist/bits/navigation-menu/navigation-menu.svelte.js +33 -13
  42. package/dist/bits/pagination/pagination.svelte.d.ts +4 -1
  43. package/dist/bits/pagination/pagination.svelte.js +9 -3
  44. package/dist/bits/pin-input/pin-input.svelte.d.ts +4 -1
  45. package/dist/bits/pin-input/pin-input.svelte.js +8 -3
  46. package/dist/bits/popover/popover.svelte.d.ts +4 -1
  47. package/dist/bits/popover/popover.svelte.js +9 -3
  48. package/dist/bits/progress/progress.svelte.d.ts +2 -1
  49. package/dist/bits/progress/progress.svelte.js +3 -1
  50. package/dist/bits/radio-group/radio-group.svelte.d.ts +3 -1
  51. package/dist/bits/radio-group/radio-group.svelte.js +6 -2
  52. package/dist/bits/range-calendar/range-calendar.svelte.d.ts +4 -1
  53. package/dist/bits/range-calendar/range-calendar.svelte.js +9 -3
  54. package/dist/bits/rating-group/rating-group.svelte.d.ts +3 -1
  55. package/dist/bits/rating-group/rating-group.svelte.js +6 -2
  56. package/dist/bits/scroll-area/scroll-area.svelte.d.ts +8 -1
  57. package/dist/bits/scroll-area/scroll-area.svelte.js +20 -7
  58. package/dist/bits/select/select.svelte.d.ts +10 -1
  59. package/dist/bits/select/select.svelte.js +27 -9
  60. package/dist/bits/separator/separator.svelte.d.ts +2 -1
  61. package/dist/bits/separator/separator.svelte.js +3 -1
  62. package/dist/bits/slider/slider.svelte.d.ts +7 -1
  63. package/dist/bits/slider/slider.svelte.js +18 -6
  64. package/dist/bits/switch/switch.svelte.d.ts +3 -1
  65. package/dist/bits/switch/switch.svelte.js +6 -2
  66. package/dist/bits/tabs/tabs.svelte.d.ts +5 -1
  67. package/dist/bits/tabs/tabs.svelte.js +12 -4
  68. package/dist/bits/time-field/time-field.svelte.d.ts +7 -1
  69. package/dist/bits/time-field/time-field.svelte.js +18 -6
  70. package/dist/bits/time-range-field/time-range-field.svelte.d.ts +3 -1
  71. package/dist/bits/time-range-field/time-range-field.svelte.js +6 -2
  72. package/dist/bits/toggle/toggle.svelte.d.ts +2 -1
  73. package/dist/bits/toggle/toggle.svelte.js +3 -1
  74. package/dist/bits/toggle-group/toggle-group.svelte.d.ts +3 -1
  75. package/dist/bits/toggle-group/toggle-group.svelte.js +6 -2
  76. package/dist/bits/toolbar/toolbar.svelte.d.ts +6 -1
  77. package/dist/bits/toolbar/toolbar.svelte.js +15 -5
  78. package/dist/bits/tooltip/tooltip.svelte.d.ts +3 -1
  79. package/dist/bits/tooltip/tooltip.svelte.js +6 -2
  80. package/dist/bits/utilities/floating-layer/use-floating-layer.svelte.d.ts +9 -0
  81. package/dist/bits/utilities/floating-layer/use-floating-layer.svelte.js +6 -3
  82. package/dist/bits/utilities/focus-scope/focus-scope-manager.d.ts +12 -0
  83. package/dist/bits/utilities/focus-scope/focus-scope-manager.js +40 -0
  84. package/dist/bits/utilities/focus-scope/focus-scope.svelte +6 -8
  85. package/dist/bits/utilities/focus-scope/focus-scope.svelte.d.ts +1 -0
  86. package/dist/bits/utilities/focus-scope/focus-scope.svelte.js +204 -0
  87. package/dist/bits/utilities/focus-scope/types.d.ts +2 -6
  88. package/dist/bits/utilities/popper-layer/popper-layer-inner.svelte +2 -2
  89. package/dist/internal/focus.js +1 -1
  90. package/dist/internal/should-enable-focus-trap.d.ts +5 -0
  91. package/dist/internal/should-enable-focus-trap.js +5 -0
  92. package/dist/internal/types.d.ts +2 -1
  93. package/package.json +2 -2
  94. package/dist/bits/utilities/focus-scope/focus-scope-stack.svelte.d.ts +0 -14
  95. package/dist/bits/utilities/focus-scope/focus-scope-stack.svelte.js +0 -50
  96. package/dist/bits/utilities/focus-scope/use-focus-scope.svelte.d.ts +0 -49
  97. package/dist/bits/utilities/focus-scope/use-focus-scope.svelte.js +0 -218
  98. package/dist/internal/should-trap-focus.d.ts +0 -6
  99. package/dist/internal/should-trap-focus.js +0 -5
@@ -19,10 +19,12 @@ export class CalendarRootState {
19
19
  formatter;
20
20
  accessibleHeadingId = useId();
21
21
  domContext;
22
+ attachment;
22
23
  months = $state([]);
23
24
  announcer;
24
25
  constructor(opts) {
25
26
  this.opts = opts;
27
+ this.attachment = attachRef(this.opts.ref);
26
28
  this.domContext = new DOMContext(opts.ref);
27
29
  this.announcer = getAnnouncer(null);
28
30
  this.formatter = createFormatter({
@@ -416,7 +418,7 @@ export class CalendarRootState {
416
418
  [this.getBitsAttr("root")]: "",
417
419
  //
418
420
  onkeydown: this.onkeydown,
419
- ...attachRef(this.opts.ref),
421
+ ...this.attachment,
420
422
  }));
421
423
  }
422
424
  export class CalendarHeadingState {
@@ -425,9 +427,11 @@ export class CalendarHeadingState {
425
427
  }
426
428
  opts;
427
429
  root;
430
+ attachment;
428
431
  constructor(opts, root) {
429
432
  this.opts = opts;
430
433
  this.root = root;
434
+ this.attachment = attachRef(this.opts.ref);
431
435
  }
432
436
  props = $derived.by(() => ({
433
437
  id: this.opts.id.current,
@@ -435,7 +439,7 @@ export class CalendarHeadingState {
435
439
  "data-disabled": getDataDisabled(this.root.opts.disabled.current),
436
440
  "data-readonly": getDataReadonly(this.root.opts.readonly.current),
437
441
  [this.root.getBitsAttr("heading")]: "",
438
- ...attachRef(this.opts.ref),
442
+ ...this.attachment,
439
443
  }));
440
444
  }
441
445
  const CalendarCellContext = new Context("Calendar.Cell | RangeCalendar.Cell");
@@ -459,9 +463,11 @@ export class CalendarCellState {
459
463
  day: "numeric",
460
464
  year: "numeric",
461
465
  }));
466
+ attachment;
462
467
  constructor(opts, root) {
463
468
  this.opts = opts;
464
469
  this.root = root;
470
+ this.attachment = attachRef(this.opts.ref);
465
471
  }
466
472
  snippetProps = $derived.by(() => ({
467
473
  disabled: this.isDisabled,
@@ -492,7 +498,7 @@ export class CalendarCellState {
492
498
  "aria-disabled": getAriaDisabled(this.ariaDisabled),
493
499
  ...this.sharedDataAttrs,
494
500
  [this.root.getBitsAttr("cell")]: "",
495
- ...attachRef(this.opts.ref),
501
+ ...this.attachment,
496
502
  }));
497
503
  }
498
504
  export class CalendarDayState {
@@ -501,10 +507,12 @@ export class CalendarDayState {
501
507
  }
502
508
  opts;
503
509
  cell;
510
+ attachment;
504
511
  constructor(opts, cell) {
505
512
  this.opts = opts;
506
513
  this.cell = cell;
507
514
  this.onclick = this.onclick.bind(this);
515
+ this.attachment = attachRef(this.opts.ref);
508
516
  }
509
517
  #tabindex = $derived.by(() => (this.cell.isOutsideMonth && this.cell.root.opts.disableDaysOutsideMonth.current) ||
510
518
  this.cell.isDisabled
@@ -535,7 +543,7 @@ export class CalendarDayState {
535
543
  "data-bits-day": "",
536
544
  //
537
545
  onclick: this.onclick,
538
- ...attachRef(this.opts.ref),
546
+ ...this.attachment,
539
547
  }));
540
548
  }
541
549
  export class CalendarNextButtonState {
@@ -545,10 +553,12 @@ export class CalendarNextButtonState {
545
553
  opts;
546
554
  root;
547
555
  isDisabled = $derived.by(() => this.root.isNextButtonDisabled);
556
+ attachment;
548
557
  constructor(opts, root) {
549
558
  this.opts = opts;
550
559
  this.root = root;
551
560
  this.onclick = this.onclick.bind(this);
561
+ this.attachment = attachRef(this.opts.ref);
552
562
  }
553
563
  onclick(_) {
554
564
  if (this.isDisabled)
@@ -566,7 +576,7 @@ export class CalendarNextButtonState {
566
576
  [this.root.getBitsAttr("next-button")]: "",
567
577
  //
568
578
  onclick: this.onclick,
569
- ...attachRef(this.opts.ref),
579
+ ...this.attachment,
570
580
  }));
571
581
  }
572
582
  export class CalendarPrevButtonState {
@@ -576,10 +586,12 @@ export class CalendarPrevButtonState {
576
586
  opts;
577
587
  root;
578
588
  isDisabled = $derived.by(() => this.root.isPrevButtonDisabled);
589
+ attachment;
579
590
  constructor(opts, root) {
580
591
  this.opts = opts;
581
592
  this.root = root;
582
593
  this.onclick = this.onclick.bind(this);
594
+ this.attachment = attachRef(this.opts.ref);
583
595
  }
584
596
  onclick(_) {
585
597
  if (this.isDisabled)
@@ -597,7 +609,7 @@ export class CalendarPrevButtonState {
597
609
  [this.root.getBitsAttr("prev-button")]: "",
598
610
  //
599
611
  onclick: this.onclick,
600
- ...attachRef(this.opts.ref),
612
+ ...this.attachment,
601
613
  }));
602
614
  }
603
615
  export class CalendarGridState {
@@ -606,9 +618,11 @@ export class CalendarGridState {
606
618
  }
607
619
  opts;
608
620
  root;
621
+ attachment;
609
622
  constructor(opts, root) {
610
623
  this.opts = opts;
611
624
  this.root = root;
625
+ this.attachment = attachRef(this.opts.ref);
612
626
  }
613
627
  props = $derived.by(() => ({
614
628
  id: this.opts.id.current,
@@ -619,7 +633,7 @@ export class CalendarGridState {
619
633
  "data-readonly": getDataReadonly(this.root.opts.readonly.current),
620
634
  "data-disabled": getDataDisabled(this.root.opts.disabled.current),
621
635
  [this.root.getBitsAttr("grid")]: "",
622
- ...attachRef(this.opts.ref),
636
+ ...this.attachment,
623
637
  }));
624
638
  }
625
639
  export class CalendarGridBodyState {
@@ -628,16 +642,18 @@ export class CalendarGridBodyState {
628
642
  }
629
643
  opts;
630
644
  root;
645
+ attachment;
631
646
  constructor(opts, root) {
632
647
  this.opts = opts;
633
648
  this.root = root;
649
+ this.attachment = attachRef(this.opts.ref);
634
650
  }
635
651
  props = $derived.by(() => ({
636
652
  id: this.opts.id.current,
637
653
  "data-disabled": getDataDisabled(this.root.opts.disabled.current),
638
654
  "data-readonly": getDataReadonly(this.root.opts.readonly.current),
639
655
  [this.root.getBitsAttr("grid-body")]: "",
640
- ...attachRef(this.opts.ref),
656
+ ...this.attachment,
641
657
  }));
642
658
  }
643
659
  export class CalendarGridHeadState {
@@ -646,16 +662,18 @@ export class CalendarGridHeadState {
646
662
  }
647
663
  opts;
648
664
  root;
665
+ attachment;
649
666
  constructor(opts, root) {
650
667
  this.opts = opts;
651
668
  this.root = root;
669
+ this.attachment = attachRef(this.opts.ref);
652
670
  }
653
671
  props = $derived.by(() => ({
654
672
  id: this.opts.id.current,
655
673
  "data-disabled": getDataDisabled(this.root.opts.disabled.current),
656
674
  "data-readonly": getDataReadonly(this.root.opts.readonly.current),
657
675
  [this.root.getBitsAttr("grid-head")]: "",
658
- ...attachRef(this.opts.ref),
676
+ ...this.attachment,
659
677
  }));
660
678
  }
661
679
  export class CalendarGridRowState {
@@ -664,16 +682,18 @@ export class CalendarGridRowState {
664
682
  }
665
683
  opts;
666
684
  root;
685
+ attachment;
667
686
  constructor(opts, root) {
668
687
  this.opts = opts;
669
688
  this.root = root;
689
+ this.attachment = attachRef(this.opts.ref);
670
690
  }
671
691
  props = $derived.by(() => ({
672
692
  id: this.opts.id.current,
673
693
  "data-disabled": getDataDisabled(this.root.opts.disabled.current),
674
694
  "data-readonly": getDataReadonly(this.root.opts.readonly.current),
675
695
  [this.root.getBitsAttr("grid-row")]: "",
676
- ...attachRef(this.opts.ref),
696
+ ...this.attachment,
677
697
  }));
678
698
  }
679
699
  export class CalendarHeadCellState {
@@ -682,16 +702,18 @@ export class CalendarHeadCellState {
682
702
  }
683
703
  opts;
684
704
  root;
705
+ attachment;
685
706
  constructor(opts, root) {
686
707
  this.opts = opts;
687
708
  this.root = root;
709
+ this.attachment = attachRef(this.opts.ref);
688
710
  }
689
711
  props = $derived.by(() => ({
690
712
  id: this.opts.id.current,
691
713
  "data-disabled": getDataDisabled(this.root.opts.disabled.current),
692
714
  "data-readonly": getDataReadonly(this.root.opts.readonly.current),
693
715
  [this.root.getBitsAttr("head-cell")]: "",
694
- ...attachRef(this.opts.ref),
716
+ ...this.attachment,
695
717
  }));
696
718
  }
697
719
  export class CalendarHeaderState {
@@ -700,16 +722,18 @@ export class CalendarHeaderState {
700
722
  }
701
723
  opts;
702
724
  root;
725
+ attachment;
703
726
  constructor(opts, root) {
704
727
  this.opts = opts;
705
728
  this.root = root;
729
+ this.attachment = attachRef(this.opts.ref);
706
730
  }
707
731
  props = $derived.by(() => ({
708
732
  id: this.opts.id.current,
709
733
  "data-disabled": getDataDisabled(this.root.opts.disabled.current),
710
734
  "data-readonly": getDataReadonly(this.root.opts.readonly.current),
711
735
  [this.root.getBitsAttr("header")]: "",
712
- ...attachRef(this.opts.ref),
736
+ ...this.attachment,
713
737
  }));
714
738
  }
715
739
  export class CalendarMonthSelectState {
@@ -718,10 +742,12 @@ export class CalendarMonthSelectState {
718
742
  }
719
743
  opts;
720
744
  root;
745
+ attachment;
721
746
  constructor(opts, root) {
722
747
  this.opts = opts;
723
748
  this.root = root;
724
749
  this.onchange = this.onchange.bind(this);
750
+ this.attachment = attachRef(this.opts.ref);
725
751
  }
726
752
  monthItems = $derived.by(() => {
727
753
  this.root.opts.locale.current;
@@ -770,7 +796,7 @@ export class CalendarMonthSelectState {
770
796
  [this.root.getBitsAttr("month-select")]: "",
771
797
  //
772
798
  onchange: this.onchange,
773
- ...attachRef(this.opts.ref),
799
+ ...this.attachment,
774
800
  }));
775
801
  }
776
802
  export class CalendarYearSelectState {
@@ -779,10 +805,12 @@ export class CalendarYearSelectState {
779
805
  }
780
806
  opts;
781
807
  root;
808
+ attachment;
782
809
  constructor(opts, root) {
783
810
  this.opts = opts;
784
811
  this.root = root;
785
812
  this.onchange = this.onchange.bind(this);
813
+ this.attachment = attachRef(this.opts.ref);
786
814
  }
787
815
  years = $derived.by(() => {
788
816
  if (this.opts.years.current && this.opts.years.current.length)
@@ -835,6 +863,6 @@ export class CalendarYearSelectState {
835
863
  [this.root.getBitsAttr("year-select")]: "",
836
864
  //
837
865
  onchange: this.onchange,
838
- ...attachRef(this.opts.ref),
866
+ ...this.attachment,
839
867
  }));
840
868
  }
@@ -11,6 +11,8 @@
11
11
  child,
12
12
  id = createId(uid),
13
13
  ref = $bindable(null),
14
+ // for safari
15
+ tabindex = 0,
14
16
  ...restProps
15
17
  }: CalendarNextButtonProps = $props();
16
18
 
@@ -22,7 +24,7 @@
22
24
  ),
23
25
  });
24
26
 
25
- const mergedProps = $derived(mergeProps(restProps, nextButtonState.props));
27
+ const mergedProps = $derived(mergeProps(restProps, nextButtonState.props, { tabindex }));
26
28
  </script>
27
29
 
28
30
  {#if child}
@@ -11,6 +11,8 @@
11
11
  child,
12
12
  id = createId(uid),
13
13
  ref = $bindable(null),
14
+ // for safari
15
+ tabindex = 0,
14
16
  ...restProps
15
17
  }: CalendarPrevButtonProps = $props();
16
18
 
@@ -22,7 +24,7 @@
22
24
  ),
23
25
  });
24
26
 
25
- const mergedProps = $derived(mergeProps(restProps, prevButtonState.props));
27
+ const mergedProps = $derived(mergeProps(restProps, prevButtonState.props, { tabindex }));
26
28
  </script>
27
29
 
28
30
  {#if child}
@@ -1,7 +1,7 @@
1
1
  import { type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
2
2
  import type { HTMLButtonAttributes } from "svelte/elements";
3
3
  import { Context } from "runed";
4
- import type { BitsKeyboardEvent, BitsMouseEvent, OnChangeFn, WithRefOpts } from "../../internal/types.js";
4
+ import type { BitsKeyboardEvent, BitsMouseEvent, OnChangeFn, RefAttachment, WithRefOpts } from "../../internal/types.js";
5
5
  interface CheckboxGroupStateOpts extends WithRefOpts, ReadableBoxedValues<{
6
6
  name: string | undefined;
7
7
  disabled: boolean;
@@ -15,6 +15,7 @@ export declare const CheckboxGroupContext: Context<CheckboxGroupState>;
15
15
  export declare class CheckboxGroupState {
16
16
  static create(opts: CheckboxGroupStateOpts): CheckboxGroupState;
17
17
  readonly opts: CheckboxGroupStateOpts;
18
+ readonly attachment: RefAttachment;
18
19
  labelId: string | undefined;
19
20
  constructor(opts: CheckboxGroupStateOpts);
20
21
  addValue(checkboxValue: string | undefined): void;
@@ -32,6 +33,7 @@ export declare class CheckboxGroupLabelState {
32
33
  static create(opts: CheckboxGroupLabelStateOpts): CheckboxGroupLabelState;
33
34
  readonly opts: CheckboxGroupLabelStateOpts;
34
35
  readonly group: CheckboxGroupState;
36
+ readonly attachment: RefAttachment;
35
37
  constructor(opts: CheckboxGroupLabelStateOpts, group: CheckboxGroupState);
36
38
  readonly props: {
37
39
  readonly id: string;
@@ -57,6 +59,7 @@ export declare class CheckboxRootState {
57
59
  readonly trueName: string | undefined;
58
60
  readonly trueRequired: boolean;
59
61
  readonly trueDisabled: boolean;
62
+ readonly attachment: RefAttachment;
60
63
  constructor(opts: CheckboxRootStateOpts, group: CheckboxGroupState | null);
61
64
  onkeydown(e: BitsKeyboardEvent): void;
62
65
  onclick(_: BitsMouseEvent): void;
@@ -12,9 +12,11 @@ export class CheckboxGroupState {
12
12
  return CheckboxGroupContext.set(new CheckboxGroupState(opts));
13
13
  }
14
14
  opts;
15
+ attachment;
15
16
  labelId = $state(undefined);
16
17
  constructor(opts) {
17
18
  this.opts = opts;
19
+ this.attachment = attachRef(this.opts.ref);
18
20
  }
19
21
  addValue(checkboxValue) {
20
22
  if (!checkboxValue)
@@ -41,7 +43,7 @@ export class CheckboxGroupState {
41
43
  "aria-labelledby": this.labelId,
42
44
  "data-disabled": getDataDisabled(this.opts.disabled.current),
43
45
  [checkboxAttrs.group]: "",
44
- ...attachRef(this.opts.ref),
46
+ ...this.attachment,
45
47
  }));
46
48
  }
47
49
  export class CheckboxGroupLabelState {
@@ -50,15 +52,17 @@ export class CheckboxGroupLabelState {
50
52
  }
51
53
  opts;
52
54
  group;
55
+ attachment;
53
56
  constructor(opts, group) {
54
57
  this.opts = opts;
55
58
  this.group = group;
59
+ this.attachment = attachRef(this.opts.ref, (v) => (this.group.labelId = v?.id));
56
60
  }
57
61
  props = $derived.by(() => ({
58
62
  id: this.opts.id.current,
59
63
  "data-disabled": getDataDisabled(this.group.opts.disabled.current),
60
64
  [checkboxAttrs["group-label"]]: "",
61
- ...attachRef(this.opts.ref, (v) => (this.group.labelId = v?.id)),
65
+ ...this.attachment,
62
66
  }));
63
67
  }
64
68
  const CheckboxRootContext = new Context("Checkbox.Root");
@@ -88,9 +92,11 @@ export class CheckboxRootState {
88
92
  }
89
93
  return this.opts.disabled.current;
90
94
  });
95
+ attachment;
91
96
  constructor(opts, group) {
92
97
  this.opts = opts;
93
98
  this.group = group;
99
+ this.attachment = attachRef(this.opts.ref);
94
100
  this.onkeydown = this.onkeydown.bind(this);
95
101
  this.onclick = this.onclick.bind(this);
96
102
  watch.pre([() => $state.snapshot(this.group?.opts.value.current), () => this.opts.value.current], ([groupValue, value]) => {
@@ -150,7 +156,7 @@ export class CheckboxRootState {
150
156
  //
151
157
  onclick: this.onclick,
152
158
  onkeydown: this.onkeydown,
153
- ...attachRef(this.opts.ref),
159
+ ...this.attachment,
154
160
  }));
155
161
  }
156
162
  export class CheckboxInputState {
@@ -1,5 +1,5 @@
1
1
  import { type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
2
- import type { BitsKeyboardEvent, BitsMouseEvent, OnChangeFn, WithRefOpts } from "../../internal/types.js";
2
+ import type { BitsKeyboardEvent, BitsMouseEvent, OnChangeFn, RefAttachment, WithRefOpts } from "../../internal/types.js";
3
3
  interface CollapsibleRootStateOpts extends WithRefOpts, WritableBoxedValues<{
4
4
  open: boolean;
5
5
  }>, ReadableBoxedValues<{
@@ -10,6 +10,7 @@ interface CollapsibleRootStateOpts extends WithRefOpts, WritableBoxedValues<{
10
10
  export declare class CollapsibleRootState {
11
11
  static create(opts: CollapsibleRootStateOpts): CollapsibleRootState;
12
12
  readonly opts: CollapsibleRootStateOpts;
13
+ readonly attachment: RefAttachment;
13
14
  contentNode: HTMLElement | null;
14
15
  constructor(opts: CollapsibleRootStateOpts);
15
16
  toggleOpen(): void;
@@ -28,6 +29,7 @@ export declare class CollapsibleContentState {
28
29
  static create(opts: CollapsibleContentStateOpts): CollapsibleContentState;
29
30
  readonly opts: CollapsibleContentStateOpts;
30
31
  readonly root: CollapsibleRootState;
32
+ readonly attachment: RefAttachment;
31
33
  readonly present: boolean;
32
34
  constructor(opts: CollapsibleContentStateOpts, root: CollapsibleRootState);
33
35
  readonly snippetProps: {
@@ -52,6 +54,7 @@ export declare class CollapsibleTriggerState {
52
54
  static create(opts: CollapsibleTriggerStateOpts): CollapsibleTriggerState;
53
55
  readonly opts: CollapsibleTriggerStateOpts;
54
56
  readonly root: CollapsibleRootState;
57
+ readonly attachment: RefAttachment;
55
58
  constructor(opts: CollapsibleTriggerStateOpts, root: CollapsibleRootState);
56
59
  onclick(e: BitsMouseEvent): void;
57
60
  onkeydown(e: BitsKeyboardEvent): void;
@@ -13,10 +13,12 @@ export class CollapsibleRootState {
13
13
  return CollapsibleRootContext.set(new CollapsibleRootState(opts));
14
14
  }
15
15
  opts;
16
+ attachment;
16
17
  contentNode = $state(null);
17
18
  constructor(opts) {
18
19
  this.opts = opts;
19
20
  this.toggleOpen = this.toggleOpen.bind(this);
21
+ this.attachment = attachRef(this.opts.ref);
20
22
  new OpenChangeComplete({
21
23
  ref: box.with(() => this.contentNode),
22
24
  open: this.opts.open,
@@ -33,7 +35,7 @@ export class CollapsibleRootState {
33
35
  "data-state": getDataOpenClosed(this.opts.open.current),
34
36
  "data-disabled": getDataDisabled(this.opts.disabled.current),
35
37
  [collapsibleAttrs.root]: "",
36
- ...attachRef(this.opts.ref),
38
+ ...this.attachment,
37
39
  }));
38
40
  }
39
41
  export class CollapsibleContentState {
@@ -42,6 +44,7 @@ export class CollapsibleContentState {
42
44
  }
43
45
  opts;
44
46
  root;
47
+ attachment;
45
48
  present = $derived.by(() => this.opts.forceMount.current || this.root.opts.open.current);
46
49
  #originalStyles;
47
50
  #isMountAnimationPrevented = $state(false);
@@ -51,6 +54,7 @@ export class CollapsibleContentState {
51
54
  this.opts = opts;
52
55
  this.root = root;
53
56
  this.#isMountAnimationPrevented = root.opts.open.current;
57
+ this.attachment = attachRef(this.opts.ref, (v) => (this.root.contentNode = v));
54
58
  $effect.pre(() => {
55
59
  const rAF = requestAnimationFrame(() => {
56
60
  this.#isMountAnimationPrevented = false;
@@ -101,7 +105,7 @@ export class CollapsibleContentState {
101
105
  "data-state": getDataOpenClosed(this.root.opts.open.current),
102
106
  "data-disabled": getDataDisabled(this.root.opts.disabled.current),
103
107
  [collapsibleAttrs.content]: "",
104
- ...attachRef(this.opts.ref, (v) => (this.root.contentNode = v)),
108
+ ...this.attachment,
105
109
  }));
106
110
  }
107
111
  export class CollapsibleTriggerState {
@@ -110,10 +114,12 @@ export class CollapsibleTriggerState {
110
114
  }
111
115
  opts;
112
116
  root;
117
+ attachment;
113
118
  #isDisabled = $derived.by(() => this.opts.disabled.current || this.root.opts.disabled.current);
114
119
  constructor(opts, root) {
115
120
  this.opts = opts;
116
121
  this.root = root;
122
+ this.attachment = attachRef(this.opts.ref);
117
123
  this.onclick = this.onclick.bind(this);
118
124
  this.onkeydown = this.onkeydown.bind(this);
119
125
  }
@@ -144,6 +150,6 @@ export class CollapsibleTriggerState {
144
150
  //
145
151
  onclick: this.onclick,
146
152
  onkeydown: this.onkeydown,
147
- ...attachRef(this.opts.ref),
153
+ ...this.attachment,
148
154
  }));
149
155
  }
@@ -1,6 +1,6 @@
1
1
  import { type WritableBoxedValues, type ReadableBoxedValues } from "svelte-toolbelt";
2
2
  import type { CommandState } from "./types.js";
3
- import type { BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, WithRefOpts } from "../../internal/types.js";
3
+ import type { BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, RefAttachment, WithRefOpts } from "../../internal/types.js";
4
4
  interface GridItem {
5
5
  index: number;
6
6
  firstRowOfGroup: boolean;
@@ -24,6 +24,7 @@ export declare class CommandRootState {
24
24
  #private;
25
25
  static create(opts: CommandRootStateOpts): CommandRootState;
26
26
  readonly opts: CommandRootStateOpts;
27
+ readonly attachment: RefAttachment;
27
28
  sortAfterTick: boolean;
28
29
  sortAndFilterAfterTick: boolean;
29
30
  allItems: Set<string>;
@@ -162,6 +163,7 @@ export declare class CommandEmptyState {
162
163
  static create(opts: CommandEmptyStateOpts): CommandEmptyState;
163
164
  readonly opts: CommandEmptyStateOpts;
164
165
  readonly root: CommandRootState;
166
+ readonly attachment: RefAttachment;
165
167
  readonly shouldRender: boolean;
166
168
  constructor(opts: CommandEmptyStateOpts, root: CommandRootState);
167
169
  readonly props: {
@@ -178,6 +180,7 @@ export declare class CommandGroupContainerState {
178
180
  static create(opts: CommandGroupContainerStateOpts): CommandGroupContainerState;
179
181
  readonly opts: CommandGroupContainerStateOpts;
180
182
  readonly root: CommandRootState;
183
+ readonly attachment: RefAttachment;
181
184
  readonly shouldRender: boolean;
182
185
  headingNode: HTMLElement | null;
183
186
  trueValue: string;
@@ -195,6 +198,7 @@ export declare class CommandGroupHeadingState {
195
198
  static create(opts: CommandGroupHeadingStateOpts): CommandGroupHeadingState;
196
199
  readonly opts: CommandGroupHeadingStateOpts;
197
200
  readonly group: CommandGroupContainerState;
201
+ readonly attachment: RefAttachment;
198
202
  constructor(opts: CommandGroupHeadingStateOpts, group: CommandGroupContainerState);
199
203
  readonly props: {
200
204
  readonly id: string;
@@ -206,6 +210,7 @@ export declare class CommandGroupItemsState {
206
210
  static create(opts: CommandGroupItemsStateOpts): CommandGroupItemsState;
207
211
  readonly opts: CommandGroupItemsStateOpts;
208
212
  readonly group: CommandGroupContainerState;
213
+ readonly attachment: RefAttachment;
209
214
  constructor(opts: CommandGroupItemsStateOpts, group: CommandGroupContainerState);
210
215
  readonly props: {
211
216
  readonly id: string;
@@ -224,6 +229,7 @@ export declare class CommandInputState {
224
229
  static create(opts: CommandInputStateOpts): CommandInputState;
225
230
  readonly opts: CommandInputStateOpts;
226
231
  readonly root: CommandRootState;
232
+ readonly attachment: RefAttachment;
227
233
  constructor(opts: CommandInputStateOpts, root: CommandRootState);
228
234
  readonly props: {
229
235
  readonly id: string;
@@ -253,6 +259,7 @@ export declare class CommandItemState {
253
259
  static create(opts: Omit<CommandItemStateOpts, "group">): CommandItemState;
254
260
  readonly opts: CommandItemStateOpts;
255
261
  readonly root: CommandRootState;
262
+ readonly attachment: RefAttachment;
256
263
  readonly shouldRender: boolean;
257
264
  readonly isSelected: boolean;
258
265
  trueValue: string;
@@ -279,6 +286,7 @@ interface CommandLoadingStateOpts extends WithRefOpts, ReadableBoxedValues<{
279
286
  export declare class CommandLoadingState {
280
287
  static create(opts: CommandLoadingStateOpts): CommandLoadingState;
281
288
  readonly opts: CommandLoadingStateOpts;
289
+ readonly attachment: RefAttachment;
282
290
  constructor(opts: CommandLoadingStateOpts);
283
291
  readonly props: {
284
292
  readonly id: string;
@@ -297,6 +305,7 @@ export declare class CommandSeparatorState {
297
305
  static create(opts: CommandSeparatorStateOpts): CommandSeparatorState;
298
306
  readonly opts: CommandSeparatorStateOpts;
299
307
  readonly root: CommandRootState;
308
+ readonly attachment: RefAttachment;
300
309
  readonly shouldRender: boolean;
301
310
  constructor(opts: CommandSeparatorStateOpts, root: CommandRootState);
302
311
  readonly props: {
@@ -312,6 +321,7 @@ export declare class CommandListState {
312
321
  static create(opts: CommandListStateOpts): CommandListState;
313
322
  readonly opts: CommandListStateOpts;
314
323
  readonly root: CommandRootState;
324
+ readonly attachment: RefAttachment;
315
325
  constructor(opts: CommandListStateOpts, root: CommandRootState);
316
326
  readonly props: {
317
327
  readonly id: string;
@@ -327,6 +337,7 @@ export declare class CommandLabelState {
327
337
  static create(opts: CommandLabelStateOpts): CommandLabelState;
328
338
  readonly opts: CommandLabelStateOpts;
329
339
  readonly root: CommandRootState;
340
+ readonly attachment: RefAttachment;
330
341
  constructor(opts: CommandLabelStateOpts, root: CommandRootState);
331
342
  readonly props: {
332
343
  readonly id: string;
@@ -340,6 +351,7 @@ export declare class CommandViewportState {
340
351
  static create(opts: CommandViewportStateOpts): CommandViewportState;
341
352
  readonly opts: CommandViewportStateOpts;
342
353
  readonly list: CommandListState;
354
+ readonly attachment: RefAttachment;
343
355
  constructor(opts: CommandViewportStateOpts, list: CommandListState);
344
356
  readonly props: {
345
357
  readonly id: string;