@agentero/design-system 0.5.0 → 0.6.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.
- package/mcp/manifests/components.html +428 -2
- package/mcp/manifests/components.json +1 -1
- package/package.json +6 -1
- package/src/toast/icons.d.ts +36 -0
- package/src/toast/icons.js +45 -0
- package/src/toast/index.d.ts +2 -0
- package/src/toast/index.js +2 -0
- package/src/toast/toast.d.ts +324 -0
- package/src/toast/toast.js +163 -0
- package/theme/base.css +146 -8
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
//#region src/toast/icons.tsx
|
|
3
|
+
var t = (t) => /* @__PURE__ */ e("svg", {
|
|
4
|
+
width: "24",
|
|
5
|
+
height: "24",
|
|
6
|
+
viewBox: "0 0 24 24",
|
|
7
|
+
fill: "none",
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
9
|
+
...t,
|
|
10
|
+
children: /* @__PURE__ */ e("path", { d: "M10.5808 14.1462L8.25765 11.8231C8.1192 11.6846 7.94517 11.6138 7.73555 11.6106C7.52593 11.6074 7.34869 11.6782 7.20382 11.8231C7.05896 11.968 6.98653 12.1436 6.98653 12.35C6.98653 12.5564 7.05896 12.732 7.20382 12.8769L9.94805 15.6211C10.1288 15.8019 10.3397 15.8923 10.5808 15.8923C10.8218 15.8923 11.0327 15.8019 11.2134 15.6211L16.7769 10.0577C16.9153 9.91923 16.9862 9.7452 16.9894 9.53558C16.9926 9.32596 16.9218 9.14872 16.7769 9.00386C16.632 8.85899 16.4564 8.78656 16.25 8.78656C16.0436 8.78656 15.8679 8.85899 15.7231 9.00386L10.5808 14.1462ZM12.0016 21.5C10.6877 21.5 9.45268 21.2506 8.29655 20.752C7.1404 20.2533 6.13472 19.5766 5.2795 18.7217C4.42427 17.8669 3.74721 16.8616 3.24833 15.706C2.74944 14.5504 2.5 13.3156 2.5 12.0017C2.5 10.6877 2.74933 9.45271 3.248 8.29658C3.74667 7.14043 4.42342 6.13475 5.27825 5.27953C6.1331 4.4243 7.13834 3.74724 8.29398 3.24836C9.44959 2.74947 10.6844 2.50003 11.9983 2.50003C13.3122 2.50003 14.5473 2.74936 15.7034 3.24803C16.8596 3.7467 17.8652 4.42345 18.7205 5.27828C19.5757 6.13313 20.2527 7.13837 20.7516 8.29401C21.2505 9.44962 21.5 10.6844 21.5 11.9983C21.5 13.3123 21.2506 14.5473 20.752 15.7034C20.2533 16.8596 19.5765 17.8653 18.7217 18.7205C17.8669 19.5757 16.8616 20.2528 15.706 20.7517C14.5504 21.2505 13.3156 21.5 12.0016 21.5ZM12 20C14.2333 20 16.125 19.225 17.675 17.675C19.225 16.125 20 14.2333 20 12C20 9.76667 19.225 7.87501 17.675 6.32501C16.125 4.77501 14.2333 4.00001 12 4.00001C9.76664 4.00001 7.87498 4.77501 6.32498 6.32501C4.77498 7.87501 3.99998 9.76667 3.99998 12C3.99998 14.2333 4.77498 16.125 6.32498 17.675C7.87498 19.225 9.76664 20 12 20Z" })
|
|
11
|
+
}), n = (t) => /* @__PURE__ */ e("svg", {
|
|
12
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
13
|
+
width: "24",
|
|
14
|
+
height: "24",
|
|
15
|
+
viewBox: "0 0 24 24",
|
|
16
|
+
fill: "none",
|
|
17
|
+
...t,
|
|
18
|
+
children: /* @__PURE__ */ e("path", { d: "M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z" })
|
|
19
|
+
}), r = (t) => /* @__PURE__ */ e("svg", {
|
|
20
|
+
width: "24",
|
|
21
|
+
height: "24",
|
|
22
|
+
viewBox: "0 0 24 24",
|
|
23
|
+
fill: "none",
|
|
24
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
25
|
+
...t,
|
|
26
|
+
children: /* @__PURE__ */ e("path", { d: "M3.42555 20.4999C3.25605 20.4999 3.10382 20.4585 2.96887 20.3756C2.83392 20.2928 2.72897 20.1836 2.654 20.048C2.57602 19.9134 2.53312 19.7676 2.52532 19.6105C2.51752 19.4535 2.5599 19.2979 2.65245 19.1439L11.2132 4.35609C11.3057 4.20206 11.4216 4.08819 11.5607 4.01447C11.6998 3.94074 11.8462 3.90387 12.0001 3.90387C12.1539 3.90387 12.3004 3.94074 12.4395 4.01447C12.5786 4.08819 12.6944 4.20206 12.787 4.35609L21.3477 19.1439C21.4403 19.2979 21.4827 19.4535 21.4749 19.6105C21.4671 19.7676 21.4242 19.9134 21.3462 20.048C21.2712 20.1836 21.1663 20.2928 21.0313 20.3756C20.8964 20.4585 20.7441 20.4999 20.5746 20.4999H3.42555ZM4.4501 19H19.5501L12.0001 5.99997L4.4501 19ZM12.0001 17.8076C12.2289 17.8076 12.4208 17.7302 12.5756 17.5754C12.7304 17.4206 12.8078 17.2288 12.8078 17C12.8078 16.7711 12.7304 16.5793 12.5756 16.4245C12.4208 16.2697 12.2289 16.1923 12.0001 16.1923C11.7712 16.1923 11.5794 16.2697 11.4246 16.4245C11.2698 16.5793 11.1924 16.7711 11.1924 17C11.1924 17.2288 11.2698 17.4206 11.4246 17.5754C11.5794 17.7302 11.7712 17.8076 12.0001 17.8076ZM12.0004 15.1923C12.213 15.1923 12.3911 15.1204 12.5347 14.9767C12.6783 14.8329 12.7501 14.6548 12.7501 14.4423V10.9423C12.7501 10.7298 12.6782 10.5517 12.5344 10.4079C12.3906 10.2642 12.2124 10.1923 11.9998 10.1923C11.7872 10.1923 11.6091 10.2642 11.4655 10.4079C11.3219 10.5517 11.2501 10.7298 11.2501 10.9423V14.4423C11.2501 14.6548 11.322 14.8329 11.4658 14.9767C11.6096 15.1204 11.7878 15.1923 12.0004 15.1923Z" })
|
|
27
|
+
}), i = (t) => /* @__PURE__ */ e("svg", {
|
|
28
|
+
width: "24",
|
|
29
|
+
height: "24",
|
|
30
|
+
viewBox: "0 0 24 24",
|
|
31
|
+
fill: "none",
|
|
32
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
33
|
+
...t,
|
|
34
|
+
children: /* @__PURE__ */ e("path", { d: "M12.0003 16.75C12.2129 16.75 12.391 16.6781 12.5345 16.5343C12.6782 16.3906 12.75 16.2125 12.75 16V11.75C12.75 11.5375 12.6781 11.3593 12.5343 11.2155C12.3904 11.0718 12.2122 11 11.9998 11C11.7871 11 11.609 11.0718 11.4655 11.2155C11.3218 11.3593 11.25 11.5375 11.25 11.75V16C11.25 16.2125 11.3219 16.3906 11.4658 16.5343C11.6096 16.6781 11.7878 16.75 12.0003 16.75ZM12 9.2885C12.2288 9.2885 12.4207 9.21108 12.5755 9.05625C12.7303 8.90142 12.8077 8.70958 12.8077 8.48075C12.8077 8.25192 12.7303 8.06008 12.5755 7.90525C12.4207 7.75058 12.2288 7.67325 12 7.67325C11.7712 7.67325 11.5793 7.75058 11.4245 7.90525C11.2697 8.06008 11.1923 8.25192 11.1923 8.48075C11.1923 8.70958 11.2697 8.90142 11.4245 9.05625C11.5793 9.21108 11.7712 9.2885 12 9.2885ZM12.0017 21.5C10.6877 21.5 9.45267 21.2507 8.2965 20.752C7.14033 20.2533 6.13467 19.5766 5.2795 18.7218C4.42433 17.8669 3.74725 16.8617 3.24825 15.706C2.74942 14.5503 2.5 13.3156 2.5 12.0017C2.5 10.6877 2.74933 9.45267 3.248 8.2965C3.74667 7.14033 4.42342 6.13467 5.27825 5.2795C6.13308 4.42433 7.13833 3.74725 8.294 3.24825C9.44967 2.74942 10.6844 2.5 11.9983 2.5C13.3123 2.5 14.5473 2.74933 15.7035 3.248C16.8597 3.74667 17.8653 4.42342 18.7205 5.27825C19.5757 6.13308 20.2528 7.13833 20.7518 8.294C21.2506 9.44967 21.5 10.6844 21.5 11.9983C21.5 13.3123 21.2507 14.5473 20.752 15.7035C20.2533 16.8597 19.5766 17.8653 18.7218 18.7205C17.8669 19.5757 16.8617 20.2528 15.706 20.7518C14.5503 21.2506 13.3156 21.5 12.0017 21.5Z" })
|
|
35
|
+
}), a = (t) => /* @__PURE__ */ e("svg", {
|
|
36
|
+
width: "24",
|
|
37
|
+
height: "24",
|
|
38
|
+
viewBox: "0 0 24 24",
|
|
39
|
+
fill: "none",
|
|
40
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
41
|
+
...t,
|
|
42
|
+
children: /* @__PURE__ */ e("path", { d: "M12 13.0634L8.75381 16.3096C8.60895 16.4545 8.4333 16.5253 8.22689 16.5221C8.02049 16.5189 7.84485 16.4449 7.69999 16.3C7.55512 16.1551 7.48269 15.9779 7.48269 15.7683C7.48269 15.5587 7.55512 15.3814 7.69999 15.2366L10.9366 12L7.69036 8.77883C7.5455 8.63396 7.47467 8.45672 7.47789 8.2471C7.48109 8.03749 7.55512 7.86024 7.69999 7.71538C7.84485 7.57051 8.0221 7.49808 8.23171 7.49808C8.44131 7.49808 8.61855 7.57051 8.76341 7.71538L12 10.9616L15.2212 7.71538C15.366 7.57051 15.5417 7.49808 15.7481 7.49808C15.9545 7.49808 16.1301 7.57051 16.275 7.71538C16.4301 7.87051 16.5077 8.05032 16.5077 8.2548C16.5077 8.45929 16.4301 8.63396 16.275 8.77883L13.0384 12L16.2846 15.2462C16.4295 15.391 16.5019 15.5667 16.5019 15.7731C16.5019 15.9795 16.4295 16.1551 16.2846 16.3C16.1295 16.4551 15.9497 16.5327 15.7452 16.5327C15.5407 16.5327 15.366 16.4551 15.2212 16.3L12 13.0634Z" })
|
|
43
|
+
});
|
|
44
|
+
//#endregion
|
|
45
|
+
export { t as IconCheckCircle, a as IconCloseSmall, n as IconErrorOutline, i as IconInfoFilled, r as IconWarning };
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { toast as sonnerToast } from 'sonner';
|
|
3
|
+
import { VariantProps } from 'tailwind-variants';
|
|
4
|
+
/**
|
|
5
|
+
* Style recipe for Toast using tailwind-variants. Multi-slot recipe whose
|
|
6
|
+
* variants (`layout`, `type`) drive the two layout treatments (`inline`,
|
|
7
|
+
* `expanded`) across the five semantic toast types. Compound variants paint
|
|
8
|
+
* the colored left rail that distinguishes the expanded layout per type.
|
|
9
|
+
*
|
|
10
|
+
* Exported for advanced composition (e.g., styling a custom element to match
|
|
11
|
+
* a Toast slot). Prefer rendering the `Toast` provider + calling `toast()`.
|
|
12
|
+
*
|
|
13
|
+
* @summary tailwind-variants recipe backing the Toast component styles
|
|
14
|
+
*/
|
|
15
|
+
export declare const toastRecipe: import('tailwind-variants').TVReturnType<{
|
|
16
|
+
layout: {
|
|
17
|
+
inline: {
|
|
18
|
+
root: string;
|
|
19
|
+
iconWrapper: string;
|
|
20
|
+
contentWrapper: string;
|
|
21
|
+
leading: string;
|
|
22
|
+
trailing: string;
|
|
23
|
+
};
|
|
24
|
+
expanded: {
|
|
25
|
+
root: string;
|
|
26
|
+
iconWrapper: string;
|
|
27
|
+
contentWrapper: string;
|
|
28
|
+
leading: string;
|
|
29
|
+
trailing: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
type: {
|
|
33
|
+
neutral: {
|
|
34
|
+
icon: string;
|
|
35
|
+
};
|
|
36
|
+
success: {
|
|
37
|
+
icon: string;
|
|
38
|
+
};
|
|
39
|
+
error: {
|
|
40
|
+
icon: string;
|
|
41
|
+
};
|
|
42
|
+
warning: {
|
|
43
|
+
icon: string;
|
|
44
|
+
};
|
|
45
|
+
info: {
|
|
46
|
+
icon: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}, {
|
|
50
|
+
root: string;
|
|
51
|
+
iconWrapper: string;
|
|
52
|
+
icon: string;
|
|
53
|
+
contentWrapper: string;
|
|
54
|
+
leading: string;
|
|
55
|
+
title: string;
|
|
56
|
+
description: string;
|
|
57
|
+
trailing: string;
|
|
58
|
+
actionBtn: string;
|
|
59
|
+
}, undefined, {
|
|
60
|
+
layout: {
|
|
61
|
+
inline: {
|
|
62
|
+
root: string;
|
|
63
|
+
iconWrapper: string;
|
|
64
|
+
contentWrapper: string;
|
|
65
|
+
leading: string;
|
|
66
|
+
trailing: string;
|
|
67
|
+
};
|
|
68
|
+
expanded: {
|
|
69
|
+
root: string;
|
|
70
|
+
iconWrapper: string;
|
|
71
|
+
contentWrapper: string;
|
|
72
|
+
leading: string;
|
|
73
|
+
trailing: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
type: {
|
|
77
|
+
neutral: {
|
|
78
|
+
icon: string;
|
|
79
|
+
};
|
|
80
|
+
success: {
|
|
81
|
+
icon: string;
|
|
82
|
+
};
|
|
83
|
+
error: {
|
|
84
|
+
icon: string;
|
|
85
|
+
};
|
|
86
|
+
warning: {
|
|
87
|
+
icon: string;
|
|
88
|
+
};
|
|
89
|
+
info: {
|
|
90
|
+
icon: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
}, {
|
|
94
|
+
root: string;
|
|
95
|
+
iconWrapper: string;
|
|
96
|
+
icon: string;
|
|
97
|
+
contentWrapper: string;
|
|
98
|
+
leading: string;
|
|
99
|
+
title: string;
|
|
100
|
+
description: string;
|
|
101
|
+
trailing: string;
|
|
102
|
+
actionBtn: string;
|
|
103
|
+
}, import('tailwind-variants').TVReturnType<{
|
|
104
|
+
layout: {
|
|
105
|
+
inline: {
|
|
106
|
+
root: string;
|
|
107
|
+
iconWrapper: string;
|
|
108
|
+
contentWrapper: string;
|
|
109
|
+
leading: string;
|
|
110
|
+
trailing: string;
|
|
111
|
+
};
|
|
112
|
+
expanded: {
|
|
113
|
+
root: string;
|
|
114
|
+
iconWrapper: string;
|
|
115
|
+
contentWrapper: string;
|
|
116
|
+
leading: string;
|
|
117
|
+
trailing: string;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
type: {
|
|
121
|
+
neutral: {
|
|
122
|
+
icon: string;
|
|
123
|
+
};
|
|
124
|
+
success: {
|
|
125
|
+
icon: string;
|
|
126
|
+
};
|
|
127
|
+
error: {
|
|
128
|
+
icon: string;
|
|
129
|
+
};
|
|
130
|
+
warning: {
|
|
131
|
+
icon: string;
|
|
132
|
+
};
|
|
133
|
+
info: {
|
|
134
|
+
icon: string;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
}, {
|
|
138
|
+
root: string;
|
|
139
|
+
iconWrapper: string;
|
|
140
|
+
icon: string;
|
|
141
|
+
contentWrapper: string;
|
|
142
|
+
leading: string;
|
|
143
|
+
title: string;
|
|
144
|
+
description: string;
|
|
145
|
+
trailing: string;
|
|
146
|
+
actionBtn: string;
|
|
147
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
148
|
+
type ToastVariants = VariantProps<typeof toastRecipe>;
|
|
149
|
+
/**
|
|
150
|
+
* Semantic type of a toast notification. Drives the built-in icon and the
|
|
151
|
+
* color applied to the expanded-layout left rail.
|
|
152
|
+
*
|
|
153
|
+
* @summary Toast semantic type union (`neutral`, `success`, `error`, `warning`, `info`)
|
|
154
|
+
*/
|
|
155
|
+
export type ToastType = NonNullable<ToastVariants['type']>;
|
|
156
|
+
/** Structured action with a label and click handler, rendered as a secondary Button. */
|
|
157
|
+
type ToastActionObject = {
|
|
158
|
+
label: ReactNode;
|
|
159
|
+
onClick: () => void;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Trailing action rendered next to the title. Pass `{ label, onClick }` for
|
|
163
|
+
* the built-in secondary Button, or any ReactNode to render a custom control.
|
|
164
|
+
*
|
|
165
|
+
* @summary Toast action — structured object or raw ReactNode
|
|
166
|
+
*/
|
|
167
|
+
export type ToastAction = ToastActionObject | ReactNode;
|
|
168
|
+
/**
|
|
169
|
+
* Options passed to {@link toast} and its typed helpers. Controls the toast's
|
|
170
|
+
* content, layout, trailing actions, auto-dismiss duration, and id.
|
|
171
|
+
*
|
|
172
|
+
* @summary Options for the imperative `toast()` API
|
|
173
|
+
*/
|
|
174
|
+
export type ToastOptions = {
|
|
175
|
+
/** Optional secondary text shown below the title. */
|
|
176
|
+
description?: ReactNode;
|
|
177
|
+
/**
|
|
178
|
+
* Layout variant. Defaults to `'inline'`.
|
|
179
|
+
* - `'inline'` — compact single-line layout.
|
|
180
|
+
* - `'expanded'` — multi-line layout with a colored left rail.
|
|
181
|
+
*/
|
|
182
|
+
variant?: 'inline' | 'expanded';
|
|
183
|
+
/** Custom icon that overrides the default type-based icon. */
|
|
184
|
+
icon?: ReactNode;
|
|
185
|
+
/**
|
|
186
|
+
* Optional primary action rendered in the trailing area. Pass
|
|
187
|
+
* `{ label, onClick }` for the built-in secondary Button, or any ReactNode
|
|
188
|
+
* for a custom control.
|
|
189
|
+
*/
|
|
190
|
+
action?: ToastAction;
|
|
191
|
+
/** Optional cancel button rendered alongside `action`. */
|
|
192
|
+
cancel?: {
|
|
193
|
+
label: ReactNode;
|
|
194
|
+
onClick: () => void;
|
|
195
|
+
};
|
|
196
|
+
/** Auto-dismiss duration in milliseconds. Overrides the `Toast` provider default. */
|
|
197
|
+
duration?: number;
|
|
198
|
+
/** Explicit toast id — useful for deduplication or programmatic dismissal via `toast.dismiss(id)`. */
|
|
199
|
+
id?: string | number;
|
|
200
|
+
/** Additional className merged onto the root element. Escape hatch — prefer `variant` and `type` for style decisions. */
|
|
201
|
+
className?: string;
|
|
202
|
+
/** Whether to show the dismiss (close) button. Defaults to `true`. */
|
|
203
|
+
dismissible?: boolean;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Imperative API for showing toast notifications. Calling `toast(title)`
|
|
207
|
+
* fires a neutral toast; the typed helpers (`toast.success`, `toast.error`,
|
|
208
|
+
* `toast.warning`, `toast.info`) apply the matching semantic icon and color.
|
|
209
|
+
*
|
|
210
|
+
* `toast.dismiss(id?)` dismisses a specific toast (or all of them when called
|
|
211
|
+
* without an id); `toast.loading` + `toast.promise` wire to sonner's async
|
|
212
|
+
* helpers; `toast.custom` is an escape hatch for fully-custom render output —
|
|
213
|
+
* reach for the typed helpers first.
|
|
214
|
+
*
|
|
215
|
+
* Requires a `<Toast />` provider mounted somewhere in the React tree.
|
|
216
|
+
*
|
|
217
|
+
* @summary Imperative `toast()` with typed semantic helpers and async utilities
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* toast('Something happened');
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* toast.success('Policy saved');
|
|
224
|
+
* toast.error('Save failed');
|
|
225
|
+
* toast.warning('License expiring soon');
|
|
226
|
+
* toast.info('Sync in progress');
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* toast.error('Upload failed', {
|
|
230
|
+
* variant: 'expanded',
|
|
231
|
+
* description: 'The file could not be processed.',
|
|
232
|
+
* action: { label: 'Retry', onClick: retry }
|
|
233
|
+
* });
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* const id = toast.info('Uploading...');
|
|
237
|
+
* toast.dismiss(id);
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* toast.promise(saveDocument(), {
|
|
241
|
+
* loading: 'Saving...',
|
|
242
|
+
* success: 'Saved',
|
|
243
|
+
* error: 'Save failed'
|
|
244
|
+
* });
|
|
245
|
+
*/
|
|
246
|
+
type TypedToastFn = (title: ReactNode, options?: ToastOptions) => string | number;
|
|
247
|
+
type ToastApi = TypedToastFn & {
|
|
248
|
+
success: TypedToastFn;
|
|
249
|
+
error: TypedToastFn;
|
|
250
|
+
warning: TypedToastFn;
|
|
251
|
+
info: TypedToastFn;
|
|
252
|
+
dismiss: typeof sonnerToast.dismiss;
|
|
253
|
+
custom: typeof sonnerToast.custom;
|
|
254
|
+
loading: typeof sonnerToast.loading;
|
|
255
|
+
promise: typeof sonnerToast.promise;
|
|
256
|
+
};
|
|
257
|
+
export declare const toast: ToastApi;
|
|
258
|
+
/**
|
|
259
|
+
* Placement of the Toaster on the screen. Mirrors sonner's `position` prop.
|
|
260
|
+
*
|
|
261
|
+
* @summary Toaster screen position union
|
|
262
|
+
*/
|
|
263
|
+
export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
264
|
+
/**
|
|
265
|
+
* Props for the `Toast` provider. Exposes the sonner `Toaster` configuration
|
|
266
|
+
* surface the design system documents directly (`position`, `duration`,
|
|
267
|
+
* `className`, `dir`, `gap`, `offset`, `expand`, `visibleToasts`, `hotkey`,
|
|
268
|
+
* `richColors`, `invert`). Any additional props are forwarded to sonner via
|
|
269
|
+
* the underlying `<Toaster>` component.
|
|
270
|
+
*
|
|
271
|
+
* @summary Props accepted by the Toast provider
|
|
272
|
+
*/
|
|
273
|
+
export type ToastProps = {
|
|
274
|
+
/** Placement of the toaster on the screen. Defaults to `'bottom-right'`. */
|
|
275
|
+
position?: ToastPosition;
|
|
276
|
+
/** Default auto-dismiss duration in ms for toasts fired against this provider. Defaults to `5000`. */
|
|
277
|
+
duration?: number;
|
|
278
|
+
/** Text direction. Sonner forwards this to the rendered toaster root. */
|
|
279
|
+
dir?: 'auto' | 'ltr' | 'rtl';
|
|
280
|
+
/** Gap between stacked toasts, in pixels. */
|
|
281
|
+
gap?: number;
|
|
282
|
+
/** Offset from the screen edge, in pixels or as a CSS length. */
|
|
283
|
+
offset?: string | number;
|
|
284
|
+
/** When `true`, stack expands on hover instead of auto-collapsing. */
|
|
285
|
+
expand?: boolean;
|
|
286
|
+
/** Maximum number of toasts rendered at once before earlier ones dismiss. */
|
|
287
|
+
visibleToasts?: number;
|
|
288
|
+
/** Keyboard shortcut used to focus the toaster. */
|
|
289
|
+
hotkey?: string[];
|
|
290
|
+
/** When `true`, sonner paints colored backgrounds per type (DS uses its own icon tokens by default). */
|
|
291
|
+
richColors?: boolean;
|
|
292
|
+
/** When `true`, flips light/dark theme on the toaster root. */
|
|
293
|
+
invert?: boolean;
|
|
294
|
+
/** Additional className merged onto the sonner `<Toaster>` root. */
|
|
295
|
+
className?: string;
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Toast provider. Renders the sonner `<Toaster />` configured for the
|
|
299
|
+
* {@link toast} imperative API. Mount it once near the root of your React
|
|
300
|
+
* tree (below any context providers that the toasts need, and above the
|
|
301
|
+
* rest of the app) so every call to `toast()` from anywhere in the tree
|
|
302
|
+
* renders into the same surface.
|
|
303
|
+
*
|
|
304
|
+
* Defaults: `position='bottom-right'`, `duration=5000`. The Toaster is sized
|
|
305
|
+
* to `23.75rem` (`[--width:23.75rem]`) and each list item stretches to that
|
|
306
|
+
* width (`[&>li]:w-full`) so the DS Toast fills the Toaster row rather than
|
|
307
|
+
* sonner's 356px default. The provider disables sonner's built-in close
|
|
308
|
+
* button (`closeButton={false}`) — dismissal is rendered inside each Toast
|
|
309
|
+
* by the DS component itself.
|
|
310
|
+
*
|
|
311
|
+
* Do **not** use Toast for persistent feedback — mount an `Alert` with
|
|
312
|
+
* `color="success|danger"` instead. Do **not** use Toast for form
|
|
313
|
+
* validation errors — render those inline with the form field.
|
|
314
|
+
*
|
|
315
|
+
* @summary Toast provider; mount once near the app root
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* <Toast />
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* <Toast position="top-center" duration={4000} />
|
|
322
|
+
*/
|
|
323
|
+
export declare const Toast: ({ position, duration, className, ...props }: ToastProps) => import("react/jsx-runtime").JSX.Element;
|
|
324
|
+
export {};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { Button as t } from "../button/button.js";
|
|
4
|
+
import { IconCheckCircle as n, IconCloseSmall as r, IconErrorOutline as i, IconInfoFilled as a, IconWarning as o } from "./icons.js";
|
|
5
|
+
import { tv as s } from "tailwind-variants";
|
|
6
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
|
+
import { Toaster as u, toast as d } from "sonner";
|
|
8
|
+
//#region src/toast/toast.tsx
|
|
9
|
+
var f = s({
|
|
10
|
+
slots: {
|
|
11
|
+
root: "w-full flex items-start border border-border-default-base-primary bg-white text-text-default-base-primary shadow-xs",
|
|
12
|
+
iconWrapper: "shrink-0",
|
|
13
|
+
icon: "size-6 [&_svg]:size-6 [&_path]:fill-current",
|
|
14
|
+
contentWrapper: "flex flex-1 min-w-0",
|
|
15
|
+
leading: "flex flex-1 min-w-0 text-sm leading-normal",
|
|
16
|
+
title: "font-semibold text-text-default-base-primary shrink-0",
|
|
17
|
+
description: "font-normal text-text-default-base-tertiary",
|
|
18
|
+
trailing: "flex items-center gap-2",
|
|
19
|
+
actionBtn: "min-w-0 shadow-xs"
|
|
20
|
+
},
|
|
21
|
+
variants: {
|
|
22
|
+
layout: {
|
|
23
|
+
inline: {
|
|
24
|
+
root: "rounded-lg p-2 gap-2 items-center",
|
|
25
|
+
iconWrapper: "pl-1",
|
|
26
|
+
contentWrapper: "flex-row items-center gap-0",
|
|
27
|
+
leading: "flex-col items-start gap-0",
|
|
28
|
+
trailing: "pl-2"
|
|
29
|
+
},
|
|
30
|
+
expanded: {
|
|
31
|
+
root: "rounded-md p-4 gap-1 [background-size:0.375rem_100%] bg-left bg-no-repeat",
|
|
32
|
+
iconWrapper: "-mt-px",
|
|
33
|
+
contentWrapper: "flex-col items-start gap-3",
|
|
34
|
+
leading: "flex-col items-start gap-0 px-2",
|
|
35
|
+
trailing: "px-2"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
type: {
|
|
39
|
+
neutral: { icon: "text-icon-default-base-secondary" },
|
|
40
|
+
success: { icon: "text-icon-default-positive-primary" },
|
|
41
|
+
error: { icon: "text-icon-default-danger-primary" },
|
|
42
|
+
warning: { icon: "text-icon-default-warning-primary" },
|
|
43
|
+
info: { icon: "text-icon-default-info-primary" }
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
compoundVariants: [
|
|
47
|
+
{
|
|
48
|
+
layout: "expanded",
|
|
49
|
+
type: "neutral",
|
|
50
|
+
class: { root: "bg-[linear-gradient(var(--color-rail-neutral),var(--color-rail-neutral))]" }
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
layout: "expanded",
|
|
54
|
+
type: "success",
|
|
55
|
+
class: { root: "bg-[linear-gradient(var(--color-rail-success),var(--color-rail-success))]" }
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
layout: "expanded",
|
|
59
|
+
type: "error",
|
|
60
|
+
class: { root: "bg-[linear-gradient(var(--color-rail-danger),var(--color-rail-danger))]" }
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
layout: "expanded",
|
|
64
|
+
type: "warning",
|
|
65
|
+
class: { root: "bg-[linear-gradient(var(--color-rail-warning),var(--color-rail-warning))]" }
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
layout: "expanded",
|
|
69
|
+
type: "info",
|
|
70
|
+
class: { root: "bg-[linear-gradient(var(--color-rail-info),var(--color-rail-info))]" }
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
defaultVariants: {
|
|
74
|
+
layout: "inline",
|
|
75
|
+
type: "neutral"
|
|
76
|
+
}
|
|
77
|
+
}), p = (e) => typeof e == "object" && !!e && "onClick" in e, m = {
|
|
78
|
+
neutral: /* @__PURE__ */ c(a, {}),
|
|
79
|
+
success: /* @__PURE__ */ c(n, {}),
|
|
80
|
+
info: /* @__PURE__ */ c(a, {}),
|
|
81
|
+
warning: /* @__PURE__ */ c(o, {}),
|
|
82
|
+
error: /* @__PURE__ */ c(i, {})
|
|
83
|
+
}, h = ({ id: n, title: i, type: a = "neutral", variant: o = "inline", icon: s, description: u, action: h, cancel: g, className: _, dismissible: v = !0 }) => {
|
|
84
|
+
let y = f({
|
|
85
|
+
layout: o,
|
|
86
|
+
type: a
|
|
87
|
+
});
|
|
88
|
+
return /* @__PURE__ */ l("div", {
|
|
89
|
+
"data-slot": "toast",
|
|
90
|
+
className: e(y.root(), _),
|
|
91
|
+
children: [
|
|
92
|
+
/* @__PURE__ */ c("div", {
|
|
93
|
+
className: y.iconWrapper(),
|
|
94
|
+
children: /* @__PURE__ */ c("span", {
|
|
95
|
+
className: y.icon(),
|
|
96
|
+
children: s ?? m[a]
|
|
97
|
+
})
|
|
98
|
+
}),
|
|
99
|
+
/* @__PURE__ */ l("div", {
|
|
100
|
+
className: y.contentWrapper(),
|
|
101
|
+
children: [/* @__PURE__ */ l("div", {
|
|
102
|
+
className: y.leading(),
|
|
103
|
+
children: [i && /* @__PURE__ */ c("h2", {
|
|
104
|
+
className: y.title(),
|
|
105
|
+
children: i
|
|
106
|
+
}), u && /* @__PURE__ */ c("p", {
|
|
107
|
+
className: y.description(),
|
|
108
|
+
children: u
|
|
109
|
+
})]
|
|
110
|
+
}), (h || g) && /* @__PURE__ */ l("div", {
|
|
111
|
+
className: y.trailing(),
|
|
112
|
+
children: [h && (p(h) ? /* @__PURE__ */ c(t, {
|
|
113
|
+
variant: "secondary",
|
|
114
|
+
className: y.actionBtn(),
|
|
115
|
+
onClick: () => {
|
|
116
|
+
h.onClick(), d.dismiss(n);
|
|
117
|
+
},
|
|
118
|
+
children: h.label
|
|
119
|
+
}) : h), g && /* @__PURE__ */ c(t, {
|
|
120
|
+
variant: "ghost",
|
|
121
|
+
onClick: () => {
|
|
122
|
+
g.onClick(), d.dismiss(n);
|
|
123
|
+
},
|
|
124
|
+
children: g.label
|
|
125
|
+
})]
|
|
126
|
+
})]
|
|
127
|
+
}),
|
|
128
|
+
v && /* @__PURE__ */ c(t, {
|
|
129
|
+
onClick: () => d.dismiss(n),
|
|
130
|
+
"aria-label": "Close",
|
|
131
|
+
variant: "ghost",
|
|
132
|
+
iconOnly: !0,
|
|
133
|
+
children: /* @__PURE__ */ c(r, {})
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
}, g = (e, t, n) => {
|
|
138
|
+
let { duration: r, id: i, className: a, ...o } = n ?? {}, s = {};
|
|
139
|
+
return r !== void 0 && (s.duration = r), i !== void 0 && (s.id = i), d.custom((n) => /* @__PURE__ */ c(h, {
|
|
140
|
+
id: n,
|
|
141
|
+
title: e,
|
|
142
|
+
type: t,
|
|
143
|
+
className: a,
|
|
144
|
+
...o
|
|
145
|
+
}), s);
|
|
146
|
+
}, _ = Object.assign((e, t) => g(e, void 0, t), {
|
|
147
|
+
success: (e, t) => g(e, "success", t),
|
|
148
|
+
error: (e, t) => g(e, "error", t),
|
|
149
|
+
warning: (e, t) => g(e, "warning", t),
|
|
150
|
+
info: (e, t) => g(e, "info", t),
|
|
151
|
+
dismiss: d.dismiss,
|
|
152
|
+
custom: d.custom,
|
|
153
|
+
loading: d.loading,
|
|
154
|
+
promise: d.promise
|
|
155
|
+
}), v = ({ position: t = "bottom-right", duration: n = 5e3, className: r, ...i }) => /* @__PURE__ */ c(u, {
|
|
156
|
+
...i,
|
|
157
|
+
position: t,
|
|
158
|
+
duration: n,
|
|
159
|
+
closeButton: !1,
|
|
160
|
+
className: e("[--width:23.75rem]! [&>li]:w-full", r)
|
|
161
|
+
});
|
|
162
|
+
//#endregion
|
|
163
|
+
export { v as Toast, _ as toast, f as toastRecipe };
|