@xds/solid 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dom/Accordion.js +3 -2
- package/dist/dom/Avatar.js +17 -13
- package/dist/dom/AvatarStack.js +17 -13
- package/dist/dom/Badge.js +12 -10
- package/dist/dom/Banner.js +25 -15
- package/dist/dom/Breadcrumb.js +87 -0
- package/dist/dom/Button.js +10 -3
- package/dist/dom/Card.js +31 -26
- package/dist/dom/Checkbox.js +57 -26
- package/dist/dom/Chip.js +21 -17
- package/dist/dom/ChipBar.js +17 -13
- package/dist/dom/Combobox.js +295 -0
- package/dist/dom/CountBadge.js +28 -23
- package/dist/dom/DatePicker.js +13 -7
- package/dist/dom/DateRangePicker.js +16 -10
- package/dist/dom/Dialog.js +3 -2
- package/dist/dom/Divider.js +12 -10
- package/dist/dom/EmptyState.js +14 -11
- package/dist/dom/Icon.js +30 -19
- package/dist/dom/IconButton.js +10 -3
- package/dist/dom/Labels.js +26 -0
- package/dist/dom/Link.js +62 -0
- package/dist/dom/ListRow.js +34 -28
- package/dist/dom/MediaCard.js +32 -23
- package/dist/dom/Menu.js +18 -15
- package/dist/dom/Pagination.js +132 -0
- package/dist/dom/Popover.js +126 -0
- package/dist/dom/ProgressBar.js +27 -15
- package/dist/dom/RadioGroup.js +44 -23
- package/dist/dom/SearchField.js +58 -32
- package/dist/dom/SectionHeader.js +17 -10
- package/dist/dom/SegmentedControl.js +33 -19
- package/dist/dom/Select.js +91 -51
- package/dist/dom/Sidebar.js +17 -13
- package/dist/dom/Skeleton.js +15 -13
- package/dist/dom/Slider.js +15 -7
- package/dist/dom/Spinner.js +23 -17
- package/dist/dom/Switch.js +49 -24
- package/dist/dom/Table.js +150 -0
- package/dist/dom/Tabs.js +16 -6
- package/dist/dom/Text.js +6 -3
- package/dist/dom/TextField.js +37 -19
- package/dist/dom/Thumbnail.js +21 -14
- package/dist/dom/TimePicker.js +245 -0
- package/dist/dom/Toast.js +19 -20
- package/dist/dom/ToastQueue.js +59 -0
- package/dist/dom/Tooltip.js +10 -6
- package/dist/dom/base.js +16 -0
- package/dist/dom/controllable.js +44 -0
- package/dist/dom/index.js +10 -1
- package/dist/dom/modal-popover.js +2 -2
- package/dist/dom/presence.js +3 -2
- package/dist/dom/preview.js +20 -1
- package/dist/dom/root.js +16 -4
- package/dist/dom/rows.js +13 -0
- package/dist/dom/trigger.js +5 -3
- package/dist/source/Accordion.jsx +3 -2
- package/dist/source/Avatar.d.ts +1 -1
- package/dist/source/Avatar.jsx +2 -1
- package/dist/source/AvatarStack.d.ts +1 -1
- package/dist/source/AvatarStack.jsx +2 -1
- package/dist/source/Badge.d.ts +1 -1
- package/dist/source/Badge.jsx +2 -1
- package/dist/source/Banner.d.ts +1 -1
- package/dist/source/Banner.jsx +5 -2
- package/dist/source/Breadcrumb.d.ts +9 -0
- package/dist/source/Breadcrumb.jsx +26 -0
- package/dist/source/Button.d.ts +5 -1
- package/dist/source/Button.jsx +5 -2
- package/dist/source/Card.d.ts +1 -1
- package/dist/source/Card.jsx +3 -2
- package/dist/source/Checkbox.d.ts +10 -4
- package/dist/source/Checkbox.jsx +26 -8
- package/dist/source/Chip.d.ts +1 -1
- package/dist/source/Chip.jsx +2 -1
- package/dist/source/ChipBar.d.ts +1 -1
- package/dist/source/ChipBar.jsx +2 -1
- package/dist/source/Combobox.d.ts +16 -0
- package/dist/source/Combobox.jsx +137 -0
- package/dist/source/CountBadge.d.ts +1 -1
- package/dist/source/CountBadge.jsx +3 -2
- package/dist/source/DatePicker.jsx +13 -7
- package/dist/source/DateRangePicker.jsx +16 -10
- package/dist/source/Dialog.jsx +3 -2
- package/dist/source/Divider.d.ts +1 -1
- package/dist/source/Divider.jsx +2 -1
- package/dist/source/EmptyState.d.ts +1 -1
- package/dist/source/EmptyState.jsx +2 -1
- package/dist/source/Icon.d.ts +1 -1
- package/dist/source/Icon.jsx +2 -1
- package/dist/source/IconButton.d.ts +5 -1
- package/dist/source/IconButton.jsx +5 -2
- package/dist/source/Labels.d.ts +17 -0
- package/dist/source/Labels.jsx +11 -0
- package/dist/source/Link.d.ts +20 -0
- package/dist/source/Link.jsx +21 -0
- package/dist/source/ListRow.d.ts +1 -1
- package/dist/source/ListRow.jsx +3 -2
- package/dist/source/MediaCard.d.ts +1 -1
- package/dist/source/MediaCard.jsx +3 -2
- package/dist/source/Menu.d.ts +1 -1
- package/dist/source/Menu.jsx +11 -3
- package/dist/source/Pagination.d.ts +12 -0
- package/dist/source/Pagination.jsx +51 -0
- package/dist/source/Popover.d.ts +19 -0
- package/dist/source/Popover.jsx +65 -0
- package/dist/source/ProgressBar.d.ts +1 -1
- package/dist/source/ProgressBar.jsx +2 -1
- package/dist/source/RadioGroup.d.ts +5 -2
- package/dist/source/RadioGroup.jsx +18 -5
- package/dist/source/SearchField.d.ts +11 -3
- package/dist/source/SearchField.jsx +26 -12
- package/dist/source/SectionHeader.d.ts +1 -1
- package/dist/source/SectionHeader.jsx +2 -1
- package/dist/source/SegmentedControl.d.ts +4 -3
- package/dist/source/SegmentedControl.jsx +16 -5
- package/dist/source/Select.d.ts +10 -1
- package/dist/source/Select.jsx +46 -11
- package/dist/source/Sidebar.d.ts +1 -1
- package/dist/source/Sidebar.jsx +2 -1
- package/dist/source/Skeleton.jsx +2 -2
- package/dist/source/Slider.d.ts +2 -2
- package/dist/source/Slider.jsx +14 -6
- package/dist/source/Spinner.d.ts +1 -1
- package/dist/source/Spinner.jsx +2 -1
- package/dist/source/Switch.d.ts +10 -4
- package/dist/source/Switch.jsx +18 -6
- package/dist/source/Table.d.ts +17 -0
- package/dist/source/Table.jsx +46 -0
- package/dist/source/Tabs.d.ts +2 -2
- package/dist/source/Tabs.jsx +16 -5
- package/dist/source/Text.d.ts +1 -1
- package/dist/source/Text.jsx +2 -1
- package/dist/source/TextField.d.ts +12 -3
- package/dist/source/TextField.jsx +24 -9
- package/dist/source/Thumbnail.d.ts +1 -1
- package/dist/source/Thumbnail.jsx +2 -1
- package/dist/source/TimePicker.d.ts +19 -0
- package/dist/source/TimePicker.jsx +137 -0
- package/dist/source/Toast.d.ts +1 -1
- package/dist/source/Toast.jsx +2 -1
- package/dist/source/ToastQueue.d.ts +19 -0
- package/dist/source/ToastQueue.jsx +27 -0
- package/dist/source/Tooltip.jsx +4 -3
- package/dist/source/base.d.ts +15 -0
- package/dist/source/base.js +15 -0
- package/dist/source/controllable.d.ts +30 -0
- package/dist/source/controllable.js +30 -0
- package/dist/source/index.d.ts +10 -1
- package/dist/source/index.js +9 -0
- package/dist/source/modal-popover.js +2 -2
- package/dist/source/presence.js +3 -2
- package/dist/source/preview.d.ts +10 -2
- package/dist/source/preview.jsx +12 -2
- package/dist/source/root.d.ts +14 -4
- package/dist/source/root.js +7 -2
- package/dist/source/rows.d.ts +8 -0
- package/dist/source/rows.js +5 -0
- package/dist/source/trigger.d.ts +4 -2
- package/dist/source/trigger.js +2 -2
- package/eject/files/Accordion.tsx +138 -0
- package/eject/files/Avatar.tsx +48 -0
- package/eject/files/AvatarStack.tsx +51 -0
- package/eject/files/Badge.tsx +39 -0
- package/eject/files/Banner.tsx +80 -0
- package/eject/files/Breadcrumb.tsx +57 -0
- package/eject/files/Button.tsx +90 -0
- package/eject/files/Card.tsx +100 -0
- package/eject/files/Checkbox.tsx +100 -0
- package/eject/files/Chip.tsx +40 -0
- package/eject/files/ChipBar.tsx +34 -0
- package/eject/files/Combobox.tsx +200 -0
- package/eject/files/CountBadge.tsx +55 -0
- package/eject/files/DatePicker.tsx +225 -0
- package/eject/files/DateRangePicker.tsx +319 -0
- package/eject/files/Dialog.tsx +117 -0
- package/eject/files/Divider.tsx +21 -0
- package/eject/files/EmptyState.tsx +39 -0
- package/eject/files/Icon.tsx +37 -0
- package/eject/files/IconButton.tsx +76 -0
- package/eject/files/Link.tsx +61 -0
- package/eject/files/ListRow.tsx +94 -0
- package/eject/files/MediaCard.tsx +116 -0
- package/eject/files/Menu.tsx +190 -0
- package/eject/files/Pagination.tsx +109 -0
- package/eject/files/Popover.tsx +124 -0
- package/eject/files/ProgressBar.tsx +37 -0
- package/eject/files/RadioGroup.tsx +138 -0
- package/eject/files/SearchField.tsx +124 -0
- package/eject/files/SectionHeader.tsx +59 -0
- package/eject/files/SegmentedControl.tsx +79 -0
- package/eject/files/Select.tsx +290 -0
- package/eject/files/Sidebar.tsx +156 -0
- package/eject/files/Skeleton.tsx +33 -0
- package/eject/files/Slider.tsx +131 -0
- package/eject/files/Spinner.tsx +44 -0
- package/eject/files/Switch.tsx +88 -0
- package/eject/files/Table.tsx +98 -0
- package/eject/files/Tabs.tsx +87 -0
- package/eject/files/Text.tsx +38 -0
- package/eject/files/TextField.tsx +171 -0
- package/eject/files/Thumbnail.tsx +84 -0
- package/eject/files/TimePicker.tsx +237 -0
- package/eject/files/Toast.tsx +100 -0
- package/eject/files/ToastQueue.tsx +62 -0
- package/eject/files/Tooltip.tsx +135 -0
- package/eject/files/accordion.css +89 -0
- package/eject/files/accordion.ts +67 -0
- package/eject/files/avatar-stack.ts +57 -0
- package/eject/files/avatar.ts +42 -0
- package/eject/files/badge.ts +30 -0
- package/eject/files/banner.ts +71 -0
- package/eject/files/base.css +38 -0
- package/eject/files/breadcrumb.css +51 -0
- package/eject/files/breadcrumb.ts +42 -0
- package/eject/files/button.css +241 -0
- package/eject/files/button.ts +106 -0
- package/eject/files/card.ts +58 -0
- package/eject/files/checkbox.ts +52 -0
- package/eject/files/chip-bar.ts +16 -0
- package/eject/files/chip.ts +35 -0
- package/eject/files/combobox.css +269 -0
- package/eject/files/combobox.ts +85 -0
- package/eject/files/count-badge.ts +32 -0
- package/eject/files/date-picker.css +375 -0
- package/eject/files/date-picker.ts +280 -0
- package/eject/files/date-range-picker.ts +338 -0
- package/eject/files/dialog.css +139 -0
- package/eject/files/dialog.ts +15 -0
- package/eject/files/divider.ts +5 -0
- package/eject/files/empty-state.ts +22 -0
- package/eject/files/icon.ts +36 -0
- package/eject/files/link.css +64 -0
- package/eject/files/link.ts +63 -0
- package/eject/files/list-row.ts +66 -0
- package/eject/files/media-card.ts +66 -0
- package/eject/files/menu.css +192 -0
- package/eject/files/menu.ts +84 -0
- package/eject/files/overlay.css +40 -0
- package/eject/files/pagination.css +106 -0
- package/eject/files/pagination.ts +68 -0
- package/eject/files/parts.ts +17 -0
- package/eject/files/popover.css +101 -0
- package/eject/files/popover.ts +37 -0
- package/eject/files/progress-bar.ts +26 -0
- package/eject/files/radio-group.css +184 -0
- package/eject/files/radio-group.ts +30 -0
- package/eject/files/section-header.ts +32 -0
- package/eject/files/segmented-control.ts +33 -0
- package/eject/files/select.css +347 -0
- package/eject/files/select.ts +77 -0
- package/eject/files/sidebar.ts +75 -0
- package/eject/files/skeleton.ts +51 -0
- package/eject/files/slider.css +160 -0
- package/eject/files/slider.ts +80 -0
- package/eject/files/spinner.ts +22 -0
- package/eject/files/switch.ts +45 -0
- package/eject/files/table.css +107 -0
- package/eject/files/table.ts +84 -0
- package/eject/files/tabs.css +120 -0
- package/eject/files/tabs.ts +37 -0
- package/eject/files/text-field.css +225 -0
- package/eject/files/text-field.ts +64 -0
- package/eject/files/text.ts +38 -0
- package/eject/files/thumbnail.ts +51 -0
- package/eject/files/time-picker.ts +113 -0
- package/eject/files/toast-queue.ts +64 -0
- package/eject/files/toast.ts +31 -0
- package/eject/files/tooltip.css +111 -0
- package/eject/files/tooltip.ts +21 -0
- package/eject/manifest.json +1027 -0
- package/package.json +12 -4
- package/styles.css +1066 -167
- package/tailwind.css +1295 -218
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
import { type RootProps, rootAttributes, withStyle } from "@xds/solid/base";
|
|
5
|
+
import type { JSX } from "@solidjs/web";
|
|
6
|
+
import * as accordion from "@zag-js/accordion";
|
|
7
|
+
import { mergeProps, normalizeProps, useMachine } from "@zag-js/solid";
|
|
8
|
+
import { createEffect, createMemo, createUniqueId, type Element, For, Show } from "solid-js";
|
|
9
|
+
import {
|
|
10
|
+
ACCORDION_PARTS,
|
|
11
|
+
type AccordionBaseProps,
|
|
12
|
+
type AccordionItemBase,
|
|
13
|
+
focusTitleOnClick,
|
|
14
|
+
setPanelOpen,
|
|
15
|
+
} from "./accordion.ts";
|
|
16
|
+
import { Icon } from "./Icon.tsx";
|
|
17
|
+
import { classes } from "./parts.ts";
|
|
18
|
+
|
|
19
|
+
export type AccordionItem<Value extends string = string> = AccordionItemBase<Value> & {
|
|
20
|
+
/** The body, shown under the title while the item is open. */
|
|
21
|
+
content: Element;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type AccordionProps<Value extends string = string> = AccordionBaseProps<Value> &
|
|
25
|
+
RootProps & {
|
|
26
|
+
items: readonly AccordionItem<Value>[];
|
|
27
|
+
onChange: (expanded: Value[]) => void;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Items whose bodies open and close under their titles, separated by hairlines. The chevron
|
|
32
|
+
* turns over when an item is open, so the state does not depend on color. Opening and closing
|
|
33
|
+
* animate the height, and do not for people who ask for less motion.
|
|
34
|
+
*
|
|
35
|
+
* Each title is a heading holding a button that says whether its body is expanded and which
|
|
36
|
+
* body it controls. A closed body is hidden, but the browser's find in page still opens it.
|
|
37
|
+
*/
|
|
38
|
+
export function Accordion<Value extends string = string>(props: AccordionProps<Value>) {
|
|
39
|
+
const id = createUniqueId();
|
|
40
|
+
const service = useMachine(accordion.machine, () => ({
|
|
41
|
+
id,
|
|
42
|
+
// The app's id goes on the root, where Zag looks for it by this one.
|
|
43
|
+
ids: { root: props.id },
|
|
44
|
+
value: [...props.expanded],
|
|
45
|
+
onValueChange: (details: accordion.ValueChangeDetails) =>
|
|
46
|
+
props.onChange(details.value as Value[]),
|
|
47
|
+
multiple: props.multiple ?? false,
|
|
48
|
+
collapsible: true,
|
|
49
|
+
hiddenUntilFound: true,
|
|
50
|
+
}));
|
|
51
|
+
const api = createMemo(() => accordion.connect(service, normalizeProps));
|
|
52
|
+
const root = withStyle(
|
|
53
|
+
() => api().getRootProps(),
|
|
54
|
+
() => props.style,
|
|
55
|
+
rootAttributes(props),
|
|
56
|
+
);
|
|
57
|
+
const body = (value: Value) => {
|
|
58
|
+
// The panel hides itself once it has finished closing; see Panel.
|
|
59
|
+
const { hidden: _hidden, ...attributes } = api().getItemContentProps({ value });
|
|
60
|
+
return attributes as JSX.HTMLAttributes<HTMLDivElement>;
|
|
61
|
+
};
|
|
62
|
+
return (
|
|
63
|
+
<div {...root} class={classes("{{prefix}}-accordion", props.class)}>
|
|
64
|
+
<For each={props.items}>
|
|
65
|
+
{(item) => (
|
|
66
|
+
<div {...api().getItemProps({ value: item.value })} class="{{prefix}}-accordion__item">
|
|
67
|
+
<h3
|
|
68
|
+
{...api().getItemHeaderProps({ value: item.value })}
|
|
69
|
+
class="{{prefix}}-accordion__heading"
|
|
70
|
+
>
|
|
71
|
+
<button
|
|
72
|
+
{...mergeProps(() => api().getItemTriggerProps({ value: item.value }), {
|
|
73
|
+
// Runs before Zag's handler.
|
|
74
|
+
onClick: focusTitleOnClick,
|
|
75
|
+
})}
|
|
76
|
+
class="{{prefix}}-accordion__trigger group"
|
|
77
|
+
>
|
|
78
|
+
<span class={ACCORDION_PARTS.text}>
|
|
79
|
+
<span class={ACCORDION_PARTS.title}>{item.title}</span>
|
|
80
|
+
<Show when={item.description}>
|
|
81
|
+
{(description) => (
|
|
82
|
+
<span class={ACCORDION_PARTS.description}>{description()}</span>
|
|
83
|
+
)}
|
|
84
|
+
</Show>
|
|
85
|
+
</span>
|
|
86
|
+
<Icon name="chevron-down" size="sm" class={ACCORDION_PARTS.chevron} />
|
|
87
|
+
</button>
|
|
88
|
+
</h3>
|
|
89
|
+
<Panel open={api().value.includes(item.value)} attributes={body(item.value)}>
|
|
90
|
+
{item.content}
|
|
91
|
+
</Panel>
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
</For>
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* An item's body. Its height moves between zero and the height of what it holds, and it is
|
|
101
|
+
* hidden only once it has finished closing.
|
|
102
|
+
*/
|
|
103
|
+
function Panel(props: {
|
|
104
|
+
open: boolean;
|
|
105
|
+
attributes: JSX.HTMLAttributes<HTMLDivElement>;
|
|
106
|
+
children: Element;
|
|
107
|
+
}) {
|
|
108
|
+
let panel!: HTMLDivElement;
|
|
109
|
+
let rendered = false;
|
|
110
|
+
// A page rendered on the server shows the panel before the effect below can run, so a closed
|
|
111
|
+
// one starts hidden. Read once so the effect owns `hidden` from then on.
|
|
112
|
+
const closedAtFirst = !props.open;
|
|
113
|
+
createEffect(
|
|
114
|
+
() => props.open,
|
|
115
|
+
(open) => {
|
|
116
|
+
const stop = setPanelOpen(panel, open, rendered);
|
|
117
|
+
rendered = true;
|
|
118
|
+
// The next toggle takes over from this one.
|
|
119
|
+
return stop;
|
|
120
|
+
},
|
|
121
|
+
);
|
|
122
|
+
// A group: a region is a landmark, and a page of accordions would fill the list of
|
|
123
|
+
// landmarks. A closed one is left out of the accessibility tree as soon as it starts closing;
|
|
124
|
+
// `hidden="until-found"` alone leaves the empty group in it.
|
|
125
|
+
return (
|
|
126
|
+
// A group, not a fieldset: it is the body of a disclosure, not a set of form fields.
|
|
127
|
+
<div
|
|
128
|
+
{...props.attributes}
|
|
129
|
+
ref={(element) => (panel = element)}
|
|
130
|
+
hidden={closedAtFirst || undefined}
|
|
131
|
+
role="group"
|
|
132
|
+
aria-hidden={props.open ? undefined : "true"}
|
|
133
|
+
class="{{prefix}}-accordion__panel"
|
|
134
|
+
>
|
|
135
|
+
<div class="{{prefix}}-accordion__body">{props.children}</div>
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
import { createPicture, type RootProps, rootAttributes, useDefaults } from "@xds/solid/base";
|
|
5
|
+
import { Show } from "solid-js";
|
|
6
|
+
import { type AvatarBaseProps, avatarClass, avatarInitials, pictureClass } from "./avatar.ts";
|
|
7
|
+
import { classes, rootPart } from "./parts.ts";
|
|
8
|
+
|
|
9
|
+
export type { AvatarSize } from "./avatar.ts";
|
|
10
|
+
|
|
11
|
+
export type AvatarProps = AvatarBaseProps & RootProps;
|
|
12
|
+
|
|
13
|
+
const ROOT = rootPart("Avatar");
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Stands for a person or a team by a picture, or by their initials when there is none.
|
|
17
|
+
* Assistive technology gets the full name either way. The small size has room for one letter.
|
|
18
|
+
*/
|
|
19
|
+
export function Avatar(props: AvatarProps) {
|
|
20
|
+
const defaults = useDefaults("Avatar");
|
|
21
|
+
const size = () => props.size ?? defaults().size;
|
|
22
|
+
const picture = createPicture(() => props.src);
|
|
23
|
+
return (
|
|
24
|
+
<span
|
|
25
|
+
{...rootAttributes(props)}
|
|
26
|
+
role="img"
|
|
27
|
+
aria-label={props.name}
|
|
28
|
+
class={classes(ROOT, avatarClass(size()), props.class)}
|
|
29
|
+
style={props.style}
|
|
30
|
+
>
|
|
31
|
+
{avatarInitials(props.name, size())}
|
|
32
|
+
<Show when={picture.loaded() !== false && props.src}>
|
|
33
|
+
{(src) => (
|
|
34
|
+
<img
|
|
35
|
+
ref={(element) => picture.sync(element, src())}
|
|
36
|
+
src={src()}
|
|
37
|
+
// The name is on the avatar itself; a second one on the picture would be read twice.
|
|
38
|
+
alt=""
|
|
39
|
+
aria-hidden="true"
|
|
40
|
+
class={pictureClass(picture.loaded() === true)}
|
|
41
|
+
onLoad={() => picture.onLoad(src())}
|
|
42
|
+
onError={() => picture.onError(src())}
|
|
43
|
+
/>
|
|
44
|
+
)}
|
|
45
|
+
</Show>
|
|
46
|
+
</span>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
import { type RootProps, rootAttributes, useDefaults } from "@xds/solid/base";
|
|
5
|
+
import { createMemo, For, Show } from "solid-js";
|
|
6
|
+
import {
|
|
7
|
+
type AvatarStackBaseProps,
|
|
8
|
+
avatarStack,
|
|
9
|
+
avatarStackClass,
|
|
10
|
+
avatarStackItemClass,
|
|
11
|
+
avatarStackRestClass,
|
|
12
|
+
} from "./avatar-stack.ts";
|
|
13
|
+
import { Avatar } from "./Avatar.tsx";
|
|
14
|
+
import { classes, rootPart } from "./parts.ts";
|
|
15
|
+
|
|
16
|
+
export type AvatarStackProps = AvatarStackBaseProps & RootProps;
|
|
17
|
+
|
|
18
|
+
const ROOT = rootPart("AvatarStack");
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Several people in the room of one. Assistive technology gets one image named after
|
|
22
|
+
* everyone in it, including those who did not fit.
|
|
23
|
+
*/
|
|
24
|
+
export function AvatarStack(props: AvatarStackProps) {
|
|
25
|
+
const defaults = useDefaults("AvatarStack");
|
|
26
|
+
// Handed to every avatar, so that an Avatar default cannot make them a size the stack is not.
|
|
27
|
+
const size = () => props.size ?? defaults().size ?? "md";
|
|
28
|
+
const stack = createMemo(() => avatarStack(props.people, props.max, props.label));
|
|
29
|
+
return (
|
|
30
|
+
<span
|
|
31
|
+
{...rootAttributes(props)}
|
|
32
|
+
role="img"
|
|
33
|
+
aria-label={stack().name}
|
|
34
|
+
class={classes(ROOT, avatarStackClass, props.class)}
|
|
35
|
+
style={props.style}
|
|
36
|
+
>
|
|
37
|
+
<For each={stack().shown}>
|
|
38
|
+
{(person) => (
|
|
39
|
+
<span aria-hidden="true" class={avatarStackItemClass(size())}>
|
|
40
|
+
<Avatar name={person.name} src={person.src} size={size()} />
|
|
41
|
+
</span>
|
|
42
|
+
)}
|
|
43
|
+
</For>
|
|
44
|
+
<Show when={stack().rest > 0}>
|
|
45
|
+
<span aria-hidden="true" class={avatarStackRestClass(size())}>
|
|
46
|
+
+{stack().rest}
|
|
47
|
+
</span>
|
|
48
|
+
</Show>
|
|
49
|
+
</span>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
import { type RootProps, rootAttributes, useDefaults } from "@xds/solid/base";
|
|
5
|
+
import { type Element, Show } from "solid-js";
|
|
6
|
+
import { type BadgeBaseProps, badgeClass, badgeDotClass } from "./badge.ts";
|
|
7
|
+
import { Icon } from "./Icon.tsx";
|
|
8
|
+
import { classes, rootPart } from "./parts.ts";
|
|
9
|
+
|
|
10
|
+
export type { BadgeTone } from "./badge.ts";
|
|
11
|
+
|
|
12
|
+
export type BadgeProps = BadgeBaseProps &
|
|
13
|
+
RootProps & {
|
|
14
|
+
children: Element;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const ROOT = rootPart("Badge");
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A short status or category. The words carry the meaning; the color only reinforces it, so a
|
|
21
|
+
* badge still reads for someone who cannot tell the tones apart. `dot` adds a small mark for
|
|
22
|
+
* live states such as "connected", and `icon` a drawing in front of the words.
|
|
23
|
+
*/
|
|
24
|
+
export function Badge(props: BadgeProps) {
|
|
25
|
+
const defaults = useDefaults("Badge");
|
|
26
|
+
return (
|
|
27
|
+
<span
|
|
28
|
+
{...rootAttributes(props)}
|
|
29
|
+
class={classes(ROOT, badgeClass(props.tone ?? defaults().tone), props.class)}
|
|
30
|
+
style={props.style}
|
|
31
|
+
>
|
|
32
|
+
<Show when={props.dot}>
|
|
33
|
+
<span aria-hidden="true" class={badgeDotClass} />
|
|
34
|
+
</Show>
|
|
35
|
+
<Show when={props.icon}>{(name) => <Icon name={name()} size="xs" />}</Show>
|
|
36
|
+
{props.children}
|
|
37
|
+
</span>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
import { type RootProps, rootAttributes, useDefaults, useLabels } from "@xds/solid/base";
|
|
5
|
+
import { type Element, Show } from "solid-js";
|
|
6
|
+
import {
|
|
7
|
+
BANNER_PARTS,
|
|
8
|
+
type BannerBaseProps,
|
|
9
|
+
bannerClass,
|
|
10
|
+
bannerIconClass,
|
|
11
|
+
bannerIconPath,
|
|
12
|
+
bannerRole,
|
|
13
|
+
} from "./banner.ts";
|
|
14
|
+
import { Button } from "./Button.tsx";
|
|
15
|
+
import { IconButton } from "./IconButton.tsx";
|
|
16
|
+
import { classes, rootPart } from "./parts.ts";
|
|
17
|
+
|
|
18
|
+
export type { BannerTone } from "./banner.ts";
|
|
19
|
+
|
|
20
|
+
export type BannerProps = BannerBaseProps &
|
|
21
|
+
RootProps & {
|
|
22
|
+
/** What the person can do about the message. Drawn under it as a small secondary button. */
|
|
23
|
+
action?: { label: string; onPress: () => void };
|
|
24
|
+
/**
|
|
25
|
+
* Shows a close control. The banner does not hide itself: the handler decides what happens
|
|
26
|
+
* to it.
|
|
27
|
+
*/
|
|
28
|
+
onDismiss?: () => void;
|
|
29
|
+
children: Element;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const ROOT = rootPart("Banner");
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A message about the whole view or a section of it. Each tone has its own icon shape, so the
|
|
36
|
+
* tone does not depend on color. Problems (`warning`, `danger`) interrupt a screen reader;
|
|
37
|
+
* `info` and `success` wait their turn.
|
|
38
|
+
*/
|
|
39
|
+
export function Banner(props: BannerProps) {
|
|
40
|
+
const defaults = useDefaults("Banner");
|
|
41
|
+
const labels = useLabels();
|
|
42
|
+
const tone = () => props.tone ?? defaults().tone;
|
|
43
|
+
return (
|
|
44
|
+
<div
|
|
45
|
+
{...rootAttributes(props)}
|
|
46
|
+
role={bannerRole(tone())}
|
|
47
|
+
class={classes(ROOT, bannerClass(tone()), props.class)}
|
|
48
|
+
style={props.style}
|
|
49
|
+
>
|
|
50
|
+
<svg viewBox="0 0 24 24" aria-hidden="true" class={bannerIconClass(tone())}>
|
|
51
|
+
<path fill="currentColor" d={bannerIconPath(tone())} />
|
|
52
|
+
</svg>
|
|
53
|
+
<div class={BANNER_PARTS.body}>
|
|
54
|
+
<Show when={props.title}>{(title) => <p class={BANNER_PARTS.title}>{title()}</p>}</Show>
|
|
55
|
+
<div>{props.children}</div>
|
|
56
|
+
<Show when={props.action}>
|
|
57
|
+
{(action) => (
|
|
58
|
+
<div class={BANNER_PARTS.action}>
|
|
59
|
+
{/* Its variant is the banner's, not one the app gives its own buttons. */}
|
|
60
|
+
<Button variant="secondary" size="sm" onPress={() => action().onPress()}>
|
|
61
|
+
{action().label}
|
|
62
|
+
</Button>
|
|
63
|
+
</div>
|
|
64
|
+
)}
|
|
65
|
+
</Show>
|
|
66
|
+
</div>
|
|
67
|
+
<Show when={props.onDismiss}>
|
|
68
|
+
<div class={BANNER_PARTS.dismiss}>
|
|
69
|
+
<IconButton
|
|
70
|
+
icon="x"
|
|
71
|
+
label={props.dismissLabel ?? labels().dismiss}
|
|
72
|
+
variant="ghost"
|
|
73
|
+
size="sm"
|
|
74
|
+
onPress={() => props.onDismiss?.()}
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
</Show>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
import { type RootProps, rootAttributes, useLabels } from "@xds/solid/base";
|
|
5
|
+
import { For, Show } from "solid-js";
|
|
6
|
+
import { BREADCRUMB_PARTS, BREADCRUMB_SEPARATOR, type BreadcrumbBaseProps } from "./breadcrumb.ts";
|
|
7
|
+
import { Icon } from "./Icon.tsx";
|
|
8
|
+
import { Link } from "./Link.tsx";
|
|
9
|
+
import { classes, rootPart } from "./parts.ts";
|
|
10
|
+
|
|
11
|
+
export type { BreadcrumbItem } from "./breadcrumb.ts";
|
|
12
|
+
|
|
13
|
+
export type BreadcrumbProps = BreadcrumbBaseProps & RootProps;
|
|
14
|
+
|
|
15
|
+
const ROOT = rootPart("Breadcrumb");
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Where the current view sits in the app: the places above it, each a link, then the view
|
|
19
|
+
* itself. A navigation landmark; the current place is marked as the page.
|
|
20
|
+
*/
|
|
21
|
+
export function Breadcrumb(props: BreadcrumbProps) {
|
|
22
|
+
const labels = useLabels();
|
|
23
|
+
return (
|
|
24
|
+
<nav
|
|
25
|
+
{...rootAttributes(props)}
|
|
26
|
+
aria-label={props.label ?? labels().breadcrumb}
|
|
27
|
+
class={classes(ROOT, props.class)}
|
|
28
|
+
style={props.style}
|
|
29
|
+
>
|
|
30
|
+
<ol class={BREADCRUMB_PARTS.list}>
|
|
31
|
+
<For each={props.items}>
|
|
32
|
+
{(item, index) => (
|
|
33
|
+
<li class={BREADCRUMB_PARTS.item}>
|
|
34
|
+
<Show
|
|
35
|
+
when={index() < props.items.length - 1}
|
|
36
|
+
fallback={
|
|
37
|
+
<span aria-current="page" class={BREADCRUMB_PARTS.current}>
|
|
38
|
+
{item.label}
|
|
39
|
+
</span>
|
|
40
|
+
}
|
|
41
|
+
>
|
|
42
|
+
<Link href={item.href} onPress={() => item.onPress?.()}>
|
|
43
|
+
{item.label}
|
|
44
|
+
</Link>
|
|
45
|
+
<Icon
|
|
46
|
+
name={BREADCRUMB_SEPARATOR.name}
|
|
47
|
+
size={BREADCRUMB_SEPARATOR.size}
|
|
48
|
+
class={BREADCRUMB_PARTS.separator}
|
|
49
|
+
/>
|
|
50
|
+
</Show>
|
|
51
|
+
</li>
|
|
52
|
+
)}
|
|
53
|
+
</For>
|
|
54
|
+
</ol>
|
|
55
|
+
</nav>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
import { type RootProps, rootAttributes, useDefaults, withTrigger } from "@xds/solid/base";
|
|
5
|
+
import type { JSX } from "@solidjs/web";
|
|
6
|
+
import { children, createMemo, type Element, Show } from "solid-js";
|
|
7
|
+
import { BUTTON_ICON, type ButtonBaseProps, buttonClass, isHeld } from "./button.ts";
|
|
8
|
+
import { Icon } from "./Icon.tsx";
|
|
9
|
+
import { classes } from "./parts.ts";
|
|
10
|
+
import { Spinner } from "./Spinner.tsx";
|
|
11
|
+
|
|
12
|
+
export type { ButtonVariant, ControlSize } from "./button.ts";
|
|
13
|
+
|
|
14
|
+
export type ButtonProps = ButtonBaseProps &
|
|
15
|
+
RootProps & {
|
|
16
|
+
onPress?: () => void;
|
|
17
|
+
onFocus?: JSX.FocusEventHandler<HTMLButtonElement, FocusEvent>;
|
|
18
|
+
onBlur?: JSX.FocusEventHandler<HTMLButtonElement, FocusEvent>;
|
|
19
|
+
/** The native button. */
|
|
20
|
+
ref?: JSX.Ref<HTMLButtonElement>;
|
|
21
|
+
/** Leave it out for a button that holds only an icon, and name that one with `aria-label`. */
|
|
22
|
+
children?: Element;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A native button. It also opens a Menu or a Tooltip it is the trigger of: their props reach
|
|
27
|
+
* it through context.
|
|
28
|
+
*/
|
|
29
|
+
export function Button(props: ButtonProps) {
|
|
30
|
+
// Read once: each read of a JSX prop creates its nodes again.
|
|
31
|
+
const label = children(() => props.children);
|
|
32
|
+
const defaults = useDefaults("Button");
|
|
33
|
+
const variant = () => props.variant ?? defaults().variant ?? "secondary";
|
|
34
|
+
const size = () => props.size ?? defaults().size ?? "md";
|
|
35
|
+
const icon = () => BUTTON_ICON[size()];
|
|
36
|
+
const held = () =>
|
|
37
|
+
isHeld({ variant: variant(), selected: props.selected, disabled: props.disabled });
|
|
38
|
+
const attributes = withTrigger(
|
|
39
|
+
createMemo((): JSX.ButtonHTMLAttributes<HTMLButtonElement> => ({
|
|
40
|
+
type: props.type ?? "button",
|
|
41
|
+
// Its root part, `{{prefix}}-button`, is in the recipe.
|
|
42
|
+
class: classes(
|
|
43
|
+
buttonClass({
|
|
44
|
+
variant: variant(),
|
|
45
|
+
size: size(),
|
|
46
|
+
iconOnly:
|
|
47
|
+
label() == null && (props.iconStart !== undefined || props.iconEnd !== undefined),
|
|
48
|
+
fullWidth: props.fullWidth ?? false,
|
|
49
|
+
}),
|
|
50
|
+
props.class,
|
|
51
|
+
),
|
|
52
|
+
style: props.style,
|
|
53
|
+
disabled: props.disabled,
|
|
54
|
+
// Loading keeps the button focusable, so focus is not lost while it waits.
|
|
55
|
+
"aria-disabled": props.loading ? "true" : undefined,
|
|
56
|
+
"data-pending": props.loading ? "" : undefined,
|
|
57
|
+
"aria-pressed": props.selected === undefined ? undefined : props.selected ? "true" : "false",
|
|
58
|
+
"aria-label": props["aria-label"],
|
|
59
|
+
onClick: (event) => {
|
|
60
|
+
// The press was taken already: block keyboard Enter/Space form submit or reset too.
|
|
61
|
+
if (props.loading) {
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
props.onPress?.();
|
|
66
|
+
},
|
|
67
|
+
onFocus: (event) => props.onFocus?.(event),
|
|
68
|
+
onBlur: (event) => props.onBlur?.(event),
|
|
69
|
+
})),
|
|
70
|
+
() => props.loading === true,
|
|
71
|
+
rootAttributes(props),
|
|
72
|
+
);
|
|
73
|
+
return (
|
|
74
|
+
<button ref={props.ref} {...attributes}>
|
|
75
|
+
<Show when={props.loading}>
|
|
76
|
+
<Show when={props.iconStart} fallback={<Spinner size="sm" />}>
|
|
77
|
+
{/* Where the icon was, so the button keeps its width. */}
|
|
78
|
+
<span class={icon().box}>
|
|
79
|
+
<Spinner size="sm" />
|
|
80
|
+
</span>
|
|
81
|
+
</Show>
|
|
82
|
+
</Show>
|
|
83
|
+
<Show when={!props.loading && props.iconStart}>
|
|
84
|
+
{(name) => <Icon name={name()} size={icon().size} filled={held()} />}
|
|
85
|
+
</Show>
|
|
86
|
+
{label()}
|
|
87
|
+
<Show when={props.iconEnd}>{(name) => <Icon name={name()} size={icon().size} />}</Show>
|
|
88
|
+
</button>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
import { type RootProps, rootAttributes } from "@xds/solid/base";
|
|
5
|
+
import { dynamic } from "@solidjs/web";
|
|
6
|
+
import { children, type Element, Show } from "solid-js";
|
|
7
|
+
import { CARD_PARTS, type CardBaseProps, cardClass, cardMediaClass } from "./card.ts";
|
|
8
|
+
import { classes, rootPart } from "./parts.ts";
|
|
9
|
+
|
|
10
|
+
export type CardProps = CardBaseProps &
|
|
11
|
+
RootProps & {
|
|
12
|
+
/** Sit across from the title. A pressable card takes none: it is one button already. */
|
|
13
|
+
actions?: Element;
|
|
14
|
+
/** A picture or a drawing at the top, running edge to edge above the padding. */
|
|
15
|
+
media?: Element;
|
|
16
|
+
/** Makes the whole card one button. Put no other control inside it then. */
|
|
17
|
+
onPress?: () => void;
|
|
18
|
+
children?: Element;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const ROOT = rootPart("Card");
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A surface that groups related content. A hairline outline and a trace of shadow lift it off
|
|
25
|
+
* the page; in dark mode, where shadows barely show, the lighter fill does that. `title`
|
|
26
|
+
* renders as a heading; `actions` sit across from it.
|
|
27
|
+
*/
|
|
28
|
+
export function Card(props: CardProps) {
|
|
29
|
+
// Read once: each read of a JSX prop creates its nodes again.
|
|
30
|
+
const media = children(() => props.media);
|
|
31
|
+
const actions = children(() => props.actions);
|
|
32
|
+
const body = children(() => props.children);
|
|
33
|
+
const pressable = () => props.onPress !== undefined;
|
|
34
|
+
// A button may hold only phrasing content, so inside one the parts are spans. Its heading
|
|
35
|
+
// would not be reachable as a heading anyway: a button reads as its text.
|
|
36
|
+
const Header = dynamic(() => (pressable() ? "span" : "header"));
|
|
37
|
+
const Box = dynamic(() => (pressable() ? "span" : "div"));
|
|
38
|
+
const Title = dynamic(() => (pressable() ? "span" : "h2"));
|
|
39
|
+
const Line = dynamic(() => (pressable() ? "span" : "p"));
|
|
40
|
+
const surface = () =>
|
|
41
|
+
classes(
|
|
42
|
+
ROOT,
|
|
43
|
+
cardClass({ selected: props.selected, flush: props.flush, pressable: pressable() }),
|
|
44
|
+
props.class,
|
|
45
|
+
);
|
|
46
|
+
const parts = () => (
|
|
47
|
+
<>
|
|
48
|
+
<Show when={media() != null}>
|
|
49
|
+
<Box class={cardMediaClass(props.flush)}>{media()}</Box>
|
|
50
|
+
</Show>
|
|
51
|
+
<Show when={props.title || props.description || (actions() != null && !pressable())}>
|
|
52
|
+
<Header class={CARD_PARTS.header}>
|
|
53
|
+
<Box class={CARD_PARTS.heading}>
|
|
54
|
+
<Show when={props.title}>
|
|
55
|
+
{(title) => <Title class={CARD_PARTS.title}>{title()}</Title>}
|
|
56
|
+
</Show>
|
|
57
|
+
<Show when={props.description}>
|
|
58
|
+
{(description) => <Line class={CARD_PARTS.description}>{description()}</Line>}
|
|
59
|
+
</Show>
|
|
60
|
+
</Box>
|
|
61
|
+
<Show when={actions() != null && !pressable()}>
|
|
62
|
+
<div class={CARD_PARTS.actions}>{actions()}</div>
|
|
63
|
+
</Show>
|
|
64
|
+
</Header>
|
|
65
|
+
</Show>
|
|
66
|
+
{body()}
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
const content = () => (
|
|
70
|
+
<Show when={props.flush} fallback={parts()}>
|
|
71
|
+
<Box class={CARD_PARTS.flush}>{parts()}</Box>
|
|
72
|
+
</Show>
|
|
73
|
+
);
|
|
74
|
+
return (
|
|
75
|
+
<Show
|
|
76
|
+
when={pressable()}
|
|
77
|
+
fallback={
|
|
78
|
+
<section
|
|
79
|
+
{...rootAttributes(props)}
|
|
80
|
+
aria-current={props.selected ? "true" : undefined}
|
|
81
|
+
class={surface()}
|
|
82
|
+
style={props.style}
|
|
83
|
+
>
|
|
84
|
+
{content()}
|
|
85
|
+
</section>
|
|
86
|
+
}
|
|
87
|
+
>
|
|
88
|
+
<button
|
|
89
|
+
{...rootAttributes(props)}
|
|
90
|
+
type="button"
|
|
91
|
+
onClick={() => props.onPress?.()}
|
|
92
|
+
aria-pressed={props.selected === undefined ? undefined : props.selected ? "true" : "false"}
|
|
93
|
+
class={surface()}
|
|
94
|
+
style={props.style}
|
|
95
|
+
>
|
|
96
|
+
{content()}
|
|
97
|
+
</button>
|
|
98
|
+
</Show>
|
|
99
|
+
);
|
|
100
|
+
}
|