@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,87 @@
|
|
|
1
|
+
import { Icon } from "./Icon.js";
|
|
2
|
+
import { useLabels } from "./Labels.js";
|
|
3
|
+
import { Link } from "./Link.js";
|
|
4
|
+
import { rootAttributes } from "./root.js";
|
|
5
|
+
import { className, createComponent, effect, insert, readShallow, spread, template } from "@solidjs/web";
|
|
6
|
+
import { BREADCRUMB_PARTS, BREADCRUMB_SEPARATOR, classes, rootPart } from "@xds/core";
|
|
7
|
+
import { For, Show } from "solid-js";
|
|
8
|
+
// packages/ui-solid/src/Breadcrumb.tsx
|
|
9
|
+
var _tmpl$ = /* @__PURE__ */ template(`<nav><ol>`);
|
|
10
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<li>`);
|
|
11
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<span aria-current=page>`);
|
|
12
|
+
var ROOT = rootPart("Breadcrumb");
|
|
13
|
+
/**
|
|
14
|
+
* Where the current view sits in the app: the places above it, each a link, then the view
|
|
15
|
+
* itself. A navigation landmark; the current place is marked as the page.
|
|
16
|
+
*/
|
|
17
|
+
function Breadcrumb(props) {
|
|
18
|
+
const labels = useLabels();
|
|
19
|
+
var _el$ = _tmpl$();
|
|
20
|
+
var _el$2 = _el$.firstChild;
|
|
21
|
+
spread(_el$, [() => {
|
|
22
|
+
return rootAttributes(props);
|
|
23
|
+
}, {
|
|
24
|
+
get "aria-label"() {
|
|
25
|
+
return props.label ?? labels().breadcrumb;
|
|
26
|
+
},
|
|
27
|
+
get "class"() {
|
|
28
|
+
return classes(ROOT, props.class);
|
|
29
|
+
},
|
|
30
|
+
get style() {
|
|
31
|
+
return props.style;
|
|
32
|
+
}
|
|
33
|
+
}], true);
|
|
34
|
+
insert(_el$2, createComponent(For, {
|
|
35
|
+
get each() {
|
|
36
|
+
return props.items;
|
|
37
|
+
},
|
|
38
|
+
children: (item, index) => (() => {
|
|
39
|
+
var _el$3 = _tmpl$2();
|
|
40
|
+
insert(_el$3, createComponent(Show, {
|
|
41
|
+
get when() {
|
|
42
|
+
return index() < props.items.length - 1;
|
|
43
|
+
},
|
|
44
|
+
get fallback() {
|
|
45
|
+
var _el$4 = _tmpl$3();
|
|
46
|
+
insert(_el$4, () => {
|
|
47
|
+
return item.label;
|
|
48
|
+
});
|
|
49
|
+
effect(() => readShallow(BREADCRUMB_PARTS.current), (_v$, _$p) => {
|
|
50
|
+
className(_el$4, _v$, _$p);
|
|
51
|
+
});
|
|
52
|
+
return _el$4;
|
|
53
|
+
},
|
|
54
|
+
get children() {
|
|
55
|
+
return [createComponent(Link, {
|
|
56
|
+
get href() {
|
|
57
|
+
return item.href;
|
|
58
|
+
},
|
|
59
|
+
onPress: () => item.onPress?.(),
|
|
60
|
+
get children() {
|
|
61
|
+
return item.label;
|
|
62
|
+
}
|
|
63
|
+
}), createComponent(Icon, {
|
|
64
|
+
get name() {
|
|
65
|
+
return BREADCRUMB_SEPARATOR.name;
|
|
66
|
+
},
|
|
67
|
+
get size() {
|
|
68
|
+
return BREADCRUMB_SEPARATOR.size;
|
|
69
|
+
},
|
|
70
|
+
get "class"() {
|
|
71
|
+
return BREADCRUMB_PARTS.separator;
|
|
72
|
+
}
|
|
73
|
+
})];
|
|
74
|
+
}
|
|
75
|
+
}));
|
|
76
|
+
effect(() => readShallow(BREADCRUMB_PARTS.item), (_v$, _$p) => {
|
|
77
|
+
className(_el$3, _v$, _$p);
|
|
78
|
+
});
|
|
79
|
+
return _el$3;
|
|
80
|
+
})()
|
|
81
|
+
}));
|
|
82
|
+
effect(() => readShallow(BREADCRUMB_PARTS.list), (_v$, _$p) => {
|
|
83
|
+
className(_el$2, _v$, _$p);
|
|
84
|
+
});
|
|
85
|
+
return _el$;
|
|
86
|
+
}
|
|
87
|
+
export { Breadcrumb };
|
package/dist/dom/Checkbox.js
CHANGED
|
@@ -2,8 +2,8 @@ import { composeRefs, createControllable, resetWithForm } from "./controllable.j
|
|
|
2
2
|
import { keepChecked } from "./controlled.js";
|
|
3
3
|
import { rootAttributes } from "./root.js";
|
|
4
4
|
import { className, createComponent, effect, insert, readShallow, ref, setAttribute, spread, template } from "@solidjs/web";
|
|
5
|
-
import {
|
|
6
|
-
import { Show } from "solid-js";
|
|
5
|
+
import { checkboxBoxClass, checkboxClass, checkboxLabelClass, checkboxMark, checkboxMarkClass, classes, isControlled, rootPart } from "@xds/core";
|
|
6
|
+
import { Show, createEffect } from "solid-js";
|
|
7
7
|
// packages/ui-solid/src/Checkbox.tsx
|
|
8
8
|
var _tmpl$ = /* @__PURE__ */ template(`<span>`);
|
|
9
9
|
var _tmpl$2 = /* @__PURE__ */ template(`<label><input type=checkbox class="peer sr-only"><span><svg viewBox="0 0 16 16"fill=none aria-hidden=true><path stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>`);
|
|
@@ -11,7 +11,7 @@ var ROOT = rootPart("Checkbox");
|
|
|
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
|
function Checkbox(props) {
|
|
17
17
|
const controlled = () => isControlled(props, "checked");
|
|
@@ -24,6 +24,10 @@ function Checkbox(props) {
|
|
|
24
24
|
});
|
|
25
25
|
let input;
|
|
26
26
|
resetWithForm(() => input, controlled, checked.reset);
|
|
27
|
+
const indeterminate = () => props.indeterminate ?? false;
|
|
28
|
+
createEffect(indeterminate, (value) => {
|
|
29
|
+
if (input) input.indeterminate = value;
|
|
30
|
+
});
|
|
27
31
|
var _el$ = _tmpl$2();
|
|
28
32
|
var _el$2 = _el$.firstChild;
|
|
29
33
|
var _el$3 = _el$2.nextSibling;
|
|
@@ -42,6 +46,7 @@ function Checkbox(props) {
|
|
|
42
46
|
_el$2.addEventListener("blur", (event) => props.onBlur?.(event));
|
|
43
47
|
_el$2.addEventListener("focus", (event) => props.onFocus?.(event));
|
|
44
48
|
_el$2.addEventListener("change", (event) => {
|
|
49
|
+
event.currentTarget.indeterminate = indeterminate();
|
|
45
50
|
checked.set(event.currentTarget.checked);
|
|
46
51
|
keepChecked(event.currentTarget, checked.value);
|
|
47
52
|
});
|
|
@@ -49,7 +54,6 @@ function Checkbox(props) {
|
|
|
49
54
|
(typeof _ref$ === "function" || Array.isArray(_ref$)) && ref(() => {
|
|
50
55
|
return _ref$;
|
|
51
56
|
}, _el$2);
|
|
52
|
-
setAttribute(_el$5, "d", CHECKBOX_MARK);
|
|
53
57
|
insert(_el$, createComponent(Show, {
|
|
54
58
|
get when() {
|
|
55
59
|
return props.label;
|
|
@@ -73,9 +77,10 @@ function Checkbox(props) {
|
|
|
73
77
|
o: props.disabled,
|
|
74
78
|
i: props.name || void 0,
|
|
75
79
|
n: readShallow(checkboxBoxClass),
|
|
76
|
-
s: readShallow(checkboxMarkClass)
|
|
80
|
+
s: readShallow(checkboxMarkClass),
|
|
81
|
+
h: checkboxMark(indeterminate())
|
|
77
82
|
};
|
|
78
|
-
}, ({ e, t, a, o, i, n, s }, _p$) => {
|
|
83
|
+
}, ({ e, t, a, o, i, n, s, h }, _p$) => {
|
|
79
84
|
e !== _p$?.e && setAttribute(_el$2, "aria-label", e);
|
|
80
85
|
_el$2.checked = t;
|
|
81
86
|
a !== _p$?.a && (_el$2.defaultChecked = a);
|
|
@@ -83,6 +88,7 @@ function Checkbox(props) {
|
|
|
83
88
|
i !== _p$?.i && setAttribute(_el$2, "name", i);
|
|
84
89
|
className(_el$3, n, _p$?.n);
|
|
85
90
|
className(_el$4, s, _p$?.s);
|
|
91
|
+
h !== _p$?.h && setAttribute(_el$5, "d", h);
|
|
86
92
|
});
|
|
87
93
|
return _el$;
|
|
88
94
|
}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { createControllable, resetWithForm } from "./controllable.js";
|
|
2
|
+
import { Icon } from "./Icon.js";
|
|
3
|
+
import { useLabels } from "./Labels.js";
|
|
4
|
+
import { Portal as Portal$1 } from "./portal.js";
|
|
5
|
+
import { rootAttributes, withStyle } from "./root.js";
|
|
6
|
+
import { createItemProps } from "./rows.js";
|
|
7
|
+
import { className, createComponent, effect, insert, memo, readShallow, ref, setAttribute, spread, template } from "@solidjs/web";
|
|
8
|
+
import { COMBOBOX_PARTS, classes, isControlled, matchOptions, readCssPx, selectOptionIds } from "@xds/core";
|
|
9
|
+
import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
|
|
10
|
+
import { For, Show, createMemo, createSignal, createUniqueId } from "solid-js";
|
|
11
|
+
import { space } from "@xds/tokens";
|
|
12
|
+
import * as combobox from "@zag-js/combobox";
|
|
13
|
+
// packages/ui-solid/src/Combobox.tsx
|
|
14
|
+
var _tmpl$ = /* @__PURE__ */ template(`<span>`);
|
|
15
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<input type=hidden>`);
|
|
16
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
|
|
17
|
+
var _tmpl$4 = /* @__PURE__ */ template(`<div><div>`);
|
|
18
|
+
var _tmpl$5 = /* @__PURE__ */ template(`<div><label></label><div><input></div><div><span aria-live=polite></span></div><!><!>`);
|
|
19
|
+
var _tmpl$6 = /* @__PURE__ */ template(`<div><span><span>`);
|
|
20
|
+
/**
|
|
21
|
+
* A field for choosing one option from a list by typing part of its name. As the person types,
|
|
22
|
+
* the options whose label holds what was typed open under it, those that start with it first,
|
|
23
|
+
* and the first is highlighted, so Enter chooses it. Choosing an option calls `onChange`, puts
|
|
24
|
+
* its label in the field and closes the list. Text that names no option goes back to the chosen
|
|
25
|
+
* option's label when the field is left. When nothing matches, the list says so.
|
|
26
|
+
*
|
|
27
|
+
* Without `value` it keeps its own choice, from `defaultValue`. Given `value`, even as
|
|
28
|
+
* `undefined`, it shows that.
|
|
29
|
+
*/
|
|
30
|
+
function Combobox(props) {
|
|
31
|
+
const id = createUniqueId();
|
|
32
|
+
const descriptionId = `${id}-description`;
|
|
33
|
+
const errorId = `${id}-error`;
|
|
34
|
+
const labels = useLabels();
|
|
35
|
+
const invalid = () => props.error !== void 0;
|
|
36
|
+
const controlled = () => isControlled(props, "value");
|
|
37
|
+
const value = createControllable({
|
|
38
|
+
controlled,
|
|
39
|
+
value: () => props.value,
|
|
40
|
+
defaultValue: () => props.defaultValue,
|
|
41
|
+
onChange: (next) => {
|
|
42
|
+
if (next !== void 0) props.onChange?.(next);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
let element;
|
|
46
|
+
resetWithForm(() => element, controlled, value.reset);
|
|
47
|
+
const [query, setQuery] = createSignal("");
|
|
48
|
+
const shown = createMemo(() => matchOptions(props.options, query()));
|
|
49
|
+
const collection = createMemo(() => combobox.collection({
|
|
50
|
+
items: shown(),
|
|
51
|
+
itemToValue: (option) => option.value,
|
|
52
|
+
itemToString: (option) => option.label
|
|
53
|
+
}));
|
|
54
|
+
const service = useMachine(combobox.machine, () => ({
|
|
55
|
+
id,
|
|
56
|
+
ids: { root: props.id },
|
|
57
|
+
collection: collection(),
|
|
58
|
+
value: value.value() === void 0 ? [] : [value.value()],
|
|
59
|
+
onValueChange: (details) => {
|
|
60
|
+
const next = details.value[0];
|
|
61
|
+
if (next !== void 0) value.set(next);
|
|
62
|
+
},
|
|
63
|
+
onInputValueChange: (details) => {
|
|
64
|
+
if (details.reason === "input-change") setQuery(details.inputValue);
|
|
65
|
+
},
|
|
66
|
+
onOpenChange: (details) => {
|
|
67
|
+
if (!details.open) setQuery("");
|
|
68
|
+
},
|
|
69
|
+
inputBehavior: "autohighlight",
|
|
70
|
+
selectionBehavior: "replace",
|
|
71
|
+
openOnClick: true,
|
|
72
|
+
disabled: props.disabled,
|
|
73
|
+
invalid: invalid(),
|
|
74
|
+
placeholder: props.placeholder,
|
|
75
|
+
positioning: {
|
|
76
|
+
placement: "bottom-start",
|
|
77
|
+
gutter: readCssPx(null, "--xds-space-1", space[1]),
|
|
78
|
+
sameWidth: true,
|
|
79
|
+
overflowPadding: readCssPx(null, "--xds-space-3", space[3])
|
|
80
|
+
}
|
|
81
|
+
}));
|
|
82
|
+
const api = createMemo(() => combobox.connect(service, normalizeProps));
|
|
83
|
+
const input = mergeProps$1(() => api().getInputProps(), { onBlur: () => {
|
|
84
|
+
const chosen = props.options.find((option) => option.value === value.value())?.label ?? "";
|
|
85
|
+
const now = combobox.connect(service, normalizeProps);
|
|
86
|
+
if (now.inputValue !== chosen) now.setInputValue(chosen, "script");
|
|
87
|
+
} });
|
|
88
|
+
const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
|
|
89
|
+
var _el$ = _tmpl$5();
|
|
90
|
+
var _el$2 = _el$.firstChild;
|
|
91
|
+
var _el$3 = _el$2.nextSibling;
|
|
92
|
+
var _el$4 = _el$3.firstChild;
|
|
93
|
+
var _el$5 = _el$3.nextSibling;
|
|
94
|
+
var _el$7 = _el$5.firstChild;
|
|
95
|
+
var _el$9 = _el$5.nextSibling;
|
|
96
|
+
var _el$13 = _el$9.nextSibling;
|
|
97
|
+
spread(_el$, [root, { get "class"() {
|
|
98
|
+
return classes("xds-combobox", props.class);
|
|
99
|
+
} }], true);
|
|
100
|
+
ref(() => {
|
|
101
|
+
return (node) => element = node;
|
|
102
|
+
}, _el$);
|
|
103
|
+
spread(_el$2, [() => {
|
|
104
|
+
return api().getLabelProps();
|
|
105
|
+
}, { get "class"() {
|
|
106
|
+
return COMBOBOX_PARTS.label;
|
|
107
|
+
} }], true);
|
|
108
|
+
insert(_el$2, () => {
|
|
109
|
+
return props.label;
|
|
110
|
+
});
|
|
111
|
+
spread(_el$3, [() => {
|
|
112
|
+
return api().getControlProps();
|
|
113
|
+
}, { get "class"() {
|
|
114
|
+
return COMBOBOX_PARTS.control;
|
|
115
|
+
} }], true);
|
|
116
|
+
spread(_el$4, [input, {
|
|
117
|
+
get "aria-describedby"() {
|
|
118
|
+
return invalid() ? errorId : props.description ? descriptionId : void 0;
|
|
119
|
+
},
|
|
120
|
+
get "class"() {
|
|
121
|
+
return COMBOBOX_PARTS.input;
|
|
122
|
+
}
|
|
123
|
+
}], false);
|
|
124
|
+
insert(_el$3, createComponent(Icon, {
|
|
125
|
+
name: "chevrons-up-down",
|
|
126
|
+
size: "sm",
|
|
127
|
+
get "class"() {
|
|
128
|
+
return COMBOBOX_PARTS.icon;
|
|
129
|
+
}
|
|
130
|
+
}), null);
|
|
131
|
+
insert(_el$5, createComponent(Show, {
|
|
132
|
+
get when() {
|
|
133
|
+
return memo(() => {
|
|
134
|
+
return !invalid();
|
|
135
|
+
})() && props.description;
|
|
136
|
+
},
|
|
137
|
+
get children() {
|
|
138
|
+
var _el$6 = _tmpl$();
|
|
139
|
+
setAttribute(_el$6, "id", descriptionId);
|
|
140
|
+
insert(_el$6, () => {
|
|
141
|
+
return props.description;
|
|
142
|
+
});
|
|
143
|
+
effect(() => readShallow(COMBOBOX_PARTS.description), (_v$, _$p) => {
|
|
144
|
+
className(_el$6, _v$, _$p);
|
|
145
|
+
});
|
|
146
|
+
return _el$6;
|
|
147
|
+
}
|
|
148
|
+
}), _el$7);
|
|
149
|
+
setAttribute(_el$7, "id", errorId);
|
|
150
|
+
insert(_el$7, () => {
|
|
151
|
+
return props.error;
|
|
152
|
+
});
|
|
153
|
+
insert(_el$, createComponent(Show, {
|
|
154
|
+
get when() {
|
|
155
|
+
return props.name !== void 0;
|
|
156
|
+
},
|
|
157
|
+
get children() {
|
|
158
|
+
var _el$8 = _tmpl$2();
|
|
159
|
+
effect(() => {
|
|
160
|
+
return {
|
|
161
|
+
e: props.name,
|
|
162
|
+
t: value.value() ?? ""
|
|
163
|
+
};
|
|
164
|
+
}, ({ e, t }, _p$) => {
|
|
165
|
+
e !== _p$?.e && setAttribute(_el$8, "name", e);
|
|
166
|
+
_el$8.value = t ?? "";
|
|
167
|
+
});
|
|
168
|
+
return _el$8;
|
|
169
|
+
}
|
|
170
|
+
}), _el$9);
|
|
171
|
+
insert(_el$, createComponent(Portal$1, { get children() {
|
|
172
|
+
var _el$10 = _tmpl$4();
|
|
173
|
+
var _el$11 = _el$10.firstChild;
|
|
174
|
+
spread(_el$10, [() => {
|
|
175
|
+
return api().getPositionerProps();
|
|
176
|
+
}, { get "class"() {
|
|
177
|
+
return COMBOBOX_PARTS.positioner;
|
|
178
|
+
} }], true);
|
|
179
|
+
spread(_el$11, [() => {
|
|
180
|
+
return api().getContentProps();
|
|
181
|
+
}, { get "class"() {
|
|
182
|
+
return COMBOBOX_PARTS.content;
|
|
183
|
+
} }], true);
|
|
184
|
+
insert(_el$11, createComponent(Show, {
|
|
185
|
+
get when() {
|
|
186
|
+
return shown().length > 0;
|
|
187
|
+
},
|
|
188
|
+
get fallback() {
|
|
189
|
+
var _el$14 = _tmpl$3();
|
|
190
|
+
spread(_el$14, [() => {
|
|
191
|
+
return api().getEmptyProps();
|
|
192
|
+
}, { get "class"() {
|
|
193
|
+
return COMBOBOX_PARTS.empty;
|
|
194
|
+
} }], true);
|
|
195
|
+
insert(_el$14, () => {
|
|
196
|
+
return props.emptyLabel ?? labels().noMatches;
|
|
197
|
+
});
|
|
198
|
+
return _el$14;
|
|
199
|
+
},
|
|
200
|
+
get children() {
|
|
201
|
+
var _el$12 = _tmpl$3();
|
|
202
|
+
spread(_el$12, [() => {
|
|
203
|
+
return api().getListProps();
|
|
204
|
+
}, { get "class"() {
|
|
205
|
+
return COMBOBOX_PARTS.list;
|
|
206
|
+
} }], true);
|
|
207
|
+
insert(_el$12, createComponent(For, {
|
|
208
|
+
get each() {
|
|
209
|
+
return shown();
|
|
210
|
+
},
|
|
211
|
+
children: (option, index) => {
|
|
212
|
+
const ids = () => selectOptionIds(id, index());
|
|
213
|
+
const itemProps = createItemProps(() => api().getItemProps({ item: option }));
|
|
214
|
+
const textProps = createItemProps(() => api().getItemTextProps({ item: option }));
|
|
215
|
+
const selected = createMemo(() => api().getItemState({ item: option }).selected);
|
|
216
|
+
var _el$15 = _tmpl$6();
|
|
217
|
+
var _el$16 = _el$15.firstChild;
|
|
218
|
+
var _el$17 = _el$16.firstChild;
|
|
219
|
+
spread(_el$15, [itemProps, {
|
|
220
|
+
get "aria-labelledby"() {
|
|
221
|
+
return ids().label;
|
|
222
|
+
},
|
|
223
|
+
get "aria-describedby"() {
|
|
224
|
+
return option.description ? ids().description : void 0;
|
|
225
|
+
},
|
|
226
|
+
get "class"() {
|
|
227
|
+
return COMBOBOX_PARTS.item;
|
|
228
|
+
}
|
|
229
|
+
}], true);
|
|
230
|
+
spread(_el$17, [textProps, {
|
|
231
|
+
get id() {
|
|
232
|
+
return ids().label;
|
|
233
|
+
},
|
|
234
|
+
get "class"() {
|
|
235
|
+
return COMBOBOX_PARTS.itemLabel;
|
|
236
|
+
}
|
|
237
|
+
}], true);
|
|
238
|
+
insert(_el$17, () => {
|
|
239
|
+
return option.label;
|
|
240
|
+
});
|
|
241
|
+
insert(_el$16, createComponent(Show, {
|
|
242
|
+
get when() {
|
|
243
|
+
return option.description;
|
|
244
|
+
},
|
|
245
|
+
get children() {
|
|
246
|
+
var _el$18 = _tmpl$();
|
|
247
|
+
insert(_el$18, () => {
|
|
248
|
+
return option.description;
|
|
249
|
+
});
|
|
250
|
+
effect(() => {
|
|
251
|
+
return {
|
|
252
|
+
e: ids().description,
|
|
253
|
+
t: readShallow(COMBOBOX_PARTS.itemDescription)
|
|
254
|
+
};
|
|
255
|
+
}, ({ e, t }, _p$) => {
|
|
256
|
+
e !== _p$?.e && setAttribute(_el$18, "id", e);
|
|
257
|
+
className(_el$18, t, _p$?.t);
|
|
258
|
+
});
|
|
259
|
+
return _el$18;
|
|
260
|
+
}
|
|
261
|
+
}), null);
|
|
262
|
+
insert(_el$15, createComponent(Show, {
|
|
263
|
+
get when() {
|
|
264
|
+
return selected();
|
|
265
|
+
},
|
|
266
|
+
get children() {
|
|
267
|
+
return createComponent(Icon, {
|
|
268
|
+
name: "check",
|
|
269
|
+
size: "sm"
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}), null);
|
|
273
|
+
effect(() => readShallow(COMBOBOX_PARTS.itemWords), (_v$, _$p) => {
|
|
274
|
+
className(_el$16, _v$, _$p);
|
|
275
|
+
});
|
|
276
|
+
return _el$15;
|
|
277
|
+
}
|
|
278
|
+
}));
|
|
279
|
+
return _el$12;
|
|
280
|
+
}
|
|
281
|
+
}));
|
|
282
|
+
return _el$10;
|
|
283
|
+
} }), _el$13);
|
|
284
|
+
effect(() => {
|
|
285
|
+
return {
|
|
286
|
+
e: readShallow(COMBOBOX_PARTS.footer),
|
|
287
|
+
t: readShallow(COMBOBOX_PARTS.error)
|
|
288
|
+
};
|
|
289
|
+
}, ({ e, t }, _p$) => {
|
|
290
|
+
className(_el$5, e, _p$?.e);
|
|
291
|
+
className(_el$7, t, _p$?.t);
|
|
292
|
+
});
|
|
293
|
+
return _el$;
|
|
294
|
+
}
|
|
295
|
+
export { Combobox };
|
package/dist/dom/Link.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { composeRefs } from "./controllable.js";
|
|
2
|
+
import { Icon } from "./Icon.js";
|
|
3
|
+
import { rootAttributes } from "./root.js";
|
|
4
|
+
import { createComponent, dynamic, memo, mergeProps } from "@solidjs/web";
|
|
5
|
+
import { LINK_ICON, LINK_PARTS, classes, linkElement, rootPart } from "@xds/core";
|
|
6
|
+
import { Show, createMemo } from "solid-js";
|
|
7
|
+
// packages/ui-solid/src/Link.tsx
|
|
8
|
+
var ROOT = rootPart("Link");
|
|
9
|
+
/**
|
|
10
|
+
* Text that takes the person somewhere, in the type of the text around it. It is underlined, so
|
|
11
|
+
* it does not depend on color. With `href` it is a native link; without one, a button that
|
|
12
|
+
* assistive technology hears as a link.
|
|
13
|
+
*/
|
|
14
|
+
function Link(props) {
|
|
15
|
+
const element = createMemo(() => linkElement({
|
|
16
|
+
href: props.href,
|
|
17
|
+
external: props.external,
|
|
18
|
+
disabled: props.disabled
|
|
19
|
+
}));
|
|
20
|
+
const Tag = dynamic(() => element().tag);
|
|
21
|
+
const ref = composeRefs(() => {}, () => props.ref);
|
|
22
|
+
return createComponent(Tag, mergeProps({ ref }, () => {
|
|
23
|
+
return rootAttributes(props);
|
|
24
|
+
}, () => {
|
|
25
|
+
return element().attributes;
|
|
26
|
+
}, {
|
|
27
|
+
get "class"() {
|
|
28
|
+
return classes(ROOT, props.class);
|
|
29
|
+
},
|
|
30
|
+
get style() {
|
|
31
|
+
return props.style;
|
|
32
|
+
},
|
|
33
|
+
onClick: () => {
|
|
34
|
+
if (!props.disabled) props.onPress?.();
|
|
35
|
+
},
|
|
36
|
+
onFocus: (event) => props.onFocus?.(event),
|
|
37
|
+
onBlur: (event) => props.onBlur?.(event),
|
|
38
|
+
get children() {
|
|
39
|
+
return [memo(() => {
|
|
40
|
+
return props.children;
|
|
41
|
+
}), createComponent(Show, {
|
|
42
|
+
get when() {
|
|
43
|
+
return props.external;
|
|
44
|
+
},
|
|
45
|
+
get children() {
|
|
46
|
+
return createComponent(Icon, {
|
|
47
|
+
get name() {
|
|
48
|
+
return LINK_ICON.name;
|
|
49
|
+
},
|
|
50
|
+
get size() {
|
|
51
|
+
return LINK_ICON.size;
|
|
52
|
+
},
|
|
53
|
+
get "class"() {
|
|
54
|
+
return LINK_PARTS.icon;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
})];
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
export { Link };
|
package/dist/dom/Menu.js
CHANGED
|
@@ -3,6 +3,7 @@ import { modalPopover } from "./modal-popover.js";
|
|
|
3
3
|
import { Portal as Portal$1 } from "./portal.js";
|
|
4
4
|
import { createPresence } from "./presence.js";
|
|
5
5
|
import { rootAttributes } from "./root.js";
|
|
6
|
+
import { createItemProps } from "./rows.js";
|
|
6
7
|
import { TriggerContext, provideTrigger } from "./trigger.js";
|
|
7
8
|
import { createComponent, delegateEvents, effect, insert, readShallow, ref, spread, style, template } from "@solidjs/web";
|
|
8
9
|
import { classes, firstMenuValue, keepListKeys, layoutRect, leaveEscapeToFields, menuItemClass, opensOnPress, readCssPx, underlayLayerStyle } from "@xds/core";
|
|
@@ -124,22 +125,22 @@ function Menu(props) {
|
|
|
124
125
|
get each() {
|
|
125
126
|
return props.items;
|
|
126
127
|
},
|
|
127
|
-
children: (item, index) =>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
128
|
+
children: (item, index) => {
|
|
129
|
+
if (item === "separator") return (() => {
|
|
130
|
+
var _el$4 = _tmpl$3();
|
|
131
|
+
spread(_el$4, [() => {
|
|
132
|
+
return api().getSeparatorProps();
|
|
133
|
+
}, { class: "xds-menu__separator" }], false);
|
|
134
|
+
return _el$4;
|
|
135
|
+
})();
|
|
136
|
+
const itemProps = createItemProps(() => api().getItemProps({
|
|
137
|
+
value: String(index()),
|
|
138
|
+
disabled: item.disabled
|
|
139
|
+
}));
|
|
134
140
|
var _el$5 = _tmpl$4();
|
|
135
141
|
var _el$6 = _el$5.firstChild;
|
|
136
142
|
var _el$7 = _el$6.nextSibling;
|
|
137
|
-
spread(_el$5, [()
|
|
138
|
-
return api().getItemProps({
|
|
139
|
-
value: String(index()),
|
|
140
|
-
disabled: item.disabled
|
|
141
|
-
});
|
|
142
|
-
}, { get "class"() {
|
|
143
|
+
spread(_el$5, [itemProps, { get "class"() {
|
|
143
144
|
return menuItemClass(item.danger);
|
|
144
145
|
} }], true);
|
|
145
146
|
insert(_el$5, createComponent(Show, {
|
|
@@ -170,7 +171,7 @@ function Menu(props) {
|
|
|
170
171
|
}
|
|
171
172
|
}), _el$7);
|
|
172
173
|
return _el$5;
|
|
173
|
-
}
|
|
174
|
+
}
|
|
174
175
|
}));
|
|
175
176
|
return _el$2;
|
|
176
177
|
})()];
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { createControllable } from "./controllable.js";
|
|
2
|
+
import { Icon } from "./Icon.js";
|
|
3
|
+
import { useLabels } from "./Labels.js";
|
|
4
|
+
import { rootAttributes } from "./root.js";
|
|
5
|
+
import { className, createComponent, delegateEvents, effect, insert, memo, readShallow, setAttribute, spread, template } from "@solidjs/web";
|
|
6
|
+
import { PAGINATION_PARTS, PAGINATION_STEPS, clampPage, classes, isControlled, paginationEntries, rootPart } from "@xds/core";
|
|
7
|
+
import { For, Show } from "solid-js";
|
|
8
|
+
// packages/ui-solid/src/Pagination.tsx
|
|
9
|
+
var _tmpl$ = /* @__PURE__ */ template(`<nav><ul><li><button type=button></button></li><li><button type=button>`);
|
|
10
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<li>`);
|
|
11
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<span aria-hidden=true>…`);
|
|
12
|
+
var _tmpl$4 = /* @__PURE__ */ template(`<button type=button>`);
|
|
13
|
+
var ROOT = rootPart("Pagination");
|
|
14
|
+
/**
|
|
15
|
+
* Moves through a list split into pages: a step back, the first and the last pages, the page
|
|
16
|
+
* shown with an ellipsis for those left out, and a step on. A navigation landmark; the page
|
|
17
|
+
* shown is marked as the current page. Without `value` it keeps its own, from `defaultValue`.
|
|
18
|
+
*/
|
|
19
|
+
function Pagination(props) {
|
|
20
|
+
const labels = useLabels();
|
|
21
|
+
const value = createControllable({
|
|
22
|
+
controlled: () => isControlled(props, "value"),
|
|
23
|
+
value: () => props.value,
|
|
24
|
+
defaultValue: () => props.defaultValue ?? 1,
|
|
25
|
+
onChange: (next) => {
|
|
26
|
+
if (next !== void 0) props.onChange?.(next);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const page = () => clampPage(value.value() ?? 1, props.count);
|
|
30
|
+
const last = () => Math.max(1, Math.floor(props.count));
|
|
31
|
+
const go = (next) => {
|
|
32
|
+
if (next !== page() && next >= 1 && next <= last()) value.set(next);
|
|
33
|
+
};
|
|
34
|
+
var _el$ = _tmpl$();
|
|
35
|
+
var _el$2 = _el$.firstChild;
|
|
36
|
+
var _el$3 = _el$2.firstChild;
|
|
37
|
+
var _el$4 = _el$3.firstChild;
|
|
38
|
+
var _el$5 = _el$3.nextSibling;
|
|
39
|
+
var _el$6 = _el$5.firstChild;
|
|
40
|
+
spread(_el$, [() => {
|
|
41
|
+
return rootAttributes(props);
|
|
42
|
+
}, {
|
|
43
|
+
get "aria-label"() {
|
|
44
|
+
return props.label ?? labels().pagination;
|
|
45
|
+
},
|
|
46
|
+
get "class"() {
|
|
47
|
+
return classes(ROOT, props.class);
|
|
48
|
+
},
|
|
49
|
+
get style() {
|
|
50
|
+
return props.style;
|
|
51
|
+
}
|
|
52
|
+
}], true);
|
|
53
|
+
_el$4._$$click = () => go(page() - 1);
|
|
54
|
+
insert(_el$4, createComponent(Icon, {
|
|
55
|
+
get name() {
|
|
56
|
+
return PAGINATION_STEPS.previous;
|
|
57
|
+
},
|
|
58
|
+
get size() {
|
|
59
|
+
return PAGINATION_STEPS.size;
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
62
|
+
insert(_el$2, createComponent(For, {
|
|
63
|
+
get each() {
|
|
64
|
+
return paginationEntries(page(), props.count);
|
|
65
|
+
},
|
|
66
|
+
keyed: false,
|
|
67
|
+
children: (entry) => (() => {
|
|
68
|
+
var _el$7 = _tmpl$2();
|
|
69
|
+
insert(_el$7, createComponent(Show, {
|
|
70
|
+
get when() {
|
|
71
|
+
return memo(() => {
|
|
72
|
+
return entry() !== "gap";
|
|
73
|
+
})() && entry();
|
|
74
|
+
},
|
|
75
|
+
get fallback() {
|
|
76
|
+
var _el$8 = _tmpl$3();
|
|
77
|
+
effect(() => readShallow(PAGINATION_PARTS.gap), (_v$, _$p) => {
|
|
78
|
+
className(_el$8, _v$, _$p);
|
|
79
|
+
});
|
|
80
|
+
return _el$8;
|
|
81
|
+
},
|
|
82
|
+
children: (number) => (() => {
|
|
83
|
+
var _el$9 = _tmpl$4();
|
|
84
|
+
_el$9._$$click = () => go(number());
|
|
85
|
+
insert(_el$9, number);
|
|
86
|
+
effect(() => {
|
|
87
|
+
return {
|
|
88
|
+
e: readShallow(PAGINATION_PARTS.page),
|
|
89
|
+
t: number() === page() ? "page" : void 0
|
|
90
|
+
};
|
|
91
|
+
}, ({ e, t }, _p$) => {
|
|
92
|
+
className(_el$9, e, _p$?.e);
|
|
93
|
+
t !== _p$?.t && setAttribute(_el$9, "aria-current", t);
|
|
94
|
+
});
|
|
95
|
+
return _el$9;
|
|
96
|
+
})()
|
|
97
|
+
}));
|
|
98
|
+
return _el$7;
|
|
99
|
+
})()
|
|
100
|
+
}), _el$5);
|
|
101
|
+
_el$6._$$click = () => go(page() + 1);
|
|
102
|
+
insert(_el$6, createComponent(Icon, {
|
|
103
|
+
get name() {
|
|
104
|
+
return PAGINATION_STEPS.next;
|
|
105
|
+
},
|
|
106
|
+
get size() {
|
|
107
|
+
return PAGINATION_STEPS.size;
|
|
108
|
+
}
|
|
109
|
+
}));
|
|
110
|
+
effect(() => {
|
|
111
|
+
return {
|
|
112
|
+
e: readShallow(PAGINATION_PARTS.list),
|
|
113
|
+
t: readShallow(PAGINATION_PARTS.step),
|
|
114
|
+
a: props.previousLabel ?? labels().previousPage,
|
|
115
|
+
o: page() <= 1 ? "true" : void 0,
|
|
116
|
+
i: readShallow(PAGINATION_PARTS.step),
|
|
117
|
+
n: props.nextLabel ?? labels().nextPage,
|
|
118
|
+
s: page() >= last() ? "true" : void 0
|
|
119
|
+
};
|
|
120
|
+
}, ({ e, t, a, o, i, n, s }, _p$) => {
|
|
121
|
+
className(_el$2, e, _p$?.e);
|
|
122
|
+
className(_el$4, t, _p$?.t);
|
|
123
|
+
a !== _p$?.a && setAttribute(_el$4, "aria-label", a);
|
|
124
|
+
o !== _p$?.o && setAttribute(_el$4, "aria-disabled", o);
|
|
125
|
+
className(_el$6, i, _p$?.i);
|
|
126
|
+
n !== _p$?.n && setAttribute(_el$6, "aria-label", n);
|
|
127
|
+
s !== _p$?.s && setAttribute(_el$6, "aria-disabled", s);
|
|
128
|
+
});
|
|
129
|
+
return _el$;
|
|
130
|
+
}
|
|
131
|
+
delegateEvents(["click"]);
|
|
132
|
+
export { Pagination };
|