bits-ui 2.8.1 → 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 (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 +9 -3
  11. package/dist/bits/collapsible/collapsible.svelte.d.ts +4 -1
  12. package/dist/bits/collapsible/collapsible.svelte.js +9 -3
  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 +33 -18
  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 +1 -1
@@ -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;
@@ -52,6 +52,7 @@ export class CommandRootState {
52
52
  return CommandRootContext.set(new CommandRootState(opts));
53
53
  }
54
54
  opts;
55
+ attachment;
55
56
  #updateScheduled = false;
56
57
  #isInitialMount = true;
57
58
  sortAfterTick = false;
@@ -102,6 +103,7 @@ export class CommandRootState {
102
103
  }
103
104
  constructor(opts) {
104
105
  this.opts = opts;
106
+ this.attachment = attachRef(this.opts.ref);
105
107
  const defaults = { ...this._commandState, value: this.opts.value.current ?? "" };
106
108
  this._commandState = defaults;
107
109
  this.commandState = defaults;
@@ -925,7 +927,7 @@ export class CommandRootState {
925
927
  [commandAttrs.root]: "",
926
928
  tabindex: -1,
927
929
  onkeydown: this.onkeydown,
928
- ...attachRef(this.opts.ref),
930
+ ...this.attachment,
929
931
  }));
930
932
  }
931
933
  function itemIsDisabled(item) {
@@ -937,6 +939,7 @@ export class CommandEmptyState {
937
939
  }
938
940
  opts;
939
941
  root;
942
+ attachment;
940
943
  shouldRender = $derived.by(() => {
941
944
  return ((this.root._commandState.filtered.count === 0 && this.#isInitialRender === false) ||
942
945
  this.opts.forceMount.current);
@@ -945,6 +948,7 @@ export class CommandEmptyState {
945
948
  constructor(opts, root) {
946
949
  this.opts = opts;
947
950
  this.root = root;
951
+ this.attachment = attachRef(this.opts.ref);
948
952
  $effect.pre(() => {
949
953
  this.#isInitialRender = false;
950
954
  });
@@ -953,7 +957,7 @@ export class CommandEmptyState {
953
957
  id: this.opts.id.current,
954
958
  role: "presentation",
955
959
  [commandAttrs.empty]: "",
956
- ...attachRef(this.opts.ref),
960
+ ...this.attachment,
957
961
  }));
958
962
  }
959
963
  export class CommandGroupContainerState {
@@ -962,6 +966,7 @@ export class CommandGroupContainerState {
962
966
  }
963
967
  opts;
964
968
  root;
969
+ attachment;
965
970
  shouldRender = $derived.by(() => {
966
971
  if (this.opts.forceMount.current)
967
972
  return true;
@@ -976,6 +981,7 @@ export class CommandGroupContainerState {
976
981
  constructor(opts, root) {
977
982
  this.opts = opts;
978
983
  this.root = root;
984
+ this.attachment = attachRef(this.opts.ref);
979
985
  this.trueValue = opts.value.current ?? opts.id.current;
980
986
  watch(() => this.trueValue, () => {
981
987
  return this.root.registerGroup(this.trueValue);
@@ -1001,7 +1007,7 @@ export class CommandGroupContainerState {
1001
1007
  hidden: this.shouldRender ? undefined : true,
1002
1008
  "data-value": this.trueValue,
1003
1009
  [commandAttrs.group]: "",
1004
- ...attachRef(this.opts.ref),
1010
+ ...this.attachment,
1005
1011
  }));
1006
1012
  }
1007
1013
  export class CommandGroupHeadingState {
@@ -1010,14 +1016,16 @@ export class CommandGroupHeadingState {
1010
1016
  }
1011
1017
  opts;
1012
1018
  group;
1019
+ attachment;
1013
1020
  constructor(opts, group) {
1014
1021
  this.opts = opts;
1015
1022
  this.group = group;
1023
+ this.attachment = attachRef(this.opts.ref, (v) => (this.group.headingNode = v));
1016
1024
  }
1017
1025
  props = $derived.by(() => ({
1018
1026
  id: this.opts.id.current,
1019
1027
  [commandAttrs["group-heading"]]: "",
1020
- ...attachRef(this.opts.ref, (v) => (this.group.headingNode = v)),
1028
+ ...this.attachment,
1021
1029
  }));
1022
1030
  }
1023
1031
  export class CommandGroupItemsState {
@@ -1026,16 +1034,18 @@ export class CommandGroupItemsState {
1026
1034
  }
1027
1035
  opts;
1028
1036
  group;
1037
+ attachment;
1029
1038
  constructor(opts, group) {
1030
1039
  this.opts = opts;
1031
1040
  this.group = group;
1041
+ this.attachment = attachRef(this.opts.ref);
1032
1042
  }
1033
1043
  props = $derived.by(() => ({
1034
1044
  id: this.opts.id.current,
1035
1045
  role: "group",
1036
1046
  [commandAttrs["group-items"]]: "",
1037
1047
  "aria-labelledby": this.group.headingNode?.id ?? undefined,
1038
- ...attachRef(this.opts.ref),
1048
+ ...this.attachment,
1039
1049
  }));
1040
1050
  }
1041
1051
  export class CommandInputState {
@@ -1044,6 +1054,7 @@ export class CommandInputState {
1044
1054
  }
1045
1055
  opts;
1046
1056
  root;
1057
+ attachment;
1047
1058
  #selectedItemId = $derived.by(() => {
1048
1059
  const item = this.root.viewportNode?.querySelector(`${COMMAND_ITEM_SELECTOR}[${COMMAND_VALUE_ATTR}="${cssesc(this.root.opts.value.current)}"]`);
1049
1060
  if (item === undefined || item === null)
@@ -1053,6 +1064,7 @@ export class CommandInputState {
1053
1064
  constructor(opts, root) {
1054
1065
  this.opts = opts;
1055
1066
  this.root = root;
1067
+ this.attachment = attachRef(this.opts.ref, (v) => (this.root.inputNode = v));
1056
1068
  watch(() => this.opts.ref.current, () => {
1057
1069
  const node = this.opts.ref.current;
1058
1070
  if (node && this.opts.autofocus.current) {
@@ -1078,7 +1090,7 @@ export class CommandInputState {
1078
1090
  "aria-controls": this.root.viewportNode?.id ?? undefined,
1079
1091
  "aria-labelledby": this.root.labelNode?.id ?? undefined,
1080
1092
  "aria-activedescendant": this.#selectedItemId,
1081
- ...attachRef(this.opts.ref, (v) => (this.root.inputNode = v)),
1093
+ ...this.attachment,
1082
1094
  }));
1083
1095
  }
1084
1096
  export class CommandItemState {
@@ -1088,6 +1100,7 @@ export class CommandItemState {
1088
1100
  }
1089
1101
  opts;
1090
1102
  root;
1103
+ attachment;
1091
1104
  #group = null;
1092
1105
  #trueForceMount = $derived.by(() => {
1093
1106
  return this.opts.forceMount.current || this.#group?.opts.forceMount.current === true;
@@ -1111,6 +1124,7 @@ export class CommandItemState {
1111
1124
  this.root = root;
1112
1125
  this.#group = CommandGroupContainerContext.getOr(null);
1113
1126
  this.trueValue = opts.value.current;
1127
+ this.attachment = attachRef(this.opts.ref);
1114
1128
  watch([
1115
1129
  () => this.trueValue,
1116
1130
  () => this.#group?.trueValue,
@@ -1164,7 +1178,7 @@ export class CommandItemState {
1164
1178
  role: "option",
1165
1179
  onpointermove: this.onpointermove,
1166
1180
  onclick: this.onclick,
1167
- ...attachRef(this.opts.ref),
1181
+ ...this.attachment,
1168
1182
  }));
1169
1183
  }
1170
1184
  export class CommandLoadingState {
@@ -1172,8 +1186,10 @@ export class CommandLoadingState {
1172
1186
  return new CommandLoadingState(opts);
1173
1187
  }
1174
1188
  opts;
1189
+ attachment;
1175
1190
  constructor(opts) {
1176
1191
  this.opts = opts;
1192
+ this.attachment = attachRef(this.opts.ref);
1177
1193
  }
1178
1194
  props = $derived.by(() => ({
1179
1195
  id: this.opts.id.current,
@@ -1183,7 +1199,7 @@ export class CommandLoadingState {
1183
1199
  "aria-valuemax": 100,
1184
1200
  "aria-label": "Loading...",
1185
1201
  [commandAttrs.loading]: "",
1186
- ...attachRef(this.opts.ref),
1202
+ ...this.attachment,
1187
1203
  }));
1188
1204
  }
1189
1205
  export class CommandSeparatorState {
@@ -1192,17 +1208,19 @@ export class CommandSeparatorState {
1192
1208
  }
1193
1209
  opts;
1194
1210
  root;
1211
+ attachment;
1195
1212
  shouldRender = $derived.by(() => !this.root._commandState.search || this.opts.forceMount.current);
1196
1213
  constructor(opts, root) {
1197
1214
  this.opts = opts;
1198
1215
  this.root = root;
1216
+ this.attachment = attachRef(this.opts.ref);
1199
1217
  }
1200
1218
  props = $derived.by(() => ({
1201
1219
  id: this.opts.id.current,
1202
1220
  // role="separator" cannot belong to a role="listbox"
1203
1221
  "aria-hidden": "true",
1204
1222
  [commandAttrs.separator]: "",
1205
- ...attachRef(this.opts.ref),
1223
+ ...this.attachment,
1206
1224
  }));
1207
1225
  }
1208
1226
  export class CommandListState {
@@ -1211,16 +1229,18 @@ export class CommandListState {
1211
1229
  }
1212
1230
  opts;
1213
1231
  root;
1232
+ attachment;
1214
1233
  constructor(opts, root) {
1215
1234
  this.opts = opts;
1216
1235
  this.root = root;
1236
+ this.attachment = attachRef(this.opts.ref);
1217
1237
  }
1218
1238
  props = $derived.by(() => ({
1219
1239
  id: this.opts.id.current,
1220
1240
  role: "listbox",
1221
1241
  "aria-label": this.opts.ariaLabel.current,
1222
1242
  [commandAttrs.list]: "",
1223
- ...attachRef(this.opts.ref),
1243
+ ...this.attachment,
1224
1244
  }));
1225
1245
  }
1226
1246
  export class CommandLabelState {
@@ -1229,16 +1249,18 @@ export class CommandLabelState {
1229
1249
  }
1230
1250
  opts;
1231
1251
  root;
1252
+ attachment;
1232
1253
  constructor(opts, root) {
1233
1254
  this.opts = opts;
1234
1255
  this.root = root;
1256
+ this.attachment = attachRef(this.opts.ref, (v) => (this.root.labelNode = v));
1235
1257
  }
1236
1258
  props = $derived.by(() => ({
1237
1259
  id: this.opts.id.current,
1238
1260
  [commandAttrs["input-label"]]: "",
1239
1261
  for: this.opts.for?.current,
1240
1262
  style: srOnlyStyles,
1241
- ...attachRef(this.opts.ref, (v) => (this.root.labelNode = v)),
1263
+ ...this.attachment,
1242
1264
  }));
1243
1265
  }
1244
1266
  export class CommandViewportState {
@@ -1247,9 +1269,11 @@ export class CommandViewportState {
1247
1269
  }
1248
1270
  opts;
1249
1271
  list;
1272
+ attachment;
1250
1273
  constructor(opts, list) {
1251
1274
  this.opts = opts;
1252
1275
  this.list = list;
1276
+ this.attachment = attachRef(this.opts.ref, (v) => (this.list.root.viewportNode = v));
1253
1277
  watch([() => this.opts.ref.current, () => this.list.opts.ref.current], ([node, listNode]) => {
1254
1278
  if (node === null || listNode === null)
1255
1279
  return;
@@ -1270,6 +1294,6 @@ export class CommandViewportState {
1270
1294
  props = $derived.by(() => ({
1271
1295
  id: this.opts.id.current,
1272
1296
  [commandAttrs.viewport]: "",
1273
- ...attachRef(this.opts.ref, (v) => (this.list.root.viewportNode = v)),
1297
+ ...this.attachment,
1274
1298
  }));
1275
1299
  }
@@ -2,7 +2,7 @@ import type { Updater } from "svelte/store";
2
2
  import type { DateValue } from "@internationalized/date";
3
3
  import { type WritableBox, DOMContext, type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
4
4
  import type { DateRangeFieldRootState } from "../date-range-field/date-range-field.svelte.js";
5
- import type { BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, WithRefOpts } from "../../internal/types.js";
5
+ import type { BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, WithRefOpts, RefAttachment } from "../../internal/types.js";
6
6
  import type { DateAndTimeSegmentObj, DateOnInvalid, DateSegmentObj, DateSegmentPart, DateValidator, Granularity, HourCycle, SegmentPart, SegmentValueObj, TimeSegmentObj, EditableTimeSegmentPart } from "../../shared/date/types.js";
7
7
  import { type Formatter } from "../../internal/date-time/formatter.js";
8
8
  import { type Announcer } from "../../internal/date-time/announcer.js";
@@ -171,6 +171,7 @@ export declare class DateFieldInputState {
171
171
  readonly opts: DateFieldInputStateOpts;
172
172
  readonly root: DateFieldRootState;
173
173
  readonly domContext: DOMContext;
174
+ readonly attachment: RefAttachment;
174
175
  constructor(opts: DateFieldInputStateOpts, root: DateFieldRootState);
175
176
  readonly props: {
176
177
  readonly id: string;
@@ -200,6 +201,7 @@ export declare class DateFieldLabelState {
200
201
  static create(opts: DateFieldLabelStateOpts): DateFieldLabelState;
201
202
  readonly opts: DateFieldLabelStateOpts;
202
203
  readonly root: DateFieldRootState;
204
+ readonly attachment: RefAttachment;
203
205
  constructor(opts: DateFieldLabelStateOpts, root: DateFieldRootState);
204
206
  onclick(_: BitsMouseEvent): void;
205
207
  readonly props: {
@@ -216,6 +218,7 @@ declare abstract class BaseNumericSegmentState {
216
218
  readonly announcer: Announcer;
217
219
  readonly part: string;
218
220
  readonly config: SegmentConfig;
221
+ readonly attachment: RefAttachment;
219
222
  constructor(opts: WithRefOpts, root: DateFieldRootState, part: string, config: SegmentConfig);
220
223
  onkeydown(e: BitsKeyboardEvent): void;
221
224
  onfocusout(_: BitsFocusEvent): void;
@@ -226,7 +229,7 @@ declare abstract class BaseNumericSegmentState {
226
229
  "aria-valuenow": number;
227
230
  "aria-valuetext": string;
228
231
  };
229
- props: {
232
+ readonly props: {
230
233
  "aria-invalid": "true" | undefined;
231
234
  "aria-disabled": "true" | "false";
232
235
  "aria-readonly": "true" | "false";
@@ -313,6 +316,7 @@ export declare class DateFieldDayPeriodSegmentState {
313
316
  static create(opts: DateFieldDayPeriodSegmentStateOpts): DateFieldDayPeriodSegmentState;
314
317
  readonly opts: DateFieldDayPeriodSegmentStateOpts;
315
318
  readonly root: DateFieldRootState;
319
+ readonly attachment: RefAttachment;
316
320
  constructor(opts: DateFieldDayPeriodSegmentStateOpts, root: DateFieldRootState);
317
321
  onkeydown(e: BitsKeyboardEvent): void;
318
322
  readonly props: {
@@ -377,6 +381,7 @@ export declare class DateFieldLiteralSegmentState {
377
381
  static create(opts: DateFieldLiteralSegmentStateOpts): DateFieldLiteralSegmentState;
378
382
  readonly opts: DateFieldLiteralSegmentStateOpts;
379
383
  readonly root: DateFieldRootState;
384
+ readonly attachment: RefAttachment;
380
385
  constructor(opts: DateFieldLiteralSegmentStateOpts, root: DateFieldRootState);
381
386
  readonly props: {
382
387
  readonly "aria-invalid": "true" | undefined;
@@ -410,6 +415,7 @@ export declare class DateFieldTimeZoneSegmentState {
410
415
  static create(opts: DateFieldTimeZoneSegmentStateOpts): DateFieldTimeZoneSegmentState;
411
416
  readonly opts: DateFieldTimeZoneSegmentStateOpts;
412
417
  readonly root: DateFieldRootState;
418
+ readonly attachment: RefAttachment;
413
419
  constructor(opts: DateFieldTimeZoneSegmentStateOpts, root: DateFieldRootState);
414
420
  onkeydown(e: BitsKeyboardEvent): void;
415
421
  readonly props: {