@xds/solid 1.0.0 → 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/Tabs.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { createControllable } from "./controllable.js";
|
|
1
2
|
import { Icon } from "./Icon.js";
|
|
2
|
-
import { withStyle } from "./root.js";
|
|
3
|
+
import { rootAttributes, withStyle } from "./root.js";
|
|
3
4
|
import { createComponent, insert, spread, template } from "@solidjs/web";
|
|
4
|
-
import { classes, tabStopIndex, tabsClass } from "@xds/core";
|
|
5
|
+
import { classes, isControlled, tabStopIndex, tabsClass } from "@xds/core";
|
|
5
6
|
import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
|
|
6
7
|
import { For, Show, createMemo, createUniqueId } from "solid-js";
|
|
7
8
|
import * as tabs from "@zag-js/tabs";
|
|
@@ -14,17 +15,26 @@ var _tmpl$2 = /* @__PURE__ */ template(`<button><!><!>`);
|
|
|
14
15
|
*
|
|
15
16
|
* The selected tab is underlined as well as darker, so the choice does not depend on color.
|
|
16
17
|
* This is only the row: the app shows the view that matches `value`. The arrow keys move
|
|
17
|
-
* between tabs.
|
|
18
|
+
* between tabs. Without `value` they keep their own, from `defaultValue`, or the first tab.
|
|
18
19
|
*/
|
|
19
20
|
function Tabs(props) {
|
|
20
21
|
const id = createUniqueId();
|
|
22
|
+
const value = createControllable({
|
|
23
|
+
controlled: () => isControlled(props, "value"),
|
|
24
|
+
value: () => props.value,
|
|
25
|
+
defaultValue: () => props.defaultValue ?? props.items[0]?.value,
|
|
26
|
+
onChange: (next) => {
|
|
27
|
+
if (next !== void 0) props.onChange?.(next);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
21
30
|
const service = useMachine(tabs.machine, () => ({
|
|
22
31
|
id,
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
ids: { root: props.id },
|
|
33
|
+
value: value.value() ?? null,
|
|
34
|
+
onValueChange: (details) => value.set(details.value)
|
|
25
35
|
}));
|
|
26
36
|
const api = createMemo(() => tabs.connect(service, normalizeProps));
|
|
27
|
-
const root = withStyle(() => api().getRootProps(), () => props.style);
|
|
37
|
+
const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
|
|
28
38
|
var _el$ = _tmpl$();
|
|
29
39
|
var _el$2 = _el$.firstChild;
|
|
30
40
|
var _el$3 = _el$2.firstChild;
|
package/dist/dom/Text.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { useDefaults } from "./Defaults.js";
|
|
2
|
-
import {
|
|
2
|
+
import { rootAttributes } from "./root.js";
|
|
3
|
+
import { createComponent, dynamic, mergeProps } from "@solidjs/web";
|
|
3
4
|
import { classes, rootPart, textClass } from "@xds/core";
|
|
4
5
|
// packages/ui-solid/src/Text.tsx
|
|
5
6
|
var ROOT = rootPart("Text");
|
|
6
7
|
function Text(props) {
|
|
7
8
|
const Tag = dynamic(() => props.as ?? "p");
|
|
8
9
|
const defaults = useDefaults("Text");
|
|
9
|
-
return createComponent(Tag, {
|
|
10
|
+
return createComponent(Tag, mergeProps(() => {
|
|
11
|
+
return rootAttributes(props);
|
|
12
|
+
}, {
|
|
10
13
|
get "class"() {
|
|
11
14
|
return classes(ROOT, textClass({
|
|
12
15
|
variant: props.variant ?? defaults().variant,
|
|
@@ -19,6 +22,6 @@ function Text(props) {
|
|
|
19
22
|
get children() {
|
|
20
23
|
return props.children;
|
|
21
24
|
}
|
|
22
|
-
});
|
|
25
|
+
}));
|
|
23
26
|
}
|
|
24
27
|
export { Text };
|
package/dist/dom/TextField.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { composeRefs, createControllable, resetWithForm } from "./controllable.js";
|
|
1
2
|
import { keepValue } from "./controlled.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
3
|
+
import { rootAttributes } from "./root.js";
|
|
4
|
+
import { createComponent, insert, memo, ref, setAttribute, spread, template } from "@solidjs/web";
|
|
5
|
+
import { classes, isControlled } from "@xds/core";
|
|
4
6
|
import { Show, children, createEffect, createUniqueId, onSettled } from "solid-js";
|
|
5
7
|
// packages/ui-solid/src/TextField.tsx
|
|
6
8
|
var _tmpl$ = /* @__PURE__ */ template(`<textarea>`);
|
|
@@ -18,6 +20,8 @@ var _tmpl$8 = /* @__PURE__ */ template(`<span class="xds-text-field__slot xds-te
|
|
|
18
20
|
*
|
|
19
21
|
* An invalid field blocks its form from being submitted, so `error` has to be cleared as soon as
|
|
20
22
|
* the person edits the value.
|
|
23
|
+
*
|
|
24
|
+
* Without `value` it keeps its own text, from `defaultValue`.
|
|
21
25
|
*/
|
|
22
26
|
function TextField(props) {
|
|
23
27
|
const id = createUniqueId();
|
|
@@ -27,6 +31,15 @@ function TextField(props) {
|
|
|
27
31
|
const trailing = children(() => props.trailing);
|
|
28
32
|
const invalid = () => props.error !== void 0;
|
|
29
33
|
let input;
|
|
34
|
+
const controlled = () => isControlled(props, "value");
|
|
35
|
+
const defaultValue = () => props.defaultValue ?? "";
|
|
36
|
+
const value = createControllable({
|
|
37
|
+
controlled,
|
|
38
|
+
value: () => props.value ?? "",
|
|
39
|
+
defaultValue,
|
|
40
|
+
onChange: (next) => props.onChange?.(next)
|
|
41
|
+
});
|
|
42
|
+
resetWithForm(() => input, controlled, value.reset);
|
|
30
43
|
onSettled(() => {
|
|
31
44
|
if (input instanceof HTMLTextAreaElement) input.setSelectionRange(0, 0);
|
|
32
45
|
if (props.autoFocus) input.focus();
|
|
@@ -37,8 +50,8 @@ function TextField(props) {
|
|
|
37
50
|
const shared = (box) => ({
|
|
38
51
|
id,
|
|
39
52
|
class: box ? "xds-text-field__input xds-text-field__control" : "xds-text-field__input",
|
|
40
|
-
value:
|
|
41
|
-
defaultValue:
|
|
53
|
+
value: value.value(),
|
|
54
|
+
defaultValue: controlled() ? value.value() : defaultValue(),
|
|
42
55
|
placeholder: props.placeholder,
|
|
43
56
|
name: props.name,
|
|
44
57
|
maxlength: props.maxLength,
|
|
@@ -46,15 +59,19 @@ function TextField(props) {
|
|
|
46
59
|
autocomplete: props.autoComplete,
|
|
47
60
|
required: props.required,
|
|
48
61
|
disabled: props.disabled,
|
|
62
|
+
readonly: props.readOnly,
|
|
49
63
|
"aria-invalid": invalid() ? "true" : void 0,
|
|
50
64
|
"aria-errormessage": invalid() ? errorId : void 0,
|
|
51
65
|
"aria-describedby": invalid() ? errorId : props.description ? descriptionId : void 0,
|
|
52
66
|
onInput: (event) => {
|
|
53
|
-
|
|
54
|
-
if (!event.isComposing) keepValue(event.currentTarget,
|
|
67
|
+
value.set(event.currentTarget.value);
|
|
68
|
+
if (!event.isComposing) keepValue(event.currentTarget, value.value);
|
|
55
69
|
},
|
|
56
|
-
onCompositionEnd: (event) => keepValue(event.currentTarget,
|
|
70
|
+
onCompositionEnd: (event) => keepValue(event.currentTarget, value.value),
|
|
71
|
+
onFocus: (event) => props.onFocus?.(event),
|
|
72
|
+
onBlur: (event) => props.onBlur?.(event)
|
|
57
73
|
});
|
|
74
|
+
const ref$1 = composeRefs((element) => input = element, () => props.ref);
|
|
58
75
|
const field = (box) => props.multiline ? (() => {
|
|
59
76
|
var _el$ = _tmpl$();
|
|
60
77
|
spread(_el$, [{ get rows() {
|
|
@@ -63,7 +80,7 @@ function TextField(props) {
|
|
|
63
80
|
return shared(box);
|
|
64
81
|
}], false);
|
|
65
82
|
ref(() => {
|
|
66
|
-
return
|
|
83
|
+
return ref$1;
|
|
67
84
|
}, _el$);
|
|
68
85
|
return _el$;
|
|
69
86
|
})() : (() => {
|
|
@@ -74,7 +91,7 @@ function TextField(props) {
|
|
|
74
91
|
return shared(box);
|
|
75
92
|
}], false);
|
|
76
93
|
ref(() => {
|
|
77
|
-
return
|
|
94
|
+
return ref$1;
|
|
78
95
|
}, _el$2);
|
|
79
96
|
return _el$2;
|
|
80
97
|
})();
|
|
@@ -83,6 +100,16 @@ function TextField(props) {
|
|
|
83
100
|
var _el$9 = _el$4.nextSibling;
|
|
84
101
|
var _el$11 = _el$9.firstChild;
|
|
85
102
|
var _el$15 = _el$11.nextSibling;
|
|
103
|
+
spread(_el$3, [() => {
|
|
104
|
+
return rootAttributes(props);
|
|
105
|
+
}, {
|
|
106
|
+
get "class"() {
|
|
107
|
+
return classes("xds-text-field", props.class);
|
|
108
|
+
},
|
|
109
|
+
get style() {
|
|
110
|
+
return props.style;
|
|
111
|
+
}
|
|
112
|
+
}], true);
|
|
86
113
|
setAttribute(_el$4, "for", id);
|
|
87
114
|
insert(_el$4, () => {
|
|
88
115
|
return props.label;
|
|
@@ -153,7 +180,7 @@ function TextField(props) {
|
|
|
153
180
|
var _el$13 = _el$12.firstChild;
|
|
154
181
|
var _el$14 = _el$13.nextSibling;
|
|
155
182
|
insert(_el$12, () => {
|
|
156
|
-
return
|
|
183
|
+
return value.value().length;
|
|
157
184
|
}, _el$13);
|
|
158
185
|
insert(_el$12, () => {
|
|
159
186
|
return props.maxLength;
|
|
@@ -161,15 +188,6 @@ function TextField(props) {
|
|
|
161
188
|
return _el$12;
|
|
162
189
|
}
|
|
163
190
|
}), _el$15);
|
|
164
|
-
effect(() => {
|
|
165
|
-
return {
|
|
166
|
-
e: readShallow(classes("xds-text-field", props.class)),
|
|
167
|
-
t: readShallow(props.style)
|
|
168
|
-
};
|
|
169
|
-
}, ({ e, t }, _p$) => {
|
|
170
|
-
className(_el$3, e, _p$?.e);
|
|
171
|
-
style(_el$3, t, _p$?.t);
|
|
172
|
-
});
|
|
173
191
|
return _el$3;
|
|
174
192
|
}
|
|
175
193
|
export { TextField };
|
package/dist/dom/Thumbnail.js
CHANGED
|
@@ -2,7 +2,8 @@ import { Badge } from "./Badge.js";
|
|
|
2
2
|
import { useDefaults } from "./Defaults.js";
|
|
3
3
|
import { Icon } from "./Icon.js";
|
|
4
4
|
import { createPicture } from "./picture.js";
|
|
5
|
-
import {
|
|
5
|
+
import { rootAttributes } from "./root.js";
|
|
6
|
+
import { className, createComponent, effect, insert, memo, readShallow, ref, setAttribute, setStyleProperty, spread, template } from "@solidjs/web";
|
|
6
7
|
import { THUMBNAIL_PARTS, classes, pictureClass, rootPart, thumbnailBadgeClass, thumbnailClass, thumbnailWatched } from "@xds/core";
|
|
7
8
|
import { Show } from "solid-js";
|
|
8
9
|
// packages/ui-solid/src/Thumbnail.tsx
|
|
@@ -25,6 +26,16 @@ function Thumbnail(props) {
|
|
|
25
26
|
var _el$4 = _el$3.nextSibling;
|
|
26
27
|
var _el$5 = _el$2.nextSibling;
|
|
27
28
|
var _el$8 = _el$5.nextSibling;
|
|
29
|
+
spread(_el$, [() => {
|
|
30
|
+
return rootAttributes(props);
|
|
31
|
+
}, {
|
|
32
|
+
get "class"() {
|
|
33
|
+
return classes(ROOT, thumbnailClass(props.ratio ?? defaults().ratio), props.class);
|
|
34
|
+
},
|
|
35
|
+
get style() {
|
|
36
|
+
return props.style;
|
|
37
|
+
}
|
|
38
|
+
}], true);
|
|
28
39
|
insert(_el$2, createComponent(Show, {
|
|
29
40
|
get when() {
|
|
30
41
|
return picture.loaded() !== true;
|
|
@@ -102,20 +113,16 @@ function Thumbnail(props) {
|
|
|
102
113
|
}), _el$8);
|
|
103
114
|
effect(() => {
|
|
104
115
|
return {
|
|
105
|
-
e: readShallow(
|
|
106
|
-
t:
|
|
107
|
-
a:
|
|
108
|
-
o: props.alt ?
|
|
109
|
-
i: props.alt || void 0,
|
|
110
|
-
n: props.alt ? void 0 : "true"
|
|
116
|
+
e: readShallow(THUMBNAIL_PARTS.placeholder),
|
|
117
|
+
t: props.alt ? "img" : void 0,
|
|
118
|
+
a: props.alt || void 0,
|
|
119
|
+
o: props.alt ? void 0 : "true"
|
|
111
120
|
};
|
|
112
|
-
}, ({ e, t, a, o
|
|
113
|
-
className(_el
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
o !== _p$?.o && setAttribute(_el$2, "
|
|
117
|
-
i !== _p$?.i && setAttribute(_el$2, "aria-label", i);
|
|
118
|
-
n !== _p$?.n && setAttribute(_el$2, "aria-hidden", n);
|
|
121
|
+
}, ({ e, t, a, o }, _p$) => {
|
|
122
|
+
className(_el$2, e, _p$?.e);
|
|
123
|
+
t !== _p$?.t && setAttribute(_el$2, "role", t);
|
|
124
|
+
a !== _p$?.a && setAttribute(_el$2, "aria-label", a);
|
|
125
|
+
o !== _p$?.o && setAttribute(_el$2, "aria-hidden", o);
|
|
119
126
|
});
|
|
120
127
|
return _el$;
|
|
121
128
|
}
|
package/dist/dom/Toast.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rootAttributes } from "./root.js";
|
|
2
|
+
import { className, createComponent, delegateEvents, effect, insert, readShallow, ref, spread, template } from "@solidjs/web";
|
|
2
3
|
import { TOAST_PARTS, classes, readCssMs, rootPart } from "@xds/core";
|
|
3
4
|
import { Show, createEffect, createSignal, onSettled } from "solid-js";
|
|
4
5
|
import { motion } from "@xds/tokens";
|
|
@@ -50,10 +51,20 @@ function Toast(props) {
|
|
|
50
51
|
get children() {
|
|
51
52
|
var _el$2 = _tmpl$();
|
|
52
53
|
var _el$3 = _el$2.firstChild;
|
|
53
|
-
_el$2
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
spread(_el$2, [() => {
|
|
55
|
+
return rootAttributes(props);
|
|
56
|
+
}, {
|
|
57
|
+
onPointerEnter: (event) => setHovered(event.currentTarget),
|
|
58
|
+
onPointerLeave: () => setHovered(void 0),
|
|
59
|
+
onFocusIn: (event) => setFocused(event.currentTarget),
|
|
60
|
+
onFocusOut: () => setFocused(void 0),
|
|
61
|
+
get "class"() {
|
|
62
|
+
return classes(ROOT, TOAST_PARTS.toast, props.class);
|
|
63
|
+
},
|
|
64
|
+
get style() {
|
|
65
|
+
return props.style;
|
|
66
|
+
}
|
|
67
|
+
}], true);
|
|
57
68
|
insert(_el$3, () => {
|
|
58
69
|
return props.message;
|
|
59
70
|
});
|
|
@@ -76,16 +87,8 @@ function Toast(props) {
|
|
|
76
87
|
return _el$4;
|
|
77
88
|
})()
|
|
78
89
|
}), null);
|
|
79
|
-
effect(() => {
|
|
80
|
-
|
|
81
|
-
e: readShallow(classes(ROOT, TOAST_PARTS.toast, props.class)),
|
|
82
|
-
t: readShallow(props.style),
|
|
83
|
-
a: readShallow(TOAST_PARTS.message)
|
|
84
|
-
};
|
|
85
|
-
}, ({ e, t, a }, _p$) => {
|
|
86
|
-
className(_el$2, e, _p$?.e);
|
|
87
|
-
style(_el$2, t, _p$?.t);
|
|
88
|
-
className(_el$3, a, _p$?.a);
|
|
90
|
+
effect(() => readShallow(TOAST_PARTS.message), (_v$, _$p) => {
|
|
91
|
+
className(_el$3, _v$, _$p);
|
|
89
92
|
});
|
|
90
93
|
return _el$2;
|
|
91
94
|
}
|
|
@@ -95,9 +98,5 @@ function Toast(props) {
|
|
|
95
98
|
});
|
|
96
99
|
return _el$;
|
|
97
100
|
}
|
|
98
|
-
delegateEvents([
|
|
99
|
-
"focusin",
|
|
100
|
-
"focusout",
|
|
101
|
-
"click"
|
|
102
|
-
]);
|
|
101
|
+
delegateEvents(["click"]);
|
|
103
102
|
export { Toast };
|
package/dist/dom/Tooltip.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Portal as Portal$1 } from "./portal.js";
|
|
2
2
|
import { createPresence } from "./presence.js";
|
|
3
|
-
import { withStyle } from "./root.js";
|
|
3
|
+
import { rootAttributes, withStyle } from "./root.js";
|
|
4
4
|
import { TriggerContext, provideTrigger } from "./trigger.js";
|
|
5
|
-
import { createComponent, insert, ref, spread, template } from "@solidjs/web";
|
|
5
|
+
import { createComponent, insert, mergeProps, ref, spread, template } from "@solidjs/web";
|
|
6
6
|
import { classes, readCssMs, readCssPx, tooltipEndSide } from "@xds/core";
|
|
7
7
|
import { normalizeProps, useMachine } from "@zag-js/solid";
|
|
8
8
|
import { Show, createMemo, createUniqueId } from "solid-js";
|
|
@@ -23,14 +23,17 @@ var _tmpl$2 = /* @__PURE__ */ template(`<kbd class=xds-tooltip__shortcut>`);
|
|
|
23
23
|
* while it shows.
|
|
24
24
|
*/
|
|
25
25
|
function Tooltip(props) {
|
|
26
|
-
return createComponent(Overlay, {
|
|
26
|
+
return createComponent(Overlay, mergeProps({
|
|
27
27
|
get label() {
|
|
28
28
|
return props.label;
|
|
29
29
|
},
|
|
30
30
|
get shortcut() {
|
|
31
31
|
return props.shortcut;
|
|
32
32
|
},
|
|
33
|
-
placement: () => props.placement ?? "top"
|
|
33
|
+
placement: () => props.placement ?? "top"
|
|
34
|
+
}, () => {
|
|
35
|
+
return rootAttributes(props);
|
|
36
|
+
}, {
|
|
34
37
|
get "class"() {
|
|
35
38
|
return props.class;
|
|
36
39
|
},
|
|
@@ -40,7 +43,7 @@ function Tooltip(props) {
|
|
|
40
43
|
get children() {
|
|
41
44
|
return props.children;
|
|
42
45
|
}
|
|
43
|
-
});
|
|
46
|
+
}));
|
|
44
47
|
}
|
|
45
48
|
/**
|
|
46
49
|
* A Tooltip at the end edge of its control instead of above or below it: a collapsed Sidebar
|
|
@@ -63,6 +66,7 @@ function Overlay(props) {
|
|
|
63
66
|
const id = createUniqueId();
|
|
64
67
|
const service = useMachine(tooltip.machine, () => ({
|
|
65
68
|
id,
|
|
69
|
+
ids: { content: props.id },
|
|
66
70
|
openDelay: readCssMs(null, "--xds-motion-duration-tooltip-delay", motion.duration.tooltipDelay),
|
|
67
71
|
closeDelay: 0,
|
|
68
72
|
closeOnScroll: false,
|
|
@@ -73,7 +77,7 @@ function Overlay(props) {
|
|
|
73
77
|
}));
|
|
74
78
|
const api = createMemo(() => tooltip.connect(service, normalizeProps));
|
|
75
79
|
const trigger = provideTrigger(() => api().getTriggerProps());
|
|
76
|
-
const contentProps = withStyle(() => api().getContentProps(), () => props.style);
|
|
80
|
+
const contentProps = withStyle(() => api().getContentProps(), () => props.style, rootAttributes(props));
|
|
77
81
|
let content;
|
|
78
82
|
const present = createPresence(() => api().open, () => [content]);
|
|
79
83
|
return [createComponent(TriggerContext, {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { onFormReset } from "@xds/core";
|
|
2
|
+
import { createEffect, createSignal, untrack } from "solid-js";
|
|
3
|
+
// packages/ui-solid/src/controllable.ts
|
|
4
|
+
/**
|
|
5
|
+
* The state of a control that the app may keep or leave to it. It is the app's while the app
|
|
6
|
+
* gives the prop (`controlled`, from `isControlled`), and the control's own otherwise, from
|
|
7
|
+
* `defaultValue`. Either way a change goes to `onChange`, read when the change comes. The state
|
|
8
|
+
* is a plain value, never a function, which a signal would take for an update.
|
|
9
|
+
*/
|
|
10
|
+
function createControllable(options) {
|
|
11
|
+
const [own, setOwn] = createSignal(untrack(options.defaultValue));
|
|
12
|
+
return {
|
|
13
|
+
value: () => options.controlled() ? options.value() : own(),
|
|
14
|
+
set: (next) => {
|
|
15
|
+
if (!untrack(options.controlled)) setOwn(() => next);
|
|
16
|
+
options.onChange(next);
|
|
17
|
+
},
|
|
18
|
+
reset: () => setOwn(() => untrack(options.defaultValue))
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Sets a control that keeps its own state back to its default when its form is reset, as the
|
|
23
|
+
* form sets the native field back. A controlled one shows what its owner gives it, whatever the
|
|
24
|
+
* form does.
|
|
25
|
+
*/
|
|
26
|
+
function resetWithForm(element, controlled, reset) {
|
|
27
|
+
createEffect(controlled, (isControlled) => isControlled ? void 0 : onFormReset(element(), reset));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* One ref from the component's own and the one the app gives (`ref`, read when the element is
|
|
31
|
+
* made), which reaches the native input or button. Solid hands a component a ref the app
|
|
32
|
+
* writes as a variable as a function that sets it.
|
|
33
|
+
*/
|
|
34
|
+
function composeRefs(own, ref) {
|
|
35
|
+
return (element) => {
|
|
36
|
+
own(element);
|
|
37
|
+
apply(ref(), element);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function apply(ref, element) {
|
|
41
|
+
if (typeof ref === "function") ref(element);
|
|
42
|
+
else if (Array.isArray(ref)) for (const each of ref) apply(each, element);
|
|
43
|
+
}
|
|
44
|
+
export { composeRefs, createControllable, resetWithForm };
|
package/dist/dom/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import { Divider } from "./Divider.js";
|
|
|
17
17
|
import { EmptyState } from "./EmptyState.js";
|
|
18
18
|
import { Icon } from "./Icon.js";
|
|
19
19
|
import { IconButton } from "./IconButton.js";
|
|
20
|
+
import { Labels } from "./Labels.js";
|
|
20
21
|
import { ListRow } from "./ListRow.js";
|
|
21
22
|
import { MediaCard } from "./MediaCard.js";
|
|
22
23
|
import { Menu } from "./Menu.js";
|
|
@@ -37,4 +38,4 @@ import { TextField } from "./TextField.js";
|
|
|
37
38
|
import { Thumbnail } from "./Thumbnail.js";
|
|
38
39
|
import { Toast } from "./Toast.js";
|
|
39
40
|
import { Tooltip } from "./Tooltip.js";
|
|
40
|
-
export { Accordion, Avatar, AvatarStack, Badge, Banner, Button, Card, Checkbox, Chip, ChipBar, CountBadge, DatePicker, DateRangePicker, Defaults, Dialog, Divider, EmptyState, Icon, IconButton, ListRow, MediaCard, Menu, ProgressBar, RadioGroup, SearchField, SectionHeader, SegmentedControl, Select, Sidebar, Skeleton, Slider, Spinner, Switch, Tabs, Text, TextField, Thumbnail, Toast, Tooltip };
|
|
41
|
+
export { Accordion, Avatar, AvatarStack, Badge, Banner, Button, Card, Checkbox, Chip, ChipBar, CountBadge, DatePicker, DateRangePicker, Defaults, Dialog, Divider, EmptyState, Icon, IconButton, Labels, ListRow, MediaCard, Menu, ProgressBar, RadioGroup, SearchField, SectionHeader, SegmentedControl, Select, Sidebar, Skeleton, Slider, Spinner, Switch, Tabs, Text, TextField, Thumbnail, Toast, Tooltip };
|
package/dist/dom/preview.js
CHANGED
|
@@ -7,6 +7,7 @@ import { Badge } from "./Badge.js";
|
|
|
7
7
|
import { Spinner } from "./Spinner.js";
|
|
8
8
|
import { Button } from "./Button.js";
|
|
9
9
|
import { IconButton } from "./IconButton.js";
|
|
10
|
+
import { Labels } from "./Labels.js";
|
|
10
11
|
import { Banner } from "./Banner.js";
|
|
11
12
|
import { Card } from "./Card.js";
|
|
12
13
|
import { Checkbox } from "./Checkbox.js";
|
|
@@ -57,6 +58,7 @@ var COMPONENTS = {
|
|
|
57
58
|
DatePicker,
|
|
58
59
|
DateRangePicker,
|
|
59
60
|
Defaults,
|
|
61
|
+
Labels,
|
|
60
62
|
Dialog,
|
|
61
63
|
Divider,
|
|
62
64
|
EmptyState,
|
package/dist/dom/root.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { mergeProps } from "@zag-js/solid";
|
|
2
|
+
import { omit } from "solid-js";
|
|
2
3
|
// packages/ui-solid/src/root.ts
|
|
4
|
+
var isRootAttribute = (key) => key === "id" || typeof key === "string" && key.startsWith("data-");
|
|
5
|
+
/**
|
|
6
|
+
* The `id` and `data-*` attributes among a component's props, to spread on its root element.
|
|
7
|
+
* A live view rather than ui-core's `rootAttributes`, which copies the values: an attribute
|
|
8
|
+
* whose prop changes follows it, and one the app leaves out is not in it, so it overrides
|
|
9
|
+
* nothing it is spread before.
|
|
10
|
+
*/
|
|
11
|
+
function rootAttributes(props) {
|
|
12
|
+
return omit(props, (key) => !isRootAttribute(key));
|
|
13
|
+
}
|
|
3
14
|
var css = (style) => typeof style === "string" ? style : Object.entries(style).filter(([, value]) => value !== void 0).map(([property, value]) => `${property}:${String(value)}`).join(";");
|
|
4
15
|
/**
|
|
5
16
|
* The style of a root element that sets one of its own: the app's comes after it, so that it
|
|
@@ -18,9 +29,10 @@ function layStyle(own, app) {
|
|
|
18
29
|
/**
|
|
19
30
|
* The props Zag gives a component's root element, with the app's style laid over the one Zag
|
|
20
31
|
* sets: Zag's mergeProps merges the two, where a `style` after the spread would replace Zag's.
|
|
21
|
-
*
|
|
32
|
+
* The app's root attributes win over Zag's, so give the machine the app's `id` for the part
|
|
33
|
+
* too (`ids`), which is how Zag finds it. Spread the result on the element.
|
|
22
34
|
*/
|
|
23
|
-
function withStyle(zag, style) {
|
|
24
|
-
return mergeProps(zag, () => ({ style: style() }));
|
|
35
|
+
function withStyle(zag, style, attributes = {}) {
|
|
36
|
+
return mergeProps(zag, attributes, () => ({ style: style() }));
|
|
25
37
|
}
|
|
26
|
-
export { layStyle, withStyle };
|
|
38
|
+
export { layStyle, rootAttributes, withStyle };
|
package/dist/dom/trigger.js
CHANGED
|
@@ -17,15 +17,17 @@ function provideTrigger(own) {
|
|
|
17
17
|
* For a control that can open an overlay: its own props, after those of the overlays it opens.
|
|
18
18
|
* Its own attributes win, its own handlers run first, and its class is added to theirs, so the
|
|
19
19
|
* own class must be a string. While `inert` is true, as for a loading button, the overlays get
|
|
20
|
-
* none of its events and so do not open.
|
|
20
|
+
* none of its events and so do not open. The app's root attributes (`root`) come before the
|
|
21
|
+
* overlays': an overlay finds its trigger by the id it gives it. Spread the result on the
|
|
22
|
+
* element.
|
|
21
23
|
*/
|
|
22
|
-
function withTrigger(own, inert) {
|
|
24
|
+
function withTrigger(own, inert, root = {}) {
|
|
23
25
|
const trigger = useContext(TriggerContext);
|
|
24
26
|
const overlays = () => {
|
|
25
27
|
const props = trigger?.() ?? {};
|
|
26
28
|
if (!inert?.()) return props;
|
|
27
29
|
return Object.fromEntries(Object.entries(props).filter(([key]) => !key.startsWith("on")));
|
|
28
30
|
};
|
|
29
|
-
return mergeProps(overlays, own);
|
|
31
|
+
return mergeProps(root, overlays, own);
|
|
30
32
|
}
|
|
31
33
|
export { TriggerContext, provideTrigger, withTrigger };
|
|
@@ -3,11 +3,12 @@ import * as accordion from "@zag-js/accordion";
|
|
|
3
3
|
import { mergeProps, normalizeProps, useMachine } from "@zag-js/solid";
|
|
4
4
|
import { createEffect, createMemo, createUniqueId, For, Show } from "solid-js";
|
|
5
5
|
import { Icon } from "./Icon.jsx";
|
|
6
|
-
import { withStyle } from "./root.js";
|
|
6
|
+
import { rootAttributes, withStyle } from "./root.js";
|
|
7
7
|
export function Accordion(props) {
|
|
8
8
|
const id = createUniqueId();
|
|
9
9
|
const service = useMachine(accordion.machine, () => ({
|
|
10
10
|
id,
|
|
11
|
+
ids: { root: props.id },
|
|
11
12
|
value: [...props.expanded],
|
|
12
13
|
onValueChange: (details) => props.onChange(details.value),
|
|
13
14
|
multiple: props.multiple ?? false,
|
|
@@ -15,7 +16,7 @@ export function Accordion(props) {
|
|
|
15
16
|
hiddenUntilFound: true,
|
|
16
17
|
}));
|
|
17
18
|
const api = createMemo(() => accordion.connect(service, normalizeProps));
|
|
18
|
-
const root = withStyle(() => api().getRootProps(), () => props.style);
|
|
19
|
+
const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
|
|
19
20
|
const body = (value) => {
|
|
20
21
|
const { hidden: _hidden, ...attributes } = api().getItemContentProps({ value });
|
|
21
22
|
return attributes;
|
package/dist/source/Avatar.d.ts
CHANGED
package/dist/source/Avatar.jsx
CHANGED
|
@@ -2,12 +2,13 @@ import { avatarClass, avatarInitials, classes, pictureClass, rootPart, } from "@
|
|
|
2
2
|
import { Show } from "solid-js";
|
|
3
3
|
import { useDefaults } from "./Defaults.jsx";
|
|
4
4
|
import { createPicture } from "./picture.js";
|
|
5
|
+
import { rootAttributes } from "./root.js";
|
|
5
6
|
const ROOT = rootPart("Avatar");
|
|
6
7
|
export function Avatar(props) {
|
|
7
8
|
const defaults = useDefaults("Avatar");
|
|
8
9
|
const size = () => props.size ?? defaults().size;
|
|
9
10
|
const picture = createPicture(() => props.src);
|
|
10
|
-
return (<span role="img" aria-label={props.name} class={classes(ROOT, avatarClass(size()), props.class)} style={props.style}>
|
|
11
|
+
return (<span {...rootAttributes(props)} role="img" aria-label={props.name} class={classes(ROOT, avatarClass(size()), props.class)} style={props.style}>
|
|
11
12
|
{avatarInitials(props.name, size())}
|
|
12
13
|
<Show when={picture.loaded() !== false && props.src}>
|
|
13
14
|
{(src) => (<img ref={(element) => picture.sync(element, src())} src={src()} alt="" aria-hidden="true" class={pictureClass(picture.loaded() === true)} onLoad={() => picture.onLoad(src())} onError={() => picture.onError(src())}/>)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AvatarStackBaseProps } from "@xds/core";
|
|
2
|
-
import type
|
|
2
|
+
import { type RootProps } from "./root.ts";
|
|
3
3
|
export type AvatarStackProps = AvatarStackBaseProps & RootProps;
|
|
4
4
|
/**
|
|
5
5
|
* Several people in the room of one. Assistive technology gets one image named after
|
|
@@ -2,12 +2,13 @@ import { avatarStack, avatarStackClass, avatarStackItemClass, avatarStackRestCla
|
|
|
2
2
|
import { createMemo, For, Show } from "solid-js";
|
|
3
3
|
import { Avatar } from "./Avatar.jsx";
|
|
4
4
|
import { useDefaults } from "./Defaults.jsx";
|
|
5
|
+
import { rootAttributes } from "./root.js";
|
|
5
6
|
const ROOT = rootPart("AvatarStack");
|
|
6
7
|
export function AvatarStack(props) {
|
|
7
8
|
const defaults = useDefaults("AvatarStack");
|
|
8
9
|
const size = () => props.size ?? defaults().size ?? "md";
|
|
9
10
|
const stack = createMemo(() => avatarStack(props.people, props.max, props.label));
|
|
10
|
-
return (<span role="img" aria-label={stack().name} class={classes(ROOT, avatarStackClass, props.class)} style={props.style}>
|
|
11
|
+
return (<span {...rootAttributes(props)} role="img" aria-label={stack().name} class={classes(ROOT, avatarStackClass, props.class)} style={props.style}>
|
|
11
12
|
<For each={stack().shown}>
|
|
12
13
|
{(person) => (<span aria-hidden="true" class={avatarStackItemClass(size())}>
|
|
13
14
|
<Avatar name={person.name} src={person.src} size={size()}/>
|
package/dist/source/Badge.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type BadgeBaseProps } from "@xds/core";
|
|
2
2
|
import { type Element } from "solid-js";
|
|
3
|
-
import type
|
|
3
|
+
import { type RootProps } from "./root.ts";
|
|
4
4
|
export type { BadgeTone } from "@xds/core";
|
|
5
5
|
export type BadgeProps = BadgeBaseProps & RootProps & {
|
|
6
6
|
children: Element;
|
package/dist/source/Badge.jsx
CHANGED
|
@@ -2,10 +2,11 @@ import { badgeClass, badgeDotClass, classes, rootPart } from "@xds/core";
|
|
|
2
2
|
import { Show } from "solid-js";
|
|
3
3
|
import { useDefaults } from "./Defaults.jsx";
|
|
4
4
|
import { Icon } from "./Icon.jsx";
|
|
5
|
+
import { rootAttributes } from "./root.js";
|
|
5
6
|
const ROOT = rootPart("Badge");
|
|
6
7
|
export function Badge(props) {
|
|
7
8
|
const defaults = useDefaults("Badge");
|
|
8
|
-
return (<span class={classes(ROOT, badgeClass(props.tone ?? defaults().tone), props.class)} style={props.style}>
|
|
9
|
+
return (<span {...rootAttributes(props)} class={classes(ROOT, badgeClass(props.tone ?? defaults().tone), props.class)} style={props.style}>
|
|
9
10
|
<Show when={props.dot}>
|
|
10
11
|
<span aria-hidden="true" class={badgeDotClass}/>
|
|
11
12
|
</Show>
|
package/dist/source/Banner.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type BannerBaseProps } from "@xds/core";
|
|
2
2
|
import { type Element } from "solid-js";
|
|
3
|
-
import type
|
|
3
|
+
import { type RootProps } from "./root.ts";
|
|
4
4
|
export type { BannerTone } from "@xds/core";
|
|
5
5
|
export type BannerProps = BannerBaseProps & RootProps & {
|
|
6
6
|
/** What the person can do about the message. Drawn under it as a small secondary button. */
|
package/dist/source/Banner.jsx
CHANGED
|
@@ -3,11 +3,14 @@ import { Show } from "solid-js";
|
|
|
3
3
|
import { Button } from "./Button.jsx";
|
|
4
4
|
import { useDefaults } from "./Defaults.jsx";
|
|
5
5
|
import { IconButton } from "./IconButton.jsx";
|
|
6
|
+
import { useLabels } from "./Labels.jsx";
|
|
7
|
+
import { rootAttributes } from "./root.js";
|
|
6
8
|
const ROOT = rootPart("Banner");
|
|
7
9
|
export function Banner(props) {
|
|
8
10
|
const defaults = useDefaults("Banner");
|
|
11
|
+
const labels = useLabels();
|
|
9
12
|
const tone = () => props.tone ?? defaults().tone;
|
|
10
|
-
return (<div role={bannerRole(tone())} class={classes(ROOT, bannerClass(tone()), props.class)} style={props.style}>
|
|
13
|
+
return (<div {...rootAttributes(props)} role={bannerRole(tone())} class={classes(ROOT, bannerClass(tone()), props.class)} style={props.style}>
|
|
11
14
|
<svg viewBox="0 0 24 24" aria-hidden="true" class={bannerIconClass(tone())}>
|
|
12
15
|
<path fill="currentColor" d={bannerIconPath(tone())}/>
|
|
13
16
|
</svg>
|
|
@@ -25,7 +28,7 @@ export function Banner(props) {
|
|
|
25
28
|
</div>
|
|
26
29
|
<Show when={props.onDismiss}>
|
|
27
30
|
<div class={BANNER_PARTS.dismiss}>
|
|
28
|
-
<IconButton icon="x" label={props.dismissLabel ??
|
|
31
|
+
<IconButton icon="x" label={props.dismissLabel ?? labels().dismiss} variant="ghost" size="sm" onPress={() => props.onDismiss?.()}/>
|
|
29
32
|
</div>
|
|
30
33
|
</Show>
|
|
31
34
|
</div>);
|
package/dist/source/Button.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { type ButtonBaseProps } from "@xds/core";
|
|
2
2
|
import type { JSX } from "@solidjs/web";
|
|
3
3
|
import { type Element } from "solid-js";
|
|
4
|
-
import type
|
|
4
|
+
import { type RootProps } from "./root.ts";
|
|
5
5
|
export type { ButtonVariant, ControlSize } from "@xds/core";
|
|
6
6
|
export type ButtonProps = ButtonBaseProps & RootProps & {
|
|
7
7
|
onPress?: () => void;
|
|
8
|
+
onFocus?: JSX.FocusEventHandler<HTMLButtonElement, FocusEvent>;
|
|
9
|
+
onBlur?: JSX.FocusEventHandler<HTMLButtonElement, FocusEvent>;
|
|
10
|
+
/** The native button. */
|
|
11
|
+
ref?: JSX.Ref<HTMLButtonElement>;
|
|
8
12
|
/** Leave it out for a button that holds only an icon, and name that one with `aria-label`. */
|
|
9
13
|
children?: Element;
|
|
10
14
|
};
|