@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
@@ -1,5 +1,5 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { classes, DATE_PICKER_NAV_CLASS, dateRangeMachineProps, datePickerContentAttrs, datePickerIds, datePickerLocale, datePickerTriggerAttrs, endRangeChoiceOnClose, focusOpeningDay, formatRange, keepCalendarFocus, keepDayFocused, keepRangePreview, rangeDayClick, rangeGridKeyDown, rangeMonths, rangeMonthViews, rangeSummary, shownRange, } from "@xds/core";
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { classes, DATE_PICKER_NAV_CLASS, dateRangeMachineProps, datePickerContentAttrs, datePickerIds, datePickerLocale, datePickerTriggerAttrs, endRangeChoiceOnClose, focusOpeningDay, formatRange, keepCalendarFocus, keepDayFocused, keepRangePreview, rangeDayClick, rangeGridKeyDown, rangeMonths, rangeMonthViews, rangeSummary, shownRange } from "@xds/core";
3
3
  import * as datePicker from "@zag-js/date-picker";
4
4
  import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
5
5
  import { useEffect, useId, useRef, useState } from "react";
@@ -7,42 +7,364 @@ import { Icon } from "./Icon.js";
7
7
  import { useModalPopover } from "./modal-popover.js";
8
8
  import { Portal } from "./portal.js";
9
9
  import { usePresence } from "./presence.js";
10
- export function DateRangePicker({ onChange, className, style, ...props }) {
11
- const { label, value, placeholder, description, error, startName, endName } = props;
12
- const id = useId();
13
- const ids = datePickerIds(id);
14
- const locale = datePickerLocale();
15
- const [draft, setDraft] = useState(null);
16
- const [months, setMonths] = useState(1);
17
- const shown = shownRange(value, draft);
18
- const service = useMachine(datePicker.machine, dateRangeMachineProps(props, shown, { id, locale, months, onDraft: setDraft, onChange }));
19
- const api = datePicker.connect(service, normalizeProps);
20
- const trigger = api.getTriggerProps();
21
- const positioner = useRef(null);
22
- const surface = useRef(null);
23
- useModalPopover(api.open, () => positioner.current);
24
- const present = usePresence(api.open, () => [surface.current]);
25
- const focused = api.focusedValue.toString();
26
- const month = api.visibleRange.start.toString();
27
- useEffect(() => keepDayFocused(api.open, surface.current), [api.open, focused, month]);
28
- useEffect(() => endRangeChoiceOnClose(service, api.open), [api.open]);
29
- useEffect(() => keepRangePreview(service, shown, api.open), [focused]);
30
- const summary = rangeSummary(shown, props, locale);
31
- const invalid = error !== undefined;
32
- return (_jsxs("div", { ...mergeProps(api.getRootProps(), {
33
- className: classes("xds-date-picker xds-date-range-picker", className),
34
- style,
35
- }), children: [_jsx("span", { id: ids.label, className: "xds-date-picker__label", children: label }), _jsx("div", { ...api.getControlProps(), className: "xds-date-picker__control", children: _jsxs("button", { ...trigger, ...datePickerTriggerAttrs(props, ids), type: "button", onClick: (event) => {
36
- if (!api.open)
37
- setMonths(rangeMonths());
38
- focusOpeningDay(api, { ...props, value: value?.start });
39
- trigger.onClick?.(event);
40
- }, className: "xds-date-picker__trigger", children: [_jsx("span", { id: ids.value, className: "xds-date-picker__value", children: value === undefined ? placeholder : formatRange(value, locale) }), _jsx(Icon, { name: "calendar", size: "sm", className: "text-xds-field-placeholder" })] }) }), (invalid || description) && (_jsx("div", { className: "xds-date-picker__footer", children: invalid ? (_jsx("span", { id: ids.error, className: "xds-date-picker__error", children: error })) : (_jsx("span", { id: ids.description, className: "xds-date-picker__description", children: description })) })), startName !== undefined && (_jsx("input", { type: "hidden", name: startName, value: value?.start ?? "" })), endName !== undefined && _jsx("input", { type: "hidden", name: endName, value: value?.end ?? "" }), _jsxs(Portal, { children: [api.open && (_jsx("div", { className: "xds-date-picker__underlay", onMouseDown: (event) => event.preventDefault() })), _jsx("div", { ...api.getPositionerProps(), ref: positioner, className: "xds-date-picker__positioner", children: _jsxs("div", { ...api.getContentProps(), ...datePickerContentAttrs(ids), ref: surface, hidden: !present, onKeyDown: (event) => keepCalendarFocus(event, surface.current), className: "xds-date-picker__content xds-date-range-picker__content", children: [_jsxs("div", { className: "xds-date-range-picker__summary", "aria-live": "polite", children: [_jsx("span", { children: summary.start }), _jsx("span", { children: summary.end })] }), _jsx("div", { className: "xds-date-range-picker__months", children: rangeMonthViews(api, months).map((view) => {
41
- const table = api.getTableProps({ view: "day", id: view.table.id });
42
- return (_jsxs("div", { className: "xds-date-range-picker__month", children: [_jsxs("div", { className: "xds-date-picker__header", children: [view.index === 0 ? (_jsx("button", { ...api.getPreviousTriggerProps(), type: "button", className: DATE_PICKER_NAV_CLASS, children: _jsx(Icon, { name: "chevron-left", size: "sm" }) })) : (_jsx("span", { className: "xds-date-range-picker__nav-space" })), _jsx("span", { ...api.getRangeTextProps(), className: "xds-date-picker__heading", children: view.name }), view.index === months - 1 ? (_jsx("button", { ...api.getNextTriggerProps(), type: "button", className: DATE_PICKER_NAV_CLASS, children: _jsx(Icon, { name: "chevron-right", size: "sm" }) })) : (_jsx("span", { className: "xds-date-range-picker__nav-space" }))] }), _jsxs("table", { ...table, ...view.table, onKeyDown: (event) => rangeGridKeyDown(event, api, shown, props, table.onKeyDown), className: "xds-date-picker__grid", children: [_jsx("thead", { ...api.getTableHeadProps({ view: "day" }), children: _jsx("tr", { ...api.getTableRowProps({ view: "day" }), children: api.weekDays.map((weekDay) => (_jsx("th", { scope: "col", className: "xds-date-picker__weekday", children: weekDay.narrow }, weekDay.long))) }) }), _jsx("tbody", { ...api.getTableBodyProps({ view: "day" }), children: view.weeks.map((week) => (_jsx("tr", { ...api.getTableRowProps({ view: "day" }), children: week.map((date) => {
43
- const cell = { value: date, visibleRange: view.visibleRange };
44
- const day = api.getDayTableCellTriggerProps(cell);
45
- return (_jsx("td", { ...api.getDayTableCellProps(cell), className: "xds-date-picker__cell", children: _jsx("div", { ...day, onClick: (event) => rangeDayClick(event, api, shown, props, date, view.visibleRange, day.onClick), className: "xds-date-picker__day", children: date.day }) }, date.toString()));
46
- }) }, week[0]?.toString()))) })] })] }, view.index));
47
- }) })] }) })] })] }));
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ export function DateRangePicker(t0) {
12
+ const $ = _c(39);
13
+ const {
14
+ onChange,
15
+ className,
16
+ style,
17
+ ...props
18
+ } = t0;
19
+ const {
20
+ label,
21
+ value,
22
+ placeholder,
23
+ description,
24
+ error,
25
+ startName,
26
+ endName
27
+ } = props;
28
+ const id = useId();
29
+ const ids = datePickerIds(id);
30
+ const locale = datePickerLocale();
31
+ const [draft, setDraft] = useState(null);
32
+ const [months, setMonths] = useState(1);
33
+ const shown = shownRange(value, draft);
34
+ const service = useMachine(datePicker.machine, dateRangeMachineProps(props, shown, {
35
+ id,
36
+ locale,
37
+ months,
38
+ onDraft: setDraft,
39
+ onChange
40
+ }));
41
+ const api = datePicker.connect(service, normalizeProps);
42
+ const trigger = api.getTriggerProps();
43
+ const positioner = useRef(null);
44
+ const surface = useRef(null);
45
+ let t1;
46
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
47
+ t1 = () => positioner.current;
48
+ $[0] = t1;
49
+ } else {
50
+ t1 = $[0];
51
+ }
52
+ useModalPopover(api.open, t1);
53
+ let t2;
54
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
55
+ t2 = () => [surface.current];
56
+ $[1] = t2;
57
+ } else {
58
+ t2 = $[1];
59
+ }
60
+ const present = usePresence(api.open, t2);
61
+ const focused = api.focusedValue.toString();
62
+ const month = api.visibleRange.start.toString();
63
+ useEffect(() => keepDayFocused(api.open, surface.current), [api.open, focused, month]);
64
+ let t3;
65
+ if ($[2] !== api) {
66
+ t3 = [api.open];
67
+ $[2] = api;
68
+ $[3] = t3;
69
+ } else {
70
+ t3 = $[3];
71
+ }
72
+ useEffect(() => endRangeChoiceOnClose(service, api.open), t3);
73
+ useEffect(() => keepRangePreview(service, shown, api.open), [focused]);
74
+ const summary = rangeSummary(shown, props, locale);
75
+ const invalid = error !== undefined;
76
+ const t4 = mergeProps(api.getRootProps(), {
77
+ className: classes("xds-date-picker xds-date-range-picker", className),
78
+ style
79
+ });
80
+ let t5;
81
+ if ($[4] !== api) {
82
+ t5 = api.getControlProps();
83
+ $[4] = api;
84
+ $[5] = t5;
85
+ } else {
86
+ t5 = $[5];
87
+ }
88
+ let t6;
89
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
90
+ t6 = /*#__PURE__*/_jsx(Icon, {
91
+ name: "calendar",
92
+ size: "sm",
93
+ className: "text-xds-field-placeholder"
94
+ });
95
+ $[6] = t6;
96
+ } else {
97
+ t6 = $[6];
98
+ }
99
+ const T0 = Portal;
100
+ const t7 = api.open && /*#__PURE__*/_jsx("div", {
101
+ className: "xds-date-picker__underlay",
102
+ onMouseDown: _temp
103
+ });
104
+ let t8;
105
+ if ($[7] !== api) {
106
+ t8 = api.getPositionerProps();
107
+ $[7] = api;
108
+ $[8] = t8;
109
+ } else {
110
+ t8 = $[8];
111
+ }
112
+ const t9 = "xds-date-picker__positioner";
113
+ let t10;
114
+ if ($[9] !== api) {
115
+ t10 = api.getContentProps();
116
+ $[9] = api;
117
+ $[10] = t10;
118
+ } else {
119
+ t10 = $[10];
120
+ }
121
+ const t11 = datePickerContentAttrs(ids);
122
+ const t12 = !present;
123
+ let t13;
124
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
125
+ t13 = event_1 => keepCalendarFocus(event_1, surface.current);
126
+ $[11] = t13;
127
+ } else {
128
+ t13 = $[11];
129
+ }
130
+ let t14;
131
+ if ($[12] !== summary.start) {
132
+ t14 = /*#__PURE__*/_jsx("span", {
133
+ children: summary.start
134
+ });
135
+ $[12] = summary.start;
136
+ $[13] = t14;
137
+ } else {
138
+ t14 = $[13];
139
+ }
140
+ let t15;
141
+ if ($[14] !== summary.end) {
142
+ t15 = /*#__PURE__*/_jsx("span", {
143
+ children: summary.end
144
+ });
145
+ $[14] = summary.end;
146
+ $[15] = t15;
147
+ } else {
148
+ t15 = $[15];
149
+ }
150
+ let t16;
151
+ if ($[16] !== t14 || $[17] !== t15) {
152
+ t16 = /*#__PURE__*/_jsxs("div", {
153
+ className: "xds-date-range-picker__summary",
154
+ "aria-live": "polite",
155
+ children: [t14, t15]
156
+ });
157
+ $[16] = t14;
158
+ $[17] = t15;
159
+ $[18] = t16;
160
+ } else {
161
+ t16 = $[18];
162
+ }
163
+ let t17;
164
+ if ($[19] !== api || $[20] !== months || $[21] !== props || $[22] !== shown) {
165
+ t17 = rangeMonthViews(api, months).map(view => {
166
+ const table = api.getTableProps({
167
+ view: "day",
168
+ id: view.table.id
169
+ });
170
+ return /*#__PURE__*/_jsxs("div", {
171
+ className: "xds-date-range-picker__month",
172
+ children: [/*#__PURE__*/_jsxs("div", {
173
+ className: "xds-date-picker__header",
174
+ children: [view.index === 0 ? /*#__PURE__*/_jsx("button", {
175
+ ...api.getPreviousTriggerProps(),
176
+ type: "button",
177
+ className: DATE_PICKER_NAV_CLASS,
178
+ children: /*#__PURE__*/_jsx(Icon, {
179
+ name: "chevron-left",
180
+ size: "sm"
181
+ })
182
+ }) : /*#__PURE__*/_jsx("span", {
183
+ className: "xds-date-range-picker__nav-space"
184
+ }), /*#__PURE__*/_jsx("span", {
185
+ ...api.getRangeTextProps(),
186
+ className: "xds-date-picker__heading",
187
+ children: view.name
188
+ }), view.index === months - 1 ? /*#__PURE__*/_jsx("button", {
189
+ ...api.getNextTriggerProps(),
190
+ type: "button",
191
+ className: DATE_PICKER_NAV_CLASS,
192
+ children: /*#__PURE__*/_jsx(Icon, {
193
+ name: "chevron-right",
194
+ size: "sm"
195
+ })
196
+ }) : /*#__PURE__*/_jsx("span", {
197
+ className: "xds-date-range-picker__nav-space"
198
+ })]
199
+ }), /*#__PURE__*/_jsxs("table", {
200
+ ...table,
201
+ ...view.table,
202
+ onKeyDown: event_2 => rangeGridKeyDown(event_2, api, shown, props, table.onKeyDown),
203
+ className: "xds-date-picker__grid",
204
+ children: [/*#__PURE__*/_jsx("thead", {
205
+ ...api.getTableHeadProps({
206
+ view: "day"
207
+ }),
208
+ children: /*#__PURE__*/_jsx("tr", {
209
+ ...api.getTableRowProps({
210
+ view: "day"
211
+ }),
212
+ children: api.weekDays.map(_temp2)
213
+ })
214
+ }), /*#__PURE__*/_jsx("tbody", {
215
+ ...api.getTableBodyProps({
216
+ view: "day"
217
+ }),
218
+ children: view.weeks.map(week => /*#__PURE__*/_jsx("tr", {
219
+ ...api.getTableRowProps({
220
+ view: "day"
221
+ }),
222
+ children: week.map(date => {
223
+ const cell = {
224
+ value: date,
225
+ visibleRange: view.visibleRange
226
+ };
227
+ const day = api.getDayTableCellTriggerProps(cell);
228
+ return /*#__PURE__*/_jsx("td", {
229
+ ...api.getDayTableCellProps(cell),
230
+ className: "xds-date-picker__cell",
231
+ children: /*#__PURE__*/_jsx("div", {
232
+ ...day,
233
+ onClick: event_3 => rangeDayClick(event_3, api, shown, props, date, view.visibleRange, day.onClick),
234
+ className: "xds-date-picker__day",
235
+ children: date.day
236
+ })
237
+ }, date.toString());
238
+ })
239
+ }, week[0]?.toString()))
240
+ })]
241
+ })]
242
+ }, view.index);
243
+ });
244
+ $[19] = api;
245
+ $[20] = months;
246
+ $[21] = props;
247
+ $[22] = shown;
248
+ $[23] = t17;
249
+ } else {
250
+ t17 = $[23];
251
+ }
252
+ let t18;
253
+ if ($[24] !== t17) {
254
+ t18 = /*#__PURE__*/_jsx("div", {
255
+ className: "xds-date-range-picker__months",
256
+ children: t17
257
+ });
258
+ $[24] = t17;
259
+ $[25] = t18;
260
+ } else {
261
+ t18 = $[25];
262
+ }
263
+ let t19;
264
+ if ($[26] !== t10 || $[27] !== t11 || $[28] !== t12 || $[29] !== t16 || $[30] !== t18) {
265
+ t19 = /*#__PURE__*/_jsxs("div", {
266
+ ...t10,
267
+ ...t11,
268
+ ref: surface,
269
+ hidden: t12,
270
+ onKeyDown: t13,
271
+ className: "xds-date-picker__content xds-date-range-picker__content",
272
+ children: [t16, t18]
273
+ });
274
+ $[26] = t10;
275
+ $[27] = t11;
276
+ $[28] = t12;
277
+ $[29] = t16;
278
+ $[30] = t18;
279
+ $[31] = t19;
280
+ } else {
281
+ t19 = $[31];
282
+ }
283
+ let t20;
284
+ if ($[32] !== t19 || $[33] !== t8) {
285
+ t20 = /*#__PURE__*/_jsx("div", {
286
+ ...t8,
287
+ ref: positioner,
288
+ className: t9,
289
+ children: t19
290
+ });
291
+ $[32] = t19;
292
+ $[33] = t8;
293
+ $[34] = t20;
294
+ } else {
295
+ t20 = $[34];
296
+ }
297
+ let t21;
298
+ if ($[35] !== T0 || $[36] !== t20 || $[37] !== t7) {
299
+ t21 = /*#__PURE__*/_jsxs(T0, {
300
+ children: [t7, t20]
301
+ });
302
+ $[35] = T0;
303
+ $[36] = t20;
304
+ $[37] = t7;
305
+ $[38] = t21;
306
+ } else {
307
+ t21 = $[38];
308
+ }
309
+ return /*#__PURE__*/_jsxs("div", {
310
+ ...t4,
311
+ children: [/*#__PURE__*/_jsx("span", {
312
+ id: ids.label,
313
+ className: "xds-date-picker__label",
314
+ children: label
315
+ }), /*#__PURE__*/_jsx("div", {
316
+ ...t5,
317
+ className: "xds-date-picker__control",
318
+ children: /*#__PURE__*/_jsxs("button", {
319
+ ...trigger,
320
+ ...datePickerTriggerAttrs(props, ids),
321
+ type: "button",
322
+ onClick: event => {
323
+ if (!api.open) {
324
+ setMonths(rangeMonths());
325
+ }
326
+ focusOpeningDay(api, {
327
+ ...props,
328
+ value: value?.start
329
+ });
330
+ trigger.onClick?.(event);
331
+ },
332
+ className: "xds-date-picker__trigger",
333
+ children: [/*#__PURE__*/_jsx("span", {
334
+ id: ids.value,
335
+ className: "xds-date-picker__value",
336
+ children: value === undefined ? placeholder : formatRange(value, locale)
337
+ }), t6]
338
+ })
339
+ }), (invalid || description) && /*#__PURE__*/_jsx("div", {
340
+ className: "xds-date-picker__footer",
341
+ children: invalid ? /*#__PURE__*/_jsx("span", {
342
+ id: ids.error,
343
+ className: "xds-date-picker__error",
344
+ children: error
345
+ }) : /*#__PURE__*/_jsx("span", {
346
+ id: ids.description,
347
+ className: "xds-date-picker__description",
348
+ children: description
349
+ })
350
+ }), startName !== undefined && /*#__PURE__*/_jsx("input", {
351
+ type: "hidden",
352
+ name: startName,
353
+ value: value?.start ?? ""
354
+ }), endName !== undefined && /*#__PURE__*/_jsx("input", {
355
+ type: "hidden",
356
+ name: endName,
357
+ value: value?.end ?? ""
358
+ }), t21]
359
+ });
360
+ }
361
+ function _temp2(weekDay) {
362
+ return /*#__PURE__*/_jsx("th", {
363
+ scope: "col",
364
+ className: "xds-date-picker__weekday",
365
+ children: weekDay.narrow
366
+ }, weekDay.long);
367
+ }
368
+ function _temp(event_0) {
369
+ return event_0.preventDefault();
48
370
  }
package/dist/Defaults.js CHANGED
@@ -1,13 +1,48 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { mergeDefaults } from "@xds/core";
3
3
  import { createContext, useContext, useMemo } from "react";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
4
5
  const DefaultsContext = createContext({});
5
- export function Defaults({ value, children }) {
6
- const outer = useContext(DefaultsContext);
7
- const key = JSON.stringify(value);
8
- const merged = useMemo(() => mergeDefaults(outer, value), [outer, key]);
9
- return _jsx(DefaultsContext, { value: merged, children: children });
6
+ export function Defaults(t0) {
7
+ const $ = _c(8);
8
+ const {
9
+ value,
10
+ children
11
+ } = t0;
12
+ const outer = useContext(DefaultsContext);
13
+ let t1;
14
+ if ($[0] !== value) {
15
+ t1 = JSON.stringify(value);
16
+ $[0] = value;
17
+ $[1] = t1;
18
+ } else {
19
+ t1 = $[1];
20
+ }
21
+ const key = t1;
22
+ let t2;
23
+ if ($[2] !== key || $[3] !== outer) {
24
+ t2 = mergeDefaults(outer, JSON.parse(key));
25
+ $[2] = key;
26
+ $[3] = outer;
27
+ $[4] = t2;
28
+ } else {
29
+ t2 = $[4];
30
+ }
31
+ const merged = t2;
32
+ let t3;
33
+ if ($[5] !== children || $[6] !== merged) {
34
+ t3 = /*#__PURE__*/_jsx(DefaultsContext, {
35
+ value: merged,
36
+ children: children
37
+ });
38
+ $[5] = children;
39
+ $[6] = merged;
40
+ $[7] = t3;
41
+ } else {
42
+ t3 = $[7];
43
+ }
44
+ return t3;
10
45
  }
11
46
  export function useDefaults(name) {
12
- return useContext(DefaultsContext)[name] ?? {};
47
+ return useContext(DefaultsContext)[name] ?? {};
13
48
  }
package/dist/Dialog.js CHANGED
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { classes, leaveEscapeToFields } from "@xds/core";
3
3
  import * as dialog from "@zag-js/dialog";
4
4
  import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
@@ -6,28 +6,132 @@ import { useId, useRef } from "react";
6
6
  import { Portal } from "./portal.js";
7
7
  import { usePresence } from "./presence.js";
8
8
  import { TriggerContext } from "./trigger.js";
9
- export function Dialog({ open, onClose, title, description, children, actions, dismissible = true, className, style, }) {
10
- const backdrop = useRef(null);
11
- const positioner = useRef(null);
12
- const content = useRef(null);
13
- const service = useMachine(dialog.machine, {
14
- id: useId(),
15
- open,
16
- onOpenChange: (details) => {
17
- if (!details.open)
18
- onClose();
19
- },
20
- closeOnEscape: dismissible,
21
- closeOnInteractOutside: dismissible,
22
- onEscapeKeyDown: leaveEscapeToFields,
23
- initialFocusEl: () => content.current,
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ export function Dialog(t0) {
11
+ const $ = _c(13);
12
+ const {
13
+ open,
14
+ onClose,
15
+ title,
16
+ description,
17
+ children,
18
+ actions,
19
+ dismissible: t1,
20
+ className,
21
+ style
22
+ } = t0;
23
+ const dismissible = t1 === undefined ? true : t1;
24
+ const backdrop = useRef(null);
25
+ const positioner = useRef(null);
26
+ const content = useRef(null);
27
+ const t2 = useId();
28
+ let t3;
29
+ if ($[0] !== onClose) {
30
+ t3 = details => {
31
+ if (!details.open) {
32
+ onClose();
33
+ }
34
+ };
35
+ $[0] = onClose;
36
+ $[1] = t3;
37
+ } else {
38
+ t3 = $[1];
39
+ }
40
+ let t4;
41
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
42
+ t4 = () => content.current;
43
+ $[2] = t4;
44
+ } else {
45
+ t4 = $[2];
46
+ }
47
+ let t5;
48
+ if ($[3] !== dismissible || $[4] !== open || $[5] !== t2 || $[6] !== t3) {
49
+ t5 = {
50
+ id: t2,
51
+ open,
52
+ onOpenChange: t3,
53
+ closeOnEscape: dismissible,
54
+ closeOnInteractOutside: dismissible,
55
+ onEscapeKeyDown: leaveEscapeToFields,
56
+ initialFocusEl: t4
57
+ };
58
+ $[3] = dismissible;
59
+ $[4] = open;
60
+ $[5] = t2;
61
+ $[6] = t3;
62
+ $[7] = t5;
63
+ } else {
64
+ t5 = $[7];
65
+ }
66
+ const service = useMachine(dialog.machine, t5);
67
+ const api = dialog.connect(service, normalizeProps);
68
+ let t6;
69
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
70
+ t6 = () => [backdrop.current, positioner.current];
71
+ $[8] = t6;
72
+ } else {
73
+ t6 = $[8];
74
+ }
75
+ const present = usePresence(api.open, t6);
76
+ if (!present) {
77
+ return null;
78
+ }
79
+ let t7;
80
+ if ($[9] !== children) {
81
+ t7 = children != null && /*#__PURE__*/_jsx("div", {
82
+ className: "xds-dialog__body",
83
+ children: children
24
84
  });
25
- const api = dialog.connect(service, normalizeProps);
26
- const present = usePresence(api.open, () => [backdrop.current, positioner.current]);
27
- if (!present)
28
- return null;
29
- return (_jsx(Portal, { children: _jsxs(TriggerContext, { value: null, children: [_jsx("div", { ...api.getBackdropProps(), ref: backdrop, hidden: false, onMouseDown: (event) => event.preventDefault(), className: "xds-dialog__backdrop" }), _jsx("div", { ...api.getPositionerProps(), ref: positioner, className: "xds-dialog__positioner", children: _jsxs("section", { ...mergeProps(api.getContentProps(), {
30
- className: classes("xds-dialog", className),
31
- style,
32
- }), ref: content, hidden: false, children: [_jsx("h2", { ...api.getTitleProps(), className: "xds-dialog__title", children: title }), description && (_jsx("p", { ...api.getDescriptionProps(), className: "xds-dialog__description", children: description })), children != null && _jsx("div", { className: "xds-dialog__body", children: children }), actions != null && _jsx("div", { className: "xds-dialog__actions", children: actions })] }) })] }) }));
85
+ $[9] = children;
86
+ $[10] = t7;
87
+ } else {
88
+ t7 = $[10];
89
+ }
90
+ let t8;
91
+ if ($[11] !== actions) {
92
+ t8 = actions != null && /*#__PURE__*/_jsx("div", {
93
+ className: "xds-dialog__actions",
94
+ children: actions
95
+ });
96
+ $[11] = actions;
97
+ $[12] = t8;
98
+ } else {
99
+ t8 = $[12];
100
+ }
101
+ return /*#__PURE__*/_jsx(Portal, {
102
+ children: /*#__PURE__*/_jsxs(TriggerContext, {
103
+ value: null,
104
+ children: [/*#__PURE__*/_jsx("div", {
105
+ ...api.getBackdropProps(),
106
+ ref: backdrop,
107
+ hidden: false,
108
+ onMouseDown: _temp,
109
+ className: "xds-dialog__backdrop"
110
+ }), /*#__PURE__*/_jsx("div", {
111
+ ...api.getPositionerProps(),
112
+ ref: positioner,
113
+ className: "xds-dialog__positioner",
114
+ children: /*#__PURE__*/_jsxs("section", {
115
+ ...mergeProps(api.getContentProps(), {
116
+ className: classes("xds-dialog", className),
117
+ style
118
+ }),
119
+ ref: content,
120
+ hidden: false,
121
+ children: [/*#__PURE__*/_jsx("h2", {
122
+ ...api.getTitleProps(),
123
+ className: "xds-dialog__title",
124
+ children: title
125
+ }), description && /*#__PURE__*/_jsx("p", {
126
+ ...api.getDescriptionProps(),
127
+ className: "xds-dialog__description",
128
+ children: description
129
+ }), t7, t8]
130
+ })
131
+ })]
132
+ })
133
+ });
134
+ }
135
+ function _temp(event) {
136
+ return event.preventDefault();
33
137
  }
package/dist/Divider.js CHANGED
@@ -1,5 +1,31 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { classes, dividerClass, rootPart } from "@xds/core";
3
- export function Divider({ className, style }) {
4
- return _jsx("hr", { className: classes(rootPart("Divider"), dividerClass, className), style: style });
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ export function Divider(t0) {
5
+ const $ = _c(5);
6
+ const {
7
+ className,
8
+ style
9
+ } = t0;
10
+ let t1;
11
+ if ($[0] !== className) {
12
+ t1 = classes(rootPart("Divider"), dividerClass, className);
13
+ $[0] = className;
14
+ $[1] = t1;
15
+ } else {
16
+ t1 = $[1];
17
+ }
18
+ let t2;
19
+ if ($[2] !== style || $[3] !== t1) {
20
+ t2 = /*#__PURE__*/_jsx("hr", {
21
+ className: t1,
22
+ style: style
23
+ });
24
+ $[2] = style;
25
+ $[3] = t1;
26
+ $[4] = t2;
27
+ } else {
28
+ t2 = $[4];
29
+ }
30
+ return t2;
5
31
  }