@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,126 @@
|
|
|
1
|
+
import { createControllable } from "./controllable.js";
|
|
2
|
+
import { IconButton } from "./IconButton.js";
|
|
3
|
+
import { useLabels } from "./Labels.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 { TriggerContext, provideTrigger } from "./trigger.js";
|
|
8
|
+
import { className, createComponent, effect, insert, readShallow, ref, spread, template } from "@solidjs/web";
|
|
9
|
+
import { POPOVER_PARTS, classes, isControlled, leaveEscapeToFields, readCssPx } from "@xds/core";
|
|
10
|
+
import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
|
|
11
|
+
import { Show, createMemo, createUniqueId } from "solid-js";
|
|
12
|
+
import { space } from "@xds/tokens";
|
|
13
|
+
import * as popover from "@zag-js/popover";
|
|
14
|
+
// packages/ui-solid/src/Popover.tsx
|
|
15
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div>`);
|
|
16
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<div><section><div><h2>`);
|
|
17
|
+
/**
|
|
18
|
+
* A surface that opens beside the control that opens it, for details or a short task that do
|
|
19
|
+
* not need the whole screen: a press outside, Escape or its close button closes it, and the
|
|
20
|
+
* focus goes back to the trigger. It is a dialog named by its title, and not modal: the page
|
|
21
|
+
* stays as it is behind it. Without `open` it keeps its own, from `defaultOpen`.
|
|
22
|
+
*/
|
|
23
|
+
function Popover(props) {
|
|
24
|
+
const id = createUniqueId();
|
|
25
|
+
const labels = useLabels();
|
|
26
|
+
const open = createControllable({
|
|
27
|
+
controlled: () => isControlled(props, "open"),
|
|
28
|
+
value: () => props.open,
|
|
29
|
+
defaultValue: () => props.defaultOpen ?? false,
|
|
30
|
+
onChange: (next) => props.onOpenChange?.(next ?? false)
|
|
31
|
+
});
|
|
32
|
+
let content;
|
|
33
|
+
const service = useMachine(popover.machine, () => ({
|
|
34
|
+
id,
|
|
35
|
+
ids: { content: props.id },
|
|
36
|
+
open: open.value() ?? false,
|
|
37
|
+
onOpenChange: (details) => open.set(details.open),
|
|
38
|
+
positioning: {
|
|
39
|
+
placement: props.placement ?? "bottom",
|
|
40
|
+
gutter: readCssPx(null, "--xds-space-1", space[1])
|
|
41
|
+
},
|
|
42
|
+
onEscapeKeyDown: leaveEscapeToFields,
|
|
43
|
+
initialFocusEl: () => content ?? null
|
|
44
|
+
}));
|
|
45
|
+
const api = createMemo(() => popover.connect(service, normalizeProps));
|
|
46
|
+
const trigger = provideTrigger(() => mergeProps$1(api().getTriggerProps(), { class: POPOVER_PARTS.trigger }));
|
|
47
|
+
const contentProps = withStyle(() => api().getContentProps(), () => props.style, rootAttributes(props));
|
|
48
|
+
const present = createPresence(() => api().open, () => [content]);
|
|
49
|
+
return [createComponent(TriggerContext, {
|
|
50
|
+
value: trigger,
|
|
51
|
+
get children() {
|
|
52
|
+
return props.trigger;
|
|
53
|
+
}
|
|
54
|
+
}), createComponent(Show, {
|
|
55
|
+
get when() {
|
|
56
|
+
return present();
|
|
57
|
+
},
|
|
58
|
+
get children() {
|
|
59
|
+
return createComponent(Portal$1, { get children() {
|
|
60
|
+
return createComponent(TriggerContext, {
|
|
61
|
+
value: null,
|
|
62
|
+
get children() {
|
|
63
|
+
var _el$ = _tmpl$2();
|
|
64
|
+
var _el$2 = _el$.firstChild;
|
|
65
|
+
var _el$3 = _el$2.firstChild;
|
|
66
|
+
var _el$4 = _el$3.firstChild;
|
|
67
|
+
spread(_el$, [() => {
|
|
68
|
+
return api().getPositionerProps();
|
|
69
|
+
}, { get "class"() {
|
|
70
|
+
return POPOVER_PARTS.positioner;
|
|
71
|
+
} }], true);
|
|
72
|
+
spread(_el$2, [contentProps, {
|
|
73
|
+
hidden: false,
|
|
74
|
+
get "class"() {
|
|
75
|
+
return classes("xds-popover", props.class);
|
|
76
|
+
}
|
|
77
|
+
}], true);
|
|
78
|
+
ref(() => {
|
|
79
|
+
return (element) => content = element;
|
|
80
|
+
}, _el$2);
|
|
81
|
+
spread(_el$4, [() => {
|
|
82
|
+
return api().getTitleProps();
|
|
83
|
+
}, { get "class"() {
|
|
84
|
+
return POPOVER_PARTS.title;
|
|
85
|
+
} }], true);
|
|
86
|
+
insert(_el$4, () => {
|
|
87
|
+
return props.title;
|
|
88
|
+
});
|
|
89
|
+
insert(_el$3, createComponent(IconButton, {
|
|
90
|
+
icon: "x",
|
|
91
|
+
get label() {
|
|
92
|
+
return props.closeLabel ?? labels().close;
|
|
93
|
+
},
|
|
94
|
+
variant: "ghost",
|
|
95
|
+
size: "sm",
|
|
96
|
+
get "class"() {
|
|
97
|
+
return POPOVER_PARTS.close;
|
|
98
|
+
},
|
|
99
|
+
onPress: () => api().setOpen(false)
|
|
100
|
+
}), null);
|
|
101
|
+
insert(_el$2, createComponent(Show, {
|
|
102
|
+
get when() {
|
|
103
|
+
return props.children != null;
|
|
104
|
+
},
|
|
105
|
+
get children() {
|
|
106
|
+
var _el$5 = _tmpl$();
|
|
107
|
+
insert(_el$5, () => {
|
|
108
|
+
return props.children;
|
|
109
|
+
});
|
|
110
|
+
effect(() => readShallow(POPOVER_PARTS.body), (_v$, _$p) => {
|
|
111
|
+
className(_el$5, _v$, _$p);
|
|
112
|
+
});
|
|
113
|
+
return _el$5;
|
|
114
|
+
}
|
|
115
|
+
}), null);
|
|
116
|
+
effect(() => readShallow(POPOVER_PARTS.header), (_v$, _$p) => {
|
|
117
|
+
className(_el$3, _v$, _$p);
|
|
118
|
+
});
|
|
119
|
+
return _el$;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
} });
|
|
123
|
+
}
|
|
124
|
+
})];
|
|
125
|
+
}
|
|
126
|
+
export { Popover };
|
package/dist/dom/Select.js
CHANGED
|
@@ -4,20 +4,22 @@ import { modalPopover } from "./modal-popover.js";
|
|
|
4
4
|
import { Portal as Portal$1 } from "./portal.js";
|
|
5
5
|
import { createPresence } from "./presence.js";
|
|
6
6
|
import { rootAttributes, withStyle } from "./root.js";
|
|
7
|
+
import { createItemProps } from "./rows.js";
|
|
7
8
|
import { createComponent, delegateEvents, effect, insert, memo, readShallow, ref, setAttribute, spread, style, template } from "@solidjs/web";
|
|
8
|
-
import { classes, isControlled, keepListKeys, readCssPx, selectOptionIds, underlayLayerStyle } from "@xds/core";
|
|
9
|
+
import { classes, isControlled, keepListKeys, orderedValues, readCssPx, selectOptionIds, selectedLabels, underlayLayerStyle } from "@xds/core";
|
|
9
10
|
import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
|
|
10
11
|
import { For, Show, createMemo, createUniqueId } from "solid-js";
|
|
11
12
|
import { space } from "@xds/tokens";
|
|
12
13
|
import * as select from "@zag-js/select";
|
|
13
14
|
// packages/ui-solid/src/Select.tsx
|
|
14
15
|
var _tmpl$ = /* @__PURE__ */ template(`<span class=xds-select__description>`);
|
|
15
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<
|
|
16
|
-
var _tmpl$3 = /* @__PURE__ */ template(`<div
|
|
17
|
-
var _tmpl$4 = /* @__PURE__ */ template(`<div><
|
|
18
|
-
var _tmpl$5 = /* @__PURE__ */ template(`<
|
|
19
|
-
var _tmpl$6 = /* @__PURE__ */ template(`<
|
|
20
|
-
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>`);
|
|
21
23
|
/**
|
|
22
24
|
* A field for choosing one option from a list too long to show at once. Closed, it looks like a
|
|
23
25
|
* TextField; pressed, it opens the list under itself with a Menu's surface, as wide as the
|
|
@@ -30,6 +32,10 @@ var _tmpl$7 = /* @__PURE__ */ template(`<div><span class=xds-select__item-words>
|
|
|
30
32
|
*
|
|
31
33
|
* Without `value` it keeps its own choice, from `defaultValue`. Given `value`, even as
|
|
32
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.
|
|
33
39
|
*/
|
|
34
40
|
function Select(props) {
|
|
35
41
|
const id = createUniqueId();
|
|
@@ -45,6 +51,13 @@ function Select(props) {
|
|
|
45
51
|
if (next !== void 0) props.onChange?.(next);
|
|
46
52
|
}
|
|
47
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;
|
|
48
61
|
const collection = createMemo(() => select.collection({
|
|
49
62
|
items: [...props.options],
|
|
50
63
|
itemToValue: (option) => option.value,
|
|
@@ -54,11 +67,17 @@ function Select(props) {
|
|
|
54
67
|
id,
|
|
55
68
|
ids: { root: props.id },
|
|
56
69
|
collection: collection(),
|
|
57
|
-
value: value.value() === void 0 ? [] : [value.value()],
|
|
70
|
+
value: multiple() ? [...values.value()] : value.value() === void 0 ? [] : [value.value()],
|
|
58
71
|
onValueChange: (details) => {
|
|
72
|
+
if (multiple()) {
|
|
73
|
+
values.set(orderedValues(props.options, details.value));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
59
76
|
const next = details.value[0];
|
|
60
77
|
if (next !== void 0) value.set(next);
|
|
61
78
|
},
|
|
79
|
+
multiple: multiple(),
|
|
80
|
+
closeOnSelect: !multiple(),
|
|
62
81
|
disabled: props.disabled,
|
|
63
82
|
invalid: invalid(),
|
|
64
83
|
name: props.name,
|
|
@@ -97,14 +116,15 @@ function Select(props) {
|
|
|
97
116
|
keepListKeys(event, surface, ".xds-select__item:not([data-disabled])", (value) => api().setHighlightedValue(value));
|
|
98
117
|
current().getContentProps().onKeyDown?.(event);
|
|
99
118
|
} });
|
|
100
|
-
var _el$ = _tmpl$
|
|
119
|
+
var _el$ = _tmpl$5();
|
|
101
120
|
var _el$2 = _el$.firstChild;
|
|
102
121
|
var _el$3 = _el$2.nextSibling;
|
|
103
122
|
var _el$4 = _el$3.firstChild;
|
|
104
123
|
var _el$5 = _el$3.nextSibling;
|
|
105
124
|
var _el$7 = _el$5.firstChild;
|
|
106
125
|
var _el$8 = _el$5.nextSibling;
|
|
107
|
-
_el$8.firstChild;
|
|
126
|
+
var _el$10 = _el$8.firstChild;
|
|
127
|
+
var _el$11 = _el$10.nextSibling;
|
|
108
128
|
spread(_el$, [root, { get "class"() {
|
|
109
129
|
return classes("xds-select", props.class);
|
|
110
130
|
} }], true);
|
|
@@ -128,7 +148,7 @@ function Select(props) {
|
|
|
128
148
|
class: "xds-select__value"
|
|
129
149
|
}], true);
|
|
130
150
|
insert(_el$4, () => {
|
|
131
|
-
return api().valueAsString || props.placeholder;
|
|
151
|
+
return (multiple() ? selectedLabels(props.options, values.value()) : api().valueAsString) || props.placeholder;
|
|
132
152
|
});
|
|
133
153
|
insert(_el$3, createComponent(Icon, {
|
|
134
154
|
name: "chevrons-up-down",
|
|
@@ -157,45 +177,53 @@ function Select(props) {
|
|
|
157
177
|
spread(_el$8, () => {
|
|
158
178
|
return api().getHiddenSelectProps();
|
|
159
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);
|
|
160
188
|
insert(_el$8, createComponent(For, {
|
|
161
189
|
get each() {
|
|
162
190
|
return props.options;
|
|
163
191
|
},
|
|
164
192
|
children: (option) => (() => {
|
|
165
|
-
var _el$
|
|
166
|
-
insert(_el$
|
|
193
|
+
var _el$16 = _tmpl$6();
|
|
194
|
+
insert(_el$16, () => {
|
|
167
195
|
return option.label;
|
|
168
196
|
});
|
|
169
197
|
effect(() => option.value, (_v$) => {
|
|
170
|
-
_el$
|
|
198
|
+
_el$16.value = _v$;
|
|
171
199
|
});
|
|
172
|
-
return _el$
|
|
200
|
+
return _el$16;
|
|
173
201
|
})()
|
|
174
|
-
}),
|
|
202
|
+
}), _el$11);
|
|
175
203
|
insert(_el$, createComponent(Portal$1, { get children() {
|
|
176
204
|
return [createComponent(Show, {
|
|
177
205
|
get when() {
|
|
178
206
|
return api().open;
|
|
179
207
|
},
|
|
180
208
|
get children() {
|
|
181
|
-
var _el$
|
|
182
|
-
_el$
|
|
209
|
+
var _el$12 = _tmpl$3();
|
|
210
|
+
_el$12._$$mousedown = (event) => event.preventDefault();
|
|
183
211
|
effect(() => readShallow(underlayLayerStyle(api().getPositionerProps().style)), (_v$, _$p) => {
|
|
184
|
-
style(_el$
|
|
212
|
+
style(_el$12, _v$, _$p);
|
|
185
213
|
});
|
|
186
|
-
return _el$
|
|
214
|
+
return _el$12;
|
|
187
215
|
}
|
|
188
216
|
}), (() => {
|
|
189
|
-
var _el$
|
|
190
|
-
var _el$
|
|
191
|
-
var _el$
|
|
192
|
-
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, [() => {
|
|
193
221
|
return api().getPositionerProps();
|
|
194
222
|
}, { class: "xds-select__positioner" }], true);
|
|
195
223
|
ref(() => {
|
|
196
224
|
return (element) => positioner = element;
|
|
197
|
-
}, _el$
|
|
198
|
-
spread(_el$
|
|
225
|
+
}, _el$13);
|
|
226
|
+
spread(_el$14, [content, {
|
|
199
227
|
get hidden() {
|
|
200
228
|
return !present();
|
|
201
229
|
},
|
|
@@ -203,22 +231,23 @@ function Select(props) {
|
|
|
203
231
|
}], true);
|
|
204
232
|
ref(() => {
|
|
205
233
|
return (element) => surface = element;
|
|
206
|
-
}, _el$
|
|
207
|
-
spread(_el$
|
|
234
|
+
}, _el$14);
|
|
235
|
+
spread(_el$15, [() => {
|
|
208
236
|
return api().getListProps();
|
|
209
237
|
}, { class: "xds-select__list" }], true);
|
|
210
|
-
insert(_el$
|
|
238
|
+
insert(_el$15, createComponent(For, {
|
|
211
239
|
get each() {
|
|
212
240
|
return collection().items;
|
|
213
241
|
},
|
|
214
242
|
children: (option, index) => {
|
|
215
243
|
const ids = () => selectOptionIds(id, index());
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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, {
|
|
222
251
|
get "aria-labelledby"() {
|
|
223
252
|
return ids().label;
|
|
224
253
|
},
|
|
@@ -227,35 +256,33 @@ function Select(props) {
|
|
|
227
256
|
},
|
|
228
257
|
class: "xds-select__item"
|
|
229
258
|
}], true);
|
|
230
|
-
spread(_el$
|
|
231
|
-
return api().getItemTextProps({ item: option });
|
|
232
|
-
}, {
|
|
259
|
+
spread(_el$19, [textProps, {
|
|
233
260
|
get id() {
|
|
234
261
|
return ids().label;
|
|
235
262
|
},
|
|
236
263
|
class: "xds-select__item-label"
|
|
237
264
|
}], true);
|
|
238
|
-
insert(_el$
|
|
265
|
+
insert(_el$19, () => {
|
|
239
266
|
return option.label;
|
|
240
267
|
});
|
|
241
|
-
insert(_el$
|
|
268
|
+
insert(_el$18, createComponent(Show, {
|
|
242
269
|
get when() {
|
|
243
270
|
return option.description;
|
|
244
271
|
},
|
|
245
272
|
get children() {
|
|
246
|
-
var _el$
|
|
247
|
-
insert(_el$
|
|
273
|
+
var _el$20 = _tmpl$7();
|
|
274
|
+
insert(_el$20, () => {
|
|
248
275
|
return option.description;
|
|
249
276
|
});
|
|
250
277
|
effect(() => ids().description, (_v$) => {
|
|
251
|
-
setAttribute(_el$
|
|
278
|
+
setAttribute(_el$20, "id", _v$);
|
|
252
279
|
});
|
|
253
|
-
return _el$
|
|
280
|
+
return _el$20;
|
|
254
281
|
}
|
|
255
282
|
}), null);
|
|
256
|
-
insert(_el$
|
|
283
|
+
insert(_el$17, createComponent(Show, {
|
|
257
284
|
get when() {
|
|
258
|
-
return
|
|
285
|
+
return selected();
|
|
259
286
|
},
|
|
260
287
|
get children() {
|
|
261
288
|
return createComponent(Icon, {
|
|
@@ -264,10 +291,10 @@ function Select(props) {
|
|
|
264
291
|
});
|
|
265
292
|
}
|
|
266
293
|
}), null);
|
|
267
|
-
return _el$
|
|
294
|
+
return _el$17;
|
|
268
295
|
}
|
|
269
296
|
}));
|
|
270
|
-
return _el$
|
|
297
|
+
return _el$13;
|
|
271
298
|
})()];
|
|
272
299
|
} }), null);
|
|
273
300
|
return _el$;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Icon } from "./Icon.js";
|
|
2
|
+
import { rootAttributes } from "./root.js";
|
|
3
|
+
import { className, createComponent, delegateEvents, effect, insert, readShallow, setAttribute, spread, template } from "@solidjs/web";
|
|
4
|
+
import { TABLE_PARTS, classes, columnSort, nextSort, rootPart, sortIcon } from "@xds/core";
|
|
5
|
+
import { For, Show } from "solid-js";
|
|
6
|
+
// packages/ui-solid/src/Table.tsx
|
|
7
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div><table><thead><tr></tr></thead><tbody>`);
|
|
8
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<button type=button><!><!>`);
|
|
9
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<th scope=col>`);
|
|
10
|
+
var _tmpl$4 = /* @__PURE__ */ template(`<tr><td>`);
|
|
11
|
+
var _tmpl$5 = /* @__PURE__ */ template(`<tr>`);
|
|
12
|
+
var _tmpl$6 = /* @__PURE__ */ template(`<td>`);
|
|
13
|
+
var ROOT = rootPart("Table");
|
|
14
|
+
/**
|
|
15
|
+
* Rows of data under a row of column headers, to read and compare across. The header of a
|
|
16
|
+
* sortable column is a button that asks for the rows sorted by it, ascending first and then the
|
|
17
|
+
* other way, and the header they are sorted by says so with `aria-sort` and an arrow. The rows
|
|
18
|
+
* are shown in the order given. Where the columns do not fit, the table scrolls sideways.
|
|
19
|
+
*/
|
|
20
|
+
function Table(props) {
|
|
21
|
+
const end = (align) => align === "end" && TABLE_PARTS.end;
|
|
22
|
+
var _el$ = _tmpl$();
|
|
23
|
+
var _el$2 = _el$.firstChild;
|
|
24
|
+
var _el$3 = _el$2.firstChild;
|
|
25
|
+
var _el$4 = _el$3.firstChild;
|
|
26
|
+
var _el$5 = _el$3.nextSibling;
|
|
27
|
+
spread(_el$, [() => {
|
|
28
|
+
return rootAttributes(props);
|
|
29
|
+
}, {
|
|
30
|
+
get "class"() {
|
|
31
|
+
return classes(ROOT, props.class);
|
|
32
|
+
},
|
|
33
|
+
get style() {
|
|
34
|
+
return props.style;
|
|
35
|
+
}
|
|
36
|
+
}], true);
|
|
37
|
+
insert(_el$4, createComponent(For, {
|
|
38
|
+
get each() {
|
|
39
|
+
return props.columns;
|
|
40
|
+
},
|
|
41
|
+
children: (column) => {
|
|
42
|
+
const direction = () => columnSort(props.sort, column.key);
|
|
43
|
+
var _el$6 = _tmpl$3();
|
|
44
|
+
insert(_el$6, createComponent(Show, {
|
|
45
|
+
get when() {
|
|
46
|
+
return column.sortable;
|
|
47
|
+
},
|
|
48
|
+
get fallback() {
|
|
49
|
+
return column.label;
|
|
50
|
+
},
|
|
51
|
+
get children() {
|
|
52
|
+
var _el$7 = _tmpl$2();
|
|
53
|
+
var _el$8 = _el$7.firstChild;
|
|
54
|
+
var _el$9 = _el$8.nextSibling;
|
|
55
|
+
_el$7._$$click = () => props.onSortChange?.(nextSort(props.sort, column.key));
|
|
56
|
+
insert(_el$7, () => {
|
|
57
|
+
return column.label;
|
|
58
|
+
}, _el$8);
|
|
59
|
+
insert(_el$7, createComponent(Icon, {
|
|
60
|
+
get name() {
|
|
61
|
+
return sortIcon(direction());
|
|
62
|
+
},
|
|
63
|
+
size: "xs"
|
|
64
|
+
}), _el$9);
|
|
65
|
+
effect(() => readShallow(TABLE_PARTS.sort), (_v$, _$p) => {
|
|
66
|
+
className(_el$7, _v$, _$p);
|
|
67
|
+
});
|
|
68
|
+
return _el$7;
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
effect(() => {
|
|
72
|
+
return {
|
|
73
|
+
e: direction(),
|
|
74
|
+
t: readShallow(classes(TABLE_PARTS.header, end(column.align)))
|
|
75
|
+
};
|
|
76
|
+
}, ({ e, t }, _p$) => {
|
|
77
|
+
e !== _p$?.e && setAttribute(_el$6, "aria-sort", e);
|
|
78
|
+
className(_el$6, t, _p$?.t);
|
|
79
|
+
});
|
|
80
|
+
return _el$6;
|
|
81
|
+
}
|
|
82
|
+
}));
|
|
83
|
+
insert(_el$5, createComponent(Show, {
|
|
84
|
+
get when() {
|
|
85
|
+
return props.rows.length > 0 || props.empty === void 0;
|
|
86
|
+
},
|
|
87
|
+
get fallback() {
|
|
88
|
+
var _el$10 = _tmpl$4();
|
|
89
|
+
var _el$11 = _el$10.firstChild;
|
|
90
|
+
insert(_el$11, () => {
|
|
91
|
+
return props.empty;
|
|
92
|
+
});
|
|
93
|
+
effect(() => {
|
|
94
|
+
return {
|
|
95
|
+
e: readShallow(TABLE_PARTS.row),
|
|
96
|
+
t: readShallow(TABLE_PARTS.empty),
|
|
97
|
+
a: props.columns.length
|
|
98
|
+
};
|
|
99
|
+
}, ({ e, t, a }, _p$) => {
|
|
100
|
+
className(_el$10, e, _p$?.e);
|
|
101
|
+
className(_el$11, t, _p$?.t);
|
|
102
|
+
a !== _p$?.a && setAttribute(_el$11, "colspan", a);
|
|
103
|
+
});
|
|
104
|
+
return _el$10;
|
|
105
|
+
},
|
|
106
|
+
get children() {
|
|
107
|
+
return createComponent(For, {
|
|
108
|
+
get each() {
|
|
109
|
+
return props.rows;
|
|
110
|
+
},
|
|
111
|
+
children: (row) => (() => {
|
|
112
|
+
var _el$12 = _tmpl$5();
|
|
113
|
+
insert(_el$12, createComponent(For, {
|
|
114
|
+
get each() {
|
|
115
|
+
return props.columns;
|
|
116
|
+
},
|
|
117
|
+
children: (column, index) => (() => {
|
|
118
|
+
var _el$13 = _tmpl$6();
|
|
119
|
+
insert(_el$13, () => {
|
|
120
|
+
return row.cells[index()];
|
|
121
|
+
});
|
|
122
|
+
effect(() => readShallow(classes(TABLE_PARTS.cell, end(column.align))), (_v$, _$p) => {
|
|
123
|
+
className(_el$13, _v$, _$p);
|
|
124
|
+
});
|
|
125
|
+
return _el$13;
|
|
126
|
+
})()
|
|
127
|
+
}));
|
|
128
|
+
effect(() => readShallow(TABLE_PARTS.row), (_v$, _$p) => {
|
|
129
|
+
className(_el$12, _v$, _$p);
|
|
130
|
+
});
|
|
131
|
+
return _el$12;
|
|
132
|
+
})()
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}));
|
|
136
|
+
effect(() => {
|
|
137
|
+
return {
|
|
138
|
+
e: readShallow(TABLE_PARTS.table),
|
|
139
|
+
t: props.label,
|
|
140
|
+
a: readShallow(TABLE_PARTS.row)
|
|
141
|
+
};
|
|
142
|
+
}, ({ e, t, a }, _p$) => {
|
|
143
|
+
className(_el$2, e, _p$?.e);
|
|
144
|
+
t !== _p$?.t && setAttribute(_el$2, "aria-label", t);
|
|
145
|
+
className(_el$4, a, _p$?.a);
|
|
146
|
+
});
|
|
147
|
+
return _el$;
|
|
148
|
+
}
|
|
149
|
+
delegateEvents(["click"]);
|
|
150
|
+
export { Table };
|