bits-ui 1.0.0-next.21 → 1.0.0-next.22
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/checkbox/checkbox.svelte.d.ts +1 -2
- package/dist/bits/checkbox/checkbox.svelte.js +2 -13
- package/dist/bits/dialog/dialog.svelte.js +6 -0
- package/dist/bits/switch/switch.svelte.d.ts +1 -2
- package/dist/bits/switch/switch.svelte.js +2 -13
- package/dist/bits/toggle/toggle.svelte.d.ts +1 -3
- package/dist/bits/toggle/toggle.svelte.js +2 -22
- package/dist/bits/toggle-group/toggle-group.svelte.d.ts +1 -2
- package/dist/bits/toggle-group/toggle-group.svelte.js +3 -14
- package/package.json +1 -1
|
@@ -26,8 +26,7 @@ declare class CheckboxRootState {
|
|
|
26
26
|
readonly "data-disabled": "" | undefined;
|
|
27
27
|
readonly "data-state": "checked" | "indeterminate" | "unchecked";
|
|
28
28
|
readonly "data-checkbox-root": "";
|
|
29
|
-
readonly
|
|
30
|
-
readonly onpointerup: (e: PointerEvent) => void;
|
|
29
|
+
readonly onclick: () => void;
|
|
31
30
|
readonly onkeydown: (e: KeyboardEvent) => void;
|
|
32
31
|
};
|
|
33
32
|
}
|
|
@@ -42,21 +42,11 @@ class CheckboxRootState {
|
|
|
42
42
|
this.checked.current = !this.checked.current;
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
#
|
|
45
|
+
#onclick = () => {
|
|
46
46
|
if (this.disabled.current)
|
|
47
47
|
return;
|
|
48
|
-
if (e.pointerType === "touch" || e.button !== 0)
|
|
49
|
-
return e.preventDefault();
|
|
50
48
|
this.#toggle();
|
|
51
49
|
};
|
|
52
|
-
#onpointerup = (e) => {
|
|
53
|
-
if (this.disabled.current)
|
|
54
|
-
return;
|
|
55
|
-
if (e.pointerType === "touch") {
|
|
56
|
-
e.preventDefault();
|
|
57
|
-
this.#toggle();
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
50
|
props = $derived.by(() => ({
|
|
61
51
|
id: this.#id.current,
|
|
62
52
|
role: "checkbox",
|
|
@@ -68,8 +58,7 @@ class CheckboxRootState {
|
|
|
68
58
|
"data-state": getCheckboxDataState(this.checked.current),
|
|
69
59
|
[CHECKBOX_ROOT_ATTR]: "",
|
|
70
60
|
//
|
|
71
|
-
|
|
72
|
-
onpointerup: this.#onpointerup,
|
|
61
|
+
onclick: this.#onclick,
|
|
73
62
|
onkeydown: this.#onkeydown,
|
|
74
63
|
}));
|
|
75
64
|
}
|
|
@@ -69,6 +69,8 @@ class DialogTriggerState {
|
|
|
69
69
|
return;
|
|
70
70
|
if (e.pointerType === "touch")
|
|
71
71
|
return e.preventDefault();
|
|
72
|
+
if (e.button > 0)
|
|
73
|
+
return;
|
|
72
74
|
// by default, it will attempt to focus this trigger on pointerdown
|
|
73
75
|
// since this also opens the dialog we want to prevent that behavior
|
|
74
76
|
e.preventDefault();
|
|
@@ -126,6 +128,8 @@ class DialogCloseState {
|
|
|
126
128
|
return;
|
|
127
129
|
if (e.pointerType === "touch")
|
|
128
130
|
return e.preventDefault();
|
|
131
|
+
if (e.button > 0)
|
|
132
|
+
return;
|
|
129
133
|
this.#root.handleClose();
|
|
130
134
|
};
|
|
131
135
|
#onpointerup = (e) => {
|
|
@@ -298,6 +302,8 @@ class AlertDialogCancelState {
|
|
|
298
302
|
return;
|
|
299
303
|
if (e.pointerType === "touch")
|
|
300
304
|
return e.preventDefault();
|
|
305
|
+
if (e.button > 0)
|
|
306
|
+
return;
|
|
301
307
|
this.#root.handleClose();
|
|
302
308
|
};
|
|
303
309
|
#onkeydown = (e) => {
|
|
@@ -28,8 +28,7 @@ declare class SwitchRootState {
|
|
|
28
28
|
readonly "aria-checked": "true" | "false" | "mixed";
|
|
29
29
|
readonly "aria-required": "true" | "false";
|
|
30
30
|
readonly "data-switch-root": "";
|
|
31
|
-
readonly
|
|
32
|
-
readonly onpointerup: (e: PointerEvent) => void;
|
|
31
|
+
readonly onclick: (e: PointerEvent) => void;
|
|
33
32
|
readonly onkeydown: (e: KeyboardEvent) => void;
|
|
34
33
|
readonly "data-disabled": "" | undefined;
|
|
35
34
|
readonly "data-state": "checked" | "unchecked";
|
|
@@ -34,19 +34,9 @@ class SwitchRootState {
|
|
|
34
34
|
e.preventDefault();
|
|
35
35
|
this.#toggle();
|
|
36
36
|
};
|
|
37
|
-
#
|
|
37
|
+
#onclick = (e) => {
|
|
38
38
|
if (this.disabled.current)
|
|
39
39
|
return;
|
|
40
|
-
if (e.pointerType === "touch") {
|
|
41
|
-
e.preventDefault();
|
|
42
|
-
this.#toggle();
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
#onpointerdown = (e) => {
|
|
46
|
-
if (this.disabled.current)
|
|
47
|
-
return;
|
|
48
|
-
if (e.pointerType === "touch")
|
|
49
|
-
return e.preventDefault();
|
|
50
40
|
this.#toggle();
|
|
51
41
|
};
|
|
52
42
|
sharedProps = $derived.by(() => ({
|
|
@@ -63,8 +53,7 @@ class SwitchRootState {
|
|
|
63
53
|
"aria-required": getAriaRequired(this.required.current),
|
|
64
54
|
[ROOT_ATTR]: "",
|
|
65
55
|
//
|
|
66
|
-
|
|
67
|
-
onpointerup: this.#onpointerup,
|
|
56
|
+
onclick: this.#onclick,
|
|
68
57
|
onkeydown: this.#onkeydown,
|
|
69
58
|
}));
|
|
70
59
|
}
|
|
@@ -15,9 +15,7 @@ declare class ToggleRootState {
|
|
|
15
15
|
readonly "aria-pressed": "true" | "false";
|
|
16
16
|
readonly "data-state": "off" | "on";
|
|
17
17
|
readonly disabled: true | undefined;
|
|
18
|
-
readonly
|
|
19
|
-
readonly onpointerup: (e: PointerEvent) => void;
|
|
20
|
-
readonly onkeydown: (e: KeyboardEvent) => void;
|
|
18
|
+
readonly onclick: () => void;
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
21
|
export declare function useToggleRoot(props: ToggleRootStateProps): ToggleRootState;
|
|
@@ -22,27 +22,9 @@ class ToggleRootState {
|
|
|
22
22
|
this.pressed.current = !this.pressed.current;
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
-
#
|
|
25
|
+
#onclick = () => {
|
|
26
26
|
if (this.#disabled.current)
|
|
27
27
|
return;
|
|
28
|
-
if (e.pointerType === "touch" || e.button !== 0)
|
|
29
|
-
return e.preventDefault();
|
|
30
|
-
this.#togglePressed();
|
|
31
|
-
};
|
|
32
|
-
#onpointerup = (e) => {
|
|
33
|
-
if (this.#disabled.current)
|
|
34
|
-
return;
|
|
35
|
-
if (e.pointerType === "touch") {
|
|
36
|
-
e.preventDefault();
|
|
37
|
-
this.#togglePressed();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
#onkeydown = (e) => {
|
|
41
|
-
if (this.#disabled.current)
|
|
42
|
-
return;
|
|
43
|
-
if (![kbd.ENTER, kbd.SPACE].includes(e.key))
|
|
44
|
-
return;
|
|
45
|
-
e.preventDefault();
|
|
46
28
|
this.#togglePressed();
|
|
47
29
|
};
|
|
48
30
|
props = $derived.by(() => ({
|
|
@@ -51,9 +33,7 @@ class ToggleRootState {
|
|
|
51
33
|
"aria-pressed": getAriaPressed(this.pressed.current),
|
|
52
34
|
"data-state": getToggleDataState(this.pressed.current),
|
|
53
35
|
disabled: getDisabled(this.#disabled.current),
|
|
54
|
-
|
|
55
|
-
onpointerup: this.#onpointerup,
|
|
56
|
-
onkeydown: this.#onkeydown,
|
|
36
|
+
onclick: this.#onclick,
|
|
57
37
|
}));
|
|
58
38
|
}
|
|
59
39
|
//
|
|
@@ -72,8 +72,7 @@ declare class ToggleGroupItemState {
|
|
|
72
72
|
readonly "aria-checked": "true" | "false" | "mixed" | undefined;
|
|
73
73
|
readonly disabled: true | undefined;
|
|
74
74
|
readonly "data-toggle-group-item": "";
|
|
75
|
-
readonly
|
|
76
|
-
readonly onpointerup: (e: PointerEvent) => void;
|
|
75
|
+
readonly onclick: () => void;
|
|
77
76
|
readonly onkeydown: (e: KeyboardEvent) => void;
|
|
78
77
|
};
|
|
79
78
|
}
|
|
@@ -104,20 +104,10 @@ class ToggleGroupItemState {
|
|
|
104
104
|
return;
|
|
105
105
|
this.#root.toggleItem(this.#value.current, this.#id.current);
|
|
106
106
|
};
|
|
107
|
-
#
|
|
107
|
+
#onclick = () => {
|
|
108
108
|
if (this.#isDisabled)
|
|
109
109
|
return;
|
|
110
|
-
|
|
111
|
-
return e.preventDefault();
|
|
112
|
-
this.toggleItem();
|
|
113
|
-
};
|
|
114
|
-
#onpointerup = (e) => {
|
|
115
|
-
if (this.#isDisabled)
|
|
116
|
-
return;
|
|
117
|
-
if (e.pointerType === "touch") {
|
|
118
|
-
e.preventDefault();
|
|
119
|
-
this.toggleItem();
|
|
120
|
-
}
|
|
110
|
+
this.#root.toggleItem(this.#value.current, this.#id.current);
|
|
121
111
|
};
|
|
122
112
|
#onkeydown = (e) => {
|
|
123
113
|
if (this.#isDisabled)
|
|
@@ -154,8 +144,7 @@ class ToggleGroupItemState {
|
|
|
154
144
|
disabled: getDisabled(this.#isDisabled),
|
|
155
145
|
[ITEM_ATTR]: "",
|
|
156
146
|
//
|
|
157
|
-
|
|
158
|
-
onpointerup: this.#onpointerup,
|
|
147
|
+
onclick: this.#onclick,
|
|
159
148
|
onkeydown: this.#onkeydown,
|
|
160
149
|
}));
|
|
161
150
|
}
|