@kanso-labs/kanso-ui 0.49.0 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,77 @@
1
+ import { ReactNode, RefAttributes } from "react";
2
+ import { RenderComponentProps } from "../../render/useRender.js";
3
+ type SkeletonBarProps = Omit<RenderComponentProps<'div'>, 'children' | 'render'> & {
4
+ /**
5
+ * What the bar stands in for: `sm`, 12px, an eyebrow or a supporting line;
6
+ * `md`, 14px, a title or a figure; `lg`, 28px, a headline.
7
+ * @default 'sm'
8
+ */
9
+ size?: SkeletonBarSize;
10
+ /**
11
+ * How wide the bar is: a number of pixels, or a CSS length or percentage
12
+ * of its row.
13
+ */
14
+ width: number | string;
15
+ };
16
+ type SkeletonBarSize = 'lg' | 'md' | 'sm';
17
+ type SkeletonCircleProps = Omit<RenderComponentProps<'div'>, 'children' | 'render'>;
18
+ type SkeletonProps = RenderComponentProps<'div'> & {
19
+ /**
20
+ * What a screen reader hears. Left out, it is the library's word for
21
+ * loading in the `I18nProvider`'s locale — "Loading" in English.
22
+ */
23
+ 'aria-label'?: string;
24
+ /** The shapes: `Skeleton.Row`s, or bars and circles of the call site's. */
25
+ children?: ReactNode;
26
+ };
27
+ type SkeletonRowProps = Omit<RenderComponentProps<'div'>, 'render'> & {
28
+ /** The bars standing in for the row's lines, one above the other. */
29
+ children?: ReactNode;
30
+ /** What stands before the lines, usually a `Skeleton.Circle`. */
31
+ leading?: ReactNode;
32
+ /**
33
+ * How many lines the row stands in for: `1` is the lists page's 56px
34
+ * one-line item, `2` its 72px two-line item.
35
+ * @default 1
36
+ */
37
+ lines?: 1 | 2;
38
+ /** What stands after the lines, such as a bar in place of a figure. */
39
+ trailing?: ReactNode;
40
+ };
41
+ /**
42
+ * The shape of what is being read, drawn at once in its place: rows of bars
43
+ * and circles, fading gently, that a screen reader hears as one "Loading".
44
+ *
45
+ * ```tsx
46
+ * <Skeleton>
47
+ * <Skeleton.Row leading={<Skeleton.Circle />} lines={2}>
48
+ * <Skeleton.Bar size="md" width="60%" />
49
+ * <Skeleton.Bar width="40%" />
50
+ * </Skeleton.Row>
51
+ * </Skeleton>
52
+ * ```
53
+ *
54
+ * Draw it where the content will be, in its place rather than over it, and
55
+ * swap it for the content once that is read. It says "Loading" where a
56
+ * reader reaches it and announces nothing as it comes and goes; mark the
57
+ * container it is swapped in `aria-busy` while it loads, or announce the
58
+ * change through a live region, where that matters. The call site's `className` and
59
+ * `style` land on its own element.
60
+ */
61
+ declare function Skeleton({ 'aria-label': ariaLabel, children, render, ...props }: SkeletonProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
62
+ declare namespace Skeleton {
63
+ var Bar: typeof SkeletonBar;
64
+ var Circle: typeof SkeletonCircle;
65
+ var Row: typeof SkeletonRow;
66
+ }
67
+ /** A bar standing in for a line of text, at the width the call site gives. */
68
+ declare function SkeletonBar({ size, width, ...props }: RefAttributes<HTMLDivElement> & SkeletonBarProps): import("react").JSX.Element;
69
+ /** A 40px circle standing in for a row's mark, such as an avatar. */
70
+ declare function SkeletonCircle(props: RefAttributes<HTMLDivElement> & SkeletonCircleProps): import("react").JSX.Element;
71
+ /**
72
+ * A row standing in for a list item: 56px for one line, 72px for two, with
73
+ * the lists page's padding, a leading and a trailing slot, and its bars one
74
+ * above the other between them.
75
+ */
76
+ declare function SkeletonRow({ children, leading, lines, trailing, ...props }: RefAttributes<HTMLDivElement> & SkeletonRowProps): import("react").JSX.Element;
77
+ export { SkeletonBar, type SkeletonBarProps, type SkeletonBarSize, SkeletonCircle, type SkeletonCircleProps, type SkeletonProps, SkeletonRow, type SkeletonRowProps, Skeleton as default };
@@ -0,0 +1,242 @@
1
+ "use client";
2
+ import { c } from "react/compiler-runtime";
3
+ import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
4
+ import { useMessages } from "../../i18n/index.js";
5
+ import { hasContent } from "../../render/content.js";
6
+ import { useRender } from "../../render/useRender.js";
7
+ import { rowStyles } from "../../row/styles.js";
8
+ import { mergeStyles } from "../../styles/merge.js";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ // src/components/skeleton/index.tsx
11
+ const styles = { bar: {
12
+ kWkggS: "x1rrhr5q x1o55y2u",
13
+ kaIpWk: "x1tfhd1",
14
+ kB7OPa: "x9f619",
15
+ kmuXW: "x2lah0s",
16
+ kAXs8y: "x1g12otp",
17
+ ks0D6T: "x193iq5w",
18
+ $$css: true
19
+ } };
20
+ const barSizes = {
21
+ lg: {
22
+ kZKoxP: "x1fgtraw",
23
+ $$css: true
24
+ },
25
+ md: {
26
+ kZKoxP: "x1v9usgg",
27
+ $$css: true
28
+ },
29
+ sm: {
30
+ kZKoxP: "x1kpxq89",
31
+ $$css: true
32
+ }
33
+ };
34
+ const _temp = {
35
+ kzqmXN: "x1uyokj7",
36
+ "$$css": true
37
+ };
38
+ const barWidth = { width: (inlineSize) => [_temp, { "--x-inlineSize": ((val) => typeof val === "number" ? val + "px" : val != null ? val : void 0)(inlineSize) }] };
39
+ /**
40
+ * The shape of what is being read, drawn at once in its place: rows of bars
41
+ * and circles, fading gently, that a screen reader hears as one "Loading".
42
+ *
43
+ * ```tsx
44
+ * <Skeleton>
45
+ * <Skeleton.Row leading={<Skeleton.Circle />} lines={2}>
46
+ * <Skeleton.Bar size="md" width="60%" />
47
+ * <Skeleton.Bar width="40%" />
48
+ * </Skeleton.Row>
49
+ * </Skeleton>
50
+ * ```
51
+ *
52
+ * Draw it where the content will be, in its place rather than over it, and
53
+ * swap it for the content once that is read. It says "Loading" where a
54
+ * reader reaches it and announces nothing as it comes and goes; mark the
55
+ * container it is swapped in `aria-busy` while it loads, or announce the
56
+ * change through a live region, where that matters. The call site's `className` and
57
+ * `style` land on its own element.
58
+ */
59
+ function Skeleton(t0) {
60
+ const $ = c(10);
61
+ const { "aria-label": ariaLabel, children, render, ...props } = t0;
62
+ const messages = useMessages();
63
+ const t1 = "div";
64
+ const t2 = true;
65
+ const t3 = ariaLabel === void 0 || ariaLabel === "" ? messages.loading : ariaLabel;
66
+ const t4 = "progressbar";
67
+ const t5 = mergeStyles({ className: "x9f619" }, props);
68
+ let t6;
69
+ if ($[0] !== children) {
70
+ t6 = /* @__PURE__ */ jsx("div", {
71
+ "aria-hidden": "true",
72
+ className: "xpz12be xmg6eyc xa4qsjk x19utubg x1d1m1p8 x1aquc0h x4hg4is x9f619",
73
+ children
74
+ });
75
+ $[0] = children;
76
+ $[1] = t6;
77
+ } else t6 = $[1];
78
+ let t7;
79
+ if ($[2] !== props || $[3] !== t3 || $[4] !== t5 || $[5] !== t6) {
80
+ t7 = {
81
+ "aria-busy": t2,
82
+ "aria-label": t3,
83
+ role: t4,
84
+ ...props,
85
+ ...t5,
86
+ children: t6
87
+ };
88
+ $[2] = props;
89
+ $[3] = t3;
90
+ $[4] = t5;
91
+ $[5] = t6;
92
+ $[6] = t7;
93
+ } else t7 = $[6];
94
+ let t8;
95
+ if ($[7] !== render || $[8] !== t7) {
96
+ t8 = {
97
+ defaultTagName: t1,
98
+ props: t7,
99
+ render
100
+ };
101
+ $[7] = render;
102
+ $[8] = t7;
103
+ $[9] = t8;
104
+ } else t8 = $[9];
105
+ return useRender(t8);
106
+ }
107
+ /** A bar standing in for a line of text, at the width the call site gives. */
108
+ function SkeletonBar(t0) {
109
+ const $ = c(6);
110
+ let t1;
111
+ let t2;
112
+ if ($[0] !== t0) {
113
+ const { size: t3, width, ...props$1 } = t0;
114
+ const size = t3 === void 0 ? "sm" : t3;
115
+ t1 = props$1;
116
+ t2 = mergeStyles(props(styles.bar, barSizes[size], barWidth.width(typeof width === "number" ? `${width}px` : width)), props$1);
117
+ $[0] = t0;
118
+ $[1] = t1;
119
+ $[2] = t2;
120
+ } else {
121
+ t1 = $[1];
122
+ t2 = $[2];
123
+ }
124
+ let t3;
125
+ if ($[3] !== t1 || $[4] !== t2) {
126
+ t3 = /* @__PURE__ */ jsx("div", {
127
+ ...t1,
128
+ ...t2
129
+ });
130
+ $[3] = t1;
131
+ $[4] = t2;
132
+ $[5] = t3;
133
+ } else t3 = $[5];
134
+ return t3;
135
+ }
136
+ /** A 40px circle standing in for a row's mark, such as an avatar. */
137
+ function SkeletonCircle(props) {
138
+ const $ = c(5);
139
+ let t0;
140
+ if ($[0] !== props) {
141
+ t0 = mergeStyles({ className: "x1rrhr5q x1o55y2u x1rv7mn0 x1dkaolv x9f619 x2lah0s x1g12otp x1eujcsb" }, props);
142
+ $[0] = props;
143
+ $[1] = t0;
144
+ } else t0 = $[1];
145
+ let t1;
146
+ if ($[2] !== props || $[3] !== t0) {
147
+ t1 = /* @__PURE__ */ jsx("div", {
148
+ ...props,
149
+ ...t0
150
+ });
151
+ $[2] = props;
152
+ $[3] = t0;
153
+ $[4] = t1;
154
+ } else t1 = $[4];
155
+ return t1;
156
+ }
157
+ /**
158
+ * A row standing in for a list item: 56px for one line, 72px for two, with
159
+ * the lists page's padding, a leading and a trailing slot, and its bars one
160
+ * above the other between them.
161
+ */
162
+ function SkeletonRow(t0) {
163
+ const $ = c(18);
164
+ let children;
165
+ let leading;
166
+ let t1;
167
+ let t2;
168
+ let trailing;
169
+ if ($[0] !== t0) {
170
+ const { children: t3, leading: t4, lines: t5, trailing: t6, ...props$2 } = t0;
171
+ children = t3;
172
+ leading = t4;
173
+ trailing = t6;
174
+ const lines = t5 === void 0 ? 1 : t5;
175
+ t1 = props$2;
176
+ t2 = mergeStyles(props(rowStyles.base, rowStyles.list, lines === 2 && rowStyles.twoLine), props$2);
177
+ $[0] = t0;
178
+ $[1] = children;
179
+ $[2] = leading;
180
+ $[3] = t1;
181
+ $[4] = t2;
182
+ $[5] = trailing;
183
+ } else {
184
+ children = $[1];
185
+ leading = $[2];
186
+ t1 = $[3];
187
+ t2 = $[4];
188
+ trailing = $[5];
189
+ }
190
+ let t3;
191
+ if ($[6] !== leading) {
192
+ t3 = !hasContent(leading) ? null : /* @__PURE__ */ jsx("div", {
193
+ ...props(rowStyles.slot),
194
+ children: leading
195
+ });
196
+ $[6] = leading;
197
+ $[7] = t3;
198
+ } else t3 = $[7];
199
+ let t4;
200
+ if ($[8] !== children) {
201
+ t4 = /* @__PURE__ */ jsx("div", {
202
+ className: "x9f619 x78zum5 xdt5ytf x1iyjqo2 x126z3so xeuugli",
203
+ children
204
+ });
205
+ $[8] = children;
206
+ $[9] = t4;
207
+ } else t4 = $[9];
208
+ let t5;
209
+ if ($[10] !== trailing) {
210
+ t5 = !hasContent(trailing) ? null : /* @__PURE__ */ jsx("div", {
211
+ ...props(rowStyles.slot),
212
+ children: trailing
213
+ });
214
+ $[10] = trailing;
215
+ $[11] = t5;
216
+ } else t5 = $[11];
217
+ let t6;
218
+ if ($[12] !== t1 || $[13] !== t2 || $[14] !== t3 || $[15] !== t4 || $[16] !== t5) {
219
+ t6 = /* @__PURE__ */ jsxs("div", {
220
+ ...t1,
221
+ ...t2,
222
+ children: [
223
+ t3,
224
+ t4,
225
+ t5
226
+ ]
227
+ });
228
+ $[12] = t1;
229
+ $[13] = t2;
230
+ $[14] = t3;
231
+ $[15] = t4;
232
+ $[16] = t5;
233
+ $[17] = t6;
234
+ } else t6 = $[17];
235
+ return t6;
236
+ }
237
+ Skeleton.Bar = SkeletonBar;
238
+ Skeleton.Circle = SkeletonCircle;
239
+ Skeleton.Row = SkeletonRow;
240
+ export { SkeletonBar, SkeletonCircle, SkeletonRow, Skeleton as default };
241
+
242
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_c","stylex","useMessages","hasContent","useRender","rowStyles","mergeStyles","styles","bar","kWkggS","kaIpWk","kB7OPa","kmuXW","kAXs8y","ks0D6T","$$css","barSizes","lg","kZKoxP","md","sm","_temp","kzqmXN","barWidth","width","inlineSize","val","undefined","size","children","leading","lines","trailing","Skeleton","t0","$","ariaLabel","render","props","messages","t1","t2","t3","loading","t4","t5","className","t6","t7","role","t8","defaultTagName","SkeletonBar","SkeletonCircle","SkeletonRow","base","list","twoLine","slot","Bar","Circle","Row"],"sources":["../../../src/components/skeleton/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport type { RenderComponentProps } from '../../render/useRender';\nimport { useMessages } from '../../i18n';\nimport { hasContent } from '../../render/content';\nimport { useRender } from '../../render/useRender';\nimport { rowStyles } from '../../row/styles';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, sizing, spacing } from '../../tokens/design.tokens.stylex';\n\n// The shape of a page drawn at once, while what fills it is read: rows at the\n// lists page's 56dp and 72dp heights, holding bars in place of their lines\n// and 40dp circles in place of their marks. No Material Design page draws a\n// skeleton, so this is the library's own, drawn on the lists page's row as\n// ListItem draws it, from src/row: its 16dp inline padding and 16dp between a\n// slot and the lines.\n//\n// Every shape is surface container highest, the bars at the 4dp corner and\n// the circles round. A bar is 12dp tall for an eyebrow or a supporting line,\n// 14dp for a title or a figure and 28dp for a headline, each a little under\n// the line it stands in for, so a row of bars reads as a row of text rather\n// than as blocks. Those three heights fall between steps of the spacing scale\n// and are written out. Its width is the call site's, since only it knows how\n// long the words it stands in for tend to be.\n//\n// **No shimmer.** What is inside a skeleton fades from full opacity to 60%\n// over 1.5 seconds and back, eased at both ends, so a screen of rows breathes\n// as one rather than flickering row by row — the reading react-native-kanso-ui\n// takes too. Under reduced motion it holds at full opacity.\n//\n// **A screen reader hears one \"Loading\".** The skeleton is one element, a\n// busy progress bar named by `aria-label`, or by the library's own word for\n// loading in the `I18nProvider`'s locale, as a pending Button is. What it\n// holds is hidden from screen readers, so nothing inside is read past it.\n//\n// Under forced colours a fill is painted over in the page's own colour, which\n// would leave every shape invisible, so the shapes are drawn in `GrayText`,\n// the mode's colour for what cannot be used yet, and held at full opacity,\n// since `GrayText` at 60% on the page's colour is barely there.\n\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst REDUCED_MOTION = '@media (prefers-reduced-motion: reduce)';\nconst fade = \"xw0kf14-B\";\nconst styles = {\n bar: {\n kWkggS: \"x1rrhr5q x1o55y2u\",\n kaIpWk: \"x1tfhd1\",\n kB7OPa: \"x9f619\",\n kmuXW: \"x2lah0s\",\n kAXs8y: \"x1g12otp\",\n ks0D6T: \"x193iq5w\",\n $$css: true\n }\n};\n\n// The bars' heights, by what each stands in for, and their widths, which\n// are the call site's — see the header.\nconst barSizes = {\n lg: {\n kZKoxP: \"x1fgtraw\",\n $$css: true\n },\n md: {\n kZKoxP: \"x1v9usgg\",\n $$css: true\n },\n sm: {\n kZKoxP: \"x1kpxq89\",\n $$css: true\n }\n};\nconst _temp = {\n kzqmXN: \"x1uyokj7\",\n \"$$css\": true\n};\nconst barWidth = {\n width: (inlineSize: string) => [_temp, {\n \"--x-inlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(inlineSize)\n }]\n};\ntype SkeletonBarProps = Omit<RenderComponentProps<'div'>, 'children' | 'render'> & {\n /**\n * What the bar stands in for: `sm`, 12px, an eyebrow or a supporting line;\n * `md`, 14px, a title or a figure; `lg`, 28px, a headline.\n * @default 'sm'\n */\n size?: SkeletonBarSize;\n /**\n * How wide the bar is: a number of pixels, or a CSS length or percentage\n * of its row.\n */\n width: number | string;\n};\ntype SkeletonBarSize = 'lg' | 'md' | 'sm';\ntype SkeletonCircleProps = Omit<RenderComponentProps<'div'>, 'children' | 'render'>;\ntype SkeletonProps = RenderComponentProps<'div'> & {\n /**\n * What a screen reader hears. Left out, it is the library's word for\n * loading in the `I18nProvider`'s locale — \"Loading\" in English.\n */\n 'aria-label'?: string;\n /** The shapes: `Skeleton.Row`s, or bars and circles of the call site's. */\n children?: ReactNode;\n};\ntype SkeletonRowProps = Omit<RenderComponentProps<'div'>, 'render'> & {\n /** The bars standing in for the row's lines, one above the other. */\n children?: ReactNode;\n /** What stands before the lines, usually a `Skeleton.Circle`. */\n leading?: ReactNode;\n /**\n * How many lines the row stands in for: `1` is the lists page's 56px\n * one-line item, `2` its 72px two-line item.\n * @default 1\n */\n lines?: 1 | 2;\n /** What stands after the lines, such as a bar in place of a figure. */\n trailing?: ReactNode;\n};\n\n/**\n * The shape of what is being read, drawn at once in its place: rows of bars\n * and circles, fading gently, that a screen reader hears as one \"Loading\".\n *\n * ```tsx\n * <Skeleton>\n * <Skeleton.Row leading={<Skeleton.Circle />} lines={2}>\n * <Skeleton.Bar size=\"md\" width=\"60%\" />\n * <Skeleton.Bar width=\"40%\" />\n * </Skeleton.Row>\n * </Skeleton>\n * ```\n *\n * Draw it where the content will be, in its place rather than over it, and\n * swap it for the content once that is read. It says \"Loading\" where a\n * reader reaches it and announces nothing as it comes and goes; mark the\n * container it is swapped in `aria-busy` while it loads, or announce the\n * change through a live region, where that matters. The call site's `className` and\n * `style` land on its own element.\n */\nfunction Skeleton({\n 'aria-label': ariaLabel,\n children,\n render,\n ...props\n}: SkeletonProps) {\n const messages = useMessages();\n return useRender({\n defaultTagName: 'div',\n props: {\n 'aria-busy': true,\n // An empty name is no name, so it falls back as a missing one does.\n 'aria-label': ariaLabel === undefined || ariaLabel === '' ? messages.loading : ariaLabel,\n role: 'progressbar',\n ...props,\n ...mergeStyles({\n className: \"x9f619\"\n }, props),\n children: <div aria-hidden=\"true\" className=\"xpz12be xmg6eyc xa4qsjk x19utubg x1d1m1p8 x1aquc0h x4hg4is x9f619\">\n {children}\n </div>\n },\n render\n });\n}\n\n/** A bar standing in for a line of text, at the width the call site gives. */\nfunction SkeletonBar({\n size = 'sm',\n width,\n ...props\n}: RefAttributes<HTMLDivElement> & SkeletonBarProps) {\n return <div {...props} {...mergeStyles(stylex.props(styles.bar, barSizes[size], barWidth.width(typeof width === 'number' ? `${width}px` : width)), props)} />;\n}\n\n/** A 40px circle standing in for a row's mark, such as an avatar. */\nfunction SkeletonCircle(props: RefAttributes<HTMLDivElement> & SkeletonCircleProps) {\n return <div {...props} {...mergeStyles({\n className: \"x1rrhr5q x1o55y2u x1rv7mn0 x1dkaolv x9f619 x2lah0s x1g12otp x1eujcsb\"\n }, props)} />;\n}\n\n/**\n * A row standing in for a list item: 56px for one line, 72px for two, with\n * the lists page's padding, a leading and a trailing slot, and its bars one\n * above the other between them.\n */\nfunction SkeletonRow({\n children,\n leading,\n lines = 1,\n trailing,\n ...props\n}: RefAttributes<HTMLDivElement> & SkeletonRowProps) {\n return <div {...props} {...mergeStyles(stylex.props(rowStyles.base, rowStyles.list, lines === 2 && rowStyles.twoLine), props)}>\n {!hasContent(leading) ? null : <div {...stylex.props(rowStyles.slot)}>{leading}</div>}\n <div className=\"x9f619 x78zum5 xdt5ytf x1iyjqo2 x126z3so xeuugli\">{children}</div>\n {!hasContent(trailing) ? null : <div {...stylex.props(rowStyles.slot)}>{trailing}</div>}\n </div>;\n}\nSkeleton.Bar = SkeletonBar;\nSkeleton.Circle = SkeletonCircle;\nSkeleton.Row = SkeletonRow;\nexport type { SkeletonBarProps, SkeletonBarSize, SkeletonCircleProps, SkeletonProps, SkeletonRowProps };\nexport { SkeletonBar, SkeletonCircle, SkeletonRow };\nexport default Skeleton;"],"mappings":";;;;;;;;;;AA8CA,MAAMO,SAAS,EACbC,KAAK;CACHC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,OAAO;CACPC,QAAQ;CACRC,QAAQ;CACRC,OAAO;AACT,EACF;AAIA,MAAMC,WAAW;CACfC,IAAI;EACFC,QAAQ;EACRH,OAAO;CACT;CACAI,IAAI;EACFD,QAAQ;EACRH,OAAO;CACT;CACAK,IAAI;EACFF,QAAQ;EACRH,OAAO;CACT;AACF;AACA,MAAMM,QAAQ;CACZC,QAAQ;CACR,SAAS;AACX;AACA,MAAMC,WAAW,EACfC,QAAQC,eAAuB,CAACJ,OAAO,EACrC,oBAAmBK,QAAO,OAAOA,QAAQ,WAAWA,MAAM,OAAOA,OAAO,OAAOA,MAAMC,KAAAA,EAAAA,CAAWF,UAAU,EAC5G,CAAC,EACH;;;;;;;;;;;;;;;;;;;;;AA4DA,SAAAQ,SAAAC,IAAA;CAAA,M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Y;CAAA,IAAAZ,EAAA,QAAAK,MAAAL,EAAA,QAAAM,MAAAN,EAAA,QAAAO,MAAAP,EAAA,QAAAS,MAAAT,EAAA,QAAAU,IAAA;EAHpFE,KAAA,qBAAA,OAAA;GAIC,GAJQT;GAAK,GAAMG;GAApB,UAAA;IACFC;IACDE;IACCC;GACG;;EAAAV,EAAA,MAAAK;EAAAL,EAAA,MAAAM;EAAAN,EAAA,MAAAO;EAAAP,EAAA,MAAAS;EAAAT,EAAA,MAAAU;EAAAV,EAAA,MAAAY;CAAA,OAAAA,KAAAZ,EAAA;CAAA,OAJDY;AAIC;AAEVd,SAAS0B,MAAMP;AACfnB,SAAS2B,SAASP;AAClBpB,SAAS4B,MAAMP"}
@@ -11,6 +11,7 @@ type SnackbarMessage = {
11
11
  action: SnackbarAction | undefined;
12
12
  message: ReactNode;
13
13
  showCloseButton: boolean;
14
+ tone?: SnackbarTone | undefined;
14
15
  };
15
16
  type SnackbarOptions = {
16
17
  /**
@@ -50,6 +51,13 @@ type SnackbarOptions = {
50
51
  * way to be rid of it.
51
52
  */
52
53
  timeout?: number;
54
+ /**
55
+ * `failure` leads the message with a warning glyph in the inverse error,
56
+ * so a failure does not look like a confirmation. Left out, the message is
57
+ * drawn as a confirmation. The glyph is not announced, so the message's
58
+ * words should say that something failed.
59
+ */
60
+ tone?: SnackbarTone;
53
61
  };
54
62
  type SnackbarProps = {
55
63
  /**
@@ -74,6 +82,8 @@ type SnackbarProps = {
74
82
  /** A function may compute the style from the region's render state. */
75
83
  style?: ToastRegionProps<SnackbarMessage>['style'];
76
84
  } & Omit<ToastRegionProps<SnackbarMessage>, 'aria-label' | 'children' | 'className' | 'queue' | 'style'>;
85
+ /** What a message reports: `failure`, where something did not happen. */
86
+ type SnackbarTone = 'failure';
77
87
  /**
78
88
  * The queue a snackbar is shown from. Make one where the app can reach it —
79
89
  * a module of its own is the usual place — mount `Snackbar` once with it,
@@ -139,4 +149,4 @@ declare function Snackbar({ closeLabel, queue, ...props }: RefAttributes<HTMLDiv
139
149
  declare namespace Snackbar {
140
150
  var Queue: typeof SnackbarQueue;
141
151
  }
142
- export { type SnackbarAction, type SnackbarMessage, type SnackbarOptions, type SnackbarProps, type SnackbarQueue, type ToastRegionRenderProps as SnackbarRegionRenderProps, Snackbar as default };
152
+ export { type SnackbarAction, type SnackbarMessage, type SnackbarOptions, type SnackbarProps, type SnackbarQueue, type ToastRegionRenderProps as SnackbarRegionRenderProps, type SnackbarTone, Snackbar as default };
@@ -3,7 +3,7 @@ import { c } from "react/compiler-runtime";
3
3
  import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
4
4
  import { useSyncExternalStore } from "react";
5
5
  import { Button, Text, UNSTABLE_Toast, UNSTABLE_ToastContent, UNSTABLE_ToastQueue, UNSTABLE_ToastRegion } from "react-aria-components";
6
- import { CloseGlyph } from "../../glyphs/index.js";
6
+ import { CloseGlyph, ErrorGlyph } from "../../glyphs/index.js";
7
7
  import { useBottomEdgeClearance } from "../../hooks/useBottomEdge.js";
8
8
  import { useRipple } from "../../hooks/useRipple.js";
9
9
  import { mergeStatefulStyles } from "../../styles/merge.js";
@@ -163,12 +163,13 @@ var SnackbarQueue = class {
163
163
  * it does not come back.
164
164
  */
165
165
  add(message, options = {}) {
166
- const { action, onClose, showCloseButton = false, timeout } = options;
166
+ const { action, onClose, showCloseButton = false, timeout, tone } = options;
167
167
  this.clear();
168
168
  const key = this.#toasts.add({
169
169
  action,
170
170
  message,
171
- showCloseButton
171
+ showCloseButton,
172
+ tone
172
173
  }, { timeout: readableTimeout(timeout ?? (action === void 0 ? MESSAGE_MS : UNTIL_CLOSED)) });
173
174
  this.#open.set(key, onClose);
174
175
  return key;
@@ -364,9 +365,9 @@ function SnackbarControls(t0) {
364
365
  }
365
366
  /** One snackbar: its message, then whatever sits after it. */
366
367
  function SnackbarToast(t0) {
367
- const $ = c(14);
368
+ const $ = c(17);
368
369
  const { close, closeLabel, queue, toast } = t0;
369
- const { action, message, showCloseButton } = toast.content;
370
+ const { action, message, showCloseButton, tone } = toast.content;
370
371
  const fading = useFading(queue, toast.key);
371
372
  let t1;
372
373
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -378,47 +379,58 @@ function SnackbarToast(t0) {
378
379
  } else t1 = $[0];
379
380
  const t2 = t1[!!fading << 0];
380
381
  let t3;
381
- if ($[1] !== message) {
382
- t3 = /* @__PURE__ */ jsx(UNSTABLE_ToastContent, {
382
+ if ($[1] !== tone) {
383
+ t3 = tone === "failure" ? /* @__PURE__ */ jsx(ErrorGlyph, { className: "xqcrz7y x1qx5ct2 x9f619 x7yhsra x2lah0s xw4jnvo x1hmvnq2 xq0p5jb" }) : null;
384
+ $[1] = tone;
385
+ $[2] = t3;
386
+ } else t3 = $[2];
387
+ let t4;
388
+ if ($[3] !== message) {
389
+ t4 = /* @__PURE__ */ jsx(UNSTABLE_ToastContent, {
383
390
  className: "x9f619 x1girmi0 x4pfjvb x1iyjqo2 xpo2rfv x193rfdd x1hews6w xkjl1po xn43zvd xv61bfh xz158ff xeuugli xj0a0fe xxlmvz2",
384
391
  children: /* @__PURE__ */ jsx(Text, {
385
392
  slot: "title",
386
393
  children: message
387
394
  })
388
395
  });
389
- $[1] = message;
390
- $[2] = t3;
391
- } else t3 = $[2];
392
- let t4;
393
- if ($[3] !== action || $[4] !== close || $[5] !== closeLabel || $[6] !== fading || $[7] !== showCloseButton) {
394
- t4 = /* @__PURE__ */ jsx(SnackbarControls, {
396
+ $[3] = message;
397
+ $[4] = t4;
398
+ } else t4 = $[4];
399
+ let t5;
400
+ if ($[5] !== action || $[6] !== close || $[7] !== closeLabel || $[8] !== fading || $[9] !== showCloseButton) {
401
+ t5 = /* @__PURE__ */ jsx(SnackbarControls, {
395
402
  action,
396
403
  close,
397
404
  closeLabel,
398
405
  fading,
399
406
  showCloseButton
400
407
  });
401
- $[3] = action;
402
- $[4] = close;
403
- $[5] = closeLabel;
404
- $[6] = fading;
405
- $[7] = showCloseButton;
406
- $[8] = t4;
407
- } else t4 = $[8];
408
- let t5;
409
- if ($[9] !== t2 || $[10] !== t3 || $[11] !== t4 || $[12] !== toast) {
410
- t5 = /* @__PURE__ */ jsxs(UNSTABLE_Toast, {
408
+ $[5] = action;
409
+ $[6] = close;
410
+ $[7] = closeLabel;
411
+ $[8] = fading;
412
+ $[9] = showCloseButton;
413
+ $[10] = t5;
414
+ } else t5 = $[10];
415
+ let t6;
416
+ if ($[11] !== t2 || $[12] !== t3 || $[13] !== t4 || $[14] !== t5 || $[15] !== toast) {
417
+ t6 = /* @__PURE__ */ jsxs(UNSTABLE_Toast, {
411
418
  toast,
412
419
  ...t2,
413
- children: [t3, t4]
420
+ children: [
421
+ t3,
422
+ t4,
423
+ t5
424
+ ]
414
425
  });
415
- $[9] = t2;
416
- $[10] = t3;
417
- $[11] = t4;
418
- $[12] = toast;
419
- $[13] = t5;
420
- } else t5 = $[13];
421
- return t5;
426
+ $[11] = t2;
427
+ $[12] = t3;
428
+ $[13] = t4;
429
+ $[14] = t5;
430
+ $[15] = toast;
431
+ $[16] = t6;
432
+ } else t6 = $[16];
433
+ return t6;
422
434
  }
423
435
  /**
424
436
  * Whether a snackbar is fading out of its queue. `rac` is always the queue