@xds/solid 0.0.0-stage → 0.2.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,233 @@
|
|
|
1
|
+
import { Icon } from "./Icon.js";
|
|
2
|
+
import { PlaceRow } from "./ListRow.js";
|
|
3
|
+
import { TooltipBeside } from "./Tooltip.js";
|
|
4
|
+
import { withTrigger } from "./trigger.js";
|
|
5
|
+
import { className, createComponent, effect, insert, memo, readShallow, setAttribute, spread, style, template } from "@solidjs/web";
|
|
6
|
+
import { SIDEBAR_PARTS, classes, rootPart, sidebarClass, sidebarCount, sidebarIconClass, sidebarRailButtonClass, sidebarSectionClass, sidebarTitleClass } from "@xds/core";
|
|
7
|
+
import { For, Show, createMemo, createUniqueId } from "solid-js";
|
|
8
|
+
// packages/ui-solid/src/Sidebar.tsx
|
|
9
|
+
var _tmpl$ = /* @__PURE__ */ template(`<nav><div></div><!>`);
|
|
10
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<div>`);
|
|
11
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<div aria-hidden=true>`);
|
|
12
|
+
var _tmpl$4 = /* @__PURE__ */ template(`<div><!><ul>`);
|
|
13
|
+
var _tmpl$5 = /* @__PURE__ */ template(`<p>`);
|
|
14
|
+
var _tmpl$6 = /* @__PURE__ */ template(`<li>`);
|
|
15
|
+
var _tmpl$7 = /* @__PURE__ */ template(`<span>`);
|
|
16
|
+
var _tmpl$8 = /* @__PURE__ */ template(`<button>`);
|
|
17
|
+
var ROOT = rootPart("Sidebar");
|
|
18
|
+
/**
|
|
19
|
+
* The top-level places of an app used with a pointer: the counterpart of TabBar on touch. Each
|
|
20
|
+
* row is a compact list row; the current one is selected, its title heavier and its icon
|
|
21
|
+
* filled, so the place does not depend on the tint alone.
|
|
22
|
+
*
|
|
23
|
+
* It is navigation named by `label`, and the current row says it is the current page.
|
|
24
|
+
* Collapsed, the rows keep their names, and show them in a Tooltip under a pointer and on
|
|
25
|
+
* keyboard focus.
|
|
26
|
+
*/
|
|
27
|
+
function Sidebar(props) {
|
|
28
|
+
const id = createUniqueId();
|
|
29
|
+
const collapsed = () => props.collapsed ?? false;
|
|
30
|
+
var _el$ = _tmpl$();
|
|
31
|
+
var _el$2 = _el$.firstChild;
|
|
32
|
+
var _el$3 = _el$2.nextSibling;
|
|
33
|
+
insert(_el$, createComponent(Show, {
|
|
34
|
+
get when() {
|
|
35
|
+
return props.header;
|
|
36
|
+
},
|
|
37
|
+
children: (header) => (() => {
|
|
38
|
+
var _el$4 = _tmpl$2();
|
|
39
|
+
insert(_el$4, header);
|
|
40
|
+
effect(() => readShallow(SIDEBAR_PARTS.edge), (_v$, _$p) => {
|
|
41
|
+
className(_el$4, _v$, _$p);
|
|
42
|
+
});
|
|
43
|
+
return _el$4;
|
|
44
|
+
})()
|
|
45
|
+
}), _el$2);
|
|
46
|
+
insert(_el$2, createComponent(For, {
|
|
47
|
+
get each() {
|
|
48
|
+
return props.sections;
|
|
49
|
+
},
|
|
50
|
+
children: (section, index) => {
|
|
51
|
+
const title = () => `${id}-${index()}`;
|
|
52
|
+
var _el$5 = _tmpl$4();
|
|
53
|
+
var _el$6 = _el$5.firstChild;
|
|
54
|
+
var _el$8 = _el$6.nextSibling;
|
|
55
|
+
insert(_el$5, createComponent(Show, {
|
|
56
|
+
get when() {
|
|
57
|
+
return section.title;
|
|
58
|
+
},
|
|
59
|
+
children: (text) => (() => {
|
|
60
|
+
var _el$9 = _tmpl$5();
|
|
61
|
+
insert(_el$9, text);
|
|
62
|
+
effect(() => {
|
|
63
|
+
return {
|
|
64
|
+
e: title(),
|
|
65
|
+
t: readShallow(sidebarTitleClass(collapsed()))
|
|
66
|
+
};
|
|
67
|
+
}, ({ e, t }, _p$) => {
|
|
68
|
+
e !== _p$?.e && setAttribute(_el$9, "id", e);
|
|
69
|
+
className(_el$9, t, _p$?.t);
|
|
70
|
+
});
|
|
71
|
+
return _el$9;
|
|
72
|
+
})()
|
|
73
|
+
}), _el$6);
|
|
74
|
+
insert(_el$5, createComponent(Show, {
|
|
75
|
+
get when() {
|
|
76
|
+
return memo(() => {
|
|
77
|
+
return !!collapsed();
|
|
78
|
+
})() ? index() > 0 : collapsed();
|
|
79
|
+
},
|
|
80
|
+
get children() {
|
|
81
|
+
var _el$7 = _tmpl$3();
|
|
82
|
+
effect(() => readShallow(SIDEBAR_PARTS.rule), (_v$, _$p) => {
|
|
83
|
+
className(_el$7, _v$, _$p);
|
|
84
|
+
});
|
|
85
|
+
return _el$7;
|
|
86
|
+
}
|
|
87
|
+
}), _el$8);
|
|
88
|
+
insert(_el$8, createComponent(For, {
|
|
89
|
+
get each() {
|
|
90
|
+
return section.items;
|
|
91
|
+
},
|
|
92
|
+
children: (item) => {
|
|
93
|
+
const selected = () => item.value === props.value;
|
|
94
|
+
var _el$10 = _tmpl$6();
|
|
95
|
+
insert(_el$10, createComponent(Show, {
|
|
96
|
+
get when() {
|
|
97
|
+
return collapsed();
|
|
98
|
+
},
|
|
99
|
+
get fallback() {
|
|
100
|
+
return createComponent(PlaceRow, {
|
|
101
|
+
compact: true,
|
|
102
|
+
current: "page",
|
|
103
|
+
get selected() {
|
|
104
|
+
return selected();
|
|
105
|
+
},
|
|
106
|
+
onPress: () => props.onChange(item.value),
|
|
107
|
+
get title() {
|
|
108
|
+
return item.label;
|
|
109
|
+
},
|
|
110
|
+
get leading() {
|
|
111
|
+
return createComponent(Icon, {
|
|
112
|
+
get name() {
|
|
113
|
+
return item.icon;
|
|
114
|
+
},
|
|
115
|
+
size: "md",
|
|
116
|
+
get filled() {
|
|
117
|
+
return selected();
|
|
118
|
+
},
|
|
119
|
+
get "class"() {
|
|
120
|
+
return sidebarIconClass(selected());
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
get trailing() {
|
|
125
|
+
return createComponent(Show, {
|
|
126
|
+
get when() {
|
|
127
|
+
return sidebarCount(item.count);
|
|
128
|
+
},
|
|
129
|
+
children: (count) => (() => {
|
|
130
|
+
var _el$11 = _tmpl$7();
|
|
131
|
+
insert(_el$11, count);
|
|
132
|
+
effect(() => readShallow(SIDEBAR_PARTS.count), (_v$, _$p) => {
|
|
133
|
+
className(_el$11, _v$, _$p);
|
|
134
|
+
});
|
|
135
|
+
return _el$11;
|
|
136
|
+
})()
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
get children() {
|
|
142
|
+
return createComponent(TooltipBeside, {
|
|
143
|
+
get label() {
|
|
144
|
+
return item.label;
|
|
145
|
+
},
|
|
146
|
+
get children() {
|
|
147
|
+
return createComponent(RailButton, {
|
|
148
|
+
get label() {
|
|
149
|
+
return item.label;
|
|
150
|
+
},
|
|
151
|
+
get icon() {
|
|
152
|
+
return item.icon;
|
|
153
|
+
},
|
|
154
|
+
get selected() {
|
|
155
|
+
return selected();
|
|
156
|
+
},
|
|
157
|
+
onPress: () => props.onChange(item.value)
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}));
|
|
163
|
+
effect(() => readShallow(SIDEBAR_PARTS.item), (_v$, _$p) => {
|
|
164
|
+
className(_el$10, _v$, _$p);
|
|
165
|
+
});
|
|
166
|
+
return _el$10;
|
|
167
|
+
}
|
|
168
|
+
}));
|
|
169
|
+
effect(() => {
|
|
170
|
+
return {
|
|
171
|
+
e: readShallow(sidebarSectionClass(index(), collapsed())),
|
|
172
|
+
t: section.title ? title() : void 0,
|
|
173
|
+
a: readShallow(SIDEBAR_PARTS.list)
|
|
174
|
+
};
|
|
175
|
+
}, ({ e, t, a }, _p$) => {
|
|
176
|
+
className(_el$5, e, _p$?.e);
|
|
177
|
+
t !== _p$?.t && setAttribute(_el$8, "aria-labelledby", t);
|
|
178
|
+
className(_el$8, a, _p$?.a);
|
|
179
|
+
});
|
|
180
|
+
return _el$5;
|
|
181
|
+
}
|
|
182
|
+
}));
|
|
183
|
+
insert(_el$, createComponent(Show, {
|
|
184
|
+
get when() {
|
|
185
|
+
return props.footer;
|
|
186
|
+
},
|
|
187
|
+
children: (footer) => (() => {
|
|
188
|
+
var _el$12 = _tmpl$2();
|
|
189
|
+
insert(_el$12, footer);
|
|
190
|
+
effect(() => readShallow(SIDEBAR_PARTS.edge), (_v$, _$p) => {
|
|
191
|
+
className(_el$12, _v$, _$p);
|
|
192
|
+
});
|
|
193
|
+
return _el$12;
|
|
194
|
+
})()
|
|
195
|
+
}), _el$3);
|
|
196
|
+
effect(() => {
|
|
197
|
+
return {
|
|
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);
|
|
208
|
+
});
|
|
209
|
+
return _el$;
|
|
210
|
+
}
|
|
211
|
+
/** A row of the collapsed rail. It is the trigger of the Tooltip that names it. */
|
|
212
|
+
function RailButton(props) {
|
|
213
|
+
const attributes = withTrigger(createMemo(() => ({
|
|
214
|
+
type: "button",
|
|
215
|
+
class: sidebarRailButtonClass(props.selected),
|
|
216
|
+
"aria-label": props.label,
|
|
217
|
+
"aria-current": props.selected ? "page" : void 0,
|
|
218
|
+
onClick: () => props.onPress()
|
|
219
|
+
})));
|
|
220
|
+
var _el$13 = _tmpl$8();
|
|
221
|
+
spread(_el$13, attributes, true);
|
|
222
|
+
insert(_el$13, createComponent(Icon, {
|
|
223
|
+
get name() {
|
|
224
|
+
return props.icon;
|
|
225
|
+
},
|
|
226
|
+
size: "md",
|
|
227
|
+
get filled() {
|
|
228
|
+
return props.selected;
|
|
229
|
+
}
|
|
230
|
+
}));
|
|
231
|
+
return _el$13;
|
|
232
|
+
}
|
|
233
|
+
export { Sidebar };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useDefaults } from "./Defaults.js";
|
|
2
|
+
import { layStyle } from "./root.js";
|
|
3
|
+
import { className, effect, readShallow, style, template } from "@solidjs/web";
|
|
4
|
+
import { classes, rootPart, skeletonClass, skeletonSize } from "@xds/core";
|
|
5
|
+
// packages/ui-solid/src/Skeleton.tsx
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template(`<span aria-hidden=true>`);
|
|
7
|
+
var ROOT = rootPart("Skeleton");
|
|
8
|
+
/**
|
|
9
|
+
* Holds the place of content that is loading, in the shape the content will have. It pulses,
|
|
10
|
+
* and stands still for people who ask for less motion.
|
|
11
|
+
*
|
|
12
|
+
* It is hidden from assistive technology: the screen that shows skeletons says that it is
|
|
13
|
+
* loading, once, instead of every placeholder saying so.
|
|
14
|
+
*/
|
|
15
|
+
function Skeleton(props) {
|
|
16
|
+
const defaults = useDefaults("Skeleton");
|
|
17
|
+
const shape = () => props.shape ?? defaults().shape;
|
|
18
|
+
var _el$ = _tmpl$();
|
|
19
|
+
effect(() => {
|
|
20
|
+
return {
|
|
21
|
+
e: readShallow(classes(ROOT, skeletonClass(shape()), props.class)),
|
|
22
|
+
t: readShallow(layStyle(skeletonSize({
|
|
23
|
+
shape: shape(),
|
|
24
|
+
width: props.width,
|
|
25
|
+
height: props.height
|
|
26
|
+
}), props.style))
|
|
27
|
+
};
|
|
28
|
+
}, ({ e, t }, _p$) => {
|
|
29
|
+
className(_el$, e, _p$?.e);
|
|
30
|
+
style(_el$, t, _p$?.t);
|
|
31
|
+
});
|
|
32
|
+
return _el$;
|
|
33
|
+
}
|
|
34
|
+
export { Skeleton };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { withStyle } from "./root.js";
|
|
2
|
+
import { createComponent, insert, ref, spread, template } from "@solidjs/web";
|
|
3
|
+
import { classes, focusThumbOnPress, sliderArrowValue, sliderPageSize, sliderValueText } from "@xds/core";
|
|
4
|
+
import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
|
|
5
|
+
import { Show, createMemo, createUniqueId } from "solid-js";
|
|
6
|
+
import * as slider from "@zag-js/slider";
|
|
7
|
+
// packages/ui-solid/src/Slider.tsx
|
|
8
|
+
var _tmpl$ = /* @__PURE__ */ template(`<output>`);
|
|
9
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<div><label></label><div><div><div></div></div><div><input>`);
|
|
10
|
+
/**
|
|
11
|
+
* Picks a number in a range by dragging the thumb, or by pressing the track where it should
|
|
12
|
+
* go. The values snap to `step`.
|
|
13
|
+
*
|
|
14
|
+
* It is a slider named by its label with its value, minimum and maximum, and each arrow key
|
|
15
|
+
* moves it one step.
|
|
16
|
+
*/
|
|
17
|
+
function Slider(props) {
|
|
18
|
+
const id = createUniqueId();
|
|
19
|
+
const min = () => props.min ?? 0;
|
|
20
|
+
const max = () => props.max ?? 100;
|
|
21
|
+
const step = () => props.step ?? 1;
|
|
22
|
+
const pageSize = () => sliderPageSize({
|
|
23
|
+
min: min(),
|
|
24
|
+
max: max(),
|
|
25
|
+
step: step()
|
|
26
|
+
});
|
|
27
|
+
const service = useMachine(slider.machine, () => ({
|
|
28
|
+
id,
|
|
29
|
+
value: [props.value],
|
|
30
|
+
onValueChange: (details) => props.onChange(details.value[0] ?? min()),
|
|
31
|
+
min: min(),
|
|
32
|
+
max: max(),
|
|
33
|
+
step: step(),
|
|
34
|
+
largeStep: pageSize(),
|
|
35
|
+
disabled: props.disabled,
|
|
36
|
+
thumbAlignment: "center",
|
|
37
|
+
getAriaValueText: (details) => sliderValueText(details.value)
|
|
38
|
+
}));
|
|
39
|
+
const api = createMemo(() => slider.connect(service, normalizeProps));
|
|
40
|
+
const root = withStyle(() => api().getRootProps(), () => props.style);
|
|
41
|
+
const thumb = mergeProps$1(() => api().getThumbProps({ index: 0 }), {
|
|
42
|
+
draggable: "false",
|
|
43
|
+
onKeyDown: (event) => {
|
|
44
|
+
if (props.disabled) return;
|
|
45
|
+
const next = sliderArrowValue(event, {
|
|
46
|
+
value: api().value[0] ?? min(),
|
|
47
|
+
min: min(),
|
|
48
|
+
max: max(),
|
|
49
|
+
step: step(),
|
|
50
|
+
pageSize: pageSize()
|
|
51
|
+
});
|
|
52
|
+
if (next !== void 0) api().setThumbValue(0, next);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
let thumbElement;
|
|
56
|
+
const control = mergeProps$1(() => api().getControlProps(), { onPointerDown: (event) => {
|
|
57
|
+
if (!props.disabled) focusThumbOnPress(event, thumbElement);
|
|
58
|
+
} });
|
|
59
|
+
var _el$ = _tmpl$2();
|
|
60
|
+
var _el$2 = _el$.firstChild;
|
|
61
|
+
var _el$4 = _el$2.nextSibling;
|
|
62
|
+
var _el$5 = _el$4.firstChild;
|
|
63
|
+
var _el$6 = _el$5.firstChild;
|
|
64
|
+
var _el$7 = _el$5.nextSibling;
|
|
65
|
+
var _el$8 = _el$7.firstChild;
|
|
66
|
+
spread(_el$, [root, {
|
|
67
|
+
role: "group",
|
|
68
|
+
get "aria-labelledby"() {
|
|
69
|
+
return api().getLabelProps().id;
|
|
70
|
+
},
|
|
71
|
+
get "class"() {
|
|
72
|
+
return classes("xds-slider", props.class);
|
|
73
|
+
}
|
|
74
|
+
}], true);
|
|
75
|
+
spread(_el$2, [() => {
|
|
76
|
+
return api().getLabelProps();
|
|
77
|
+
}, { class: "xds-slider__label" }], true);
|
|
78
|
+
insert(_el$2, () => {
|
|
79
|
+
return props.label;
|
|
80
|
+
});
|
|
81
|
+
insert(_el$, createComponent(Show, {
|
|
82
|
+
get when() {
|
|
83
|
+
return props.showValue;
|
|
84
|
+
},
|
|
85
|
+
get children() {
|
|
86
|
+
var _el$3 = _tmpl$();
|
|
87
|
+
spread(_el$3, [() => {
|
|
88
|
+
return api().getValueTextProps();
|
|
89
|
+
}, {
|
|
90
|
+
"aria-live": "off",
|
|
91
|
+
class: "xds-slider__output"
|
|
92
|
+
}], true);
|
|
93
|
+
insert(_el$3, () => {
|
|
94
|
+
return sliderValueText(api().value[0] ?? props.value);
|
|
95
|
+
});
|
|
96
|
+
return _el$3;
|
|
97
|
+
}
|
|
98
|
+
}), _el$4);
|
|
99
|
+
spread(_el$4, [control, { class: "xds-slider__control" }], true);
|
|
100
|
+
spread(_el$5, [() => {
|
|
101
|
+
return api().getTrackProps();
|
|
102
|
+
}, { class: "xds-slider__track" }], true);
|
|
103
|
+
spread(_el$6, [() => {
|
|
104
|
+
return api().getRangeProps();
|
|
105
|
+
}, { class: "xds-slider__range" }], false);
|
|
106
|
+
spread(_el$7, [thumb, { class: "xds-slider__thumb" }], true);
|
|
107
|
+
ref(() => {
|
|
108
|
+
return (element) => thumbElement = element;
|
|
109
|
+
}, _el$7);
|
|
110
|
+
spread(_el$8, () => {
|
|
111
|
+
return api().getHiddenInputProps({ index: 0 });
|
|
112
|
+
}, false);
|
|
113
|
+
return _el$;
|
|
114
|
+
}
|
|
115
|
+
export { Slider };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useDefaults } from "./Defaults.js";
|
|
2
|
+
import { className, effect, readShallow, setAttribute, style, template } from "@solidjs/web";
|
|
3
|
+
import { classes, rootPart, spinnerClass } from "@xds/core";
|
|
4
|
+
// packages/ui-solid/src/Spinner.tsx
|
|
5
|
+
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>`);
|
|
6
|
+
var ROOT = rootPart("Spinner");
|
|
7
|
+
/**
|
|
8
|
+
* Says that something is in progress and how long is unknown. Takes the color of the text around
|
|
9
|
+
* it. With `label` it is announced; without one it is decoration next to text that already says
|
|
10
|
+
* what is happening.
|
|
11
|
+
*/
|
|
12
|
+
function Spinner(props) {
|
|
13
|
+
const defaults = useDefaults("Spinner");
|
|
14
|
+
var _el$ = _tmpl$();
|
|
15
|
+
var _el$2 = _el$.firstChild;
|
|
16
|
+
effect(() => {
|
|
17
|
+
return {
|
|
18
|
+
e: readShallow(classes(ROOT, "inline-flex shrink-0", props.class)),
|
|
19
|
+
t: readShallow(props.style),
|
|
20
|
+
a: props.label ? "status" : void 0,
|
|
21
|
+
o: props.label || void 0,
|
|
22
|
+
i: props.label ? void 0 : "true",
|
|
23
|
+
n: readShallow(spinnerClass(props.size ?? defaults().size))
|
|
24
|
+
};
|
|
25
|
+
}, ({ e, t, a, o, i, n }, _p$) => {
|
|
26
|
+
className(_el$, e, _p$?.e);
|
|
27
|
+
style(_el$, t, _p$?.t);
|
|
28
|
+
a !== _p$?.a && setAttribute(_el$, "role", a);
|
|
29
|
+
o !== _p$?.o && setAttribute(_el$, "aria-label", o);
|
|
30
|
+
i !== _p$?.i && setAttribute(_el$, "aria-hidden", i);
|
|
31
|
+
className(_el$2, n, _p$?.n);
|
|
32
|
+
});
|
|
33
|
+
return _el$;
|
|
34
|
+
}
|
|
35
|
+
export { Spinner };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { keepChecked } from "./controlled.js";
|
|
2
|
+
import { className, createComponent, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
|
|
3
|
+
import { classes, rootPart, switchClass, switchLabelClass, switchThumbClass, switchTrackClass } from "@xds/core";
|
|
4
|
+
import { Show } from "solid-js";
|
|
5
|
+
// packages/ui-solid/src/Switch.tsx
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template(`<span>`);
|
|
7
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<label><input type=checkbox role=switch class="peer sr-only"><span><span>`);
|
|
8
|
+
var ROOT = rootPart("Switch");
|
|
9
|
+
/**
|
|
10
|
+
* Turns a setting on or off, and takes effect at once. For a choice that is applied later,
|
|
11
|
+
* with a form, use a Checkbox.
|
|
12
|
+
*
|
|
13
|
+
* 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.
|
|
15
|
+
*/
|
|
16
|
+
function Switch(props) {
|
|
17
|
+
var _el$ = _tmpl$2();
|
|
18
|
+
var _el$2 = _el$.firstChild;
|
|
19
|
+
var _el$3 = _el$2.nextSibling;
|
|
20
|
+
var _el$4 = _el$3.firstChild;
|
|
21
|
+
_el$2.addEventListener("change", (event) => {
|
|
22
|
+
props.onChange(event.currentTarget.checked);
|
|
23
|
+
keepChecked(event.currentTarget, () => props.checked);
|
|
24
|
+
});
|
|
25
|
+
insert(_el$, createComponent(Show, {
|
|
26
|
+
get when() {
|
|
27
|
+
return props.label;
|
|
28
|
+
},
|
|
29
|
+
get children() {
|
|
30
|
+
var _el$5 = _tmpl$();
|
|
31
|
+
insert(_el$5, () => {
|
|
32
|
+
return props.label;
|
|
33
|
+
});
|
|
34
|
+
effect(() => readShallow(switchLabelClass), (_v$, _$p) => {
|
|
35
|
+
className(_el$5, _v$, _$p);
|
|
36
|
+
});
|
|
37
|
+
return _el$5;
|
|
38
|
+
}
|
|
39
|
+
}), null);
|
|
40
|
+
effect(() => {
|
|
41
|
+
return {
|
|
42
|
+
e: readShallow(classes(ROOT, switchClass, props.class)),
|
|
43
|
+
t: readShallow(props.style),
|
|
44
|
+
a: props.checked ? "true" : "false",
|
|
45
|
+
o: props["aria-label"],
|
|
46
|
+
i: props.checked,
|
|
47
|
+
n: props.checked,
|
|
48
|
+
s: props.disabled,
|
|
49
|
+
h: readShallow(switchTrackClass),
|
|
50
|
+
r: readShallow(switchThumbClass)
|
|
51
|
+
};
|
|
52
|
+
}, ({ e, t, a, o, i, n, s, h, r }, _p$) => {
|
|
53
|
+
className(_el$, e, _p$?.e);
|
|
54
|
+
style(_el$, t, _p$?.t);
|
|
55
|
+
a !== _p$?.a && setAttribute(_el$2, "aria-checked", a);
|
|
56
|
+
o !== _p$?.o && setAttribute(_el$2, "aria-label", o);
|
|
57
|
+
_el$2.checked = i;
|
|
58
|
+
n !== _p$?.n && (_el$2.defaultChecked = n);
|
|
59
|
+
s !== _p$?.s && setAttribute(_el$2, "disabled", s);
|
|
60
|
+
className(_el$3, h, _p$?.h);
|
|
61
|
+
className(_el$4, r, _p$?.r);
|
|
62
|
+
});
|
|
63
|
+
return _el$;
|
|
64
|
+
}
|
|
65
|
+
export { Switch };
|
package/dist/dom/Tabs.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Icon } from "./Icon.js";
|
|
2
|
+
import { withStyle } from "./root.js";
|
|
3
|
+
import { createComponent, insert, spread, template } from "@solidjs/web";
|
|
4
|
+
import { classes, tabStopIndex, tabsClass } from "@xds/core";
|
|
5
|
+
import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
|
|
6
|
+
import { For, Show, createMemo, createUniqueId } from "solid-js";
|
|
7
|
+
import * as tabs from "@zag-js/tabs";
|
|
8
|
+
// packages/ui-solid/src/Tabs.tsx
|
|
9
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div><div><div>`);
|
|
10
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<button><!><!>`);
|
|
11
|
+
/**
|
|
12
|
+
* Switches between views inside one screen. For two to four short modes a SegmentedControl is
|
|
13
|
+
* lighter; tabs are for more items, longer labels, or a row that may have to scroll.
|
|
14
|
+
*
|
|
15
|
+
* The selected tab is underlined as well as darker, so the choice does not depend on color.
|
|
16
|
+
* This is only the row: the app shows the view that matches `value`. The arrow keys move
|
|
17
|
+
* between tabs.
|
|
18
|
+
*/
|
|
19
|
+
function Tabs(props) {
|
|
20
|
+
const id = createUniqueId();
|
|
21
|
+
const service = useMachine(tabs.machine, () => ({
|
|
22
|
+
id,
|
|
23
|
+
value: props.value,
|
|
24
|
+
onValueChange: (details) => props.onChange(details.value)
|
|
25
|
+
}));
|
|
26
|
+
const api = createMemo(() => tabs.connect(service, normalizeProps));
|
|
27
|
+
const root = withStyle(() => api().getRootProps(), () => props.style);
|
|
28
|
+
var _el$ = _tmpl$();
|
|
29
|
+
var _el$2 = _el$.firstChild;
|
|
30
|
+
var _el$3 = _el$2.firstChild;
|
|
31
|
+
spread(_el$, [root, { get "class"() {
|
|
32
|
+
return classes(tabsClass(props.fullWidth), props.class);
|
|
33
|
+
} }], true);
|
|
34
|
+
spread(_el$2, [() => {
|
|
35
|
+
return api().getListProps();
|
|
36
|
+
}, {
|
|
37
|
+
get "aria-label"() {
|
|
38
|
+
return props.label;
|
|
39
|
+
},
|
|
40
|
+
class: "xds-tabs__list"
|
|
41
|
+
}], true);
|
|
42
|
+
insert(_el$2, createComponent(For, {
|
|
43
|
+
get each() {
|
|
44
|
+
return props.items;
|
|
45
|
+
},
|
|
46
|
+
children: (item) => {
|
|
47
|
+
const trigger = () => api().getTriggerProps({ value: item.value });
|
|
48
|
+
const tabIndex = () => tabStopIndex(api().focusedValue, item.value, trigger().tabIndex);
|
|
49
|
+
var _el$4 = _tmpl$2();
|
|
50
|
+
var _el$5 = _el$4.firstChild;
|
|
51
|
+
var _el$6 = _el$5.nextSibling;
|
|
52
|
+
spread(_el$4, [() => {
|
|
53
|
+
return mergeProps$1(trigger, () => ({ tabIndex: tabIndex() }));
|
|
54
|
+
}, {
|
|
55
|
+
"aria-controls": void 0,
|
|
56
|
+
class: "xds-tabs__tab"
|
|
57
|
+
}], true);
|
|
58
|
+
insert(_el$4, createComponent(Show, {
|
|
59
|
+
get when() {
|
|
60
|
+
return item.icon;
|
|
61
|
+
},
|
|
62
|
+
children: (name) => createComponent(Icon, {
|
|
63
|
+
get name() {
|
|
64
|
+
return name();
|
|
65
|
+
},
|
|
66
|
+
size: "sm"
|
|
67
|
+
})
|
|
68
|
+
}), _el$5);
|
|
69
|
+
insert(_el$4, () => {
|
|
70
|
+
return item.label;
|
|
71
|
+
}, _el$6);
|
|
72
|
+
return _el$4;
|
|
73
|
+
}
|
|
74
|
+
}), _el$3);
|
|
75
|
+
spread(_el$3, [() => {
|
|
76
|
+
return api().getIndicatorProps();
|
|
77
|
+
}, { class: "xds-tabs__indicator" }], false);
|
|
78
|
+
return _el$;
|
|
79
|
+
}
|
|
80
|
+
export { Tabs };
|
package/dist/dom/Text.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useDefaults } from "./Defaults.js";
|
|
2
|
+
import { createComponent, dynamic } from "@solidjs/web";
|
|
3
|
+
import { classes, rootPart, textClass } from "@xds/core";
|
|
4
|
+
// packages/ui-solid/src/Text.tsx
|
|
5
|
+
var ROOT = rootPart("Text");
|
|
6
|
+
function Text(props) {
|
|
7
|
+
const Tag = dynamic(() => props.as ?? "p");
|
|
8
|
+
const defaults = useDefaults("Text");
|
|
9
|
+
return createComponent(Tag, {
|
|
10
|
+
get "class"() {
|
|
11
|
+
return classes(ROOT, textClass({
|
|
12
|
+
variant: props.variant ?? defaults().variant,
|
|
13
|
+
tone: props.tone ?? defaults().tone
|
|
14
|
+
}), props.class);
|
|
15
|
+
},
|
|
16
|
+
get style() {
|
|
17
|
+
return props.style;
|
|
18
|
+
},
|
|
19
|
+
get children() {
|
|
20
|
+
return props.children;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export { Text };
|