@xds/solid 1.1.0 → 1.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/dist/dom/Breadcrumb.js +87 -0
- package/dist/dom/Checkbox.js +12 -6
- package/dist/dom/Combobox.js +295 -0
- package/dist/dom/Link.js +62 -0
- package/dist/dom/Menu.js +15 -14
- package/dist/dom/Pagination.js +132 -0
- package/dist/dom/Popover.js +126 -0
- package/dist/dom/Select.js +75 -48
- package/dist/dom/Table.js +150 -0
- package/dist/dom/TimePicker.js +245 -0
- package/dist/dom/ToastQueue.js +59 -0
- package/dist/dom/base.js +16 -0
- package/dist/dom/index.js +9 -1
- package/dist/dom/modal-popover.js +2 -2
- package/dist/dom/presence.js +3 -2
- package/dist/dom/preview.js +19 -2
- package/dist/dom/rows.js +13 -0
- package/dist/source/Breadcrumb.d.ts +9 -0
- package/dist/source/Breadcrumb.jsx +26 -0
- package/dist/source/Checkbox.d.ts +1 -1
- package/dist/source/Checkbox.jsx +9 -3
- package/dist/source/Combobox.d.ts +16 -0
- package/dist/source/Combobox.jsx +137 -0
- package/dist/source/Link.d.ts +20 -0
- package/dist/source/Link.jsx +21 -0
- package/dist/source/Menu.jsx +8 -2
- package/dist/source/Pagination.d.ts +12 -0
- package/dist/source/Pagination.jsx +51 -0
- package/dist/source/Popover.d.ts +19 -0
- package/dist/source/Popover.jsx +65 -0
- package/dist/source/Select.d.ts +6 -0
- package/dist/source/Select.jsx +32 -8
- package/dist/source/Table.d.ts +17 -0
- package/dist/source/Table.jsx +46 -0
- package/dist/source/TimePicker.d.ts +19 -0
- package/dist/source/TimePicker.jsx +137 -0
- package/dist/source/ToastQueue.d.ts +19 -0
- package/dist/source/ToastQueue.jsx +27 -0
- package/dist/source/base.d.ts +15 -0
- package/dist/source/base.js +15 -0
- package/dist/source/controllable.d.ts +1 -1
- package/dist/source/index.d.ts +9 -1
- package/dist/source/index.js +8 -0
- package/dist/source/modal-popover.js +2 -2
- package/dist/source/presence.js +3 -2
- package/dist/source/preview.d.ts +10 -2
- package/dist/source/preview.jsx +12 -3
- package/dist/source/rows.d.ts +8 -0
- package/dist/source/rows.js +5 -0
- package/eject/files/Accordion.tsx +138 -0
- package/eject/files/Avatar.tsx +48 -0
- package/eject/files/AvatarStack.tsx +51 -0
- package/eject/files/Badge.tsx +39 -0
- package/eject/files/Banner.tsx +80 -0
- package/eject/files/Breadcrumb.tsx +57 -0
- package/eject/files/Button.tsx +90 -0
- package/eject/files/Card.tsx +100 -0
- package/eject/files/Checkbox.tsx +100 -0
- package/eject/files/Chip.tsx +40 -0
- package/eject/files/ChipBar.tsx +34 -0
- package/eject/files/Combobox.tsx +200 -0
- package/eject/files/CountBadge.tsx +55 -0
- package/eject/files/DatePicker.tsx +225 -0
- package/eject/files/DateRangePicker.tsx +319 -0
- package/eject/files/Dialog.tsx +117 -0
- package/eject/files/Divider.tsx +21 -0
- package/eject/files/EmptyState.tsx +39 -0
- package/eject/files/Icon.tsx +37 -0
- package/eject/files/IconButton.tsx +76 -0
- package/eject/files/Link.tsx +61 -0
- package/eject/files/ListRow.tsx +94 -0
- package/eject/files/MediaCard.tsx +116 -0
- package/eject/files/Menu.tsx +190 -0
- package/eject/files/Pagination.tsx +109 -0
- package/eject/files/Popover.tsx +124 -0
- package/eject/files/ProgressBar.tsx +37 -0
- package/eject/files/RadioGroup.tsx +138 -0
- package/eject/files/SearchField.tsx +124 -0
- package/eject/files/SectionHeader.tsx +59 -0
- package/eject/files/SegmentedControl.tsx +79 -0
- package/eject/files/Select.tsx +290 -0
- package/eject/files/Sidebar.tsx +156 -0
- package/eject/files/Skeleton.tsx +33 -0
- package/eject/files/Slider.tsx +131 -0
- package/eject/files/Spinner.tsx +44 -0
- package/eject/files/Switch.tsx +88 -0
- package/eject/files/Table.tsx +98 -0
- package/eject/files/Tabs.tsx +87 -0
- package/eject/files/Text.tsx +38 -0
- package/eject/files/TextField.tsx +171 -0
- package/eject/files/Thumbnail.tsx +84 -0
- package/eject/files/TimePicker.tsx +237 -0
- package/eject/files/Toast.tsx +100 -0
- package/eject/files/ToastQueue.tsx +62 -0
- package/eject/files/Tooltip.tsx +135 -0
- package/eject/files/accordion.css +89 -0
- package/eject/files/accordion.ts +67 -0
- package/eject/files/avatar-stack.ts +57 -0
- package/eject/files/avatar.ts +42 -0
- package/eject/files/badge.ts +30 -0
- package/eject/files/banner.ts +71 -0
- package/eject/files/base.css +38 -0
- package/eject/files/breadcrumb.css +51 -0
- package/eject/files/breadcrumb.ts +42 -0
- package/eject/files/button.css +241 -0
- package/eject/files/button.ts +106 -0
- package/eject/files/card.ts +58 -0
- package/eject/files/checkbox.ts +52 -0
- package/eject/files/chip-bar.ts +16 -0
- package/eject/files/chip.ts +35 -0
- package/eject/files/combobox.css +269 -0
- package/eject/files/combobox.ts +85 -0
- package/eject/files/count-badge.ts +32 -0
- package/eject/files/date-picker.css +375 -0
- package/eject/files/date-picker.ts +280 -0
- package/eject/files/date-range-picker.ts +338 -0
- package/eject/files/dialog.css +139 -0
- package/eject/files/dialog.ts +15 -0
- package/eject/files/divider.ts +5 -0
- package/eject/files/empty-state.ts +22 -0
- package/eject/files/icon.ts +36 -0
- package/eject/files/link.css +64 -0
- package/eject/files/link.ts +63 -0
- package/eject/files/list-row.ts +66 -0
- package/eject/files/media-card.ts +66 -0
- package/eject/files/menu.css +192 -0
- package/eject/files/menu.ts +84 -0
- package/eject/files/overlay.css +40 -0
- package/eject/files/pagination.css +106 -0
- package/eject/files/pagination.ts +68 -0
- package/eject/files/parts.ts +17 -0
- package/eject/files/popover.css +101 -0
- package/eject/files/popover.ts +37 -0
- package/eject/files/progress-bar.ts +26 -0
- package/eject/files/radio-group.css +184 -0
- package/eject/files/radio-group.ts +30 -0
- package/eject/files/section-header.ts +32 -0
- package/eject/files/segmented-control.ts +33 -0
- package/eject/files/select.css +347 -0
- package/eject/files/select.ts +77 -0
- package/eject/files/sidebar.ts +75 -0
- package/eject/files/skeleton.ts +51 -0
- package/eject/files/slider.css +160 -0
- package/eject/files/slider.ts +80 -0
- package/eject/files/spinner.ts +22 -0
- package/eject/files/switch.ts +45 -0
- package/eject/files/table.css +107 -0
- package/eject/files/table.ts +84 -0
- package/eject/files/tabs.css +120 -0
- package/eject/files/tabs.ts +37 -0
- package/eject/files/text-field.css +225 -0
- package/eject/files/text-field.ts +64 -0
- package/eject/files/text.ts +38 -0
- package/eject/files/thumbnail.ts +51 -0
- package/eject/files/time-picker.ts +113 -0
- package/eject/files/toast-queue.ts +64 -0
- package/eject/files/toast.ts +31 -0
- package/eject/files/tooltip.css +111 -0
- package/eject/files/tooltip.ts +21 -0
- package/eject/manifest.json +1027 -0
- package/package.json +12 -4
- package/styles.css +1064 -169
- package/tailwind.css +1295 -218
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { createControllable, resetWithForm } from "./controllable.js";
|
|
2
|
+
import { Icon } from "./Icon.js";
|
|
3
|
+
import { modalPopover } from "./modal-popover.js";
|
|
4
|
+
import { Portal as Portal$1 } from "./portal.js";
|
|
5
|
+
import { createPresence } from "./presence.js";
|
|
6
|
+
import { rootAttributes, withStyle } from "./root.js";
|
|
7
|
+
import { createItemProps } from "./rows.js";
|
|
8
|
+
import { createComponent, delegateEvents, effect, insert, memo, readShallow, ref, setAttribute, spread, style, template } from "@solidjs/web";
|
|
9
|
+
import { classes, isControlled, keepListKeys, readCssPx, timeOptions, timePickerIds, timePickerLocale, underlayLayerStyle } from "@xds/core";
|
|
10
|
+
import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
|
|
11
|
+
import { For, Show, createMemo, createUniqueId } from "solid-js";
|
|
12
|
+
import { space } from "@xds/tokens";
|
|
13
|
+
import * as select from "@zag-js/select";
|
|
14
|
+
// packages/ui-solid/src/TimePicker.tsx
|
|
15
|
+
var _tmpl$ = /* @__PURE__ */ template(`<span class=xds-time-picker__description>`);
|
|
16
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<div class=xds-time-picker__underlay>`);
|
|
17
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<div><div><div>`);
|
|
18
|
+
var _tmpl$4 = /* @__PURE__ */ template(`<div><span></span><button><span></span></button><div class=xds-time-picker__footer><span class=xds-time-picker__error aria-live=polite></span></div><input type=hidden>`);
|
|
19
|
+
var _tmpl$5 = /* @__PURE__ */ template(`<div><span class=xds-time-picker__item-words><span>`);
|
|
20
|
+
/**
|
|
21
|
+
* A field for choosing a time of day. Closed, it looks like a Select with a clock: the chosen
|
|
22
|
+
* time on the locale's own clock ("9:30 AM", "09:30"). Pressed, it opens the times from `min` to
|
|
23
|
+
* `max`, `step` minutes apart, under itself, with the chosen one in view; choosing one calls
|
|
24
|
+
* `onChange` with it as `HH:MM` and closes the list.
|
|
25
|
+
*
|
|
26
|
+
* The field is a button that says it opens a list box, as a Select's does: the arrow keys move,
|
|
27
|
+
* typing the hour jumps to it, and Enter chooses. Without `value` it keeps its own choice, from
|
|
28
|
+
* `defaultValue`.
|
|
29
|
+
*/
|
|
30
|
+
function TimePicker(props) {
|
|
31
|
+
const id = createUniqueId();
|
|
32
|
+
const ids = timePickerIds(id);
|
|
33
|
+
const invalid = () => props.error !== void 0;
|
|
34
|
+
const controlled = () => isControlled(props, "value");
|
|
35
|
+
const value = createControllable({
|
|
36
|
+
controlled,
|
|
37
|
+
value: () => props.value,
|
|
38
|
+
defaultValue: () => props.defaultValue,
|
|
39
|
+
onChange: (next) => {
|
|
40
|
+
if (next !== void 0) props.onChange?.(next);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
let element;
|
|
44
|
+
resetWithForm(() => element, controlled, value.reset);
|
|
45
|
+
const options = createMemo(() => timeOptions({
|
|
46
|
+
min: props.min,
|
|
47
|
+
max: props.max,
|
|
48
|
+
step: props.step,
|
|
49
|
+
value: value.value()
|
|
50
|
+
}, timePickerLocale(props.locale)));
|
|
51
|
+
const collection = createMemo(() => select.collection({
|
|
52
|
+
items: options(),
|
|
53
|
+
itemToValue: (option) => option.value,
|
|
54
|
+
itemToString: (option) => option.label
|
|
55
|
+
}));
|
|
56
|
+
const service = useMachine(select.machine, () => ({
|
|
57
|
+
id,
|
|
58
|
+
ids: { root: props.id },
|
|
59
|
+
collection: collection(),
|
|
60
|
+
value: value.value() === void 0 ? [] : [value.value()],
|
|
61
|
+
onValueChange: (details) => {
|
|
62
|
+
const next = details.value[0];
|
|
63
|
+
if (next !== void 0) value.set(next);
|
|
64
|
+
},
|
|
65
|
+
disabled: props.disabled,
|
|
66
|
+
invalid: invalid(),
|
|
67
|
+
positioning: {
|
|
68
|
+
placement: "bottom-start",
|
|
69
|
+
gutter: readCssPx(null, "--xds-space-1", space[1]),
|
|
70
|
+
sameWidth: true,
|
|
71
|
+
overflowPadding: readCssPx(null, "--xds-space-3", space[3])
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
const api = createMemo(() => select.connect(service, normalizeProps));
|
|
75
|
+
const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
|
|
76
|
+
const current = () => select.connect(service, normalizeProps);
|
|
77
|
+
const labelProps = createMemo(() => {
|
|
78
|
+
const { for: _, ...rest } = api().getLabelProps();
|
|
79
|
+
return rest;
|
|
80
|
+
});
|
|
81
|
+
const triggerProps = createMemo(() => {
|
|
82
|
+
const { role: _role, "aria-invalid": _invalid, "aria-required": _required, onKeyDown: _onKeyDown, ...rest } = api().getTriggerProps();
|
|
83
|
+
return {
|
|
84
|
+
...rest,
|
|
85
|
+
onKeyDown: (event) => {
|
|
86
|
+
if (!api().open && (event.key === "Home" || event.key === "End")) return;
|
|
87
|
+
current().getTriggerProps().onKeyDown?.(event);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
let positioner;
|
|
92
|
+
let surface;
|
|
93
|
+
modalPopover(() => api().open, () => positioner);
|
|
94
|
+
const present = createPresence(() => api().open, () => [surface]);
|
|
95
|
+
const content = mergeProps$1(() => {
|
|
96
|
+
const { onKeyDown: _onKeyDown, ...rest } = api().getContentProps();
|
|
97
|
+
return rest;
|
|
98
|
+
}, { onKeyDown: (event) => {
|
|
99
|
+
keepListKeys(event, surface, ".xds-time-picker__item:not([data-disabled])", (value) => api().setHighlightedValue(value));
|
|
100
|
+
current().getContentProps().onKeyDown?.(event);
|
|
101
|
+
} });
|
|
102
|
+
var _el$ = _tmpl$4();
|
|
103
|
+
var _el$2 = _el$.firstChild;
|
|
104
|
+
var _el$3 = _el$2.nextSibling;
|
|
105
|
+
var _el$4 = _el$3.firstChild;
|
|
106
|
+
var _el$5 = _el$3.nextSibling;
|
|
107
|
+
var _el$7 = _el$5.firstChild;
|
|
108
|
+
var _el$8 = _el$5.nextSibling;
|
|
109
|
+
spread(_el$, [root, { get "class"() {
|
|
110
|
+
return classes("xds-time-picker", props.class);
|
|
111
|
+
} }], true);
|
|
112
|
+
ref(() => {
|
|
113
|
+
return (node) => element = node;
|
|
114
|
+
}, _el$);
|
|
115
|
+
spread(_el$2, [labelProps, { class: "xds-time-picker__label" }], true);
|
|
116
|
+
insert(_el$2, () => {
|
|
117
|
+
return props.label;
|
|
118
|
+
});
|
|
119
|
+
spread(_el$3, [triggerProps, {
|
|
120
|
+
get "aria-labelledby"() {
|
|
121
|
+
return `${ids.value} ${labelProps().id}`;
|
|
122
|
+
},
|
|
123
|
+
get "aria-describedby"() {
|
|
124
|
+
return invalid() ? ids.error : props.description ? ids.description : void 0;
|
|
125
|
+
},
|
|
126
|
+
class: "xds-time-picker__trigger"
|
|
127
|
+
}], true);
|
|
128
|
+
spread(_el$4, [() => {
|
|
129
|
+
return api().getValueTextProps();
|
|
130
|
+
}, {
|
|
131
|
+
get id() {
|
|
132
|
+
return ids.value;
|
|
133
|
+
},
|
|
134
|
+
class: "xds-time-picker__value"
|
|
135
|
+
}], true);
|
|
136
|
+
insert(_el$4, () => {
|
|
137
|
+
return api().valueAsString || props.placeholder;
|
|
138
|
+
});
|
|
139
|
+
insert(_el$3, createComponent(Icon, {
|
|
140
|
+
name: "clock",
|
|
141
|
+
size: "sm",
|
|
142
|
+
class: "text-xds-field-placeholder"
|
|
143
|
+
}), null);
|
|
144
|
+
insert(_el$5, createComponent(Show, {
|
|
145
|
+
get when() {
|
|
146
|
+
return memo(() => {
|
|
147
|
+
return !invalid();
|
|
148
|
+
})() && props.description;
|
|
149
|
+
},
|
|
150
|
+
get children() {
|
|
151
|
+
var _el$6 = _tmpl$();
|
|
152
|
+
insert(_el$6, () => {
|
|
153
|
+
return props.description;
|
|
154
|
+
});
|
|
155
|
+
effect(() => ids.description, (_v$) => {
|
|
156
|
+
setAttribute(_el$6, "id", _v$);
|
|
157
|
+
});
|
|
158
|
+
return _el$6;
|
|
159
|
+
}
|
|
160
|
+
}), _el$7);
|
|
161
|
+
insert(_el$7, () => {
|
|
162
|
+
return props.error;
|
|
163
|
+
});
|
|
164
|
+
insert(_el$, createComponent(Portal$1, { get children() {
|
|
165
|
+
return [createComponent(Show, {
|
|
166
|
+
get when() {
|
|
167
|
+
return api().open;
|
|
168
|
+
},
|
|
169
|
+
get children() {
|
|
170
|
+
var _el$9 = _tmpl$2();
|
|
171
|
+
_el$9._$$mousedown = (event) => event.preventDefault();
|
|
172
|
+
effect(() => readShallow(underlayLayerStyle(api().getPositionerProps().style)), (_v$, _$p) => {
|
|
173
|
+
style(_el$9, _v$, _$p);
|
|
174
|
+
});
|
|
175
|
+
return _el$9;
|
|
176
|
+
}
|
|
177
|
+
}), (() => {
|
|
178
|
+
var _el$10 = _tmpl$3();
|
|
179
|
+
var _el$11 = _el$10.firstChild;
|
|
180
|
+
var _el$12 = _el$11.firstChild;
|
|
181
|
+
spread(_el$10, [() => {
|
|
182
|
+
return api().getPositionerProps();
|
|
183
|
+
}, { class: "xds-time-picker__positioner" }], true);
|
|
184
|
+
ref(() => {
|
|
185
|
+
return (element) => positioner = element;
|
|
186
|
+
}, _el$10);
|
|
187
|
+
spread(_el$11, [content, {
|
|
188
|
+
get hidden() {
|
|
189
|
+
return !present();
|
|
190
|
+
},
|
|
191
|
+
class: "xds-time-picker__content"
|
|
192
|
+
}], true);
|
|
193
|
+
ref(() => {
|
|
194
|
+
return (element) => surface = element;
|
|
195
|
+
}, _el$11);
|
|
196
|
+
spread(_el$12, [() => {
|
|
197
|
+
return api().getListProps();
|
|
198
|
+
}, { class: "xds-time-picker__list" }], true);
|
|
199
|
+
insert(_el$12, createComponent(For, {
|
|
200
|
+
get each() {
|
|
201
|
+
return collection().items;
|
|
202
|
+
},
|
|
203
|
+
children: (option) => {
|
|
204
|
+
const itemProps = createItemProps(() => api().getItemProps({ item: option }));
|
|
205
|
+
const textProps = createItemProps(() => api().getItemTextProps({ item: option }));
|
|
206
|
+
const selected = createMemo(() => api().getItemState({ item: option }).selected);
|
|
207
|
+
var _el$13 = _tmpl$5();
|
|
208
|
+
var _el$15 = _el$13.firstChild.firstChild;
|
|
209
|
+
spread(_el$13, [itemProps, { class: "xds-time-picker__item" }], true);
|
|
210
|
+
spread(_el$15, [textProps, { class: "xds-time-picker__item-label" }], true);
|
|
211
|
+
insert(_el$15, () => {
|
|
212
|
+
return option.label;
|
|
213
|
+
});
|
|
214
|
+
insert(_el$13, createComponent(Show, {
|
|
215
|
+
get when() {
|
|
216
|
+
return selected();
|
|
217
|
+
},
|
|
218
|
+
get children() {
|
|
219
|
+
return createComponent(Icon, {
|
|
220
|
+
name: "check",
|
|
221
|
+
size: "sm"
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}), null);
|
|
225
|
+
return _el$13;
|
|
226
|
+
}
|
|
227
|
+
}));
|
|
228
|
+
return _el$10;
|
|
229
|
+
})()];
|
|
230
|
+
} }), null);
|
|
231
|
+
effect(() => {
|
|
232
|
+
return {
|
|
233
|
+
e: ids.error,
|
|
234
|
+
t: props.name,
|
|
235
|
+
a: value.value() ?? ""
|
|
236
|
+
};
|
|
237
|
+
}, ({ e, t, a }, _p$) => {
|
|
238
|
+
e !== _p$?.e && setAttribute(_el$7, "id", e);
|
|
239
|
+
t !== _p$?.t && setAttribute(_el$8, "name", t);
|
|
240
|
+
_el$8.value = a ?? "";
|
|
241
|
+
});
|
|
242
|
+
return _el$;
|
|
243
|
+
}
|
|
244
|
+
delegateEvents(["mousedown"]);
|
|
245
|
+
export { TimePicker };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { rootAttributes } from "./root.js";
|
|
2
|
+
import { Toast } from "./Toast.js";
|
|
3
|
+
import { createComponent, mergeProps } from "@solidjs/web";
|
|
4
|
+
import { queueToast, readCssMs, toastQueueStep } from "@xds/core";
|
|
5
|
+
import { createEffect, createMemo, createSignal } from "solid-js";
|
|
6
|
+
import { motion } from "@xds/tokens";
|
|
7
|
+
// packages/ui-solid/src/ToastQueue.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Shows the app's toasts one at a time, in their order: the first of `toasts`, which stays for
|
|
10
|
+
* its own `duration` or until its action is taken, and then the next, `motion.duration.normal`
|
|
11
|
+
* after the one before has gone, so that each is read and announced as a message of its own.
|
|
12
|
+
* Add a toast with `queueToast`, which keeps at most three waiting, and take one out in
|
|
13
|
+
* `onClose`. Put one where a single Toast would go.
|
|
14
|
+
*/
|
|
15
|
+
function ToastQueue(props) {
|
|
16
|
+
const [visible, setVisible] = createSignal(void 0);
|
|
17
|
+
const step = createMemo(() => toastQueueStep(props.toasts, visible()));
|
|
18
|
+
const shown = () => step() === "keep" ? props.toasts[0] : void 0;
|
|
19
|
+
createEffect(() => ({
|
|
20
|
+
step: step(),
|
|
21
|
+
first: props.toasts[0]
|
|
22
|
+
}), ({ step, first }) => {
|
|
23
|
+
if (step === "close") {
|
|
24
|
+
setVisible(void 0);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (step !== "wait" || first === void 0) return void 0;
|
|
28
|
+
const gap = readCssMs(null, "--xds-motion-duration-normal", motion.duration.normal);
|
|
29
|
+
const timer = setTimeout(() => setVisible(() => first.id), gap);
|
|
30
|
+
return () => clearTimeout(timer);
|
|
31
|
+
});
|
|
32
|
+
return createComponent(Toast, mergeProps(() => {
|
|
33
|
+
return rootAttributes(props);
|
|
34
|
+
}, {
|
|
35
|
+
get "class"() {
|
|
36
|
+
return props.class;
|
|
37
|
+
},
|
|
38
|
+
get style() {
|
|
39
|
+
return props.style;
|
|
40
|
+
},
|
|
41
|
+
get open() {
|
|
42
|
+
return shown() !== void 0;
|
|
43
|
+
},
|
|
44
|
+
get message() {
|
|
45
|
+
return shown()?.message ?? "";
|
|
46
|
+
},
|
|
47
|
+
get action() {
|
|
48
|
+
return shown()?.action;
|
|
49
|
+
},
|
|
50
|
+
get duration() {
|
|
51
|
+
return shown()?.duration;
|
|
52
|
+
},
|
|
53
|
+
onClose: () => {
|
|
54
|
+
const toast = shown();
|
|
55
|
+
if (toast !== void 0) props.onClose(toast.id);
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
export { ToastQueue, queueToast };
|
package/dist/dom/base.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useDefaults } from "./Defaults.js";
|
|
2
|
+
import { useLabels } from "./Labels.js";
|
|
3
|
+
import { PlaceRow } from "./ListRow.js";
|
|
4
|
+
import { TooltipBeside } from "./Tooltip.js";
|
|
5
|
+
import { composeRefs, createControllable, resetWithForm } from "./controllable.js";
|
|
6
|
+
import { keepChecked, keepValue } from "./controlled.js";
|
|
7
|
+
import { modalPopover } from "./modal-popover.js";
|
|
8
|
+
import { createPicture } from "./picture.js";
|
|
9
|
+
import { Portal } from "./portal.js";
|
|
10
|
+
import { createPresence } from "./presence.js";
|
|
11
|
+
import { layStyle, rootAttributes, withStyle } from "./root.js";
|
|
12
|
+
import { createItemProps } from "./rows.js";
|
|
13
|
+
import { TriggerContext, provideTrigger, withTrigger } from "./trigger.js";
|
|
14
|
+
import { AVATAR_SIZE, DEFAULT_LABELS, PEER_FOCUS, PRESSABLE_ROW, afterAnimations, buttonClass, focusWithoutRing, initials, isControlled, keepListKeys, leaveEscapeToFields, pictureClass, readCssMs, readCssPx, selectOptionIds, switchClass, switchLabelClass, underlayLayerStyle } from "@xds/core";
|
|
15
|
+
import { icons, motion, space } from "@xds/tokens";
|
|
16
|
+
export { AVATAR_SIZE, DEFAULT_LABELS, PEER_FOCUS, PRESSABLE_ROW, PlaceRow, Portal, TooltipBeside, TriggerContext, afterAnimations, buttonClass, composeRefs, createControllable, createItemProps, createPicture, createPresence, focusWithoutRing, icons, initials, isControlled, keepChecked, keepListKeys, keepValue, layStyle, leaveEscapeToFields, modalPopover, motion, pictureClass, provideTrigger, readCssMs, readCssPx, resetWithForm, rootAttributes, selectOptionIds, space, switchClass, switchLabelClass, underlayLayerStyle, useDefaults, useLabels, withStyle, withTrigger };
|
package/dist/dom/index.js
CHANGED
|
@@ -3,11 +3,13 @@ import { Avatar } from "./Avatar.js";
|
|
|
3
3
|
import { AvatarStack } from "./AvatarStack.js";
|
|
4
4
|
import { Badge } from "./Badge.js";
|
|
5
5
|
import { Banner } from "./Banner.js";
|
|
6
|
+
import { Breadcrumb } from "./Breadcrumb.js";
|
|
6
7
|
import { Button } from "./Button.js";
|
|
7
8
|
import { Card } from "./Card.js";
|
|
8
9
|
import { Checkbox } from "./Checkbox.js";
|
|
9
10
|
import { Chip } from "./Chip.js";
|
|
10
11
|
import { ChipBar } from "./ChipBar.js";
|
|
12
|
+
import { Combobox } from "./Combobox.js";
|
|
11
13
|
import { CountBadge } from "./CountBadge.js";
|
|
12
14
|
import { DatePicker } from "./DatePicker.js";
|
|
13
15
|
import { DateRangePicker } from "./DateRangePicker.js";
|
|
@@ -18,9 +20,12 @@ import { EmptyState } from "./EmptyState.js";
|
|
|
18
20
|
import { Icon } from "./Icon.js";
|
|
19
21
|
import { IconButton } from "./IconButton.js";
|
|
20
22
|
import { Labels } from "./Labels.js";
|
|
23
|
+
import { Link } from "./Link.js";
|
|
21
24
|
import { ListRow } from "./ListRow.js";
|
|
22
25
|
import { MediaCard } from "./MediaCard.js";
|
|
23
26
|
import { Menu } from "./Menu.js";
|
|
27
|
+
import { Pagination } from "./Pagination.js";
|
|
28
|
+
import { Popover } from "./Popover.js";
|
|
24
29
|
import { ProgressBar } from "./ProgressBar.js";
|
|
25
30
|
import { RadioGroup } from "./RadioGroup.js";
|
|
26
31
|
import { SearchField } from "./SearchField.js";
|
|
@@ -32,10 +37,13 @@ import { Skeleton } from "./Skeleton.js";
|
|
|
32
37
|
import { Slider } from "./Slider.js";
|
|
33
38
|
import { Spinner } from "./Spinner.js";
|
|
34
39
|
import { Switch } from "./Switch.js";
|
|
40
|
+
import { Table } from "./Table.js";
|
|
35
41
|
import { Tabs } from "./Tabs.js";
|
|
36
42
|
import { Text } from "./Text.js";
|
|
37
43
|
import { TextField } from "./TextField.js";
|
|
38
44
|
import { Thumbnail } from "./Thumbnail.js";
|
|
45
|
+
import { TimePicker } from "./TimePicker.js";
|
|
39
46
|
import { Toast } from "./Toast.js";
|
|
47
|
+
import { ToastQueue, queueToast } from "./ToastQueue.js";
|
|
40
48
|
import { Tooltip } from "./Tooltip.js";
|
|
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 };
|
|
49
|
+
export { Accordion, Avatar, AvatarStack, Badge, Banner, Breadcrumb, Button, Card, Checkbox, Chip, ChipBar, Combobox, CountBadge, DatePicker, DateRangePicker, Defaults, Dialog, Divider, EmptyState, Icon, IconButton, Labels, Link, ListRow, MediaCard, Menu, Pagination, Popover, ProgressBar, RadioGroup, SearchField, SectionHeader, SegmentedControl, Select, Sidebar, Skeleton, Slider, Spinner, Switch, Table, Tabs, Text, TextField, Thumbnail, TimePicker, Toast, ToastQueue, Tooltip, queueToast };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createEffect } from "solid-js";
|
|
1
|
+
import { createEffect, createMemo } from "solid-js";
|
|
2
2
|
import { ariaHidden } from "@zag-js/aria-hidden";
|
|
3
3
|
import { preventBodyScroll } from "@zag-js/remove-scroll";
|
|
4
4
|
// packages/ui-solid/src/modal-popover.ts
|
|
@@ -9,7 +9,7 @@ import { preventBodyScroll } from "@zag-js/remove-scroll";
|
|
|
9
9
|
* the page. Zag does all of this around a dialog, but not around a menu or a select.
|
|
10
10
|
*/
|
|
11
11
|
function modalPopover(open, popup) {
|
|
12
|
-
createEffect(open, (isOpen) => {
|
|
12
|
+
createEffect(createMemo(open), (isOpen) => {
|
|
13
13
|
if (!isOpen) return;
|
|
14
14
|
const unlock = preventBodyScroll(document);
|
|
15
15
|
const reveal = ariaHidden(() => [popup() ?? null], { defer: true });
|
package/dist/dom/presence.js
CHANGED
|
@@ -8,13 +8,14 @@ import { createEffect, createMemo, createSignal } from "solid-js";
|
|
|
8
8
|
*/
|
|
9
9
|
function createPresence(open, parts) {
|
|
10
10
|
const [exited, setExited] = createSignal(true);
|
|
11
|
-
|
|
11
|
+
const isOpen = createMemo(open);
|
|
12
|
+
createEffect(isOpen, (isOpen) => {
|
|
12
13
|
if (isOpen) {
|
|
13
14
|
setExited(false);
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
return afterAnimations(parts(), () => setExited(true));
|
|
17
18
|
});
|
|
18
|
-
return createMemo(() =>
|
|
19
|
+
return createMemo(() => isOpen() || !exited());
|
|
19
20
|
}
|
|
20
21
|
export { createPresence };
|
package/dist/dom/preview.js
CHANGED
|
@@ -9,10 +9,13 @@ import { Button } from "./Button.js";
|
|
|
9
9
|
import { IconButton } from "./IconButton.js";
|
|
10
10
|
import { Labels } from "./Labels.js";
|
|
11
11
|
import { Banner } from "./Banner.js";
|
|
12
|
+
import { Link } from "./Link.js";
|
|
13
|
+
import { Breadcrumb } from "./Breadcrumb.js";
|
|
12
14
|
import { Card } from "./Card.js";
|
|
13
15
|
import { Checkbox } from "./Checkbox.js";
|
|
14
16
|
import { Chip } from "./Chip.js";
|
|
15
17
|
import { ChipBar } from "./ChipBar.js";
|
|
18
|
+
import { Combobox } from "./Combobox.js";
|
|
16
19
|
import { CountBadge } from "./CountBadge.js";
|
|
17
20
|
import { DatePicker } from "./DatePicker.js";
|
|
18
21
|
import { DateRangePicker } from "./DateRangePicker.js";
|
|
@@ -23,6 +26,8 @@ import { ListRow } from "./ListRow.js";
|
|
|
23
26
|
import { Thumbnail } from "./Thumbnail.js";
|
|
24
27
|
import { MediaCard } from "./MediaCard.js";
|
|
25
28
|
import { Menu } from "./Menu.js";
|
|
29
|
+
import { Pagination } from "./Pagination.js";
|
|
30
|
+
import { Popover } from "./Popover.js";
|
|
26
31
|
import { ProgressBar } from "./ProgressBar.js";
|
|
27
32
|
import { RadioGroup } from "./RadioGroup.js";
|
|
28
33
|
import { SearchField } from "./SearchField.js";
|
|
@@ -34,10 +39,13 @@ import { Sidebar } from "./Sidebar.js";
|
|
|
34
39
|
import { Skeleton } from "./Skeleton.js";
|
|
35
40
|
import { Slider } from "./Slider.js";
|
|
36
41
|
import { Switch } from "./Switch.js";
|
|
42
|
+
import { Table } from "./Table.js";
|
|
37
43
|
import { Tabs } from "./Tabs.js";
|
|
38
44
|
import { Text } from "./Text.js";
|
|
39
45
|
import { TextField } from "./TextField.js";
|
|
46
|
+
import { TimePicker } from "./TimePicker.js";
|
|
40
47
|
import { Toast } from "./Toast.js";
|
|
48
|
+
import { ToastQueue } from "./ToastQueue.js";
|
|
41
49
|
import "./index.js";
|
|
42
50
|
import { dynamic, memo } from "@solidjs/web";
|
|
43
51
|
import { Show, createComponent as createComponent$1, createSignal, onSettled, untrack } from "solid-js";
|
|
@@ -49,24 +57,29 @@ var COMPONENTS = {
|
|
|
49
57
|
AvatarStack,
|
|
50
58
|
Badge,
|
|
51
59
|
Banner,
|
|
60
|
+
Breadcrumb,
|
|
52
61
|
Button,
|
|
53
62
|
Card,
|
|
54
63
|
Checkbox,
|
|
55
64
|
Chip,
|
|
56
65
|
ChipBar,
|
|
66
|
+
Combobox,
|
|
57
67
|
CountBadge,
|
|
58
68
|
DatePicker,
|
|
59
69
|
DateRangePicker,
|
|
60
70
|
Defaults,
|
|
61
|
-
Labels,
|
|
62
71
|
Dialog,
|
|
63
72
|
Divider,
|
|
64
73
|
EmptyState,
|
|
65
74
|
Icon,
|
|
66
75
|
IconButton,
|
|
76
|
+
Labels,
|
|
77
|
+
Link,
|
|
67
78
|
ListRow,
|
|
68
79
|
MediaCard,
|
|
69
80
|
Menu,
|
|
81
|
+
Pagination,
|
|
82
|
+
Popover,
|
|
70
83
|
ProgressBar,
|
|
71
84
|
RadioGroup,
|
|
72
85
|
SearchField,
|
|
@@ -78,15 +91,19 @@ var COMPONENTS = {
|
|
|
78
91
|
Slider,
|
|
79
92
|
Spinner,
|
|
80
93
|
Switch,
|
|
94
|
+
Table,
|
|
81
95
|
Tabs,
|
|
82
96
|
Text,
|
|
83
97
|
TextField,
|
|
84
98
|
Thumbnail,
|
|
99
|
+
TimePicker,
|
|
85
100
|
Toast,
|
|
101
|
+
ToastQueue,
|
|
86
102
|
Tooltip
|
|
87
103
|
};
|
|
88
104
|
function Preview(props) {
|
|
89
105
|
const screen = untrack(() => props.screen);
|
|
106
|
+
const components = untrack(() => props.components);
|
|
90
107
|
const state = {};
|
|
91
108
|
const writes = /* @__PURE__ */ new Map();
|
|
92
109
|
for (const [key, first] of Object.entries(screen.state)) {
|
|
@@ -117,7 +134,7 @@ function Preview(props) {
|
|
|
117
134
|
return host.draw(slot.fallback);
|
|
118
135
|
}
|
|
119
136
|
});
|
|
120
|
-
const type = slot.kind === "element" ? dynamic(() => slot.tag, { static: true }) : COMPONENTS[slot.name];
|
|
137
|
+
const type = slot.kind === "element" ? dynamic(() => slot.tag, { static: true }) : components?.[slot.name] ?? COMPONENTS[slot.name];
|
|
121
138
|
return createComponent$1(type, propsOf(slot));
|
|
122
139
|
}
|
|
123
140
|
};
|
package/dist/dom/rows.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { sameItemProps } from "@xds/core";
|
|
2
|
+
import { createMemo } from "solid-js";
|
|
3
|
+
// packages/ui-solid/src/rows.ts
|
|
4
|
+
/**
|
|
5
|
+
* The props a machine gives one row's part, followed only while they draw something else
|
|
6
|
+
* (`sameItemProps`). Read through `api()`, a row's props are made anew on every change to the
|
|
7
|
+
* machine, and each row's spread would set its attributes and its handlers again; this way a
|
|
8
|
+
* step of the highlight sets them on the two rows it moves between.
|
|
9
|
+
*/
|
|
10
|
+
function createItemProps(props) {
|
|
11
|
+
return createMemo(props, { equals: sameItemProps });
|
|
12
|
+
}
|
|
13
|
+
export { createItemProps };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type BreadcrumbBaseProps } from "@xds/core";
|
|
2
|
+
import { type RootProps } from "./root.ts";
|
|
3
|
+
export type { BreadcrumbItem } from "@xds/core";
|
|
4
|
+
export type BreadcrumbProps = BreadcrumbBaseProps & RootProps;
|
|
5
|
+
/**
|
|
6
|
+
* Where the current view sits in the app: the places above it, each a link, then the view
|
|
7
|
+
* itself. A navigation landmark; the current place is marked as the page.
|
|
8
|
+
*/
|
|
9
|
+
export declare function Breadcrumb(props: BreadcrumbProps): import("@solidjs/web").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BREADCRUMB_PARTS, BREADCRUMB_SEPARATOR, classes, rootPart, } from "@xds/core";
|
|
2
|
+
import { For, Show } from "solid-js";
|
|
3
|
+
import { Icon } from "./Icon.jsx";
|
|
4
|
+
import { useLabels } from "./Labels.jsx";
|
|
5
|
+
import { Link } from "./Link.jsx";
|
|
6
|
+
import { rootAttributes } from "./root.js";
|
|
7
|
+
const ROOT = rootPart("Breadcrumb");
|
|
8
|
+
export function Breadcrumb(props) {
|
|
9
|
+
const labels = useLabels();
|
|
10
|
+
return (<nav {...rootAttributes(props)} aria-label={props.label ?? labels().breadcrumb} class={classes(ROOT, props.class)} style={props.style}>
|
|
11
|
+
<ol class={BREADCRUMB_PARTS.list}>
|
|
12
|
+
<For each={props.items}>
|
|
13
|
+
{(item, index) => (<li class={BREADCRUMB_PARTS.item}>
|
|
14
|
+
<Show when={index() < props.items.length - 1} fallback={<span aria-current="page" class={BREADCRUMB_PARTS.current}>
|
|
15
|
+
{item.label}
|
|
16
|
+
</span>}>
|
|
17
|
+
<Link href={item.href} onPress={() => item.onPress?.()}>
|
|
18
|
+
{item.label}
|
|
19
|
+
</Link>
|
|
20
|
+
<Icon name={BREADCRUMB_SEPARATOR.name} size={BREADCRUMB_SEPARATOR.size} class={BREADCRUMB_PARTS.separator}/>
|
|
21
|
+
</Show>
|
|
22
|
+
</li>)}
|
|
23
|
+
</For>
|
|
24
|
+
</ol>
|
|
25
|
+
</nav>);
|
|
26
|
+
}
|
|
@@ -11,6 +11,6 @@ export type CheckboxProps = CheckboxBaseProps & RootProps & {
|
|
|
11
11
|
/**
|
|
12
12
|
* A choice that is applied later, with the form it belongs to. A native checkbox: the input is
|
|
13
13
|
* hidden and the box is drawn beside it. Without `checked` it keeps its own state, from
|
|
14
|
-
* `defaultChecked`.
|
|
14
|
+
* `defaultChecked`. With `indeterminate` it shows a dash and is reported as mixed.
|
|
15
15
|
*/
|
|
16
16
|
export declare function Checkbox(props: CheckboxProps): JSX.Element;
|
package/dist/source/Checkbox.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Show } from "solid-js";
|
|
1
|
+
import { checkboxBoxClass, checkboxClass, checkboxLabelClass, checkboxMark, checkboxMarkClass, classes, isControlled, rootPart, } from "@xds/core";
|
|
2
|
+
import { createEffect, Show } from "solid-js";
|
|
3
3
|
import { composeRefs, createControllable, resetWithForm } from "./controllable.js";
|
|
4
4
|
import { keepChecked } from "./controlled.js";
|
|
5
5
|
import { rootAttributes } from "./root.js";
|
|
@@ -15,14 +15,20 @@ export function Checkbox(props) {
|
|
|
15
15
|
});
|
|
16
16
|
let input;
|
|
17
17
|
resetWithForm(() => input, controlled, checked.reset);
|
|
18
|
+
const indeterminate = () => props.indeterminate ?? false;
|
|
19
|
+
createEffect(indeterminate, (value) => {
|
|
20
|
+
if (input)
|
|
21
|
+
input.indeterminate = value;
|
|
22
|
+
});
|
|
18
23
|
return (<label {...rootAttributes(props)} class={classes(ROOT, checkboxClass, props.class)} style={props.style}>
|
|
19
24
|
<input ref={composeRefs((element) => (input = element), () => props.ref)} type="checkbox" aria-label={props["aria-label"]} class="peer sr-only" checked={checked.value()} defaultChecked={controlled() ? checked.value() : defaultChecked()} disabled={props.disabled} name={props.name || undefined} onChange={(event) => {
|
|
25
|
+
event.currentTarget.indeterminate = indeterminate();
|
|
20
26
|
checked.set(event.currentTarget.checked);
|
|
21
27
|
keepChecked(event.currentTarget, checked.value);
|
|
22
28
|
}} onFocus={(event) => props.onFocus?.(event)} onBlur={(event) => props.onBlur?.(event)}/>
|
|
23
29
|
<span class={checkboxBoxClass}>
|
|
24
30
|
<svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class={checkboxMarkClass}>
|
|
25
|
-
<path d={
|
|
31
|
+
<path d={checkboxMark(indeterminate())} stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
26
32
|
</svg>
|
|
27
33
|
</span>
|
|
28
34
|
<Show when={props.label}>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ComboboxBaseProps } from "@xds/core";
|
|
2
|
+
import { type RootProps } from "./root.ts";
|
|
3
|
+
export type ComboboxProps<Value extends string = string> = ComboboxBaseProps<Value> & RootProps & {
|
|
4
|
+
onChange?: (value: Value) => void;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* A field for choosing one option from a list by typing part of its name. As the person types,
|
|
8
|
+
* the options whose label holds what was typed open under it, those that start with it first,
|
|
9
|
+
* and the first is highlighted, so Enter chooses it. Choosing an option calls `onChange`, puts
|
|
10
|
+
* its label in the field and closes the list. Text that names no option goes back to the chosen
|
|
11
|
+
* option's label when the field is left. When nothing matches, the list says so.
|
|
12
|
+
*
|
|
13
|
+
* Without `value` it keeps its own choice, from `defaultValue`. Given `value`, even as
|
|
14
|
+
* `undefined`, it shows that.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Combobox<Value extends string = string>(props: ComboboxProps<Value>): import("@solidjs/web").JSX.Element;
|