@xds/solid 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +19 -2
- package/dist/dom/Accordion.js +139 -0
- package/dist/dom/Avatar.js +59 -0
- package/dist/dom/AvatarStack.js +74 -0
- package/dist/dom/Badge.js +58 -0
- package/dist/dom/Banner.js +102 -0
- package/dist/dom/Button.js +107 -0
- package/dist/dom/Card.js +164 -0
- package/dist/dom/Checkbox.js +64 -0
- package/dist/dom/Chip.js +52 -0
- package/dist/dom/ChipBar.js +28 -0
- package/dist/dom/CountBadge.js +67 -0
- package/dist/dom/DatePicker.js +300 -0
- package/dist/dom/DateRangePicker.js +404 -0
- package/dist/dom/Defaults.js +29 -0
- package/dist/dom/Dialog.js +136 -0
- package/dist/dom/Divider.js +20 -0
- package/dist/dom/EmptyState.js +70 -0
- package/dist/dom/Icon.js +46 -0
- package/dist/dom/IconButton.js +72 -0
- package/dist/dom/ListRow.js +126 -0
- package/dist/dom/MediaCard.js +178 -0
- package/dist/dom/Menu.js +176 -0
- package/dist/dom/ProgressBar.js +33 -0
- package/dist/dom/RadioGroup.js +123 -0
- package/dist/dom/SearchField.js +94 -0
- package/dist/dom/SectionHeader.js +104 -0
- package/dist/dom/SegmentedControl.js +69 -0
- package/dist/dom/Select.js +271 -0
- package/dist/dom/Sidebar.js +233 -0
- package/dist/dom/Skeleton.js +34 -0
- package/dist/dom/Slider.js +115 -0
- package/dist/dom/Spinner.js +35 -0
- package/dist/dom/Switch.js +65 -0
- package/dist/dom/Tabs.js +80 -0
- package/dist/dom/Text.js +24 -0
- package/dist/dom/TextField.js +172 -0
- package/dist/dom/Thumbnail.js +119 -0
- package/dist/dom/Toast.js +99 -0
- package/dist/dom/Tooltip.js +128 -0
- package/dist/dom/controlled.js +13 -0
- package/dist/dom/index.js +40 -0
- package/dist/dom/modal-popover.js +22 -0
- package/dist/dom/picture.js +29 -0
- package/dist/dom/presence.js +20 -0
- package/dist/dom/preview.js +139 -0
- package/dist/dom/root.js +26 -0
- package/dist/dom/trigger.js +31 -0
- package/dist/source/Accordion.d.ts +21 -0
- package/dist/source/Accordion.jsx +57 -0
- package/dist/source/Avatar.d.ts +9 -0
- package/dist/source/Avatar.jsx +16 -0
- package/dist/source/AvatarStack.d.ts +8 -0
- package/dist/source/AvatarStack.jsx +22 -0
- package/dist/source/Badge.d.ts +13 -0
- package/dist/source/Badge.jsx +15 -0
- package/dist/source/Banner.d.ts +23 -0
- package/dist/source/Banner.jsx +32 -0
- package/dist/source/Button.d.ts +15 -0
- package/dist/source/Button.jsx +48 -0
- package/dist/source/Card.d.ts +18 -0
- package/dist/source/Card.jsx +46 -0
- package/dist/source/Checkbox.d.ts +10 -0
- package/dist/source/Checkbox.jsx +20 -0
- package/dist/source/Chip.d.ts +12 -0
- package/dist/source/Chip.jsx +12 -0
- package/dist/source/ChipBar.d.ts +12 -0
- package/dist/source/ChipBar.jsx +7 -0
- package/dist/source/CountBadge.d.ts +12 -0
- package/dist/source/CountBadge.jsx +17 -0
- package/dist/source/DatePicker.d.ts +20 -0
- package/dist/source/DatePicker.jsx +109 -0
- package/dist/source/DateRangePicker.d.ts +24 -0
- package/dist/source/DateRangePicker.jsx +150 -0
- package/dist/source/Defaults.d.ts +23 -0
- package/dist/source/Defaults.jsx +12 -0
- package/dist/source/Dialog.d.ts +21 -0
- package/dist/source/Dialog.jsx +58 -0
- package/dist/source/Divider.d.ts +4 -0
- package/dist/source/Divider.jsx +5 -0
- package/dist/source/EmptyState.d.ts +12 -0
- package/dist/source/EmptyState.jsx +16 -0
- package/dist/source/Icon.d.ts +8 -0
- package/dist/source/Icon.jsx +11 -0
- package/dist/source/IconButton.d.ts +13 -0
- package/dist/source/IconButton.jsx +36 -0
- package/dist/source/ListRow.d.ts +21 -0
- package/dist/source/ListRow.jsx +38 -0
- package/dist/source/MediaCard.d.ts +20 -0
- package/dist/source/MediaCard.jsx +47 -0
- package/dist/source/Menu.d.ts +19 -0
- package/dist/source/Menu.jsx +99 -0
- package/dist/source/ProgressBar.d.ts +8 -0
- package/dist/source/ProgressBar.jsx +8 -0
- package/dist/source/RadioGroup.d.ts +15 -0
- package/dist/source/RadioGroup.jsx +57 -0
- package/dist/source/SearchField.d.ts +15 -0
- package/dist/source/SearchField.jsx +39 -0
- package/dist/source/SectionHeader.d.ts +14 -0
- package/dist/source/SectionHeader.jsx +32 -0
- package/dist/source/SegmentedControl.d.ts +12 -0
- package/dist/source/SegmentedControl.jsx +21 -0
- package/dist/source/Select.d.ts +18 -0
- package/dist/source/Select.jsx +139 -0
- package/dist/source/Sidebar.d.ts +22 -0
- package/dist/source/Sidebar.jsx +65 -0
- package/dist/source/Skeleton.d.ts +11 -0
- package/dist/source/Skeleton.jsx +9 -0
- package/dist/source/Slider.d.ts +13 -0
- package/dist/source/Slider.jsx +69 -0
- package/dist/source/Spinner.d.ts +9 -0
- package/dist/source/Spinner.jsx +12 -0
- package/dist/source/Switch.d.ts +13 -0
- package/dist/source/Switch.jsx +18 -0
- package/dist/source/Tabs.d.ts +14 -0
- package/dist/source/Tabs.jsx +31 -0
- package/dist/source/Text.d.ts +10 -0
- package/dist/source/Text.jsx +14 -0
- package/dist/source/TextField.d.ts +22 -0
- package/dist/source/TextField.jsx +73 -0
- package/dist/source/Thumbnail.d.ts +9 -0
- package/dist/source/Thumbnail.jsx +34 -0
- package/dist/source/Toast.d.ts +16 -0
- package/dist/source/Toast.jsx +42 -0
- package/dist/source/Tooltip.d.ts +28 -0
- package/dist/source/Tooltip.jsx +52 -0
- package/dist/source/controlled.d.ts +4 -0
- package/dist/source/controlled.js +11 -0
- package/dist/source/index.d.ts +40 -0
- package/dist/source/index.js +39 -0
- package/dist/source/modal-popover.d.ts +7 -0
- package/dist/source/modal-popover.js +15 -0
- package/dist/source/picture.d.ts +20 -0
- package/dist/source/picture.js +13 -0
- package/dist/source/presence.d.ts +7 -0
- package/dist/source/presence.js +13 -0
- package/dist/source/preview.d.ts +6 -0
- package/dist/source/preview.jsx +110 -0
- package/dist/source/root.d.ts +25 -0
- package/dist/source/root.js +19 -0
- package/dist/source/trigger.d.ts +18 -0
- package/dist/source/trigger.js +18 -0
- package/package.json +63 -4
- package/page.css +20 -0
- package/styles.css +3353 -0
- package/tailwind.css +2665 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { keepChecked } from "./controlled.js";
|
|
2
|
+
import { className, createComponent, effect, insert, readShallow, ref, setAttribute, setProperty, style, template } from "@solidjs/web";
|
|
3
|
+
import { classes } from "@xds/core";
|
|
4
|
+
import { For, Show, createUniqueId } from "solid-js";
|
|
5
|
+
// packages/ui-solid/src/RadioGroup.tsx
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template(`<span class=xds-radio-group__error>`);
|
|
7
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<div role=radiogroup aria-orientation=vertical><span class=xds-radio-group__label></span><div class=xds-radio-group__options></div><div aria-live=polite>`);
|
|
8
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<span class=xds-radio-group__description>`);
|
|
9
|
+
var _tmpl$4 = /* @__PURE__ */ template(`<label class=xds-radio-group__option><input type=radio class="xds-radio-group__input sr-only"><span class=xds-radio-group__row><span class=xds-radio-group__circle-line><span class=xds-radio-group__circle><span class=xds-radio-group__dot></span></span></span><span class=xds-radio-group__words><span class=xds-radio-group__text>`);
|
|
10
|
+
/**
|
|
11
|
+
* One choice among a few, applied later with the form it belongs to. For a choice that takes
|
|
12
|
+
* effect at once among two to four options, a SegmentedControl is the usual pick.
|
|
13
|
+
*
|
|
14
|
+
* The chosen option has a dot and a thicker ring, so the choice does not depend on color. The
|
|
15
|
+
* options are native radio buttons, hidden and drawn beside, in a group named by the legend:
|
|
16
|
+
* the arrow keys move between them, and the error is tied to the group and announced.
|
|
17
|
+
*/
|
|
18
|
+
function RadioGroup(props) {
|
|
19
|
+
const id = createUniqueId();
|
|
20
|
+
const labelId = `${id}-label`;
|
|
21
|
+
const errorId = `${id}-error`;
|
|
22
|
+
const invalid = () => props.error !== void 0;
|
|
23
|
+
let group;
|
|
24
|
+
var _el$ = _tmpl$2();
|
|
25
|
+
var _el$2 = _el$.firstChild;
|
|
26
|
+
var _el$3 = _el$2.nextSibling;
|
|
27
|
+
var _el$4 = _el$3.nextSibling;
|
|
28
|
+
setAttribute(_el$, "aria-labelledby", labelId);
|
|
29
|
+
ref(() => {
|
|
30
|
+
return (element) => group = element;
|
|
31
|
+
}, _el$);
|
|
32
|
+
setAttribute(_el$2, "id", labelId);
|
|
33
|
+
insert(_el$2, () => {
|
|
34
|
+
return props.label;
|
|
35
|
+
});
|
|
36
|
+
insert(_el$3, createComponent(For, {
|
|
37
|
+
get each() {
|
|
38
|
+
return props.options;
|
|
39
|
+
},
|
|
40
|
+
children: (option, index) => (() => {
|
|
41
|
+
var _el$6 = _tmpl$4();
|
|
42
|
+
var _el$7 = _el$6.firstChild;
|
|
43
|
+
var _el$10 = _el$7.nextSibling.firstChild.nextSibling;
|
|
44
|
+
var _el$11 = _el$10.firstChild;
|
|
45
|
+
_el$7.addEventListener("change", () => {
|
|
46
|
+
props.onChange(option.value);
|
|
47
|
+
for (const input of group.querySelectorAll("input")) keepChecked(input, () => input.value === props.value);
|
|
48
|
+
});
|
|
49
|
+
insert(_el$11, () => {
|
|
50
|
+
return option.label;
|
|
51
|
+
});
|
|
52
|
+
insert(_el$10, createComponent(Show, {
|
|
53
|
+
get when() {
|
|
54
|
+
return option.description;
|
|
55
|
+
},
|
|
56
|
+
get children() {
|
|
57
|
+
var _el$12 = _tmpl$3();
|
|
58
|
+
insert(_el$12, () => {
|
|
59
|
+
return option.description;
|
|
60
|
+
});
|
|
61
|
+
effect(() => `${id}-${index()}-description`, (_v$) => {
|
|
62
|
+
setAttribute(_el$12, "id", _v$);
|
|
63
|
+
});
|
|
64
|
+
return _el$12;
|
|
65
|
+
}
|
|
66
|
+
}), null);
|
|
67
|
+
effect(() => {
|
|
68
|
+
return {
|
|
69
|
+
e: props.name ?? id,
|
|
70
|
+
t: option.value,
|
|
71
|
+
a: option.value === props.value,
|
|
72
|
+
o: option.value === props.value,
|
|
73
|
+
i: props.disabled,
|
|
74
|
+
n: `${id}-${index()}`,
|
|
75
|
+
s: [option.description ? `${id}-${index()}-description` : void 0, invalid() ? errorId : void 0].filter(Boolean).join(" ") || void 0,
|
|
76
|
+
h: invalid() ? "true" : void 0,
|
|
77
|
+
r: `${id}-${index()}`
|
|
78
|
+
};
|
|
79
|
+
}, ({ e, t, a, o, i, n, s, h, r }, _p$) => {
|
|
80
|
+
e !== _p$?.e && setAttribute(_el$7, "name", e);
|
|
81
|
+
setProperty(_el$7, "value", t);
|
|
82
|
+
_el$7.checked = a;
|
|
83
|
+
o !== _p$?.o && (_el$7.defaultChecked = o);
|
|
84
|
+
i !== _p$?.i && setAttribute(_el$7, "disabled", i);
|
|
85
|
+
n !== _p$?.n && setAttribute(_el$7, "aria-labelledby", n);
|
|
86
|
+
s !== _p$?.s && setAttribute(_el$7, "aria-describedby", s);
|
|
87
|
+
h !== _p$?.h && setAttribute(_el$7, "aria-invalid", h);
|
|
88
|
+
r !== _p$?.r && setAttribute(_el$11, "id", r);
|
|
89
|
+
});
|
|
90
|
+
return _el$6;
|
|
91
|
+
})()
|
|
92
|
+
}));
|
|
93
|
+
insert(_el$4, createComponent(Show, {
|
|
94
|
+
get when() {
|
|
95
|
+
return invalid();
|
|
96
|
+
},
|
|
97
|
+
get children() {
|
|
98
|
+
var _el$5 = _tmpl$();
|
|
99
|
+
setAttribute(_el$5, "id", errorId);
|
|
100
|
+
insert(_el$5, () => {
|
|
101
|
+
return props.error;
|
|
102
|
+
});
|
|
103
|
+
return _el$5;
|
|
104
|
+
}
|
|
105
|
+
}));
|
|
106
|
+
effect(() => {
|
|
107
|
+
return {
|
|
108
|
+
e: invalid() ? errorId : void 0,
|
|
109
|
+
t: invalid() ? "true" : void 0,
|
|
110
|
+
a: props.disabled ? "true" : void 0,
|
|
111
|
+
o: readShallow(classes("xds-radio-group", props.class)),
|
|
112
|
+
i: readShallow(props.style)
|
|
113
|
+
};
|
|
114
|
+
}, ({ e, t, a, o, i }, _p$) => {
|
|
115
|
+
e !== _p$?.e && setAttribute(_el$, "aria-describedby", e);
|
|
116
|
+
t !== _p$?.t && setAttribute(_el$, "aria-invalid", t);
|
|
117
|
+
a !== _p$?.a && setAttribute(_el$, "aria-disabled", a);
|
|
118
|
+
className(_el$, o, _p$?.o);
|
|
119
|
+
style(_el$, i, _p$?.i);
|
|
120
|
+
});
|
|
121
|
+
return _el$;
|
|
122
|
+
}
|
|
123
|
+
export { RadioGroup };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { keepValue } from "./controlled.js";
|
|
2
|
+
import { Icon } from "./Icon.js";
|
|
3
|
+
import { className, createComponent, delegateEvents, effect, insert, memo, readShallow, ref, setAttribute, style, template } from "@solidjs/web";
|
|
4
|
+
import { classes, rootPart } from "@xds/core";
|
|
5
|
+
import { Show } from "solid-js";
|
|
6
|
+
// packages/ui-solid/src/SearchField.tsx
|
|
7
|
+
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">`);
|
|
8
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<div><div class="xds-text-field__control xds-text-field__control--pill xds-text-field__group"><span class="xds-text-field__slot xds-text-field__slot--leading"></span><input type=text class=xds-text-field__input enterkeyhint=search>`);
|
|
9
|
+
var ROOT = rootPart("SearchField");
|
|
10
|
+
/**
|
|
11
|
+
* A text field for a query: TextField's box as a pill, with a search icon in front and, while
|
|
12
|
+
* there is a value, a control that clears it. Escape clears too.
|
|
13
|
+
*
|
|
14
|
+
* Use it to filter or search what is on the screen. For a value that is saved with a form,
|
|
15
|
+
* use a TextField, which has a visible label.
|
|
16
|
+
*/
|
|
17
|
+
function SearchField(props) {
|
|
18
|
+
let input;
|
|
19
|
+
var _el$ = _tmpl$2();
|
|
20
|
+
var _el$2 = _el$.firstChild;
|
|
21
|
+
var _el$3 = _el$2.firstChild;
|
|
22
|
+
var _el$4 = _el$3.nextSibling;
|
|
23
|
+
insert(_el$3, createComponent(Icon, {
|
|
24
|
+
name: "search",
|
|
25
|
+
size: "sm"
|
|
26
|
+
}));
|
|
27
|
+
_el$4._$$keydown = (event) => {
|
|
28
|
+
if (event.isComposing) return;
|
|
29
|
+
if (event.key === "Enter") props.onSubmit?.(props.value);
|
|
30
|
+
if (event.key === "Escape" && props.value !== "") {
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
props.onChange("");
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
_el$4.addEventListener("compositionend", (event) => keepValue(event.currentTarget, () => props.value));
|
|
36
|
+
_el$4._$$input = (event) => {
|
|
37
|
+
props.onChange(event.currentTarget.value);
|
|
38
|
+
if (!event.isComposing) keepValue(event.currentTarget, () => props.value);
|
|
39
|
+
};
|
|
40
|
+
ref(() => {
|
|
41
|
+
return (element) => input = element;
|
|
42
|
+
}, _el$4);
|
|
43
|
+
insert(_el$2, createComponent(Show, {
|
|
44
|
+
get when() {
|
|
45
|
+
return memo(() => {
|
|
46
|
+
return props.value !== "";
|
|
47
|
+
})() && !props.disabled;
|
|
48
|
+
},
|
|
49
|
+
get children() {
|
|
50
|
+
var _el$5 = _tmpl$();
|
|
51
|
+
var _el$6 = _el$5.firstChild;
|
|
52
|
+
_el$6._$$click = () => {
|
|
53
|
+
props.onChange("");
|
|
54
|
+
input.focus();
|
|
55
|
+
};
|
|
56
|
+
insert(_el$6, createComponent(Icon, {
|
|
57
|
+
name: "circle-x",
|
|
58
|
+
size: "sm"
|
|
59
|
+
}));
|
|
60
|
+
effect(() => props.clearLabel ?? "Clear", (_v$) => {
|
|
61
|
+
setAttribute(_el$6, "aria-label", _v$);
|
|
62
|
+
});
|
|
63
|
+
return _el$5;
|
|
64
|
+
}
|
|
65
|
+
}), null);
|
|
66
|
+
effect(() => {
|
|
67
|
+
return {
|
|
68
|
+
e: readShallow(classes("xds-text-field", ROOT, props.class)),
|
|
69
|
+
t: readShallow(props.style),
|
|
70
|
+
a: props.label,
|
|
71
|
+
o: props.placeholder,
|
|
72
|
+
i: props.value,
|
|
73
|
+
n: props.value,
|
|
74
|
+
s: props.disabled,
|
|
75
|
+
h: props.value !== "" ? "" : void 0
|
|
76
|
+
};
|
|
77
|
+
}, ({ e, t, a, o, i, n, s, h }, _p$) => {
|
|
78
|
+
className(_el$, e, _p$?.e);
|
|
79
|
+
style(_el$, t, _p$?.t);
|
|
80
|
+
a !== _p$?.a && setAttribute(_el$4, "aria-label", a);
|
|
81
|
+
o !== _p$?.o && setAttribute(_el$4, "placeholder", o);
|
|
82
|
+
_el$4.value = i ?? "";
|
|
83
|
+
n !== _p$?.n && (_el$4.defaultValue = n ?? "");
|
|
84
|
+
s !== _p$?.s && setAttribute(_el$4, "disabled", s);
|
|
85
|
+
h !== _p$?.h && setAttribute(_el$4, "data-uses-escape", h);
|
|
86
|
+
});
|
|
87
|
+
return _el$;
|
|
88
|
+
}
|
|
89
|
+
delegateEvents([
|
|
90
|
+
"input",
|
|
91
|
+
"keydown",
|
|
92
|
+
"click"
|
|
93
|
+
]);
|
|
94
|
+
export { SearchField };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Button } from "./Button.js";
|
|
2
|
+
import { Icon } from "./Icon.js";
|
|
3
|
+
import { className, createComponent, dynamic, effect, insert, memo, readShallow, style, template } from "@solidjs/web";
|
|
4
|
+
import { SECTION_HEADER_PARTS, classes, rootPart } from "@xds/core";
|
|
5
|
+
import { Show } from "solid-js";
|
|
6
|
+
// packages/ui-solid/src/SectionHeader.tsx
|
|
7
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div><div><div><!><!>`);
|
|
8
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<span>`);
|
|
9
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<p>`);
|
|
10
|
+
var ROOT = rootPart("SectionHeader");
|
|
11
|
+
/**
|
|
12
|
+
* The title row of a group of content. The title is a heading at `level`; the action is a quiet
|
|
13
|
+
* button with a chevron at its end edge, which points the other way in a right-to-left layout.
|
|
14
|
+
*/
|
|
15
|
+
function SectionHeader(props) {
|
|
16
|
+
const Heading = dynamic(() => `h${props.level ?? 2}`);
|
|
17
|
+
var _el$ = _tmpl$();
|
|
18
|
+
var _el$2 = _el$.firstChild;
|
|
19
|
+
var _el$3 = _el$2.firstChild;
|
|
20
|
+
var _el$4 = _el$3.firstChild;
|
|
21
|
+
var _el$5 = _el$4.nextSibling;
|
|
22
|
+
insert(_el$2, createComponent(Show, {
|
|
23
|
+
get when() {
|
|
24
|
+
return props.icon;
|
|
25
|
+
},
|
|
26
|
+
children: (icon) => (() => {
|
|
27
|
+
var _el$6 = _tmpl$2();
|
|
28
|
+
insert(_el$6, createComponent(Icon, {
|
|
29
|
+
get name() {
|
|
30
|
+
return icon();
|
|
31
|
+
},
|
|
32
|
+
size: "md"
|
|
33
|
+
}));
|
|
34
|
+
effect(() => readShallow(SECTION_HEADER_PARTS.icon), (_v$, _$p) => {
|
|
35
|
+
className(_el$6, _v$, _$p);
|
|
36
|
+
});
|
|
37
|
+
return _el$6;
|
|
38
|
+
})()
|
|
39
|
+
}), _el$3);
|
|
40
|
+
insert(_el$3, createComponent(Heading, {
|
|
41
|
+
get "class"() {
|
|
42
|
+
return SECTION_HEADER_PARTS.title;
|
|
43
|
+
},
|
|
44
|
+
get children() {
|
|
45
|
+
return props.title;
|
|
46
|
+
}
|
|
47
|
+
}), _el$4);
|
|
48
|
+
insert(_el$3, createComponent(Show, {
|
|
49
|
+
get when() {
|
|
50
|
+
return props.description;
|
|
51
|
+
},
|
|
52
|
+
children: (description) => (() => {
|
|
53
|
+
var _el$7 = _tmpl$3();
|
|
54
|
+
insert(_el$7, description);
|
|
55
|
+
effect(() => readShallow(SECTION_HEADER_PARTS.description), (_v$, _$p) => {
|
|
56
|
+
className(_el$7, _v$, _$p);
|
|
57
|
+
});
|
|
58
|
+
return _el$7;
|
|
59
|
+
})()
|
|
60
|
+
}), _el$5);
|
|
61
|
+
insert(_el$, createComponent(Show, {
|
|
62
|
+
get when() {
|
|
63
|
+
return props.action;
|
|
64
|
+
},
|
|
65
|
+
children: (action) => (() => {
|
|
66
|
+
var _el$8 = _tmpl$2();
|
|
67
|
+
insert(_el$8, createComponent(Button, {
|
|
68
|
+
variant: "ghost",
|
|
69
|
+
size: "sm",
|
|
70
|
+
onPress: () => action().onPress(),
|
|
71
|
+
get children() {
|
|
72
|
+
return [memo(() => {
|
|
73
|
+
return action().label;
|
|
74
|
+
}), createComponent(Icon, {
|
|
75
|
+
name: "chevron-right",
|
|
76
|
+
size: "sm",
|
|
77
|
+
get "class"() {
|
|
78
|
+
return SECTION_HEADER_PARTS.chevron;
|
|
79
|
+
}
|
|
80
|
+
})];
|
|
81
|
+
}
|
|
82
|
+
}));
|
|
83
|
+
effect(() => readShallow(SECTION_HEADER_PARTS.action), (_v$, _$p) => {
|
|
84
|
+
className(_el$8, _v$, _$p);
|
|
85
|
+
});
|
|
86
|
+
return _el$8;
|
|
87
|
+
})()
|
|
88
|
+
}), null);
|
|
89
|
+
effect(() => {
|
|
90
|
+
return {
|
|
91
|
+
e: readShallow(classes(ROOT, SECTION_HEADER_PARTS.root, props.class)),
|
|
92
|
+
t: readShallow(props.style),
|
|
93
|
+
a: readShallow(SECTION_HEADER_PARTS.lead),
|
|
94
|
+
o: readShallow(SECTION_HEADER_PARTS.text)
|
|
95
|
+
};
|
|
96
|
+
}, ({ e, t, a, o }, _p$) => {
|
|
97
|
+
className(_el$, e, _p$?.e);
|
|
98
|
+
style(_el$, t, _p$?.t);
|
|
99
|
+
className(_el$2, a, _p$?.a);
|
|
100
|
+
className(_el$3, o, _p$?.o);
|
|
101
|
+
});
|
|
102
|
+
return _el$;
|
|
103
|
+
}
|
|
104
|
+
export { SectionHeader };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { keepChecked } from "./controlled.js";
|
|
2
|
+
import { className, createComponent, effect, insert, readShallow, ref, setAttribute, setProperty, style, template } from "@solidjs/web";
|
|
3
|
+
import { classes, rootPart, segmentedControlClass, segmentedControlOptionClass, segmentedControlSegmentClass } from "@xds/core";
|
|
4
|
+
import { For, createUniqueId } from "solid-js";
|
|
5
|
+
// packages/ui-solid/src/SegmentedControl.tsx
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div role=radiogroup>`);
|
|
7
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<label><input type=radio class="peer sr-only"><span>`);
|
|
8
|
+
var ROOT = rootPart("SegmentedControl");
|
|
9
|
+
/**
|
|
10
|
+
* A choice between a few views or modes, all visible at once. The selected segment is outlined
|
|
11
|
+
* as well as filled, so the choice does not depend on telling two greys apart.
|
|
12
|
+
*
|
|
13
|
+
* It is a group of native radio buttons, so the arrow keys move between segments.
|
|
14
|
+
*/
|
|
15
|
+
function SegmentedControl(props) {
|
|
16
|
+
const name = createUniqueId();
|
|
17
|
+
let group;
|
|
18
|
+
var _el$ = _tmpl$();
|
|
19
|
+
ref(() => {
|
|
20
|
+
return (element) => group = element;
|
|
21
|
+
}, _el$);
|
|
22
|
+
insert(_el$, createComponent(For, {
|
|
23
|
+
get each() {
|
|
24
|
+
return props.options;
|
|
25
|
+
},
|
|
26
|
+
children: (option) => (() => {
|
|
27
|
+
var _el$2 = _tmpl$2();
|
|
28
|
+
var _el$3 = _el$2.firstChild;
|
|
29
|
+
var _el$4 = _el$3.nextSibling;
|
|
30
|
+
_el$3.addEventListener("change", () => {
|
|
31
|
+
props.onChange(option.value);
|
|
32
|
+
for (const input of group.querySelectorAll("input")) keepChecked(input, () => input.value === props.value);
|
|
33
|
+
});
|
|
34
|
+
setAttribute(_el$3, "name", name);
|
|
35
|
+
insert(_el$4, () => {
|
|
36
|
+
return option.label;
|
|
37
|
+
});
|
|
38
|
+
effect(() => {
|
|
39
|
+
return {
|
|
40
|
+
e: readShallow(segmentedControlOptionClass(props.fullWidth)),
|
|
41
|
+
t: option.value,
|
|
42
|
+
a: option.value === props.value,
|
|
43
|
+
o: option.value === props.value,
|
|
44
|
+
i: readShallow(segmentedControlSegmentClass)
|
|
45
|
+
};
|
|
46
|
+
}, ({ e, t, a, o, i }, _p$) => {
|
|
47
|
+
className(_el$2, e, _p$?.e);
|
|
48
|
+
setProperty(_el$3, "value", t);
|
|
49
|
+
_el$3.checked = a;
|
|
50
|
+
o !== _p$?.o && (_el$3.defaultChecked = o);
|
|
51
|
+
className(_el$4, i, _p$?.i);
|
|
52
|
+
});
|
|
53
|
+
return _el$2;
|
|
54
|
+
})()
|
|
55
|
+
}));
|
|
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
|
+
return _el$;
|
|
68
|
+
}
|
|
69
|
+
export { SegmentedControl };
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { Icon } from "./Icon.js";
|
|
2
|
+
import { modalPopover } from "./modal-popover.js";
|
|
3
|
+
import { createPresence } from "./presence.js";
|
|
4
|
+
import { withStyle } from "./root.js";
|
|
5
|
+
import { Portal, createComponent, delegateEvents, effect, insert, ref, setAttribute, spread, template } from "@solidjs/web";
|
|
6
|
+
import { classes, keepListKeys, selectOptionIds } from "@xds/core";
|
|
7
|
+
import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
|
|
8
|
+
import { For, Show, createMemo, createUniqueId } from "solid-js";
|
|
9
|
+
import { space } from "@xds/tokens";
|
|
10
|
+
import * as select from "@zag-js/select";
|
|
11
|
+
// packages/ui-solid/src/Select.tsx
|
|
12
|
+
var _tmpl$ = /* @__PURE__ */ template(`<span class=xds-select__error>`);
|
|
13
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<div class=xds-select__footer>`);
|
|
14
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<div class=xds-select__underlay>`);
|
|
15
|
+
var _tmpl$4 = /* @__PURE__ */ template(`<div><div><div>`);
|
|
16
|
+
var _tmpl$5 = /* @__PURE__ */ template(`<div><span></span><button><span></span></button><select><option value></option></select><!>`);
|
|
17
|
+
var _tmpl$6 = /* @__PURE__ */ template(`<span class=xds-select__description>`);
|
|
18
|
+
var _tmpl$7 = /* @__PURE__ */ template(`<option>`);
|
|
19
|
+
var _tmpl$8 = /* @__PURE__ */ template(`<span class=xds-select__item-description>`);
|
|
20
|
+
var _tmpl$9 = /* @__PURE__ */ template(`<div><span class=xds-select__item-words><span>`);
|
|
21
|
+
/**
|
|
22
|
+
* A field for choosing one option from a list too long to show at once. Closed, it looks like a
|
|
23
|
+
* TextField; pressed, it opens the list under itself with a Menu's surface, as wide as the
|
|
24
|
+
* field. Choosing an option calls `onChange` and closes the list; a press outside or Escape
|
|
25
|
+
* closes it too.
|
|
26
|
+
*
|
|
27
|
+
* The field is a button that says it opens a list box and whether the list is open. In the list
|
|
28
|
+
* the arrow keys move, typing jumps to an option, and Enter chooses. The chosen option is
|
|
29
|
+
* selected for assistive technology and marked with a check.
|
|
30
|
+
*/
|
|
31
|
+
function Select(props) {
|
|
32
|
+
const id = createUniqueId();
|
|
33
|
+
const valueId = `${id}-value`;
|
|
34
|
+
const descriptionId = `${id}-description`;
|
|
35
|
+
const errorId = `${id}-error`;
|
|
36
|
+
const invalid = () => props.error !== void 0;
|
|
37
|
+
const collection = createMemo(() => select.collection({
|
|
38
|
+
items: [...props.options],
|
|
39
|
+
itemToValue: (option) => option.value,
|
|
40
|
+
itemToString: (option) => option.label
|
|
41
|
+
}));
|
|
42
|
+
const service = useMachine(select.machine, () => ({
|
|
43
|
+
id,
|
|
44
|
+
collection: collection(),
|
|
45
|
+
value: props.value === void 0 ? [] : [props.value],
|
|
46
|
+
onValueChange: (details) => {
|
|
47
|
+
const next = details.value[0];
|
|
48
|
+
if (next !== void 0) props.onChange(next);
|
|
49
|
+
},
|
|
50
|
+
disabled: props.disabled,
|
|
51
|
+
invalid: invalid(),
|
|
52
|
+
name: props.name,
|
|
53
|
+
positioning: {
|
|
54
|
+
placement: "bottom-start",
|
|
55
|
+
gutter: space[1],
|
|
56
|
+
sameWidth: true,
|
|
57
|
+
overflowPadding: space[3]
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
const api = createMemo(() => select.connect(service, normalizeProps));
|
|
61
|
+
const root = withStyle(() => api().getRootProps(), () => props.style);
|
|
62
|
+
const current = () => select.connect(service, normalizeProps);
|
|
63
|
+
const labelProps = createMemo(() => {
|
|
64
|
+
const { for: _, ...rest } = api().getLabelProps();
|
|
65
|
+
return rest;
|
|
66
|
+
});
|
|
67
|
+
const triggerProps = createMemo(() => {
|
|
68
|
+
const { role: _role, "aria-invalid": _invalid, "aria-required": _required, onKeyDown: _onKeyDown, ...rest } = api().getTriggerProps();
|
|
69
|
+
return {
|
|
70
|
+
...rest,
|
|
71
|
+
onKeyDown: (event) => {
|
|
72
|
+
if (!api().open && (event.key === "Home" || event.key === "End")) return;
|
|
73
|
+
current().getTriggerProps().onKeyDown?.(event);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
let positioner;
|
|
78
|
+
let surface;
|
|
79
|
+
modalPopover(() => api().open, () => positioner);
|
|
80
|
+
const present = createPresence(() => api().open, () => [surface]);
|
|
81
|
+
const content = mergeProps$1(() => {
|
|
82
|
+
const { onKeyDown: _onKeyDown, ...rest } = api().getContentProps();
|
|
83
|
+
return rest;
|
|
84
|
+
}, { onKeyDown: (event) => {
|
|
85
|
+
keepListKeys(event, surface, ".xds-select__item:not([data-disabled])", (value) => api().setHighlightedValue(value));
|
|
86
|
+
current().getContentProps().onKeyDown?.(event);
|
|
87
|
+
} });
|
|
88
|
+
var _el$ = _tmpl$5();
|
|
89
|
+
var _el$2 = _el$.firstChild;
|
|
90
|
+
var _el$3 = _el$2.nextSibling;
|
|
91
|
+
var _el$4 = _el$3.firstChild;
|
|
92
|
+
var _el$7 = _el$3.nextSibling;
|
|
93
|
+
_el$7.firstChild;
|
|
94
|
+
var _el$13 = _el$7.nextSibling;
|
|
95
|
+
spread(_el$, [root, { get "class"() {
|
|
96
|
+
return classes("xds-select", props.class);
|
|
97
|
+
} }], true);
|
|
98
|
+
spread(_el$2, [labelProps, { class: "xds-select__label" }], true);
|
|
99
|
+
insert(_el$2, () => {
|
|
100
|
+
return props.label;
|
|
101
|
+
});
|
|
102
|
+
spread(_el$3, [triggerProps, {
|
|
103
|
+
get "aria-labelledby"() {
|
|
104
|
+
return `${valueId} ${labelProps().id}`;
|
|
105
|
+
},
|
|
106
|
+
get "aria-describedby"() {
|
|
107
|
+
return invalid() ? errorId : props.description ? descriptionId : void 0;
|
|
108
|
+
},
|
|
109
|
+
class: "xds-select__trigger"
|
|
110
|
+
}], true);
|
|
111
|
+
spread(_el$4, [() => {
|
|
112
|
+
return api().getValueTextProps();
|
|
113
|
+
}, {
|
|
114
|
+
id: valueId,
|
|
115
|
+
class: "xds-select__value"
|
|
116
|
+
}], true);
|
|
117
|
+
insert(_el$4, () => {
|
|
118
|
+
return api().valueAsString || props.placeholder;
|
|
119
|
+
});
|
|
120
|
+
insert(_el$3, createComponent(Icon, {
|
|
121
|
+
name: "chevrons-up-down",
|
|
122
|
+
size: "sm",
|
|
123
|
+
class: "text-xds-field-placeholder"
|
|
124
|
+
}), null);
|
|
125
|
+
insert(_el$, createComponent(Show, {
|
|
126
|
+
get when() {
|
|
127
|
+
return invalid() || props.description;
|
|
128
|
+
},
|
|
129
|
+
get children() {
|
|
130
|
+
var _el$5 = _tmpl$2();
|
|
131
|
+
insert(_el$5, createComponent(Show, {
|
|
132
|
+
get when() {
|
|
133
|
+
return invalid();
|
|
134
|
+
},
|
|
135
|
+
get fallback() {
|
|
136
|
+
var _el$14 = _tmpl$6();
|
|
137
|
+
setAttribute(_el$14, "id", descriptionId);
|
|
138
|
+
insert(_el$14, () => {
|
|
139
|
+
return props.description;
|
|
140
|
+
});
|
|
141
|
+
return _el$14;
|
|
142
|
+
},
|
|
143
|
+
get children() {
|
|
144
|
+
var _el$6 = _tmpl$();
|
|
145
|
+
setAttribute(_el$6, "id", errorId);
|
|
146
|
+
insert(_el$6, () => {
|
|
147
|
+
return props.error;
|
|
148
|
+
});
|
|
149
|
+
return _el$6;
|
|
150
|
+
}
|
|
151
|
+
}));
|
|
152
|
+
return _el$5;
|
|
153
|
+
}
|
|
154
|
+
}), _el$7);
|
|
155
|
+
spread(_el$7, () => {
|
|
156
|
+
return api().getHiddenSelectProps();
|
|
157
|
+
}, true);
|
|
158
|
+
insert(_el$7, createComponent(For, {
|
|
159
|
+
get each() {
|
|
160
|
+
return props.options;
|
|
161
|
+
},
|
|
162
|
+
children: (option) => (() => {
|
|
163
|
+
var _el$15 = _tmpl$7();
|
|
164
|
+
insert(_el$15, () => {
|
|
165
|
+
return option.label;
|
|
166
|
+
});
|
|
167
|
+
effect(() => option.value, (_v$) => {
|
|
168
|
+
_el$15.value = _v$;
|
|
169
|
+
});
|
|
170
|
+
return _el$15;
|
|
171
|
+
})()
|
|
172
|
+
}), null);
|
|
173
|
+
insert(_el$, createComponent(Portal, { get children() {
|
|
174
|
+
return [createComponent(Show, {
|
|
175
|
+
get when() {
|
|
176
|
+
return api().open;
|
|
177
|
+
},
|
|
178
|
+
get children() {
|
|
179
|
+
var _el$9 = _tmpl$3();
|
|
180
|
+
_el$9._$$mousedown = (event) => event.preventDefault();
|
|
181
|
+
return _el$9;
|
|
182
|
+
}
|
|
183
|
+
}), (() => {
|
|
184
|
+
var _el$10 = _tmpl$4();
|
|
185
|
+
var _el$11 = _el$10.firstChild;
|
|
186
|
+
var _el$12 = _el$11.firstChild;
|
|
187
|
+
spread(_el$10, [() => {
|
|
188
|
+
return api().getPositionerProps();
|
|
189
|
+
}, { class: "xds-select__positioner" }], true);
|
|
190
|
+
ref(() => {
|
|
191
|
+
return (element) => positioner = element;
|
|
192
|
+
}, _el$10);
|
|
193
|
+
spread(_el$11, [content, {
|
|
194
|
+
get hidden() {
|
|
195
|
+
return !present();
|
|
196
|
+
},
|
|
197
|
+
class: "xds-select__content"
|
|
198
|
+
}], true);
|
|
199
|
+
ref(() => {
|
|
200
|
+
return (element) => surface = element;
|
|
201
|
+
}, _el$11);
|
|
202
|
+
spread(_el$12, [() => {
|
|
203
|
+
return api().getListProps();
|
|
204
|
+
}, { class: "xds-select__list" }], true);
|
|
205
|
+
insert(_el$12, createComponent(For, {
|
|
206
|
+
get each() {
|
|
207
|
+
return collection().items;
|
|
208
|
+
},
|
|
209
|
+
children: (option, index) => {
|
|
210
|
+
const ids = () => selectOptionIds(id, index());
|
|
211
|
+
var _el$16 = _tmpl$9();
|
|
212
|
+
var _el$17 = _el$16.firstChild;
|
|
213
|
+
var _el$18 = _el$17.firstChild;
|
|
214
|
+
spread(_el$16, [() => {
|
|
215
|
+
return api().getItemProps({ item: option });
|
|
216
|
+
}, {
|
|
217
|
+
get "aria-labelledby"() {
|
|
218
|
+
return ids().label;
|
|
219
|
+
},
|
|
220
|
+
get "aria-describedby"() {
|
|
221
|
+
return option.description ? ids().description : void 0;
|
|
222
|
+
},
|
|
223
|
+
class: "xds-select__item"
|
|
224
|
+
}], true);
|
|
225
|
+
spread(_el$18, [() => {
|
|
226
|
+
return api().getItemTextProps({ item: option });
|
|
227
|
+
}, {
|
|
228
|
+
get id() {
|
|
229
|
+
return ids().label;
|
|
230
|
+
},
|
|
231
|
+
class: "xds-select__item-label"
|
|
232
|
+
}], true);
|
|
233
|
+
insert(_el$18, () => {
|
|
234
|
+
return option.label;
|
|
235
|
+
});
|
|
236
|
+
insert(_el$17, createComponent(Show, {
|
|
237
|
+
get when() {
|
|
238
|
+
return option.description;
|
|
239
|
+
},
|
|
240
|
+
get children() {
|
|
241
|
+
var _el$19 = _tmpl$8();
|
|
242
|
+
insert(_el$19, () => {
|
|
243
|
+
return option.description;
|
|
244
|
+
});
|
|
245
|
+
effect(() => ids().description, (_v$) => {
|
|
246
|
+
setAttribute(_el$19, "id", _v$);
|
|
247
|
+
});
|
|
248
|
+
return _el$19;
|
|
249
|
+
}
|
|
250
|
+
}), null);
|
|
251
|
+
insert(_el$16, createComponent(Show, {
|
|
252
|
+
get when() {
|
|
253
|
+
return api().getItemState({ item: option }).selected;
|
|
254
|
+
},
|
|
255
|
+
get children() {
|
|
256
|
+
return createComponent(Icon, {
|
|
257
|
+
name: "check",
|
|
258
|
+
size: "sm"
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}), null);
|
|
262
|
+
return _el$16;
|
|
263
|
+
}
|
|
264
|
+
}));
|
|
265
|
+
return _el$10;
|
|
266
|
+
})()];
|
|
267
|
+
} }), _el$13);
|
|
268
|
+
return _el$;
|
|
269
|
+
}
|
|
270
|
+
delegateEvents(["mousedown"]);
|
|
271
|
+
export { Select };
|