@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
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { classes, MEDIA_CARD_PARTS, mediaCardContentClass, mediaCardIds, mediaCardThumbnailClass, rootPart } from "@xds/core";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { useDefaults } from "./Defaults.js";
|
|
5
|
+
import { Thumbnail } from "./Thumbnail.js";
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
export function MediaCard(props) {
|
|
8
|
+
const $ = _c(65);
|
|
9
|
+
const defaults = useDefaults("MediaCard");
|
|
10
|
+
const {
|
|
11
|
+
src,
|
|
12
|
+
alt: t0,
|
|
13
|
+
ratio: t1,
|
|
14
|
+
badge,
|
|
15
|
+
progress,
|
|
16
|
+
title,
|
|
17
|
+
meta: t2,
|
|
18
|
+
leading,
|
|
19
|
+
action,
|
|
20
|
+
onPress,
|
|
21
|
+
className,
|
|
22
|
+
style
|
|
23
|
+
} = props;
|
|
24
|
+
const alt = t0 === undefined ? "" : t0;
|
|
25
|
+
const ratio = t1 === undefined ? "16:9" : t1;
|
|
26
|
+
let t3;
|
|
27
|
+
if ($[0] !== t2) {
|
|
28
|
+
t3 = t2 === undefined ? [] : t2;
|
|
29
|
+
$[0] = t2;
|
|
30
|
+
$[1] = t3;
|
|
31
|
+
} else {
|
|
32
|
+
t3 = $[1];
|
|
33
|
+
}
|
|
34
|
+
const meta = t3;
|
|
35
|
+
const layout = props.layout ?? defaults.layout ?? "vertical";
|
|
36
|
+
const t4 = useId();
|
|
37
|
+
let t5;
|
|
38
|
+
if ($[2] !== meta || $[3] !== t4) {
|
|
39
|
+
t5 = mediaCardIds(t4, meta);
|
|
40
|
+
$[2] = meta;
|
|
41
|
+
$[3] = t4;
|
|
42
|
+
$[4] = t5;
|
|
43
|
+
} else {
|
|
44
|
+
t5 = $[4];
|
|
45
|
+
}
|
|
46
|
+
const ids = t5;
|
|
47
|
+
let t6;
|
|
48
|
+
if ($[5] !== onPress) {
|
|
49
|
+
t6 = onPress ? {
|
|
50
|
+
"aria-hidden": true
|
|
51
|
+
} : {};
|
|
52
|
+
$[5] = onPress;
|
|
53
|
+
$[6] = t6;
|
|
54
|
+
} else {
|
|
55
|
+
t6 = $[6];
|
|
56
|
+
}
|
|
57
|
+
const part = t6;
|
|
58
|
+
const horizontal = layout === "horizontal";
|
|
59
|
+
const t7 = onPress !== undefined;
|
|
60
|
+
let t8;
|
|
61
|
+
if ($[7] !== horizontal || $[8] !== t7) {
|
|
62
|
+
t8 = mediaCardContentClass({
|
|
63
|
+
horizontal,
|
|
64
|
+
pressable: t7
|
|
65
|
+
});
|
|
66
|
+
$[7] = horizontal;
|
|
67
|
+
$[8] = t7;
|
|
68
|
+
$[9] = t8;
|
|
69
|
+
} else {
|
|
70
|
+
t8 = $[9];
|
|
71
|
+
}
|
|
72
|
+
let t9;
|
|
73
|
+
if ($[10] !== horizontal) {
|
|
74
|
+
t9 = mediaCardThumbnailClass(horizontal);
|
|
75
|
+
$[10] = horizontal;
|
|
76
|
+
$[11] = t9;
|
|
77
|
+
} else {
|
|
78
|
+
t9 = $[11];
|
|
79
|
+
}
|
|
80
|
+
let t10;
|
|
81
|
+
if ($[12] !== alt || $[13] !== badge || $[14] !== progress || $[15] !== ratio || $[16] !== src) {
|
|
82
|
+
t10 = /*#__PURE__*/_jsx(Thumbnail, {
|
|
83
|
+
src: src,
|
|
84
|
+
alt: alt,
|
|
85
|
+
ratio: ratio,
|
|
86
|
+
badge: badge,
|
|
87
|
+
progress: progress
|
|
88
|
+
});
|
|
89
|
+
$[12] = alt;
|
|
90
|
+
$[13] = badge;
|
|
91
|
+
$[14] = progress;
|
|
92
|
+
$[15] = ratio;
|
|
93
|
+
$[16] = src;
|
|
94
|
+
$[17] = t10;
|
|
95
|
+
} else {
|
|
96
|
+
t10 = $[17];
|
|
97
|
+
}
|
|
98
|
+
let t11;
|
|
99
|
+
if ($[18] !== part || $[19] !== t10 || $[20] !== t9) {
|
|
100
|
+
t11 = /*#__PURE__*/_jsx("span", {
|
|
101
|
+
...part,
|
|
102
|
+
className: t9,
|
|
103
|
+
children: t10
|
|
104
|
+
});
|
|
105
|
+
$[18] = part;
|
|
106
|
+
$[19] = t10;
|
|
107
|
+
$[20] = t9;
|
|
108
|
+
$[21] = t11;
|
|
109
|
+
} else {
|
|
110
|
+
t11 = $[21];
|
|
111
|
+
}
|
|
112
|
+
let t12;
|
|
113
|
+
if ($[22] !== horizontal || $[23] !== leading || $[24] !== part) {
|
|
114
|
+
t12 = !horizontal && leading != null && /*#__PURE__*/_jsx("span", {
|
|
115
|
+
...part,
|
|
116
|
+
className: MEDIA_CARD_PARTS.leading,
|
|
117
|
+
children: leading
|
|
118
|
+
});
|
|
119
|
+
$[22] = horizontal;
|
|
120
|
+
$[23] = leading;
|
|
121
|
+
$[24] = part;
|
|
122
|
+
$[25] = t12;
|
|
123
|
+
} else {
|
|
124
|
+
t12 = $[25];
|
|
125
|
+
}
|
|
126
|
+
let t13;
|
|
127
|
+
if ($[26] !== ids.title || $[27] !== title) {
|
|
128
|
+
t13 = /*#__PURE__*/_jsx("span", {
|
|
129
|
+
id: ids.title,
|
|
130
|
+
className: MEDIA_CARD_PARTS.title,
|
|
131
|
+
children: title
|
|
132
|
+
});
|
|
133
|
+
$[26] = ids.title;
|
|
134
|
+
$[27] = title;
|
|
135
|
+
$[28] = t13;
|
|
136
|
+
} else {
|
|
137
|
+
t13 = $[28];
|
|
138
|
+
}
|
|
139
|
+
let t14;
|
|
140
|
+
if ($[29] !== ids.details || $[30] !== meta) {
|
|
141
|
+
let t15;
|
|
142
|
+
if ($[32] !== ids.details) {
|
|
143
|
+
t15 = (line, index) => /*#__PURE__*/_jsx("span", {
|
|
144
|
+
id: ids.details[index],
|
|
145
|
+
className: MEDIA_CARD_PARTS.meta,
|
|
146
|
+
children: line
|
|
147
|
+
}, index);
|
|
148
|
+
$[32] = ids.details;
|
|
149
|
+
$[33] = t15;
|
|
150
|
+
} else {
|
|
151
|
+
t15 = $[33];
|
|
152
|
+
}
|
|
153
|
+
t14 = meta.map(t15);
|
|
154
|
+
$[29] = ids.details;
|
|
155
|
+
$[30] = meta;
|
|
156
|
+
$[31] = t14;
|
|
157
|
+
} else {
|
|
158
|
+
t14 = $[31];
|
|
159
|
+
}
|
|
160
|
+
let t15;
|
|
161
|
+
if ($[34] !== part || $[35] !== t13 || $[36] !== t14) {
|
|
162
|
+
t15 = /*#__PURE__*/_jsxs("span", {
|
|
163
|
+
...part,
|
|
164
|
+
className: MEDIA_CARD_PARTS.text,
|
|
165
|
+
children: [t13, t14]
|
|
166
|
+
});
|
|
167
|
+
$[34] = part;
|
|
168
|
+
$[35] = t13;
|
|
169
|
+
$[36] = t14;
|
|
170
|
+
$[37] = t15;
|
|
171
|
+
} else {
|
|
172
|
+
t15 = $[37];
|
|
173
|
+
}
|
|
174
|
+
let t16;
|
|
175
|
+
if ($[38] !== action) {
|
|
176
|
+
t16 = action != null && /*#__PURE__*/_jsx("div", {
|
|
177
|
+
className: MEDIA_CARD_PARTS.action,
|
|
178
|
+
children: action
|
|
179
|
+
});
|
|
180
|
+
$[38] = action;
|
|
181
|
+
$[39] = t16;
|
|
182
|
+
} else {
|
|
183
|
+
t16 = $[39];
|
|
184
|
+
}
|
|
185
|
+
let t17;
|
|
186
|
+
if ($[40] !== t12 || $[41] !== t15 || $[42] !== t16) {
|
|
187
|
+
t17 = /*#__PURE__*/_jsxs("div", {
|
|
188
|
+
className: MEDIA_CARD_PARTS.body,
|
|
189
|
+
children: [t12, t15, t16]
|
|
190
|
+
});
|
|
191
|
+
$[40] = t12;
|
|
192
|
+
$[41] = t15;
|
|
193
|
+
$[42] = t16;
|
|
194
|
+
$[43] = t17;
|
|
195
|
+
} else {
|
|
196
|
+
t17 = $[43];
|
|
197
|
+
}
|
|
198
|
+
let t18;
|
|
199
|
+
if ($[44] !== t11 || $[45] !== t17 || $[46] !== t8) {
|
|
200
|
+
t18 = /*#__PURE__*/_jsxs("div", {
|
|
201
|
+
className: t8,
|
|
202
|
+
children: [t11, t17]
|
|
203
|
+
});
|
|
204
|
+
$[44] = t11;
|
|
205
|
+
$[45] = t17;
|
|
206
|
+
$[46] = t8;
|
|
207
|
+
$[47] = t18;
|
|
208
|
+
} else {
|
|
209
|
+
t18 = $[47];
|
|
210
|
+
}
|
|
211
|
+
const content = t18;
|
|
212
|
+
if (!onPress) {
|
|
213
|
+
const t19 = ids.names;
|
|
214
|
+
let t20;
|
|
215
|
+
if ($[48] !== className) {
|
|
216
|
+
t20 = classes(rootPart("MediaCard"), MEDIA_CARD_PARTS.group, className);
|
|
217
|
+
$[48] = className;
|
|
218
|
+
$[49] = t20;
|
|
219
|
+
} else {
|
|
220
|
+
t20 = $[49];
|
|
221
|
+
}
|
|
222
|
+
let t21;
|
|
223
|
+
if ($[50] !== content || $[51] !== ids.names || $[52] !== style || $[53] !== t20) {
|
|
224
|
+
t21 = /*#__PURE__*/_jsx("div", {
|
|
225
|
+
role: "group",
|
|
226
|
+
"aria-labelledby": t19,
|
|
227
|
+
className: t20,
|
|
228
|
+
style: style,
|
|
229
|
+
children: content
|
|
230
|
+
});
|
|
231
|
+
$[50] = content;
|
|
232
|
+
$[51] = ids.names;
|
|
233
|
+
$[52] = style;
|
|
234
|
+
$[53] = t20;
|
|
235
|
+
$[54] = t21;
|
|
236
|
+
} else {
|
|
237
|
+
t21 = $[54];
|
|
238
|
+
}
|
|
239
|
+
return t21;
|
|
240
|
+
}
|
|
241
|
+
let t19;
|
|
242
|
+
if ($[55] !== className) {
|
|
243
|
+
t19 = classes(rootPart("MediaCard"), MEDIA_CARD_PARTS.pressable, className);
|
|
244
|
+
$[55] = className;
|
|
245
|
+
$[56] = t19;
|
|
246
|
+
} else {
|
|
247
|
+
t19 = $[56];
|
|
248
|
+
}
|
|
249
|
+
let t20;
|
|
250
|
+
if ($[57] !== ids.names || $[58] !== onPress) {
|
|
251
|
+
t20 = /*#__PURE__*/_jsx("button", {
|
|
252
|
+
type: "button",
|
|
253
|
+
onClick: onPress,
|
|
254
|
+
"aria-labelledby": ids.names,
|
|
255
|
+
className: MEDIA_CARD_PARTS.button
|
|
256
|
+
});
|
|
257
|
+
$[57] = ids.names;
|
|
258
|
+
$[58] = onPress;
|
|
259
|
+
$[59] = t20;
|
|
260
|
+
} else {
|
|
261
|
+
t20 = $[59];
|
|
262
|
+
}
|
|
263
|
+
let t21;
|
|
264
|
+
if ($[60] !== content || $[61] !== style || $[62] !== t19 || $[63] !== t20) {
|
|
265
|
+
t21 = /*#__PURE__*/_jsxs("div", {
|
|
266
|
+
className: t19,
|
|
267
|
+
style: style,
|
|
268
|
+
children: [t20, content]
|
|
269
|
+
});
|
|
270
|
+
$[60] = content;
|
|
271
|
+
$[61] = style;
|
|
272
|
+
$[62] = t19;
|
|
273
|
+
$[63] = t20;
|
|
274
|
+
$[64] = t21;
|
|
275
|
+
} else {
|
|
276
|
+
t21 = $[64];
|
|
277
|
+
}
|
|
278
|
+
return t21;
|
|
279
|
+
}
|
package/dist/Menu.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type MenuBaseProps } from "@xds/core";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
import type { RootProps } from "./root.ts";
|
|
4
|
+
export type { MenuItem } from "@xds/core";
|
|
5
|
+
/** `className` and `style` are for the menu itself, the list that opens, not for its trigger. */
|
|
6
|
+
export type MenuProps = MenuBaseProps & RootProps & {
|
|
7
|
+
/** The control that opens the menu: a Button or an IconButton. */
|
|
8
|
+
trigger: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A list of actions that opens from a control. Choosing an item calls its `onSelect` and
|
|
12
|
+
* closes the menu; a press outside or Escape closes it too, and focus goes back to the
|
|
13
|
+
* trigger.
|
|
14
|
+
*
|
|
15
|
+
* The trigger reports that it opens a menu and whether the menu is open. The arrow keys move
|
|
16
|
+
* the highlight and Enter chooses.
|
|
17
|
+
*/
|
|
18
|
+
export declare function Menu({ trigger, label, items, align, className, style }: MenuProps): import("react").JSX.Element;
|
package/dist/Menu.js
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { space } from "@xds/tokens";
|
|
3
|
+
import { classes, firstMenuValue, keepListKeys, layoutRect, leaveEscapeToFields, menuItemClass, opensOnPress } from "@xds/core";
|
|
4
|
+
import * as menu from "@zag-js/menu";
|
|
5
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
6
|
+
import { useId, useRef } from "react";
|
|
7
|
+
import { Icon } from "./Icon.js";
|
|
8
|
+
import { useModalPopover } from "./modal-popover.js";
|
|
9
|
+
import { Portal } from "./portal.js";
|
|
10
|
+
import { usePresence } from "./presence.js";
|
|
11
|
+
import { TriggerContext, useMergedProps, useProvideTrigger } from "./trigger.js";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
export function Menu(t0) {
|
|
14
|
+
const $ = _c(31);
|
|
15
|
+
const {
|
|
16
|
+
trigger,
|
|
17
|
+
label,
|
|
18
|
+
items,
|
|
19
|
+
align: t1,
|
|
20
|
+
className,
|
|
21
|
+
style
|
|
22
|
+
} = t0;
|
|
23
|
+
const align = t1 === undefined ? "start" : t1;
|
|
24
|
+
const t2 = useId();
|
|
25
|
+
const t3 = `bottom-${align}`;
|
|
26
|
+
let t4;
|
|
27
|
+
if ($[0] !== t3) {
|
|
28
|
+
t4 = {
|
|
29
|
+
placement: t3,
|
|
30
|
+
gutter: space[1],
|
|
31
|
+
getAnchorRect: _temp
|
|
32
|
+
};
|
|
33
|
+
$[0] = t3;
|
|
34
|
+
$[1] = t4;
|
|
35
|
+
} else {
|
|
36
|
+
t4 = $[1];
|
|
37
|
+
}
|
|
38
|
+
let t5;
|
|
39
|
+
if ($[2] !== items) {
|
|
40
|
+
t5 = details => {
|
|
41
|
+
const item = items[Number(details.value)];
|
|
42
|
+
if (item && item !== "separator") {
|
|
43
|
+
item.onSelect();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
$[2] = items;
|
|
47
|
+
$[3] = t5;
|
|
48
|
+
} else {
|
|
49
|
+
t5 = $[3];
|
|
50
|
+
}
|
|
51
|
+
let t6;
|
|
52
|
+
if ($[4] !== label || $[5] !== t2 || $[6] !== t4 || $[7] !== t5) {
|
|
53
|
+
t6 = {
|
|
54
|
+
id: t2,
|
|
55
|
+
"aria-label": label,
|
|
56
|
+
positioning: t4,
|
|
57
|
+
onSelect: t5,
|
|
58
|
+
onEscapeKeyDown: leaveEscapeToFields,
|
|
59
|
+
loopFocus: true
|
|
60
|
+
};
|
|
61
|
+
$[4] = label;
|
|
62
|
+
$[5] = t2;
|
|
63
|
+
$[6] = t4;
|
|
64
|
+
$[7] = t5;
|
|
65
|
+
$[8] = t6;
|
|
66
|
+
} else {
|
|
67
|
+
t6 = $[8];
|
|
68
|
+
}
|
|
69
|
+
const service = useMachine(menu.machine, t6);
|
|
70
|
+
const api = menu.connect(service, normalizeProps);
|
|
71
|
+
const {
|
|
72
|
+
onPointerDown: _onPointerDown,
|
|
73
|
+
...triggerProps
|
|
74
|
+
} = api.getTriggerProps();
|
|
75
|
+
const pressOpened = useRef(false);
|
|
76
|
+
const provided = useProvideTrigger(useMergedProps(triggerProps, {
|
|
77
|
+
className: "xds-menu__trigger",
|
|
78
|
+
onPointerDown: event => {
|
|
79
|
+
pressOpened.current = opensOnPress(event) && !api.open;
|
|
80
|
+
if (pressOpened.current) {
|
|
81
|
+
api.setOpen(true);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
onClick: event_0 => {
|
|
85
|
+
const pointer = event_0.detail !== 0;
|
|
86
|
+
if (pressOpened.current && pointer) {
|
|
87
|
+
pressOpened.current = false;
|
|
88
|
+
event_0.preventDefault();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (pointer) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
requestAnimationFrame(() => {
|
|
95
|
+
const now = menu.connect(service, normalizeProps);
|
|
96
|
+
if (!now.open) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const first = firstMenuValue(items);
|
|
100
|
+
if (first !== undefined) {
|
|
101
|
+
now.setHighlightedValue(first);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}));
|
|
106
|
+
const positioner = useRef(null);
|
|
107
|
+
const surface = useRef(null);
|
|
108
|
+
let t7;
|
|
109
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
110
|
+
t7 = () => positioner.current;
|
|
111
|
+
$[9] = t7;
|
|
112
|
+
} else {
|
|
113
|
+
t7 = $[9];
|
|
114
|
+
}
|
|
115
|
+
useModalPopover(api.open, t7);
|
|
116
|
+
let t8;
|
|
117
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
118
|
+
t8 = () => [surface.current];
|
|
119
|
+
$[10] = t8;
|
|
120
|
+
} else {
|
|
121
|
+
t8 = $[10];
|
|
122
|
+
}
|
|
123
|
+
const present = usePresence(api.open, t8);
|
|
124
|
+
const content = useMergedProps(api.getContentProps(), {
|
|
125
|
+
className: classes("xds-menu", className),
|
|
126
|
+
style,
|
|
127
|
+
onKeyDown: event_1 => keepListKeys(event_1, surface.current, ".xds-menu__item:not([data-disabled])", value => api.setHighlightedValue(value))
|
|
128
|
+
});
|
|
129
|
+
let t9;
|
|
130
|
+
if ($[11] !== provided || $[12] !== trigger) {
|
|
131
|
+
t9 = /*#__PURE__*/_jsx(TriggerContext, {
|
|
132
|
+
value: provided,
|
|
133
|
+
children: trigger
|
|
134
|
+
});
|
|
135
|
+
$[11] = provided;
|
|
136
|
+
$[12] = trigger;
|
|
137
|
+
$[13] = t9;
|
|
138
|
+
} else {
|
|
139
|
+
t9 = $[13];
|
|
140
|
+
}
|
|
141
|
+
const T0 = Portal;
|
|
142
|
+
const T1 = TriggerContext;
|
|
143
|
+
const t10 = null;
|
|
144
|
+
const t11 = api.open && /*#__PURE__*/_jsx("div", {
|
|
145
|
+
className: "xds-menu__underlay",
|
|
146
|
+
onMouseDown: _temp2
|
|
147
|
+
});
|
|
148
|
+
const t12 = api.getPositionerProps();
|
|
149
|
+
const t13 = "xds-menu__positioner";
|
|
150
|
+
const t14 = !present;
|
|
151
|
+
const t15 = items.map((item_0, index) => item_0 === "separator" ? /*#__PURE__*/_jsx("div", {
|
|
152
|
+
...api.getSeparatorProps(),
|
|
153
|
+
className: "xds-menu__separator"
|
|
154
|
+
}, index) : /*#__PURE__*/_jsxs("div", {
|
|
155
|
+
...api.getItemProps({
|
|
156
|
+
value: String(index),
|
|
157
|
+
disabled: item_0.disabled
|
|
158
|
+
}),
|
|
159
|
+
className: menuItemClass(item_0.danger),
|
|
160
|
+
children: [item_0.icon && /*#__PURE__*/_jsx(Icon, {
|
|
161
|
+
name: item_0.icon,
|
|
162
|
+
size: "sm",
|
|
163
|
+
className: "xds-menu__item-icon"
|
|
164
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
165
|
+
className: "flex-1",
|
|
166
|
+
children: item_0.label
|
|
167
|
+
}), item_0.selected && /*#__PURE__*/_jsx(Icon, {
|
|
168
|
+
name: "check",
|
|
169
|
+
size: "sm",
|
|
170
|
+
label: "Selected"
|
|
171
|
+
})]
|
|
172
|
+
}, index));
|
|
173
|
+
let t16;
|
|
174
|
+
if ($[14] !== content || $[15] !== t14 || $[16] !== t15) {
|
|
175
|
+
t16 = /*#__PURE__*/_jsx("div", {
|
|
176
|
+
...content,
|
|
177
|
+
ref: surface,
|
|
178
|
+
hidden: t14,
|
|
179
|
+
children: t15
|
|
180
|
+
});
|
|
181
|
+
$[14] = content;
|
|
182
|
+
$[15] = t14;
|
|
183
|
+
$[16] = t15;
|
|
184
|
+
$[17] = t16;
|
|
185
|
+
} else {
|
|
186
|
+
t16 = $[17];
|
|
187
|
+
}
|
|
188
|
+
let t17;
|
|
189
|
+
if ($[18] !== t12 || $[19] !== t16) {
|
|
190
|
+
t17 = /*#__PURE__*/_jsx("div", {
|
|
191
|
+
...t12,
|
|
192
|
+
ref: positioner,
|
|
193
|
+
className: t13,
|
|
194
|
+
children: t16
|
|
195
|
+
});
|
|
196
|
+
$[18] = t12;
|
|
197
|
+
$[19] = t16;
|
|
198
|
+
$[20] = t17;
|
|
199
|
+
} else {
|
|
200
|
+
t17 = $[20];
|
|
201
|
+
}
|
|
202
|
+
let t18;
|
|
203
|
+
if ($[21] !== T1 || $[22] !== t11 || $[23] !== t17) {
|
|
204
|
+
t18 = /*#__PURE__*/_jsxs(T1, {
|
|
205
|
+
value: t10,
|
|
206
|
+
children: [t11, t17]
|
|
207
|
+
});
|
|
208
|
+
$[21] = T1;
|
|
209
|
+
$[22] = t11;
|
|
210
|
+
$[23] = t17;
|
|
211
|
+
$[24] = t18;
|
|
212
|
+
} else {
|
|
213
|
+
t18 = $[24];
|
|
214
|
+
}
|
|
215
|
+
let t19;
|
|
216
|
+
if ($[25] !== T0 || $[26] !== t18) {
|
|
217
|
+
t19 = /*#__PURE__*/_jsx(T0, {
|
|
218
|
+
children: t18
|
|
219
|
+
});
|
|
220
|
+
$[25] = T0;
|
|
221
|
+
$[26] = t18;
|
|
222
|
+
$[27] = t19;
|
|
223
|
+
} else {
|
|
224
|
+
t19 = $[27];
|
|
225
|
+
}
|
|
226
|
+
let t20;
|
|
227
|
+
if ($[28] !== t19 || $[29] !== t9) {
|
|
228
|
+
t20 = /*#__PURE__*/_jsxs(_Fragment, {
|
|
229
|
+
children: [t9, t19]
|
|
230
|
+
});
|
|
231
|
+
$[28] = t19;
|
|
232
|
+
$[29] = t9;
|
|
233
|
+
$[30] = t20;
|
|
234
|
+
} else {
|
|
235
|
+
t20 = $[30];
|
|
236
|
+
}
|
|
237
|
+
return t20;
|
|
238
|
+
}
|
|
239
|
+
function _temp2(event_2) {
|
|
240
|
+
return event_2.preventDefault();
|
|
241
|
+
}
|
|
242
|
+
function _temp(anchor) {
|
|
243
|
+
return anchor instanceof HTMLElement ? layoutRect(anchor) : null;
|
|
244
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ProgressBarBaseProps } from "@xds/core";
|
|
2
|
+
import type { RootProps } from "./root.ts";
|
|
3
|
+
export type ProgressBarProps = ProgressBarBaseProps & RootProps;
|
|
4
|
+
/**
|
|
5
|
+
* How far along something is, from 0 to 1. For work of unknown length use a Spinner.
|
|
6
|
+
* `label` says what is progressing; a screen reader reads it with the percentage.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ProgressBar({ value, label, className, style }: ProgressBarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { classes, progressBarClass, progressBarFillClass, progressPercent, rootPart } from "@xds/core";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
export function ProgressBar(t0) {
|
|
5
|
+
const $ = _c(12);
|
|
6
|
+
const {
|
|
7
|
+
value,
|
|
8
|
+
label,
|
|
9
|
+
className,
|
|
10
|
+
style
|
|
11
|
+
} = t0;
|
|
12
|
+
let t1;
|
|
13
|
+
if ($[0] !== value) {
|
|
14
|
+
t1 = progressPercent(value);
|
|
15
|
+
$[0] = value;
|
|
16
|
+
$[1] = t1;
|
|
17
|
+
} else {
|
|
18
|
+
t1 = $[1];
|
|
19
|
+
}
|
|
20
|
+
const percent = t1;
|
|
21
|
+
let t2;
|
|
22
|
+
if ($[2] !== className) {
|
|
23
|
+
t2 = classes(rootPart("ProgressBar"), progressBarClass, className);
|
|
24
|
+
$[2] = className;
|
|
25
|
+
$[3] = t2;
|
|
26
|
+
} else {
|
|
27
|
+
t2 = $[3];
|
|
28
|
+
}
|
|
29
|
+
const t3 = `${percent}%`;
|
|
30
|
+
let t4;
|
|
31
|
+
if ($[4] !== t3) {
|
|
32
|
+
t4 = /*#__PURE__*/_jsx("div", {
|
|
33
|
+
className: progressBarFillClass,
|
|
34
|
+
style: {
|
|
35
|
+
width: t3
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
$[4] = t3;
|
|
39
|
+
$[5] = t4;
|
|
40
|
+
} else {
|
|
41
|
+
t4 = $[5];
|
|
42
|
+
}
|
|
43
|
+
let t5;
|
|
44
|
+
if ($[6] !== label || $[7] !== percent || $[8] !== style || $[9] !== t2 || $[10] !== t4) {
|
|
45
|
+
t5 = /*#__PURE__*/_jsx("div", {
|
|
46
|
+
role: "progressbar",
|
|
47
|
+
"aria-label": label,
|
|
48
|
+
"aria-valuemin": 0,
|
|
49
|
+
"aria-valuemax": 100,
|
|
50
|
+
"aria-valuenow": percent,
|
|
51
|
+
className: t2,
|
|
52
|
+
style: style,
|
|
53
|
+
children: t4
|
|
54
|
+
});
|
|
55
|
+
$[6] = label;
|
|
56
|
+
$[7] = percent;
|
|
57
|
+
$[8] = style;
|
|
58
|
+
$[9] = t2;
|
|
59
|
+
$[10] = t4;
|
|
60
|
+
$[11] = t5;
|
|
61
|
+
} else {
|
|
62
|
+
t5 = $[11];
|
|
63
|
+
}
|
|
64
|
+
return t5;
|
|
65
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type RadioGroupBaseProps } from "@xds/core";
|
|
2
|
+
import type { RootProps } from "./root.ts";
|
|
3
|
+
export type { RadioOption } from "@xds/core";
|
|
4
|
+
export type RadioGroupProps<Value extends string = string> = RadioGroupBaseProps<Value> & RootProps & {
|
|
5
|
+
onChange: (value: Value) => void;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* One choice among a few, applied later with the form it belongs to. For a choice that takes
|
|
9
|
+
* effect at once among two to four options, a SegmentedControl is the usual pick.
|
|
10
|
+
*
|
|
11
|
+
* The chosen option has a dot and a thicker ring, so the choice does not depend on color. The
|
|
12
|
+
* options are native radio buttons, hidden and drawn beside, in a group named by the legend:
|
|
13
|
+
* the arrow keys move between them, and the error is tied to the group and announced.
|
|
14
|
+
*/
|
|
15
|
+
export declare function RadioGroup<Value extends string = string>({ label, options, value, onChange, disabled, error, name, className, style, }: RadioGroupProps<Value>): import("react").JSX.Element;
|