bits-ui 2.8.1 → 2.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bits/accordion/accordion.svelte.d.ts +6 -1
- package/dist/bits/accordion/accordion.svelte.js +15 -5
- 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/checkbox/checkbox.svelte.d.ts +4 -1
- package/dist/bits/checkbox/checkbox.svelte.js +13 -3
- package/dist/bits/collapsible/collapsible.svelte.d.ts +5 -1
- package/dist/bits/collapsible/collapsible.svelte.js +15 -4
- package/dist/bits/command/command.svelte.d.ts +13 -1
- package/dist/bits/command/command.svelte.js +36 -12
- 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/dialog.svelte.d.ts +9 -1
- package/dist/bits/dialog/dialog.svelte.js +41 -19
- 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 +37 -15
- package/dist/bits/menubar/components/menubar-trigger.svelte +4 -3
- package/dist/bits/menubar/menubar.svelte.d.ts +4 -1
- package/dist/bits/menubar/menubar.svelte.js +9 -3
- package/dist/bits/meter/meter.svelte.d.ts +2 -1
- package/dist/bits/meter/meter.svelte.js +3 -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/internal/types.d.ts +2 -1
- package/package.json +9 -12
|
@@ -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) {
|
|
@@ -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
|
-
...
|
|
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
|
-
...
|
|
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
|
-
...
|
|
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
|
-
...
|
|
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
|
-
...
|
|
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
|
-
...
|
|
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
|
-
...
|
|
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
|
-
...
|
|
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
|
-
...
|
|
39
|
+
...this.attachment,
|
|
38
40
|
}));
|
|
39
41
|
}
|
|
40
42
|
export function getToggleDataState(condition) {
|