@xds/solid 1.0.1 → 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/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/Breadcrumb.js +87 -0
- package/dist/dom/Button.js +10 -3
- package/dist/dom/Card.js +31 -26
- package/dist/dom/Checkbox.js +57 -26
- package/dist/dom/Chip.js +21 -17
- package/dist/dom/ChipBar.js +17 -13
- package/dist/dom/Combobox.js +295 -0
- 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/Link.js +62 -0
- package/dist/dom/ListRow.js +34 -28
- package/dist/dom/MediaCard.js +32 -23
- package/dist/dom/Menu.js +18 -15
- package/dist/dom/Pagination.js +132 -0
- package/dist/dom/Popover.js +126 -0
- 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 +91 -51
- 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/Table.js +150 -0
- 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/TimePicker.js +245 -0
- package/dist/dom/Toast.js +19 -20
- package/dist/dom/ToastQueue.js +59 -0
- package/dist/dom/Tooltip.js +10 -6
- package/dist/dom/base.js +16 -0
- package/dist/dom/controllable.js +44 -0
- package/dist/dom/index.js +10 -1
- package/dist/dom/modal-popover.js +2 -2
- package/dist/dom/presence.js +3 -2
- package/dist/dom/preview.js +20 -1
- package/dist/dom/root.js +16 -4
- package/dist/dom/rows.js +13 -0
- 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/Breadcrumb.d.ts +9 -0
- package/dist/source/Breadcrumb.jsx +26 -0
- 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 +26 -8
- 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/Combobox.d.ts +16 -0
- package/dist/source/Combobox.jsx +137 -0
- 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/Link.d.ts +20 -0
- package/dist/source/Link.jsx +21 -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 +11 -3
- 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/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 +10 -1
- package/dist/source/Select.jsx +46 -11
- 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/Table.d.ts +17 -0
- package/dist/source/Table.jsx +46 -0
- 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/TimePicker.d.ts +19 -0
- package/dist/source/TimePicker.jsx +137 -0
- package/dist/source/Toast.d.ts +1 -1
- package/dist/source/Toast.jsx +2 -1
- package/dist/source/ToastQueue.d.ts +19 -0
- package/dist/source/ToastQueue.jsx +27 -0
- package/dist/source/Tooltip.jsx +4 -3
- package/dist/source/base.d.ts +15 -0
- package/dist/source/base.js +15 -0
- package/dist/source/controllable.d.ts +30 -0
- package/dist/source/controllable.js +30 -0
- package/dist/source/index.d.ts +10 -1
- package/dist/source/index.js +9 -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 -2
- package/dist/source/root.d.ts +14 -4
- package/dist/source/root.js +7 -2
- package/dist/source/rows.d.ts +8 -0
- package/dist/source/rows.js +5 -0
- package/dist/source/trigger.d.ts +4 -2
- package/dist/source/trigger.js +2 -2
- 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 +1066 -167
- package/tailwind.css +1295 -218
package/dist/dom/Select.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
+
import { createControllable } from "./controllable.js";
|
|
1
2
|
import { Icon } from "./Icon.js";
|
|
2
3
|
import { modalPopover } from "./modal-popover.js";
|
|
3
4
|
import { Portal as Portal$1 } from "./portal.js";
|
|
4
5
|
import { createPresence } from "./presence.js";
|
|
5
|
-
import { withStyle } from "./root.js";
|
|
6
|
+
import { rootAttributes, withStyle } from "./root.js";
|
|
7
|
+
import { createItemProps } from "./rows.js";
|
|
6
8
|
import { createComponent, delegateEvents, effect, insert, memo, readShallow, ref, setAttribute, spread, style, template } from "@solidjs/web";
|
|
7
|
-
import { classes, keepListKeys, readCssPx, selectOptionIds, underlayLayerStyle } from "@xds/core";
|
|
9
|
+
import { classes, isControlled, keepListKeys, orderedValues, readCssPx, selectOptionIds, selectedLabels, underlayLayerStyle } from "@xds/core";
|
|
8
10
|
import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
|
|
9
11
|
import { For, Show, createMemo, createUniqueId } from "solid-js";
|
|
10
12
|
import { space } from "@xds/tokens";
|
|
11
13
|
import * as select from "@zag-js/select";
|
|
12
14
|
// packages/ui-solid/src/Select.tsx
|
|
13
15
|
var _tmpl$ = /* @__PURE__ */ template(`<span class=xds-select__description>`);
|
|
14
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<
|
|
15
|
-
var _tmpl$3 = /* @__PURE__ */ template(`<div
|
|
16
|
-
var _tmpl$4 = /* @__PURE__ */ template(`<div><
|
|
17
|
-
var _tmpl$5 = /* @__PURE__ */ template(`<
|
|
18
|
-
var _tmpl$6 = /* @__PURE__ */ template(`<
|
|
19
|
-
var _tmpl$7 = /* @__PURE__ */ template(`<
|
|
16
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<option value>`);
|
|
17
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<div class=xds-select__underlay>`);
|
|
18
|
+
var _tmpl$4 = /* @__PURE__ */ template(`<div><div><div>`);
|
|
19
|
+
var _tmpl$5 = /* @__PURE__ */ template(`<div><span></span><button><span></span></button><div class=xds-select__footer><span class=xds-select__error aria-live=polite></span></div><select><!><!>`);
|
|
20
|
+
var _tmpl$6 = /* @__PURE__ */ template(`<option>`);
|
|
21
|
+
var _tmpl$7 = /* @__PURE__ */ template(`<span class=xds-select__item-description>`);
|
|
22
|
+
var _tmpl$8 = /* @__PURE__ */ template(`<div><span class=xds-select__item-words><span>`);
|
|
20
23
|
/**
|
|
21
24
|
* A field for choosing one option from a list too long to show at once. Closed, it looks like a
|
|
22
25
|
* TextField; pressed, it opens the list under itself with a Menu's surface, as wide as the
|
|
@@ -26,6 +29,13 @@ var _tmpl$7 = /* @__PURE__ */ template(`<div><span class=xds-select__item-words>
|
|
|
26
29
|
* The field is a button that says it opens a list box and whether the list is open. In the list
|
|
27
30
|
* the arrow keys move, typing jumps to an option, and Enter chooses. The chosen option is
|
|
28
31
|
* selected for assistive technology and marked with a check.
|
|
32
|
+
*
|
|
33
|
+
* Without `value` it keeps its own choice, from `defaultValue`. Given `value`, even as
|
|
34
|
+
* `undefined`, it shows that.
|
|
35
|
+
*
|
|
36
|
+
* With `multiple`, any number of options can be chosen: choosing one adds it or takes it away,
|
|
37
|
+
* the list stays open, and `onValuesChange` gets them all. The list box says that several can
|
|
38
|
+
* be chosen.
|
|
29
39
|
*/
|
|
30
40
|
function Select(props) {
|
|
31
41
|
const id = createUniqueId();
|
|
@@ -33,6 +43,21 @@ function Select(props) {
|
|
|
33
43
|
const descriptionId = `${id}-description`;
|
|
34
44
|
const errorId = `${id}-error`;
|
|
35
45
|
const invalid = () => props.error !== void 0;
|
|
46
|
+
const value = createControllable({
|
|
47
|
+
controlled: () => isControlled(props, "value"),
|
|
48
|
+
value: () => props.value,
|
|
49
|
+
defaultValue: () => props.defaultValue,
|
|
50
|
+
onChange: (next) => {
|
|
51
|
+
if (next !== void 0) props.onChange?.(next);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const values = createControllable({
|
|
55
|
+
controlled: () => isControlled(props, "values"),
|
|
56
|
+
value: () => props.values ?? [],
|
|
57
|
+
defaultValue: () => props.defaultValues ?? [],
|
|
58
|
+
onChange: (next) => props.onValuesChange?.([...next])
|
|
59
|
+
});
|
|
60
|
+
const multiple = () => props.multiple ?? false;
|
|
36
61
|
const collection = createMemo(() => select.collection({
|
|
37
62
|
items: [...props.options],
|
|
38
63
|
itemToValue: (option) => option.value,
|
|
@@ -40,12 +65,19 @@ function Select(props) {
|
|
|
40
65
|
}));
|
|
41
66
|
const service = useMachine(select.machine, () => ({
|
|
42
67
|
id,
|
|
68
|
+
ids: { root: props.id },
|
|
43
69
|
collection: collection(),
|
|
44
|
-
value:
|
|
70
|
+
value: multiple() ? [...values.value()] : value.value() === void 0 ? [] : [value.value()],
|
|
45
71
|
onValueChange: (details) => {
|
|
72
|
+
if (multiple()) {
|
|
73
|
+
values.set(orderedValues(props.options, details.value));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
46
76
|
const next = details.value[0];
|
|
47
|
-
if (next !== void 0)
|
|
77
|
+
if (next !== void 0) value.set(next);
|
|
48
78
|
},
|
|
79
|
+
multiple: multiple(),
|
|
80
|
+
closeOnSelect: !multiple(),
|
|
49
81
|
disabled: props.disabled,
|
|
50
82
|
invalid: invalid(),
|
|
51
83
|
name: props.name,
|
|
@@ -57,7 +89,7 @@ function Select(props) {
|
|
|
57
89
|
}
|
|
58
90
|
}));
|
|
59
91
|
const api = createMemo(() => select.connect(service, normalizeProps));
|
|
60
|
-
const root = withStyle(() => api().getRootProps(), () => props.style);
|
|
92
|
+
const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
|
|
61
93
|
const current = () => select.connect(service, normalizeProps);
|
|
62
94
|
const labelProps = createMemo(() => {
|
|
63
95
|
const { for: _, ...rest } = api().getLabelProps();
|
|
@@ -84,14 +116,15 @@ function Select(props) {
|
|
|
84
116
|
keepListKeys(event, surface, ".xds-select__item:not([data-disabled])", (value) => api().setHighlightedValue(value));
|
|
85
117
|
current().getContentProps().onKeyDown?.(event);
|
|
86
118
|
} });
|
|
87
|
-
var _el$ = _tmpl$
|
|
119
|
+
var _el$ = _tmpl$5();
|
|
88
120
|
var _el$2 = _el$.firstChild;
|
|
89
121
|
var _el$3 = _el$2.nextSibling;
|
|
90
122
|
var _el$4 = _el$3.firstChild;
|
|
91
123
|
var _el$5 = _el$3.nextSibling;
|
|
92
124
|
var _el$7 = _el$5.firstChild;
|
|
93
125
|
var _el$8 = _el$5.nextSibling;
|
|
94
|
-
_el$8.firstChild;
|
|
126
|
+
var _el$10 = _el$8.firstChild;
|
|
127
|
+
var _el$11 = _el$10.nextSibling;
|
|
95
128
|
spread(_el$, [root, { get "class"() {
|
|
96
129
|
return classes("xds-select", props.class);
|
|
97
130
|
} }], true);
|
|
@@ -115,7 +148,7 @@ function Select(props) {
|
|
|
115
148
|
class: "xds-select__value"
|
|
116
149
|
}], true);
|
|
117
150
|
insert(_el$4, () => {
|
|
118
|
-
return api().valueAsString || props.placeholder;
|
|
151
|
+
return (multiple() ? selectedLabels(props.options, values.value()) : api().valueAsString) || props.placeholder;
|
|
119
152
|
});
|
|
120
153
|
insert(_el$3, createComponent(Icon, {
|
|
121
154
|
name: "chevrons-up-down",
|
|
@@ -144,45 +177,53 @@ function Select(props) {
|
|
|
144
177
|
spread(_el$8, () => {
|
|
145
178
|
return api().getHiddenSelectProps();
|
|
146
179
|
}, true);
|
|
180
|
+
insert(_el$8, createComponent(Show, {
|
|
181
|
+
get when() {
|
|
182
|
+
return !multiple();
|
|
183
|
+
},
|
|
184
|
+
get children() {
|
|
185
|
+
return _tmpl$2();
|
|
186
|
+
}
|
|
187
|
+
}), _el$10);
|
|
147
188
|
insert(_el$8, createComponent(For, {
|
|
148
189
|
get each() {
|
|
149
190
|
return props.options;
|
|
150
191
|
},
|
|
151
192
|
children: (option) => (() => {
|
|
152
|
-
var _el$
|
|
153
|
-
insert(_el$
|
|
193
|
+
var _el$16 = _tmpl$6();
|
|
194
|
+
insert(_el$16, () => {
|
|
154
195
|
return option.label;
|
|
155
196
|
});
|
|
156
197
|
effect(() => option.value, (_v$) => {
|
|
157
|
-
_el$
|
|
198
|
+
_el$16.value = _v$;
|
|
158
199
|
});
|
|
159
|
-
return _el$
|
|
200
|
+
return _el$16;
|
|
160
201
|
})()
|
|
161
|
-
}),
|
|
202
|
+
}), _el$11);
|
|
162
203
|
insert(_el$, createComponent(Portal$1, { get children() {
|
|
163
204
|
return [createComponent(Show, {
|
|
164
205
|
get when() {
|
|
165
206
|
return api().open;
|
|
166
207
|
},
|
|
167
208
|
get children() {
|
|
168
|
-
var _el$
|
|
169
|
-
_el$
|
|
209
|
+
var _el$12 = _tmpl$3();
|
|
210
|
+
_el$12._$$mousedown = (event) => event.preventDefault();
|
|
170
211
|
effect(() => readShallow(underlayLayerStyle(api().getPositionerProps().style)), (_v$, _$p) => {
|
|
171
|
-
style(_el$
|
|
212
|
+
style(_el$12, _v$, _$p);
|
|
172
213
|
});
|
|
173
|
-
return _el$
|
|
214
|
+
return _el$12;
|
|
174
215
|
}
|
|
175
216
|
}), (() => {
|
|
176
|
-
var _el$
|
|
177
|
-
var _el$
|
|
178
|
-
var _el$
|
|
179
|
-
spread(_el$
|
|
217
|
+
var _el$13 = _tmpl$4();
|
|
218
|
+
var _el$14 = _el$13.firstChild;
|
|
219
|
+
var _el$15 = _el$14.firstChild;
|
|
220
|
+
spread(_el$13, [() => {
|
|
180
221
|
return api().getPositionerProps();
|
|
181
222
|
}, { class: "xds-select__positioner" }], true);
|
|
182
223
|
ref(() => {
|
|
183
224
|
return (element) => positioner = element;
|
|
184
|
-
}, _el$
|
|
185
|
-
spread(_el$
|
|
225
|
+
}, _el$13);
|
|
226
|
+
spread(_el$14, [content, {
|
|
186
227
|
get hidden() {
|
|
187
228
|
return !present();
|
|
188
229
|
},
|
|
@@ -190,22 +231,23 @@ function Select(props) {
|
|
|
190
231
|
}], true);
|
|
191
232
|
ref(() => {
|
|
192
233
|
return (element) => surface = element;
|
|
193
|
-
}, _el$
|
|
194
|
-
spread(_el$
|
|
234
|
+
}, _el$14);
|
|
235
|
+
spread(_el$15, [() => {
|
|
195
236
|
return api().getListProps();
|
|
196
237
|
}, { class: "xds-select__list" }], true);
|
|
197
|
-
insert(_el$
|
|
238
|
+
insert(_el$15, createComponent(For, {
|
|
198
239
|
get each() {
|
|
199
240
|
return collection().items;
|
|
200
241
|
},
|
|
201
242
|
children: (option, index) => {
|
|
202
243
|
const ids = () => selectOptionIds(id, index());
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
244
|
+
const itemProps = createItemProps(() => api().getItemProps({ item: option }));
|
|
245
|
+
const textProps = createItemProps(() => api().getItemTextProps({ item: option }));
|
|
246
|
+
const selected = createMemo(() => api().getItemState({ item: option }).selected);
|
|
247
|
+
var _el$17 = _tmpl$8();
|
|
248
|
+
var _el$18 = _el$17.firstChild;
|
|
249
|
+
var _el$19 = _el$18.firstChild;
|
|
250
|
+
spread(_el$17, [itemProps, {
|
|
209
251
|
get "aria-labelledby"() {
|
|
210
252
|
return ids().label;
|
|
211
253
|
},
|
|
@@ -214,35 +256,33 @@ function Select(props) {
|
|
|
214
256
|
},
|
|
215
257
|
class: "xds-select__item"
|
|
216
258
|
}], true);
|
|
217
|
-
spread(_el$
|
|
218
|
-
return api().getItemTextProps({ item: option });
|
|
219
|
-
}, {
|
|
259
|
+
spread(_el$19, [textProps, {
|
|
220
260
|
get id() {
|
|
221
261
|
return ids().label;
|
|
222
262
|
},
|
|
223
263
|
class: "xds-select__item-label"
|
|
224
264
|
}], true);
|
|
225
|
-
insert(_el$
|
|
265
|
+
insert(_el$19, () => {
|
|
226
266
|
return option.label;
|
|
227
267
|
});
|
|
228
|
-
insert(_el$
|
|
268
|
+
insert(_el$18, createComponent(Show, {
|
|
229
269
|
get when() {
|
|
230
270
|
return option.description;
|
|
231
271
|
},
|
|
232
272
|
get children() {
|
|
233
|
-
var _el$
|
|
234
|
-
insert(_el$
|
|
273
|
+
var _el$20 = _tmpl$7();
|
|
274
|
+
insert(_el$20, () => {
|
|
235
275
|
return option.description;
|
|
236
276
|
});
|
|
237
277
|
effect(() => ids().description, (_v$) => {
|
|
238
|
-
setAttribute(_el$
|
|
278
|
+
setAttribute(_el$20, "id", _v$);
|
|
239
279
|
});
|
|
240
|
-
return _el$
|
|
280
|
+
return _el$20;
|
|
241
281
|
}
|
|
242
282
|
}), null);
|
|
243
|
-
insert(_el$
|
|
283
|
+
insert(_el$17, createComponent(Show, {
|
|
244
284
|
get when() {
|
|
245
|
-
return
|
|
285
|
+
return selected();
|
|
246
286
|
},
|
|
247
287
|
get children() {
|
|
248
288
|
return createComponent(Icon, {
|
|
@@ -251,10 +291,10 @@ function Select(props) {
|
|
|
251
291
|
});
|
|
252
292
|
}
|
|
253
293
|
}), null);
|
|
254
|
-
return _el$
|
|
294
|
+
return _el$17;
|
|
255
295
|
}
|
|
256
296
|
}));
|
|
257
|
-
return _el$
|
|
297
|
+
return _el$13;
|
|
258
298
|
})()];
|
|
259
299
|
} }), null);
|
|
260
300
|
return _el$;
|
package/dist/dom/Sidebar.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Icon } from "./Icon.js";
|
|
2
2
|
import { PlaceRow } from "./ListRow.js";
|
|
3
|
+
import { rootAttributes } from "./root.js";
|
|
3
4
|
import { TooltipBeside } from "./Tooltip.js";
|
|
4
5
|
import { withTrigger } from "./trigger.js";
|
|
5
|
-
import { className, createComponent, effect, insert, memo, readShallow, setAttribute, spread,
|
|
6
|
+
import { className, createComponent, effect, insert, memo, readShallow, setAttribute, spread, template } from "@solidjs/web";
|
|
6
7
|
import { SIDEBAR_PARTS, classes, rootPart, sidebarClass, sidebarCount, sidebarIconClass, sidebarRailButtonClass, sidebarSectionClass, sidebarTitleClass } from "@xds/core";
|
|
7
8
|
import { For, Show, createMemo, createUniqueId } from "solid-js";
|
|
8
9
|
// packages/ui-solid/src/Sidebar.tsx
|
|
@@ -30,6 +31,19 @@ function Sidebar(props) {
|
|
|
30
31
|
var _el$ = _tmpl$();
|
|
31
32
|
var _el$2 = _el$.firstChild;
|
|
32
33
|
var _el$3 = _el$2.nextSibling;
|
|
34
|
+
spread(_el$, [() => {
|
|
35
|
+
return rootAttributes(props);
|
|
36
|
+
}, {
|
|
37
|
+
get "aria-label"() {
|
|
38
|
+
return props.label;
|
|
39
|
+
},
|
|
40
|
+
get "class"() {
|
|
41
|
+
return classes(ROOT, sidebarClass(collapsed()), props.class);
|
|
42
|
+
},
|
|
43
|
+
get style() {
|
|
44
|
+
return props.style;
|
|
45
|
+
}
|
|
46
|
+
}], true);
|
|
33
47
|
insert(_el$, createComponent(Show, {
|
|
34
48
|
get when() {
|
|
35
49
|
return props.header;
|
|
@@ -193,18 +207,8 @@ function Sidebar(props) {
|
|
|
193
207
|
return _el$12;
|
|
194
208
|
})()
|
|
195
209
|
}), _el$3);
|
|
196
|
-
effect(() => {
|
|
197
|
-
|
|
198
|
-
e: props.label,
|
|
199
|
-
t: readShallow(classes(ROOT, sidebarClass(collapsed()), props.class)),
|
|
200
|
-
a: readShallow(props.style),
|
|
201
|
-
o: readShallow(SIDEBAR_PARTS.places)
|
|
202
|
-
};
|
|
203
|
-
}, ({ e, t, a, o }, _p$) => {
|
|
204
|
-
e !== _p$?.e && setAttribute(_el$, "aria-label", e);
|
|
205
|
-
className(_el$, t, _p$?.t);
|
|
206
|
-
style(_el$, a, _p$?.a);
|
|
207
|
-
className(_el$2, o, _p$?.o);
|
|
210
|
+
effect(() => readShallow(SIDEBAR_PARTS.places), (_v$, _$p) => {
|
|
211
|
+
className(_el$2, _v$, _$p);
|
|
208
212
|
});
|
|
209
213
|
return _el$;
|
|
210
214
|
}
|
package/dist/dom/Skeleton.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useDefaults } from "./Defaults.js";
|
|
2
|
-
import { layStyle } from "./root.js";
|
|
3
|
-
import {
|
|
2
|
+
import { layStyle, rootAttributes } from "./root.js";
|
|
3
|
+
import { spread, template } from "@solidjs/web";
|
|
4
4
|
import { classes, rootPart, skeletonClass, skeletonSize } from "@xds/core";
|
|
5
5
|
// packages/ui-solid/src/Skeleton.tsx
|
|
6
|
-
var _tmpl$ = /* @__PURE__ */ template(`<span
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template(`<span>`);
|
|
7
7
|
var ROOT = rootPart("Skeleton");
|
|
8
8
|
/**
|
|
9
9
|
* Holds the place of content that is loading, in the shape the content will have. It pulses,
|
|
@@ -16,19 +16,21 @@ function Skeleton(props) {
|
|
|
16
16
|
const defaults = useDefaults("Skeleton");
|
|
17
17
|
const shape = () => props.shape ?? defaults().shape;
|
|
18
18
|
var _el$ = _tmpl$();
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
spread(_el$, [() => {
|
|
20
|
+
return rootAttributes(props);
|
|
21
|
+
}, {
|
|
22
|
+
"aria-hidden": "true",
|
|
23
|
+
get "class"() {
|
|
24
|
+
return classes(ROOT, skeletonClass(shape()), props.class);
|
|
25
|
+
},
|
|
26
|
+
get style() {
|
|
27
|
+
return layStyle(skeletonSize({
|
|
23
28
|
shape: shape(),
|
|
24
29
|
width: props.width,
|
|
25
30
|
height: props.height
|
|
26
|
-
}), props.style)
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
className(_el$, e, _p$?.e);
|
|
30
|
-
style(_el$, t, _p$?.t);
|
|
31
|
-
});
|
|
31
|
+
}), props.style);
|
|
32
|
+
}
|
|
33
|
+
}], false);
|
|
32
34
|
return _el$;
|
|
33
35
|
}
|
|
34
36
|
export { Skeleton };
|
package/dist/dom/Slider.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createControllable } from "./controllable.js";
|
|
2
|
+
import { rootAttributes, withStyle } from "./root.js";
|
|
2
3
|
import { createComponent, insert, ref, spread, template } from "@solidjs/web";
|
|
3
|
-
import { classes, focusThumbOnPress, sliderArrowValue, sliderPageSize, sliderValueText } from "@xds/core";
|
|
4
|
+
import { classes, focusThumbOnPress, isControlled, sliderArrowValue, sliderPageSize, sliderValueText } from "@xds/core";
|
|
4
5
|
import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
|
|
5
6
|
import { Show, createMemo, createUniqueId } from "solid-js";
|
|
6
7
|
import * as slider from "@zag-js/slider";
|
|
@@ -12,7 +13,7 @@ var _tmpl$2 = /* @__PURE__ */ template(`<div><label></label><div><div><div></div
|
|
|
12
13
|
* go. The values snap to `step`.
|
|
13
14
|
*
|
|
14
15
|
* It is a slider named by its label with its value, minimum and maximum, and each arrow key
|
|
15
|
-
* moves it one step.
|
|
16
|
+
* moves it one step. Without `value` it keeps its own, from `defaultValue`, or `min`.
|
|
16
17
|
*/
|
|
17
18
|
function Slider(props) {
|
|
18
19
|
const id = createUniqueId();
|
|
@@ -24,11 +25,18 @@ function Slider(props) {
|
|
|
24
25
|
max: max(),
|
|
25
26
|
step: step()
|
|
26
27
|
});
|
|
28
|
+
const value = createControllable({
|
|
29
|
+
controlled: () => isControlled(props, "value"),
|
|
30
|
+
value: () => props.value ?? min(),
|
|
31
|
+
defaultValue: () => props.defaultValue ?? min(),
|
|
32
|
+
onChange: (next) => props.onChange?.(next)
|
|
33
|
+
});
|
|
27
34
|
const service = useMachine(slider.machine, () => ({
|
|
28
35
|
id,
|
|
36
|
+
ids: { root: props.id },
|
|
29
37
|
name: props.name,
|
|
30
|
-
value: [
|
|
31
|
-
onValueChange: (details) =>
|
|
38
|
+
value: [value.value()],
|
|
39
|
+
onValueChange: (details) => value.set(details.value[0] ?? min()),
|
|
32
40
|
min: min(),
|
|
33
41
|
max: max(),
|
|
34
42
|
step: step(),
|
|
@@ -38,7 +46,7 @@ function Slider(props) {
|
|
|
38
46
|
getAriaValueText: (details) => sliderValueText(details.value, props.locale)
|
|
39
47
|
}));
|
|
40
48
|
const api = createMemo(() => slider.connect(service, normalizeProps));
|
|
41
|
-
const root = withStyle(() => api().getRootProps(), () => props.style);
|
|
49
|
+
const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
|
|
42
50
|
const thumb = mergeProps$1(() => api().getThumbProps({ index: 0 }), {
|
|
43
51
|
draggable: "false",
|
|
44
52
|
onKeyDown: (event) => {
|
|
@@ -95,7 +103,7 @@ function Slider(props) {
|
|
|
95
103
|
class: "xds-slider__output"
|
|
96
104
|
}], true);
|
|
97
105
|
insert(_el$3, () => {
|
|
98
|
-
return sliderValueText(api().value[0] ??
|
|
106
|
+
return sliderValueText(api().value[0] ?? value.value(), props.locale);
|
|
99
107
|
});
|
|
100
108
|
return _el$3;
|
|
101
109
|
}
|
package/dist/dom/Spinner.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useDefaults } from "./Defaults.js";
|
|
2
|
-
import {
|
|
2
|
+
import { rootAttributes } from "./root.js";
|
|
3
|
+
import { className, effect, readShallow, spread, template } from "@solidjs/web";
|
|
3
4
|
import { classes, rootPart, spinnerClass } from "@xds/core";
|
|
4
5
|
// packages/ui-solid/src/Spinner.tsx
|
|
5
6
|
var _tmpl$ = /* @__PURE__ */ template(`<span><svg viewBox="0 0 24 24"fill=none aria-hidden=true><circle cx=12 cy=12 r=9 stroke=currentColor stroke-width=3 opacity=0.25></circle><path d="M21 12a9 9 0 0 0-9-9"stroke=currentColor stroke-width=3 stroke-linecap=round>`);
|
|
@@ -13,22 +14,27 @@ function Spinner(props) {
|
|
|
13
14
|
const defaults = useDefaults("Spinner");
|
|
14
15
|
var _el$ = _tmpl$();
|
|
15
16
|
var _el$2 = _el$.firstChild;
|
|
16
|
-
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
spread(_el$, [() => {
|
|
18
|
+
return rootAttributes(props);
|
|
19
|
+
}, {
|
|
20
|
+
get "class"() {
|
|
21
|
+
return classes(ROOT, "inline-flex shrink-0", props.class);
|
|
22
|
+
},
|
|
23
|
+
get style() {
|
|
24
|
+
return props.style;
|
|
25
|
+
},
|
|
26
|
+
get role() {
|
|
27
|
+
return props.label ? "status" : void 0;
|
|
28
|
+
},
|
|
29
|
+
get "aria-label"() {
|
|
30
|
+
return props.label || void 0;
|
|
31
|
+
},
|
|
32
|
+
get "aria-hidden"() {
|
|
33
|
+
return props.label ? void 0 : "true";
|
|
34
|
+
}
|
|
35
|
+
}], true);
|
|
36
|
+
effect(() => readShallow(spinnerClass(props.size ?? defaults().size)), (_v$, _$p) => {
|
|
37
|
+
className(_el$2, _v$, _$p);
|
|
32
38
|
});
|
|
33
39
|
return _el$;
|
|
34
40
|
}
|
package/dist/dom/Switch.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { composeRefs, createControllable, resetWithForm } from "./controllable.js";
|
|
1
2
|
import { keepChecked } from "./controlled.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
3
|
+
import { rootAttributes } from "./root.js";
|
|
4
|
+
import { className, createComponent, effect, insert, readShallow, ref, setAttribute, spread, template } from "@solidjs/web";
|
|
5
|
+
import { classes, isControlled, rootPart, switchClass, switchLabelClass, switchThumbClass, switchTrackClass } from "@xds/core";
|
|
4
6
|
import { Show } from "solid-js";
|
|
5
7
|
// packages/ui-solid/src/Switch.tsx
|
|
6
8
|
var _tmpl$ = /* @__PURE__ */ template(`<span>`);
|
|
@@ -11,17 +13,44 @@ var ROOT = rootPart("Switch");
|
|
|
11
13
|
* with a form, use a Checkbox.
|
|
12
14
|
*
|
|
13
15
|
* It is a native checkbox with the switch role, so the keyboard, forms and screen readers
|
|
14
|
-
* treat it as one. The input is hidden and the track is drawn beside it.
|
|
16
|
+
* treat it as one. The input is hidden and the track is drawn beside it. Without `checked` it
|
|
17
|
+
* keeps its own state, from `defaultChecked`.
|
|
15
18
|
*/
|
|
16
19
|
function Switch(props) {
|
|
20
|
+
const controlled = () => isControlled(props, "checked");
|
|
21
|
+
const defaultChecked = () => props.defaultChecked ?? false;
|
|
22
|
+
const checked = createControllable({
|
|
23
|
+
controlled,
|
|
24
|
+
value: () => props.checked ?? false,
|
|
25
|
+
defaultValue: defaultChecked,
|
|
26
|
+
onChange: (next) => props.onChange?.(next)
|
|
27
|
+
});
|
|
28
|
+
let input;
|
|
29
|
+
resetWithForm(() => input, controlled, checked.reset);
|
|
17
30
|
var _el$ = _tmpl$2();
|
|
18
31
|
var _el$2 = _el$.firstChild;
|
|
19
32
|
var _el$3 = _el$2.nextSibling;
|
|
20
33
|
var _el$4 = _el$3.firstChild;
|
|
34
|
+
spread(_el$, [() => {
|
|
35
|
+
return rootAttributes(props);
|
|
36
|
+
}, {
|
|
37
|
+
get "class"() {
|
|
38
|
+
return classes(ROOT, switchClass, props.class);
|
|
39
|
+
},
|
|
40
|
+
get style() {
|
|
41
|
+
return props.style;
|
|
42
|
+
}
|
|
43
|
+
}], true);
|
|
44
|
+
_el$2.addEventListener("blur", (event) => props.onBlur?.(event));
|
|
45
|
+
_el$2.addEventListener("focus", (event) => props.onFocus?.(event));
|
|
21
46
|
_el$2.addEventListener("change", (event) => {
|
|
22
|
-
|
|
23
|
-
keepChecked(event.currentTarget,
|
|
47
|
+
checked.set(event.currentTarget.checked);
|
|
48
|
+
keepChecked(event.currentTarget, checked.value);
|
|
24
49
|
});
|
|
50
|
+
var _ref$ = composeRefs((element) => input = element, () => props.ref);
|
|
51
|
+
(typeof _ref$ === "function" || Array.isArray(_ref$)) && ref(() => {
|
|
52
|
+
return _ref$;
|
|
53
|
+
}, _el$2);
|
|
25
54
|
insert(_el$, createComponent(Show, {
|
|
26
55
|
get when() {
|
|
27
56
|
return props.label;
|
|
@@ -39,26 +68,22 @@ function Switch(props) {
|
|
|
39
68
|
}), null);
|
|
40
69
|
effect(() => {
|
|
41
70
|
return {
|
|
42
|
-
e:
|
|
43
|
-
t:
|
|
44
|
-
a:
|
|
45
|
-
o:
|
|
46
|
-
i: props.
|
|
47
|
-
n:
|
|
48
|
-
s:
|
|
49
|
-
h: readShallow(switchTrackClass),
|
|
50
|
-
r: readShallow(switchThumbClass)
|
|
71
|
+
e: checked.value() ? "true" : "false",
|
|
72
|
+
t: props["aria-label"],
|
|
73
|
+
a: checked.value(),
|
|
74
|
+
o: controlled() ? checked.value() : defaultChecked(),
|
|
75
|
+
i: props.disabled,
|
|
76
|
+
n: readShallow(switchTrackClass),
|
|
77
|
+
s: readShallow(switchThumbClass)
|
|
51
78
|
};
|
|
52
|
-
}, ({ e, t, a, o, i, n, s
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
o !== _p$?.o &&
|
|
57
|
-
_el$2
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
className(_el$3, h, _p$?.h);
|
|
61
|
-
className(_el$4, r, _p$?.r);
|
|
79
|
+
}, ({ e, t, a, o, i, n, s }, _p$) => {
|
|
80
|
+
e !== _p$?.e && setAttribute(_el$2, "aria-checked", e);
|
|
81
|
+
t !== _p$?.t && setAttribute(_el$2, "aria-label", t);
|
|
82
|
+
_el$2.checked = a;
|
|
83
|
+
o !== _p$?.o && (_el$2.defaultChecked = o);
|
|
84
|
+
i !== _p$?.i && setAttribute(_el$2, "disabled", i);
|
|
85
|
+
className(_el$3, n, _p$?.n);
|
|
86
|
+
className(_el$4, s, _p$?.s);
|
|
62
87
|
});
|
|
63
88
|
return _el$;
|
|
64
89
|
}
|