@xds/react 0.1.0 → 1.0.0-rc.1

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.
Files changed (140) hide show
  1. package/dist/Accordion.js +191 -33
  2. package/dist/Avatar.js +65 -6
  3. package/dist/AvatarStack.js +101 -6
  4. package/dist/Badge.js +61 -4
  5. package/dist/Banner.js +161 -5
  6. package/dist/Button.js +152 -24
  7. package/dist/Card.js +171 -12
  8. package/dist/Checkbox.js +138 -3
  9. package/dist/Chip.js +71 -4
  10. package/dist/ChipBar.js +36 -3
  11. package/dist/CountBadge.js +62 -9
  12. package/dist/DatePicker.js +421 -25
  13. package/dist/DateRangePicker.js +362 -40
  14. package/dist/Defaults.js +42 -7
  15. package/dist/Dialog.js +128 -24
  16. package/dist/Divider.js +29 -3
  17. package/dist/EmptyState.js +83 -3
  18. package/dist/Icon.js +74 -4
  19. package/dist/IconButton.js +113 -18
  20. package/dist/ListRow.js +180 -10
  21. package/dist/MediaCard.js +273 -11
  22. package/dist/Menu.js +234 -58
  23. package/dist/ProgressBar.js +63 -4
  24. package/dist/RadioGroup.js +173 -12
  25. package/dist/SearchField.js +148 -16
  26. package/dist/SectionHeader.js +121 -5
  27. package/dist/SegmentedControl.js +104 -5
  28. package/dist/Select.js +307 -55
  29. package/dist/Sidebar.js +212 -19
  30. package/dist/Skeleton.js +61 -5
  31. package/dist/Slider.js +142 -35
  32. package/dist/Spinner.js +93 -4
  33. package/dist/Switch.js +114 -3
  34. package/dist/Tabs.js +130 -14
  35. package/dist/Text.js +42 -4
  36. package/dist/TextField.js +209 -26
  37. package/dist/Thumbnail.js +146 -7
  38. package/dist/Toast.js +118 -30
  39. package/dist/Tooltip.js +154 -20
  40. package/dist/base.d.ts +11 -0
  41. package/dist/base.js +10 -0
  42. package/dist/modal-popover.js +32 -10
  43. package/dist/picture.d.ts +6 -4
  44. package/dist/picture.js +72 -17
  45. package/dist/portal.js +24 -4
  46. package/dist/presence.js +30 -9
  47. package/dist/preview.d.ts +14 -3
  48. package/dist/preview.js +118 -74
  49. package/dist/root.js +1 -0
  50. package/dist/trigger.d.ts +7 -0
  51. package/dist/trigger.js +41 -8
  52. package/eject/files/Accordion.tsx +157 -0
  53. package/eject/files/Avatar.tsx +41 -0
  54. package/eject/files/AvatarStack.tsx +47 -0
  55. package/eject/files/Badge.tsx +33 -0
  56. package/eject/files/Banner.tsx +70 -0
  57. package/eject/files/Button.tsx +88 -0
  58. package/eject/files/Card.tsx +85 -0
  59. package/eject/files/Checkbox.tsx +59 -0
  60. package/eject/files/Chip.tsx +43 -0
  61. package/eject/files/ChipBar.tsx +31 -0
  62. package/eject/files/CountBadge.tsx +50 -0
  63. package/eject/files/DatePicker.tsx +192 -0
  64. package/eject/files/DateRangePicker.tsx +271 -0
  65. package/eject/files/Dialog.tsx +108 -0
  66. package/eject/files/Divider.tsx +13 -0
  67. package/eject/files/EmptyState.tsx +39 -0
  68. package/eject/files/Icon.tsx +38 -0
  69. package/eject/files/IconButton.tsx +62 -0
  70. package/eject/files/ListRow.tsx +86 -0
  71. package/eject/files/MediaCard.tsx +111 -0
  72. package/eject/files/Menu.tsx +168 -0
  73. package/eject/files/ProgressBar.tsx +34 -0
  74. package/eject/files/RadioGroup.tsx +112 -0
  75. package/eject/files/SearchField.tsx +88 -0
  76. package/eject/files/SectionHeader.tsx +56 -0
  77. package/eject/files/SegmentedControl.tsx +57 -0
  78. package/eject/files/Select.tsx +228 -0
  79. package/eject/files/Sidebar.tsx +149 -0
  80. package/eject/files/Skeleton.tsx +28 -0
  81. package/eject/files/Slider.tsx +109 -0
  82. package/eject/files/Spinner.tsx +36 -0
  83. package/eject/files/Switch.tsx +53 -0
  84. package/eject/files/Tabs.tsx +71 -0
  85. package/eject/files/Text.tsx +31 -0
  86. package/eject/files/TextField.tsx +122 -0
  87. package/eject/files/Thumbnail.tsx +66 -0
  88. package/eject/files/Toast.tsx +88 -0
  89. package/eject/files/Tooltip.tsx +120 -0
  90. package/eject/files/accordion.css +89 -0
  91. package/eject/files/accordion.ts +67 -0
  92. package/eject/files/avatar-stack.ts +57 -0
  93. package/eject/files/avatar.ts +42 -0
  94. package/eject/files/badge.ts +30 -0
  95. package/eject/files/banner.ts +68 -0
  96. package/eject/files/base.css +38 -0
  97. package/eject/files/button.css +241 -0
  98. package/eject/files/button.ts +106 -0
  99. package/eject/files/card.ts +58 -0
  100. package/eject/files/checkbox.ts +32 -0
  101. package/eject/files/chip-bar.ts +16 -0
  102. package/eject/files/chip.ts +35 -0
  103. package/eject/files/count-badge.ts +32 -0
  104. package/eject/files/date-picker.css +352 -0
  105. package/eject/files/date-picker.ts +250 -0
  106. package/eject/files/date-range-picker.ts +323 -0
  107. package/eject/files/dialog.css +139 -0
  108. package/eject/files/dialog.ts +15 -0
  109. package/eject/files/divider.ts +5 -0
  110. package/eject/files/empty-state.ts +22 -0
  111. package/eject/files/icon.ts +36 -0
  112. package/eject/files/list-row.ts +66 -0
  113. package/eject/files/media-card.ts +66 -0
  114. package/eject/files/menu.css +176 -0
  115. package/eject/files/menu.ts +84 -0
  116. package/eject/files/parts.ts +17 -0
  117. package/eject/files/progress-bar.ts +23 -0
  118. package/eject/files/radio-group.css +160 -0
  119. package/eject/files/radio-group.ts +24 -0
  120. package/eject/files/section-header.ts +32 -0
  121. package/eject/files/segmented-control.ts +30 -0
  122. package/eject/files/select.css +285 -0
  123. package/eject/files/select.ts +36 -0
  124. package/eject/files/sidebar.ts +75 -0
  125. package/eject/files/skeleton.ts +51 -0
  126. package/eject/files/slider.css +136 -0
  127. package/eject/files/slider.ts +65 -0
  128. package/eject/files/spinner.ts +22 -0
  129. package/eject/files/switch.ts +34 -0
  130. package/eject/files/tabs.css +112 -0
  131. package/eject/files/tabs.ts +35 -0
  132. package/eject/files/text-field.css +229 -0
  133. package/eject/files/text-field.ts +48 -0
  134. package/eject/files/text.ts +38 -0
  135. package/eject/files/thumbnail.ts +51 -0
  136. package/eject/files/toast.ts +31 -0
  137. package/eject/files/tooltip.css +104 -0
  138. package/eject/files/tooltip.ts +21 -0
  139. package/eject/manifest.json +814 -0
  140. package/package.json +9 -4
package/dist/MediaCard.js CHANGED
@@ -1,17 +1,279 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { classes, MEDIA_CARD_PARTS, mediaCardContentClass, mediaCardIds, mediaCardThumbnailClass, rootPart, } from "@xds/core";
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { classes, MEDIA_CARD_PARTS, mediaCardContentClass, mediaCardIds, mediaCardThumbnailClass, rootPart } from "@xds/core";
3
3
  import { useId } from "react";
4
4
  import { useDefaults } from "./Defaults.js";
5
5
  import { Thumbnail } from "./Thumbnail.js";
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
7
  export function MediaCard(props) {
7
- const defaults = useDefaults("MediaCard");
8
- const { layout = defaults.layout ?? "vertical", src, alt = "", ratio = "16:9", badge, progress, title, meta = [], leading, action, onPress, className, style, } = props;
9
- const ids = mediaCardIds(useId(), meta);
10
- const part = onPress ? { "aria-hidden": true } : {};
11
- const horizontal = layout === "horizontal";
12
- const content = (_jsxs("div", { className: mediaCardContentClass({ horizontal, pressable: onPress !== undefined }), children: [_jsx("span", { ...part, className: mediaCardThumbnailClass(horizontal), children: _jsx(Thumbnail, { src: src, alt: alt, ratio: ratio, badge: badge, progress: progress }) }), _jsxs("div", { className: MEDIA_CARD_PARTS.body, children: [!horizontal && leading != null && (_jsx("span", { ...part, className: MEDIA_CARD_PARTS.leading, children: leading })), _jsxs("span", { ...part, className: MEDIA_CARD_PARTS.text, children: [_jsx("span", { id: ids.title, className: MEDIA_CARD_PARTS.title, children: title }), meta.map((line, index) => (_jsx("span", { id: ids.details[index], className: MEDIA_CARD_PARTS.meta, children: line }, index)))] }), action != null && _jsx("div", { className: MEDIA_CARD_PARTS.action, children: action })] })] }));
13
- if (!onPress) {
14
- return (_jsx("div", { role: "group", "aria-labelledby": ids.names, className: classes(rootPart("MediaCard"), MEDIA_CARD_PARTS.group, className), style: style, children: content }));
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];
15
238
  }
16
- return (_jsxs("div", { className: classes(rootPart("MediaCard"), MEDIA_CARD_PARTS.pressable, className), style: style, children: [_jsx("button", { type: "button", onClick: onPress, "aria-labelledby": ids.names, className: MEDIA_CARD_PARTS.button }), content] }));
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;
17
279
  }
package/dist/Menu.js CHANGED
@@ -1,68 +1,244 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { space } from "@xds/tokens";
3
- import { classes, firstMenuValue, keepListKeys, layoutRect, leaveEscapeToFields, menuItemClass, opensOnPress, } from "@xds/core";
3
+ import { classes, firstMenuValue, keepListKeys, layoutRect, leaveEscapeToFields, menuItemClass, opensOnPress } from "@xds/core";
4
4
  import * as menu from "@zag-js/menu";
5
- import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
5
+ import { normalizeProps, useMachine } from "@zag-js/react";
6
6
  import { useId, useRef } from "react";
7
7
  import { Icon } from "./Icon.js";
8
8
  import { useModalPopover } from "./modal-popover.js";
9
9
  import { Portal } from "./portal.js";
10
10
  import { usePresence } from "./presence.js";
11
- import { TriggerContext, useProvideTrigger } from "./trigger.js";
12
- export function Menu({ trigger, label, items, align = "start", className, style }) {
13
- const service = useMachine(menu.machine, {
14
- id: useId(),
15
- "aria-label": label,
16
- positioning: {
17
- placement: `bottom-${align}`,
18
- gutter: space[1],
19
- getAnchorRect: (anchor) => (anchor instanceof HTMLElement ? layoutRect(anchor) : null),
20
- },
21
- onSelect: (details) => {
22
- const item = items[Number(details.value)];
23
- if (item && item !== "separator")
24
- item.onSelect();
25
- },
26
- onEscapeKeyDown: leaveEscapeToFields,
27
- loopFocus: true,
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
28
134
  });
29
- const api = menu.connect(service, normalizeProps);
30
- const { onPointerDown: _onPointerDown, ...triggerProps } = api.getTriggerProps();
31
- const pressOpened = useRef(false);
32
- const provided = useProvideTrigger(mergeProps(triggerProps, {
33
- className: "xds-menu__trigger",
34
- onPointerDown: (event) => {
35
- pressOpened.current = opensOnPress(event) && !api.open;
36
- if (pressOpened.current)
37
- api.setOpen(true);
38
- },
39
- onClick: (event) => {
40
- const pointer = event.detail !== 0;
41
- if (pressOpened.current && pointer) {
42
- pressOpened.current = false;
43
- event.preventDefault();
44
- return;
45
- }
46
- if (pointer)
47
- return;
48
- requestAnimationFrame(() => {
49
- const now = menu.connect(service, normalizeProps);
50
- if (!now.open)
51
- return;
52
- const first = firstMenuValue(items);
53
- if (first !== undefined)
54
- now.setHighlightedValue(first);
55
- });
56
- },
57
- }));
58
- const positioner = useRef(null);
59
- const surface = useRef(null);
60
- useModalPopover(api.open, () => positioner.current);
61
- const present = usePresence(api.open, () => [surface.current]);
62
- const content = mergeProps(api.getContentProps(), {
63
- className: classes("xds-menu", className),
64
- style,
65
- onKeyDown: (event) => keepListKeys(event, surface.current, ".xds-menu__item:not([data-disabled])", (value) => api.setHighlightedValue(value)),
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
66
180
  });
67
- return (_jsxs(_Fragment, { children: [_jsx(TriggerContext, { value: provided, children: trigger }), _jsx(Portal, { children: _jsxs(TriggerContext, { value: null, children: [api.open && (_jsx("div", { className: "xds-menu__underlay", onMouseDown: (event) => event.preventDefault() })), _jsx("div", { ...api.getPositionerProps(), ref: positioner, className: "xds-menu__positioner", children: _jsx("div", { ...content, ref: surface, hidden: !present, children: items.map((item, index) => item === "separator" ? (_jsx("div", { ...api.getSeparatorProps(), className: "xds-menu__separator" }, index)) : (_jsxs("div", { ...api.getItemProps({ value: String(index), disabled: item.disabled }), className: menuItemClass(item.danger), children: [item.icon && (_jsx(Icon, { name: item.icon, size: "sm", className: "xds-menu__item-icon" })), _jsx("span", { className: "flex-1", children: item.label }), item.selected && _jsx(Icon, { name: "check", size: "sm", label: "Selected" })] }, index))) }) })] }) })] }));
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;
68
244
  }
@@ -1,6 +1,65 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { classes, progressBarClass, progressBarFillClass, progressPercent, rootPart } from "@xds/core";
1
3
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { classes, progressBarClass, progressBarFillClass, progressPercent, rootPart, } from "@xds/core";
3
- export function ProgressBar({ value, label, className, style }) {
4
- const percent = progressPercent(value);
5
- return (_jsx("div", { role: "progressbar", "aria-label": label, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": percent, className: classes(rootPart("ProgressBar"), progressBarClass, className), style: style, children: _jsx("div", { className: progressBarFillClass, style: { width: `${percent}%` } }) }));
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;
6
65
  }