@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/Select.js CHANGED
@@ -1,6 +1,6 @@
1
- import { 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, keepListKeys, selectOptionIds, } from "@xds/core";
3
+ import { classes, keepListKeys, selectOptionIds } from "@xds/core";
4
4
  import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
5
5
  import * as select from "@zag-js/select";
6
6
  import { useId, useMemo, useRef } from "react";
@@ -8,59 +8,311 @@ 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
- export function Select({ label, options, value, onChange, placeholder, description, error, name, disabled = false, className, style, }) {
12
- const id = useId();
13
- const valueId = `${id}-value`;
14
- const descriptionId = `${id}-description`;
15
- const errorId = `${id}-error`;
16
- const invalid = error !== undefined;
17
- const collection = useMemo(() => select.collection({
18
- items: [...options],
19
- itemToValue: (option) => option.value,
20
- itemToString: (option) => option.label,
21
- }), [options]);
22
- const service = useMachine(select.machine, {
23
- id,
24
- collection,
25
- value: value === undefined ? [] : [value],
26
- onValueChange: (details) => {
27
- const next = details.value[0];
28
- if (next !== undefined)
29
- onChange(next);
30
- },
31
- disabled,
32
- invalid,
33
- name,
34
- positioning: {
35
- placement: "bottom-start",
36
- gutter: space[1],
37
- sameWidth: true,
38
- overflowPadding: space[3],
39
- },
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ export function Select(t0) {
13
+ const $ = _c(33);
14
+ const {
15
+ label,
16
+ options,
17
+ value,
18
+ onChange,
19
+ placeholder,
20
+ description,
21
+ error,
22
+ name,
23
+ disabled: t1,
24
+ className,
25
+ style
26
+ } = t0;
27
+ const disabled = t1 === undefined ? false : t1;
28
+ const id = useId();
29
+ const valueId = `${id}-value`;
30
+ const descriptionId = `${id}-description`;
31
+ const errorId = `${id}-error`;
32
+ const invalid = error !== undefined;
33
+ let t2;
34
+ if ($[0] !== options) {
35
+ t2 = select.collection({
36
+ items: [...options],
37
+ itemToValue: _temp,
38
+ itemToString: _temp2
40
39
  });
41
- const api = select.connect(service, normalizeProps);
42
- const current = () => select.connect(service, normalizeProps);
43
- const { htmlFor: _for, ...labelProps } = api.getLabelProps();
44
- const { role: _role, "aria-invalid": _invalid, "aria-required": _required, onKeyDown: _onTriggerKeyDown, ...triggerProps } = api.getTriggerProps();
45
- const positioner = useRef(null);
46
- const surface = useRef(null);
47
- const { onKeyDown: _onContentKeyDown, ...contentProps } = api.getContentProps();
48
- const content = {
49
- ...contentProps,
50
- onKeyDown: (event) => {
51
- keepListKeys(event, surface.current, ".xds-select__item:not([data-disabled])", (row) => api.setHighlightedValue(row));
52
- current().getContentProps().onKeyDown?.(event);
53
- },
40
+ $[0] = options;
41
+ $[1] = t2;
42
+ } else {
43
+ t2 = $[1];
44
+ }
45
+ const collection = t2;
46
+ let t3;
47
+ if ($[2] !== value) {
48
+ t3 = value === undefined ? [] : [value];
49
+ $[2] = value;
50
+ $[3] = t3;
51
+ } else {
52
+ t3 = $[3];
53
+ }
54
+ let t4;
55
+ if ($[4] !== onChange) {
56
+ t4 = details => {
57
+ const next = details.value[0];
58
+ if (next !== undefined) {
59
+ onChange(next);
60
+ }
61
+ };
62
+ $[4] = onChange;
63
+ $[5] = t4;
64
+ } else {
65
+ t4 = $[5];
66
+ }
67
+ let t5;
68
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
69
+ t5 = {
70
+ placement: "bottom-start",
71
+ gutter: space[1],
72
+ sameWidth: true,
73
+ overflowPadding: space[3]
74
+ };
75
+ $[6] = t5;
76
+ } else {
77
+ t5 = $[6];
78
+ }
79
+ let t6;
80
+ if ($[7] !== collection || $[8] !== disabled || $[9] !== id || $[10] !== invalid || $[11] !== name || $[12] !== t3 || $[13] !== t4) {
81
+ t6 = {
82
+ id,
83
+ collection,
84
+ value: t3,
85
+ onValueChange: t4,
86
+ disabled,
87
+ invalid,
88
+ name,
89
+ positioning: t5
54
90
  };
55
- useModalPopover(api.open, () => positioner.current);
56
- const present = usePresence(api.open, () => [surface.current]);
57
- return (_jsxs("div", { ...mergeProps(api.getRootProps(), { className: classes("xds-select", className), style }), children: [_jsx("span", { ...labelProps, className: "xds-select__label", children: label }), _jsxs("button", { ...triggerProps, "aria-labelledby": `${valueId} ${labelProps.id}`, "aria-describedby": invalid ? errorId : description ? descriptionId : undefined, onKeyDown: (event) => {
58
- const now = current();
59
- if (!now.open && (event.key === "Home" || event.key === "End"))
60
- return;
61
- now.getTriggerProps().onKeyDown?.(event);
62
- }, type: "button", className: "xds-select__trigger", children: [_jsx("span", { ...api.getValueTextProps(), id: valueId, className: "xds-select__value", children: api.valueAsString || placeholder }), _jsx(Icon, { name: "chevrons-up-down", size: "sm", className: "text-xds-field-placeholder" })] }), (invalid || description) && (_jsx("div", { className: "xds-select__footer", children: invalid ? (_jsx("span", { id: errorId, className: "xds-select__error", children: error })) : (_jsx("span", { id: descriptionId, className: "xds-select__description", children: description })) })), _jsxs("select", { ...api.getHiddenSelectProps(), children: [_jsx("option", { value: "" }), options.map((option) => (_jsx("option", { value: option.value, children: option.label }, option.value)))] }), _jsxs(Portal, { children: [api.open && (_jsx("div", { className: "xds-select__underlay", onMouseDown: (event) => event.preventDefault() })), _jsx("div", { ...api.getPositionerProps(), ref: positioner, className: "xds-select__positioner", children: _jsx("div", { ...content, ref: surface, hidden: !present, className: "xds-select__content", children: _jsx("div", { ...api.getListProps(), className: "xds-select__list", children: collection.items.map((option, index) => {
63
- const ids = selectOptionIds(id, index);
64
- return (_jsxs("div", { ...api.getItemProps({ item: option }), "aria-labelledby": ids.label, "aria-describedby": option.description ? ids.description : undefined, className: "xds-select__item", children: [_jsxs("span", { className: "xds-select__item-words", children: [_jsx("span", { ...api.getItemTextProps({ item: option }), id: ids.label, className: "xds-select__item-label", children: option.label }), option.description && (_jsx("span", { id: ids.description, className: "xds-select__item-description", children: option.description }))] }), api.getItemState({ item: option }).selected && _jsx(Icon, { name: "check", size: "sm" })] }, option.value));
65
- }) }) }) })] })] }));
91
+ $[7] = collection;
92
+ $[8] = disabled;
93
+ $[9] = id;
94
+ $[10] = invalid;
95
+ $[11] = name;
96
+ $[12] = t3;
97
+ $[13] = t4;
98
+ $[14] = t6;
99
+ } else {
100
+ t6 = $[14];
101
+ }
102
+ const service = useMachine(select.machine, t6);
103
+ const api = select.connect(service, normalizeProps);
104
+ let t7;
105
+ if ($[15] !== service) {
106
+ t7 = () => select.connect(service, normalizeProps);
107
+ $[15] = service;
108
+ $[16] = t7;
109
+ } else {
110
+ t7 = $[16];
111
+ }
112
+ const current = t7;
113
+ const {
114
+ htmlFor: _for,
115
+ ...labelProps
116
+ } = api.getLabelProps();
117
+ const {
118
+ role: _role,
119
+ "aria-invalid": _invalid,
120
+ "aria-required": _required,
121
+ onKeyDown: _onTriggerKeyDown,
122
+ ...triggerProps
123
+ } = api.getTriggerProps();
124
+ const positioner = useRef(null);
125
+ const surface = useRef(null);
126
+ const {
127
+ onKeyDown: _onContentKeyDown,
128
+ ...contentProps
129
+ } = api.getContentProps();
130
+ const content = {
131
+ ...contentProps,
132
+ onKeyDown: event => {
133
+ keepListKeys(event, surface.current, ".xds-select__item:not([data-disabled])", row => api.setHighlightedValue(row));
134
+ current().getContentProps().onKeyDown?.(event);
135
+ }
136
+ };
137
+ let t8;
138
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
139
+ t8 = () => positioner.current;
140
+ $[17] = t8;
141
+ } else {
142
+ t8 = $[17];
143
+ }
144
+ useModalPopover(api.open, t8);
145
+ const present = usePresence(api.open, () => [surface.current]);
146
+ const t9 = mergeProps(api.getRootProps(), {
147
+ className: classes("xds-select", className),
148
+ style
149
+ });
150
+ let t10;
151
+ if ($[18] !== current) {
152
+ t10 = event_0 => {
153
+ const now = current();
154
+ if (!now.open && (event_0.key === "Home" || event_0.key === "End")) {
155
+ return;
156
+ }
157
+ now.getTriggerProps().onKeyDown?.(event_0);
158
+ };
159
+ $[18] = current;
160
+ $[19] = t10;
161
+ } else {
162
+ t10 = $[19];
163
+ }
164
+ let t11;
165
+ if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
166
+ t11 = /*#__PURE__*/_jsx(Icon, {
167
+ name: "chevrons-up-down",
168
+ size: "sm",
169
+ className: "text-xds-field-placeholder"
170
+ });
171
+ $[20] = t11;
172
+ } else {
173
+ t11 = $[20];
174
+ }
175
+ let t12;
176
+ if ($[21] !== description || $[22] !== descriptionId || $[23] !== error || $[24] !== errorId || $[25] !== invalid) {
177
+ t12 = (invalid || description) && /*#__PURE__*/_jsx("div", {
178
+ className: "xds-select__footer",
179
+ children: invalid ? /*#__PURE__*/_jsx("span", {
180
+ id: errorId,
181
+ className: "xds-select__error",
182
+ children: error
183
+ }) : /*#__PURE__*/_jsx("span", {
184
+ id: descriptionId,
185
+ className: "xds-select__description",
186
+ children: description
187
+ })
188
+ });
189
+ $[21] = description;
190
+ $[22] = descriptionId;
191
+ $[23] = error;
192
+ $[24] = errorId;
193
+ $[25] = invalid;
194
+ $[26] = t12;
195
+ } else {
196
+ t12 = $[26];
197
+ }
198
+ const t13 = api.getHiddenSelectProps();
199
+ let t14;
200
+ if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
201
+ t14 = /*#__PURE__*/_jsx("option", {
202
+ value: ""
203
+ });
204
+ $[27] = t14;
205
+ } else {
206
+ t14 = $[27];
207
+ }
208
+ let t15;
209
+ if ($[28] !== options) {
210
+ t15 = options.map(_temp3);
211
+ $[28] = options;
212
+ $[29] = t15;
213
+ } else {
214
+ t15 = $[29];
215
+ }
216
+ const t16 = api.getPositionerProps();
217
+ const t17 = api.getListProps();
218
+ const t18 = "xds-select__list";
219
+ const t19 = collection.items.map((option_2, index) => {
220
+ const ids = selectOptionIds(id, index);
221
+ return /*#__PURE__*/_jsxs("div", {
222
+ ...api.getItemProps({
223
+ item: option_2
224
+ }),
225
+ "aria-labelledby": ids.label,
226
+ "aria-describedby": option_2.description ? ids.description : undefined,
227
+ className: "xds-select__item",
228
+ children: [/*#__PURE__*/_jsxs("span", {
229
+ className: "xds-select__item-words",
230
+ children: [/*#__PURE__*/_jsx("span", {
231
+ ...api.getItemTextProps({
232
+ item: option_2
233
+ }),
234
+ id: ids.label,
235
+ className: "xds-select__item-label",
236
+ children: option_2.label
237
+ }), option_2.description && /*#__PURE__*/_jsx("span", {
238
+ id: ids.description,
239
+ className: "xds-select__item-description",
240
+ children: option_2.description
241
+ })]
242
+ }), api.getItemState({
243
+ item: option_2
244
+ }).selected && /*#__PURE__*/_jsx(Icon, {
245
+ name: "check",
246
+ size: "sm"
247
+ })]
248
+ }, option_2.value);
249
+ });
250
+ let t20;
251
+ if ($[30] !== t17 || $[31] !== t19) {
252
+ t20 = /*#__PURE__*/_jsx("div", {
253
+ ...t17,
254
+ className: t18,
255
+ children: t19
256
+ });
257
+ $[30] = t17;
258
+ $[31] = t19;
259
+ $[32] = t20;
260
+ } else {
261
+ t20 = $[32];
262
+ }
263
+ return /*#__PURE__*/_jsxs("div", {
264
+ ...t9,
265
+ children: [/*#__PURE__*/_jsx("span", {
266
+ ...labelProps,
267
+ className: "xds-select__label",
268
+ children: label
269
+ }), /*#__PURE__*/_jsxs("button", {
270
+ ...triggerProps,
271
+ "aria-labelledby": `${valueId} ${labelProps.id}`,
272
+ "aria-describedby": invalid ? errorId : description ? descriptionId : undefined,
273
+ onKeyDown: t10,
274
+ type: "button",
275
+ className: "xds-select__trigger",
276
+ children: [/*#__PURE__*/_jsx("span", {
277
+ ...api.getValueTextProps(),
278
+ id: valueId,
279
+ className: "xds-select__value",
280
+ children: api.valueAsString || placeholder
281
+ }), t11]
282
+ }), t12, /*#__PURE__*/_jsxs("select", {
283
+ ...t13,
284
+ children: [t14, t15]
285
+ }), /*#__PURE__*/_jsxs(Portal, {
286
+ children: [api.open && /*#__PURE__*/_jsx("div", {
287
+ className: "xds-select__underlay",
288
+ onMouseDown: _temp4
289
+ }), /*#__PURE__*/_jsx("div", {
290
+ ...t16,
291
+ ref: positioner,
292
+ className: "xds-select__positioner",
293
+ children: /*#__PURE__*/_jsx("div", {
294
+ ...content,
295
+ ref: surface,
296
+ hidden: !present,
297
+ className: "xds-select__content",
298
+ children: t20
299
+ })
300
+ })]
301
+ })]
302
+ });
303
+ }
304
+ function _temp4(event_1) {
305
+ return event_1.preventDefault();
306
+ }
307
+ function _temp3(option_1) {
308
+ return /*#__PURE__*/_jsx("option", {
309
+ value: option_1.value,
310
+ children: option_1.label
311
+ }, option_1.value);
312
+ }
313
+ function _temp2(option_0) {
314
+ return option_0.label;
315
+ }
316
+ function _temp(option) {
317
+ return option.value;
66
318
  }
package/dist/Sidebar.js CHANGED
@@ -1,27 +1,220 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { classes, rootPart, SIDEBAR_PARTS, sidebarClass, sidebarCount, sidebarIconClass, sidebarRailButtonClass, sidebarSectionClass, sidebarTitleClass, } from "@xds/core";
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { classes, rootPart, SIDEBAR_PARTS, sidebarClass, sidebarCount, sidebarIconClass, sidebarRailButtonClass, sidebarSectionClass, sidebarTitleClass } from "@xds/core";
3
3
  import { useId } from "react";
4
4
  import { Icon } from "./Icon.js";
5
5
  import { PlaceRow } from "./ListRow.js";
6
6
  import { TooltipBeside } from "./Tooltip.js";
7
7
  import { useTrigger } from "./trigger.js";
8
- export function Sidebar({ sections, value, onChange, label, collapsed = false, header, footer, className, style, }) {
9
- const id = useId();
10
- return (_jsxs("nav", { "aria-label": label, className: classes(rootPart("Sidebar"), sidebarClass(collapsed), className), style: style, children: [header != null && _jsx("div", { className: SIDEBAR_PARTS.edge, children: header }), _jsx("div", { className: SIDEBAR_PARTS.places, children: sections.map((section, index) => {
11
- const title = `${id}-${index}`;
12
- return (_jsxs("div", { className: sidebarSectionClass(index, collapsed), children: [section.title && (_jsx("p", { id: title, className: sidebarTitleClass(collapsed), children: section.title })), collapsed && index > 0 && _jsx("div", { "aria-hidden": "true", className: SIDEBAR_PARTS.rule }), _jsx("ul", { ...(section.title ? { "aria-labelledby": title } : {}), className: SIDEBAR_PARTS.list, children: section.items.map((item) => {
13
- const selected = item.value === value;
14
- const count = sidebarCount(item.count);
15
- return (_jsx("li", { className: SIDEBAR_PARTS.item, children: collapsed ? (_jsx(TooltipBeside, { label: item.label, children: _jsx(RailButton, { label: item.label, icon: item.icon, selected: selected, onPress: () => onChange(item.value) }) })) : (_jsx(PlaceRow, { compact: true, current: "page", selected: selected, onPress: () => onChange(item.value), title: item.label, leading: _jsx(Icon, { name: item.icon, size: "md", filled: selected, className: sidebarIconClass(selected) }), trailing: count !== undefined && (_jsx("span", { className: SIDEBAR_PARTS.count, children: count })) })) }, item.value));
16
- }) })] }, index));
17
- }) }), footer != null && _jsx("div", { className: SIDEBAR_PARTS.edge, children: footer })] }));
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ export function Sidebar(t0) {
10
+ const $ = _c(27);
11
+ const {
12
+ sections,
13
+ value,
14
+ onChange,
15
+ label,
16
+ collapsed: t1,
17
+ header,
18
+ footer,
19
+ className,
20
+ style
21
+ } = t0;
22
+ const collapsed = t1 === undefined ? false : t1;
23
+ const id = useId();
24
+ let t2;
25
+ if ($[0] !== className || $[1] !== collapsed) {
26
+ t2 = classes(rootPart("Sidebar"), sidebarClass(collapsed), className);
27
+ $[0] = className;
28
+ $[1] = collapsed;
29
+ $[2] = t2;
30
+ } else {
31
+ t2 = $[2];
32
+ }
33
+ let t3;
34
+ if ($[3] !== header) {
35
+ t3 = header != null && /*#__PURE__*/_jsx("div", {
36
+ className: SIDEBAR_PARTS.edge,
37
+ children: header
38
+ });
39
+ $[3] = header;
40
+ $[4] = t3;
41
+ } else {
42
+ t3 = $[4];
43
+ }
44
+ let t4;
45
+ if ($[5] !== collapsed || $[6] !== id || $[7] !== onChange || $[8] !== sections || $[9] !== value) {
46
+ let t5;
47
+ if ($[11] !== collapsed || $[12] !== id || $[13] !== onChange || $[14] !== value) {
48
+ t5 = (section, index) => {
49
+ const title = `${id}-${index}`;
50
+ return /*#__PURE__*/_jsxs("div", {
51
+ className: sidebarSectionClass(index, collapsed),
52
+ children: [section.title && /*#__PURE__*/_jsx("p", {
53
+ id: title,
54
+ className: sidebarTitleClass(collapsed),
55
+ children: section.title
56
+ }), collapsed && index > 0 && /*#__PURE__*/_jsx("div", {
57
+ "aria-hidden": "true",
58
+ className: SIDEBAR_PARTS.rule
59
+ }), /*#__PURE__*/_jsx("ul", {
60
+ ...(section.title ? {
61
+ "aria-labelledby": title
62
+ } : {}),
63
+ className: SIDEBAR_PARTS.list,
64
+ children: section.items.map(item => {
65
+ const selected = item.value === value;
66
+ const count = sidebarCount(item.count);
67
+ return /*#__PURE__*/_jsx("li", {
68
+ className: SIDEBAR_PARTS.item,
69
+ children: collapsed ? /*#__PURE__*/_jsx(TooltipBeside, {
70
+ label: item.label,
71
+ children: /*#__PURE__*/_jsx(RailButton, {
72
+ label: item.label,
73
+ icon: item.icon,
74
+ selected: selected,
75
+ onPress: () => onChange(item.value)
76
+ })
77
+ }) : /*#__PURE__*/_jsx(PlaceRow, {
78
+ compact: true,
79
+ current: "page",
80
+ selected: selected,
81
+ onPress: () => onChange(item.value),
82
+ title: item.label,
83
+ leading: /*#__PURE__*/_jsx(Icon, {
84
+ name: item.icon,
85
+ size: "md",
86
+ filled: selected,
87
+ className: sidebarIconClass(selected)
88
+ }),
89
+ trailing: count !== undefined && /*#__PURE__*/_jsx("span", {
90
+ className: SIDEBAR_PARTS.count,
91
+ children: count
92
+ })
93
+ })
94
+ }, item.value);
95
+ })
96
+ })]
97
+ }, index);
98
+ };
99
+ $[11] = collapsed;
100
+ $[12] = id;
101
+ $[13] = onChange;
102
+ $[14] = value;
103
+ $[15] = t5;
104
+ } else {
105
+ t5 = $[15];
106
+ }
107
+ t4 = sections.map(t5);
108
+ $[5] = collapsed;
109
+ $[6] = id;
110
+ $[7] = onChange;
111
+ $[8] = sections;
112
+ $[9] = value;
113
+ $[10] = t4;
114
+ } else {
115
+ t4 = $[10];
116
+ }
117
+ let t5;
118
+ if ($[16] !== t4) {
119
+ t5 = /*#__PURE__*/_jsx("div", {
120
+ className: SIDEBAR_PARTS.places,
121
+ children: t4
122
+ });
123
+ $[16] = t4;
124
+ $[17] = t5;
125
+ } else {
126
+ t5 = $[17];
127
+ }
128
+ let t6;
129
+ if ($[18] !== footer) {
130
+ t6 = footer != null && /*#__PURE__*/_jsx("div", {
131
+ className: SIDEBAR_PARTS.edge,
132
+ children: footer
133
+ });
134
+ $[18] = footer;
135
+ $[19] = t6;
136
+ } else {
137
+ t6 = $[19];
138
+ }
139
+ let t7;
140
+ if ($[20] !== label || $[21] !== style || $[22] !== t2 || $[23] !== t3 || $[24] !== t5 || $[25] !== t6) {
141
+ t7 = /*#__PURE__*/_jsxs("nav", {
142
+ "aria-label": label,
143
+ className: t2,
144
+ style: style,
145
+ children: [t3, t5, t6]
146
+ });
147
+ $[20] = label;
148
+ $[21] = style;
149
+ $[22] = t2;
150
+ $[23] = t3;
151
+ $[24] = t5;
152
+ $[25] = t6;
153
+ $[26] = t7;
154
+ } else {
155
+ t7 = $[26];
156
+ }
157
+ return t7;
18
158
  }
19
- function RailButton({ label, icon, selected, onPress, }) {
20
- const attributes = useTrigger({
21
- className: sidebarRailButtonClass(selected),
22
- "aria-label": label,
23
- "aria-current": selected ? "page" : undefined,
24
- onClick: onPress,
159
+ function RailButton(t0) {
160
+ const $ = _c(13);
161
+ const {
162
+ label,
163
+ icon,
164
+ selected,
165
+ onPress
166
+ } = t0;
167
+ let t1;
168
+ if ($[0] !== selected) {
169
+ t1 = sidebarRailButtonClass(selected);
170
+ $[0] = selected;
171
+ $[1] = t1;
172
+ } else {
173
+ t1 = $[1];
174
+ }
175
+ const t2 = selected ? "page" : undefined;
176
+ let t3;
177
+ if ($[2] !== label || $[3] !== onPress || $[4] !== t1 || $[5] !== t2) {
178
+ t3 = {
179
+ className: t1,
180
+ "aria-label": label,
181
+ "aria-current": t2,
182
+ onClick: onPress
183
+ };
184
+ $[2] = label;
185
+ $[3] = onPress;
186
+ $[4] = t1;
187
+ $[5] = t2;
188
+ $[6] = t3;
189
+ } else {
190
+ t3 = $[6];
191
+ }
192
+ const attributes = useTrigger(t3);
193
+ let t4;
194
+ if ($[7] !== icon || $[8] !== selected) {
195
+ t4 = /*#__PURE__*/_jsx(Icon, {
196
+ name: icon,
197
+ size: "md",
198
+ filled: selected
199
+ });
200
+ $[7] = icon;
201
+ $[8] = selected;
202
+ $[9] = t4;
203
+ } else {
204
+ t4 = $[9];
205
+ }
206
+ let t5;
207
+ if ($[10] !== attributes || $[11] !== t4) {
208
+ t5 = /*#__PURE__*/_jsx("button", {
209
+ ...attributes,
210
+ type: "button",
211
+ children: t4
25
212
  });
26
- return (_jsx("button", { ...attributes, type: "button", children: _jsx(Icon, { name: icon, size: "md", filled: selected }) }));
213
+ $[10] = attributes;
214
+ $[11] = t4;
215
+ $[12] = t5;
216
+ } else {
217
+ t5 = $[12];
218
+ }
219
+ return t5;
27
220
  }
package/dist/Skeleton.js CHANGED
@@ -1,8 +1,64 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { classes, rootPart, skeletonClass, skeletonSize, } from "@xds/core";
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { classes, rootPart, skeletonClass, skeletonSize } from "@xds/core";
3
3
  import { useDefaults } from "./Defaults.js";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
4
5
  export function Skeleton(props) {
5
- const defaults = useDefaults("Skeleton");
6
- const { shape = defaults.shape, width, height, className, style } = props;
7
- return (_jsx("span", { "aria-hidden": "true", className: classes(rootPart("Skeleton"), skeletonClass(shape), className), style: { ...skeletonSize({ shape, width, height }), ...style } }));
6
+ const $ = _c(13);
7
+ const defaults = useDefaults("Skeleton");
8
+ const {
9
+ width,
10
+ height,
11
+ className,
12
+ style
13
+ } = props;
14
+ const shape = props.shape ?? defaults.shape;
15
+ let t0;
16
+ if ($[0] !== className || $[1] !== shape) {
17
+ t0 = classes(rootPart("Skeleton"), skeletonClass(shape), className);
18
+ $[0] = className;
19
+ $[1] = shape;
20
+ $[2] = t0;
21
+ } else {
22
+ t0 = $[2];
23
+ }
24
+ let t1;
25
+ if ($[3] !== height || $[4] !== shape || $[5] !== width) {
26
+ t1 = skeletonSize({
27
+ shape,
28
+ width,
29
+ height
30
+ });
31
+ $[3] = height;
32
+ $[4] = shape;
33
+ $[5] = width;
34
+ $[6] = t1;
35
+ } else {
36
+ t1 = $[6];
37
+ }
38
+ let t2;
39
+ if ($[7] !== style || $[8] !== t1) {
40
+ t2 = {
41
+ ...t1,
42
+ ...style
43
+ };
44
+ $[7] = style;
45
+ $[8] = t1;
46
+ $[9] = t2;
47
+ } else {
48
+ t2 = $[9];
49
+ }
50
+ let t3;
51
+ if ($[10] !== t0 || $[11] !== t2) {
52
+ t3 = /*#__PURE__*/_jsx("span", {
53
+ "aria-hidden": "true",
54
+ className: t0,
55
+ style: t2
56
+ });
57
+ $[10] = t0;
58
+ $[11] = t2;
59
+ $[12] = t3;
60
+ } else {
61
+ t3 = $[12];
62
+ }
63
+ return t3;
8
64
  }