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.
- package/dist/bits/accordion/accordion.svelte.d.ts +6 -1
- package/dist/bits/accordion/accordion.svelte.js +15 -5
- package/dist/bits/alert-dialog/components/alert-dialog-content.svelte +6 -9
- package/dist/bits/aspect-ratio/aspect-ratio.svelte.d.ts +2 -1
- package/dist/bits/aspect-ratio/aspect-ratio.svelte.js +3 -1
- package/dist/bits/avatar/avatar.svelte.d.ts +4 -1
- package/dist/bits/avatar/avatar.svelte.js +9 -3
- package/dist/bits/calendar/calendar.svelte.d.ts +15 -1
- package/dist/bits/calendar/calendar.svelte.js +42 -14
- package/dist/bits/calendar/components/calendar-next-button.svelte +3 -1
- package/dist/bits/calendar/components/calendar-prev-button.svelte +3 -1
- package/dist/bits/checkbox/checkbox.svelte.d.ts +4 -1
- package/dist/bits/checkbox/checkbox.svelte.js +9 -3
- package/dist/bits/collapsible/collapsible.svelte.d.ts +4 -1
- package/dist/bits/collapsible/collapsible.svelte.js +9 -3
- package/dist/bits/command/command.svelte.d.ts +13 -1
- package/dist/bits/command/command.svelte.js +36 -12
- package/dist/bits/context-menu/components/context-menu-content.svelte +1 -1
- package/dist/bits/date-field/date-field.svelte.d.ts +8 -2
- package/dist/bits/date-field/date-field.svelte.js +18 -6
- package/dist/bits/date-range-field/date-range-field.svelte.d.ts +3 -1
- package/dist/bits/date-range-field/date-range-field.svelte.js +6 -2
- package/dist/bits/dialog/components/dialog-content.svelte +5 -7
- package/dist/bits/dialog/dialog.svelte.d.ts +9 -1
- package/dist/bits/dialog/dialog.svelte.js +33 -18
- package/dist/bits/dropdown-menu/components/dropdown-menu-content.svelte +3 -2
- package/dist/bits/label/label.svelte.d.ts +2 -1
- package/dist/bits/label/label.svelte.js +3 -1
- package/dist/bits/link-preview/link-preview.svelte.d.ts +3 -1
- package/dist/bits/link-preview/link-preview.svelte.js +6 -2
- package/dist/bits/menu/menu.svelte.d.ts +12 -1
- package/dist/bits/menu/menu.svelte.js +38 -26
- package/dist/bits/menubar/components/menubar-trigger.svelte +4 -3
- package/dist/bits/menubar/menubar.svelte.d.ts +4 -3
- package/dist/bits/menubar/menubar.svelte.js +9 -6
- package/dist/bits/meter/meter.svelte.d.ts +2 -1
- package/dist/bits/meter/meter.svelte.js +3 -1
- package/dist/bits/navigation-menu/components/navigation-menu-link.svelte +2 -1
- package/dist/bits/navigation-menu/components/navigation-menu-trigger.svelte +2 -1
- package/dist/bits/navigation-menu/navigation-menu.svelte.d.ts +14 -3
- package/dist/bits/navigation-menu/navigation-menu.svelte.js +33 -13
- package/dist/bits/pagination/pagination.svelte.d.ts +4 -1
- package/dist/bits/pagination/pagination.svelte.js +9 -3
- package/dist/bits/pin-input/pin-input.svelte.d.ts +4 -1
- package/dist/bits/pin-input/pin-input.svelte.js +8 -3
- package/dist/bits/popover/popover.svelte.d.ts +4 -1
- package/dist/bits/popover/popover.svelte.js +9 -3
- package/dist/bits/progress/progress.svelte.d.ts +2 -1
- package/dist/bits/progress/progress.svelte.js +3 -1
- package/dist/bits/radio-group/radio-group.svelte.d.ts +3 -1
- package/dist/bits/radio-group/radio-group.svelte.js +6 -2
- package/dist/bits/range-calendar/range-calendar.svelte.d.ts +4 -1
- package/dist/bits/range-calendar/range-calendar.svelte.js +9 -3
- package/dist/bits/rating-group/rating-group.svelte.d.ts +3 -1
- package/dist/bits/rating-group/rating-group.svelte.js +6 -2
- package/dist/bits/scroll-area/scroll-area.svelte.d.ts +8 -1
- package/dist/bits/scroll-area/scroll-area.svelte.js +20 -7
- package/dist/bits/select/select.svelte.d.ts +10 -1
- package/dist/bits/select/select.svelte.js +27 -9
- package/dist/bits/separator/separator.svelte.d.ts +2 -1
- package/dist/bits/separator/separator.svelte.js +3 -1
- package/dist/bits/slider/slider.svelte.d.ts +7 -1
- package/dist/bits/slider/slider.svelte.js +18 -6
- package/dist/bits/switch/switch.svelte.d.ts +3 -1
- package/dist/bits/switch/switch.svelte.js +6 -2
- package/dist/bits/tabs/tabs.svelte.d.ts +5 -1
- package/dist/bits/tabs/tabs.svelte.js +12 -4
- package/dist/bits/time-field/time-field.svelte.d.ts +7 -1
- package/dist/bits/time-field/time-field.svelte.js +18 -6
- package/dist/bits/time-range-field/time-range-field.svelte.d.ts +3 -1
- package/dist/bits/time-range-field/time-range-field.svelte.js +6 -2
- package/dist/bits/toggle/toggle.svelte.d.ts +2 -1
- package/dist/bits/toggle/toggle.svelte.js +3 -1
- package/dist/bits/toggle-group/toggle-group.svelte.d.ts +3 -1
- package/dist/bits/toggle-group/toggle-group.svelte.js +6 -2
- package/dist/bits/toolbar/toolbar.svelte.d.ts +6 -1
- package/dist/bits/toolbar/toolbar.svelte.js +15 -5
- package/dist/bits/tooltip/tooltip.svelte.d.ts +3 -1
- package/dist/bits/tooltip/tooltip.svelte.js +6 -2
- package/dist/bits/utilities/floating-layer/use-floating-layer.svelte.d.ts +9 -0
- package/dist/bits/utilities/floating-layer/use-floating-layer.svelte.js +6 -3
- package/dist/bits/utilities/focus-scope/focus-scope-manager.d.ts +12 -0
- package/dist/bits/utilities/focus-scope/focus-scope-manager.js +40 -0
- package/dist/bits/utilities/focus-scope/focus-scope.svelte +6 -8
- package/dist/bits/utilities/focus-scope/focus-scope.svelte.d.ts +1 -0
- package/dist/bits/utilities/focus-scope/focus-scope.svelte.js +204 -0
- package/dist/bits/utilities/focus-scope/types.d.ts +2 -6
- package/dist/bits/utilities/popper-layer/popper-layer-inner.svelte +2 -2
- package/dist/internal/focus.js +1 -1
- package/dist/internal/should-enable-focus-trap.d.ts +5 -0
- package/dist/internal/should-enable-focus-trap.js +5 -0
- package/dist/internal/types.d.ts +2 -1
- package/package.json +2 -2
- package/dist/bits/utilities/focus-scope/focus-scope-stack.svelte.d.ts +0 -14
- package/dist/bits/utilities/focus-scope/focus-scope-stack.svelte.js +0 -50
- package/dist/bits/utilities/focus-scope/use-focus-scope.svelte.d.ts +0 -49
- package/dist/bits/utilities/focus-scope/use-focus-scope.svelte.js +0 -218
- package/dist/internal/should-trap-focus.d.ts +0 -6
- package/dist/internal/should-trap-focus.js +0 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Previous } from "runed";
|
|
2
2
|
import { DOMContext, type ReadableBoxedValues, type WritableBoxedValues, type Box } from "svelte-toolbelt";
|
|
3
|
-
import type { BitsEvent, BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, OnChangeFn, WithRefOpts } from "../../internal/types.js";
|
|
3
|
+
import type { BitsEvent, BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, OnChangeFn, WithRefOpts, RefAttachment } from "../../internal/types.js";
|
|
4
4
|
export declare const INTERACTION_KEYS: string[];
|
|
5
5
|
export declare const FIRST_KEYS: string[];
|
|
6
6
|
export declare const LAST_KEYS: string[];
|
|
@@ -115,6 +115,7 @@ export declare class SelectInputState {
|
|
|
115
115
|
static create(opts: SelectInputStateOpts): SelectInputState;
|
|
116
116
|
readonly opts: SelectInputStateOpts;
|
|
117
117
|
readonly root: SelectRoot;
|
|
118
|
+
readonly attachment: RefAttachment;
|
|
118
119
|
constructor(opts: SelectInputStateOpts, root: SelectRoot);
|
|
119
120
|
onkeydown(e: BitsKeyboardEvent): void;
|
|
120
121
|
oninput(e: BitsEvent<Event, HTMLInputElement>): void;
|
|
@@ -137,6 +138,7 @@ export declare class SelectComboTriggerState {
|
|
|
137
138
|
static create(opts: SelectComboTriggerStateOpts): SelectComboTriggerState;
|
|
138
139
|
readonly opts: SelectComboTriggerStateOpts;
|
|
139
140
|
readonly root: SelectBaseRootState;
|
|
141
|
+
readonly attachment: RefAttachment;
|
|
140
142
|
constructor(opts: SelectComboTriggerStateOpts, root: SelectBaseRootState);
|
|
141
143
|
onkeydown(e: BitsKeyboardEvent): void;
|
|
142
144
|
/**
|
|
@@ -161,6 +163,7 @@ export declare class SelectTriggerState {
|
|
|
161
163
|
static create(opts: SelectTriggerStateOpts): SelectTriggerState;
|
|
162
164
|
readonly opts: SelectTriggerStateOpts;
|
|
163
165
|
readonly root: SelectRoot;
|
|
166
|
+
readonly attachment: RefAttachment;
|
|
164
167
|
constructor(opts: SelectTriggerStateOpts, root: SelectRoot);
|
|
165
168
|
onkeydown(e: BitsKeyboardEvent): void;
|
|
166
169
|
onclick(e: BitsMouseEvent): void;
|
|
@@ -191,6 +194,7 @@ export declare class SelectContentState {
|
|
|
191
194
|
static create(opts: SelectContentStateOpts): SelectContentState;
|
|
192
195
|
readonly opts: SelectContentStateOpts;
|
|
193
196
|
readonly root: SelectRoot;
|
|
197
|
+
readonly attachment: RefAttachment;
|
|
194
198
|
viewportNode: HTMLElement | null;
|
|
195
199
|
isPositioned: boolean;
|
|
196
200
|
domContext: DOMContext;
|
|
@@ -239,6 +243,7 @@ export declare class SelectItemState {
|
|
|
239
243
|
static create(opts: SelectItemStateOpts): SelectItemState;
|
|
240
244
|
readonly opts: SelectItemStateOpts;
|
|
241
245
|
readonly root: SelectRoot;
|
|
246
|
+
readonly attachment: RefAttachment;
|
|
242
247
|
readonly isSelected: boolean;
|
|
243
248
|
readonly isHighlighted: boolean;
|
|
244
249
|
readonly prevHighlighted: Previous<boolean>;
|
|
@@ -278,6 +283,7 @@ export declare class SelectGroupState {
|
|
|
278
283
|
readonly opts: SelectGroupStateOpts;
|
|
279
284
|
readonly root: SelectBaseRootState;
|
|
280
285
|
labelNode: HTMLElement | null;
|
|
286
|
+
readonly attachment: RefAttachment;
|
|
281
287
|
constructor(opts: SelectGroupStateOpts, root: SelectBaseRootState);
|
|
282
288
|
readonly props: {
|
|
283
289
|
readonly id: string;
|
|
@@ -291,6 +297,7 @@ export declare class SelectGroupHeadingState {
|
|
|
291
297
|
static create(opts: SelectGroupHeadingStateOpts): SelectGroupHeadingState;
|
|
292
298
|
readonly opts: SelectGroupHeadingStateOpts;
|
|
293
299
|
readonly group: SelectGroupState;
|
|
300
|
+
readonly attachment: RefAttachment;
|
|
294
301
|
constructor(opts: SelectGroupHeadingStateOpts, group: SelectGroupState);
|
|
295
302
|
readonly props: {
|
|
296
303
|
readonly id: string;
|
|
@@ -322,6 +329,7 @@ export declare class SelectViewportState {
|
|
|
322
329
|
readonly opts: SelectViewportStateOpts;
|
|
323
330
|
readonly content: SelectContentState;
|
|
324
331
|
readonly root: SelectBaseRootState;
|
|
332
|
+
readonly attachment: RefAttachment;
|
|
325
333
|
prevScrollTop: number;
|
|
326
334
|
constructor(opts: SelectViewportStateOpts, content: SelectContentState);
|
|
327
335
|
readonly props: {
|
|
@@ -342,6 +350,7 @@ export declare class SelectScrollButtonImplState {
|
|
|
342
350
|
readonly opts: SelectScrollButtonImplStateOpts;
|
|
343
351
|
readonly content: SelectContentState;
|
|
344
352
|
readonly root: SelectBaseRootState;
|
|
353
|
+
readonly attachment: RefAttachment;
|
|
345
354
|
autoScrollTimer: number | null;
|
|
346
355
|
userScrollTimer: number;
|
|
347
356
|
isUserScrolling: boolean;
|
|
@@ -256,9 +256,11 @@ export class SelectInputState {
|
|
|
256
256
|
}
|
|
257
257
|
opts;
|
|
258
258
|
root;
|
|
259
|
+
attachment;
|
|
259
260
|
constructor(opts, root) {
|
|
260
261
|
this.opts = opts;
|
|
261
262
|
this.root = root;
|
|
263
|
+
this.attachment = attachRef(opts.ref, (v) => (this.root.inputNode = v));
|
|
262
264
|
this.root.domContext = new DOMContext(opts.ref);
|
|
263
265
|
this.onkeydown = this.onkeydown.bind(this);
|
|
264
266
|
this.oninput = this.oninput.bind(this);
|
|
@@ -384,7 +386,7 @@ export class SelectInputState {
|
|
|
384
386
|
onkeydown: this.onkeydown,
|
|
385
387
|
oninput: this.oninput,
|
|
386
388
|
[this.root.getBitsAttr("input")]: "",
|
|
387
|
-
...
|
|
389
|
+
...this.attachment,
|
|
388
390
|
}));
|
|
389
391
|
}
|
|
390
392
|
export class SelectComboTriggerState {
|
|
@@ -393,9 +395,11 @@ export class SelectComboTriggerState {
|
|
|
393
395
|
}
|
|
394
396
|
opts;
|
|
395
397
|
root;
|
|
398
|
+
attachment;
|
|
396
399
|
constructor(opts, root) {
|
|
397
400
|
this.opts = opts;
|
|
398
401
|
this.root = root;
|
|
402
|
+
this.attachment = attachRef(opts.ref);
|
|
399
403
|
this.onkeydown = this.onkeydown.bind(this);
|
|
400
404
|
this.onpointerdown = this.onpointerdown.bind(this);
|
|
401
405
|
}
|
|
@@ -432,7 +436,7 @@ export class SelectComboTriggerState {
|
|
|
432
436
|
[this.root.getBitsAttr("trigger")]: "",
|
|
433
437
|
onpointerdown: this.onpointerdown,
|
|
434
438
|
onkeydown: this.onkeydown,
|
|
435
|
-
...
|
|
439
|
+
...this.attachment,
|
|
436
440
|
}));
|
|
437
441
|
}
|
|
438
442
|
export class SelectTriggerState {
|
|
@@ -441,11 +445,13 @@ export class SelectTriggerState {
|
|
|
441
445
|
}
|
|
442
446
|
opts;
|
|
443
447
|
root;
|
|
448
|
+
attachment;
|
|
444
449
|
#domTypeahead;
|
|
445
450
|
#dataTypeahead;
|
|
446
451
|
constructor(opts, root) {
|
|
447
452
|
this.opts = opts;
|
|
448
453
|
this.root = root;
|
|
454
|
+
this.attachment = attachRef(opts.ref, (v) => (this.root.triggerNode = v));
|
|
449
455
|
this.root.domContext = new DOMContext(opts.ref);
|
|
450
456
|
this.#domTypeahead = new DOMTypeahead({
|
|
451
457
|
getCurrentItem: () => this.root.highlightedNode,
|
|
@@ -670,7 +676,7 @@ export class SelectTriggerState {
|
|
|
670
676
|
onkeydown: this.onkeydown,
|
|
671
677
|
onclick: this.onclick,
|
|
672
678
|
onpointerup: this.onpointerup,
|
|
673
|
-
...
|
|
679
|
+
...this.attachment,
|
|
674
680
|
}));
|
|
675
681
|
}
|
|
676
682
|
export class SelectContentState {
|
|
@@ -679,12 +685,14 @@ export class SelectContentState {
|
|
|
679
685
|
}
|
|
680
686
|
opts;
|
|
681
687
|
root;
|
|
688
|
+
attachment;
|
|
682
689
|
viewportNode = $state(null);
|
|
683
690
|
isPositioned = $state(false);
|
|
684
691
|
domContext;
|
|
685
692
|
constructor(opts, root) {
|
|
686
693
|
this.opts = opts;
|
|
687
694
|
this.root = root;
|
|
695
|
+
this.attachment = attachRef(opts.ref, (v) => (this.root.contentNode = v));
|
|
688
696
|
this.domContext = new DOMContext(this.opts.ref);
|
|
689
697
|
if (this.root.domContext === null) {
|
|
690
698
|
this.root.domContext = this.domContext;
|
|
@@ -744,7 +752,7 @@ export class SelectContentState {
|
|
|
744
752
|
...this.#styles,
|
|
745
753
|
},
|
|
746
754
|
onpointermove: this.onpointermove,
|
|
747
|
-
...
|
|
755
|
+
...this.attachment,
|
|
748
756
|
}));
|
|
749
757
|
popperProps = {
|
|
750
758
|
onInteractOutside: this.onInteractOutside,
|
|
@@ -768,6 +776,7 @@ export class SelectItemState {
|
|
|
768
776
|
}
|
|
769
777
|
opts;
|
|
770
778
|
root;
|
|
779
|
+
attachment;
|
|
771
780
|
isSelected = $derived.by(() => this.root.includesItem(this.opts.value.current));
|
|
772
781
|
isHighlighted = $derived.by(() => this.root.highlightedValue === this.opts.value.current);
|
|
773
782
|
prevHighlighted = new Previous(() => this.isHighlighted);
|
|
@@ -775,6 +784,7 @@ export class SelectItemState {
|
|
|
775
784
|
constructor(opts, root) {
|
|
776
785
|
this.opts = opts;
|
|
777
786
|
this.root = root;
|
|
787
|
+
this.attachment = attachRef(opts.ref);
|
|
778
788
|
watch([() => this.isHighlighted, () => this.prevHighlighted.current], () => {
|
|
779
789
|
if (this.isHighlighted) {
|
|
780
790
|
this.opts.onHighlight.current();
|
|
@@ -878,7 +888,7 @@ export class SelectItemState {
|
|
|
878
888
|
onpointermove: this.onpointermove,
|
|
879
889
|
onpointerdown: this.onpointerdown,
|
|
880
890
|
onpointerup: this.onpointerup,
|
|
881
|
-
...
|
|
891
|
+
...this.attachment,
|
|
882
892
|
}));
|
|
883
893
|
}
|
|
884
894
|
export class SelectGroupState {
|
|
@@ -888,16 +898,18 @@ export class SelectGroupState {
|
|
|
888
898
|
opts;
|
|
889
899
|
root;
|
|
890
900
|
labelNode = $state(null);
|
|
901
|
+
attachment;
|
|
891
902
|
constructor(opts, root) {
|
|
892
903
|
this.opts = opts;
|
|
893
904
|
this.root = root;
|
|
905
|
+
this.attachment = attachRef(opts.ref);
|
|
894
906
|
}
|
|
895
907
|
props = $derived.by(() => ({
|
|
896
908
|
id: this.opts.id.current,
|
|
897
909
|
role: "group",
|
|
898
910
|
[this.root.getBitsAttr("group")]: "",
|
|
899
911
|
"aria-labelledby": this.labelNode?.id ?? undefined,
|
|
900
|
-
...
|
|
912
|
+
...this.attachment,
|
|
901
913
|
}));
|
|
902
914
|
}
|
|
903
915
|
export class SelectGroupHeadingState {
|
|
@@ -906,14 +918,16 @@ export class SelectGroupHeadingState {
|
|
|
906
918
|
}
|
|
907
919
|
opts;
|
|
908
920
|
group;
|
|
921
|
+
attachment;
|
|
909
922
|
constructor(opts, group) {
|
|
910
923
|
this.opts = opts;
|
|
911
924
|
this.group = group;
|
|
925
|
+
this.attachment = attachRef(opts.ref, (v) => (this.group.labelNode = v));
|
|
912
926
|
}
|
|
913
927
|
props = $derived.by(() => ({
|
|
914
928
|
id: this.opts.id.current,
|
|
915
929
|
[this.group.root.getBitsAttr("group-label")]: "",
|
|
916
|
-
...
|
|
930
|
+
...this.attachment,
|
|
917
931
|
}));
|
|
918
932
|
}
|
|
919
933
|
export class SelectHiddenInputState {
|
|
@@ -952,11 +966,13 @@ export class SelectViewportState {
|
|
|
952
966
|
opts;
|
|
953
967
|
content;
|
|
954
968
|
root;
|
|
969
|
+
attachment;
|
|
955
970
|
prevScrollTop = $state(0);
|
|
956
971
|
constructor(opts, content) {
|
|
957
972
|
this.opts = opts;
|
|
958
973
|
this.content = content;
|
|
959
974
|
this.root = content.root;
|
|
975
|
+
this.attachment = attachRef(opts.ref, (v) => (this.content.viewportNode = v));
|
|
960
976
|
}
|
|
961
977
|
props = $derived.by(() => ({
|
|
962
978
|
id: this.opts.id.current,
|
|
@@ -970,13 +986,14 @@ export class SelectViewportState {
|
|
|
970
986
|
flex: 1,
|
|
971
987
|
overflow: "auto",
|
|
972
988
|
},
|
|
973
|
-
...
|
|
989
|
+
...this.attachment,
|
|
974
990
|
}));
|
|
975
991
|
}
|
|
976
992
|
export class SelectScrollButtonImplState {
|
|
977
993
|
opts;
|
|
978
994
|
content;
|
|
979
995
|
root;
|
|
996
|
+
attachment;
|
|
980
997
|
autoScrollTimer = null;
|
|
981
998
|
userScrollTimer = -1;
|
|
982
999
|
isUserScrolling = false;
|
|
@@ -986,6 +1003,7 @@ export class SelectScrollButtonImplState {
|
|
|
986
1003
|
this.opts = opts;
|
|
987
1004
|
this.content = content;
|
|
988
1005
|
this.root = content.root;
|
|
1006
|
+
this.attachment = attachRef(opts.ref);
|
|
989
1007
|
watch([() => this.mounted], () => {
|
|
990
1008
|
if (!this.mounted) {
|
|
991
1009
|
this.isUserScrolling = false;
|
|
@@ -1040,7 +1058,7 @@ export class SelectScrollButtonImplState {
|
|
|
1040
1058
|
onpointerdown: this.onpointerdown,
|
|
1041
1059
|
onpointermove: this.onpointermove,
|
|
1042
1060
|
onpointerleave: this.onpointerleave,
|
|
1043
|
-
...
|
|
1061
|
+
...this.attachment,
|
|
1044
1062
|
}));
|
|
1045
1063
|
}
|
|
1046
1064
|
export class SelectScrollDownButtonState {
|
|
@@ -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
|
import type { Orientation } from "../../shared/index.js";
|
|
4
4
|
interface SeparatorRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
|
5
5
|
orientation: Orientation;
|
|
@@ -9,6 +9,7 @@ interface SeparatorRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
|
|
9
9
|
export declare class SeparatorRootState {
|
|
10
10
|
static create(opts: SeparatorRootStateOpts): SeparatorRootState;
|
|
11
11
|
readonly opts: SeparatorRootStateOpts;
|
|
12
|
+
readonly attachment: RefAttachment;
|
|
12
13
|
constructor(opts: SeparatorRootStateOpts);
|
|
13
14
|
readonly props: {
|
|
14
15
|
readonly id: string;
|
|
@@ -9,8 +9,10 @@ export class SeparatorRootState {
|
|
|
9
9
|
return new SeparatorRootState(opts);
|
|
10
10
|
}
|
|
11
11
|
opts;
|
|
12
|
+
attachment;
|
|
12
13
|
constructor(opts) {
|
|
13
14
|
this.opts = opts;
|
|
15
|
+
this.attachment = attachRef(opts.ref);
|
|
14
16
|
}
|
|
15
17
|
props = $derived.by(() => ({
|
|
16
18
|
id: this.opts.id.current,
|
|
@@ -19,6 +21,6 @@ export class SeparatorRootState {
|
|
|
19
21
|
"aria-hidden": getAriaHidden(this.opts.decorative.current),
|
|
20
22
|
"data-orientation": getDataOrientation(this.opts.orientation.current),
|
|
21
23
|
[separatorAttrs.root]: "",
|
|
22
|
-
...
|
|
24
|
+
...this.attachment,
|
|
23
25
|
}));
|
|
24
26
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Box, type ReadableBox, DOMContext, type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
|
|
2
2
|
import { Context } from "runed";
|
|
3
|
-
import type { BitsKeyboardEvent, OnChangeFn, WithRefOpts } from "../../internal/types.js";
|
|
3
|
+
import type { BitsKeyboardEvent, OnChangeFn, RefAttachment, WithRefOpts } from "../../internal/types.js";
|
|
4
4
|
import type { Direction, Orientation, SliderThumbPositioning } from "../../shared/index.js";
|
|
5
5
|
import type { SliderLabelPosition } from "./types.js";
|
|
6
6
|
declare const sliderAttrs: import("../../internal/attrs.js").CreateBitsAttrsReturn<readonly ["root", "thumb", "range", "tick", "tick-label", "thumb-label"]>;
|
|
@@ -20,6 +20,7 @@ interface SliderBaseRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
|
|
20
20
|
declare abstract class SliderBaseRootState {
|
|
21
21
|
#private;
|
|
22
22
|
readonly opts: SliderBaseRootStateOpts;
|
|
23
|
+
readonly attachment: RefAttachment;
|
|
23
24
|
isActive: boolean;
|
|
24
25
|
readonly direction: "rl" | "lr" | "tb" | "bt";
|
|
25
26
|
readonly normalizedSteps: number[];
|
|
@@ -189,6 +190,7 @@ export declare class SliderRangeState {
|
|
|
189
190
|
static create(opts: SliderRangeStateOpts): SliderRangeState;
|
|
190
191
|
readonly opts: SliderRangeStateOpts;
|
|
191
192
|
readonly root: SliderRoot;
|
|
193
|
+
readonly attachment: RefAttachment;
|
|
192
194
|
constructor(opts: SliderRangeStateOpts, root: SliderRoot);
|
|
193
195
|
readonly rangeStyles: {
|
|
194
196
|
accentColor?: import("csstype").Property.AccentColor | undefined;
|
|
@@ -1860,6 +1862,7 @@ export declare class SliderThumbState {
|
|
|
1860
1862
|
static create(opts: SliderThumbStateOpts): SliderThumbState;
|
|
1861
1863
|
readonly opts: SliderThumbStateOpts;
|
|
1862
1864
|
readonly root: SliderRoot;
|
|
1865
|
+
readonly attachment: RefAttachment;
|
|
1863
1866
|
constructor(opts: SliderThumbStateOpts, root: SliderRoot);
|
|
1864
1867
|
onkeydown(e: BitsKeyboardEvent): void;
|
|
1865
1868
|
readonly props: {
|
|
@@ -1902,6 +1905,7 @@ export declare class SliderTickState {
|
|
|
1902
1905
|
static create(opts: SliderTickStateOpts): SliderTickState;
|
|
1903
1906
|
readonly opts: SliderTickStateOpts;
|
|
1904
1907
|
readonly root: SliderRoot;
|
|
1908
|
+
readonly attachment: RefAttachment;
|
|
1905
1909
|
constructor(opts: SliderTickStateOpts, root: SliderRoot);
|
|
1906
1910
|
readonly props: {
|
|
1907
1911
|
readonly id: string;
|
|
@@ -1929,6 +1933,7 @@ export declare class SliderTickLabelState {
|
|
|
1929
1933
|
static create(opts: SliderTickLabelStateOpts): SliderTickLabelState;
|
|
1930
1934
|
readonly opts: SliderTickLabelStateOpts;
|
|
1931
1935
|
readonly root: SliderRoot;
|
|
1936
|
+
readonly attachment: RefAttachment;
|
|
1932
1937
|
constructor(opts: SliderTickLabelStateOpts, root: SliderRoot);
|
|
1933
1938
|
readonly props: {
|
|
1934
1939
|
readonly id: string;
|
|
@@ -1950,6 +1955,7 @@ export declare class SliderThumbLabelState {
|
|
|
1950
1955
|
static create(opts: SliderThumbLabelStateOpts): SliderThumbLabelState;
|
|
1951
1956
|
readonly opts: SliderThumbLabelStateOpts;
|
|
1952
1957
|
readonly root: SliderRoot;
|
|
1958
|
+
readonly attachment: RefAttachment;
|
|
1953
1959
|
constructor(opts: SliderThumbLabelStateOpts, root: SliderRoot);
|
|
1954
1960
|
readonly props: {
|
|
1955
1961
|
readonly id: string;
|
|
@@ -19,6 +19,7 @@ const sliderAttrs = createBitsAttrs({
|
|
|
19
19
|
export const SliderRootContext = new Context("Slider.Root");
|
|
20
20
|
class SliderBaseRootState {
|
|
21
21
|
opts;
|
|
22
|
+
attachment;
|
|
22
23
|
isActive = $state(false);
|
|
23
24
|
direction = $derived.by(() => {
|
|
24
25
|
if (this.opts.orientation.current === "horizontal") {
|
|
@@ -35,6 +36,7 @@ class SliderBaseRootState {
|
|
|
35
36
|
domContext;
|
|
36
37
|
constructor(opts) {
|
|
37
38
|
this.opts = opts;
|
|
39
|
+
this.attachment = attachRef(opts.ref);
|
|
38
40
|
this.domContext = new DOMContext(this.opts.ref);
|
|
39
41
|
}
|
|
40
42
|
isThumbActive(_index) {
|
|
@@ -94,7 +96,7 @@ class SliderBaseRootState {
|
|
|
94
96
|
touchAction: this.#touchAction,
|
|
95
97
|
},
|
|
96
98
|
[sliderAttrs.root]: "",
|
|
97
|
-
...
|
|
99
|
+
...this.attachment,
|
|
98
100
|
}));
|
|
99
101
|
}
|
|
100
102
|
class SliderSingleRootState extends SliderBaseRootState {
|
|
@@ -564,9 +566,11 @@ export class SliderRangeState {
|
|
|
564
566
|
}
|
|
565
567
|
opts;
|
|
566
568
|
root;
|
|
569
|
+
attachment;
|
|
567
570
|
constructor(opts, root) {
|
|
568
571
|
this.opts = opts;
|
|
569
572
|
this.root = root;
|
|
573
|
+
this.attachment = attachRef(opts.ref);
|
|
570
574
|
}
|
|
571
575
|
rangeStyles = $derived.by(() => {
|
|
572
576
|
if (Array.isArray(this.root.opts.value.current)) {
|
|
@@ -605,7 +609,7 @@ export class SliderRangeState {
|
|
|
605
609
|
"data-disabled": getDataDisabled(this.root.opts.disabled.current),
|
|
606
610
|
style: this.rangeStyles,
|
|
607
611
|
[sliderAttrs.range]: "",
|
|
608
|
-
...
|
|
612
|
+
...this.attachment,
|
|
609
613
|
}));
|
|
610
614
|
}
|
|
611
615
|
export class SliderThumbState {
|
|
@@ -614,10 +618,12 @@ export class SliderThumbState {
|
|
|
614
618
|
}
|
|
615
619
|
opts;
|
|
616
620
|
root;
|
|
621
|
+
attachment;
|
|
617
622
|
#isDisabled = $derived.by(() => this.root.opts.disabled.current || this.opts.disabled.current);
|
|
618
623
|
constructor(opts, root) {
|
|
619
624
|
this.opts = opts;
|
|
620
625
|
this.root = root;
|
|
626
|
+
this.attachment = attachRef(opts.ref);
|
|
621
627
|
this.onkeydown = this.onkeydown.bind(this);
|
|
622
628
|
}
|
|
623
629
|
#updateValue(newValue) {
|
|
@@ -717,7 +723,7 @@ export class SliderThumbState {
|
|
|
717
723
|
"data-active": this.root.isThumbActive(this.opts.index.current) ? "" : undefined,
|
|
718
724
|
"data-disabled": getDataDisabled(this.opts.disabled.current || this.root.opts.disabled.current),
|
|
719
725
|
tabindex: this.opts.disabled.current || this.root.opts.disabled.current ? -1 : 0,
|
|
720
|
-
...
|
|
726
|
+
...this.attachment,
|
|
721
727
|
}));
|
|
722
728
|
}
|
|
723
729
|
export class SliderTickState {
|
|
@@ -726,14 +732,16 @@ export class SliderTickState {
|
|
|
726
732
|
}
|
|
727
733
|
opts;
|
|
728
734
|
root;
|
|
735
|
+
attachment;
|
|
729
736
|
constructor(opts, root) {
|
|
730
737
|
this.opts = opts;
|
|
731
738
|
this.root = root;
|
|
739
|
+
this.attachment = attachRef(opts.ref);
|
|
732
740
|
}
|
|
733
741
|
props = $derived.by(() => ({
|
|
734
742
|
...this.root.ticksPropsArr[this.opts.index.current],
|
|
735
743
|
id: this.opts.id.current,
|
|
736
|
-
...
|
|
744
|
+
...this.attachment,
|
|
737
745
|
}));
|
|
738
746
|
}
|
|
739
747
|
export class SliderTickLabelState {
|
|
@@ -742,9 +750,11 @@ export class SliderTickLabelState {
|
|
|
742
750
|
}
|
|
743
751
|
opts;
|
|
744
752
|
root;
|
|
753
|
+
attachment;
|
|
745
754
|
constructor(opts, root) {
|
|
746
755
|
this.opts = opts;
|
|
747
756
|
this.root = root;
|
|
757
|
+
this.attachment = attachRef(opts.ref);
|
|
748
758
|
}
|
|
749
759
|
props = $derived.by(() => {
|
|
750
760
|
const tickProps = this.root.ticksPropsArr[this.opts.index.current];
|
|
@@ -763,7 +773,7 @@ export class SliderTickLabelState {
|
|
|
763
773
|
"data-position": labelPosition,
|
|
764
774
|
style,
|
|
765
775
|
[sliderAttrs["tick-label"]]: "",
|
|
766
|
-
...
|
|
776
|
+
...this.attachment,
|
|
767
777
|
};
|
|
768
778
|
});
|
|
769
779
|
}
|
|
@@ -773,9 +783,11 @@ export class SliderThumbLabelState {
|
|
|
773
783
|
}
|
|
774
784
|
opts;
|
|
775
785
|
root;
|
|
786
|
+
attachment;
|
|
776
787
|
constructor(opts, root) {
|
|
777
788
|
this.opts = opts;
|
|
778
789
|
this.root = root;
|
|
790
|
+
this.attachment = attachRef(opts.ref);
|
|
779
791
|
}
|
|
780
792
|
props = $derived.by(() => {
|
|
781
793
|
const value = this.root.opts.value.current;
|
|
@@ -792,7 +804,7 @@ export class SliderThumbLabelState {
|
|
|
792
804
|
"data-position": labelPosition,
|
|
793
805
|
style,
|
|
794
806
|
[sliderAttrs["thumb-label"]]: "",
|
|
795
|
-
...
|
|
807
|
+
...this.attachment,
|
|
796
808
|
};
|
|
797
809
|
});
|
|
798
810
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
|
|
2
|
-
import type { BitsKeyboardEvent, BitsPointerEvent, WithRefOpts } from "../../internal/types.js";
|
|
2
|
+
import type { BitsKeyboardEvent, BitsPointerEvent, RefAttachment, WithRefOpts } from "../../internal/types.js";
|
|
3
3
|
interface SwitchRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
|
4
4
|
disabled: boolean;
|
|
5
5
|
required: boolean;
|
|
@@ -13,6 +13,7 @@ export declare class SwitchRootState {
|
|
|
13
13
|
#private;
|
|
14
14
|
static create(opts: SwitchRootStateOpts): SwitchRootState;
|
|
15
15
|
readonly opts: SwitchRootStateOpts;
|
|
16
|
+
readonly attachment: RefAttachment;
|
|
16
17
|
constructor(opts: SwitchRootStateOpts);
|
|
17
18
|
onkeydown(e: BitsKeyboardEvent): void;
|
|
18
19
|
onclick(_: BitsPointerEvent): void;
|
|
@@ -57,6 +58,7 @@ export declare class SwitchThumbState {
|
|
|
57
58
|
static create(opts: SwitchThumbStateOpts): SwitchThumbState;
|
|
58
59
|
readonly opts: SwitchThumbStateOpts;
|
|
59
60
|
readonly root: SwitchRootState;
|
|
61
|
+
readonly attachment: RefAttachment;
|
|
60
62
|
constructor(opts: SwitchThumbStateOpts, root: SwitchRootState);
|
|
61
63
|
readonly snippetProps: {
|
|
62
64
|
checked: boolean;
|
|
@@ -12,8 +12,10 @@ export class SwitchRootState {
|
|
|
12
12
|
return SwitchRootContext.set(new SwitchRootState(opts));
|
|
13
13
|
}
|
|
14
14
|
opts;
|
|
15
|
+
attachment;
|
|
15
16
|
constructor(opts) {
|
|
16
17
|
this.opts = opts;
|
|
18
|
+
this.attachment = attachRef(opts.ref);
|
|
17
19
|
this.onkeydown = this.onkeydown.bind(this);
|
|
18
20
|
this.onclick = this.onclick.bind(this);
|
|
19
21
|
}
|
|
@@ -50,7 +52,7 @@ export class SwitchRootState {
|
|
|
50
52
|
//
|
|
51
53
|
onclick: this.onclick,
|
|
52
54
|
onkeydown: this.onkeydown,
|
|
53
|
-
...
|
|
55
|
+
...this.attachment,
|
|
54
56
|
}));
|
|
55
57
|
}
|
|
56
58
|
export class SwitchInputState {
|
|
@@ -77,9 +79,11 @@ export class SwitchThumbState {
|
|
|
77
79
|
}
|
|
78
80
|
opts;
|
|
79
81
|
root;
|
|
82
|
+
attachment;
|
|
80
83
|
constructor(opts, root) {
|
|
81
84
|
this.opts = opts;
|
|
82
85
|
this.root = root;
|
|
86
|
+
this.attachment = attachRef(opts.ref);
|
|
83
87
|
}
|
|
84
88
|
snippetProps = $derived.by(() => ({
|
|
85
89
|
checked: this.root.opts.checked.current,
|
|
@@ -88,6 +92,6 @@ export class SwitchThumbState {
|
|
|
88
92
|
...this.root.sharedProps,
|
|
89
93
|
id: this.opts.id.current,
|
|
90
94
|
[switchAttrs.thumb]: "",
|
|
91
|
-
...
|
|
95
|
+
...this.attachment,
|
|
92
96
|
}));
|
|
93
97
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SvelteMap } from "svelte/reactivity";
|
|
2
2
|
import { type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
|
|
3
3
|
import type { TabsActivationMode } from "./types.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 { Orientation } from "../../shared/index.js";
|
|
6
6
|
import { RovingFocusGroup } from "../../internal/roving-focus-group.js";
|
|
7
7
|
interface TabsRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
|
@@ -16,6 +16,7 @@ interface TabsRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
|
|
16
16
|
export declare class TabsRootState {
|
|
17
17
|
static create(opts: TabsRootStateOpts): TabsRootState;
|
|
18
18
|
readonly opts: TabsRootStateOpts;
|
|
19
|
+
readonly attachment: RefAttachment;
|
|
19
20
|
readonly rovingFocusGroup: RovingFocusGroup;
|
|
20
21
|
triggerIds: string[];
|
|
21
22
|
readonly valueToTriggerId: SvelteMap<string, string>;
|
|
@@ -36,6 +37,7 @@ export declare class TabsListState {
|
|
|
36
37
|
static create(opts: TabsListStateOpts): TabsListState;
|
|
37
38
|
readonly opts: TabsListStateOpts;
|
|
38
39
|
readonly root: TabsRootState;
|
|
40
|
+
readonly attachment: RefAttachment;
|
|
39
41
|
constructor(opts: TabsListStateOpts, root: TabsRootState);
|
|
40
42
|
readonly props: {
|
|
41
43
|
readonly id: string;
|
|
@@ -55,6 +57,7 @@ export declare class TabsTriggerState {
|
|
|
55
57
|
static create(opts: TabsTriggerStateOpts): TabsTriggerState;
|
|
56
58
|
readonly opts: TabsTriggerStateOpts;
|
|
57
59
|
readonly root: TabsRootState;
|
|
60
|
+
readonly attachment: RefAttachment;
|
|
58
61
|
constructor(opts: TabsTriggerStateOpts, root: TabsRootState);
|
|
59
62
|
onfocus(_: BitsFocusEvent): void;
|
|
60
63
|
onclick(_: BitsMouseEvent): void;
|
|
@@ -84,6 +87,7 @@ export declare class TabsContentState {
|
|
|
84
87
|
static create(opts: TabsContentStateOpts): TabsContentState;
|
|
85
88
|
readonly opts: TabsContentStateOpts;
|
|
86
89
|
readonly root: TabsRootState;
|
|
90
|
+
readonly attachment: RefAttachment;
|
|
87
91
|
constructor(opts: TabsContentStateOpts, root: TabsRootState);
|
|
88
92
|
readonly props: {
|
|
89
93
|
readonly id: string;
|
|
@@ -14,6 +14,7 @@ export class TabsRootState {
|
|
|
14
14
|
return TabsRootContext.set(new TabsRootState(opts));
|
|
15
15
|
}
|
|
16
16
|
opts;
|
|
17
|
+
attachment;
|
|
17
18
|
rovingFocusGroup;
|
|
18
19
|
triggerIds = $state([]);
|
|
19
20
|
// holds the trigger ID for each value to associate it with the content
|
|
@@ -22,6 +23,7 @@ export class TabsRootState {
|
|
|
22
23
|
valueToContentId = new SvelteMap();
|
|
23
24
|
constructor(opts) {
|
|
24
25
|
this.opts = opts;
|
|
26
|
+
this.attachment = attachRef(opts.ref);
|
|
25
27
|
this.rovingFocusGroup = new RovingFocusGroup({
|
|
26
28
|
candidateAttr: tabsAttrs.trigger,
|
|
27
29
|
rootNode: this.opts.ref,
|
|
@@ -52,7 +54,7 @@ export class TabsRootState {
|
|
|
52
54
|
id: this.opts.id.current,
|
|
53
55
|
"data-orientation": getDataOrientation(this.opts.orientation.current),
|
|
54
56
|
[tabsAttrs.root]: "",
|
|
55
|
-
...
|
|
57
|
+
...this.attachment,
|
|
56
58
|
}));
|
|
57
59
|
}
|
|
58
60
|
export class TabsListState {
|
|
@@ -61,10 +63,12 @@ export class TabsListState {
|
|
|
61
63
|
}
|
|
62
64
|
opts;
|
|
63
65
|
root;
|
|
66
|
+
attachment;
|
|
64
67
|
#isDisabled = $derived.by(() => this.root.opts.disabled.current);
|
|
65
68
|
constructor(opts, root) {
|
|
66
69
|
this.opts = opts;
|
|
67
70
|
this.root = root;
|
|
71
|
+
this.attachment = attachRef(opts.ref);
|
|
68
72
|
}
|
|
69
73
|
props = $derived.by(() => ({
|
|
70
74
|
id: this.opts.id.current,
|
|
@@ -73,7 +77,7 @@ export class TabsListState {
|
|
|
73
77
|
"data-orientation": getDataOrientation(this.root.opts.orientation.current),
|
|
74
78
|
[tabsAttrs.list]: "",
|
|
75
79
|
"data-disabled": getDataDisabled(this.#isDisabled),
|
|
76
|
-
...
|
|
80
|
+
...this.attachment,
|
|
77
81
|
}));
|
|
78
82
|
}
|
|
79
83
|
export class TabsTriggerState {
|
|
@@ -82,6 +86,7 @@ export class TabsTriggerState {
|
|
|
82
86
|
}
|
|
83
87
|
opts;
|
|
84
88
|
root;
|
|
89
|
+
attachment;
|
|
85
90
|
#tabIndex = $state(0);
|
|
86
91
|
#isActive = $derived.by(() => this.root.opts.value.current === this.opts.value.current);
|
|
87
92
|
#isDisabled = $derived.by(() => this.opts.disabled.current || this.root.opts.disabled.current);
|
|
@@ -89,6 +94,7 @@ export class TabsTriggerState {
|
|
|
89
94
|
constructor(opts, root) {
|
|
90
95
|
this.opts = opts;
|
|
91
96
|
this.root = root;
|
|
97
|
+
this.attachment = attachRef(opts.ref);
|
|
92
98
|
watch([() => this.opts.id.current, () => this.opts.value.current], ([id, value]) => {
|
|
93
99
|
return this.root.registerTrigger(id, value);
|
|
94
100
|
});
|
|
@@ -146,7 +152,7 @@ export class TabsTriggerState {
|
|
|
146
152
|
onclick: this.onclick,
|
|
147
153
|
onfocus: this.onfocus,
|
|
148
154
|
onkeydown: this.onkeydown,
|
|
149
|
-
...
|
|
155
|
+
...this.attachment,
|
|
150
156
|
}));
|
|
151
157
|
}
|
|
152
158
|
export class TabsContentState {
|
|
@@ -155,11 +161,13 @@ export class TabsContentState {
|
|
|
155
161
|
}
|
|
156
162
|
opts;
|
|
157
163
|
root;
|
|
164
|
+
attachment;
|
|
158
165
|
#isActive = $derived.by(() => this.root.opts.value.current === this.opts.value.current);
|
|
159
166
|
#ariaLabelledBy = $derived.by(() => this.root.valueToTriggerId.get(this.opts.value.current));
|
|
160
167
|
constructor(opts, root) {
|
|
161
168
|
this.opts = opts;
|
|
162
169
|
this.root = root;
|
|
170
|
+
this.attachment = attachRef(opts.ref);
|
|
163
171
|
watch([() => this.opts.id.current, () => this.opts.value.current], ([id, value]) => {
|
|
164
172
|
return this.root.registerContent(id, value);
|
|
165
173
|
});
|
|
@@ -174,7 +182,7 @@ export class TabsContentState {
|
|
|
174
182
|
"aria-labelledby": this.#ariaLabelledBy,
|
|
175
183
|
"data-orientation": getDataOrientation(this.root.opts.orientation.current),
|
|
176
184
|
[tabsAttrs.content]: "",
|
|
177
|
-
...
|
|
185
|
+
...this.attachment,
|
|
178
186
|
}));
|
|
179
187
|
}
|
|
180
188
|
function getTabDataState(condition) {
|