@xds/solid 1.0.1 → 1.1.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/dom/Accordion.js +3 -2
- package/dist/dom/Avatar.js +17 -13
- package/dist/dom/AvatarStack.js +17 -13
- package/dist/dom/Badge.js +12 -10
- package/dist/dom/Banner.js +25 -15
- package/dist/dom/Button.js +10 -3
- package/dist/dom/Card.js +31 -26
- package/dist/dom/Checkbox.js +49 -24
- package/dist/dom/Chip.js +21 -17
- package/dist/dom/ChipBar.js +17 -13
- package/dist/dom/CountBadge.js +28 -23
- package/dist/dom/DatePicker.js +13 -7
- package/dist/dom/DateRangePicker.js +16 -10
- package/dist/dom/Dialog.js +3 -2
- package/dist/dom/Divider.js +12 -10
- package/dist/dom/EmptyState.js +14 -11
- package/dist/dom/Icon.js +30 -19
- package/dist/dom/IconButton.js +10 -3
- package/dist/dom/Labels.js +26 -0
- package/dist/dom/ListRow.js +34 -28
- package/dist/dom/MediaCard.js +32 -23
- package/dist/dom/Menu.js +3 -1
- package/dist/dom/ProgressBar.js +27 -15
- package/dist/dom/RadioGroup.js +44 -23
- package/dist/dom/SearchField.js +58 -32
- package/dist/dom/SectionHeader.js +17 -10
- package/dist/dom/SegmentedControl.js +33 -19
- package/dist/dom/Select.js +18 -5
- package/dist/dom/Sidebar.js +17 -13
- package/dist/dom/Skeleton.js +15 -13
- package/dist/dom/Slider.js +15 -7
- package/dist/dom/Spinner.js +23 -17
- package/dist/dom/Switch.js +49 -24
- package/dist/dom/Tabs.js +16 -6
- package/dist/dom/Text.js +6 -3
- package/dist/dom/TextField.js +37 -19
- package/dist/dom/Thumbnail.js +21 -14
- package/dist/dom/Toast.js +19 -20
- package/dist/dom/Tooltip.js +10 -6
- package/dist/dom/controllable.js +44 -0
- package/dist/dom/index.js +2 -1
- package/dist/dom/preview.js +2 -0
- package/dist/dom/root.js +16 -4
- package/dist/dom/trigger.js +5 -3
- package/dist/source/Accordion.jsx +3 -2
- package/dist/source/Avatar.d.ts +1 -1
- package/dist/source/Avatar.jsx +2 -1
- package/dist/source/AvatarStack.d.ts +1 -1
- package/dist/source/AvatarStack.jsx +2 -1
- package/dist/source/Badge.d.ts +1 -1
- package/dist/source/Badge.jsx +2 -1
- package/dist/source/Banner.d.ts +1 -1
- package/dist/source/Banner.jsx +5 -2
- package/dist/source/Button.d.ts +5 -1
- package/dist/source/Button.jsx +5 -2
- package/dist/source/Card.d.ts +1 -1
- package/dist/source/Card.jsx +3 -2
- package/dist/source/Checkbox.d.ts +10 -4
- package/dist/source/Checkbox.jsx +18 -6
- package/dist/source/Chip.d.ts +1 -1
- package/dist/source/Chip.jsx +2 -1
- package/dist/source/ChipBar.d.ts +1 -1
- package/dist/source/ChipBar.jsx +2 -1
- package/dist/source/CountBadge.d.ts +1 -1
- package/dist/source/CountBadge.jsx +3 -2
- package/dist/source/DatePicker.jsx +13 -7
- package/dist/source/DateRangePicker.jsx +16 -10
- package/dist/source/Dialog.jsx +3 -2
- package/dist/source/Divider.d.ts +1 -1
- package/dist/source/Divider.jsx +2 -1
- package/dist/source/EmptyState.d.ts +1 -1
- package/dist/source/EmptyState.jsx +2 -1
- package/dist/source/Icon.d.ts +1 -1
- package/dist/source/Icon.jsx +2 -1
- package/dist/source/IconButton.d.ts +5 -1
- package/dist/source/IconButton.jsx +5 -2
- package/dist/source/Labels.d.ts +17 -0
- package/dist/source/Labels.jsx +11 -0
- package/dist/source/ListRow.d.ts +1 -1
- package/dist/source/ListRow.jsx +3 -2
- package/dist/source/MediaCard.d.ts +1 -1
- package/dist/source/MediaCard.jsx +3 -2
- package/dist/source/Menu.d.ts +1 -1
- package/dist/source/Menu.jsx +3 -1
- package/dist/source/ProgressBar.d.ts +1 -1
- package/dist/source/ProgressBar.jsx +2 -1
- package/dist/source/RadioGroup.d.ts +5 -2
- package/dist/source/RadioGroup.jsx +18 -5
- package/dist/source/SearchField.d.ts +11 -3
- package/dist/source/SearchField.jsx +26 -12
- package/dist/source/SectionHeader.d.ts +1 -1
- package/dist/source/SectionHeader.jsx +2 -1
- package/dist/source/SegmentedControl.d.ts +4 -3
- package/dist/source/SegmentedControl.jsx +16 -5
- package/dist/source/Select.d.ts +4 -1
- package/dist/source/Select.jsx +16 -5
- package/dist/source/Sidebar.d.ts +1 -1
- package/dist/source/Sidebar.jsx +2 -1
- package/dist/source/Skeleton.jsx +2 -2
- package/dist/source/Slider.d.ts +2 -2
- package/dist/source/Slider.jsx +14 -6
- package/dist/source/Spinner.d.ts +1 -1
- package/dist/source/Spinner.jsx +2 -1
- package/dist/source/Switch.d.ts +10 -4
- package/dist/source/Switch.jsx +18 -6
- package/dist/source/Tabs.d.ts +2 -2
- package/dist/source/Tabs.jsx +16 -5
- package/dist/source/Text.d.ts +1 -1
- package/dist/source/Text.jsx +2 -1
- package/dist/source/TextField.d.ts +12 -3
- package/dist/source/TextField.jsx +24 -9
- package/dist/source/Thumbnail.d.ts +1 -1
- package/dist/source/Thumbnail.jsx +2 -1
- package/dist/source/Toast.d.ts +1 -1
- package/dist/source/Toast.jsx +2 -1
- package/dist/source/Tooltip.jsx +4 -3
- package/dist/source/controllable.d.ts +30 -0
- package/dist/source/controllable.js +30 -0
- package/dist/source/index.d.ts +1 -0
- package/dist/source/index.js +1 -0
- package/dist/source/preview.jsx +2 -1
- package/dist/source/root.d.ts +14 -4
- package/dist/source/root.js +7 -2
- package/dist/source/trigger.d.ts +4 -2
- package/dist/source/trigger.js +2 -2
- package/package.json +3 -3
- package/styles.css +4 -0
- package/tailwind.css +1 -1
package/dist/dom/SearchField.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { composeRefs, createControllable, resetWithForm } from "./controllable.js";
|
|
1
2
|
import { keepValue } from "./controlled.js";
|
|
2
3
|
import { Icon } from "./Icon.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { useLabels } from "./Labels.js";
|
|
5
|
+
import { rootAttributes } from "./root.js";
|
|
6
|
+
import { createComponent, delegateEvents, effect, insert, ref, setAttribute, spread, template } from "@solidjs/web";
|
|
7
|
+
import { classes, isControlled, rootPart } from "@xds/core";
|
|
5
8
|
import { Show } from "solid-js";
|
|
6
9
|
// packages/ui-solid/src/SearchField.tsx
|
|
7
10
|
var _tmpl$ = /* @__PURE__ */ template(`<span class="xds-text-field__slot xds-text-field__slot--trailing"><button type=button class="-me-1 flex size-xds-target-min cursor-pointer items-center justify-center rounded-xds-full hover:text-xds-field-text focus-visible:outline-(length:--xds-focus-width) focus-visible:outline-xds-border-focus focus-visible:outline-solid">`);
|
|
@@ -13,13 +16,37 @@ var ROOT = rootPart("SearchField");
|
|
|
13
16
|
*
|
|
14
17
|
* Use it to filter or search what is on the screen. For a value that is saved with a form,
|
|
15
18
|
* use a TextField, which has a visible label.
|
|
19
|
+
*
|
|
20
|
+
* Without `value` it keeps its own query, from `defaultValue`. A read-only one has no control
|
|
21
|
+
* that clears it, and Escape leaves it as it is.
|
|
16
22
|
*/
|
|
17
23
|
function SearchField(props) {
|
|
24
|
+
const labels = useLabels();
|
|
18
25
|
let input;
|
|
26
|
+
const controlled = () => isControlled(props, "value");
|
|
27
|
+
const defaultValue = () => props.defaultValue ?? "";
|
|
28
|
+
const value = createControllable({
|
|
29
|
+
controlled,
|
|
30
|
+
value: () => props.value ?? "",
|
|
31
|
+
defaultValue,
|
|
32
|
+
onChange: (next) => props.onChange?.(next)
|
|
33
|
+
});
|
|
34
|
+
resetWithForm(() => input, controlled, value.reset);
|
|
35
|
+
const clearable = () => value.value() !== "" && !props.disabled && !props.readOnly;
|
|
19
36
|
var _el$ = _tmpl$2();
|
|
20
37
|
var _el$2 = _el$.firstChild;
|
|
21
38
|
var _el$3 = _el$2.firstChild;
|
|
22
39
|
var _el$4 = _el$3.nextSibling;
|
|
40
|
+
spread(_el$, [() => {
|
|
41
|
+
return rootAttributes(props);
|
|
42
|
+
}, {
|
|
43
|
+
get "class"() {
|
|
44
|
+
return classes("xds-text-field", ROOT, props.class);
|
|
45
|
+
},
|
|
46
|
+
get style() {
|
|
47
|
+
return props.style;
|
|
48
|
+
}
|
|
49
|
+
}], true);
|
|
23
50
|
insert(_el$3, createComponent(Icon, {
|
|
24
51
|
name: "search",
|
|
25
52
|
size: "sm"
|
|
@@ -28,39 +55,40 @@ function SearchField(props) {
|
|
|
28
55
|
if (event.isComposing) return;
|
|
29
56
|
if (event.key === "Enter" && props.onSubmit) {
|
|
30
57
|
event.preventDefault();
|
|
31
|
-
props.onSubmit(
|
|
58
|
+
props.onSubmit(value.value());
|
|
32
59
|
}
|
|
33
|
-
if (event.key === "Escape" &&
|
|
60
|
+
if (event.key === "Escape" && clearable()) {
|
|
34
61
|
event.stopPropagation();
|
|
35
|
-
|
|
62
|
+
value.set("");
|
|
36
63
|
}
|
|
37
64
|
};
|
|
38
|
-
_el$4.addEventListener("
|
|
65
|
+
_el$4.addEventListener("blur", (event) => props.onBlur?.(event));
|
|
66
|
+
_el$4.addEventListener("focus", (event) => props.onFocus?.(event));
|
|
67
|
+
_el$4.addEventListener("compositionend", (event) => keepValue(event.currentTarget, value.value));
|
|
39
68
|
_el$4._$$input = (event) => {
|
|
40
|
-
|
|
41
|
-
if (!event.isComposing) keepValue(event.currentTarget,
|
|
69
|
+
value.set(event.currentTarget.value);
|
|
70
|
+
if (!event.isComposing) keepValue(event.currentTarget, value.value);
|
|
42
71
|
};
|
|
43
|
-
|
|
44
|
-
|
|
72
|
+
var _ref$ = composeRefs((element) => input = element, () => props.ref);
|
|
73
|
+
(typeof _ref$ === "function" || Array.isArray(_ref$)) && ref(() => {
|
|
74
|
+
return _ref$;
|
|
45
75
|
}, _el$4);
|
|
46
76
|
insert(_el$2, createComponent(Show, {
|
|
47
77
|
get when() {
|
|
48
|
-
return
|
|
49
|
-
return props.value !== "";
|
|
50
|
-
})() && !props.disabled;
|
|
78
|
+
return clearable();
|
|
51
79
|
},
|
|
52
80
|
get children() {
|
|
53
81
|
var _el$5 = _tmpl$();
|
|
54
82
|
var _el$6 = _el$5.firstChild;
|
|
55
83
|
_el$6._$$click = () => {
|
|
56
|
-
|
|
84
|
+
value.set("");
|
|
57
85
|
input.focus();
|
|
58
86
|
};
|
|
59
87
|
insert(_el$6, createComponent(Icon, {
|
|
60
88
|
name: "circle-x",
|
|
61
89
|
size: "sm"
|
|
62
90
|
}));
|
|
63
|
-
effect(() => props.clearLabel ??
|
|
91
|
+
effect(() => props.clearLabel ?? labels().clear, (_v$) => {
|
|
64
92
|
setAttribute(_el$6, "aria-label", _v$);
|
|
65
93
|
});
|
|
66
94
|
return _el$5;
|
|
@@ -68,24 +96,22 @@ function SearchField(props) {
|
|
|
68
96
|
}), null);
|
|
69
97
|
effect(() => {
|
|
70
98
|
return {
|
|
71
|
-
e:
|
|
72
|
-
t:
|
|
73
|
-
a:
|
|
74
|
-
o:
|
|
75
|
-
i: props.
|
|
76
|
-
n: props.
|
|
77
|
-
s:
|
|
78
|
-
h: props.value !== "" ? "" : void 0
|
|
99
|
+
e: props.label,
|
|
100
|
+
t: props.placeholder,
|
|
101
|
+
a: value.value(),
|
|
102
|
+
o: controlled() ? value.value() : defaultValue(),
|
|
103
|
+
i: props.disabled,
|
|
104
|
+
n: props.readOnly,
|
|
105
|
+
s: clearable() ? "" : void 0
|
|
79
106
|
};
|
|
80
|
-
}, ({ e, t, a, o, i, n, s
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
o !== _p$?.o &&
|
|
85
|
-
|
|
86
|
-
n !== _p$?.n && (_el$4
|
|
87
|
-
s !== _p$?.s && setAttribute(_el$4, "
|
|
88
|
-
h !== _p$?.h && setAttribute(_el$4, "data-uses-escape", h);
|
|
107
|
+
}, ({ e, t, a, o, i, n, s }, _p$) => {
|
|
108
|
+
e !== _p$?.e && setAttribute(_el$4, "aria-label", e);
|
|
109
|
+
t !== _p$?.t && setAttribute(_el$4, "placeholder", t);
|
|
110
|
+
_el$4.value = a ?? "";
|
|
111
|
+
o !== _p$?.o && (_el$4.defaultValue = o ?? "");
|
|
112
|
+
i !== _p$?.i && setAttribute(_el$4, "disabled", i);
|
|
113
|
+
n !== _p$?.n && setAttribute(_el$4, "readonly", n);
|
|
114
|
+
s !== _p$?.s && setAttribute(_el$4, "data-uses-escape", s);
|
|
89
115
|
});
|
|
90
116
|
return _el$;
|
|
91
117
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Button } from "./Button.js";
|
|
2
2
|
import { Icon } from "./Icon.js";
|
|
3
|
-
import {
|
|
3
|
+
import { rootAttributes } from "./root.js";
|
|
4
|
+
import { className, createComponent, dynamic, effect, insert, memo, readShallow, spread, template } from "@solidjs/web";
|
|
4
5
|
import { SECTION_HEADER_PARTS, classes, rootPart } from "@xds/core";
|
|
5
6
|
import { Show } from "solid-js";
|
|
6
7
|
// packages/ui-solid/src/SectionHeader.tsx
|
|
@@ -19,6 +20,16 @@ function SectionHeader(props) {
|
|
|
19
20
|
var _el$3 = _el$2.firstChild;
|
|
20
21
|
var _el$4 = _el$3.firstChild;
|
|
21
22
|
var _el$5 = _el$4.nextSibling;
|
|
23
|
+
spread(_el$, [() => {
|
|
24
|
+
return rootAttributes(props);
|
|
25
|
+
}, {
|
|
26
|
+
get "class"() {
|
|
27
|
+
return classes(ROOT, SECTION_HEADER_PARTS.root, props.class);
|
|
28
|
+
},
|
|
29
|
+
get style() {
|
|
30
|
+
return props.style;
|
|
31
|
+
}
|
|
32
|
+
}], true);
|
|
22
33
|
insert(_el$2, createComponent(Show, {
|
|
23
34
|
get when() {
|
|
24
35
|
return props.icon;
|
|
@@ -88,16 +99,12 @@ function SectionHeader(props) {
|
|
|
88
99
|
}), null);
|
|
89
100
|
effect(() => {
|
|
90
101
|
return {
|
|
91
|
-
e: readShallow(
|
|
92
|
-
t: readShallow(
|
|
93
|
-
a: readShallow(SECTION_HEADER_PARTS.lead),
|
|
94
|
-
o: readShallow(SECTION_HEADER_PARTS.text)
|
|
102
|
+
e: readShallow(SECTION_HEADER_PARTS.lead),
|
|
103
|
+
t: readShallow(SECTION_HEADER_PARTS.text)
|
|
95
104
|
};
|
|
96
|
-
}, ({ e, t
|
|
97
|
-
className(_el
|
|
98
|
-
|
|
99
|
-
className(_el$2, a, _p$?.a);
|
|
100
|
-
className(_el$3, o, _p$?.o);
|
|
105
|
+
}, ({ e, t }, _p$) => {
|
|
106
|
+
className(_el$2, e, _p$?.e);
|
|
107
|
+
className(_el$3, t, _p$?.t);
|
|
101
108
|
});
|
|
102
109
|
return _el$;
|
|
103
110
|
}
|
|
@@ -1,21 +1,46 @@
|
|
|
1
|
+
import { createControllable } from "./controllable.js";
|
|
1
2
|
import { keepChecked } from "./controlled.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
3
|
+
import { rootAttributes } from "./root.js";
|
|
4
|
+
import { className, createComponent, effect, insert, readShallow, ref, setAttribute, setProperty, spread, template } from "@solidjs/web";
|
|
5
|
+
import { classes, isControlled, rootPart, segmentedControlClass, segmentedControlOptionClass, segmentedControlSegmentClass } from "@xds/core";
|
|
4
6
|
import { For, createUniqueId } from "solid-js";
|
|
5
7
|
// packages/ui-solid/src/SegmentedControl.tsx
|
|
6
|
-
var _tmpl$ = /* @__PURE__ */ template(`<div
|
|
8
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div>`);
|
|
7
9
|
var _tmpl$2 = /* @__PURE__ */ template(`<label><input type=radio class="peer sr-only"><span>`);
|
|
8
10
|
var ROOT = rootPart("SegmentedControl");
|
|
9
11
|
/**
|
|
10
12
|
* A choice between a few views or modes, all visible at once. The selected segment is outlined
|
|
11
13
|
* as well as filled, so the choice does not depend on telling two greys apart.
|
|
12
14
|
*
|
|
13
|
-
* It is a group of native radio buttons, so the arrow keys move between segments.
|
|
15
|
+
* It is a group of native radio buttons, so the arrow keys move between segments. Without
|
|
16
|
+
* `value` it keeps its own choice, from `defaultValue`, or the first segment.
|
|
14
17
|
*/
|
|
15
18
|
function SegmentedControl(props) {
|
|
16
19
|
const name = createUniqueId();
|
|
17
20
|
let group;
|
|
21
|
+
const value = createControllable({
|
|
22
|
+
controlled: () => isControlled(props, "value"),
|
|
23
|
+
value: () => props.value,
|
|
24
|
+
defaultValue: () => props.defaultValue ?? props.options[0]?.value,
|
|
25
|
+
onChange: (next) => {
|
|
26
|
+
if (next !== void 0) props.onChange?.(next);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
18
29
|
var _el$ = _tmpl$();
|
|
30
|
+
spread(_el$, [() => {
|
|
31
|
+
return rootAttributes(props);
|
|
32
|
+
}, {
|
|
33
|
+
get "aria-label"() {
|
|
34
|
+
return props["aria-label"];
|
|
35
|
+
},
|
|
36
|
+
role: "radiogroup",
|
|
37
|
+
get "class"() {
|
|
38
|
+
return classes(ROOT, segmentedControlClass(props.fullWidth), props.class);
|
|
39
|
+
},
|
|
40
|
+
get style() {
|
|
41
|
+
return props.style;
|
|
42
|
+
}
|
|
43
|
+
}], true);
|
|
19
44
|
ref(() => {
|
|
20
45
|
return (element) => group = element;
|
|
21
46
|
}, _el$);
|
|
@@ -28,8 +53,8 @@ function SegmentedControl(props) {
|
|
|
28
53
|
var _el$3 = _el$2.firstChild;
|
|
29
54
|
var _el$4 = _el$3.nextSibling;
|
|
30
55
|
_el$3.addEventListener("change", () => {
|
|
31
|
-
|
|
32
|
-
for (const input of group.querySelectorAll("input")) keepChecked(input, () => input.value ===
|
|
56
|
+
value.set(option.value);
|
|
57
|
+
for (const input of group.querySelectorAll("input")) keepChecked(input, () => input.value === value.value());
|
|
33
58
|
});
|
|
34
59
|
setAttribute(_el$3, "name", name);
|
|
35
60
|
insert(_el$4, () => {
|
|
@@ -39,8 +64,8 @@ function SegmentedControl(props) {
|
|
|
39
64
|
return {
|
|
40
65
|
e: readShallow(segmentedControlOptionClass(props.fullWidth)),
|
|
41
66
|
t: option.value,
|
|
42
|
-
a: option.value ===
|
|
43
|
-
o: option.value ===
|
|
67
|
+
a: option.value === value.value(),
|
|
68
|
+
o: option.value === value.value(),
|
|
44
69
|
i: readShallow(segmentedControlSegmentClass)
|
|
45
70
|
};
|
|
46
71
|
}, ({ e, t, a, o, i }, _p$) => {
|
|
@@ -53,17 +78,6 @@ function SegmentedControl(props) {
|
|
|
53
78
|
return _el$2;
|
|
54
79
|
})()
|
|
55
80
|
}));
|
|
56
|
-
effect(() => {
|
|
57
|
-
return {
|
|
58
|
-
e: props["aria-label"],
|
|
59
|
-
t: readShallow(classes(ROOT, segmentedControlClass(props.fullWidth), props.class)),
|
|
60
|
-
a: readShallow(props.style)
|
|
61
|
-
};
|
|
62
|
-
}, ({ e, t, a }, _p$) => {
|
|
63
|
-
e !== _p$?.e && setAttribute(_el$, "aria-label", e);
|
|
64
|
-
className(_el$, t, _p$?.t);
|
|
65
|
-
style(_el$, a, _p$?.a);
|
|
66
|
-
});
|
|
67
81
|
return _el$;
|
|
68
82
|
}
|
|
69
83
|
export { SegmentedControl };
|
package/dist/dom/Select.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { createControllable } from "./controllable.js";
|
|
1
2
|
import { Icon } from "./Icon.js";
|
|
2
3
|
import { modalPopover } from "./modal-popover.js";
|
|
3
4
|
import { Portal as Portal$1 } from "./portal.js";
|
|
4
5
|
import { createPresence } from "./presence.js";
|
|
5
|
-
import { withStyle } from "./root.js";
|
|
6
|
+
import { rootAttributes, withStyle } from "./root.js";
|
|
6
7
|
import { createComponent, delegateEvents, effect, insert, memo, readShallow, ref, setAttribute, spread, style, template } from "@solidjs/web";
|
|
7
|
-
import { classes, keepListKeys, readCssPx, selectOptionIds, underlayLayerStyle } from "@xds/core";
|
|
8
|
+
import { classes, isControlled, keepListKeys, readCssPx, selectOptionIds, underlayLayerStyle } from "@xds/core";
|
|
8
9
|
import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
|
|
9
10
|
import { For, Show, createMemo, createUniqueId } from "solid-js";
|
|
10
11
|
import { space } from "@xds/tokens";
|
|
@@ -26,6 +27,9 @@ var _tmpl$7 = /* @__PURE__ */ template(`<div><span class=xds-select__item-words>
|
|
|
26
27
|
* The field is a button that says it opens a list box and whether the list is open. In the list
|
|
27
28
|
* the arrow keys move, typing jumps to an option, and Enter chooses. The chosen option is
|
|
28
29
|
* selected for assistive technology and marked with a check.
|
|
30
|
+
*
|
|
31
|
+
* Without `value` it keeps its own choice, from `defaultValue`. Given `value`, even as
|
|
32
|
+
* `undefined`, it shows that.
|
|
29
33
|
*/
|
|
30
34
|
function Select(props) {
|
|
31
35
|
const id = createUniqueId();
|
|
@@ -33,6 +37,14 @@ function Select(props) {
|
|
|
33
37
|
const descriptionId = `${id}-description`;
|
|
34
38
|
const errorId = `${id}-error`;
|
|
35
39
|
const invalid = () => props.error !== void 0;
|
|
40
|
+
const value = createControllable({
|
|
41
|
+
controlled: () => isControlled(props, "value"),
|
|
42
|
+
value: () => props.value,
|
|
43
|
+
defaultValue: () => props.defaultValue,
|
|
44
|
+
onChange: (next) => {
|
|
45
|
+
if (next !== void 0) props.onChange?.(next);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
36
48
|
const collection = createMemo(() => select.collection({
|
|
37
49
|
items: [...props.options],
|
|
38
50
|
itemToValue: (option) => option.value,
|
|
@@ -40,11 +52,12 @@ function Select(props) {
|
|
|
40
52
|
}));
|
|
41
53
|
const service = useMachine(select.machine, () => ({
|
|
42
54
|
id,
|
|
55
|
+
ids: { root: props.id },
|
|
43
56
|
collection: collection(),
|
|
44
|
-
value:
|
|
57
|
+
value: value.value() === void 0 ? [] : [value.value()],
|
|
45
58
|
onValueChange: (details) => {
|
|
46
59
|
const next = details.value[0];
|
|
47
|
-
if (next !== void 0)
|
|
60
|
+
if (next !== void 0) value.set(next);
|
|
48
61
|
},
|
|
49
62
|
disabled: props.disabled,
|
|
50
63
|
invalid: invalid(),
|
|
@@ -57,7 +70,7 @@ function Select(props) {
|
|
|
57
70
|
}
|
|
58
71
|
}));
|
|
59
72
|
const api = createMemo(() => select.connect(service, normalizeProps));
|
|
60
|
-
const root = withStyle(() => api().getRootProps(), () => props.style);
|
|
73
|
+
const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
|
|
61
74
|
const current = () => select.connect(service, normalizeProps);
|
|
62
75
|
const labelProps = createMemo(() => {
|
|
63
76
|
const { for: _, ...rest } = api().getLabelProps();
|
package/dist/dom/Sidebar.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Icon } from "./Icon.js";
|
|
2
2
|
import { PlaceRow } from "./ListRow.js";
|
|
3
|
+
import { rootAttributes } from "./root.js";
|
|
3
4
|
import { TooltipBeside } from "./Tooltip.js";
|
|
4
5
|
import { withTrigger } from "./trigger.js";
|
|
5
|
-
import { className, createComponent, effect, insert, memo, readShallow, setAttribute, spread,
|
|
6
|
+
import { className, createComponent, effect, insert, memo, readShallow, setAttribute, spread, template } from "@solidjs/web";
|
|
6
7
|
import { SIDEBAR_PARTS, classes, rootPart, sidebarClass, sidebarCount, sidebarIconClass, sidebarRailButtonClass, sidebarSectionClass, sidebarTitleClass } from "@xds/core";
|
|
7
8
|
import { For, Show, createMemo, createUniqueId } from "solid-js";
|
|
8
9
|
// packages/ui-solid/src/Sidebar.tsx
|
|
@@ -30,6 +31,19 @@ function Sidebar(props) {
|
|
|
30
31
|
var _el$ = _tmpl$();
|
|
31
32
|
var _el$2 = _el$.firstChild;
|
|
32
33
|
var _el$3 = _el$2.nextSibling;
|
|
34
|
+
spread(_el$, [() => {
|
|
35
|
+
return rootAttributes(props);
|
|
36
|
+
}, {
|
|
37
|
+
get "aria-label"() {
|
|
38
|
+
return props.label;
|
|
39
|
+
},
|
|
40
|
+
get "class"() {
|
|
41
|
+
return classes(ROOT, sidebarClass(collapsed()), props.class);
|
|
42
|
+
},
|
|
43
|
+
get style() {
|
|
44
|
+
return props.style;
|
|
45
|
+
}
|
|
46
|
+
}], true);
|
|
33
47
|
insert(_el$, createComponent(Show, {
|
|
34
48
|
get when() {
|
|
35
49
|
return props.header;
|
|
@@ -193,18 +207,8 @@ function Sidebar(props) {
|
|
|
193
207
|
return _el$12;
|
|
194
208
|
})()
|
|
195
209
|
}), _el$3);
|
|
196
|
-
effect(() => {
|
|
197
|
-
|
|
198
|
-
e: props.label,
|
|
199
|
-
t: readShallow(classes(ROOT, sidebarClass(collapsed()), props.class)),
|
|
200
|
-
a: readShallow(props.style),
|
|
201
|
-
o: readShallow(SIDEBAR_PARTS.places)
|
|
202
|
-
};
|
|
203
|
-
}, ({ e, t, a, o }, _p$) => {
|
|
204
|
-
e !== _p$?.e && setAttribute(_el$, "aria-label", e);
|
|
205
|
-
className(_el$, t, _p$?.t);
|
|
206
|
-
style(_el$, a, _p$?.a);
|
|
207
|
-
className(_el$2, o, _p$?.o);
|
|
210
|
+
effect(() => readShallow(SIDEBAR_PARTS.places), (_v$, _$p) => {
|
|
211
|
+
className(_el$2, _v$, _$p);
|
|
208
212
|
});
|
|
209
213
|
return _el$;
|
|
210
214
|
}
|
package/dist/dom/Skeleton.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useDefaults } from "./Defaults.js";
|
|
2
|
-
import { layStyle } from "./root.js";
|
|
3
|
-
import {
|
|
2
|
+
import { layStyle, rootAttributes } from "./root.js";
|
|
3
|
+
import { spread, template } from "@solidjs/web";
|
|
4
4
|
import { classes, rootPart, skeletonClass, skeletonSize } from "@xds/core";
|
|
5
5
|
// packages/ui-solid/src/Skeleton.tsx
|
|
6
|
-
var _tmpl$ = /* @__PURE__ */ template(`<span
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template(`<span>`);
|
|
7
7
|
var ROOT = rootPart("Skeleton");
|
|
8
8
|
/**
|
|
9
9
|
* Holds the place of content that is loading, in the shape the content will have. It pulses,
|
|
@@ -16,19 +16,21 @@ function Skeleton(props) {
|
|
|
16
16
|
const defaults = useDefaults("Skeleton");
|
|
17
17
|
const shape = () => props.shape ?? defaults().shape;
|
|
18
18
|
var _el$ = _tmpl$();
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
spread(_el$, [() => {
|
|
20
|
+
return rootAttributes(props);
|
|
21
|
+
}, {
|
|
22
|
+
"aria-hidden": "true",
|
|
23
|
+
get "class"() {
|
|
24
|
+
return classes(ROOT, skeletonClass(shape()), props.class);
|
|
25
|
+
},
|
|
26
|
+
get style() {
|
|
27
|
+
return layStyle(skeletonSize({
|
|
23
28
|
shape: shape(),
|
|
24
29
|
width: props.width,
|
|
25
30
|
height: props.height
|
|
26
|
-
}), props.style)
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
className(_el$, e, _p$?.e);
|
|
30
|
-
style(_el$, t, _p$?.t);
|
|
31
|
-
});
|
|
31
|
+
}), props.style);
|
|
32
|
+
}
|
|
33
|
+
}], false);
|
|
32
34
|
return _el$;
|
|
33
35
|
}
|
|
34
36
|
export { Skeleton };
|
package/dist/dom/Slider.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createControllable } from "./controllable.js";
|
|
2
|
+
import { rootAttributes, withStyle } from "./root.js";
|
|
2
3
|
import { createComponent, insert, ref, spread, template } from "@solidjs/web";
|
|
3
|
-
import { classes, focusThumbOnPress, sliderArrowValue, sliderPageSize, sliderValueText } from "@xds/core";
|
|
4
|
+
import { classes, focusThumbOnPress, isControlled, sliderArrowValue, sliderPageSize, sliderValueText } from "@xds/core";
|
|
4
5
|
import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
|
|
5
6
|
import { Show, createMemo, createUniqueId } from "solid-js";
|
|
6
7
|
import * as slider from "@zag-js/slider";
|
|
@@ -12,7 +13,7 @@ var _tmpl$2 = /* @__PURE__ */ template(`<div><label></label><div><div><div></div
|
|
|
12
13
|
* go. The values snap to `step`.
|
|
13
14
|
*
|
|
14
15
|
* It is a slider named by its label with its value, minimum and maximum, and each arrow key
|
|
15
|
-
* moves it one step.
|
|
16
|
+
* moves it one step. Without `value` it keeps its own, from `defaultValue`, or `min`.
|
|
16
17
|
*/
|
|
17
18
|
function Slider(props) {
|
|
18
19
|
const id = createUniqueId();
|
|
@@ -24,11 +25,18 @@ function Slider(props) {
|
|
|
24
25
|
max: max(),
|
|
25
26
|
step: step()
|
|
26
27
|
});
|
|
28
|
+
const value = createControllable({
|
|
29
|
+
controlled: () => isControlled(props, "value"),
|
|
30
|
+
value: () => props.value ?? min(),
|
|
31
|
+
defaultValue: () => props.defaultValue ?? min(),
|
|
32
|
+
onChange: (next) => props.onChange?.(next)
|
|
33
|
+
});
|
|
27
34
|
const service = useMachine(slider.machine, () => ({
|
|
28
35
|
id,
|
|
36
|
+
ids: { root: props.id },
|
|
29
37
|
name: props.name,
|
|
30
|
-
value: [
|
|
31
|
-
onValueChange: (details) =>
|
|
38
|
+
value: [value.value()],
|
|
39
|
+
onValueChange: (details) => value.set(details.value[0] ?? min()),
|
|
32
40
|
min: min(),
|
|
33
41
|
max: max(),
|
|
34
42
|
step: step(),
|
|
@@ -38,7 +46,7 @@ function Slider(props) {
|
|
|
38
46
|
getAriaValueText: (details) => sliderValueText(details.value, props.locale)
|
|
39
47
|
}));
|
|
40
48
|
const api = createMemo(() => slider.connect(service, normalizeProps));
|
|
41
|
-
const root = withStyle(() => api().getRootProps(), () => props.style);
|
|
49
|
+
const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
|
|
42
50
|
const thumb = mergeProps$1(() => api().getThumbProps({ index: 0 }), {
|
|
43
51
|
draggable: "false",
|
|
44
52
|
onKeyDown: (event) => {
|
|
@@ -95,7 +103,7 @@ function Slider(props) {
|
|
|
95
103
|
class: "xds-slider__output"
|
|
96
104
|
}], true);
|
|
97
105
|
insert(_el$3, () => {
|
|
98
|
-
return sliderValueText(api().value[0] ??
|
|
106
|
+
return sliderValueText(api().value[0] ?? value.value(), props.locale);
|
|
99
107
|
});
|
|
100
108
|
return _el$3;
|
|
101
109
|
}
|
package/dist/dom/Spinner.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useDefaults } from "./Defaults.js";
|
|
2
|
-
import {
|
|
2
|
+
import { rootAttributes } from "./root.js";
|
|
3
|
+
import { className, effect, readShallow, spread, template } from "@solidjs/web";
|
|
3
4
|
import { classes, rootPart, spinnerClass } from "@xds/core";
|
|
4
5
|
// packages/ui-solid/src/Spinner.tsx
|
|
5
6
|
var _tmpl$ = /* @__PURE__ */ template(`<span><svg viewBox="0 0 24 24"fill=none aria-hidden=true><circle cx=12 cy=12 r=9 stroke=currentColor stroke-width=3 opacity=0.25></circle><path d="M21 12a9 9 0 0 0-9-9"stroke=currentColor stroke-width=3 stroke-linecap=round>`);
|
|
@@ -13,22 +14,27 @@ function Spinner(props) {
|
|
|
13
14
|
const defaults = useDefaults("Spinner");
|
|
14
15
|
var _el$ = _tmpl$();
|
|
15
16
|
var _el$2 = _el$.firstChild;
|
|
16
|
-
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
spread(_el$, [() => {
|
|
18
|
+
return rootAttributes(props);
|
|
19
|
+
}, {
|
|
20
|
+
get "class"() {
|
|
21
|
+
return classes(ROOT, "inline-flex shrink-0", props.class);
|
|
22
|
+
},
|
|
23
|
+
get style() {
|
|
24
|
+
return props.style;
|
|
25
|
+
},
|
|
26
|
+
get role() {
|
|
27
|
+
return props.label ? "status" : void 0;
|
|
28
|
+
},
|
|
29
|
+
get "aria-label"() {
|
|
30
|
+
return props.label || void 0;
|
|
31
|
+
},
|
|
32
|
+
get "aria-hidden"() {
|
|
33
|
+
return props.label ? void 0 : "true";
|
|
34
|
+
}
|
|
35
|
+
}], true);
|
|
36
|
+
effect(() => readShallow(spinnerClass(props.size ?? defaults().size)), (_v$, _$p) => {
|
|
37
|
+
className(_el$2, _v$, _$p);
|
|
32
38
|
});
|
|
33
39
|
return _el$;
|
|
34
40
|
}
|
package/dist/dom/Switch.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { composeRefs, createControllable, resetWithForm } from "./controllable.js";
|
|
1
2
|
import { keepChecked } from "./controlled.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
3
|
+
import { rootAttributes } from "./root.js";
|
|
4
|
+
import { className, createComponent, effect, insert, readShallow, ref, setAttribute, spread, template } from "@solidjs/web";
|
|
5
|
+
import { classes, isControlled, rootPart, switchClass, switchLabelClass, switchThumbClass, switchTrackClass } from "@xds/core";
|
|
4
6
|
import { Show } from "solid-js";
|
|
5
7
|
// packages/ui-solid/src/Switch.tsx
|
|
6
8
|
var _tmpl$ = /* @__PURE__ */ template(`<span>`);
|
|
@@ -11,17 +13,44 @@ var ROOT = rootPart("Switch");
|
|
|
11
13
|
* with a form, use a Checkbox.
|
|
12
14
|
*
|
|
13
15
|
* It is a native checkbox with the switch role, so the keyboard, forms and screen readers
|
|
14
|
-
* treat it as one. The input is hidden and the track is drawn beside it.
|
|
16
|
+
* treat it as one. The input is hidden and the track is drawn beside it. Without `checked` it
|
|
17
|
+
* keeps its own state, from `defaultChecked`.
|
|
15
18
|
*/
|
|
16
19
|
function Switch(props) {
|
|
20
|
+
const controlled = () => isControlled(props, "checked");
|
|
21
|
+
const defaultChecked = () => props.defaultChecked ?? false;
|
|
22
|
+
const checked = createControllable({
|
|
23
|
+
controlled,
|
|
24
|
+
value: () => props.checked ?? false,
|
|
25
|
+
defaultValue: defaultChecked,
|
|
26
|
+
onChange: (next) => props.onChange?.(next)
|
|
27
|
+
});
|
|
28
|
+
let input;
|
|
29
|
+
resetWithForm(() => input, controlled, checked.reset);
|
|
17
30
|
var _el$ = _tmpl$2();
|
|
18
31
|
var _el$2 = _el$.firstChild;
|
|
19
32
|
var _el$3 = _el$2.nextSibling;
|
|
20
33
|
var _el$4 = _el$3.firstChild;
|
|
34
|
+
spread(_el$, [() => {
|
|
35
|
+
return rootAttributes(props);
|
|
36
|
+
}, {
|
|
37
|
+
get "class"() {
|
|
38
|
+
return classes(ROOT, switchClass, props.class);
|
|
39
|
+
},
|
|
40
|
+
get style() {
|
|
41
|
+
return props.style;
|
|
42
|
+
}
|
|
43
|
+
}], true);
|
|
44
|
+
_el$2.addEventListener("blur", (event) => props.onBlur?.(event));
|
|
45
|
+
_el$2.addEventListener("focus", (event) => props.onFocus?.(event));
|
|
21
46
|
_el$2.addEventListener("change", (event) => {
|
|
22
|
-
|
|
23
|
-
keepChecked(event.currentTarget,
|
|
47
|
+
checked.set(event.currentTarget.checked);
|
|
48
|
+
keepChecked(event.currentTarget, checked.value);
|
|
24
49
|
});
|
|
50
|
+
var _ref$ = composeRefs((element) => input = element, () => props.ref);
|
|
51
|
+
(typeof _ref$ === "function" || Array.isArray(_ref$)) && ref(() => {
|
|
52
|
+
return _ref$;
|
|
53
|
+
}, _el$2);
|
|
25
54
|
insert(_el$, createComponent(Show, {
|
|
26
55
|
get when() {
|
|
27
56
|
return props.label;
|
|
@@ -39,26 +68,22 @@ function Switch(props) {
|
|
|
39
68
|
}), null);
|
|
40
69
|
effect(() => {
|
|
41
70
|
return {
|
|
42
|
-
e:
|
|
43
|
-
t:
|
|
44
|
-
a:
|
|
45
|
-
o:
|
|
46
|
-
i: props.
|
|
47
|
-
n:
|
|
48
|
-
s:
|
|
49
|
-
h: readShallow(switchTrackClass),
|
|
50
|
-
r: readShallow(switchThumbClass)
|
|
71
|
+
e: checked.value() ? "true" : "false",
|
|
72
|
+
t: props["aria-label"],
|
|
73
|
+
a: checked.value(),
|
|
74
|
+
o: controlled() ? checked.value() : defaultChecked(),
|
|
75
|
+
i: props.disabled,
|
|
76
|
+
n: readShallow(switchTrackClass),
|
|
77
|
+
s: readShallow(switchThumbClass)
|
|
51
78
|
};
|
|
52
|
-
}, ({ e, t, a, o, i, n, s
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
o !== _p$?.o &&
|
|
57
|
-
_el$2
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
className(_el$3, h, _p$?.h);
|
|
61
|
-
className(_el$4, r, _p$?.r);
|
|
79
|
+
}, ({ e, t, a, o, i, n, s }, _p$) => {
|
|
80
|
+
e !== _p$?.e && setAttribute(_el$2, "aria-checked", e);
|
|
81
|
+
t !== _p$?.t && setAttribute(_el$2, "aria-label", t);
|
|
82
|
+
_el$2.checked = a;
|
|
83
|
+
o !== _p$?.o && (_el$2.defaultChecked = o);
|
|
84
|
+
i !== _p$?.i && setAttribute(_el$2, "disabled", i);
|
|
85
|
+
className(_el$3, n, _p$?.n);
|
|
86
|
+
className(_el$4, s, _p$?.s);
|
|
62
87
|
});
|
|
63
88
|
return _el$;
|
|
64
89
|
}
|