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
@@ -32,8 +32,10 @@ export class PinInputRootState {
32
32
  return new PinInputRootState(opts);
33
33
  }
34
34
  opts;
35
+ attachment;
35
36
  #inputRef = box(null);
36
37
  #isHoveringInput = $state(false);
38
+ inputAttachment = attachRef(this.#inputRef);
37
39
  #isFocused = box(false);
38
40
  #mirrorSelectionStart = $state(null);
39
41
  #mirrorSelectionEnd = $state(null);
@@ -55,6 +57,7 @@ export class PinInputRootState {
55
57
  domContext;
56
58
  constructor(opts) {
57
59
  this.opts = opts;
60
+ this.attachment = attachRef(this.opts.ref);
58
61
  this.domContext = new DOMContext(opts.ref);
59
62
  this.#initialLoad = {
60
63
  value: this.opts.value,
@@ -158,7 +161,7 @@ export class PinInputRootState {
158
161
  id: this.opts.id.current,
159
162
  [pinInputAttrs.root]: "",
160
163
  style: this.#rootStyles,
161
- ...attachRef(this.opts.ref),
164
+ ...this.attachment,
162
165
  }));
163
166
  inputWrapperProps = $derived.by(() => ({
164
167
  style: {
@@ -370,7 +373,7 @@ export class PinInputRootState {
370
373
  onmouseleave: this.onmouseleave,
371
374
  onfocus: this.onfocus,
372
375
  onblur: this.onblur,
373
- ...attachRef(this.#inputRef),
376
+ ...this.inputAttachment,
374
377
  }));
375
378
  #cells = $derived.by(() => Array.from({ length: this.opts.maxLength.current }).map((_, idx) => {
376
379
  const isActive = this.#isFocused.current &&
@@ -397,15 +400,17 @@ export class PinInputCellState {
397
400
  return new PinInputCellState(opts);
398
401
  }
399
402
  opts;
403
+ attachment;
400
404
  constructor(opts) {
401
405
  this.opts = opts;
406
+ this.attachment = attachRef(this.opts.ref);
402
407
  }
403
408
  props = $derived.by(() => ({
404
409
  id: this.opts.id.current,
405
410
  [pinInputAttrs.cell]: "",
406
411
  "data-active": this.opts.cell.current.isActive ? "" : undefined,
407
412
  "data-inactive": !this.opts.cell.current.isActive ? "" : undefined,
408
- ...attachRef(this.opts.ref),
413
+ ...this.attachment,
409
414
  }));
410
415
  }
411
416
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1,5 +1,5 @@
1
1
  import { type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
2
- import type { BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, OnChangeFn, WithRefOpts } from "../../internal/types.js";
2
+ import type { BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, OnChangeFn, RefAttachment, WithRefOpts } from "../../internal/types.js";
3
3
  interface PopoverRootStateOpts extends WritableBoxedValues<{
4
4
  open: boolean;
5
5
  }>, ReadableBoxedValues<{
@@ -24,6 +24,7 @@ export declare class PopoverTriggerState {
24
24
  static create(opts: PopoverTriggerStateOpts): PopoverTriggerState;
25
25
  readonly opts: PopoverTriggerStateOpts;
26
26
  readonly root: PopoverRootState;
27
+ readonly attachment: RefAttachment;
27
28
  constructor(opts: PopoverTriggerStateOpts, root: PopoverRootState);
28
29
  onclick(e: BitsMouseEvent): void;
29
30
  onkeydown(e: BitsKeyboardEvent): void;
@@ -48,6 +49,7 @@ export declare class PopoverContentState {
48
49
  static create(opts: PopoverContentStateOpts): PopoverContentState;
49
50
  readonly opts: PopoverContentStateOpts;
50
51
  readonly root: PopoverRootState;
52
+ readonly attachment: RefAttachment;
51
53
  constructor(opts: PopoverContentStateOpts, root: PopoverRootState);
52
54
  onInteractOutside: (e: PointerEvent) => void;
53
55
  onEscapeKeydown: (e: KeyboardEvent) => void;
@@ -75,6 +77,7 @@ export declare class PopoverCloseState {
75
77
  static create(opts: PopoverCloseStateOpts): PopoverCloseState;
76
78
  readonly opts: PopoverCloseStateOpts;
77
79
  readonly root: PopoverRootState;
80
+ readonly attachment: RefAttachment;
78
81
  constructor(opts: PopoverCloseStateOpts, root: PopoverRootState);
79
82
  onclick(_: BitsPointerEvent): void;
80
83
  onkeydown(e: BitsKeyboardEvent): void;
@@ -41,9 +41,11 @@ export class PopoverTriggerState {
41
41
  }
42
42
  opts;
43
43
  root;
44
+ attachment;
44
45
  constructor(opts, root) {
45
46
  this.opts = opts;
46
47
  this.root = root;
48
+ this.attachment = attachRef(this.opts.ref, (v) => (this.root.triggerNode = v));
47
49
  this.onclick = this.onclick.bind(this);
48
50
  this.onkeydown = this.onkeydown.bind(this);
49
51
  }
@@ -79,7 +81,7 @@ export class PopoverTriggerState {
79
81
  //
80
82
  onkeydown: this.onkeydown,
81
83
  onclick: this.onclick,
82
- ...attachRef(this.opts.ref, (v) => (this.root.triggerNode = v)),
84
+ ...this.attachment,
83
85
  }));
84
86
  }
85
87
  export class PopoverContentState {
@@ -88,9 +90,11 @@ export class PopoverContentState {
88
90
  }
89
91
  opts;
90
92
  root;
93
+ attachment;
91
94
  constructor(opts, root) {
92
95
  this.opts = opts;
93
96
  this.root = root;
97
+ this.attachment = attachRef(this.opts.ref, (v) => (this.root.contentNode = v));
94
98
  }
95
99
  onInteractOutside = (e) => {
96
100
  this.opts.onInteractOutside.current(e);
@@ -125,7 +129,7 @@ export class PopoverContentState {
125
129
  style: {
126
130
  pointerEvents: "auto",
127
131
  },
128
- ...attachRef(this.opts.ref, (v) => (this.root.contentNode = v)),
132
+ ...this.attachment,
129
133
  }));
130
134
  popperProps = {
131
135
  onInteractOutside: this.onInteractOutside,
@@ -139,9 +143,11 @@ export class PopoverCloseState {
139
143
  }
140
144
  opts;
141
145
  root;
146
+ attachment;
142
147
  constructor(opts, root) {
143
148
  this.opts = opts;
144
149
  this.root = root;
150
+ this.attachment = attachRef(this.opts.ref);
145
151
  this.onclick = this.onclick.bind(this);
146
152
  this.onkeydown = this.onkeydown.bind(this);
147
153
  }
@@ -160,6 +166,6 @@ export class PopoverCloseState {
160
166
  onkeydown: this.onkeydown,
161
167
  type: "button",
162
168
  [popoverAttrs.close]: "",
163
- ...attachRef(this.opts.ref),
169
+ ...this.attachment,
164
170
  }));
165
171
  }
@@ -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
  interface ProgressRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
4
4
  value: number | null;
5
5
  max: number;
@@ -9,6 +9,7 @@ interface ProgressRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
9
9
  export declare class ProgressRootState {
10
10
  static create(opts: ProgressRootStateOpts): ProgressRootState;
11
11
  readonly opts: ProgressRootStateOpts;
12
+ readonly attachment: RefAttachment;
12
13
  constructor(opts: ProgressRootStateOpts);
13
14
  readonly props: {
14
15
  readonly role: "progressbar";
@@ -9,8 +9,10 @@ export class ProgressRootState {
9
9
  return new ProgressRootState(opts);
10
10
  }
11
11
  opts;
12
+ attachment;
12
13
  constructor(opts) {
13
14
  this.opts = opts;
15
+ this.attachment = attachRef(this.opts.ref);
14
16
  }
15
17
  props = $derived.by(() => ({
16
18
  role: "progressbar",
@@ -24,7 +26,7 @@ export class ProgressRootState {
24
26
  "data-min": this.opts.min.current,
25
27
  "data-indeterminate": this.opts.value.current === null ? "" : undefined,
26
28
  [progressAttrs.root]: "",
27
- ...attachRef(this.opts.ref),
29
+ ...this.attachment,
28
30
  }));
29
31
  }
30
32
  function getProgressDataState(value, max) {
@@ -1,5 +1,5 @@
1
1
  import { type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
2
- import type { BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, WithRefOpts } from "../../internal/types.js";
2
+ import type { BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, RefAttachment, WithRefOpts } from "../../internal/types.js";
3
3
  import type { Orientation } from "../../shared/index.js";
4
4
  import { RovingFocusGroup } from "../../internal/roving-focus-group.js";
5
5
  interface RadioGroupRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
@@ -18,6 +18,7 @@ export declare class RadioGroupRootState {
18
18
  readonly opts: RadioGroupRootStateOpts;
19
19
  readonly hasValue: boolean;
20
20
  readonly rovingFocusGroup: RovingFocusGroup;
21
+ readonly attachment: RefAttachment;
21
22
  constructor(opts: RadioGroupRootStateOpts);
22
23
  isChecked(value: string): boolean;
23
24
  setValue(value: string): void;
@@ -42,6 +43,7 @@ export declare class RadioGroupItemState {
42
43
  static create(opts: RadioGroupItemStateOpts): RadioGroupItemState;
43
44
  readonly opts: RadioGroupItemStateOpts;
44
45
  readonly root: RadioGroupRootState;
46
+ readonly attachment: RefAttachment;
45
47
  readonly checked: boolean;
46
48
  constructor(opts: RadioGroupItemStateOpts, root: RadioGroupRootState);
47
49
  onclick(_: BitsMouseEvent): void;
@@ -15,8 +15,10 @@ export class RadioGroupRootState {
15
15
  opts;
16
16
  hasValue = $derived.by(() => this.opts.value.current !== "");
17
17
  rovingFocusGroup;
18
+ attachment;
18
19
  constructor(opts) {
19
20
  this.opts = opts;
21
+ this.attachment = attachRef(this.opts.ref);
20
22
  this.rovingFocusGroup = new RovingFocusGroup({
21
23
  rootNode: this.opts.ref,
22
24
  candidateAttr: radioGroupAttrs.item,
@@ -40,7 +42,7 @@ export class RadioGroupRootState {
40
42
  "data-readonly": getDataReadonly(this.opts.readonly.current),
41
43
  "data-orientation": this.opts.orientation.current,
42
44
  [radioGroupAttrs.root]: "",
43
- ...attachRef(this.opts.ref),
45
+ ...this.attachment,
44
46
  }));
45
47
  }
46
48
  export class RadioGroupItemState {
@@ -49,6 +51,7 @@ export class RadioGroupItemState {
49
51
  }
50
52
  opts;
51
53
  root;
54
+ attachment;
52
55
  checked = $derived.by(() => this.root.opts.value.current === this.opts.value.current);
53
56
  #isDisabled = $derived.by(() => this.opts.disabled.current || this.root.opts.disabled.current);
54
57
  #isReadonly = $derived.by(() => this.root.opts.readonly.current);
@@ -57,6 +60,7 @@ export class RadioGroupItemState {
57
60
  constructor(opts, root) {
58
61
  this.opts = opts;
59
62
  this.root = root;
63
+ this.attachment = attachRef(this.opts.ref);
60
64
  if (this.opts.value.current === this.root.opts.value.current) {
61
65
  this.root.rovingFocusGroup.setCurrentTabStopId(this.opts.id.current);
62
66
  this.#tabIndex = 0;
@@ -117,7 +121,7 @@ export class RadioGroupItemState {
117
121
  onkeydown: this.onkeydown,
118
122
  onfocus: this.onfocus,
119
123
  onclick: this.onclick,
120
- ...attachRef(this.opts.ref),
124
+ ...this.attachment,
121
125
  }));
122
126
  }
123
127
  export class RadioGroupInputState {
@@ -1,7 +1,7 @@
1
1
  import { type DateValue } from "@internationalized/date";
2
2
  import { DOMContext, type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
3
3
  import type { DateRange, Month } from "../../shared/index.js";
4
- import type { BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, WithRefOpts } from "../../internal/types.js";
4
+ import type { BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, RefAttachment, WithRefOpts } from "../../internal/types.js";
5
5
  import { type Announcer } from "../../internal/date-time/announcer.js";
6
6
  import { type Formatter } from "../../internal/date-time/formatter.js";
7
7
  import { calendarAttrs } from "../../internal/date-time/calendar-helpers.svelte.js";
@@ -44,6 +44,7 @@ export declare class RangeCalendarRootState {
44
44
  #private;
45
45
  static create(opts: RangeCalendarRootStateOpts): RangeCalendarRootState | import("../calendar/calendar.svelte.js").CalendarRootState;
46
46
  readonly opts: RangeCalendarRootStateOpts;
47
+ readonly attachment: RefAttachment;
47
48
  readonly visibleMonths: DateValue[];
48
49
  months: Month<DateValue>[];
49
50
  announcer: Announcer;
@@ -120,6 +121,7 @@ export declare class RangeCalendarCellState {
120
121
  static create(opts: RangeCalendarCellStateOpts): RangeCalendarCellState;
121
122
  readonly opts: RangeCalendarCellStateOpts;
122
123
  readonly root: RangeCalendarRootState;
124
+ readonly attachment: RefAttachment;
123
125
  readonly cellDate: Date;
124
126
  readonly isDisabled: boolean;
125
127
  readonly isUnavailable: boolean;
@@ -189,6 +191,7 @@ export declare class RangeCalendarDayState {
189
191
  static create(opts: RangeCalendarDayStateOpts): RangeCalendarDayState;
190
192
  readonly opts: RangeCalendarDayStateOpts;
191
193
  readonly cell: RangeCalendarCellState;
194
+ readonly attachment: RefAttachment;
192
195
  constructor(opts: RangeCalendarDayStateOpts, cell: RangeCalendarCellState);
193
196
  onclick(e: BitsMouseEvent): void;
194
197
  onmouseenter(_: BitsMouseEvent): void;
@@ -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) {