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
@@ -1,7 +1,7 @@
1
1
  import type { Updater } from "svelte/store";
2
2
  import { Time } from "@internationalized/date";
3
3
  import { type WritableBox, DOMContext, type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
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 { TimeSegmentObj, SegmentPart, HourCycle, TimeValidator, TimeOnInvalid, EditableTimeSegmentPart } from "../../shared/date/types.js";
6
6
  import { type TimeFormatter } from "../../internal/date-time/formatter.js";
7
7
  import { type Announcer } from "../../internal/date-time/announcer.js";
@@ -153,6 +153,7 @@ export declare class TimeFieldInputState {
153
153
  static create(opts: TimeFieldInputStateOpts): TimeFieldInputState;
154
154
  readonly opts: TimeFieldInputStateOpts;
155
155
  readonly root: TimeFieldRootState;
156
+ readonly attachment: RefAttachment;
156
157
  domContext: DOMContext;
157
158
  constructor(opts: TimeFieldInputStateOpts, root: TimeFieldRootState);
158
159
  readonly props: {
@@ -183,6 +184,7 @@ export declare class TimeFieldLabelState {
183
184
  static create(opts: TimeFieldLabelStateOpts): TimeFieldLabelState;
184
185
  readonly opts: TimeFieldLabelStateOpts;
185
186
  readonly root: TimeFieldRootState;
187
+ readonly attachment: RefAttachment;
186
188
  constructor(opts: TimeFieldLabelStateOpts, root: TimeFieldRootState);
187
189
  onclick(_: BitsMouseEvent): void;
188
190
  readonly props: {
@@ -199,6 +201,7 @@ declare abstract class BaseTimeSegmentState {
199
201
  readonly announcer: Announcer;
200
202
  readonly part: string;
201
203
  readonly config: SegmentConfig;
204
+ readonly attachment: RefAttachment;
202
205
  constructor(opts: WithRefOpts, root: TimeFieldRootState, part: string, config: SegmentConfig);
203
206
  onkeydown(e: BitsKeyboardEvent): void;
204
207
  onfocusout(_: BitsFocusEvent): void;
@@ -283,6 +286,7 @@ declare class TimeFieldDayPeriodSegmentState {
283
286
  #private;
284
287
  readonly opts: TimeFieldDayPeriodSegmentStateOpts;
285
288
  readonly root: TimeFieldRootState;
289
+ readonly attachment: RefAttachment;
286
290
  constructor(opts: TimeFieldDayPeriodSegmentStateOpts, root: TimeFieldRootState);
287
291
  onkeydown(e: BitsKeyboardEvent): void;
288
292
  readonly props: {
@@ -346,6 +350,7 @@ interface TimeFieldLiteralSegmentStateOpts extends WithRefOpts {
346
350
  declare class TimeFieldLiteralSegmentState {
347
351
  readonly opts: TimeFieldLiteralSegmentStateOpts;
348
352
  readonly root: TimeFieldRootState;
353
+ readonly attachment: RefAttachment;
349
354
  constructor(opts: TimeFieldLiteralSegmentStateOpts, root: TimeFieldRootState);
350
355
  readonly props: {
351
356
  readonly "aria-invalid": "true" | undefined;
@@ -376,6 +381,7 @@ declare class TimeFieldLiteralSegmentState {
376
381
  declare class TimeFieldTimeZoneSegmentState {
377
382
  readonly opts: TimeFieldLiteralSegmentStateOpts;
378
383
  readonly root: TimeFieldRootState;
384
+ readonly attachment: RefAttachment;
379
385
  constructor(opts: TimeFieldLiteralSegmentStateOpts, root: TimeFieldRootState);
380
386
  onkeydown(e: BitsKeyboardEvent): void;
381
387
  readonly props: {
@@ -461,10 +461,12 @@ export class TimeFieldInputState {
461
461
  }
462
462
  opts;
463
463
  root;
464
+ attachment;
464
465
  domContext;
465
466
  constructor(opts, root) {
466
467
  this.opts = opts;
467
468
  this.root = root;
469
+ this.attachment = attachRef(opts.ref, (v) => this.root.setFieldNode(v));
468
470
  this.domContext = new DOMContext(opts.ref);
469
471
  this.root.setName(this.opts.name.current);
470
472
  $effect(() => {
@@ -488,7 +490,7 @@ export class TimeFieldInputState {
488
490
  "data-invalid": this.root.isInvalid ? "" : undefined,
489
491
  "data-disabled": getDataDisabled(this.root.disabled.current),
490
492
  [timeFieldAttrs.input]: "",
491
- ...attachRef(this.opts.ref, (v) => this.root.setFieldNode(v)),
493
+ ...this.attachment,
492
494
  }));
493
495
  }
494
496
  export class TimeFieldHiddenInputState {
@@ -513,9 +515,11 @@ export class TimeFieldLabelState {
513
515
  }
514
516
  opts;
515
517
  root;
518
+ attachment;
516
519
  constructor(opts, root) {
517
520
  this.opts = opts;
518
521
  this.root = root;
522
+ this.attachment = attachRef(opts.ref, (v) => this.root.setLabelNode(v));
519
523
  this.onclick = this.onclick.bind(this);
520
524
  }
521
525
  onclick(_) {
@@ -532,7 +536,7 @@ export class TimeFieldLabelState {
532
536
  "data-disabled": getDataDisabled(this.root.disabled.current),
533
537
  [timeFieldAttrs.label]: "",
534
538
  onclick: this.onclick,
535
- ...attachRef(this.opts.ref, (v) => this.root.setLabelNode(v)),
539
+ ...this.attachment,
536
540
  }));
537
541
  }
538
542
  // Base class for time segments - simplified from date-field version
@@ -542,12 +546,14 @@ class BaseTimeSegmentState {
542
546
  announcer;
543
547
  part;
544
548
  config;
549
+ attachment;
545
550
  constructor(opts, root, part, config) {
546
551
  this.opts = opts;
547
552
  this.root = root;
548
553
  this.part = part;
549
554
  this.config = config;
550
555
  this.announcer = root.announcer;
556
+ this.attachment = attachRef(opts.ref);
551
557
  this.onkeydown = this.onkeydown.bind(this);
552
558
  this.onfocusout = this.onfocusout.bind(this);
553
559
  }
@@ -779,7 +785,7 @@ class BaseTimeSegmentState {
779
785
  onfocusout: this.onfocusout,
780
786
  onclick: this.root.handleSegmentClick,
781
787
  ...this.root.getBaseSegmentAttrs(this.part, this.opts.id.current),
782
- ...attachRef(this.opts.ref),
788
+ ...this.attachment,
783
789
  };
784
790
  });
785
791
  }
@@ -822,11 +828,13 @@ class TimeFieldSecondSegmentState extends BaseTimeSegmentState {
822
828
  class TimeFieldDayPeriodSegmentState {
823
829
  opts;
824
830
  root;
831
+ attachment;
825
832
  #announcer;
826
833
  constructor(opts, root) {
827
834
  this.opts = opts;
828
835
  this.root = root;
829
836
  this.#announcer = this.root.announcer;
837
+ this.attachment = attachRef(opts.ref, (v) => (this.root.dayPeriodNode = v));
830
838
  this.onkeydown = this.onkeydown.bind(this);
831
839
  }
832
840
  onkeydown(e) {
@@ -888,30 +896,34 @@ class TimeFieldDayPeriodSegmentState {
888
896
  onkeydown: this.onkeydown,
889
897
  onclick: this.root.handleSegmentClick,
890
898
  ...this.root.getBaseSegmentAttrs("dayPeriod", this.opts.id.current),
891
- ...attachRef(this.opts.ref, (v) => (this.root.dayPeriodNode = v)),
899
+ ...this.attachment,
892
900
  };
893
901
  });
894
902
  }
895
903
  class TimeFieldLiteralSegmentState {
896
904
  opts;
897
905
  root;
906
+ attachment;
898
907
  constructor(opts, root) {
899
908
  this.opts = opts;
900
909
  this.root = root;
910
+ this.attachment = attachRef(opts.ref);
901
911
  }
902
912
  props = $derived.by(() => ({
903
913
  id: this.opts.id.current,
904
914
  "aria-hidden": getAriaHidden(true),
905
915
  ...this.root.getBaseSegmentAttrs("literal", this.opts.id.current),
906
- ...attachRef(this.opts.ref),
916
+ ...this.attachment,
907
917
  }));
908
918
  }
909
919
  class TimeFieldTimeZoneSegmentState {
910
920
  opts;
911
921
  root;
922
+ attachment;
912
923
  constructor(opts, root) {
913
924
  this.opts = opts;
914
925
  this.root = root;
926
+ this.attachment = attachRef(opts.ref);
915
927
  this.onkeydown = this.onkeydown.bind(this);
916
928
  }
917
929
  onkeydown(e) {
@@ -934,7 +946,7 @@ class TimeFieldTimeZoneSegmentState {
934
946
  tabindex: 0,
935
947
  ...this.root.getBaseSegmentAttrs("timeZoneName", this.opts.id.current),
936
948
  "data-readonly": getDataReadonly(true),
937
- ...attachRef(this.opts.ref),
949
+ ...this.attachment,
938
950
  }));
939
951
  }
940
952
  export class DateFieldSegmentState {
@@ -4,7 +4,7 @@ import { Context } from "runed";
4
4
  import { TimeFieldRootState } from "../time-field/time-field.svelte.js";
5
5
  import { TimeFieldInputState } from "../time-field/time-field.svelte.js";
6
6
  import type { TimeSegmentPart } from "../../shared/index.js";
7
- import type { WithRefOpts } from "../../internal/types.js";
7
+ import type { RefAttachment, WithRefOpts } from "../../internal/types.js";
8
8
  import type { TimeGranularity, TimeOnInvalid, TimeRange, TimeRangeValidator, TimeValue } from "../../shared/date/types.js";
9
9
  import { type TimeFormatter } from "../../internal/date-time/formatter.js";
10
10
  export declare const timeRangeFieldAttrs: import("../../internal/attrs.js").CreateBitsAttrsReturn<readonly ["root", "label"]>;
@@ -34,6 +34,7 @@ export declare class TimeRangeFieldRootState<T extends TimeValue = Time> {
34
34
  #private;
35
35
  static create<T extends TimeValue = Time>(opts: TimeRangeFieldRootStateOpts<T>): TimeRangeFieldRootState<Time>;
36
36
  readonly opts: TimeRangeFieldRootStateOpts<T>;
37
+ readonly attachment: RefAttachment;
37
38
  startFieldState: TimeFieldRootState | undefined;
38
39
  endFieldState: TimeFieldRootState | undefined;
39
40
  descriptionId: string;
@@ -74,6 +75,7 @@ export declare class TimeRangeFieldLabelState {
74
75
  static create(opts: TimeRangeFieldLabelStateOpts): TimeRangeFieldLabelState;
75
76
  readonly opts: TimeRangeFieldLabelStateOpts;
76
77
  readonly root: TimeRangeFieldRootState;
78
+ readonly attachment: RefAttachment;
77
79
  constructor(opts: TimeRangeFieldLabelStateOpts, root: TimeRangeFieldRootState);
78
80
  readonly props: {
79
81
  readonly id: string;
@@ -18,6 +18,7 @@ export class TimeRangeFieldRootState {
18
18
  return TimeRangeFieldRootContext.set(new TimeRangeFieldRootState(opts));
19
19
  }
20
20
  opts;
21
+ attachment;
21
22
  startFieldState = undefined;
22
23
  endFieldState = undefined;
23
24
  descriptionId = useId();
@@ -53,6 +54,7 @@ export class TimeRangeFieldRootState {
53
54
  this.opts = opts;
54
55
  this.formatter = createTimeFormatter(this.opts.locale.current);
55
56
  this.domContext = new DOMContext(this.opts.ref);
57
+ this.attachment = attachRef(this.opts.ref, (v) => (this.fieldNode = v));
56
58
  onDestroyEffect(() => {
57
59
  removeDescriptionElement(this.descriptionId, this.domContext.getDocument());
58
60
  });
@@ -160,7 +162,7 @@ export class TimeRangeFieldRootState {
160
162
  role: "group",
161
163
  [timeRangeFieldAttrs.root]: "",
162
164
  "data-invalid": getDataInvalid(this.isInvalid),
163
- ...attachRef(this.opts.ref, (v) => (this.fieldNode = v)),
165
+ ...this.attachment,
164
166
  }));
165
167
  }
166
168
  export class TimeRangeFieldLabelState {
@@ -169,9 +171,11 @@ export class TimeRangeFieldLabelState {
169
171
  }
170
172
  opts;
171
173
  root;
174
+ attachment;
172
175
  constructor(opts, root) {
173
176
  this.opts = opts;
174
177
  this.root = root;
178
+ this.attachment = attachRef(this.opts.ref, (v) => (this.root.labelNode = v));
175
179
  }
176
180
  #onclick = () => {
177
181
  if (this.root.opts.disabled.current)
@@ -187,7 +191,7 @@ export class TimeRangeFieldLabelState {
187
191
  "data-disabled": getDataDisabled(this.root.opts.disabled.current),
188
192
  [timeRangeFieldAttrs.label]: "",
189
193
  onclick: this.#onclick,
190
- ...attachRef(this.opts.ref, (v) => (this.root.labelNode = v)),
194
+ ...this.attachment,
191
195
  }));
192
196
  }
193
197
  export class TimeRangeFieldInputState {
@@ -1,5 +1,5 @@
1
1
  import { type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
2
- import type { BitsMouseEvent, WithRefOpts } from "../../internal/types.js";
2
+ import type { BitsMouseEvent, RefAttachment, WithRefOpts } from "../../internal/types.js";
3
3
  export declare const toggleAttrs: import("../../internal/attrs.js").CreateBitsAttrsReturn<readonly ["root"]>;
4
4
  interface ToggleRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
5
5
  disabled: boolean;
@@ -11,6 +11,7 @@ export declare class ToggleRootState {
11
11
  #private;
12
12
  static create(opts: ToggleRootStateOpts): ToggleRootState;
13
13
  readonly opts: ToggleRootStateOpts;
14
+ readonly attachment: RefAttachment;
14
15
  constructor(opts: ToggleRootStateOpts);
15
16
  onclick(_: BitsMouseEvent): void;
16
17
  readonly snippetProps: {
@@ -9,8 +9,10 @@ export class ToggleRootState {
9
9
  return new ToggleRootState(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
  this.onclick = this.onclick.bind(this);
15
17
  }
16
18
  #togglePressed() {
@@ -34,7 +36,7 @@ export class ToggleRootState {
34
36
  "data-state": getToggleDataState(this.opts.pressed.current),
35
37
  disabled: getDisabled(this.opts.disabled.current),
36
38
  onclick: this.onclick,
37
- ...attachRef(this.opts.ref),
39
+ ...this.attachment,
38
40
  }));
39
41
  }
40
42
  export function getToggleDataState(condition) {
@@ -1,6 +1,6 @@
1
1
  import { type WritableBox, type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
2
2
  import type { Orientation } from "../../shared/index.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 { RovingFocusGroup } from "../../internal/roving-focus-group.js";
5
5
  export declare const toggleGroupAttrs: import("../../internal/attrs.js").CreateBitsAttrsReturn<readonly ["root", "item"]>;
6
6
  interface ToggleGroupBaseStateOpts extends WithRefOpts, ReadableBoxedValues<{
@@ -13,6 +13,7 @@ interface ToggleGroupBaseStateOpts extends WithRefOpts, ReadableBoxedValues<{
13
13
  declare abstract class ToggleGroupBaseState {
14
14
  readonly opts: ToggleGroupBaseStateOpts;
15
15
  readonly rovingFocusGroup: RovingFocusGroup;
16
+ readonly attachment: RefAttachment;
16
17
  constructor(opts: ToggleGroupBaseStateOpts);
17
18
  readonly props: {
18
19
  readonly id: string;
@@ -68,6 +69,7 @@ export declare class ToggleGroupItemState {
68
69
  static create(opts: ToggleGroupItemStateOpts): ToggleGroupItemState;
69
70
  readonly opts: ToggleGroupItemStateOpts;
70
71
  readonly root: ToggleGroup;
72
+ readonly attachment: RefAttachment;
71
73
  readonly isPressed: boolean;
72
74
  constructor(opts: ToggleGroupItemStateOpts, root: ToggleGroup);
73
75
  onclick(_: BitsMouseEvent): void;
@@ -11,8 +11,10 @@ const ToggleGroupRootContext = new Context("ToggleGroup.Root");
11
11
  class ToggleGroupBaseState {
12
12
  opts;
13
13
  rovingFocusGroup;
14
+ attachment;
14
15
  constructor(opts) {
15
16
  this.opts = opts;
17
+ this.attachment = attachRef(this.opts.ref);
16
18
  this.rovingFocusGroup = new RovingFocusGroup({
17
19
  candidateAttr: toggleGroupAttrs.item,
18
20
  rootNode: opts.ref,
@@ -26,7 +28,7 @@ class ToggleGroupBaseState {
26
28
  role: "group",
27
29
  "data-orientation": getDataOrientation(this.opts.orientation.current),
28
30
  "data-disabled": getDataDisabled(this.opts.disabled.current),
29
- ...attachRef(this.opts.ref),
31
+ ...this.attachment,
30
32
  }));
31
33
  }
32
34
  class ToggleGroupSingleState extends ToggleGroupBaseState {
@@ -86,6 +88,7 @@ export class ToggleGroupItemState {
86
88
  }
87
89
  opts;
88
90
  root;
91
+ attachment;
89
92
  #isDisabled = $derived.by(() => this.opts.disabled.current || this.root.opts.disabled.current);
90
93
  isPressed = $derived.by(() => this.root.includesItem(this.opts.value.current));
91
94
  #ariaChecked = $derived.by(() => {
@@ -97,6 +100,7 @@ export class ToggleGroupItemState {
97
100
  constructor(opts, root) {
98
101
  this.opts = opts;
99
102
  this.root = root;
103
+ this.attachment = attachRef(this.opts.ref);
100
104
  $effect(() => {
101
105
  if (!this.root.opts.rovingFocus.current) {
102
106
  this.#tabIndex = 0;
@@ -149,7 +153,7 @@ export class ToggleGroupItemState {
149
153
  //
150
154
  onclick: this.onclick,
151
155
  onkeydown: this.onkeydown,
152
- ...attachRef(this.opts.ref),
156
+ ...this.attachment,
153
157
  }));
154
158
  }
155
159
  function getToggleItemDataState(condition) {
@@ -1,6 +1,6 @@
1
1
  import { type WritableBox, type WritableBoxedValues, type ReadableBoxedValues } from "svelte-toolbelt";
2
2
  import type { Orientation } from "../../shared/index.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 { RovingFocusGroup } from "../../internal/roving-focus-group.js";
5
5
  export declare const toolbarAttrs: import("../../internal/attrs.js").CreateBitsAttrsReturn<readonly ["root", "item", "group", "group-item", "link", "button"]>;
6
6
  interface ToolbarRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
@@ -12,6 +12,7 @@ export declare class ToolbarRootState {
12
12
  static create(opts: ToolbarRootStateOpts): ToolbarRootState;
13
13
  readonly opts: ToolbarRootStateOpts;
14
14
  readonly rovingFocusGroup: RovingFocusGroup;
15
+ readonly attachment: RefAttachment;
15
16
  constructor(opts: ToolbarRootStateOpts);
16
17
  readonly props: {
17
18
  readonly id: string;
@@ -26,6 +27,7 @@ interface ToolbarGroupBaseStateOpts extends WithRefOpts, ReadableBoxedValues<{
26
27
  declare abstract class ToolbarGroupBaseState {
27
28
  readonly opts: ToolbarGroupBaseStateOpts;
28
29
  readonly root: ToolbarRootState;
30
+ readonly attachment: RefAttachment;
29
31
  constructor(opts: ToolbarGroupBaseStateOpts, root: ToolbarRootState);
30
32
  readonly props: {
31
33
  readonly id: string;
@@ -81,6 +83,7 @@ export declare class ToolbarGroupItemState {
81
83
  readonly opts: ToolbarGroupItemStateOpts;
82
84
  readonly group: ToolbarGroup;
83
85
  readonly root: ToolbarRootState;
86
+ readonly attachment: RefAttachment;
84
87
  constructor(opts: ToolbarGroupItemStateOpts, group: ToolbarGroup, root: ToolbarRootState);
85
88
  onclick(_: BitsMouseEvent): void;
86
89
  onkeydown(e: BitsKeyboardEvent): void;
@@ -107,6 +110,7 @@ export declare class ToolbarLinkState {
107
110
  static create(opts: ToolbarLinkStateOpts): ToolbarLinkState;
108
111
  readonly opts: ToolbarLinkStateOpts;
109
112
  readonly root: ToolbarRootState;
113
+ readonly attachment: RefAttachment;
110
114
  constructor(opts: ToolbarLinkStateOpts, root: ToolbarRootState);
111
115
  onkeydown(e: BitsKeyboardEvent): void;
112
116
  readonly props: {
@@ -126,6 +130,7 @@ export declare class ToolbarButtonState {
126
130
  static create(opts: ToolbarButtonStateOpts): ToolbarButtonState;
127
131
  readonly opts: ToolbarButtonStateOpts;
128
132
  readonly root: ToolbarRootState;
133
+ readonly attachment: RefAttachment;
129
134
  constructor(opts: ToolbarButtonStateOpts, root: ToolbarRootState);
130
135
  onkeydown(e: BitsKeyboardEvent): void;
131
136
  readonly props: {
@@ -15,8 +15,10 @@ export class ToolbarRootState {
15
15
  }
16
16
  opts;
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
  orientation: this.opts.orientation,
22
24
  loop: this.opts.loop,
@@ -29,15 +31,17 @@ export class ToolbarRootState {
29
31
  role: "toolbar",
30
32
  "data-orientation": this.opts.orientation.current,
31
33
  [toolbarAttrs.root]: "",
32
- ...attachRef(this.opts.ref),
34
+ ...this.attachment,
33
35
  }));
34
36
  }
35
37
  class ToolbarGroupBaseState {
36
38
  opts;
37
39
  root;
40
+ attachment;
38
41
  constructor(opts, root) {
39
42
  this.opts = opts;
40
43
  this.root = root;
44
+ this.attachment = attachRef(this.opts.ref);
41
45
  }
42
46
  props = $derived.by(() => ({
43
47
  id: this.opts.id.current,
@@ -45,7 +49,7 @@ class ToolbarGroupBaseState {
45
49
  role: "group",
46
50
  "data-orientation": getDataOrientation(this.root.opts.orientation.current),
47
51
  "data-disabled": getDataDisabled(this.opts.disabled.current),
48
- ...attachRef(this.opts.ref),
52
+ ...this.attachment,
49
53
  }));
50
54
  }
51
55
  class ToolbarGroupSingleState extends ToolbarGroupBaseState {
@@ -110,11 +114,13 @@ export class ToolbarGroupItemState {
110
114
  opts;
111
115
  group;
112
116
  root;
117
+ attachment;
113
118
  #isDisabled = $derived.by(() => this.opts.disabled.current || this.group.opts.disabled.current);
114
119
  constructor(opts, group, root) {
115
120
  this.opts = opts;
116
121
  this.group = group;
117
122
  this.root = root;
123
+ this.attachment = attachRef(this.opts.ref);
118
124
  $effect(() => {
119
125
  this.#tabIndex = this.root.rovingFocusGroup.getTabIndex(this.opts.ref.current);
120
126
  });
@@ -165,7 +171,7 @@ export class ToolbarGroupItemState {
165
171
  //
166
172
  onclick: this.onclick,
167
173
  onkeydown: this.onkeydown,
168
- ...attachRef(this.opts.ref),
174
+ ...this.attachment,
169
175
  }));
170
176
  }
171
177
  export class ToolbarLinkState {
@@ -174,9 +180,11 @@ export class ToolbarLinkState {
174
180
  }
175
181
  opts;
176
182
  root;
183
+ attachment;
177
184
  constructor(opts, root) {
178
185
  this.opts = opts;
179
186
  this.root = root;
187
+ this.attachment = attachRef(this.opts.ref);
180
188
  $effect(() => {
181
189
  this.#tabIndex = this.root.rovingFocusGroup.getTabIndex(this.opts.ref.current);
182
190
  });
@@ -203,7 +211,7 @@ export class ToolbarLinkState {
203
211
  "data-orientation": getDataOrientation(this.root.opts.orientation.current),
204
212
  //
205
213
  onkeydown: this.onkeydown,
206
- ...attachRef(this.opts.ref),
214
+ ...this.attachment,
207
215
  }));
208
216
  }
209
217
  export class ToolbarButtonState {
@@ -212,9 +220,11 @@ export class ToolbarButtonState {
212
220
  }
213
221
  opts;
214
222
  root;
223
+ attachment;
215
224
  constructor(opts, root) {
216
225
  this.opts = opts;
217
226
  this.root = root;
227
+ this.attachment = attachRef(this.opts.ref);
218
228
  $effect(() => {
219
229
  this.#tabIndex = this.root.rovingFocusGroup.getTabIndex(this.opts.ref.current);
220
230
  });
@@ -243,7 +253,7 @@ export class ToolbarButtonState {
243
253
  disabled: getDisabled(this.opts.disabled.current),
244
254
  //
245
255
  onkeydown: this.onkeydown,
246
- ...attachRef(this.opts.ref),
256
+ ...this.attachment,
247
257
  }));
248
258
  }
249
259
  //
@@ -1,5 +1,5 @@
1
1
  import { DOMContext, type WritableBoxedValues, type ReadableBoxedValues } from "svelte-toolbelt";
2
- import type { OnChangeFn, WithRefOpts } from "../../internal/types.js";
2
+ import type { OnChangeFn, RefAttachment, WithRefOpts } from "../../internal/types.js";
3
3
  import type { FocusEventHandler, MouseEventHandler, PointerEventHandler } from "svelte/elements";
4
4
  export declare const tooltipAttrs: import("../../internal/attrs.js").CreateBitsAttrsReturn<readonly ["content", "trigger"]>;
5
5
  interface TooltipProviderStateOpts extends ReadableBoxedValues<{
@@ -61,6 +61,7 @@ export declare class TooltipTriggerState {
61
61
  static create(opts: TooltipTriggerStateOpts): TooltipTriggerState;
62
62
  readonly opts: TooltipTriggerStateOpts;
63
63
  readonly root: TooltipRootState;
64
+ readonly attachment: RefAttachment;
64
65
  domContext: DOMContext;
65
66
  constructor(opts: TooltipTriggerStateOpts, root: TooltipRootState);
66
67
  handlePointerUp: () => void;
@@ -90,6 +91,7 @@ export declare class TooltipContentState {
90
91
  static create(opts: TooltipContentStateOpts): TooltipContentState;
91
92
  readonly opts: TooltipContentStateOpts;
92
93
  readonly root: TooltipRootState;
94
+ readonly attachment: RefAttachment;
93
95
  constructor(opts: TooltipContentStateOpts, root: TooltipRootState);
94
96
  onInteractOutside: (e: PointerEvent) => void;
95
97
  onEscapeKeydown: (e: KeyboardEvent) => void;
@@ -153,6 +153,7 @@ export class TooltipTriggerState {
153
153
  }
154
154
  opts;
155
155
  root;
156
+ attachment;
156
157
  #isPointerDown = box(false);
157
158
  #hasPointerMoveOpened = $state(false);
158
159
  #isDisabled = $derived.by(() => this.opts.disabled.current || this.root.disabled);
@@ -161,6 +162,7 @@ export class TooltipTriggerState {
161
162
  this.opts = opts;
162
163
  this.root = root;
163
164
  this.domContext = new DOMContext(opts.ref);
165
+ this.attachment = attachRef(this.opts.ref, (v) => (this.root.triggerNode = v));
164
166
  }
165
167
  handlePointerUp = () => {
166
168
  this.#isPointerDown.current = false;
@@ -231,7 +233,7 @@ export class TooltipTriggerState {
231
233
  onfocus: this.#onfocus,
232
234
  onblur: this.#onblur,
233
235
  onclick: this.#onclick,
234
- ...attachRef(this.opts.ref, (v) => (this.root.triggerNode = v)),
236
+ ...this.attachment,
235
237
  }));
236
238
  }
237
239
  export class TooltipContentState {
@@ -240,9 +242,11 @@ export class TooltipContentState {
240
242
  }
241
243
  opts;
242
244
  root;
245
+ attachment;
243
246
  constructor(opts, root) {
244
247
  this.opts = opts;
245
248
  this.root = root;
249
+ this.attachment = attachRef(this.opts.ref, (v) => (this.root.contentNode = v));
246
250
  new GraceArea({
247
251
  triggerNode: () => this.root.triggerNode,
248
252
  contentNode: () => this.root.contentNode,
@@ -300,7 +304,7 @@ export class TooltipContentState {
300
304
  outline: "none",
301
305
  },
302
306
  [tooltipAttrs.content]: "",
303
- ...attachRef(this.opts.ref, (v) => (this.root.contentNode = v)),
307
+ ...this.attachment,
304
308
  }));
305
309
  popperProps = {
306
310
  onInteractOutside: this.onInteractOutside,
@@ -45,6 +45,15 @@ export declare class FloatingContentState {
45
45
  contentRef: import("svelte-toolbelt").WritableBox<HTMLElement | null>;
46
46
  wrapperRef: import("svelte-toolbelt").WritableBox<HTMLElement | null>;
47
47
  arrowRef: import("svelte-toolbelt").WritableBox<HTMLElement | null>;
48
+ readonly contentAttachment: {
49
+ [x: symbol]: (node: HTMLElement) => () => void;
50
+ };
51
+ readonly wrapperAttachment: {
52
+ [x: symbol]: (node: HTMLElement) => () => void;
53
+ };
54
+ readonly arrowAttachment: {
55
+ [x: symbol]: (node: HTMLElement) => () => void;
56
+ };
48
57
  arrowId: Box<string>;
49
58
  hasExplicitBoundaries: boolean;
50
59
  detectOverflowOptions: {
@@ -52,6 +52,9 @@ export class FloatingContentState {
52
52
  contentRef = box(null);
53
53
  wrapperRef = box(null);
54
54
  arrowRef = box(null);
55
+ contentAttachment = attachRef(this.contentRef);
56
+ wrapperAttachment = attachRef(this.wrapperRef);
57
+ arrowAttachment = attachRef(this.arrowRef);
55
58
  // ids
56
59
  arrowId = box(useId());
57
60
  #transformedStyle = $derived.by(() => {
@@ -146,7 +149,7 @@ export class FloatingContentState {
146
149
  },
147
150
  // Floating UI calculates logical alignment based the `dir` attribute
148
151
  dir: this.opts.dir.current,
149
- ...attachRef(this.wrapperRef),
152
+ ...this.wrapperAttachment,
150
153
  }));
151
154
  props = $derived.by(() => ({
152
155
  "data-side": this.placedSide,
@@ -154,7 +157,7 @@ export class FloatingContentState {
154
157
  style: styleToString({
155
158
  ...this.#transformedStyle,
156
159
  }),
157
- ...attachRef(this.contentRef),
160
+ ...this.contentAttachment,
158
161
  }));
159
162
  arrowStyle = $derived({
160
163
  position: "absolute",
@@ -229,7 +232,7 @@ export class FloatingArrowState {
229
232
  id: this.opts.id.current,
230
233
  style: this.content.arrowStyle,
231
234
  "data-side": this.content.placedSide,
232
- ...attachRef(this.content.arrowRef),
235
+ ...this.content.arrowAttachment,
233
236
  }));
234
237
  }
235
238
  export class FloatingAnchorState {
@@ -0,0 +1,12 @@
1
+ import { FocusScope } from "./focus-scope.svelte.js";
2
+ export declare class FocusScopeManager {
3
+ #private;
4
+ static instance: FocusScopeManager;
5
+ static getInstance(): FocusScopeManager;
6
+ register(scope: FocusScope): void;
7
+ unregister(scope: FocusScope): void;
8
+ getActive(): FocusScope | undefined;
9
+ setFocusMemory(scope: FocusScope, element: HTMLElement): void;
10
+ getFocusMemory(scope: FocusScope): HTMLElement | undefined;
11
+ isActiveScope(scope: FocusScope): boolean;
12
+ }