@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/TextField.js CHANGED
@@ -1,30 +1,213 @@
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 } from "@xds/core";
3
3
  import { useId } from "react";
4
- export function TextField({ label, value, onChange, description, error, placeholder, leading, trailing, multiline = false, rows = 3, maxLength, name, type = "text", inputMode, autoComplete, autoFocus = false, required = false, disabled = false, className, style, }) {
5
- const id = useId();
6
- const descriptionId = `${id}-description`;
7
- const errorId = `${id}-error`;
8
- const invalid = error !== undefined;
9
- const grouped = leading != null || trailing != null;
10
- const shared = {
11
- id,
12
- className: grouped
13
- ? "xds-text-field__input"
14
- : "xds-text-field__input xds-text-field__control",
15
- value,
16
- placeholder,
17
- name,
18
- maxLength,
19
- inputMode,
20
- autoComplete,
21
- autoFocus,
22
- required,
23
- disabled,
24
- "aria-invalid": invalid || undefined,
25
- "aria-errormessage": invalid ? errorId : undefined,
26
- "aria-describedby": invalid ? errorId : description ? descriptionId : undefined,
4
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
+ export function TextField(t0) {
6
+ const $ = _c(51);
7
+ const {
8
+ label,
9
+ value,
10
+ onChange,
11
+ description,
12
+ error,
13
+ placeholder,
14
+ leading,
15
+ trailing,
16
+ multiline: t1,
17
+ rows: t2,
18
+ maxLength,
19
+ name,
20
+ type: t3,
21
+ inputMode,
22
+ autoComplete,
23
+ autoFocus: t4,
24
+ required: t5,
25
+ disabled: t6,
26
+ className,
27
+ style
28
+ } = t0;
29
+ const multiline = t1 === undefined ? false : t1;
30
+ const rows = t2 === undefined ? 3 : t2;
31
+ const type = t3 === undefined ? "text" : t3;
32
+ const autoFocus = t4 === undefined ? false : t4;
33
+ const required = t5 === undefined ? false : t5;
34
+ const disabled = t6 === undefined ? false : t6;
35
+ const id = useId();
36
+ const descriptionId = `${id}-description`;
37
+ const errorId = `${id}-error`;
38
+ const invalid = error !== undefined;
39
+ const grouped = leading != null || trailing != null;
40
+ const t7 = grouped ? "xds-text-field__input" : "xds-text-field__input xds-text-field__control";
41
+ const t8 = invalid || undefined;
42
+ const t9 = invalid ? errorId : undefined;
43
+ const t10 = invalid ? errorId : description ? descriptionId : undefined;
44
+ let t11;
45
+ if ($[0] !== autoComplete || $[1] !== autoFocus || $[2] !== disabled || $[3] !== id || $[4] !== inputMode || $[5] !== maxLength || $[6] !== name || $[7] !== placeholder || $[8] !== required || $[9] !== t10 || $[10] !== t7 || $[11] !== t8 || $[12] !== t9 || $[13] !== value) {
46
+ t11 = {
47
+ id,
48
+ className: t7,
49
+ value,
50
+ placeholder,
51
+ name,
52
+ maxLength,
53
+ inputMode,
54
+ autoComplete,
55
+ autoFocus,
56
+ required,
57
+ disabled,
58
+ "aria-invalid": t8,
59
+ "aria-errormessage": t9,
60
+ "aria-describedby": t10
27
61
  };
28
- const field = multiline ? (_jsx("textarea", { ...shared, rows: rows, onChange: (event) => onChange(event.currentTarget.value) })) : (_jsx("input", { ...shared, type: type, onChange: (event) => onChange(event.currentTarget.value) }));
29
- return (_jsxs("div", { className: classes("xds-text-field", className), style: style, children: [_jsx("label", { htmlFor: id, className: "xds-text-field__label", children: label }), grouped ? (_jsxs("div", { className: "xds-text-field__control xds-text-field__group", children: [leading != null && (_jsx("span", { className: "xds-text-field__slot xds-text-field__slot--leading", children: leading })), field, trailing != null && (_jsx("span", { className: "xds-text-field__slot xds-text-field__slot--trailing", children: trailing }))] })) : (field), _jsxs("div", { className: "xds-text-field__footer", children: [!invalid && description && (_jsx("span", { id: descriptionId, className: "xds-text-field__description", children: description })), _jsx("span", { id: errorId, className: "xds-text-field__error", "aria-live": "polite", children: error }), maxLength !== undefined && (_jsxs("span", { className: "ms-auto shrink-0 text-xds-footnote text-xds-text-secondary tabular-nums", children: [value.length, "/", maxLength] }))] })] }));
62
+ $[0] = autoComplete;
63
+ $[1] = autoFocus;
64
+ $[2] = disabled;
65
+ $[3] = id;
66
+ $[4] = inputMode;
67
+ $[5] = maxLength;
68
+ $[6] = name;
69
+ $[7] = placeholder;
70
+ $[8] = required;
71
+ $[9] = t10;
72
+ $[10] = t7;
73
+ $[11] = t8;
74
+ $[12] = t9;
75
+ $[13] = value;
76
+ $[14] = t11;
77
+ } else {
78
+ t11 = $[14];
79
+ }
80
+ const shared = t11;
81
+ let t12;
82
+ if ($[15] !== multiline || $[16] !== onChange || $[17] !== rows || $[18] !== shared || $[19] !== type) {
83
+ t12 = multiline ? /*#__PURE__*/_jsx("textarea", {
84
+ ...shared,
85
+ rows: rows,
86
+ onChange: event => onChange(event.currentTarget.value)
87
+ }) : /*#__PURE__*/_jsx("input", {
88
+ ...shared,
89
+ type: type,
90
+ onChange: event_0 => onChange(event_0.currentTarget.value)
91
+ });
92
+ $[15] = multiline;
93
+ $[16] = onChange;
94
+ $[17] = rows;
95
+ $[18] = shared;
96
+ $[19] = type;
97
+ $[20] = t12;
98
+ } else {
99
+ t12 = $[20];
100
+ }
101
+ const field = t12;
102
+ let t13;
103
+ if ($[21] !== className) {
104
+ t13 = classes("xds-text-field", className);
105
+ $[21] = className;
106
+ $[22] = t13;
107
+ } else {
108
+ t13 = $[22];
109
+ }
110
+ let t14;
111
+ if ($[23] !== id || $[24] !== label) {
112
+ t14 = /*#__PURE__*/_jsx("label", {
113
+ htmlFor: id,
114
+ className: "xds-text-field__label",
115
+ children: label
116
+ });
117
+ $[23] = id;
118
+ $[24] = label;
119
+ $[25] = t14;
120
+ } else {
121
+ t14 = $[25];
122
+ }
123
+ let t15;
124
+ if ($[26] !== field || $[27] !== grouped || $[28] !== leading || $[29] !== trailing) {
125
+ t15 = grouped ? /*#__PURE__*/_jsxs("div", {
126
+ className: "xds-text-field__control xds-text-field__group",
127
+ children: [leading != null && /*#__PURE__*/_jsx("span", {
128
+ className: "xds-text-field__slot xds-text-field__slot--leading",
129
+ children: leading
130
+ }), field, trailing != null && /*#__PURE__*/_jsx("span", {
131
+ className: "xds-text-field__slot xds-text-field__slot--trailing",
132
+ children: trailing
133
+ })]
134
+ }) : field;
135
+ $[26] = field;
136
+ $[27] = grouped;
137
+ $[28] = leading;
138
+ $[29] = trailing;
139
+ $[30] = t15;
140
+ } else {
141
+ t15 = $[30];
142
+ }
143
+ let t16;
144
+ if ($[31] !== description || $[32] !== descriptionId || $[33] !== invalid) {
145
+ t16 = !invalid && description && /*#__PURE__*/_jsx("span", {
146
+ id: descriptionId,
147
+ className: "xds-text-field__description",
148
+ children: description
149
+ });
150
+ $[31] = description;
151
+ $[32] = descriptionId;
152
+ $[33] = invalid;
153
+ $[34] = t16;
154
+ } else {
155
+ t16 = $[34];
156
+ }
157
+ let t17;
158
+ if ($[35] !== error || $[36] !== errorId) {
159
+ t17 = /*#__PURE__*/_jsx("span", {
160
+ id: errorId,
161
+ className: "xds-text-field__error",
162
+ "aria-live": "polite",
163
+ children: error
164
+ });
165
+ $[35] = error;
166
+ $[36] = errorId;
167
+ $[37] = t17;
168
+ } else {
169
+ t17 = $[37];
170
+ }
171
+ let t18;
172
+ if ($[38] !== maxLength || $[39] !== value) {
173
+ t18 = maxLength !== undefined && /*#__PURE__*/_jsxs("span", {
174
+ className: "ms-auto shrink-0 text-xds-footnote text-xds-text-secondary tabular-nums",
175
+ children: [value.length, "/", maxLength]
176
+ });
177
+ $[38] = maxLength;
178
+ $[39] = value;
179
+ $[40] = t18;
180
+ } else {
181
+ t18 = $[40];
182
+ }
183
+ let t19;
184
+ if ($[41] !== t16 || $[42] !== t17 || $[43] !== t18) {
185
+ t19 = /*#__PURE__*/_jsxs("div", {
186
+ className: "xds-text-field__footer",
187
+ children: [t16, t17, t18]
188
+ });
189
+ $[41] = t16;
190
+ $[42] = t17;
191
+ $[43] = t18;
192
+ $[44] = t19;
193
+ } else {
194
+ t19 = $[44];
195
+ }
196
+ let t20;
197
+ if ($[45] !== style || $[46] !== t13 || $[47] !== t14 || $[48] !== t15 || $[49] !== t19) {
198
+ t20 = /*#__PURE__*/_jsxs("div", {
199
+ className: t13,
200
+ style: style,
201
+ children: [t14, t15, t19]
202
+ });
203
+ $[45] = style;
204
+ $[46] = t13;
205
+ $[47] = t14;
206
+ $[48] = t15;
207
+ $[49] = t19;
208
+ $[50] = t20;
209
+ } else {
210
+ t20 = $[50];
211
+ }
212
+ return t20;
30
213
  }
package/dist/Thumbnail.js CHANGED
@@ -1,13 +1,152 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { classes, pictureClass, rootPart, THUMBNAIL_PARTS, thumbnailBadgeClass, thumbnailClass, thumbnailWatched, } from "@xds/core";
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { classes, pictureClass, rootPart, THUMBNAIL_PARTS, thumbnailBadgeClass, thumbnailClass, thumbnailWatched } from "@xds/core";
3
3
  import { Badge } from "./Badge.js";
4
4
  import { useDefaults } from "./Defaults.js";
5
5
  import { Icon } from "./Icon.js";
6
6
  import { usePicture } from "./picture.js";
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
8
  export function Thumbnail(props) {
8
- const defaults = useDefaults("Thumbnail");
9
- const { src, alt, ratio = defaults.ratio, badge, progress, className, style } = props;
10
- const picture = usePicture(src);
11
- const watched = thumbnailWatched(progress);
12
- return (_jsxs("span", { className: classes(rootPart("Thumbnail"), thumbnailClass(ratio), className), style: style, children: [_jsxs("span", { className: THUMBNAIL_PARTS.placeholder, ...(alt ? { role: "img", "aria-label": alt } : { "aria-hidden": true }), children: [picture.loaded !== true && _jsx(Icon, { name: "image", size: "lg" }), src && picture.loaded !== false && (_jsx("img", { src: src, alt: "", "aria-hidden": "true", className: pictureClass(picture.loaded === true), ref: picture.ref, onLoad: picture.onLoad, onError: picture.onError }))] }), badge && (_jsx("span", { className: thumbnailBadgeClass(watched), children: _jsx(Badge, { tone: "overlay", children: badge }) })), watched > 0 && (_jsx("span", { "aria-hidden": "true", className: THUMBNAIL_PARTS.track, children: _jsx("span", { className: THUMBNAIL_PARTS.fill, style: { width: `${watched * 100}%` } }) }))] }));
9
+ const $ = _c(37);
10
+ const defaults = useDefaults("Thumbnail");
11
+ const {
12
+ src,
13
+ alt,
14
+ badge,
15
+ progress,
16
+ className,
17
+ style
18
+ } = props;
19
+ const ratio = props.ratio ?? defaults.ratio;
20
+ const picture = usePicture(src);
21
+ let t0;
22
+ let t1;
23
+ let t2;
24
+ let t3;
25
+ let watched;
26
+ if ($[0] !== alt || $[1] !== badge || $[2] !== className || $[3] !== picture.image || $[4] !== picture.loaded || $[5] !== progress || $[6] !== ratio || $[7] !== src || $[8] !== style) {
27
+ watched = thumbnailWatched(progress);
28
+ if ($[14] !== className || $[15] !== ratio) {
29
+ t0 = classes(rootPart("Thumbnail"), thumbnailClass(ratio), className);
30
+ $[14] = className;
31
+ $[15] = ratio;
32
+ $[16] = t0;
33
+ } else {
34
+ t0 = $[16];
35
+ }
36
+ t1 = style;
37
+ let t4;
38
+ if ($[17] !== alt) {
39
+ t4 = alt ? {
40
+ role: "img",
41
+ "aria-label": alt
42
+ } : {
43
+ "aria-hidden": true
44
+ };
45
+ $[17] = alt;
46
+ $[18] = t4;
47
+ } else {
48
+ t4 = $[18];
49
+ }
50
+ let t5;
51
+ if ($[19] !== picture.loaded) {
52
+ t5 = picture.loaded !== true && /*#__PURE__*/_jsx(Icon, {
53
+ name: "image",
54
+ size: "lg"
55
+ });
56
+ $[19] = picture.loaded;
57
+ $[20] = t5;
58
+ } else {
59
+ t5 = $[20];
60
+ }
61
+ let t6;
62
+ if ($[21] !== picture.image || $[22] !== picture.loaded || $[23] !== src) {
63
+ t6 = src && picture.loaded !== false && /*#__PURE__*/_jsx("img", {
64
+ src: src,
65
+ alt: "",
66
+ "aria-hidden": "true",
67
+ className: pictureClass(picture.loaded === true),
68
+ ...picture.image
69
+ });
70
+ $[21] = picture.image;
71
+ $[22] = picture.loaded;
72
+ $[23] = src;
73
+ $[24] = t6;
74
+ } else {
75
+ t6 = $[24];
76
+ }
77
+ if ($[25] !== t4 || $[26] !== t5 || $[27] !== t6) {
78
+ t2 = /*#__PURE__*/_jsxs("span", {
79
+ className: THUMBNAIL_PARTS.placeholder,
80
+ ...t4,
81
+ children: [t5, t6]
82
+ });
83
+ $[25] = t4;
84
+ $[26] = t5;
85
+ $[27] = t6;
86
+ $[28] = t2;
87
+ } else {
88
+ t2 = $[28];
89
+ }
90
+ t3 = badge && /*#__PURE__*/_jsx("span", {
91
+ className: thumbnailBadgeClass(watched),
92
+ children: /*#__PURE__*/_jsx(Badge, {
93
+ tone: "overlay",
94
+ children: badge
95
+ })
96
+ });
97
+ $[0] = alt;
98
+ $[1] = badge;
99
+ $[2] = className;
100
+ $[3] = picture.image;
101
+ $[4] = picture.loaded;
102
+ $[5] = progress;
103
+ $[6] = ratio;
104
+ $[7] = src;
105
+ $[8] = style;
106
+ $[9] = t0;
107
+ $[10] = t1;
108
+ $[11] = t2;
109
+ $[12] = t3;
110
+ $[13] = watched;
111
+ } else {
112
+ t0 = $[9];
113
+ t1 = $[10];
114
+ t2 = $[11];
115
+ t3 = $[12];
116
+ watched = $[13];
117
+ }
118
+ let t4;
119
+ if ($[29] !== watched) {
120
+ t4 = watched > 0 && /*#__PURE__*/_jsx("span", {
121
+ "aria-hidden": "true",
122
+ className: THUMBNAIL_PARTS.track,
123
+ children: /*#__PURE__*/_jsx("span", {
124
+ className: THUMBNAIL_PARTS.fill,
125
+ style: {
126
+ width: `${watched * 100}%`
127
+ }
128
+ })
129
+ });
130
+ $[29] = watched;
131
+ $[30] = t4;
132
+ } else {
133
+ t4 = $[30];
134
+ }
135
+ let t5;
136
+ if ($[31] !== t0 || $[32] !== t1 || $[33] !== t2 || $[34] !== t3 || $[35] !== t4) {
137
+ t5 = /*#__PURE__*/_jsxs("span", {
138
+ className: t0,
139
+ style: t1,
140
+ children: [t2, t3, t4]
141
+ });
142
+ $[31] = t0;
143
+ $[32] = t1;
144
+ $[33] = t2;
145
+ $[34] = t3;
146
+ $[35] = t4;
147
+ $[36] = t5;
148
+ } else {
149
+ t5 = $[36];
150
+ }
151
+ return t5;
13
152
  }
package/dist/Toast.js CHANGED
@@ -1,33 +1,121 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { motion } from "@xds/tokens";
3
3
  import { classes, rootPart, TOAST_PARTS } from "@xds/core";
4
- import { useEffect, useRef, useState } from "react";
5
- export function Toast({ open, onClose, message, action, duration = motion.duration.toast, className, style, }) {
6
- const region = useRef(null);
7
- const [hovered, setHovered] = useState(false);
8
- const [focused, setFocused] = useState(false);
9
- const held = hovered || focused;
10
- const close = useRef(onClose);
11
- close.current = onClose;
12
- useEffect(() => {
13
- const element = region.current;
14
- if (!element?.showPopover)
15
- return;
16
- element.showPopover();
17
- return () => element.hidePopover();
18
- }, []);
19
- useEffect(() => {
20
- if (!open) {
21
- setHovered(false);
22
- setFocused(false);
23
- }
24
- if (!open || held || duration <= 0)
25
- return;
26
- const timer = setTimeout(() => close.current(), duration);
27
- return () => clearTimeout(timer);
28
- }, [open, held, duration]);
29
- return (_jsx("div", { ref: region, role: "status", popover: "manual", className: TOAST_PARTS.region, children: open && (_jsxs("div", { onPointerEnter: () => setHovered(true), onPointerLeave: () => setHovered(false), onFocus: () => setFocused(true), onBlur: () => setFocused(false), className: classes(rootPart("Toast"), TOAST_PARTS.toast, className), style: style, children: [_jsx("span", { className: TOAST_PARTS.message, children: message }), action && (_jsx("button", { type: "button", onClick: () => {
30
- action.onPress();
31
- onClose();
32
- }, className: TOAST_PARTS.action, children: action.label }))] })) }));
4
+ import { useEffect, useEffectEvent, useRef, useState } from "react";
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ export function Toast(t0) {
7
+ const $ = _c(20);
8
+ const {
9
+ open,
10
+ onClose,
11
+ message,
12
+ action,
13
+ duration: t1,
14
+ className,
15
+ style
16
+ } = t0;
17
+ const duration = t1 === undefined ? motion.duration.toast : t1;
18
+ const region = useRef(null);
19
+ const [hovered, setHovered] = useState(false);
20
+ const [focused, setFocused] = useState(false);
21
+ const held = hovered || focused;
22
+ const close = useEffectEvent(onClose);
23
+ let t2;
24
+ let t3;
25
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
26
+ t2 = () => {
27
+ const element = region.current;
28
+ if (!element?.showPopover) {
29
+ return;
30
+ }
31
+ element.showPopover();
32
+ return () => element.hidePopover();
33
+ };
34
+ t3 = [];
35
+ $[0] = t2;
36
+ $[1] = t3;
37
+ } else {
38
+ t2 = $[0];
39
+ t3 = $[1];
40
+ }
41
+ useEffect(t2, t3);
42
+ let t4;
43
+ if ($[2] !== close || $[3] !== duration || $[4] !== held || $[5] !== open) {
44
+ t4 = () => {
45
+ if (!open) {
46
+ setHovered(false);
47
+ setFocused(false);
48
+ }
49
+ if (!open || held || duration <= 0) {
50
+ return;
51
+ }
52
+ const timer = setTimeout(() => close(), duration);
53
+ return () => clearTimeout(timer);
54
+ };
55
+ $[2] = close;
56
+ $[3] = duration;
57
+ $[4] = held;
58
+ $[5] = open;
59
+ $[6] = t4;
60
+ } else {
61
+ t4 = $[6];
62
+ }
63
+ let t5;
64
+ if ($[7] !== duration || $[8] !== held || $[9] !== open) {
65
+ t5 = [open, held, duration];
66
+ $[7] = duration;
67
+ $[8] = held;
68
+ $[9] = open;
69
+ $[10] = t5;
70
+ } else {
71
+ t5 = $[10];
72
+ }
73
+ useEffect(t4, t5);
74
+ let t6;
75
+ if ($[11] !== action || $[12] !== className || $[13] !== message || $[14] !== onClose || $[15] !== open || $[16] !== style) {
76
+ t6 = open && /*#__PURE__*/_jsxs("div", {
77
+ onPointerEnter: () => setHovered(true),
78
+ onPointerLeave: () => setHovered(false),
79
+ onFocus: () => setFocused(true),
80
+ onBlur: () => setFocused(false),
81
+ className: classes(rootPart("Toast"), TOAST_PARTS.toast, className),
82
+ style: style,
83
+ children: [/*#__PURE__*/_jsx("span", {
84
+ className: TOAST_PARTS.message,
85
+ children: message
86
+ }), action && /*#__PURE__*/_jsx("button", {
87
+ type: "button",
88
+ onClick: () => {
89
+ action.onPress();
90
+ onClose();
91
+ },
92
+ className: TOAST_PARTS.action,
93
+ children: action.label
94
+ })]
95
+ });
96
+ $[11] = action;
97
+ $[12] = className;
98
+ $[13] = message;
99
+ $[14] = onClose;
100
+ $[15] = open;
101
+ $[16] = style;
102
+ $[17] = t6;
103
+ } else {
104
+ t6 = $[17];
105
+ }
106
+ let t7;
107
+ if ($[18] !== t6) {
108
+ t7 = /*#__PURE__*/_jsx("div", {
109
+ ref: region,
110
+ role: "status",
111
+ popover: "manual",
112
+ className: TOAST_PARTS.region,
113
+ children: t6
114
+ });
115
+ $[18] = t6;
116
+ $[19] = t7;
117
+ } else {
118
+ t7 = $[19];
119
+ }
120
+ return t7;
33
121
  }