bits-ui 2.3.0 → 2.4.0
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 +0 -5
- package/dist/bits/accordion/accordion.svelte.js +11 -14
- package/dist/bits/aspect-ratio/aspect-ratio.svelte.d.ts +0 -1
- package/dist/bits/aspect-ratio/aspect-ratio.svelte.js +6 -2
- package/dist/bits/avatar/avatar.svelte.d.ts +0 -3
- package/dist/bits/avatar/avatar.svelte.js +8 -6
- package/dist/bits/calendar/calendar.svelte.d.ts +2 -2
- package/dist/bits/calendar/calendar.svelte.js +4 -4
- package/dist/bits/calendar/components/calendar.svelte +4 -3
- package/dist/bits/checkbox/checkbox.svelte.d.ts +0 -3
- package/dist/bits/checkbox/checkbox.svelte.js +14 -14
- package/dist/bits/collapsible/collapsible.svelte.d.ts +0 -3
- package/dist/bits/collapsible/collapsible.svelte.js +8 -7
- package/dist/bits/command/command.svelte.d.ts +0 -12
- package/dist/bits/command/command.svelte.js +35 -31
- package/dist/bits/date-field/components/date-field.svelte +4 -3
- package/dist/bits/date-field/date-field.svelte.d.ts +2 -4
- package/dist/bits/date-field/date-field.svelte.js +8 -6
- package/dist/bits/date-picker/components/date-picker-trigger.svelte +2 -2
- package/dist/bits/date-picker/components/date-picker.svelte +4 -3
- package/dist/bits/date-range-field/components/date-range-field.svelte +4 -3
- package/dist/bits/date-range-field/date-range-field.svelte.d.ts +1 -3
- package/dist/bits/date-range-field/date-range-field.svelte.js +7 -5
- package/dist/bits/date-range-picker/components/date-range-picker-trigger.svelte +2 -2
- package/dist/bits/date-range-picker/components/date-range-picker.svelte +4 -3
- package/dist/bits/dialog/dialog.svelte.d.ts +2 -12
- package/dist/bits/dialog/dialog.svelte.js +16 -24
- package/dist/bits/index.d.ts +1 -0
- package/dist/bits/index.js +1 -0
- package/dist/bits/label/label.svelte.d.ts +0 -1
- package/dist/bits/label/label.svelte.js +6 -2
- package/dist/bits/link-preview/link-preview.svelte.d.ts +0 -2
- package/dist/bits/link-preview/link-preview.svelte.js +7 -5
- package/dist/bits/menu/components/menu-sub-content-static.svelte +1 -1
- package/dist/bits/menu/components/menu-sub-content.svelte +1 -1
- package/dist/bits/menu/menu.svelte.d.ts +2 -1
- package/dist/bits/menu/menu.svelte.js +39 -21
- package/dist/bits/menubar/menubar.svelte.d.ts +1 -7
- package/dist/bits/menubar/menubar.svelte.js +12 -14
- package/dist/bits/meter/meter.svelte.d.ts +0 -1
- package/dist/bits/meter/meter.svelte.js +6 -2
- package/dist/bits/navigation-menu/navigation-menu.svelte.d.ts +2 -11
- package/dist/bits/navigation-menu/navigation-menu.svelte.js +30 -25
- package/dist/bits/pagination/pagination.svelte.d.ts +0 -4
- package/dist/bits/pagination/pagination.svelte.js +9 -10
- package/dist/bits/pin-input/pin-input.svelte.d.ts +0 -2
- package/dist/bits/pin-input/pin-input.svelte.js +7 -5
- package/dist/bits/popover/popover.svelte.d.ts +0 -3
- package/dist/bits/popover/popover.svelte.js +9 -5
- package/dist/bits/progress/progress.svelte.d.ts +0 -1
- package/dist/bits/progress/progress.svelte.js +6 -2
- package/dist/bits/radio-group/radio-group.svelte.d.ts +7 -9
- package/dist/bits/radio-group/radio-group.svelte.js +9 -10
- package/dist/bits/range-calendar/components/range-calendar.svelte +4 -3
- package/dist/bits/range-calendar/range-calendar.svelte.d.ts +38 -38
- package/dist/bits/range-calendar/range-calendar.svelte.js +79 -79
- package/dist/bits/rating-group/rating-group.svelte.d.ts +0 -2
- package/dist/bits/rating-group/rating-group.svelte.js +33 -11
- package/dist/bits/scroll-area/scroll-area.svelte.d.ts +15 -19
- package/dist/bits/scroll-area/scroll-area.svelte.js +10 -10
- package/dist/bits/select/select.svelte.d.ts +28 -30
- package/dist/bits/select/select.svelte.js +37 -49
- package/dist/bits/separator/separator.svelte.d.ts +1 -2
- package/dist/bits/separator/separator.svelte.js +6 -3
- package/dist/bits/slider/slider.svelte.d.ts +17 -24
- package/dist/bits/slider/slider.svelte.js +15 -17
- package/dist/bits/switch/switch.svelte.d.ts +6 -8
- package/dist/bits/switch/switch.svelte.js +7 -5
- package/dist/bits/tabs/tabs.svelte.d.ts +5 -9
- package/dist/bits/tabs/tabs.svelte.js +11 -11
- package/dist/bits/time-field/components/time-field.svelte +4 -3
- package/dist/bits/time-field/time-field.svelte.d.ts +1 -3
- package/dist/bits/time-field/time-field.svelte.js +7 -5
- package/dist/bits/time-range-field/components/time-range-field.svelte +4 -3
- package/dist/bits/time-range-field/time-range-field.svelte.d.ts +1 -3
- package/dist/bits/time-range-field/time-range-field.svelte.js +7 -5
- package/dist/bits/toggle/toggle.svelte.d.ts +3 -3
- package/dist/bits/toggle/toggle.svelte.js +6 -3
- package/dist/bits/toggle-group/toggle-group.svelte.d.ts +1 -2
- package/dist/bits/toggle-group/toggle-group.svelte.js +8 -6
- package/dist/bits/toolbar/toolbar.svelte.d.ts +11 -18
- package/dist/bits/toolbar/toolbar.svelte.js +14 -17
- package/dist/bits/tooltip/tooltip.svelte.d.ts +13 -14
- package/dist/bits/tooltip/tooltip.svelte.js +7 -5
- package/dist/bits/utilities/config/bits-config.d.ts +44 -0
- package/dist/bits/utilities/config/bits-config.js +92 -0
- package/dist/bits/utilities/config/components/bits-config.svelte +14 -0
- package/dist/bits/utilities/config/components/bits-config.svelte.d.ts +4 -0
- package/dist/bits/utilities/config/exports.d.ts +2 -0
- package/dist/bits/utilities/config/exports.js +2 -0
- package/dist/bits/utilities/config/index.d.ts +1 -0
- package/dist/bits/utilities/config/index.js +1 -0
- package/dist/bits/utilities/config/prop-resolvers.d.ts +13 -0
- package/dist/bits/utilities/config/prop-resolvers.js +37 -0
- package/dist/bits/utilities/config/types.d.ts +13 -0
- package/dist/bits/utilities/config/types.js +1 -0
- package/dist/bits/utilities/portal/portal.svelte +21 -21
- package/dist/bits/utilities/portal/types.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/attrs.d.ts +14 -0
- package/dist/internal/attrs.js +18 -0
- package/dist/internal/date-time/calendar-helpers.svelte.d.ts +1 -0
- package/dist/internal/date-time/calendar-helpers.svelte.js +18 -1
- package/dist/internal/use-arrow-navigation.d.ts +2 -2
- package/dist/internal/use-arrow-navigation.js +1 -1
- package/dist/internal/use-data-typeahead.svelte.d.ts +1 -1
- package/dist/internal/use-data-typeahead.svelte.js +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ export declare const LAST_KEYS: string[];
|
|
|
8
8
|
export declare const FIRST_LAST_KEYS: string[];
|
|
9
9
|
export declare const SELECTION_KEYS: string[];
|
|
10
10
|
export declare const CONTENT_MARGIN = 10;
|
|
11
|
+
declare const selectAttrs: import("../../internal/attrs.js").BitsAttrs<readonly ["trigger", "content", "item", "viewport", "scroll-up-button", "scroll-down-button", "group", "group-label", "separator", "arrow", "input", "content-wrapper", "item-text", "value"]>;
|
|
11
12
|
type SelectBaseRootStateProps = ReadableBoxedValues<{
|
|
12
13
|
disabled: boolean;
|
|
13
14
|
required: boolean;
|
|
@@ -34,12 +35,11 @@ declare class SelectBaseRootState {
|
|
|
34
35
|
triggerNode: HTMLElement | null;
|
|
35
36
|
valueId: string;
|
|
36
37
|
highlightedNode: HTMLElement | null;
|
|
37
|
-
highlightedValue: string | null;
|
|
38
|
-
highlightedId: string | undefined;
|
|
39
|
-
highlightedLabel: string | null;
|
|
38
|
+
readonly highlightedValue: string | null;
|
|
39
|
+
readonly highlightedId: string | undefined;
|
|
40
|
+
readonly highlightedLabel: string | null;
|
|
40
41
|
isUsingKeyboard: boolean;
|
|
41
42
|
isCombobox: boolean;
|
|
42
|
-
bitsAttrs: SelectBitsAttrs;
|
|
43
43
|
domContext: DOMContext;
|
|
44
44
|
constructor(opts: SelectBaseRootStateProps);
|
|
45
45
|
setHighlightedNode(node: HTMLElement | null, initial?: boolean): void;
|
|
@@ -51,17 +51,18 @@ declare class SelectBaseRootState {
|
|
|
51
51
|
handleOpen(): void;
|
|
52
52
|
handleClose(): void;
|
|
53
53
|
toggleMenu(): void;
|
|
54
|
+
getBitsAttr: typeof selectAttrs.getAttr;
|
|
54
55
|
}
|
|
55
56
|
type SelectSingleRootStateProps = SelectBaseRootStateProps & WritableBoxedValues<{
|
|
56
57
|
value: string;
|
|
57
58
|
}>;
|
|
58
59
|
declare class SelectSingleRootState extends SelectBaseRootState {
|
|
59
60
|
readonly opts: SelectSingleRootStateProps;
|
|
60
|
-
isMulti: false;
|
|
61
|
-
hasValue: boolean;
|
|
62
|
-
currentLabel: string;
|
|
63
|
-
candidateLabels: string[];
|
|
64
|
-
dataTypeaheadEnabled: boolean;
|
|
61
|
+
readonly isMulti: false;
|
|
62
|
+
readonly hasValue: boolean;
|
|
63
|
+
readonly currentLabel: string;
|
|
64
|
+
readonly candidateLabels: string[];
|
|
65
|
+
readonly dataTypeaheadEnabled: boolean;
|
|
65
66
|
constructor(opts: SelectSingleRootStateProps);
|
|
66
67
|
includesItem(itemValue: string): boolean;
|
|
67
68
|
toggleItem(itemValue: string, itemLabel?: string): void;
|
|
@@ -72,8 +73,8 @@ type SelectMultipleRootStateProps = SelectBaseRootStateProps & WritableBoxedValu
|
|
|
72
73
|
}>;
|
|
73
74
|
declare class SelectMultipleRootState extends SelectBaseRootState {
|
|
74
75
|
readonly opts: SelectMultipleRootStateProps;
|
|
75
|
-
isMulti: true;
|
|
76
|
-
hasValue: boolean;
|
|
76
|
+
readonly isMulti: true;
|
|
77
|
+
readonly hasValue: boolean;
|
|
77
78
|
constructor(opts: SelectMultipleRootStateProps);
|
|
78
79
|
includesItem(itemValue: string): boolean;
|
|
79
80
|
toggleItem(itemValue: string, itemLabel?: string): void;
|
|
@@ -89,7 +90,7 @@ declare class SelectInputState {
|
|
|
89
90
|
constructor(opts: SelectInputStateProps, root: SelectRootState);
|
|
90
91
|
onkeydown(e: BitsKeyboardEvent): void;
|
|
91
92
|
oninput(e: BitsEvent<Event, HTMLInputElement>): void;
|
|
92
|
-
props: {
|
|
93
|
+
readonly props: {
|
|
93
94
|
readonly id: string;
|
|
94
95
|
readonly role: "combobox";
|
|
95
96
|
readonly disabled: true | undefined;
|
|
@@ -113,7 +114,7 @@ declare class SelectComboTriggerState {
|
|
|
113
114
|
* behavior of focusing the button and keep focus on the input.
|
|
114
115
|
*/
|
|
115
116
|
onpointerdown(e: BitsPointerEvent): void;
|
|
116
|
-
props: {
|
|
117
|
+
readonly props: {
|
|
117
118
|
readonly id: string;
|
|
118
119
|
readonly disabled: true | undefined;
|
|
119
120
|
readonly "aria-haspopup": "listbox";
|
|
@@ -133,7 +134,7 @@ declare class SelectTriggerState {
|
|
|
133
134
|
onclick(e: BitsMouseEvent): void;
|
|
134
135
|
onpointerdown(e: BitsPointerEvent): void;
|
|
135
136
|
onpointerup(e: BitsPointerEvent): void;
|
|
136
|
-
props: {
|
|
137
|
+
readonly props: {
|
|
137
138
|
readonly id: string;
|
|
138
139
|
readonly disabled: true | undefined;
|
|
139
140
|
readonly "aria-haspopup": "listbox";
|
|
@@ -165,10 +166,10 @@ declare class SelectContentState {
|
|
|
165
166
|
onEscapeKeydown: (e: KeyboardEvent) => void;
|
|
166
167
|
onOpenAutoFocus: (e: Event) => void;
|
|
167
168
|
onCloseAutoFocus: (e: Event) => void;
|
|
168
|
-
snippetProps: {
|
|
169
|
+
readonly snippetProps: {
|
|
169
170
|
open: boolean;
|
|
170
171
|
};
|
|
171
|
-
props: {
|
|
172
|
+
readonly props: {
|
|
172
173
|
readonly id: string;
|
|
173
174
|
readonly role: "listbox";
|
|
174
175
|
readonly "aria-multiselectable": "true" | undefined;
|
|
@@ -182,7 +183,7 @@ declare class SelectContentState {
|
|
|
182
183
|
};
|
|
183
184
|
readonly onpointermove: (_: BitsPointerEvent) => void;
|
|
184
185
|
};
|
|
185
|
-
popperProps: {
|
|
186
|
+
readonly popperProps: {
|
|
186
187
|
onInteractOutside: (e: PointerEvent) => void;
|
|
187
188
|
onEscapeKeydown: (e: KeyboardEvent) => void;
|
|
188
189
|
onOpenAutoFocus: (e: Event) => void;
|
|
@@ -202,9 +203,9 @@ type SelectItemStateProps = WithRefProps<ReadableBoxedValues<{
|
|
|
202
203
|
declare class SelectItemState {
|
|
203
204
|
readonly opts: SelectItemStateProps;
|
|
204
205
|
readonly root: SelectRootState;
|
|
205
|
-
isSelected: boolean;
|
|
206
|
-
isHighlighted: boolean;
|
|
207
|
-
prevHighlighted: Previous<boolean>;
|
|
206
|
+
readonly isSelected: boolean;
|
|
207
|
+
readonly isHighlighted: boolean;
|
|
208
|
+
readonly prevHighlighted: Previous<boolean>;
|
|
208
209
|
mounted: boolean;
|
|
209
210
|
constructor(opts: SelectItemStateProps, root: SelectRootState);
|
|
210
211
|
handleSelect(): void;
|
|
@@ -240,7 +241,7 @@ declare class SelectGroupState {
|
|
|
240
241
|
readonly root: SelectBaseRootState;
|
|
241
242
|
labelNode: HTMLElement | null;
|
|
242
243
|
constructor(opts: SelectGroupStateProps, root: SelectBaseRootState);
|
|
243
|
-
props: {
|
|
244
|
+
readonly props: {
|
|
244
245
|
readonly id: string;
|
|
245
246
|
readonly role: "group";
|
|
246
247
|
readonly "aria-labelledby": string | undefined;
|
|
@@ -251,7 +252,7 @@ declare class SelectGroupHeadingState {
|
|
|
251
252
|
readonly opts: SelectGroupHeadingStateProps;
|
|
252
253
|
readonly group: SelectGroupState;
|
|
253
254
|
constructor(opts: SelectGroupHeadingStateProps, group: SelectGroupState);
|
|
254
|
-
props: {
|
|
255
|
+
readonly props: {
|
|
255
256
|
readonly id: string;
|
|
256
257
|
};
|
|
257
258
|
}
|
|
@@ -264,7 +265,7 @@ declare class SelectHiddenInputState {
|
|
|
264
265
|
shouldRender: boolean;
|
|
265
266
|
constructor(opts: SelectHiddenInputStateProps, root: SelectBaseRootState);
|
|
266
267
|
onfocus(e: BitsFocusEvent): void;
|
|
267
|
-
props: {
|
|
268
|
+
readonly props: {
|
|
268
269
|
readonly disabled: true | undefined;
|
|
269
270
|
readonly required: true | undefined;
|
|
270
271
|
readonly name: string;
|
|
@@ -279,7 +280,7 @@ declare class SelectViewportState {
|
|
|
279
280
|
root: SelectBaseRootState;
|
|
280
281
|
prevScrollTop: number;
|
|
281
282
|
constructor(opts: SelectViewportStateProps, content: SelectContentState);
|
|
282
|
-
props: {
|
|
283
|
+
readonly props: {
|
|
283
284
|
readonly id: string;
|
|
284
285
|
readonly role: "presentation";
|
|
285
286
|
readonly style: {
|
|
@@ -307,7 +308,7 @@ declare class SelectScrollButtonImplState {
|
|
|
307
308
|
onpointerdown(_: BitsPointerEvent): void;
|
|
308
309
|
onpointermove(e: BitsPointerEvent): void;
|
|
309
310
|
onpointerleave(_: BitsPointerEvent): void;
|
|
310
|
-
props: {
|
|
311
|
+
readonly props: {
|
|
311
312
|
readonly id: string;
|
|
312
313
|
readonly "aria-hidden": "true" | undefined;
|
|
313
314
|
readonly style: {
|
|
@@ -331,7 +332,7 @@ declare class SelectScrollDownButtonState {
|
|
|
331
332
|
*/
|
|
332
333
|
handleScroll: (manual?: boolean) => void;
|
|
333
334
|
handleAutoScroll: () => void;
|
|
334
|
-
props: {
|
|
335
|
+
readonly props: {
|
|
335
336
|
readonly id: string;
|
|
336
337
|
readonly "aria-hidden": "true" | undefined;
|
|
337
338
|
readonly style: {
|
|
@@ -354,7 +355,7 @@ declare class SelectScrollUpButtonState {
|
|
|
354
355
|
*/
|
|
355
356
|
handleScroll: (manual?: boolean) => void;
|
|
356
357
|
handleAutoScroll: () => void;
|
|
357
|
-
props: {
|
|
358
|
+
readonly props: {
|
|
358
359
|
readonly id: string;
|
|
359
360
|
readonly "aria-hidden": "true" | undefined;
|
|
360
361
|
readonly style: {
|
|
@@ -398,7 +399,4 @@ export declare function useSelectScrollDownButton(props: SelectScrollButtonImplS
|
|
|
398
399
|
export declare function useSelectGroup(props: SelectGroupStateProps): SelectGroupState;
|
|
399
400
|
export declare function useSelectGroupHeading(props: SelectGroupHeadingStateProps): SelectGroupHeadingState;
|
|
400
401
|
export declare function useSelectHiddenInput(props: SelectHiddenInputStateProps): SelectHiddenInputState;
|
|
401
|
-
declare const selectParts: readonly ["trigger", "content", "item", "viewport", "scroll-up-button", "scroll-down-button", "group", "group-label", "separator", "arrow", "input", "content-wrapper", "item-text", "value"];
|
|
402
|
-
type SelectBitsAttrs = Record<(typeof selectParts)[number], string>;
|
|
403
|
-
export declare function getSelectBitsAttrs(root: SelectBaseRootState): SelectBitsAttrs;
|
|
404
402
|
export {};
|
|
@@ -8,6 +8,8 @@ import { noop } from "../../internal/noop.js";
|
|
|
8
8
|
import { useDOMTypeahead } from "../../internal/use-dom-typeahead.svelte.js";
|
|
9
9
|
import { useDataTypeahead } from "../../internal/use-data-typeahead.svelte.js";
|
|
10
10
|
import { isIOS } from "../../internal/is.js";
|
|
11
|
+
import { createBitsAttrs } from "../../internal/attrs.js";
|
|
12
|
+
import { getFloatingContentCSSVars } from "../../internal/floating-svelte/floating-utils.svelte.js";
|
|
11
13
|
// prettier-ignore
|
|
12
14
|
export const INTERACTION_KEYS = [kbd.ARROW_LEFT, kbd.ESCAPE, kbd.ARROW_RIGHT, kbd.SHIFT, kbd.CAPS_LOCK, kbd.CONTROL, kbd.ALT, kbd.META, kbd.ENTER, kbd.F1, kbd.F2, kbd.F3, kbd.F4, kbd.F5, kbd.F6, kbd.F7, kbd.F8, kbd.F9, kbd.F10, kbd.F11, kbd.F12];
|
|
13
15
|
export const FIRST_KEYS = [kbd.ARROW_DOWN, kbd.PAGE_UP, kbd.HOME];
|
|
@@ -15,6 +17,25 @@ export const LAST_KEYS = [kbd.ARROW_UP, kbd.PAGE_DOWN, kbd.END];
|
|
|
15
17
|
export const FIRST_LAST_KEYS = [...FIRST_KEYS, ...LAST_KEYS];
|
|
16
18
|
export const SELECTION_KEYS = [kbd.ENTER, kbd.SPACE];
|
|
17
19
|
export const CONTENT_MARGIN = 10;
|
|
20
|
+
const selectAttrs = createBitsAttrs({
|
|
21
|
+
component: "select",
|
|
22
|
+
parts: [
|
|
23
|
+
"trigger",
|
|
24
|
+
"content",
|
|
25
|
+
"item",
|
|
26
|
+
"viewport",
|
|
27
|
+
"scroll-up-button",
|
|
28
|
+
"scroll-down-button",
|
|
29
|
+
"group",
|
|
30
|
+
"group-label",
|
|
31
|
+
"separator",
|
|
32
|
+
"arrow",
|
|
33
|
+
"input",
|
|
34
|
+
"content-wrapper",
|
|
35
|
+
"item-text",
|
|
36
|
+
"value",
|
|
37
|
+
],
|
|
38
|
+
});
|
|
18
39
|
class SelectBaseRootState {
|
|
19
40
|
opts;
|
|
20
41
|
touchedInput = $state(false);
|
|
@@ -40,12 +61,10 @@ class SelectBaseRootState {
|
|
|
40
61
|
});
|
|
41
62
|
isUsingKeyboard = false;
|
|
42
63
|
isCombobox = false;
|
|
43
|
-
bitsAttrs;
|
|
44
64
|
domContext = new DOMContext(() => null);
|
|
45
65
|
constructor(opts) {
|
|
46
66
|
this.opts = opts;
|
|
47
67
|
this.isCombobox = opts.isCombobox;
|
|
48
|
-
this.bitsAttrs = getSelectBitsAttrs(this);
|
|
49
68
|
$effect.pre(() => {
|
|
50
69
|
if (!this.opts.open.current) {
|
|
51
70
|
this.setHighlightedNode(null);
|
|
@@ -62,7 +81,7 @@ class SelectBaseRootState {
|
|
|
62
81
|
const node = this.contentNode;
|
|
63
82
|
if (!node)
|
|
64
83
|
return [];
|
|
65
|
-
return Array.from(node.querySelectorAll(`[${this.
|
|
84
|
+
return Array.from(node.querySelectorAll(`[${this.getBitsAttr("item")}]:not([data-disabled])`));
|
|
66
85
|
}
|
|
67
86
|
setHighlightedToFirstCandidate() {
|
|
68
87
|
this.setHighlightedNode(null);
|
|
@@ -91,6 +110,9 @@ class SelectBaseRootState {
|
|
|
91
110
|
toggleMenu() {
|
|
92
111
|
this.toggleOpen();
|
|
93
112
|
}
|
|
113
|
+
getBitsAttr = (part) => {
|
|
114
|
+
return selectAttrs.getAttr(part, this.isCombobox ? "combobox" : undefined);
|
|
115
|
+
};
|
|
94
116
|
}
|
|
95
117
|
class SelectSingleRootState extends SelectBaseRootState {
|
|
96
118
|
opts;
|
|
@@ -338,7 +360,7 @@ class SelectInputState {
|
|
|
338
360
|
"data-disabled": getDataDisabled(this.root.opts.disabled.current),
|
|
339
361
|
onkeydown: this.onkeydown,
|
|
340
362
|
oninput: this.oninput,
|
|
341
|
-
[this.root.
|
|
363
|
+
[this.root.getBitsAttr("input")]: "",
|
|
342
364
|
...attachRef(this.opts.ref, (v) => (this.root.inputNode = v)),
|
|
343
365
|
}));
|
|
344
366
|
}
|
|
@@ -381,7 +403,7 @@ class SelectComboTriggerState {
|
|
|
381
403
|
"aria-haspopup": "listbox",
|
|
382
404
|
"data-state": getDataOpenClosed(this.root.opts.open.current),
|
|
383
405
|
"data-disabled": getDataDisabled(this.root.opts.disabled.current),
|
|
384
|
-
[this.root.
|
|
406
|
+
[this.root.getBitsAttr("trigger")]: "",
|
|
385
407
|
onpointerdown: this.onpointerdown,
|
|
386
408
|
onkeydown: this.onkeydown,
|
|
387
409
|
...attachRef(this.opts.ref),
|
|
@@ -420,7 +442,7 @@ class SelectTriggerState {
|
|
|
420
442
|
return;
|
|
421
443
|
this.root.opts.value.current = matchedItem.value;
|
|
422
444
|
},
|
|
423
|
-
enabled: !this.root.isMulti && this.root.dataTypeaheadEnabled,
|
|
445
|
+
enabled: () => !this.root.isMulti && this.root.dataTypeaheadEnabled,
|
|
424
446
|
candidateValues: () => (this.root.isMulti ? [] : this.root.candidateLabels),
|
|
425
447
|
getWindow: () => this.root.domContext.getWindow(),
|
|
426
448
|
});
|
|
@@ -612,7 +634,7 @@ class SelectTriggerState {
|
|
|
612
634
|
"data-state": getDataOpenClosed(this.root.opts.open.current),
|
|
613
635
|
"data-disabled": getDataDisabled(this.root.opts.disabled.current),
|
|
614
636
|
"data-placeholder": this.root.hasValue ? undefined : "",
|
|
615
|
-
[this.root.
|
|
637
|
+
[this.root.getBitsAttr("trigger")]: "",
|
|
616
638
|
onpointerdown: this.onpointerdown,
|
|
617
639
|
onkeydown: this.onkeydown,
|
|
618
640
|
onclick: this.onclick,
|
|
@@ -648,14 +670,7 @@ class SelectContentState {
|
|
|
648
670
|
this.root.isUsingKeyboard = false;
|
|
649
671
|
}
|
|
650
672
|
#styles = $derived.by(() => {
|
|
651
|
-
|
|
652
|
-
return {
|
|
653
|
-
[`${prefix}-content-transform-origin`]: "var(--bits-floating-transform-origin)",
|
|
654
|
-
[`${prefix}-content-available-width`]: "var(--bits-floating-available-width)",
|
|
655
|
-
[`${prefix}-content-available-height`]: "var(--bits-floating-available-height)",
|
|
656
|
-
[`${prefix}-anchor-width`]: " var(--bits-floating-anchor-width)",
|
|
657
|
-
[`${prefix}-anchor-height`]: "var(--bits-floating-anchor-height)",
|
|
658
|
-
};
|
|
673
|
+
return getFloatingContentCSSVars(this.root.isCombobox ? "combobox" : "select");
|
|
659
674
|
});
|
|
660
675
|
onInteractOutside = (e) => {
|
|
661
676
|
if (e.target === this.root.triggerNode || e.target === this.root.inputNode) {
|
|
@@ -685,7 +700,7 @@ class SelectContentState {
|
|
|
685
700
|
role: "listbox",
|
|
686
701
|
"aria-multiselectable": this.root.isMulti ? "true" : undefined,
|
|
687
702
|
"data-state": getDataOpenClosed(this.root.opts.open.current),
|
|
688
|
-
[this.root.
|
|
703
|
+
[this.root.getBitsAttr("content")]: "",
|
|
689
704
|
style: {
|
|
690
705
|
display: "flex",
|
|
691
706
|
flexDirection: "column",
|
|
@@ -822,7 +837,7 @@ class SelectItemState {
|
|
|
822
837
|
: undefined,
|
|
823
838
|
"data-selected": this.root.includesItem(this.opts.value.current) ? "" : undefined,
|
|
824
839
|
"data-label": this.opts.label.current,
|
|
825
|
-
[this.root.
|
|
840
|
+
[this.root.getBitsAttr("item")]: "",
|
|
826
841
|
onpointermove: this.onpointermove,
|
|
827
842
|
onpointerdown: this.onpointerdown,
|
|
828
843
|
onpointerup: this.onpointerup,
|
|
@@ -840,7 +855,7 @@ class SelectGroupState {
|
|
|
840
855
|
props = $derived.by(() => ({
|
|
841
856
|
id: this.opts.id.current,
|
|
842
857
|
role: "group",
|
|
843
|
-
[this.root.
|
|
858
|
+
[this.root.getBitsAttr("group")]: "",
|
|
844
859
|
"aria-labelledby": this.labelNode?.id ?? undefined,
|
|
845
860
|
...attachRef(this.opts.ref),
|
|
846
861
|
}));
|
|
@@ -854,7 +869,7 @@ class SelectGroupHeadingState {
|
|
|
854
869
|
}
|
|
855
870
|
props = $derived.by(() => ({
|
|
856
871
|
id: this.opts.id.current,
|
|
857
|
-
[this.group.root.
|
|
872
|
+
[this.group.root.getBitsAttr("group-label")]: "",
|
|
858
873
|
...attachRef(this.opts.ref, (v) => (this.group.labelNode = v)),
|
|
859
874
|
}));
|
|
860
875
|
}
|
|
@@ -897,7 +912,7 @@ class SelectViewportState {
|
|
|
897
912
|
props = $derived.by(() => ({
|
|
898
913
|
id: this.opts.id.current,
|
|
899
914
|
role: "presentation",
|
|
900
|
-
[this.root.
|
|
915
|
+
[this.root.getBitsAttr("viewport")]: "",
|
|
901
916
|
style: {
|
|
902
917
|
// we use position: 'relative' here on the `viewport` so that when we call
|
|
903
918
|
// `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
|
|
@@ -1032,7 +1047,7 @@ class SelectScrollDownButtonState {
|
|
|
1032
1047
|
};
|
|
1033
1048
|
props = $derived.by(() => ({
|
|
1034
1049
|
...this.scrollButtonState.props,
|
|
1035
|
-
[this.root.
|
|
1050
|
+
[this.root.getBitsAttr("scroll-down-button")]: "",
|
|
1036
1051
|
}));
|
|
1037
1052
|
}
|
|
1038
1053
|
class SelectScrollUpButtonState {
|
|
@@ -1073,7 +1088,7 @@ class SelectScrollUpButtonState {
|
|
|
1073
1088
|
};
|
|
1074
1089
|
props = $derived.by(() => ({
|
|
1075
1090
|
...this.scrollButtonState.props,
|
|
1076
|
-
[this.root.
|
|
1091
|
+
[this.root.getBitsAttr("scroll-up-button")]: "",
|
|
1077
1092
|
}));
|
|
1078
1093
|
}
|
|
1079
1094
|
const SelectRootContext = new Context("Select.Root | Combobox.Root");
|
|
@@ -1119,30 +1134,3 @@ export function useSelectGroupHeading(props) {
|
|
|
1119
1134
|
export function useSelectHiddenInput(props) {
|
|
1120
1135
|
return new SelectHiddenInputState(props, SelectRootContext.get());
|
|
1121
1136
|
}
|
|
1122
|
-
////////////////////////////////////
|
|
1123
|
-
// Helpers
|
|
1124
|
-
////////////////////////////////////
|
|
1125
|
-
const selectParts = [
|
|
1126
|
-
"trigger",
|
|
1127
|
-
"content",
|
|
1128
|
-
"item",
|
|
1129
|
-
"viewport",
|
|
1130
|
-
"scroll-up-button",
|
|
1131
|
-
"scroll-down-button",
|
|
1132
|
-
"group",
|
|
1133
|
-
"group-label",
|
|
1134
|
-
"separator",
|
|
1135
|
-
"arrow",
|
|
1136
|
-
"input",
|
|
1137
|
-
"content-wrapper",
|
|
1138
|
-
"item-text",
|
|
1139
|
-
"value",
|
|
1140
|
-
];
|
|
1141
|
-
export function getSelectBitsAttrs(root) {
|
|
1142
|
-
const isCombobox = root.isCombobox;
|
|
1143
|
-
const attrObj = {};
|
|
1144
|
-
for (const part of selectParts) {
|
|
1145
|
-
attrObj[part] = isCombobox ? `data-combobox-${part}` : `data-select-${part}`;
|
|
1146
|
-
}
|
|
1147
|
-
return attrObj;
|
|
1148
|
-
}
|
|
@@ -8,13 +8,12 @@ type SeparatorRootStateProps = WithRefProps<ReadableBoxedValues<{
|
|
|
8
8
|
declare class SeparatorRootState {
|
|
9
9
|
readonly opts: SeparatorRootStateProps;
|
|
10
10
|
constructor(opts: SeparatorRootStateProps);
|
|
11
|
-
props: {
|
|
11
|
+
readonly props: {
|
|
12
12
|
readonly id: string;
|
|
13
13
|
readonly role: "none" | "separator";
|
|
14
14
|
readonly "aria-orientation": "horizontal" | "vertical";
|
|
15
15
|
readonly "aria-hidden": "true" | undefined;
|
|
16
16
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
17
|
-
readonly "data-separator-root": "";
|
|
18
17
|
};
|
|
19
18
|
}
|
|
20
19
|
export declare function useSeparatorRoot(props: SeparatorRootStateProps): SeparatorRootState;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { attachRef } from "svelte-toolbelt";
|
|
2
|
-
import { getAriaHidden, getAriaOrientation, getDataOrientation } from "../../internal/attrs.js";
|
|
3
|
-
const
|
|
2
|
+
import { createBitsAttrs, getAriaHidden, getAriaOrientation, getDataOrientation, } from "../../internal/attrs.js";
|
|
3
|
+
const separatorAttrs = createBitsAttrs({
|
|
4
|
+
component: "separator",
|
|
5
|
+
parts: ["root"],
|
|
6
|
+
});
|
|
4
7
|
class SeparatorRootState {
|
|
5
8
|
opts;
|
|
6
9
|
constructor(opts) {
|
|
@@ -12,7 +15,7 @@ class SeparatorRootState {
|
|
|
12
15
|
"aria-orientation": getAriaOrientation(this.opts.orientation.current),
|
|
13
16
|
"aria-hidden": getAriaHidden(this.opts.decorative.current),
|
|
14
17
|
"data-orientation": getDataOrientation(this.opts.orientation.current),
|
|
15
|
-
[
|
|
18
|
+
[separatorAttrs.root]: "",
|
|
16
19
|
...attachRef(this.opts.ref),
|
|
17
20
|
}));
|
|
18
21
|
}
|
|
@@ -4,6 +4,7 @@ import type { ReadableBoxedValues, WritableBoxedValues } from "../../internal/bo
|
|
|
4
4
|
import type { BitsKeyboardEvent, OnChangeFn, WithRefProps } from "../../internal/types.js";
|
|
5
5
|
import type { Direction, Orientation, SliderThumbPositioning } from "../../shared/index.js";
|
|
6
6
|
import type { SliderLabelPosition } from "./types.js";
|
|
7
|
+
declare const sliderAttrs: import("../../internal/attrs.js").BitsAttrs<readonly ["root", "thumb", "range", "tick", "tick-label", "thumb-label"]>;
|
|
7
8
|
type SliderBaseRootStateProps = WithRefProps<ReadableBoxedValues<{
|
|
8
9
|
disabled: boolean;
|
|
9
10
|
orientation: Orientation;
|
|
@@ -33,7 +34,6 @@ declare class SliderBaseRootState {
|
|
|
33
34
|
readonly style: {
|
|
34
35
|
readonly touchAction: string | undefined;
|
|
35
36
|
};
|
|
36
|
-
readonly "data-slider-root": "";
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
type SliderSingleRootStateProps = SliderBaseRootStateProps & ReadableBoxedValues<{
|
|
@@ -56,6 +56,7 @@ declare class SliderSingleRootState extends SliderBaseRootState {
|
|
|
56
56
|
handlePointerDown: (e: PointerEvent) => void;
|
|
57
57
|
handlePointerUp: () => void;
|
|
58
58
|
thumbsPropsArr: {
|
|
59
|
+
readonly [sliderAttrs.thumb]: "";
|
|
59
60
|
readonly role: "slider";
|
|
60
61
|
readonly "aria-valuemin": number;
|
|
61
62
|
readonly "aria-valuemax": number;
|
|
@@ -65,17 +66,16 @@ declare class SliderSingleRootState extends SliderBaseRootState {
|
|
|
65
66
|
readonly "data-value": number;
|
|
66
67
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
67
68
|
readonly style: import("../../shared/index.js").StyleProperties;
|
|
68
|
-
readonly "data-slider-thumb": "";
|
|
69
69
|
}[];
|
|
70
70
|
thumbsRenderArr: number[];
|
|
71
71
|
ticksPropsArr: {
|
|
72
|
+
readonly [sliderAttrs.tick]: "";
|
|
72
73
|
readonly "data-disabled": "" | undefined;
|
|
73
74
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
74
75
|
readonly "data-bounded": "" | undefined;
|
|
75
76
|
readonly "data-value": number;
|
|
76
77
|
readonly "data-selected": "" | undefined;
|
|
77
78
|
readonly style: import("../../shared/index.js").StyleProperties;
|
|
78
|
-
readonly "data-slider-tick": "";
|
|
79
79
|
}[];
|
|
80
80
|
ticksRenderArr: number[];
|
|
81
81
|
tickItemsArr: {
|
|
@@ -127,7 +127,8 @@ declare class SliderMultiRootState extends SliderBaseRootState {
|
|
|
127
127
|
handlePointerUp: () => void;
|
|
128
128
|
getAllThumbs: () => HTMLElement[];
|
|
129
129
|
updateValue: (thumbValue: number, idx: number) => void;
|
|
130
|
-
thumbsPropsArr: {
|
|
130
|
+
readonly thumbsPropsArr: {
|
|
131
|
+
readonly [sliderAttrs.thumb]: "";
|
|
131
132
|
readonly role: "slider";
|
|
132
133
|
readonly "aria-valuemin": number;
|
|
133
134
|
readonly "aria-valuemax": number;
|
|
@@ -137,27 +138,26 @@ declare class SliderMultiRootState extends SliderBaseRootState {
|
|
|
137
138
|
readonly "data-value": number | undefined;
|
|
138
139
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
139
140
|
readonly style: import("../../shared/index.js").StyleProperties;
|
|
140
|
-
readonly "data-slider-thumb": "";
|
|
141
141
|
}[];
|
|
142
|
-
thumbsRenderArr: number[];
|
|
143
|
-
ticksPropsArr: {
|
|
142
|
+
readonly thumbsRenderArr: number[];
|
|
143
|
+
readonly ticksPropsArr: {
|
|
144
|
+
readonly [sliderAttrs.tick]: "";
|
|
144
145
|
readonly "data-disabled": "" | undefined;
|
|
145
146
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
146
147
|
readonly "data-bounded": "" | undefined;
|
|
147
148
|
readonly "data-value": number;
|
|
148
149
|
readonly style: import("../../shared/index.js").StyleProperties;
|
|
149
|
-
readonly "data-slider-tick": "";
|
|
150
150
|
}[];
|
|
151
|
-
ticksRenderArr: number[];
|
|
152
|
-
tickItemsArr: {
|
|
151
|
+
readonly ticksRenderArr: number[];
|
|
152
|
+
readonly tickItemsArr: {
|
|
153
153
|
value: number;
|
|
154
154
|
index: number;
|
|
155
155
|
}[];
|
|
156
|
-
thumbItemsArr: {
|
|
156
|
+
readonly thumbItemsArr: {
|
|
157
157
|
value: number;
|
|
158
158
|
index: number;
|
|
159
159
|
}[];
|
|
160
|
-
snippetProps: {
|
|
160
|
+
readonly snippetProps: {
|
|
161
161
|
readonly ticks: number[];
|
|
162
162
|
readonly thumbs: number[];
|
|
163
163
|
readonly tickItems: {
|
|
@@ -175,7 +175,7 @@ declare class SliderRangeState {
|
|
|
175
175
|
readonly opts: SliderRangeStateProps;
|
|
176
176
|
readonly root: SliderRootState;
|
|
177
177
|
constructor(opts: SliderRangeStateProps, root: SliderRootState);
|
|
178
|
-
rangeStyles: {
|
|
178
|
+
readonly rangeStyles: {
|
|
179
179
|
accentColor?: import("csstype").Property.AccentColor | undefined;
|
|
180
180
|
alignContent?: import("csstype").Property.AlignContent | undefined;
|
|
181
181
|
alignItems?: import("csstype").Property.AlignItems | undefined;
|
|
@@ -1002,7 +1002,7 @@ declare class SliderRangeState {
|
|
|
1002
1002
|
textAnchor?: import("csstype").Property.TextAnchor | undefined;
|
|
1003
1003
|
vectorEffect?: import("csstype").Property.VectorEffect | undefined;
|
|
1004
1004
|
};
|
|
1005
|
-
props: {
|
|
1005
|
+
readonly props: {
|
|
1006
1006
|
readonly id: string;
|
|
1007
1007
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
1008
1008
|
readonly "data-disabled": "" | undefined;
|
|
@@ -1833,7 +1833,6 @@ declare class SliderRangeState {
|
|
|
1833
1833
|
textAnchor?: import("csstype").Property.TextAnchor | undefined;
|
|
1834
1834
|
vectorEffect?: import("csstype").Property.VectorEffect | undefined;
|
|
1835
1835
|
};
|
|
1836
|
-
readonly "data-slider-range": "";
|
|
1837
1836
|
};
|
|
1838
1837
|
}
|
|
1839
1838
|
type SliderThumbStateProps = WithRefProps & ReadableBoxedValues<{
|
|
@@ -1846,7 +1845,7 @@ declare class SliderThumbState {
|
|
|
1846
1845
|
readonly root: SliderRootState;
|
|
1847
1846
|
constructor(opts: SliderThumbStateProps, root: SliderRootState);
|
|
1848
1847
|
onkeydown(e: BitsKeyboardEvent): void;
|
|
1849
|
-
props: {
|
|
1848
|
+
readonly props: {
|
|
1850
1849
|
readonly id: string;
|
|
1851
1850
|
readonly onkeydown: (e: BitsKeyboardEvent) => void;
|
|
1852
1851
|
readonly "data-active": "" | undefined;
|
|
@@ -1861,7 +1860,6 @@ declare class SliderThumbState {
|
|
|
1861
1860
|
readonly "data-value": number;
|
|
1862
1861
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
1863
1862
|
readonly style: import("../../shared/index.js").StyleProperties;
|
|
1864
|
-
readonly "data-slider-thumb": "";
|
|
1865
1863
|
} | {
|
|
1866
1864
|
readonly id: string;
|
|
1867
1865
|
readonly onkeydown: (e: BitsKeyboardEvent) => void;
|
|
@@ -1877,7 +1875,6 @@ declare class SliderThumbState {
|
|
|
1877
1875
|
readonly "data-value": number | undefined;
|
|
1878
1876
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
1879
1877
|
readonly style: import("../../shared/index.js").StyleProperties;
|
|
1880
|
-
readonly "data-slider-thumb": "";
|
|
1881
1878
|
};
|
|
1882
1879
|
}
|
|
1883
1880
|
type SliderTickStateProps = WithRefProps & ReadableBoxedValues<{
|
|
@@ -1887,7 +1884,7 @@ declare class SliderTickState {
|
|
|
1887
1884
|
readonly opts: SliderTickStateProps;
|
|
1888
1885
|
readonly root: SliderRootState;
|
|
1889
1886
|
constructor(opts: SliderTickStateProps, root: SliderRootState);
|
|
1890
|
-
props: {
|
|
1887
|
+
readonly props: {
|
|
1891
1888
|
readonly id: string;
|
|
1892
1889
|
readonly "data-disabled": "" | undefined;
|
|
1893
1890
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
@@ -1895,7 +1892,6 @@ declare class SliderTickState {
|
|
|
1895
1892
|
readonly "data-value": number;
|
|
1896
1893
|
readonly "data-selected": "" | undefined;
|
|
1897
1894
|
readonly style: import("../../shared/index.js").StyleProperties;
|
|
1898
|
-
readonly "data-slider-tick": "";
|
|
1899
1895
|
} | {
|
|
1900
1896
|
readonly id: string;
|
|
1901
1897
|
readonly "data-disabled": "" | undefined;
|
|
@@ -1903,7 +1899,6 @@ declare class SliderTickState {
|
|
|
1903
1899
|
readonly "data-bounded": "" | undefined;
|
|
1904
1900
|
readonly "data-value": number;
|
|
1905
1901
|
readonly style: import("../../shared/index.js").StyleProperties;
|
|
1906
|
-
readonly "data-slider-tick": "";
|
|
1907
1902
|
};
|
|
1908
1903
|
}
|
|
1909
1904
|
type SliderTickLabelStateProps = WithRefProps & ReadableBoxedValues<{
|
|
@@ -1914,7 +1909,7 @@ declare class SliderTickLabelState {
|
|
|
1914
1909
|
readonly opts: SliderTickLabelStateProps;
|
|
1915
1910
|
readonly root: SliderRootState;
|
|
1916
1911
|
constructor(opts: SliderTickLabelStateProps, root: SliderRootState);
|
|
1917
|
-
props: {
|
|
1912
|
+
readonly props: {
|
|
1918
1913
|
readonly id: string;
|
|
1919
1914
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
1920
1915
|
readonly "data-disabled": "" | undefined;
|
|
@@ -1923,7 +1918,6 @@ declare class SliderTickLabelState {
|
|
|
1923
1918
|
readonly "data-selected": "" | undefined;
|
|
1924
1919
|
readonly "data-position": SliderLabelPosition;
|
|
1925
1920
|
readonly style: import("../../shared/index.js").StyleProperties;
|
|
1926
|
-
readonly "data-slider-tick-label": "";
|
|
1927
1921
|
};
|
|
1928
1922
|
}
|
|
1929
1923
|
type SliderThumbLabelStateProps = WithRefProps & ReadableBoxedValues<{
|
|
@@ -1942,7 +1936,6 @@ declare class SliderThumbLabelState {
|
|
|
1942
1936
|
readonly "data-active": "" | undefined;
|
|
1943
1937
|
readonly "data-position": SliderLabelPosition;
|
|
1944
1938
|
readonly style: import("../../shared/index.js").StyleProperties;
|
|
1945
|
-
readonly "data-slider-thumb-label": "";
|
|
1946
1939
|
};
|
|
1947
1940
|
}
|
|
1948
1941
|
type SliderRootState = SliderSingleRootState | SliderMultiRootState;
|