@xds/solid 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +19 -2
- package/dist/dom/Accordion.js +139 -0
- package/dist/dom/Avatar.js +59 -0
- package/dist/dom/AvatarStack.js +74 -0
- package/dist/dom/Badge.js +58 -0
- package/dist/dom/Banner.js +102 -0
- package/dist/dom/Button.js +107 -0
- package/dist/dom/Card.js +164 -0
- package/dist/dom/Checkbox.js +64 -0
- package/dist/dom/Chip.js +52 -0
- package/dist/dom/ChipBar.js +28 -0
- package/dist/dom/CountBadge.js +67 -0
- package/dist/dom/DatePicker.js +300 -0
- package/dist/dom/DateRangePicker.js +404 -0
- package/dist/dom/Defaults.js +29 -0
- package/dist/dom/Dialog.js +136 -0
- package/dist/dom/Divider.js +20 -0
- package/dist/dom/EmptyState.js +70 -0
- package/dist/dom/Icon.js +46 -0
- package/dist/dom/IconButton.js +72 -0
- package/dist/dom/ListRow.js +126 -0
- package/dist/dom/MediaCard.js +178 -0
- package/dist/dom/Menu.js +176 -0
- package/dist/dom/ProgressBar.js +33 -0
- package/dist/dom/RadioGroup.js +123 -0
- package/dist/dom/SearchField.js +94 -0
- package/dist/dom/SectionHeader.js +104 -0
- package/dist/dom/SegmentedControl.js +69 -0
- package/dist/dom/Select.js +271 -0
- package/dist/dom/Sidebar.js +233 -0
- package/dist/dom/Skeleton.js +34 -0
- package/dist/dom/Slider.js +115 -0
- package/dist/dom/Spinner.js +35 -0
- package/dist/dom/Switch.js +65 -0
- package/dist/dom/Tabs.js +80 -0
- package/dist/dom/Text.js +24 -0
- package/dist/dom/TextField.js +172 -0
- package/dist/dom/Thumbnail.js +119 -0
- package/dist/dom/Toast.js +99 -0
- package/dist/dom/Tooltip.js +128 -0
- package/dist/dom/controlled.js +13 -0
- package/dist/dom/index.js +40 -0
- package/dist/dom/modal-popover.js +22 -0
- package/dist/dom/picture.js +29 -0
- package/dist/dom/presence.js +20 -0
- package/dist/dom/preview.js +139 -0
- package/dist/dom/root.js +26 -0
- package/dist/dom/trigger.js +31 -0
- package/dist/source/Accordion.d.ts +21 -0
- package/dist/source/Accordion.jsx +57 -0
- package/dist/source/Avatar.d.ts +9 -0
- package/dist/source/Avatar.jsx +16 -0
- package/dist/source/AvatarStack.d.ts +8 -0
- package/dist/source/AvatarStack.jsx +22 -0
- package/dist/source/Badge.d.ts +13 -0
- package/dist/source/Badge.jsx +15 -0
- package/dist/source/Banner.d.ts +23 -0
- package/dist/source/Banner.jsx +32 -0
- package/dist/source/Button.d.ts +15 -0
- package/dist/source/Button.jsx +48 -0
- package/dist/source/Card.d.ts +18 -0
- package/dist/source/Card.jsx +46 -0
- package/dist/source/Checkbox.d.ts +10 -0
- package/dist/source/Checkbox.jsx +20 -0
- package/dist/source/Chip.d.ts +12 -0
- package/dist/source/Chip.jsx +12 -0
- package/dist/source/ChipBar.d.ts +12 -0
- package/dist/source/ChipBar.jsx +7 -0
- package/dist/source/CountBadge.d.ts +12 -0
- package/dist/source/CountBadge.jsx +17 -0
- package/dist/source/DatePicker.d.ts +20 -0
- package/dist/source/DatePicker.jsx +109 -0
- package/dist/source/DateRangePicker.d.ts +24 -0
- package/dist/source/DateRangePicker.jsx +150 -0
- package/dist/source/Defaults.d.ts +23 -0
- package/dist/source/Defaults.jsx +12 -0
- package/dist/source/Dialog.d.ts +21 -0
- package/dist/source/Dialog.jsx +58 -0
- package/dist/source/Divider.d.ts +4 -0
- package/dist/source/Divider.jsx +5 -0
- package/dist/source/EmptyState.d.ts +12 -0
- package/dist/source/EmptyState.jsx +16 -0
- package/dist/source/Icon.d.ts +8 -0
- package/dist/source/Icon.jsx +11 -0
- package/dist/source/IconButton.d.ts +13 -0
- package/dist/source/IconButton.jsx +36 -0
- package/dist/source/ListRow.d.ts +21 -0
- package/dist/source/ListRow.jsx +38 -0
- package/dist/source/MediaCard.d.ts +20 -0
- package/dist/source/MediaCard.jsx +47 -0
- package/dist/source/Menu.d.ts +19 -0
- package/dist/source/Menu.jsx +99 -0
- package/dist/source/ProgressBar.d.ts +8 -0
- package/dist/source/ProgressBar.jsx +8 -0
- package/dist/source/RadioGroup.d.ts +15 -0
- package/dist/source/RadioGroup.jsx +57 -0
- package/dist/source/SearchField.d.ts +15 -0
- package/dist/source/SearchField.jsx +39 -0
- package/dist/source/SectionHeader.d.ts +14 -0
- package/dist/source/SectionHeader.jsx +32 -0
- package/dist/source/SegmentedControl.d.ts +12 -0
- package/dist/source/SegmentedControl.jsx +21 -0
- package/dist/source/Select.d.ts +18 -0
- package/dist/source/Select.jsx +139 -0
- package/dist/source/Sidebar.d.ts +22 -0
- package/dist/source/Sidebar.jsx +65 -0
- package/dist/source/Skeleton.d.ts +11 -0
- package/dist/source/Skeleton.jsx +9 -0
- package/dist/source/Slider.d.ts +13 -0
- package/dist/source/Slider.jsx +69 -0
- package/dist/source/Spinner.d.ts +9 -0
- package/dist/source/Spinner.jsx +12 -0
- package/dist/source/Switch.d.ts +13 -0
- package/dist/source/Switch.jsx +18 -0
- package/dist/source/Tabs.d.ts +14 -0
- package/dist/source/Tabs.jsx +31 -0
- package/dist/source/Text.d.ts +10 -0
- package/dist/source/Text.jsx +14 -0
- package/dist/source/TextField.d.ts +22 -0
- package/dist/source/TextField.jsx +73 -0
- package/dist/source/Thumbnail.d.ts +9 -0
- package/dist/source/Thumbnail.jsx +34 -0
- package/dist/source/Toast.d.ts +16 -0
- package/dist/source/Toast.jsx +42 -0
- package/dist/source/Tooltip.d.ts +28 -0
- package/dist/source/Tooltip.jsx +52 -0
- package/dist/source/controlled.d.ts +4 -0
- package/dist/source/controlled.js +11 -0
- package/dist/source/index.d.ts +40 -0
- package/dist/source/index.js +39 -0
- package/dist/source/modal-popover.d.ts +7 -0
- package/dist/source/modal-popover.js +15 -0
- package/dist/source/picture.d.ts +20 -0
- package/dist/source/picture.js +13 -0
- package/dist/source/presence.d.ts +7 -0
- package/dist/source/presence.js +13 -0
- package/dist/source/preview.d.ts +6 -0
- package/dist/source/preview.jsx +110 -0
- package/dist/source/root.d.ts +25 -0
- package/dist/source/root.js +19 -0
- package/dist/source/trigger.d.ts +18 -0
- package/dist/source/trigger.js +18 -0
- package/package.json +63 -4
- package/page.css +20 -0
- package/styles.css +3353 -0
- package/tailwind.css +2665 -0
package/dist/dom/Icon.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useDefaults } from "./Defaults.js";
|
|
2
|
+
import { className, createComponent, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
|
|
3
|
+
import { classes, iconClass, rootPart } from "@xds/core";
|
|
4
|
+
import { For } from "solid-js";
|
|
5
|
+
import { icons } from "@xds/tokens";
|
|
6
|
+
// packages/ui-solid/src/Icon.tsx
|
|
7
|
+
var _tmpl$ = /* @__PURE__ */ template(`<svg viewBox="0 0 24 24"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>`);
|
|
8
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<svg><path></svg>`, 2);
|
|
9
|
+
var ROOT = rootPart("Icon");
|
|
10
|
+
/**
|
|
11
|
+
* An icon from design/icons. It takes the color of the text around it. An arrow or a chevron
|
|
12
|
+
* mirrors itself in a right-to-left layout when given `rtl:-scale-x-100` in `class`.
|
|
13
|
+
*/
|
|
14
|
+
function Icon(props) {
|
|
15
|
+
const defaults = useDefaults("Icon");
|
|
16
|
+
var _el$ = _tmpl$();
|
|
17
|
+
insert(_el$, createComponent(For, {
|
|
18
|
+
get each() {
|
|
19
|
+
return icons[props.name];
|
|
20
|
+
},
|
|
21
|
+
children: (path) => (() => {
|
|
22
|
+
var _el$2 = _tmpl$2();
|
|
23
|
+
setAttribute(_el$2, "d", path);
|
|
24
|
+
return _el$2;
|
|
25
|
+
})()
|
|
26
|
+
}));
|
|
27
|
+
effect(() => {
|
|
28
|
+
return {
|
|
29
|
+
e: props.filled ? "currentColor" : "none",
|
|
30
|
+
t: readShallow(classes(ROOT, iconClass(props.size ?? defaults().size), props.class)),
|
|
31
|
+
a: readShallow(props.style),
|
|
32
|
+
o: props.label ? "img" : void 0,
|
|
33
|
+
i: props.label || void 0,
|
|
34
|
+
n: props.label ? void 0 : "true"
|
|
35
|
+
};
|
|
36
|
+
}, ({ e, t, a, o, i, n }, _p$) => {
|
|
37
|
+
e !== _p$?.e && setAttribute(_el$, "fill", e);
|
|
38
|
+
className(_el$, t, _p$?.t);
|
|
39
|
+
style(_el$, a, _p$?.a);
|
|
40
|
+
o !== _p$?.o && setAttribute(_el$, "role", o);
|
|
41
|
+
i !== _p$?.i && setAttribute(_el$, "aria-label", i);
|
|
42
|
+
n !== _p$?.n && setAttribute(_el$, "aria-hidden", n);
|
|
43
|
+
});
|
|
44
|
+
return _el$;
|
|
45
|
+
}
|
|
46
|
+
export { Icon };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useDefaults } from "./Defaults.js";
|
|
2
|
+
import { Icon } from "./Icon.js";
|
|
3
|
+
import { Spinner } from "./Spinner.js";
|
|
4
|
+
import { withTrigger } from "./trigger.js";
|
|
5
|
+
import { className, createComponent, effect, insert, readShallow, spread, template } from "@solidjs/web";
|
|
6
|
+
import { ICON_BUTTON_BOX, buttonClass, classes, isHeld } from "@xds/core";
|
|
7
|
+
import { Show, createMemo } from "solid-js";
|
|
8
|
+
// packages/ui-solid/src/IconButton.tsx
|
|
9
|
+
var _tmpl$ = /* @__PURE__ */ template(`<button>`);
|
|
10
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<span>`);
|
|
11
|
+
/**
|
|
12
|
+
* A button that holds only an icon, in Button's variants, sizes and states. It is a square as
|
|
13
|
+
* tall as a Button of its size, and its pressable area is never smaller than the minimum
|
|
14
|
+
* target, even when the square is. Like Button, it opens a Menu or a Tooltip it is the trigger
|
|
15
|
+
* of.
|
|
16
|
+
*/
|
|
17
|
+
function IconButton(props) {
|
|
18
|
+
const defaults = useDefaults("IconButton");
|
|
19
|
+
const variant = () => props.variant ?? defaults().variant ?? "ghost";
|
|
20
|
+
const size = () => props.size ?? defaults().size ?? "md";
|
|
21
|
+
const attributes = withTrigger(createMemo(() => ({
|
|
22
|
+
type: "button",
|
|
23
|
+
class: classes(buttonClass({
|
|
24
|
+
variant: variant(),
|
|
25
|
+
size: size(),
|
|
26
|
+
iconButton: true
|
|
27
|
+
}), props.class),
|
|
28
|
+
style: props.style,
|
|
29
|
+
disabled: props.disabled,
|
|
30
|
+
"aria-disabled": props.loading ? "true" : void 0,
|
|
31
|
+
"data-pending": props.loading ? "" : void 0,
|
|
32
|
+
"aria-pressed": props.selected === void 0 ? void 0 : props.selected ? "true" : "false",
|
|
33
|
+
"aria-label": props.label,
|
|
34
|
+
onClick: () => {
|
|
35
|
+
if (!props.loading) props.onPress?.();
|
|
36
|
+
}
|
|
37
|
+
})), () => props.loading === true);
|
|
38
|
+
var _el$ = _tmpl$();
|
|
39
|
+
spread(_el$, attributes, true);
|
|
40
|
+
insert(_el$, createComponent(Show, {
|
|
41
|
+
get when() {
|
|
42
|
+
return !props.loading;
|
|
43
|
+
},
|
|
44
|
+
get fallback() {
|
|
45
|
+
var _el$2 = _tmpl$2();
|
|
46
|
+
insert(_el$2, createComponent(Spinner, { size: "sm" }));
|
|
47
|
+
effect(() => readShallow(ICON_BUTTON_BOX[size()]), (_v$, _$p) => {
|
|
48
|
+
className(_el$2, _v$, _$p);
|
|
49
|
+
});
|
|
50
|
+
return _el$2;
|
|
51
|
+
},
|
|
52
|
+
get children() {
|
|
53
|
+
return createComponent(Icon, {
|
|
54
|
+
get name() {
|
|
55
|
+
return props.icon;
|
|
56
|
+
},
|
|
57
|
+
get size() {
|
|
58
|
+
return size();
|
|
59
|
+
},
|
|
60
|
+
get filled() {
|
|
61
|
+
return isHeld({
|
|
62
|
+
variant: variant(),
|
|
63
|
+
selected: props.selected,
|
|
64
|
+
disabled: props.disabled
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
return _el$;
|
|
71
|
+
}
|
|
72
|
+
export { IconButton };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Icon } from "./Icon.js";
|
|
2
|
+
import { className, createComponent, delegateEvents, effect, insert, memo, mergeProps, readShallow, setAttribute, style, template } from "@solidjs/web";
|
|
3
|
+
import { LIST_ROW_PARTS, classes, listRowClass, listRowDescriptionClass, listRowTitleClass, rootPart } from "@xds/core";
|
|
4
|
+
import { Show } from "solid-js";
|
|
5
|
+
// packages/ui-solid/src/ListRow.tsx
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template(`<span><span>`);
|
|
7
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<span>`);
|
|
8
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<button type=button>`);
|
|
9
|
+
var _tmpl$4 = /* @__PURE__ */ template(`<div>`);
|
|
10
|
+
var ROOT = rootPart("ListRow");
|
|
11
|
+
/** One line of a list or a settings screen. Separate rows with a Divider. */
|
|
12
|
+
function ListRow(props) {
|
|
13
|
+
return createComponent(PlaceRow, mergeProps(props, { current: "true" }));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A ListRow that says what kind of current item its selected state is. A Sidebar's rows are the
|
|
17
|
+
* places of an app, so its selected row is the current page. Only for this package's own
|
|
18
|
+
* components: the index does not export it.
|
|
19
|
+
*/
|
|
20
|
+
function PlaceRow(props) {
|
|
21
|
+
const pressable = () => props.onPress !== void 0;
|
|
22
|
+
const current = () => props.selected ? props.current : void 0;
|
|
23
|
+
const row = () => classes(ROOT, listRowClass({
|
|
24
|
+
compact: props.compact,
|
|
25
|
+
selected: props.selected,
|
|
26
|
+
pressable: pressable()
|
|
27
|
+
}), props.class);
|
|
28
|
+
const content = () => [
|
|
29
|
+
memo(() => {
|
|
30
|
+
return props.leading;
|
|
31
|
+
}),
|
|
32
|
+
(() => {
|
|
33
|
+
var _el$ = _tmpl$();
|
|
34
|
+
var _el$2 = _el$.firstChild;
|
|
35
|
+
insert(_el$2, () => {
|
|
36
|
+
return props.title;
|
|
37
|
+
});
|
|
38
|
+
insert(_el$, createComponent(Show, {
|
|
39
|
+
get when() {
|
|
40
|
+
return props.description;
|
|
41
|
+
},
|
|
42
|
+
children: (description) => (() => {
|
|
43
|
+
var _el$3 = _tmpl$2();
|
|
44
|
+
insert(_el$3, description);
|
|
45
|
+
effect(() => readShallow(listRowDescriptionClass(props.compact)), (_v$, _$p) => {
|
|
46
|
+
className(_el$3, _v$, _$p);
|
|
47
|
+
});
|
|
48
|
+
return _el$3;
|
|
49
|
+
})()
|
|
50
|
+
}), null);
|
|
51
|
+
effect(() => {
|
|
52
|
+
return {
|
|
53
|
+
e: readShallow(LIST_ROW_PARTS.text),
|
|
54
|
+
t: readShallow(listRowTitleClass({
|
|
55
|
+
compact: props.compact,
|
|
56
|
+
selected: props.selected,
|
|
57
|
+
disabled: props.disabled
|
|
58
|
+
}))
|
|
59
|
+
};
|
|
60
|
+
}, ({ e, t }, _p$) => {
|
|
61
|
+
className(_el$, e, _p$?.e);
|
|
62
|
+
className(_el$2, t, _p$?.t);
|
|
63
|
+
});
|
|
64
|
+
return _el$;
|
|
65
|
+
})(),
|
|
66
|
+
memo(() => {
|
|
67
|
+
return props.trailing;
|
|
68
|
+
}),
|
|
69
|
+
createComponent(Show, {
|
|
70
|
+
get when() {
|
|
71
|
+
return props.chevron;
|
|
72
|
+
},
|
|
73
|
+
get children() {
|
|
74
|
+
return createComponent(Icon, {
|
|
75
|
+
name: "chevron-right",
|
|
76
|
+
size: "sm",
|
|
77
|
+
get "class"() {
|
|
78
|
+
return LIST_ROW_PARTS.chevron;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
];
|
|
84
|
+
return createComponent(Show, {
|
|
85
|
+
get when() {
|
|
86
|
+
return pressable();
|
|
87
|
+
},
|
|
88
|
+
get fallback() {
|
|
89
|
+
var _el$5 = _tmpl$4();
|
|
90
|
+
insert(_el$5, content);
|
|
91
|
+
effect(() => {
|
|
92
|
+
return {
|
|
93
|
+
e: current(),
|
|
94
|
+
t: readShallow(row()),
|
|
95
|
+
a: readShallow(props.style)
|
|
96
|
+
};
|
|
97
|
+
}, ({ e, t, a }, _p$) => {
|
|
98
|
+
e !== _p$?.e && setAttribute(_el$5, "aria-current", e);
|
|
99
|
+
className(_el$5, t, _p$?.t);
|
|
100
|
+
style(_el$5, a, _p$?.a);
|
|
101
|
+
});
|
|
102
|
+
return _el$5;
|
|
103
|
+
},
|
|
104
|
+
get children() {
|
|
105
|
+
var _el$4 = _tmpl$3();
|
|
106
|
+
_el$4._$$click = () => props.onPress?.();
|
|
107
|
+
insert(_el$4, content);
|
|
108
|
+
effect(() => {
|
|
109
|
+
return {
|
|
110
|
+
e: current(),
|
|
111
|
+
t: props.disabled,
|
|
112
|
+
a: readShallow(row()),
|
|
113
|
+
o: readShallow(props.style)
|
|
114
|
+
};
|
|
115
|
+
}, ({ e, t, a, o }, _p$) => {
|
|
116
|
+
e !== _p$?.e && setAttribute(_el$4, "aria-current", e);
|
|
117
|
+
t !== _p$?.t && setAttribute(_el$4, "disabled", t);
|
|
118
|
+
className(_el$4, a, _p$?.a);
|
|
119
|
+
style(_el$4, o, _p$?.o);
|
|
120
|
+
});
|
|
121
|
+
return _el$4;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
delegateEvents(["click"]);
|
|
126
|
+
export { ListRow, PlaceRow };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { useDefaults } from "./Defaults.js";
|
|
2
|
+
import { Thumbnail } from "./Thumbnail.js";
|
|
3
|
+
import { className, createComponent, delegateEvents, effect, insert, memo, readShallow, setAttribute, style, template } from "@solidjs/web";
|
|
4
|
+
import { MEDIA_CARD_PARTS, classes, mediaCardContentClass, mediaCardIds, mediaCardThumbnailClass, rootPart } from "@xds/core";
|
|
5
|
+
import { For, Show, createMemo, createUniqueId } from "solid-js";
|
|
6
|
+
// packages/ui-solid/src/MediaCard.tsx
|
|
7
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div><span></span><div><span><span></span></span><!>`);
|
|
8
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<span>`);
|
|
9
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
|
|
10
|
+
var _tmpl$4 = /* @__PURE__ */ template(`<div><button type=button>`);
|
|
11
|
+
var _tmpl$5 = /* @__PURE__ */ template(`<div role=group>`);
|
|
12
|
+
var ROOT = rootPart("MediaCard");
|
|
13
|
+
/**
|
|
14
|
+
* A thumbnail with its title and details: a video in a feed, an article in a list.
|
|
15
|
+
*
|
|
16
|
+
* With `onPress` the whole card is one button with no surface at rest: under a pointer and
|
|
17
|
+
* while pressed it takes the card's fills, and it has a focus ring. The button is named by the
|
|
18
|
+
* title followed by the details. `action` is a separate control beside it, so pressing it does
|
|
19
|
+
* not press the card.
|
|
20
|
+
*/
|
|
21
|
+
function MediaCard(props) {
|
|
22
|
+
const id = createUniqueId();
|
|
23
|
+
const ids = createMemo(() => mediaCardIds(id, props.meta));
|
|
24
|
+
const defaults = useDefaults("MediaCard");
|
|
25
|
+
const horizontal = () => (props.layout ?? defaults().layout) === "horizontal";
|
|
26
|
+
const pressable = () => props.onPress !== void 0;
|
|
27
|
+
const hidden = () => pressable() ? "true" : void 0;
|
|
28
|
+
const content = () => (() => {
|
|
29
|
+
var _el$ = _tmpl$();
|
|
30
|
+
var _el$2 = _el$.firstChild;
|
|
31
|
+
var _el$3 = _el$2.nextSibling;
|
|
32
|
+
var _el$4 = _el$3.firstChild;
|
|
33
|
+
var _el$5 = _el$4.firstChild;
|
|
34
|
+
var _el$6 = _el$4.nextSibling;
|
|
35
|
+
insert(_el$2, createComponent(Thumbnail, {
|
|
36
|
+
get src() {
|
|
37
|
+
return props.src;
|
|
38
|
+
},
|
|
39
|
+
get alt() {
|
|
40
|
+
return props.alt ?? "";
|
|
41
|
+
},
|
|
42
|
+
get ratio() {
|
|
43
|
+
return props.ratio ?? "16:9";
|
|
44
|
+
},
|
|
45
|
+
get badge() {
|
|
46
|
+
return props.badge;
|
|
47
|
+
},
|
|
48
|
+
get progress() {
|
|
49
|
+
return props.progress;
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
insert(_el$3, createComponent(Show, {
|
|
53
|
+
get when() {
|
|
54
|
+
return memo(() => {
|
|
55
|
+
return !horizontal();
|
|
56
|
+
})() && props.leading;
|
|
57
|
+
},
|
|
58
|
+
children: (leading) => (() => {
|
|
59
|
+
var _el$7 = _tmpl$2();
|
|
60
|
+
insert(_el$7, leading);
|
|
61
|
+
effect(() => {
|
|
62
|
+
return {
|
|
63
|
+
e: hidden(),
|
|
64
|
+
t: readShallow(MEDIA_CARD_PARTS.leading)
|
|
65
|
+
};
|
|
66
|
+
}, ({ e, t }, _p$) => {
|
|
67
|
+
e !== _p$?.e && setAttribute(_el$7, "aria-hidden", e);
|
|
68
|
+
className(_el$7, t, _p$?.t);
|
|
69
|
+
});
|
|
70
|
+
return _el$7;
|
|
71
|
+
})()
|
|
72
|
+
}), _el$4);
|
|
73
|
+
insert(_el$5, () => {
|
|
74
|
+
return props.title;
|
|
75
|
+
});
|
|
76
|
+
insert(_el$4, createComponent(For, {
|
|
77
|
+
get each() {
|
|
78
|
+
return props.meta ?? [];
|
|
79
|
+
},
|
|
80
|
+
keyed: false,
|
|
81
|
+
children: (line, index) => (() => {
|
|
82
|
+
var _el$8 = _tmpl$2();
|
|
83
|
+
insert(_el$8, line);
|
|
84
|
+
effect(() => {
|
|
85
|
+
return {
|
|
86
|
+
e: ids().details[index],
|
|
87
|
+
t: readShallow(MEDIA_CARD_PARTS.meta)
|
|
88
|
+
};
|
|
89
|
+
}, ({ e, t }, _p$) => {
|
|
90
|
+
e !== _p$?.e && setAttribute(_el$8, "id", e);
|
|
91
|
+
className(_el$8, t, _p$?.t);
|
|
92
|
+
});
|
|
93
|
+
return _el$8;
|
|
94
|
+
})()
|
|
95
|
+
}), null);
|
|
96
|
+
insert(_el$3, createComponent(Show, {
|
|
97
|
+
get when() {
|
|
98
|
+
return props.action;
|
|
99
|
+
},
|
|
100
|
+
children: (action) => (() => {
|
|
101
|
+
var _el$9 = _tmpl$3();
|
|
102
|
+
insert(_el$9, action);
|
|
103
|
+
effect(() => readShallow(MEDIA_CARD_PARTS.action), (_v$, _$p) => {
|
|
104
|
+
className(_el$9, _v$, _$p);
|
|
105
|
+
});
|
|
106
|
+
return _el$9;
|
|
107
|
+
})()
|
|
108
|
+
}), _el$6);
|
|
109
|
+
effect(() => {
|
|
110
|
+
return {
|
|
111
|
+
e: readShallow(mediaCardContentClass({
|
|
112
|
+
horizontal: horizontal(),
|
|
113
|
+
pressable: pressable()
|
|
114
|
+
})),
|
|
115
|
+
t: hidden(),
|
|
116
|
+
a: readShallow(mediaCardThumbnailClass(horizontal())),
|
|
117
|
+
o: readShallow(MEDIA_CARD_PARTS.body),
|
|
118
|
+
i: hidden(),
|
|
119
|
+
n: readShallow(MEDIA_CARD_PARTS.text),
|
|
120
|
+
s: ids().title,
|
|
121
|
+
h: readShallow(MEDIA_CARD_PARTS.title)
|
|
122
|
+
};
|
|
123
|
+
}, ({ e, t, a, o, i, n, s, h }, _p$) => {
|
|
124
|
+
className(_el$, e, _p$?.e);
|
|
125
|
+
t !== _p$?.t && setAttribute(_el$2, "aria-hidden", t);
|
|
126
|
+
className(_el$2, a, _p$?.a);
|
|
127
|
+
className(_el$3, o, _p$?.o);
|
|
128
|
+
i !== _p$?.i && setAttribute(_el$4, "aria-hidden", i);
|
|
129
|
+
className(_el$4, n, _p$?.n);
|
|
130
|
+
s !== _p$?.s && setAttribute(_el$5, "id", s);
|
|
131
|
+
className(_el$5, h, _p$?.h);
|
|
132
|
+
});
|
|
133
|
+
return _el$;
|
|
134
|
+
})();
|
|
135
|
+
return createComponent(Show, {
|
|
136
|
+
get when() {
|
|
137
|
+
return pressable();
|
|
138
|
+
},
|
|
139
|
+
get fallback() {
|
|
140
|
+
var _el$12 = _tmpl$5();
|
|
141
|
+
insert(_el$12, content);
|
|
142
|
+
effect(() => {
|
|
143
|
+
return {
|
|
144
|
+
e: ids().names,
|
|
145
|
+
t: readShallow(classes(ROOT, MEDIA_CARD_PARTS.group, props.class)),
|
|
146
|
+
a: readShallow(props.style)
|
|
147
|
+
};
|
|
148
|
+
}, ({ e, t, a }, _p$) => {
|
|
149
|
+
e !== _p$?.e && setAttribute(_el$12, "aria-labelledby", e);
|
|
150
|
+
className(_el$12, t, _p$?.t);
|
|
151
|
+
style(_el$12, a, _p$?.a);
|
|
152
|
+
});
|
|
153
|
+
return _el$12;
|
|
154
|
+
},
|
|
155
|
+
get children() {
|
|
156
|
+
var _el$10 = _tmpl$4();
|
|
157
|
+
var _el$11 = _el$10.firstChild;
|
|
158
|
+
_el$11._$$click = () => props.onPress?.();
|
|
159
|
+
insert(_el$10, content, null);
|
|
160
|
+
effect(() => {
|
|
161
|
+
return {
|
|
162
|
+
e: readShallow(classes(ROOT, MEDIA_CARD_PARTS.pressable, props.class)),
|
|
163
|
+
t: readShallow(props.style),
|
|
164
|
+
a: ids().names,
|
|
165
|
+
o: readShallow(MEDIA_CARD_PARTS.button)
|
|
166
|
+
};
|
|
167
|
+
}, ({ e, t, a, o }, _p$) => {
|
|
168
|
+
className(_el$10, e, _p$?.e);
|
|
169
|
+
style(_el$10, t, _p$?.t);
|
|
170
|
+
a !== _p$?.a && setAttribute(_el$11, "aria-labelledby", a);
|
|
171
|
+
className(_el$11, o, _p$?.o);
|
|
172
|
+
});
|
|
173
|
+
return _el$10;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
delegateEvents(["click"]);
|
|
178
|
+
export { MediaCard };
|
package/dist/dom/Menu.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { Icon } from "./Icon.js";
|
|
2
|
+
import { modalPopover } from "./modal-popover.js";
|
|
3
|
+
import { createPresence } from "./presence.js";
|
|
4
|
+
import { TriggerContext, provideTrigger } from "./trigger.js";
|
|
5
|
+
import { Portal, createComponent, delegateEvents, insert, ref, spread, template } from "@solidjs/web";
|
|
6
|
+
import { classes, firstMenuValue, keepListKeys, layoutRect, leaveEscapeToFields, menuItemClass, opensOnPress } from "@xds/core";
|
|
7
|
+
import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
|
|
8
|
+
import { For, Show, createMemo, createUniqueId } from "solid-js";
|
|
9
|
+
import { space } from "@xds/tokens";
|
|
10
|
+
import * as menu from "@zag-js/menu";
|
|
11
|
+
// packages/ui-solid/src/Menu.tsx
|
|
12
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div class=xds-menu__underlay>`);
|
|
13
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<div><div>`);
|
|
14
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
|
|
15
|
+
var _tmpl$4 = /* @__PURE__ */ template(`<div><span class=flex-1></span><!>`);
|
|
16
|
+
/**
|
|
17
|
+
* A list of actions that opens from a control. Choosing an item calls its `onSelect` and
|
|
18
|
+
* closes the menu; a press outside or Escape closes it too, and focus goes back to the
|
|
19
|
+
* trigger.
|
|
20
|
+
*
|
|
21
|
+
* The trigger reports that it opens a menu and whether the menu is open. The arrow keys move
|
|
22
|
+
* the highlight and Enter chooses.
|
|
23
|
+
*
|
|
24
|
+
* Its `class` and `style` are the menu's surface's, which is in the page only while it is open.
|
|
25
|
+
*/
|
|
26
|
+
function Menu(props) {
|
|
27
|
+
const id = createUniqueId();
|
|
28
|
+
const service = useMachine(menu.machine, () => ({
|
|
29
|
+
id,
|
|
30
|
+
"aria-label": props.label,
|
|
31
|
+
positioning: {
|
|
32
|
+
placement: `bottom-${props.align ?? "start"}`,
|
|
33
|
+
gutter: space[1],
|
|
34
|
+
getAnchorRect: (anchor) => anchor instanceof HTMLElement ? layoutRect(anchor) : null
|
|
35
|
+
},
|
|
36
|
+
onSelect: (details) => {
|
|
37
|
+
const item = props.items[Number(details.value)];
|
|
38
|
+
if (item && item !== "separator") item.onSelect();
|
|
39
|
+
},
|
|
40
|
+
onEscapeKeyDown: leaveEscapeToFields,
|
|
41
|
+
loopFocus: true
|
|
42
|
+
}));
|
|
43
|
+
const api = createMemo(() => menu.connect(service, normalizeProps));
|
|
44
|
+
let pressOpened = false;
|
|
45
|
+
const trigger = provideTrigger(() => {
|
|
46
|
+
const { onPointerDown: _onPointerDown, ...rest } = api().getTriggerProps();
|
|
47
|
+
return mergeProps$1(rest, {
|
|
48
|
+
class: "xds-menu__trigger",
|
|
49
|
+
onPointerDown: (event) => {
|
|
50
|
+
pressOpened = opensOnPress(event) && !api().open;
|
|
51
|
+
if (pressOpened) api().setOpen(true);
|
|
52
|
+
},
|
|
53
|
+
onClick: (event) => {
|
|
54
|
+
const pointer = event.detail !== 0;
|
|
55
|
+
if (pressOpened && pointer) {
|
|
56
|
+
pressOpened = false;
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (pointer) return;
|
|
61
|
+
requestAnimationFrame(() => {
|
|
62
|
+
if (!api().open) return;
|
|
63
|
+
const first = firstMenuValue(props.items);
|
|
64
|
+
if (first !== void 0) api().setHighlightedValue(first);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
let positioner;
|
|
70
|
+
let surface;
|
|
71
|
+
modalPopover(() => api().open, () => positioner);
|
|
72
|
+
const present = createPresence(() => api().open, () => [surface]);
|
|
73
|
+
const content = mergeProps$1(() => api().getContentProps(), {
|
|
74
|
+
onKeyDown: (event) => keepListKeys(event, surface, ".xds-menu__item:not([data-disabled])", (value) => api().setHighlightedValue(value)),
|
|
75
|
+
get style() {
|
|
76
|
+
return props.style;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return [createComponent(TriggerContext, {
|
|
80
|
+
value: trigger,
|
|
81
|
+
get children() {
|
|
82
|
+
return props.trigger;
|
|
83
|
+
}
|
|
84
|
+
}), createComponent(Portal, { get children() {
|
|
85
|
+
return createComponent(TriggerContext, {
|
|
86
|
+
value: null,
|
|
87
|
+
get children() {
|
|
88
|
+
return [createComponent(Show, {
|
|
89
|
+
get when() {
|
|
90
|
+
return api().open;
|
|
91
|
+
},
|
|
92
|
+
get children() {
|
|
93
|
+
var _el$ = _tmpl$();
|
|
94
|
+
_el$._$$mousedown = (event) => event.preventDefault();
|
|
95
|
+
return _el$;
|
|
96
|
+
}
|
|
97
|
+
}), (() => {
|
|
98
|
+
var _el$2 = _tmpl$2();
|
|
99
|
+
var _el$3 = _el$2.firstChild;
|
|
100
|
+
spread(_el$2, [() => {
|
|
101
|
+
return api().getPositionerProps();
|
|
102
|
+
}, { class: "xds-menu__positioner" }], true);
|
|
103
|
+
ref(() => {
|
|
104
|
+
return (element) => positioner = element;
|
|
105
|
+
}, _el$2);
|
|
106
|
+
spread(_el$3, [content, {
|
|
107
|
+
get hidden() {
|
|
108
|
+
return !present();
|
|
109
|
+
},
|
|
110
|
+
get "class"() {
|
|
111
|
+
return classes("xds-menu", props.class);
|
|
112
|
+
}
|
|
113
|
+
}], true);
|
|
114
|
+
ref(() => {
|
|
115
|
+
return (element) => surface = element;
|
|
116
|
+
}, _el$3);
|
|
117
|
+
insert(_el$3, createComponent(For, {
|
|
118
|
+
get each() {
|
|
119
|
+
return props.items;
|
|
120
|
+
},
|
|
121
|
+
children: (item, index) => item === "separator" ? (() => {
|
|
122
|
+
var _el$4 = _tmpl$3();
|
|
123
|
+
spread(_el$4, [() => {
|
|
124
|
+
return api().getSeparatorProps();
|
|
125
|
+
}, { class: "xds-menu__separator" }], false);
|
|
126
|
+
return _el$4;
|
|
127
|
+
})() : (() => {
|
|
128
|
+
var _el$5 = _tmpl$4();
|
|
129
|
+
var _el$6 = _el$5.firstChild;
|
|
130
|
+
var _el$7 = _el$6.nextSibling;
|
|
131
|
+
spread(_el$5, [() => {
|
|
132
|
+
return api().getItemProps({
|
|
133
|
+
value: String(index()),
|
|
134
|
+
disabled: item.disabled
|
|
135
|
+
});
|
|
136
|
+
}, { get "class"() {
|
|
137
|
+
return menuItemClass(item.danger);
|
|
138
|
+
} }], true);
|
|
139
|
+
insert(_el$5, createComponent(Show, {
|
|
140
|
+
get when() {
|
|
141
|
+
return item.icon;
|
|
142
|
+
},
|
|
143
|
+
children: (name) => createComponent(Icon, {
|
|
144
|
+
get name() {
|
|
145
|
+
return name();
|
|
146
|
+
},
|
|
147
|
+
size: "sm",
|
|
148
|
+
class: "xds-menu__item-icon"
|
|
149
|
+
})
|
|
150
|
+
}), _el$6);
|
|
151
|
+
insert(_el$6, () => {
|
|
152
|
+
return item.label;
|
|
153
|
+
});
|
|
154
|
+
insert(_el$5, createComponent(Show, {
|
|
155
|
+
get when() {
|
|
156
|
+
return item.selected;
|
|
157
|
+
},
|
|
158
|
+
get children() {
|
|
159
|
+
return createComponent(Icon, {
|
|
160
|
+
name: "check",
|
|
161
|
+
size: "sm",
|
|
162
|
+
label: "Selected"
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}), _el$7);
|
|
166
|
+
return _el$5;
|
|
167
|
+
})()
|
|
168
|
+
}));
|
|
169
|
+
return _el$2;
|
|
170
|
+
})()];
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
} })];
|
|
174
|
+
}
|
|
175
|
+
delegateEvents(["mousedown"]);
|
|
176
|
+
export { Menu };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { className, effect, readShallow, setAttribute, setStyleProperty, style, template } from "@solidjs/web";
|
|
2
|
+
import { classes, progressBarClass, progressBarFillClass, progressPercent, rootPart } from "@xds/core";
|
|
3
|
+
// packages/ui-solid/src/ProgressBar.tsx
|
|
4
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div role=progressbar aria-valuemin=0 aria-valuemax=100><div>`);
|
|
5
|
+
var ROOT = rootPart("ProgressBar");
|
|
6
|
+
/**
|
|
7
|
+
* How far along something is, from 0 to 1. For work of unknown length use a Spinner.
|
|
8
|
+
* `label` says what is progressing; a screen reader reads it with the percentage.
|
|
9
|
+
*/
|
|
10
|
+
function ProgressBar(props) {
|
|
11
|
+
const percent = () => progressPercent(props.value);
|
|
12
|
+
var _el$ = _tmpl$();
|
|
13
|
+
var _el$2 = _el$.firstChild;
|
|
14
|
+
effect(() => {
|
|
15
|
+
return {
|
|
16
|
+
e: props.label,
|
|
17
|
+
t: percent(),
|
|
18
|
+
a: readShallow(classes(ROOT, progressBarClass, props.class)),
|
|
19
|
+
o: readShallow(props.style),
|
|
20
|
+
i: readShallow(progressBarFillClass),
|
|
21
|
+
n: `${percent()}%`
|
|
22
|
+
};
|
|
23
|
+
}, ({ e, t, a, o, i, n }, _p$) => {
|
|
24
|
+
e !== _p$?.e && setAttribute(_el$, "aria-label", e);
|
|
25
|
+
t !== _p$?.t && setAttribute(_el$, "aria-valuenow", t);
|
|
26
|
+
className(_el$, a, _p$?.a);
|
|
27
|
+
style(_el$, o, _p$?.o);
|
|
28
|
+
className(_el$2, i, _p$?.i);
|
|
29
|
+
n !== _p$?.n && setStyleProperty(_el$2, "width", n);
|
|
30
|
+
});
|
|
31
|
+
return _el$;
|
|
32
|
+
}
|
|
33
|
+
export { ProgressBar };
|