@xds/react 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/Accordion.d.ts +20 -0
- package/dist/Accordion.js +197 -0
- package/dist/Avatar.d.ts +9 -0
- package/dist/Avatar.js +69 -0
- package/dist/AvatarStack.d.ts +8 -0
- package/dist/AvatarStack.js +105 -0
- package/dist/Badge.d.ts +13 -0
- package/dist/Badge.js +66 -0
- package/dist/Banner.d.ts +23 -0
- package/dist/Banner.js +166 -0
- package/dist/Button.d.ts +14 -0
- package/dist/Button.js +159 -0
- package/dist/Card.d.ts +18 -0
- package/dist/Card.js +173 -0
- package/dist/Checkbox.d.ts +10 -0
- package/dist/Checkbox.js +140 -0
- package/dist/Chip.d.ts +12 -0
- package/dist/Chip.js +74 -0
- package/dist/ChipBar.d.ts +12 -0
- package/dist/ChipBar.js +38 -0
- package/dist/CountBadge.d.ts +12 -0
- package/dist/CountBadge.js +64 -0
- package/dist/DatePicker.d.ts +20 -0
- package/dist/DatePicker.js +429 -0
- package/dist/DateRangePicker.d.ts +24 -0
- package/dist/DateRangePicker.js +370 -0
- package/dist/Defaults.d.ts +17 -0
- package/dist/Defaults.js +48 -0
- package/dist/Dialog.d.ts +20 -0
- package/dist/Dialog.js +137 -0
- package/dist/Divider.d.ts +4 -0
- package/dist/Divider.js +31 -0
- package/dist/EmptyState.d.ts +12 -0
- package/dist/EmptyState.js +86 -0
- package/dist/Icon.d.ts +9 -0
- package/dist/Icon.js +79 -0
- package/dist/IconButton.d.ts +12 -0
- package/dist/IconButton.js +119 -0
- package/dist/ListRow.d.ts +21 -0
- package/dist/ListRow.js +185 -0
- package/dist/MediaCard.d.ts +20 -0
- package/dist/MediaCard.js +279 -0
- package/dist/Menu.d.ts +18 -0
- package/dist/Menu.js +244 -0
- package/dist/ProgressBar.d.ts +8 -0
- package/dist/ProgressBar.js +65 -0
- package/dist/RadioGroup.d.ts +15 -0
- package/dist/RadioGroup.js +176 -0
- package/dist/SearchField.d.ts +15 -0
- package/dist/SearchField.js +152 -0
- package/dist/SectionHeader.d.ts +14 -0
- package/dist/SectionHeader.js +124 -0
- package/dist/SegmentedControl.d.ts +12 -0
- package/dist/SegmentedControl.js +106 -0
- package/dist/Select.d.ts +18 -0
- package/dist/Select.js +318 -0
- package/dist/Sidebar.d.ts +21 -0
- package/dist/Sidebar.js +220 -0
- package/dist/Skeleton.d.ts +11 -0
- package/dist/Skeleton.js +64 -0
- package/dist/Slider.d.ts +13 -0
- package/dist/Slider.js +151 -0
- package/dist/Spinner.d.ts +9 -0
- package/dist/Spinner.js +97 -0
- package/dist/Switch.d.ts +13 -0
- package/dist/Switch.js +116 -0
- package/dist/Tabs.d.ts +14 -0
- package/dist/Tabs.js +137 -0
- package/dist/Text.d.ts +10 -0
- package/dist/Text.js +46 -0
- package/dist/TextField.d.ts +22 -0
- package/dist/TextField.js +213 -0
- package/dist/Thumbnail.d.ts +9 -0
- package/dist/Thumbnail.js +152 -0
- package/dist/Toast.d.ts +14 -0
- package/dist/Toast.js +121 -0
- package/dist/Tooltip.d.ts +26 -0
- package/dist/Tooltip.js +166 -0
- package/dist/base.d.ts +11 -0
- package/dist/base.js +10 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +39 -0
- package/dist/modal-popover.d.ts +7 -0
- package/dist/modal-popover.js +37 -0
- package/dist/picture.d.ts +13 -0
- package/dist/picture.js +76 -0
- package/dist/portal.d.ts +9 -0
- package/dist/portal.js +27 -0
- package/dist/presence.d.ts +6 -0
- package/dist/presence.js +34 -0
- package/dist/preview.d.ts +17 -0
- package/dist/preview.js +126 -0
- package/dist/root.d.ts +12 -0
- package/dist/root.js +1 -0
- package/dist/trigger.d.ts +24 -0
- package/dist/trigger.js +47 -0
- package/eject/files/Accordion.tsx +157 -0
- package/eject/files/Avatar.tsx +41 -0
- package/eject/files/AvatarStack.tsx +47 -0
- package/eject/files/Badge.tsx +33 -0
- package/eject/files/Banner.tsx +70 -0
- package/eject/files/Button.tsx +88 -0
- package/eject/files/Card.tsx +85 -0
- package/eject/files/Checkbox.tsx +59 -0
- package/eject/files/Chip.tsx +43 -0
- package/eject/files/ChipBar.tsx +31 -0
- package/eject/files/CountBadge.tsx +50 -0
- package/eject/files/DatePicker.tsx +192 -0
- package/eject/files/DateRangePicker.tsx +271 -0
- package/eject/files/Dialog.tsx +108 -0
- package/eject/files/Divider.tsx +13 -0
- package/eject/files/EmptyState.tsx +39 -0
- package/eject/files/Icon.tsx +38 -0
- package/eject/files/IconButton.tsx +62 -0
- package/eject/files/ListRow.tsx +86 -0
- package/eject/files/MediaCard.tsx +111 -0
- package/eject/files/Menu.tsx +168 -0
- package/eject/files/ProgressBar.tsx +34 -0
- package/eject/files/RadioGroup.tsx +112 -0
- package/eject/files/SearchField.tsx +88 -0
- package/eject/files/SectionHeader.tsx +56 -0
- package/eject/files/SegmentedControl.tsx +57 -0
- package/eject/files/Select.tsx +228 -0
- package/eject/files/Sidebar.tsx +149 -0
- package/eject/files/Skeleton.tsx +28 -0
- package/eject/files/Slider.tsx +109 -0
- package/eject/files/Spinner.tsx +36 -0
- package/eject/files/Switch.tsx +53 -0
- package/eject/files/Tabs.tsx +71 -0
- package/eject/files/Text.tsx +31 -0
- package/eject/files/TextField.tsx +122 -0
- package/eject/files/Thumbnail.tsx +66 -0
- package/eject/files/Toast.tsx +88 -0
- package/eject/files/Tooltip.tsx +120 -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 +68 -0
- package/eject/files/base.css +38 -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 +32 -0
- package/eject/files/chip-bar.ts +16 -0
- package/eject/files/chip.ts +35 -0
- package/eject/files/count-badge.ts +32 -0
- package/eject/files/date-picker.css +352 -0
- package/eject/files/date-picker.ts +250 -0
- package/eject/files/date-range-picker.ts +323 -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/list-row.ts +66 -0
- package/eject/files/media-card.ts +66 -0
- package/eject/files/menu.css +176 -0
- package/eject/files/menu.ts +84 -0
- package/eject/files/parts.ts +17 -0
- package/eject/files/progress-bar.ts +23 -0
- package/eject/files/radio-group.css +160 -0
- package/eject/files/radio-group.ts +24 -0
- package/eject/files/section-header.ts +32 -0
- package/eject/files/segmented-control.ts +30 -0
- package/eject/files/select.css +285 -0
- package/eject/files/select.ts +36 -0
- package/eject/files/sidebar.ts +75 -0
- package/eject/files/skeleton.ts +51 -0
- package/eject/files/slider.css +136 -0
- package/eject/files/slider.ts +65 -0
- package/eject/files/spinner.ts +22 -0
- package/eject/files/switch.ts +34 -0
- package/eject/files/tabs.css +112 -0
- package/eject/files/tabs.ts +35 -0
- package/eject/files/text-field.css +229 -0
- package/eject/files/text-field.ts +48 -0
- package/eject/files/text.ts +38 -0
- package/eject/files/thumbnail.ts +51 -0
- package/eject/files/toast.ts +31 -0
- package/eject/files/tooltip.css +104 -0
- package/eject/files/tooltip.ts +21 -0
- package/eject/manifest.json +814 -0
- package/package.json +66 -4
- package/page.css +20 -0
- package/styles.css +3252 -0
- package/tailwind.css +2665 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kjmin-dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @xds/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The components of the xds design system for React, with the look of an app made with `xds create`.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @xds/react
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Import the stylesheet once, then use the components:
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import "@xds/react/styles.css";
|
|
13
|
+
import { Button } from "@xds/react";
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`<Button>` and every other component take the app's class and style on their root element, which also carries a stable class such as `xds-button`. The `Defaults` component sets what the components inside it take when the app passes no variant, size or tone.
|
|
17
|
+
|
|
18
|
+
The stylesheet keeps to the `xds` cascade layer and to the library's own elements, so the app's styles win. `@xds/react/page.css` gives the page the library's background, text color and font. An app with Tailwind CSS 4.1 or later can import `@xds/react/tailwind.css` before Tailwind instead of `styles.css`.
|
|
19
|
+
|
|
20
|
+
This channel is a preview while its behavior library, Zag.js 2, is a prerelease. See [xds as a library](https://github.com/kjmin-dev/xds/blob/main/docs/library.md) for modes, themes and the rest of the customization.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type AccordionBaseProps, type AccordionItemBase } from "@xds/core";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
import type { RootProps } from "./root.ts";
|
|
4
|
+
export type AccordionItem<Value extends string = string> = AccordionItemBase<Value> & {
|
|
5
|
+
/** The body, shown under the title while the item is open. */
|
|
6
|
+
content: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export type AccordionProps<Value extends string = string> = AccordionBaseProps<Value> & RootProps & {
|
|
9
|
+
items: readonly AccordionItem<Value>[];
|
|
10
|
+
onChange: (expanded: Value[]) => void;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Items whose bodies open and close under their titles, separated by hairlines. The chevron
|
|
14
|
+
* turns over when an item is open, so the state does not depend on color. Opening and closing
|
|
15
|
+
* animate the height, and do not for people who ask for less motion.
|
|
16
|
+
*
|
|
17
|
+
* Each title is a heading holding a button that says whether its body is expanded and which
|
|
18
|
+
* body it controls. A closed body is hidden, but the browser's find in page still opens it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function Accordion<Value extends string = string>({ items, expanded, onChange, multiple, className, style, }: AccordionProps<Value>): import("react").JSX.Element;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { ACCORDION_PARTS, classes, focusTitleOnClick, setPanelOpen } from "@xds/core";
|
|
3
|
+
import * as accordion from "@zag-js/accordion";
|
|
4
|
+
import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
|
|
5
|
+
import { useId, useLayoutEffect, useRef, useState } from "react";
|
|
6
|
+
import { Icon } from "./Icon.js";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
export function Accordion(t0) {
|
|
9
|
+
const $ = _c(18);
|
|
10
|
+
const {
|
|
11
|
+
items,
|
|
12
|
+
expanded,
|
|
13
|
+
onChange,
|
|
14
|
+
multiple: t1,
|
|
15
|
+
className,
|
|
16
|
+
style
|
|
17
|
+
} = t0;
|
|
18
|
+
const multiple = t1 === undefined ? false : t1;
|
|
19
|
+
const t2 = useId();
|
|
20
|
+
let t3;
|
|
21
|
+
if ($[0] !== expanded) {
|
|
22
|
+
t3 = [...expanded];
|
|
23
|
+
$[0] = expanded;
|
|
24
|
+
$[1] = t3;
|
|
25
|
+
} else {
|
|
26
|
+
t3 = $[1];
|
|
27
|
+
}
|
|
28
|
+
let t4;
|
|
29
|
+
if ($[2] !== onChange) {
|
|
30
|
+
t4 = details => onChange(details.value);
|
|
31
|
+
$[2] = onChange;
|
|
32
|
+
$[3] = t4;
|
|
33
|
+
} else {
|
|
34
|
+
t4 = $[3];
|
|
35
|
+
}
|
|
36
|
+
let t5;
|
|
37
|
+
if ($[4] !== multiple || $[5] !== t2 || $[6] !== t3 || $[7] !== t4) {
|
|
38
|
+
t5 = {
|
|
39
|
+
id: t2,
|
|
40
|
+
value: t3,
|
|
41
|
+
onValueChange: t4,
|
|
42
|
+
multiple,
|
|
43
|
+
collapsible: true,
|
|
44
|
+
hiddenUntilFound: true
|
|
45
|
+
};
|
|
46
|
+
$[4] = multiple;
|
|
47
|
+
$[5] = t2;
|
|
48
|
+
$[6] = t3;
|
|
49
|
+
$[7] = t4;
|
|
50
|
+
$[8] = t5;
|
|
51
|
+
} else {
|
|
52
|
+
t5 = $[8];
|
|
53
|
+
}
|
|
54
|
+
const service = useMachine(accordion.machine, t5);
|
|
55
|
+
let t6;
|
|
56
|
+
let t7;
|
|
57
|
+
if ($[9] !== className || $[10] !== items || $[11] !== service || $[12] !== style) {
|
|
58
|
+
const api = accordion.connect(service, normalizeProps);
|
|
59
|
+
t6 = mergeProps(api.getRootProps(), {
|
|
60
|
+
className: classes("xds-accordion", className),
|
|
61
|
+
style
|
|
62
|
+
});
|
|
63
|
+
t7 = items.map(item => {
|
|
64
|
+
const {
|
|
65
|
+
hidden: _hidden,
|
|
66
|
+
...body
|
|
67
|
+
} = api.getItemContentProps({
|
|
68
|
+
value: item.value
|
|
69
|
+
});
|
|
70
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
71
|
+
...api.getItemProps({
|
|
72
|
+
value: item.value
|
|
73
|
+
}),
|
|
74
|
+
className: "xds-accordion__item",
|
|
75
|
+
children: [/*#__PURE__*/_jsx("h3", {
|
|
76
|
+
...api.getItemHeaderProps({
|
|
77
|
+
value: item.value
|
|
78
|
+
}),
|
|
79
|
+
className: "xds-accordion__heading",
|
|
80
|
+
children: /*#__PURE__*/_jsxs("button", {
|
|
81
|
+
...mergeProps(api.getItemTriggerProps({
|
|
82
|
+
value: item.value
|
|
83
|
+
}), {
|
|
84
|
+
onClick: focusTitleOnClick
|
|
85
|
+
}),
|
|
86
|
+
type: "button",
|
|
87
|
+
className: "xds-accordion__trigger group",
|
|
88
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
89
|
+
className: ACCORDION_PARTS.text,
|
|
90
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
91
|
+
className: ACCORDION_PARTS.title,
|
|
92
|
+
children: item.title
|
|
93
|
+
}), item.description && /*#__PURE__*/_jsx("span", {
|
|
94
|
+
className: ACCORDION_PARTS.description,
|
|
95
|
+
children: item.description
|
|
96
|
+
})]
|
|
97
|
+
}), /*#__PURE__*/_jsx(Icon, {
|
|
98
|
+
name: "chevron-down",
|
|
99
|
+
size: "sm",
|
|
100
|
+
className: ACCORDION_PARTS.chevron
|
|
101
|
+
})]
|
|
102
|
+
})
|
|
103
|
+
}), /*#__PURE__*/_jsx(Panel, {
|
|
104
|
+
open: api.value.includes(item.value),
|
|
105
|
+
attributes: body,
|
|
106
|
+
children: item.content
|
|
107
|
+
})]
|
|
108
|
+
}, item.value);
|
|
109
|
+
});
|
|
110
|
+
$[9] = className;
|
|
111
|
+
$[10] = items;
|
|
112
|
+
$[11] = service;
|
|
113
|
+
$[12] = style;
|
|
114
|
+
$[13] = t6;
|
|
115
|
+
$[14] = t7;
|
|
116
|
+
} else {
|
|
117
|
+
t6 = $[13];
|
|
118
|
+
t7 = $[14];
|
|
119
|
+
}
|
|
120
|
+
let t8;
|
|
121
|
+
if ($[15] !== t6 || $[16] !== t7) {
|
|
122
|
+
t8 = /*#__PURE__*/_jsx("div", {
|
|
123
|
+
...t6,
|
|
124
|
+
children: t7
|
|
125
|
+
});
|
|
126
|
+
$[15] = t6;
|
|
127
|
+
$[16] = t7;
|
|
128
|
+
$[17] = t8;
|
|
129
|
+
} else {
|
|
130
|
+
t8 = $[17];
|
|
131
|
+
}
|
|
132
|
+
return t8;
|
|
133
|
+
}
|
|
134
|
+
function Panel(t0) {
|
|
135
|
+
const $ = _c(10);
|
|
136
|
+
const {
|
|
137
|
+
open,
|
|
138
|
+
attributes,
|
|
139
|
+
children
|
|
140
|
+
} = t0;
|
|
141
|
+
const panel = useRef(null);
|
|
142
|
+
const shown = useRef(undefined);
|
|
143
|
+
const [closedAtFirst] = useState(!open);
|
|
144
|
+
let t1;
|
|
145
|
+
let t2;
|
|
146
|
+
if ($[0] !== open) {
|
|
147
|
+
t1 = () => {
|
|
148
|
+
if (!panel.current) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const stop = setPanelOpen(panel.current, open, shown.current !== undefined && shown.current !== open);
|
|
152
|
+
shown.current = open;
|
|
153
|
+
return stop;
|
|
154
|
+
};
|
|
155
|
+
t2 = [open];
|
|
156
|
+
$[0] = open;
|
|
157
|
+
$[1] = t1;
|
|
158
|
+
$[2] = t2;
|
|
159
|
+
} else {
|
|
160
|
+
t1 = $[1];
|
|
161
|
+
t2 = $[2];
|
|
162
|
+
}
|
|
163
|
+
useLayoutEffect(t1, t2);
|
|
164
|
+
const t3 = closedAtFirst || undefined;
|
|
165
|
+
const t4 = open ? undefined : true;
|
|
166
|
+
let t5;
|
|
167
|
+
if ($[3] !== children) {
|
|
168
|
+
t5 = /*#__PURE__*/_jsx("div", {
|
|
169
|
+
className: "xds-accordion__body",
|
|
170
|
+
children: children
|
|
171
|
+
});
|
|
172
|
+
$[3] = children;
|
|
173
|
+
$[4] = t5;
|
|
174
|
+
} else {
|
|
175
|
+
t5 = $[4];
|
|
176
|
+
}
|
|
177
|
+
let t6;
|
|
178
|
+
if ($[5] !== attributes || $[6] !== t3 || $[7] !== t4 || $[8] !== t5) {
|
|
179
|
+
t6 = /*#__PURE__*/_jsx("div", {
|
|
180
|
+
...attributes,
|
|
181
|
+
ref: panel,
|
|
182
|
+
hidden: t3,
|
|
183
|
+
role: "group",
|
|
184
|
+
"aria-hidden": t4,
|
|
185
|
+
className: "xds-accordion__panel",
|
|
186
|
+
children: t5
|
|
187
|
+
});
|
|
188
|
+
$[5] = attributes;
|
|
189
|
+
$[6] = t3;
|
|
190
|
+
$[7] = t4;
|
|
191
|
+
$[8] = t5;
|
|
192
|
+
$[9] = t6;
|
|
193
|
+
} else {
|
|
194
|
+
t6 = $[9];
|
|
195
|
+
}
|
|
196
|
+
return t6;
|
|
197
|
+
}
|
package/dist/Avatar.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AvatarBaseProps } from "@xds/core";
|
|
2
|
+
import type { RootProps } from "./root.ts";
|
|
3
|
+
export type { AvatarSize } from "@xds/core";
|
|
4
|
+
export type AvatarProps = AvatarBaseProps & RootProps;
|
|
5
|
+
/**
|
|
6
|
+
* Stands for a person or a team by a picture, or by their initials when there is none.
|
|
7
|
+
* Assistive technology gets the full name either way. The small size has room for one letter.
|
|
8
|
+
*/
|
|
9
|
+
export declare function Avatar(props: AvatarProps): import("react").JSX.Element;
|
package/dist/Avatar.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { avatarClass, avatarInitials, classes, pictureClass, rootPart } from "@xds/core";
|
|
3
|
+
import { useDefaults } from "./Defaults.js";
|
|
4
|
+
import { usePicture } from "./picture.js";
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
export function Avatar(props) {
|
|
7
|
+
const $ = _c(15);
|
|
8
|
+
const defaults = useDefaults("Avatar");
|
|
9
|
+
const {
|
|
10
|
+
name,
|
|
11
|
+
src,
|
|
12
|
+
className,
|
|
13
|
+
style
|
|
14
|
+
} = props;
|
|
15
|
+
const size = props.size ?? defaults.size;
|
|
16
|
+
const picture = usePicture(src);
|
|
17
|
+
let t0;
|
|
18
|
+
if ($[0] !== className || $[1] !== size) {
|
|
19
|
+
t0 = classes(rootPart("Avatar"), avatarClass(size), className);
|
|
20
|
+
$[0] = className;
|
|
21
|
+
$[1] = size;
|
|
22
|
+
$[2] = t0;
|
|
23
|
+
} else {
|
|
24
|
+
t0 = $[2];
|
|
25
|
+
}
|
|
26
|
+
let t1;
|
|
27
|
+
if ($[3] !== name || $[4] !== size) {
|
|
28
|
+
t1 = avatarInitials(name, size);
|
|
29
|
+
$[3] = name;
|
|
30
|
+
$[4] = size;
|
|
31
|
+
$[5] = t1;
|
|
32
|
+
} else {
|
|
33
|
+
t1 = $[5];
|
|
34
|
+
}
|
|
35
|
+
let t2;
|
|
36
|
+
if ($[6] !== picture || $[7] !== src) {
|
|
37
|
+
t2 = src && picture.loaded !== false && /*#__PURE__*/_jsx("img", {
|
|
38
|
+
src: src,
|
|
39
|
+
alt: "",
|
|
40
|
+
"aria-hidden": "true",
|
|
41
|
+
className: pictureClass(picture.loaded === true),
|
|
42
|
+
...picture.image
|
|
43
|
+
});
|
|
44
|
+
$[6] = picture;
|
|
45
|
+
$[7] = src;
|
|
46
|
+
$[8] = t2;
|
|
47
|
+
} else {
|
|
48
|
+
t2 = $[8];
|
|
49
|
+
}
|
|
50
|
+
let t3;
|
|
51
|
+
if ($[9] !== name || $[10] !== style || $[11] !== t0 || $[12] !== t1 || $[13] !== t2) {
|
|
52
|
+
t3 = /*#__PURE__*/_jsxs("span", {
|
|
53
|
+
role: "img",
|
|
54
|
+
"aria-label": name,
|
|
55
|
+
className: t0,
|
|
56
|
+
style: style,
|
|
57
|
+
children: [t1, t2]
|
|
58
|
+
});
|
|
59
|
+
$[9] = name;
|
|
60
|
+
$[10] = style;
|
|
61
|
+
$[11] = t0;
|
|
62
|
+
$[12] = t1;
|
|
63
|
+
$[13] = t2;
|
|
64
|
+
$[14] = t3;
|
|
65
|
+
} else {
|
|
66
|
+
t3 = $[14];
|
|
67
|
+
}
|
|
68
|
+
return t3;
|
|
69
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type AvatarStackBaseProps } from "@xds/core";
|
|
2
|
+
import type { RootProps } from "./root.ts";
|
|
3
|
+
export type AvatarStackProps = AvatarStackBaseProps & RootProps;
|
|
4
|
+
/**
|
|
5
|
+
* Several people in the room of one. Assistive technology gets one image named after
|
|
6
|
+
* everyone in it, including those who did not fit.
|
|
7
|
+
*/
|
|
8
|
+
export declare function AvatarStack(props: AvatarStackProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { avatarStack, avatarStackClass, avatarStackItemClass, avatarStackRestClass, classes, rootPart } from "@xds/core";
|
|
3
|
+
import { Avatar } from "./Avatar.js";
|
|
4
|
+
import { useDefaults } from "./Defaults.js";
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
export function AvatarStack(props) {
|
|
7
|
+
const $ = _c(26);
|
|
8
|
+
const defaults = useDefaults("AvatarStack");
|
|
9
|
+
const {
|
|
10
|
+
people,
|
|
11
|
+
max,
|
|
12
|
+
label,
|
|
13
|
+
className,
|
|
14
|
+
style
|
|
15
|
+
} = props;
|
|
16
|
+
const size = props.size ?? defaults.size ?? "md";
|
|
17
|
+
let stack;
|
|
18
|
+
let t0;
|
|
19
|
+
let t1;
|
|
20
|
+
let t2;
|
|
21
|
+
let t3;
|
|
22
|
+
let t4;
|
|
23
|
+
if ($[0] !== className || $[1] !== label || $[2] !== max || $[3] !== people || $[4] !== size || $[5] !== style) {
|
|
24
|
+
stack = avatarStack(people, max, label);
|
|
25
|
+
t0 = "img";
|
|
26
|
+
t1 = stack.name;
|
|
27
|
+
if ($[12] !== className) {
|
|
28
|
+
t2 = classes(rootPart("AvatarStack"), avatarStackClass, className);
|
|
29
|
+
$[12] = className;
|
|
30
|
+
$[13] = t2;
|
|
31
|
+
} else {
|
|
32
|
+
t2 = $[13];
|
|
33
|
+
}
|
|
34
|
+
t3 = style;
|
|
35
|
+
let t5;
|
|
36
|
+
if ($[14] !== size) {
|
|
37
|
+
t5 = (person, index) => /*#__PURE__*/_jsx("span", {
|
|
38
|
+
"aria-hidden": "true",
|
|
39
|
+
className: avatarStackItemClass(size),
|
|
40
|
+
children: /*#__PURE__*/_jsx(Avatar, {
|
|
41
|
+
name: person.name,
|
|
42
|
+
src: person.src,
|
|
43
|
+
size: size
|
|
44
|
+
})
|
|
45
|
+
}, index);
|
|
46
|
+
$[14] = size;
|
|
47
|
+
$[15] = t5;
|
|
48
|
+
} else {
|
|
49
|
+
t5 = $[15];
|
|
50
|
+
}
|
|
51
|
+
t4 = stack.shown.map(t5);
|
|
52
|
+
$[0] = className;
|
|
53
|
+
$[1] = label;
|
|
54
|
+
$[2] = max;
|
|
55
|
+
$[3] = people;
|
|
56
|
+
$[4] = size;
|
|
57
|
+
$[5] = style;
|
|
58
|
+
$[6] = stack;
|
|
59
|
+
$[7] = t0;
|
|
60
|
+
$[8] = t1;
|
|
61
|
+
$[9] = t2;
|
|
62
|
+
$[10] = t3;
|
|
63
|
+
$[11] = t4;
|
|
64
|
+
} else {
|
|
65
|
+
stack = $[6];
|
|
66
|
+
t0 = $[7];
|
|
67
|
+
t1 = $[8];
|
|
68
|
+
t2 = $[9];
|
|
69
|
+
t3 = $[10];
|
|
70
|
+
t4 = $[11];
|
|
71
|
+
}
|
|
72
|
+
let t5;
|
|
73
|
+
if ($[16] !== size || $[17] !== stack.rest) {
|
|
74
|
+
t5 = stack.rest > 0 && /*#__PURE__*/_jsxs("span", {
|
|
75
|
+
"aria-hidden": "true",
|
|
76
|
+
className: avatarStackRestClass(size),
|
|
77
|
+
children: ["+", stack.rest]
|
|
78
|
+
});
|
|
79
|
+
$[16] = size;
|
|
80
|
+
$[17] = stack.rest;
|
|
81
|
+
$[18] = t5;
|
|
82
|
+
} else {
|
|
83
|
+
t5 = $[18];
|
|
84
|
+
}
|
|
85
|
+
let t6;
|
|
86
|
+
if ($[19] !== t0 || $[20] !== t1 || $[21] !== t2 || $[22] !== t3 || $[23] !== t4 || $[24] !== t5) {
|
|
87
|
+
t6 = /*#__PURE__*/_jsxs("span", {
|
|
88
|
+
role: t0,
|
|
89
|
+
"aria-label": t1,
|
|
90
|
+
className: t2,
|
|
91
|
+
style: t3,
|
|
92
|
+
children: [t4, t5]
|
|
93
|
+
});
|
|
94
|
+
$[19] = t0;
|
|
95
|
+
$[20] = t1;
|
|
96
|
+
$[21] = t2;
|
|
97
|
+
$[22] = t3;
|
|
98
|
+
$[23] = t4;
|
|
99
|
+
$[24] = t5;
|
|
100
|
+
$[25] = t6;
|
|
101
|
+
} else {
|
|
102
|
+
t6 = $[25];
|
|
103
|
+
}
|
|
104
|
+
return t6;
|
|
105
|
+
}
|
package/dist/Badge.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type BadgeBaseProps } from "@xds/core";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { RootProps } from "./root.ts";
|
|
4
|
+
export type { BadgeTone } from "@xds/core";
|
|
5
|
+
export type BadgeProps = BadgeBaseProps & RootProps & {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A short status or category. The words carry the meaning; the color only reinforces it, so a
|
|
10
|
+
* badge still reads for someone who cannot tell the tones apart. `dot` adds a small mark for
|
|
11
|
+
* live states such as "connected", and `icon` a drawing in front of the words.
|
|
12
|
+
*/
|
|
13
|
+
export declare function Badge(props: BadgeProps): import("react").JSX.Element;
|
package/dist/Badge.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { badgeClass, badgeDotClass, classes, rootPart } from "@xds/core";
|
|
3
|
+
import { useDefaults } from "./Defaults.js";
|
|
4
|
+
import { Icon } from "./Icon.js";
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
export function Badge(props) {
|
|
7
|
+
const $ = _c(13);
|
|
8
|
+
const defaults = useDefaults("Badge");
|
|
9
|
+
const {
|
|
10
|
+
dot: t0,
|
|
11
|
+
icon,
|
|
12
|
+
className,
|
|
13
|
+
style,
|
|
14
|
+
children
|
|
15
|
+
} = props;
|
|
16
|
+
const dot = t0 === undefined ? false : t0;
|
|
17
|
+
const tone = props.tone ?? defaults.tone;
|
|
18
|
+
let t1;
|
|
19
|
+
if ($[0] !== className || $[1] !== tone) {
|
|
20
|
+
t1 = classes(rootPart("Badge"), badgeClass(tone), className);
|
|
21
|
+
$[0] = className;
|
|
22
|
+
$[1] = tone;
|
|
23
|
+
$[2] = t1;
|
|
24
|
+
} else {
|
|
25
|
+
t1 = $[2];
|
|
26
|
+
}
|
|
27
|
+
let t2;
|
|
28
|
+
if ($[3] !== dot) {
|
|
29
|
+
t2 = dot && /*#__PURE__*/_jsx("span", {
|
|
30
|
+
"aria-hidden": true,
|
|
31
|
+
className: badgeDotClass
|
|
32
|
+
});
|
|
33
|
+
$[3] = dot;
|
|
34
|
+
$[4] = t2;
|
|
35
|
+
} else {
|
|
36
|
+
t2 = $[4];
|
|
37
|
+
}
|
|
38
|
+
let t3;
|
|
39
|
+
if ($[5] !== icon) {
|
|
40
|
+
t3 = icon && /*#__PURE__*/_jsx(Icon, {
|
|
41
|
+
name: icon,
|
|
42
|
+
size: "xs"
|
|
43
|
+
});
|
|
44
|
+
$[5] = icon;
|
|
45
|
+
$[6] = t3;
|
|
46
|
+
} else {
|
|
47
|
+
t3 = $[6];
|
|
48
|
+
}
|
|
49
|
+
let t4;
|
|
50
|
+
if ($[7] !== children || $[8] !== style || $[9] !== t1 || $[10] !== t2 || $[11] !== t3) {
|
|
51
|
+
t4 = /*#__PURE__*/_jsxs("span", {
|
|
52
|
+
className: t1,
|
|
53
|
+
style: style,
|
|
54
|
+
children: [t2, t3, children]
|
|
55
|
+
});
|
|
56
|
+
$[7] = children;
|
|
57
|
+
$[8] = style;
|
|
58
|
+
$[9] = t1;
|
|
59
|
+
$[10] = t2;
|
|
60
|
+
$[11] = t3;
|
|
61
|
+
$[12] = t4;
|
|
62
|
+
} else {
|
|
63
|
+
t4 = $[12];
|
|
64
|
+
}
|
|
65
|
+
return t4;
|
|
66
|
+
}
|
package/dist/Banner.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type BannerBaseProps } from "@xds/core";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { RootProps } from "./root.ts";
|
|
4
|
+
export type { BannerTone } from "@xds/core";
|
|
5
|
+
export type BannerProps = BannerBaseProps & RootProps & {
|
|
6
|
+
/** What the person can do about the message. Drawn under it as a small secondary button. */
|
|
7
|
+
action?: {
|
|
8
|
+
label: string;
|
|
9
|
+
onPress: () => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Shows a close control. The banner does not hide itself: the handler decides what happens
|
|
13
|
+
* to it.
|
|
14
|
+
*/
|
|
15
|
+
onDismiss?: () => void;
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A message about the whole view or a section of it. Each tone has its own icon shape, so the
|
|
20
|
+
* tone does not depend on color. Problems (`warning`, `danger`) interrupt a screen reader;
|
|
21
|
+
* `info` and `success` wait their turn.
|
|
22
|
+
*/
|
|
23
|
+
export declare function Banner(props: BannerProps): import("react").JSX.Element;
|