bits-ui 1.0.0-next.85 → 1.0.0-next.87
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 +15 -15
- package/dist/bits/accordion/accordion.svelte.js +63 -101
- package/dist/bits/alert-dialog/components/alert-dialog-content.svelte +7 -3
- package/dist/bits/aspect-ratio/aspect-ratio.svelte.d.ts +3 -3
- package/dist/bits/aspect-ratio/aspect-ratio.svelte.js +7 -14
- package/dist/bits/avatar/avatar.svelte.d.ts +8 -8
- package/dist/bits/avatar/avatar.svelte.js +34 -59
- package/dist/bits/calendar/calendar.svelte.d.ts +24 -58
- package/dist/bits/calendar/calendar.svelte.js +168 -270
- package/dist/bits/calendar/components/calendar-day.svelte +1 -1
- package/dist/bits/checkbox/checkbox.svelte.d.ts +9 -17
- package/dist/bits/checkbox/checkbox.svelte.js +50 -85
- package/dist/bits/collapsible/collapsible.svelte.d.ts +12 -18
- package/dist/bits/collapsible/collapsible.svelte.js +33 -54
- package/dist/bits/combobox/components/combobox.svelte +4 -4
- package/dist/bits/command/command.svelte.d.ts +35 -37
- package/dist/bits/command/command.svelte.js +172 -255
- package/dist/bits/command/components/command-item.svelte +1 -4
- package/dist/bits/command/components/command-link-item.svelte +1 -4
- package/dist/bits/context-menu/components/context-menu-content-static.svelte +4 -7
- package/dist/bits/context-menu/components/context-menu-content.svelte +4 -7
- package/dist/bits/date-field/date-field.svelte.d.ts +34 -16
- package/dist/bits/date-field/date-field.svelte.js +287 -350
- package/dist/bits/date-picker/components/date-picker-calendar.svelte +19 -19
- package/dist/bits/date-picker/components/date-picker.svelte +13 -13
- package/dist/bits/date-picker/date-picker.svelte.d.ts +2 -2
- package/dist/bits/date-picker/date-picker.svelte.js +3 -3
- package/dist/bits/date-range-field/date-range-field.svelte.d.ts +5 -26
- package/dist/bits/date-range-field/date-range-field.svelte.js +57 -101
- package/dist/bits/date-range-picker/components/date-range-picker-calendar.svelte +20 -20
- package/dist/bits/date-range-picker/components/date-range-picker.svelte +15 -15
- package/dist/bits/date-range-picker/date-range-picker.svelte.d.ts +2 -2
- package/dist/bits/date-range-picker/date-range-picker.svelte.js +3 -3
- package/dist/bits/dialog/components/dialog-content.svelte +7 -3
- package/dist/bits/dialog/components/dialog-overlay.svelte +1 -1
- package/dist/bits/dialog/dialog.svelte.d.ts +26 -19
- package/dist/bits/dialog/dialog.svelte.js +107 -145
- package/dist/bits/dropdown-menu/components/dropdown-menu-content-static.svelte +4 -7
- package/dist/bits/dropdown-menu/components/dropdown-menu-content.svelte +4 -7
- package/dist/bits/label/label.svelte.d.ts +3 -2
- package/dist/bits/label/label.svelte.js +7 -11
- package/dist/bits/link-preview/components/link-preview-content-static.svelte +2 -2
- package/dist/bits/link-preview/components/link-preview-content.svelte +3 -3
- package/dist/bits/link-preview/link-preview.svelte.d.ts +8 -9
- package/dist/bits/link-preview/link-preview.svelte.js +41 -51
- package/dist/bits/menu/components/menu-content-static.svelte +4 -7
- package/dist/bits/menu/components/menu-content.svelte +4 -7
- package/dist/bits/menu/components/menu-sub-content-static.svelte +7 -10
- package/dist/bits/menu/components/menu-sub-content.svelte +7 -10
- package/dist/bits/menu/menu.svelte.d.ts +51 -61
- package/dist/bits/menu/menu.svelte.js +189 -244
- package/dist/bits/menubar/components/menubar-menu.svelte +1 -1
- package/dist/bits/menubar/menubar.svelte.d.ts +11 -19
- package/dist/bits/menubar/menubar.svelte.js +50 -71
- package/dist/bits/navigation-menu/components/navigation-menu-content.svelte +2 -2
- package/dist/bits/navigation-menu/components/navigation-menu-trigger.svelte +1 -4
- package/dist/bits/navigation-menu/navigation-menu.svelte.d.ts +8 -30
- package/dist/bits/navigation-menu/navigation-menu.svelte.js +20 -21
- package/dist/bits/pagination/pagination.svelte.d.ts +8 -14
- package/dist/bits/pagination/pagination.svelte.js +61 -96
- package/dist/bits/pin-input/pin-input.svelte.d.ts +7 -6
- package/dist/bits/pin-input/pin-input.svelte.js +100 -123
- package/dist/bits/popover/components/popover-content-static.svelte +2 -2
- package/dist/bits/popover/components/popover-content.svelte +2 -2
- package/dist/bits/popover/popover.svelte.d.ts +11 -8
- package/dist/bits/popover/popover.svelte.js +45 -62
- package/dist/bits/progress/progress.svelte.d.ts +2 -2
- package/dist/bits/progress/progress.svelte.js +11 -20
- package/dist/bits/radio-group/radio-group.svelte.d.ts +6 -10
- package/dist/bits/radio-group/radio-group.svelte.js +42 -62
- package/dist/bits/range-calendar/components/range-calendar-day.svelte +1 -1
- package/dist/bits/range-calendar/range-calendar.svelte.d.ts +6 -31
- package/dist/bits/range-calendar/range-calendar.svelte.js +146 -205
- package/dist/bits/scroll-area/components/scroll-area-corner.svelte +1 -1
- package/dist/bits/scroll-area/components/scroll-area-scrollbar-visible.svelte +1 -1
- package/dist/bits/scroll-area/components/scroll-area-scrollbar.svelte +1 -1
- package/dist/bits/scroll-area/scroll-area.svelte.d.ts +28 -28
- package/dist/bits/scroll-area/scroll-area.svelte.js +93 -123
- package/dist/bits/select/components/select-content-static.svelte +2 -2
- package/dist/bits/select/components/select-content.svelte +2 -2
- package/dist/bits/select/components/select-item.svelte +1 -5
- package/dist/bits/select/components/select-scroll-down-button.svelte +1 -1
- package/dist/bits/select/components/select-scroll-up-button.svelte +1 -1
- package/dist/bits/select/components/select.svelte +4 -4
- package/dist/bits/select/select.svelte.d.ts +39 -103
- package/dist/bits/select/select.svelte.js +175 -222
- package/dist/bits/separator/separator.svelte.d.ts +2 -2
- package/dist/bits/separator/separator.svelte.js +11 -20
- package/dist/bits/slider/slider.svelte.d.ts +15 -21
- package/dist/bits/slider/slider.svelte.js +135 -177
- package/dist/bits/switch/components/switch-thumb.svelte +2 -2
- package/dist/bits/switch/components/switch.svelte +2 -2
- package/dist/bits/switch/switch.svelte.d.ts +12 -10
- package/dist/bits/switch/switch.svelte.js +37 -51
- package/dist/bits/tabs/tabs.svelte.d.ts +11 -11
- package/dist/bits/tabs/tabs.svelte.js +61 -97
- package/dist/bits/toggle/components/toggle.svelte +2 -2
- package/dist/bits/toggle/toggle.svelte.d.ts +5 -2
- package/dist/bits/toggle/toggle.svelte.js +17 -23
- package/dist/bits/toggle-group/components/toggle-group-item.svelte +2 -2
- package/dist/bits/toggle-group/toggle-group.svelte.d.ts +13 -15
- package/dist/bits/toggle-group/toggle-group.svelte.js +55 -74
- package/dist/bits/toolbar/toolbar.svelte.d.ts +28 -22
- package/dist/bits/toolbar/toolbar.svelte.js +96 -129
- package/dist/bits/tooltip/components/tooltip-content-static.svelte +2 -2
- package/dist/bits/tooltip/components/tooltip-content.svelte +2 -2
- package/dist/bits/tooltip/tooltip.svelte.d.ts +11 -19
- package/dist/bits/tooltip/tooltip.svelte.js +60 -89
- package/dist/bits/utilities/dismissible-layer/use-dismissable-layer.svelte.d.ts +2 -1
- package/dist/bits/utilities/dismissible-layer/use-dismissable-layer.svelte.js +11 -14
- package/dist/bits/utilities/escape-layer/use-escape-layer.svelte.d.ts +2 -1
- package/dist/bits/utilities/escape-layer/use-escape-layer.svelte.js +7 -11
- package/dist/bits/utilities/floating-layer/use-floating-layer.svelte.d.ts +9 -10
- package/dist/bits/utilities/floating-layer/use-floating-layer.svelte.js +55 -83
- package/dist/bits/utilities/mounted.svelte +4 -4
- package/dist/bits/utilities/mounted.svelte.d.ts +2 -2
- package/dist/bits/utilities/text-selection-layer/use-text-selection-layer.svelte.d.ts +2 -1
- package/dist/bits/utilities/text-selection-layer/use-text-selection-layer.svelte.js +10 -16
- package/package.json +1 -1
|
@@ -8,11 +8,9 @@ type AccordionBaseStateProps = WithRefProps<ReadableBoxedValues<{
|
|
|
8
8
|
loop: boolean;
|
|
9
9
|
}>>;
|
|
10
10
|
declare class AccordionBaseState {
|
|
11
|
-
|
|
12
|
-
disabled: AccordionBaseStateProps["disabled"];
|
|
13
|
-
orientation: AccordionBaseStateProps["orientation"];
|
|
11
|
+
readonly opts: AccordionBaseStateProps;
|
|
14
12
|
rovingFocusGroup: UseRovingFocusReturn;
|
|
15
|
-
constructor(
|
|
13
|
+
constructor(opts: AccordionBaseStateProps);
|
|
16
14
|
props: {
|
|
17
15
|
readonly id: string;
|
|
18
16
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
@@ -24,9 +22,9 @@ type AccordionSingleStateProps = AccordionBaseStateProps & WritableBoxedValues<{
|
|
|
24
22
|
value: string;
|
|
25
23
|
}>;
|
|
26
24
|
export declare class AccordionSingleState extends AccordionBaseState {
|
|
27
|
-
|
|
25
|
+
readonly opts: AccordionSingleStateProps;
|
|
28
26
|
isMulti: false;
|
|
29
|
-
constructor(
|
|
27
|
+
constructor(opts: AccordionSingleStateProps);
|
|
30
28
|
includesItem(item: string): boolean;
|
|
31
29
|
toggleItem(item: string): void;
|
|
32
30
|
}
|
|
@@ -47,13 +45,11 @@ type AccordionItemStateProps = WithRefProps<ReadableBoxedValues<{
|
|
|
47
45
|
rootState: AccordionState;
|
|
48
46
|
}>;
|
|
49
47
|
export declare class AccordionItemState {
|
|
50
|
-
|
|
51
|
-
value: AccordionItemStateProps["value"];
|
|
52
|
-
disabled: AccordionItemStateProps["disabled"];
|
|
48
|
+
readonly opts: AccordionItemStateProps;
|
|
53
49
|
root: AccordionState;
|
|
54
50
|
isActive: boolean;
|
|
55
51
|
isDisabled: boolean;
|
|
56
|
-
constructor(
|
|
52
|
+
constructor(opts: AccordionItemStateProps);
|
|
57
53
|
updateValue(): void;
|
|
58
54
|
props: {
|
|
59
55
|
readonly id: string;
|
|
@@ -68,7 +64,9 @@ type AccordionTriggerStateProps = WithRefProps<ReadableBoxedValues<{
|
|
|
68
64
|
}>>;
|
|
69
65
|
declare class AccordionTriggerState {
|
|
70
66
|
#private;
|
|
71
|
-
|
|
67
|
+
readonly opts: AccordionTriggerStateProps;
|
|
68
|
+
readonly itemState: AccordionItemState;
|
|
69
|
+
constructor(opts: AccordionTriggerStateProps, itemState: AccordionItemState);
|
|
72
70
|
onclick(e: BitsMouseEvent): void;
|
|
73
71
|
onkeydown(e: BitsKeyboardEvent): void;
|
|
74
72
|
props: {
|
|
@@ -90,9 +88,10 @@ type AccordionContentStateProps = WithRefProps<ReadableBoxedValues<{
|
|
|
90
88
|
}>>;
|
|
91
89
|
declare class AccordionContentState {
|
|
92
90
|
#private;
|
|
93
|
-
|
|
91
|
+
readonly opts: AccordionContentStateProps;
|
|
92
|
+
readonly item: AccordionItemState;
|
|
94
93
|
present: boolean;
|
|
95
|
-
constructor(
|
|
94
|
+
constructor(opts: AccordionContentStateProps, item: AccordionItemState);
|
|
96
95
|
snippetProps: {
|
|
97
96
|
open: boolean;
|
|
98
97
|
};
|
|
@@ -112,8 +111,9 @@ type AccordionHeaderStateProps = WithRefProps<ReadableBoxedValues<{
|
|
|
112
111
|
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
113
112
|
}>>;
|
|
114
113
|
declare class AccordionHeaderState {
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
readonly opts: AccordionHeaderStateProps;
|
|
115
|
+
readonly item: AccordionItemState;
|
|
116
|
+
constructor(opts: AccordionHeaderStateProps, item: AccordionItemState);
|
|
117
117
|
props: {
|
|
118
118
|
readonly id: string;
|
|
119
119
|
readonly role: "heading";
|
|
@@ -9,50 +9,39 @@ const ACCORDION_CONTENT_ATTR = "data-accordion-content";
|
|
|
9
9
|
const ACCORDION_ITEM_ATTR = "data-accordion-item";
|
|
10
10
|
const ACCORDION_HEADER_ATTR = "data-accordion-header";
|
|
11
11
|
class AccordionBaseState {
|
|
12
|
-
|
|
13
|
-
#ref;
|
|
14
|
-
disabled;
|
|
15
|
-
#loop;
|
|
16
|
-
orientation;
|
|
12
|
+
opts;
|
|
17
13
|
rovingFocusGroup;
|
|
18
|
-
constructor(
|
|
19
|
-
this
|
|
20
|
-
this.
|
|
21
|
-
this.#ref = props.ref;
|
|
22
|
-
useRefById({
|
|
23
|
-
id: this.#id,
|
|
24
|
-
ref: this.#ref,
|
|
25
|
-
});
|
|
26
|
-
this.orientation = props.orientation;
|
|
27
|
-
this.#loop = props.loop;
|
|
14
|
+
constructor(opts) {
|
|
15
|
+
this.opts = opts;
|
|
16
|
+
useRefById(this.opts);
|
|
28
17
|
this.rovingFocusGroup = useRovingFocus({
|
|
29
|
-
rootNodeId: this
|
|
18
|
+
rootNodeId: this.opts.id,
|
|
30
19
|
candidateAttr: ACCORDION_TRIGGER_ATTR,
|
|
31
|
-
loop: this
|
|
32
|
-
orientation: this.orientation,
|
|
20
|
+
loop: this.opts.loop,
|
|
21
|
+
orientation: this.opts.orientation,
|
|
33
22
|
});
|
|
34
23
|
}
|
|
35
24
|
props = $derived.by(() => ({
|
|
36
|
-
id: this
|
|
37
|
-
"data-orientation": getDataOrientation(this.orientation.current),
|
|
38
|
-
"data-disabled": getDataDisabled(this.disabled.current),
|
|
25
|
+
id: this.opts.id.current,
|
|
26
|
+
"data-orientation": getDataOrientation(this.opts.orientation.current),
|
|
27
|
+
"data-disabled": getDataDisabled(this.opts.disabled.current),
|
|
39
28
|
[ACCORDION_ROOT_ATTR]: "",
|
|
40
29
|
}));
|
|
41
30
|
}
|
|
42
31
|
export class AccordionSingleState extends AccordionBaseState {
|
|
43
|
-
|
|
32
|
+
opts;
|
|
44
33
|
isMulti = false;
|
|
45
|
-
constructor(
|
|
46
|
-
super(
|
|
47
|
-
this
|
|
34
|
+
constructor(opts) {
|
|
35
|
+
super(opts);
|
|
36
|
+
this.opts = opts;
|
|
48
37
|
this.includesItem = this.includesItem.bind(this);
|
|
49
38
|
this.toggleItem = this.toggleItem.bind(this);
|
|
50
39
|
}
|
|
51
40
|
includesItem(item) {
|
|
52
|
-
return this
|
|
41
|
+
return this.opts.value.current === item;
|
|
53
42
|
}
|
|
54
43
|
toggleItem(item) {
|
|
55
|
-
this
|
|
44
|
+
this.opts.value.current = this.includesItem(item) ? "" : item;
|
|
56
45
|
}
|
|
57
46
|
}
|
|
58
47
|
export class AccordionMultiState extends AccordionBaseState {
|
|
@@ -77,84 +66,70 @@ export class AccordionMultiState extends AccordionBaseState {
|
|
|
77
66
|
}
|
|
78
67
|
}
|
|
79
68
|
export class AccordionItemState {
|
|
80
|
-
|
|
81
|
-
#ref;
|
|
82
|
-
value;
|
|
83
|
-
disabled;
|
|
69
|
+
opts;
|
|
84
70
|
root;
|
|
85
|
-
isActive = $derived.by(() => this.root.includesItem(this.value.current));
|
|
86
|
-
isDisabled = $derived.by(() => this.disabled.current || this.root.disabled.current);
|
|
87
|
-
constructor(
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
90
|
-
this.root = props.rootState;
|
|
91
|
-
this.#id = props.id;
|
|
92
|
-
this.#ref = props.ref;
|
|
71
|
+
isActive = $derived.by(() => this.root.includesItem(this.opts.value.current));
|
|
72
|
+
isDisabled = $derived.by(() => this.opts.disabled.current || this.root.opts.disabled.current);
|
|
73
|
+
constructor(opts) {
|
|
74
|
+
this.opts = opts;
|
|
75
|
+
this.root = opts.rootState;
|
|
93
76
|
this.updateValue = this.updateValue.bind(this);
|
|
94
77
|
useRefById({
|
|
95
|
-
|
|
96
|
-
ref: this.#ref,
|
|
78
|
+
...opts,
|
|
97
79
|
deps: () => this.isActive,
|
|
98
80
|
});
|
|
99
81
|
}
|
|
100
82
|
updateValue() {
|
|
101
|
-
this.root.toggleItem(this.value.current);
|
|
83
|
+
this.root.toggleItem(this.opts.value.current);
|
|
102
84
|
}
|
|
103
85
|
props = $derived.by(() => ({
|
|
104
|
-
id: this
|
|
86
|
+
id: this.opts.id.current,
|
|
105
87
|
"data-state": getDataOpenClosed(this.isActive),
|
|
106
88
|
"data-disabled": getDataDisabled(this.isDisabled),
|
|
107
|
-
"data-orientation": getDataOrientation(this.root.orientation.current),
|
|
89
|
+
"data-orientation": getDataOrientation(this.root.opts.orientation.current),
|
|
108
90
|
[ACCORDION_ITEM_ATTR]: "",
|
|
109
91
|
}));
|
|
110
92
|
}
|
|
111
93
|
class AccordionTriggerState {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
#id;
|
|
94
|
+
opts;
|
|
95
|
+
itemState;
|
|
115
96
|
#root;
|
|
116
|
-
#
|
|
117
|
-
|
|
118
|
-
this.#
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this
|
|
122
|
-
this.#itemState = itemState;
|
|
97
|
+
#isDisabled = $derived.by(() => this.opts.disabled.current ||
|
|
98
|
+
this.itemState.opts.disabled.current ||
|
|
99
|
+
this.#root.opts.disabled.current);
|
|
100
|
+
constructor(opts, itemState) {
|
|
101
|
+
this.opts = opts;
|
|
102
|
+
this.itemState = itemState;
|
|
123
103
|
this.#root = itemState.root;
|
|
124
|
-
this.#id = props.id;
|
|
125
|
-
this.#ref = props.ref;
|
|
126
104
|
this.onkeydown = this.onkeydown.bind(this);
|
|
127
105
|
this.onclick = this.onclick.bind(this);
|
|
128
|
-
useRefById(
|
|
129
|
-
id: props.id,
|
|
130
|
-
ref: this.#ref,
|
|
131
|
-
});
|
|
106
|
+
useRefById(opts);
|
|
132
107
|
}
|
|
133
108
|
onclick(e) {
|
|
134
109
|
if (this.#isDisabled)
|
|
135
110
|
return;
|
|
136
111
|
if (e.button !== 0)
|
|
137
112
|
return e.preventDefault();
|
|
138
|
-
this
|
|
113
|
+
this.itemState.updateValue();
|
|
139
114
|
}
|
|
140
115
|
onkeydown(e) {
|
|
141
116
|
if (this.#isDisabled)
|
|
142
117
|
return;
|
|
143
118
|
if (e.key === kbd.SPACE || e.key === kbd.ENTER) {
|
|
144
119
|
e.preventDefault();
|
|
145
|
-
this
|
|
120
|
+
this.itemState.updateValue();
|
|
146
121
|
return;
|
|
147
122
|
}
|
|
148
|
-
this.#root.rovingFocusGroup.handleKeydown(this
|
|
123
|
+
this.#root.rovingFocusGroup.handleKeydown(this.opts.ref.current, e);
|
|
149
124
|
}
|
|
150
125
|
props = $derived.by(() => ({
|
|
151
|
-
id: this
|
|
126
|
+
id: this.opts.id.current,
|
|
152
127
|
disabled: this.#isDisabled,
|
|
153
|
-
"aria-expanded": getAriaExpanded(this
|
|
128
|
+
"aria-expanded": getAriaExpanded(this.itemState.isActive),
|
|
154
129
|
"aria-disabled": getAriaDisabled(this.#isDisabled),
|
|
155
130
|
"data-disabled": getDataDisabled(this.#isDisabled),
|
|
156
|
-
"data-state": getDataOpenClosed(this
|
|
157
|
-
"data-orientation": getDataOrientation(this.#root.orientation.current),
|
|
131
|
+
"data-state": getDataOpenClosed(this.itemState.isActive),
|
|
132
|
+
"data-orientation": getDataOrientation(this.#root.opts.orientation.current),
|
|
158
133
|
[ACCORDION_TRIGGER_ATTR]: "",
|
|
159
134
|
tabindex: 0,
|
|
160
135
|
//
|
|
@@ -163,25 +138,19 @@ class AccordionTriggerState {
|
|
|
163
138
|
}));
|
|
164
139
|
}
|
|
165
140
|
class AccordionContentState {
|
|
141
|
+
opts;
|
|
166
142
|
item;
|
|
167
|
-
#ref;
|
|
168
|
-
#id;
|
|
169
143
|
#originalStyles = undefined;
|
|
170
144
|
#isMountAnimationPrevented = false;
|
|
171
145
|
#width = $state(0);
|
|
172
146
|
#height = $state(0);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
147
|
+
present = $derived.by(() => this.opts.forceMount.current || this.item.isActive);
|
|
148
|
+
constructor(opts, item) {
|
|
149
|
+
this.opts = opts;
|
|
150
|
+
this.item = item;
|
|
176
151
|
this.item = item;
|
|
177
|
-
this.#forceMount = props.forceMount;
|
|
178
152
|
this.#isMountAnimationPrevented = this.item.isActive;
|
|
179
|
-
|
|
180
|
-
this.#ref = props.ref;
|
|
181
|
-
useRefById({
|
|
182
|
-
id: this.#id,
|
|
183
|
-
ref: this.#ref,
|
|
184
|
-
});
|
|
153
|
+
useRefById(opts);
|
|
185
154
|
$effect.pre(() => {
|
|
186
155
|
const rAF = requestAnimationFrame(() => {
|
|
187
156
|
this.#isMountAnimationPrevented = false;
|
|
@@ -190,11 +159,11 @@ class AccordionContentState {
|
|
|
190
159
|
cancelAnimationFrame(rAF);
|
|
191
160
|
};
|
|
192
161
|
});
|
|
193
|
-
watch([() => this.present, () => this
|
|
162
|
+
watch([() => this.present, () => this.opts.ref.current], ([_, node]) => {
|
|
194
163
|
if (!node)
|
|
195
164
|
return;
|
|
196
165
|
afterTick(() => {
|
|
197
|
-
if (!this
|
|
166
|
+
if (!this.opts.ref.current)
|
|
198
167
|
return;
|
|
199
168
|
// get the dimensions of the element
|
|
200
169
|
this.#originalStyles = this.#originalStyles || {
|
|
@@ -220,10 +189,10 @@ class AccordionContentState {
|
|
|
220
189
|
open: this.item.isActive,
|
|
221
190
|
}));
|
|
222
191
|
props = $derived.by(() => ({
|
|
223
|
-
id: this
|
|
192
|
+
id: this.opts.id.current,
|
|
224
193
|
"data-state": getDataOpenClosed(this.item.isActive),
|
|
225
194
|
"data-disabled": getDataDisabled(this.item.isDisabled),
|
|
226
|
-
"data-orientation": getDataOrientation(this.item.root.orientation.current),
|
|
195
|
+
"data-orientation": getDataOrientation(this.item.root.opts.orientation.current),
|
|
227
196
|
[ACCORDION_CONTENT_ATTR]: "",
|
|
228
197
|
style: {
|
|
229
198
|
"--bits-accordion-content-height": `${this.#height}px`,
|
|
@@ -232,27 +201,20 @@ class AccordionContentState {
|
|
|
232
201
|
}));
|
|
233
202
|
}
|
|
234
203
|
class AccordionHeaderState {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
this.#id = props.id;
|
|
242
|
-
this.#ref = props.ref;
|
|
243
|
-
useRefById({
|
|
244
|
-
id: this.#id,
|
|
245
|
-
ref: this.#ref,
|
|
246
|
-
});
|
|
247
|
-
this.#item = item;
|
|
204
|
+
opts;
|
|
205
|
+
item;
|
|
206
|
+
constructor(opts, item) {
|
|
207
|
+
this.opts = opts;
|
|
208
|
+
this.item = item;
|
|
209
|
+
useRefById(opts);
|
|
248
210
|
}
|
|
249
211
|
props = $derived.by(() => ({
|
|
250
|
-
id: this
|
|
212
|
+
id: this.opts.id.current,
|
|
251
213
|
role: "heading",
|
|
252
|
-
"aria-level": this
|
|
253
|
-
"data-heading-level": this
|
|
254
|
-
"data-state": getDataOpenClosed(this
|
|
255
|
-
"data-orientation": getDataOrientation(this
|
|
214
|
+
"aria-level": this.opts.level.current,
|
|
215
|
+
"data-heading-level": this.opts.level.current,
|
|
216
|
+
"data-state": getDataOpenClosed(this.item.isActive),
|
|
217
|
+
"data-orientation": getDataOrientation(this.item.root.opts.orientation.current),
|
|
256
218
|
[ACCORDION_HEADER_ATTR]: "",
|
|
257
219
|
}));
|
|
258
220
|
}
|
|
@@ -40,7 +40,11 @@
|
|
|
40
40
|
const mergedProps = $derived(mergeProps(restProps, contentState.props));
|
|
41
41
|
</script>
|
|
42
42
|
|
|
43
|
-
<PresenceLayer
|
|
43
|
+
<PresenceLayer
|
|
44
|
+
{...mergedProps}
|
|
45
|
+
{forceMount}
|
|
46
|
+
present={contentState.root.opts.open.current || forceMount}
|
|
47
|
+
>
|
|
44
48
|
{#snippet presence({ present })}
|
|
45
49
|
<FocusScope
|
|
46
50
|
loop
|
|
@@ -48,7 +52,7 @@
|
|
|
48
52
|
forceMount,
|
|
49
53
|
present: present.current,
|
|
50
54
|
trapFocus,
|
|
51
|
-
open: contentState.root.open.current,
|
|
55
|
+
open: contentState.root.opts.open.current,
|
|
52
56
|
})}
|
|
53
57
|
{...mergedProps}
|
|
54
58
|
onCloseAutoFocus={(e) => {
|
|
@@ -85,7 +89,7 @@
|
|
|
85
89
|
>
|
|
86
90
|
<TextSelectionLayer {...mergedProps} enabled={present.current}>
|
|
87
91
|
{#if child}
|
|
88
|
-
{#if contentState.root.open.current}
|
|
92
|
+
{#if contentState.root.opts.open.current}
|
|
89
93
|
<ScrollLock {preventScroll} {restoreScrollDelay} />
|
|
90
94
|
{/if}
|
|
91
95
|
{@render child({
|
|
@@ -3,9 +3,9 @@ import type { WithRefProps } from "../../internal/types.js";
|
|
|
3
3
|
type AspectRatioRootStateProps = WithRefProps<ReadableBoxedValues<{
|
|
4
4
|
ratio: number;
|
|
5
5
|
}>>;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
constructor(
|
|
6
|
+
declare class AspectRatioRootState {
|
|
7
|
+
readonly opts: AspectRatioRootStateProps;
|
|
8
|
+
constructor(opts: AspectRatioRootStateProps);
|
|
9
9
|
wrapperProps: {
|
|
10
10
|
style: {
|
|
11
11
|
position: string;
|
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
import { useRefById } from "svelte-toolbelt";
|
|
2
2
|
const ASPECT_RATIO_ROOT_ATTR = "data-aspect-ratio-root";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
this.#ref = props.ref;
|
|
9
|
-
this.#id = props.id;
|
|
10
|
-
this.#ratio = props.ratio;
|
|
11
|
-
useRefById({
|
|
12
|
-
id: this.#id,
|
|
13
|
-
ref: this.#ref,
|
|
14
|
-
});
|
|
3
|
+
class AspectRatioRootState {
|
|
4
|
+
opts;
|
|
5
|
+
constructor(opts) {
|
|
6
|
+
this.opts = opts;
|
|
7
|
+
useRefById(opts);
|
|
15
8
|
}
|
|
16
9
|
wrapperProps = $derived.by(() => ({
|
|
17
10
|
style: {
|
|
18
11
|
position: "relative",
|
|
19
12
|
width: "100%",
|
|
20
|
-
paddingBottom: `${this
|
|
13
|
+
paddingBottom: `${this.opts.ratio.current ? 100 / this.opts.ratio.current : 0}%}`,
|
|
21
14
|
},
|
|
22
15
|
}));
|
|
23
16
|
props = $derived.by(() => ({
|
|
24
|
-
id: this
|
|
17
|
+
id: this.opts.id.current,
|
|
25
18
|
style: {
|
|
26
19
|
position: "absolute",
|
|
27
20
|
top: 0,
|
|
@@ -14,10 +14,8 @@ type AvatarRootStateProps = WithRefProps<{
|
|
|
14
14
|
}>;
|
|
15
15
|
type AvatarImageSrc = string | null | undefined;
|
|
16
16
|
declare class AvatarRootState {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
loadingStatus: AvatarRootStateProps["loadingStatus"];
|
|
20
|
-
constructor(props: AvatarRootStateProps);
|
|
17
|
+
readonly opts: AvatarRootStateProps;
|
|
18
|
+
constructor(opts: AvatarRootStateProps);
|
|
21
19
|
loadImage(src: string, crossorigin?: CrossOrigin, referrerPolicy?: ReferrerPolicy): () => void;
|
|
22
20
|
props: {
|
|
23
21
|
readonly id: string;
|
|
@@ -34,8 +32,9 @@ type AvatarImageStateProps = WithRefProps<ReadableBoxedValues<{
|
|
|
34
32
|
referrerPolicy: ReferrerPolicy;
|
|
35
33
|
}>>;
|
|
36
34
|
declare class AvatarImageState {
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
readonly opts: AvatarImageStateProps;
|
|
36
|
+
readonly root: AvatarRootState;
|
|
37
|
+
constructor(opts: AvatarImageStateProps, root: AvatarRootState);
|
|
39
38
|
props: {
|
|
40
39
|
readonly id: string;
|
|
41
40
|
readonly style: {
|
|
@@ -53,8 +52,9 @@ declare class AvatarImageState {
|
|
|
53
52
|
*/
|
|
54
53
|
type AvatarFallbackStateProps = WithRefProps;
|
|
55
54
|
declare class AvatarFallbackState {
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
readonly opts: AvatarFallbackStateProps;
|
|
56
|
+
readonly root: AvatarRootState;
|
|
57
|
+
constructor(opts: AvatarFallbackStateProps, root: AvatarRootState);
|
|
58
58
|
props: {
|
|
59
59
|
readonly style: {
|
|
60
60
|
readonly display: "none" | undefined;
|
|
@@ -5,20 +5,11 @@ const AVATAR_ROOT_ATTR = "data-avatar-root";
|
|
|
5
5
|
const AVATAR_IMAGE_ATTR = "data-avatar-image";
|
|
6
6
|
const AVATAR_FALLBACK_ATTR = "data-avatar-fallback";
|
|
7
7
|
class AvatarRootState {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
loadingStatus;
|
|
12
|
-
constructor(props) {
|
|
13
|
-
this.delayMs = props.delayMs;
|
|
14
|
-
this.loadingStatus = props.loadingStatus;
|
|
15
|
-
this.#ref = props.ref;
|
|
16
|
-
this.#id = props.id;
|
|
8
|
+
opts;
|
|
9
|
+
constructor(opts) {
|
|
10
|
+
this.opts = opts;
|
|
17
11
|
this.loadImage = this.loadImage.bind(this);
|
|
18
|
-
useRefById(
|
|
19
|
-
id: this.#id,
|
|
20
|
-
ref: this.#ref,
|
|
21
|
-
});
|
|
12
|
+
useRefById(opts);
|
|
22
13
|
}
|
|
23
14
|
loadImage(src, crossorigin, referrerPolicy) {
|
|
24
15
|
let imageTimerId;
|
|
@@ -28,83 +19,67 @@ class AvatarRootState {
|
|
|
28
19
|
image.crossOrigin = crossorigin;
|
|
29
20
|
if (referrerPolicy)
|
|
30
21
|
image.referrerPolicy = referrerPolicy;
|
|
31
|
-
this.loadingStatus.current = "loading";
|
|
22
|
+
this.opts.loadingStatus.current = "loading";
|
|
32
23
|
image.onload = () => {
|
|
33
24
|
imageTimerId = window.setTimeout(() => {
|
|
34
|
-
this.loadingStatus.current = "loaded";
|
|
35
|
-
}, this.delayMs.current);
|
|
25
|
+
this.opts.loadingStatus.current = "loaded";
|
|
26
|
+
}, this.opts.delayMs.current);
|
|
36
27
|
};
|
|
37
28
|
image.onerror = () => {
|
|
38
|
-
this.loadingStatus.current = "error";
|
|
29
|
+
this.opts.loadingStatus.current = "error";
|
|
39
30
|
};
|
|
40
31
|
return () => {
|
|
41
32
|
window.clearTimeout(imageTimerId);
|
|
42
33
|
};
|
|
43
34
|
}
|
|
44
35
|
props = $derived.by(() => ({
|
|
45
|
-
id: this
|
|
36
|
+
id: this.opts.id.current,
|
|
46
37
|
[AVATAR_ROOT_ATTR]: "",
|
|
47
|
-
"data-status": this.loadingStatus.current,
|
|
38
|
+
"data-status": this.opts.loadingStatus.current,
|
|
48
39
|
}));
|
|
49
40
|
}
|
|
50
41
|
class AvatarImageState {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
constructor(props, root) {
|
|
58
|
-
this.#root = root;
|
|
59
|
-
this.#src = props.src;
|
|
60
|
-
this.#id = props.id;
|
|
61
|
-
this.#ref = props.ref;
|
|
62
|
-
this.#crossOrigin = props.crossOrigin;
|
|
63
|
-
this.#referrerPolicy = props.referrerPolicy;
|
|
64
|
-
useRefById({
|
|
65
|
-
id: this.#id,
|
|
66
|
-
ref: this.#ref,
|
|
67
|
-
});
|
|
42
|
+
opts;
|
|
43
|
+
root;
|
|
44
|
+
constructor(opts, root) {
|
|
45
|
+
this.opts = opts;
|
|
46
|
+
this.root = root;
|
|
47
|
+
useRefById(opts);
|
|
68
48
|
$effect.pre(() => {
|
|
69
|
-
if (!this
|
|
70
|
-
this
|
|
49
|
+
if (!this.opts.src.current) {
|
|
50
|
+
this.root.opts.loadingStatus.current = "error";
|
|
71
51
|
return;
|
|
72
52
|
}
|
|
73
53
|
// dependency on crossorigin
|
|
74
|
-
this
|
|
75
|
-
untrack(() => this
|
|
54
|
+
this.opts.crossOrigin.current;
|
|
55
|
+
untrack(() => this.root.loadImage(this.opts.src.current ?? "", this.opts.crossOrigin.current, this.opts.referrerPolicy.current));
|
|
76
56
|
});
|
|
77
57
|
}
|
|
78
58
|
props = $derived.by(() => ({
|
|
79
|
-
id: this
|
|
59
|
+
id: this.opts.id.current,
|
|
80
60
|
style: {
|
|
81
|
-
display: this
|
|
61
|
+
display: this.root.opts.loadingStatus.current === "loaded" ? "block" : "none",
|
|
82
62
|
},
|
|
83
|
-
"data-status": this
|
|
63
|
+
"data-status": this.root.opts.loadingStatus.current,
|
|
84
64
|
[AVATAR_IMAGE_ATTR]: "",
|
|
85
|
-
src: this
|
|
86
|
-
crossorigin: this
|
|
87
|
-
referrerpolicy: this
|
|
65
|
+
src: this.opts.src.current,
|
|
66
|
+
crossorigin: this.opts.crossOrigin.current,
|
|
67
|
+
referrerpolicy: this.opts.referrerPolicy.current,
|
|
88
68
|
}));
|
|
89
69
|
}
|
|
90
70
|
class AvatarFallbackState {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
this
|
|
96
|
-
|
|
97
|
-
this.#ref = props.ref;
|
|
98
|
-
useRefById({
|
|
99
|
-
id: this.#id,
|
|
100
|
-
ref: this.#ref,
|
|
101
|
-
});
|
|
71
|
+
opts;
|
|
72
|
+
root;
|
|
73
|
+
constructor(opts, root) {
|
|
74
|
+
this.opts = opts;
|
|
75
|
+
this.root = root;
|
|
76
|
+
useRefById(opts);
|
|
102
77
|
}
|
|
103
78
|
props = $derived.by(() => ({
|
|
104
79
|
style: {
|
|
105
|
-
display: this
|
|
80
|
+
display: this.root.opts.loadingStatus.current === "loaded" ? "none" : undefined,
|
|
106
81
|
},
|
|
107
|
-
"data-status": this
|
|
82
|
+
"data-status": this.root.opts.loadingStatus.current,
|
|
108
83
|
[AVATAR_FALLBACK_ATTR]: "",
|
|
109
84
|
}));
|
|
110
85
|
}
|