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
@@ -72,6 +72,7 @@ export class NavigationMenuRootState {
72
72
  return new NavigationMenuRootState(opts);
73
73
  }
74
74
  opts;
75
+ attachment;
75
76
  provider;
76
77
  previousValue = box("");
77
78
  isDelaySkipped;
@@ -87,6 +88,7 @@ export class NavigationMenuRootState {
87
88
  });
88
89
  constructor(opts) {
89
90
  this.opts = opts;
91
+ this.attachment = attachRef(this.opts.ref);
90
92
  this.isDelaySkipped = boxAutoReset(false, {
91
93
  afterMs: this.opts.skipDelayDuration.current,
92
94
  getWindow: () => getWindow(opts.ref.current),
@@ -153,7 +155,7 @@ export class NavigationMenuRootState {
153
155
  dir: this.opts.dir.current,
154
156
  [navigationMenuAttrs.root]: "",
155
157
  [navigationMenuAttrs.menu]: "",
156
- ...attachRef(this.opts.ref),
158
+ ...this.attachment,
157
159
  }));
158
160
  }
159
161
  export class NavigationMenuSubState {
@@ -164,9 +166,11 @@ export class NavigationMenuSubState {
164
166
  context;
165
167
  previousValue = box("");
166
168
  subProvider;
169
+ attachment;
167
170
  constructor(opts, context) {
168
171
  this.opts = opts;
169
172
  this.context = context;
173
+ this.attachment = attachRef(this.opts.ref);
170
174
  this.subProvider = NavigationMenuProviderState.create({
171
175
  isRootMenu: false,
172
176
  value: this.opts.value,
@@ -194,23 +198,26 @@ export class NavigationMenuSubState {
194
198
  "data-orientation": getDataOrientation(this.opts.orientation.current),
195
199
  [navigationMenuAttrs.sub]: "",
196
200
  [navigationMenuAttrs.menu]: "",
197
- ...attachRef(this.opts.ref),
201
+ ...this.attachment,
198
202
  }));
199
203
  }
200
204
  export class NavigationMenuListState {
201
205
  static create(opts) {
202
206
  return NavigationMenuListContext.set(new NavigationMenuListState(opts, NavigationMenuProviderContext.get()));
203
207
  }
204
- opts;
205
- context;
206
208
  wrapperId = box(useId());
207
209
  wrapperRef = box(null);
210
+ opts;
211
+ context;
212
+ attachment;
213
+ wrapperAttachment = attachRef(this.wrapperRef, (v) => (this.context.indicatorTrackRef.current = v));
208
214
  listTriggers = $state.raw([]);
209
215
  rovingFocusGroup;
210
216
  wrapperMounted = $state(false);
211
217
  constructor(opts, context) {
212
218
  this.opts = opts;
213
219
  this.context = context;
220
+ this.attachment = attachRef(this.opts.ref);
214
221
  this.rovingFocusGroup = new RovingFocusGroup({
215
222
  rootNode: opts.ref,
216
223
  candidateSelector: `${navigationMenuAttrs.selector("trigger")}:not([data-disabled]), ${navigationMenuAttrs.selector("link")}:not([data-disabled])`,
@@ -227,13 +234,13 @@ export class NavigationMenuListState {
227
234
  }
228
235
  wrapperProps = $derived.by(() => ({
229
236
  id: this.wrapperId.current,
230
- ...attachRef(this.wrapperRef, (v) => (this.context.indicatorTrackRef.current = v)),
237
+ ...this.wrapperAttachment,
231
238
  }));
232
239
  props = $derived.by(() => ({
233
240
  id: this.opts.id.current,
234
241
  "data-orientation": getDataOrientation(this.context.opts.orientation.current),
235
242
  [navigationMenuAttrs.list]: "",
236
- ...attachRef(this.opts.ref),
243
+ ...this.attachment,
237
244
  }));
238
245
  }
239
246
  export class NavigationMenuItemState {
@@ -292,8 +299,10 @@ export class NavigationMenuTriggerState {
292
299
  });
293
300
  }
294
301
  opts;
302
+ attachment;
295
303
  focusProxyId = box(useId());
296
304
  focusProxyRef = box(null);
305
+ focusProxyAttachment = attachRef(this.focusProxyRef, (v) => (this.itemContext.focusProxyNode = v));
297
306
  context;
298
307
  itemContext;
299
308
  listContext;
@@ -303,6 +312,7 @@ export class NavigationMenuTriggerState {
303
312
  open = $derived.by(() => this.itemContext.opts.value.current === this.context.opts.value.current);
304
313
  constructor(opts, context) {
305
314
  this.opts = opts;
315
+ this.attachment = attachRef(this.opts.ref, (v) => (this.itemContext.triggerNode = v));
306
316
  this.hasPointerMoveOpened = boxAutoReset(false, {
307
317
  afterMs: 300,
308
318
  getWindow: () => getWindow(opts.ref.current),
@@ -386,13 +396,13 @@ export class NavigationMenuTriggerState {
386
396
  onpointerenter: this.onpointerenter,
387
397
  onclick: this.onclick,
388
398
  onkeydown: this.onkeydown,
389
- ...attachRef(this.opts.ref, (v) => (this.itemContext.triggerNode = v)),
399
+ ...this.attachment,
390
400
  }));
391
401
  focusProxyProps = $derived.by(() => ({
392
402
  id: this.focusProxyId.current,
393
403
  tabindex: 0,
394
404
  onfocus: this.focusProxyOnFocus,
395
- ...attachRef(this.focusProxyRef, (v) => (this.itemContext.focusProxyNode = v)),
405
+ ...this.focusProxyAttachment,
396
406
  }));
397
407
  }
398
408
  const LINK_SELECT_EVENT = new CustomEventDispatcher("bitsLinkSelect", {
@@ -412,10 +422,12 @@ export class NavigationMenuLinkState {
412
422
  }
413
423
  opts;
414
424
  context;
425
+ attachment;
415
426
  isFocused = $state(false);
416
427
  constructor(opts, context) {
417
428
  this.opts = opts;
418
429
  this.context = context;
430
+ this.attachment = attachRef(this.opts.ref);
419
431
  }
420
432
  onclick = (e) => {
421
433
  const currTarget = e.currentTarget;
@@ -465,7 +477,7 @@ export class NavigationMenuLinkState {
465
477
  onpointerenter: this.onpointerenter,
466
478
  onpointermove: this.onpointermove,
467
479
  [navigationMenuAttrs.link]: "",
468
- ...attachRef(this.opts.ref),
480
+ ...this.attachment,
469
481
  }));
470
482
  }
471
483
  export class NavigationMenuIndicatorState {
@@ -486,6 +498,7 @@ export class NavigationMenuIndicatorImplState {
486
498
  });
487
499
  }
488
500
  opts;
501
+ attachment;
489
502
  context;
490
503
  listContext;
491
504
  position = $state.raw(null);
@@ -501,6 +514,7 @@ export class NavigationMenuIndicatorImplState {
501
514
  this.opts = opts;
502
515
  this.context = context.provider;
503
516
  this.listContext = context.list;
517
+ this.attachment = attachRef(this.opts.ref);
504
518
  new SvelteResizeObserver(() => this.activeTrigger, this.handlePositionChange);
505
519
  new SvelteResizeObserver(() => this.context.indicatorTrackRef.current, this.handlePositionChange);
506
520
  }
@@ -535,7 +549,7 @@ export class NavigationMenuIndicatorImplState {
535
549
  }),
536
550
  },
537
551
  [navigationMenuAttrs.indicator]: "",
538
- ...attachRef(this.opts.ref),
552
+ ...this.attachment,
539
553
  }));
540
554
  }
541
555
  export class NavigationMenuContentState {
@@ -550,6 +564,7 @@ export class NavigationMenuContentState {
550
564
  context;
551
565
  itemContext;
552
566
  listContext;
567
+ attachment;
553
568
  mounted = $state(false);
554
569
  open = $derived.by(() => this.itemContext.opts.value.current === this.context.opts.value.current);
555
570
  value = $derived.by(() => this.itemContext.opts.value.current);
@@ -568,6 +583,7 @@ export class NavigationMenuContentState {
568
583
  this.context = context.provider;
569
584
  this.itemContext = context.item;
570
585
  this.listContext = context.list;
586
+ this.attachment = attachRef(this.opts.ref, (v) => (this.itemContext.contentNode = v));
571
587
  }
572
588
  onpointerenter = (_) => {
573
589
  this.context.onContentEnter();
@@ -581,7 +597,7 @@ export class NavigationMenuContentState {
581
597
  id: this.opts.id.current,
582
598
  onpointerenter: this.onpointerenter,
583
599
  onpointerleave: this.onpointerleave,
584
- ...attachRef(this.opts.ref, (v) => (this.itemContext.contentNode = v)),
600
+ ...this.attachment,
585
601
  }));
586
602
  }
587
603
  export class NavigationMenuContentImplState {
@@ -592,6 +608,7 @@ export class NavigationMenuContentImplState {
592
608
  itemContext;
593
609
  context;
594
610
  listContext;
611
+ attachment;
595
612
  prevMotionAttribute = $state(null);
596
613
  motionAttribute = $derived.by(() => {
597
614
  const items = this.listContext.listTriggers;
@@ -631,6 +648,7 @@ export class NavigationMenuContentImplState {
631
648
  domContext;
632
649
  constructor(opts, itemContext) {
633
650
  this.opts = opts;
651
+ this.attachment = attachRef(this.opts.ref);
634
652
  this.itemContext = itemContext;
635
653
  this.listContext = itemContext.listContext;
636
654
  this.context = itemContext.listContext.context;
@@ -744,7 +762,7 @@ export class NavigationMenuContentImplState {
744
762
  "data-state": getDataOpenClosed(this.context.opts.value.current === this.itemContext.opts.value.current),
745
763
  onkeydown: this.onkeydown,
746
764
  [navigationMenuAttrs.content]: "",
747
- ...attachRef(this.opts.ref),
765
+ ...this.attachment,
748
766
  }));
749
767
  }
750
768
  export class NavigationMenuViewportState {
@@ -753,6 +771,7 @@ export class NavigationMenuViewportState {
753
771
  }
754
772
  opts;
755
773
  context;
774
+ attachment;
756
775
  open = $derived.by(() => !!this.context.opts.value.current);
757
776
  viewportWidth = $derived.by(() => (this.size ? `${this.size.width}px` : undefined));
758
777
  viewportHeight = $derived.by(() => (this.size ? `${this.size.height}px` : undefined));
@@ -763,6 +782,7 @@ export class NavigationMenuViewportState {
763
782
  constructor(opts, context) {
764
783
  this.opts = opts;
765
784
  this.context = context;
785
+ this.attachment = attachRef(this.opts.ref, (v) => (this.context.viewportRef.current = v));
766
786
  watch([() => this.activeContentValue, () => this.open], () => {
767
787
  afterTick(() => {
768
788
  const currNode = this.context.viewportRef.current;
@@ -806,7 +826,7 @@ export class NavigationMenuViewportState {
806
826
  [navigationMenuAttrs.viewport]: "",
807
827
  onpointerenter: this.context.onContentEnter,
808
828
  onpointerleave: this.context.onContentLeave,
809
- ...attachRef(this.opts.ref, (v) => (this.context.viewportRef.current = v)),
829
+ ...this.attachment,
810
830
  }));
811
831
  }
812
832
  //
@@ -1,6 +1,6 @@
1
1
  import { type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
2
2
  import type { Page, PageItem } from "./types.js";
3
- import type { BitsKeyboardEvent, BitsMouseEvent, WithRefOpts } from "../../internal/types.js";
3
+ import type { BitsKeyboardEvent, BitsMouseEvent, RefAttachment, WithRefOpts } from "../../internal/types.js";
4
4
  import { type Orientation } from "../../shared/index.js";
5
5
  interface PaginationRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
6
6
  count: number;
@@ -15,6 +15,7 @@ interface PaginationRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
15
15
  export declare class PaginationRootState {
16
16
  static create(opts: PaginationRootStateOpts): PaginationRootState;
17
17
  readonly opts: PaginationRootStateOpts;
18
+ readonly attachment: RefAttachment;
18
19
  readonly totalPages: number;
19
20
  readonly range: {
20
21
  start: number;
@@ -52,6 +53,7 @@ export declare class PaginationPageState {
52
53
  static create(opts: PaginationPageStateOpts): PaginationPageState;
53
54
  readonly opts: PaginationPageStateOpts;
54
55
  readonly root: PaginationRootState;
56
+ readonly attachment: RefAttachment;
55
57
  constructor(opts: PaginationPageStateOpts, root: PaginationRootState);
56
58
  onclick(e: BitsMouseEvent): void;
57
59
  onkeydown(e: BitsKeyboardEvent): void;
@@ -74,6 +76,7 @@ export declare class PaginationButtonState {
74
76
  static create(opts: PaginationButtonStateOpts): PaginationButtonState;
75
77
  readonly opts: PaginationButtonStateOpts;
76
78
  readonly root: PaginationRootState;
79
+ readonly attachment: RefAttachment;
77
80
  constructor(opts: PaginationButtonStateOpts, root: PaginationRootState);
78
81
  onclick(e: BitsMouseEvent): void;
79
82
  onkeydown(e: BitsKeyboardEvent): void;
@@ -15,6 +15,7 @@ export class PaginationRootState {
15
15
  return PaginationRootContext.set(new PaginationRootState(opts));
16
16
  }
17
17
  opts;
18
+ attachment;
18
19
  totalPages = $derived.by(() => {
19
20
  if (this.opts.count.current === 0)
20
21
  return 1;
@@ -34,6 +35,7 @@ export class PaginationRootState {
34
35
  hasNextPage = $derived.by(() => this.opts.page.current < this.totalPages);
35
36
  constructor(opts) {
36
37
  this.opts = opts;
38
+ this.attachment = attachRef(this.opts.ref);
37
39
  }
38
40
  setPage(page) {
39
41
  this.opts.page.current = page;
@@ -65,7 +67,7 @@ export class PaginationRootState {
65
67
  id: this.opts.id.current,
66
68
  "data-orientation": getDataOrientation(this.opts.orientation.current),
67
69
  [paginationAttrs.root]: "",
68
- ...attachRef(this.opts.ref),
70
+ ...this.attachment,
69
71
  }));
70
72
  }
71
73
  export class PaginationPageState {
@@ -74,10 +76,12 @@ export class PaginationPageState {
74
76
  }
75
77
  opts;
76
78
  root;
79
+ attachment;
77
80
  #isSelected = $derived.by(() => this.opts.page.current.value === this.root.opts.page.current);
78
81
  constructor(opts, root) {
79
82
  this.opts = opts;
80
83
  this.root = root;
84
+ this.attachment = attachRef(this.opts.ref);
81
85
  this.onclick = this.onclick.bind(this);
82
86
  this.onkeydown = this.onkeydown.bind(this);
83
87
  }
@@ -106,7 +110,7 @@ export class PaginationPageState {
106
110
  //
107
111
  onclick: this.onclick,
108
112
  onkeydown: this.onkeydown,
109
- ...attachRef(this.opts.ref),
113
+ ...this.attachment,
110
114
  }));
111
115
  }
112
116
  export class PaginationButtonState {
@@ -115,9 +119,11 @@ export class PaginationButtonState {
115
119
  }
116
120
  opts;
117
121
  root;
122
+ attachment;
118
123
  constructor(opts, root) {
119
124
  this.opts = opts;
120
125
  this.root = root;
126
+ this.attachment = attachRef(this.opts.ref);
121
127
  this.onclick = this.onclick.bind(this);
122
128
  this.onkeydown = this.onkeydown.bind(this);
123
129
  }
@@ -156,7 +162,7 @@ export class PaginationButtonState {
156
162
  //
157
163
  onclick: this.onclick,
158
164
  onkeydown: this.onkeydown,
159
- ...attachRef(this.opts.ref),
165
+ ...this.attachment,
160
166
  }));
161
167
  }
162
168
  //
@@ -1,6 +1,6 @@
1
1
  import { DOMContext, type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
2
2
  import type { PinInputCell, PinInputRootProps as RootComponentProps } from "./types.js";
3
- import type { BitsEvent, BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, WithRefOpts } from "../../internal/types.js";
3
+ import type { BitsEvent, BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, RefAttachment, WithRefOpts } from "../../internal/types.js";
4
4
  export declare const REGEXP_ONLY_DIGITS = "^\\d+$";
5
5
  export declare const REGEXP_ONLY_CHARS = "^[a-zA-Z]+$";
6
6
  export declare const REGEXP_ONLY_DIGITS_AND_CHARS = "^[a-zA-Z0-9]+$";
@@ -23,6 +23,8 @@ export declare class PinInputRootState {
23
23
  #private;
24
24
  static create(opts: PinInputRootStateOpts): PinInputRootState;
25
25
  readonly opts: PinInputRootStateOpts;
26
+ readonly attachment: RefAttachment;
27
+ readonly inputAttachment: RefAttachment<HTMLInputElement>;
26
28
  domContext: DOMContext;
27
29
  constructor(opts: PinInputRootStateOpts);
28
30
  onkeydown: (e: BitsKeyboardEvent) => void;
@@ -107,6 +109,7 @@ interface PinInputCellStateOpts extends WithRefOpts, ReadableBoxedValues<{
107
109
  export declare class PinInputCellState {
108
110
  static create(opts: PinInputCellStateOpts): PinInputCellState;
109
111
  readonly opts: PinInputCellStateOpts;
112
+ readonly attachment: RefAttachment;
110
113
  constructor(opts: PinInputCellStateOpts);
111
114
  readonly props: {
112
115
  readonly id: string;
@@ -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;