@epilot/spark-ui 1.0.0-alpha.8 → 1.0.0-alpha.9
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/dist/components/accordion.cjs +1 -1
- package/dist/components/accordion.d.ts +1 -1
- package/dist/components/accordion.js +1 -1
- package/dist/components/badge.cjs +2 -2
- package/dist/components/badge.cjs.map +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/bar-chart.js +1 -1
- package/dist/components/battery-progress-row.d.cts +1 -1
- package/dist/components/battery-progress-row.d.ts +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/button.cjs +2 -2
- package/dist/components/button.cjs.map +1 -1
- package/dist/components/button.d.cts +2 -2
- package/dist/components/button.d.ts +3 -3
- package/dist/components/button.js +1 -1
- package/dist/components/callout.cjs +4 -4
- package/dist/components/callout.cjs.map +1 -1
- package/dist/components/callout.d.cts +7 -2
- package/dist/components/callout.d.ts +7 -2
- package/dist/components/callout.js +4 -4
- package/dist/components/callout.js.map +1 -1
- package/dist/components/card.d.ts +1 -1
- package/dist/components/checkbox.cjs +2 -2
- package/dist/components/checkbox.cjs.map +1 -1
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/circular-gauge.d.cts +1 -1
- package/dist/components/circular-gauge.d.ts +1 -1
- package/dist/components/device-card.d.cts +1 -1
- package/dist/components/device-card.d.ts +1 -1
- package/dist/components/energy-bar-chart.d.cts +1 -1
- package/dist/components/energy-bar-chart.d.ts +1 -1
- package/dist/components/feed-in-hero.d.cts +1 -1
- package/dist/components/feed-in-hero.d.ts +1 -1
- package/dist/components/field.cjs +3 -3
- package/dist/components/field.cjs.map +1 -1
- package/dist/components/field.d.ts +1 -1
- package/dist/components/field.js +1 -1
- package/dist/components/input-group.cjs +2 -2
- package/dist/components/input-group.cjs.map +1 -1
- package/dist/components/input-group.js +1 -1
- package/dist/components/input-otp.cjs +10 -10
- package/dist/components/input-otp.cjs.map +1 -1
- package/dist/components/input-otp.js +1 -1
- package/dist/components/input.cjs +10 -10
- package/dist/components/input.cjs.map +1 -1
- package/dist/components/input.d.ts +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/line-chart.js +1 -1
- package/dist/components/metering-row.d.cts +1 -1
- package/dist/components/metering-row.d.ts +1 -1
- package/dist/components/number-flow.d.cts +1 -1
- package/dist/components/number-flow.d.ts +1 -1
- package/dist/components/power-history-chart.js +1 -1
- package/dist/components/power-history.cjs +1 -1
- package/dist/components/power-history.js +1 -1
- package/dist/components/power-network.cjs +1 -1
- package/dist/components/power-network.js +1 -1
- package/dist/components/radio.cjs +3 -3
- package/dist/components/radio.cjs.map +1 -1
- package/dist/components/radio.d.ts +1 -1
- package/dist/components/radio.js +1 -1
- package/dist/components/sankey-chart.d.cts +1 -1
- package/dist/components/sankey-chart.d.ts +1 -1
- package/dist/components/segmented-control.d.ts +1 -1
- package/dist/components/select.cjs +2 -2
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.d.ts +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/switch.cjs +2 -2
- package/dist/components/switch.cjs.map +1 -1
- package/dist/components/switch.d.ts +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/theme.cjs +119 -3
- package/dist/components/theme.cjs.map +1 -0
- package/dist/components/theme.d.cts +1 -3
- package/dist/components/theme.d.ts +2 -4
- package/dist/components/theme.js +115 -1
- package/dist/components/theme.js.map +1 -0
- package/dist/components/toast.cjs +158 -65
- package/dist/components/toast.cjs.map +1 -1
- package/dist/components/toast.d.cts +51 -9
- package/dist/components/toast.d.ts +51 -9
- package/dist/components/toast.js +158 -65
- package/dist/components/toast.js.map +1 -1
- package/dist/generate-radix-colors-BW09KT9m.d.ts +33 -0
- package/dist/generate-radix-colors-C5mWRWnQ.d.cts +33 -0
- package/dist/{accent-colors-CjHCf8fH.cjs → lib/accent-colors.cjs} +3 -7
- package/dist/lib/accent-colors.cjs.map +1 -0
- package/dist/lib/accent-colors.d.cts +8 -0
- package/dist/lib/accent-colors.d.ts +8 -0
- package/dist/{accent-colors-Ch2J0EEY.js → lib/accent-colors.js} +2 -2
- package/dist/lib/accent-colors.js.map +1 -0
- package/dist/lib/accent-theme.cjs +130 -0
- package/dist/lib/accent-theme.cjs.map +1 -0
- package/dist/lib/accent-theme.d.cts +35 -0
- package/dist/lib/accent-theme.d.ts +35 -0
- package/dist/lib/accent-theme.js +122 -0
- package/dist/lib/accent-theme.js.map +1 -0
- package/dist/{theme-ClRJhexF.cjs → lib/generate-radix-colors.cjs} +12 -240
- package/dist/lib/generate-radix-colors.cjs.map +1 -0
- package/dist/lib/generate-radix-colors.d.cts +4 -0
- package/dist/lib/generate-radix-colors.d.ts +4 -0
- package/dist/{theme-8PDO9E0S.js → lib/generate-radix-colors.js} +8 -225
- package/dist/lib/generate-radix-colors.js.map +1 -0
- package/dist/{input-box-variants-ZCtgs-1S.cjs → lib/input-box-variants.cjs} +5 -14
- package/dist/lib/input-box-variants.cjs.map +1 -0
- package/dist/lib/input-box-variants.d.cts +10 -0
- package/dist/lib/input-box-variants.d.ts +10 -0
- package/dist/{input-box-variants-DcajYXvo.js → lib/input-box-variants.js} +3 -3
- package/dist/lib/input-box-variants.js.map +1 -0
- package/dist/lib/theme-types.cjs +1 -0
- package/dist/lib/theme-types.d.cts +4 -0
- package/dist/lib/theme-types.d.ts +4 -0
- package/dist/lib/theme-types.js +2 -0
- package/dist/lib/tones.cjs +14 -0
- package/dist/lib/tones.cjs.map +1 -0
- package/dist/{tones-PXJGlSpe.d.ts → lib/tones.d.cts} +2 -2
- package/dist/{tones-DjgKOX3s.d.cts → lib/tones.d.ts} +2 -2
- package/dist/lib/tones.js +13 -0
- package/dist/lib/tones.js.map +1 -0
- package/dist/{number-flow-DMJouddg.d.cts → number-flow-CVIvQhZn.d.cts} +1 -1
- package/dist/{number-flow-D9zsxH0-.d.ts → number-flow-DVUHTv9D.d.ts} +1 -1
- package/dist/styles/index.css +158 -0
- package/dist/{theme-types-BDdoRxXa.d.ts → theme-types-BKlzRiyw.d.ts} +1 -1
- package/package.json +18 -3
- package/dist/accent-colors-Ch2J0EEY.js.map +0 -1
- package/dist/accent-colors-CjHCf8fH.cjs.map +0 -1
- package/dist/input-box-variants-DcajYXvo.js.map +0 -1
- package/dist/input-box-variants-ZCtgs-1S.cjs.map +0 -1
- package/dist/theme-8PDO9E0S.js.map +0 -1
- package/dist/theme-ClRJhexF.cjs.map +0 -1
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const require_chunk = require("../chunk-aJGBMT86.cjs");
|
|
5
5
|
const require_icons_material_symbol = require("../icons/material-symbol.cjs");
|
|
6
|
+
const require_components_button = require("./button.cjs");
|
|
6
7
|
const require_components_spinner = require("./spinner.cjs");
|
|
7
8
|
let react = require("react");
|
|
8
9
|
react = require_chunk.__toESM(react);
|
|
9
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
-
let
|
|
11
|
+
let _base_ui_react_toast = require("@base-ui/react/toast");
|
|
11
12
|
let cnfast = require("cnfast");
|
|
12
13
|
//#region src/components/toast.tsx
|
|
13
|
-
const
|
|
14
|
+
const TOAST_ICONS = {
|
|
14
15
|
success: {
|
|
15
16
|
name: "check_circle",
|
|
16
17
|
className: "text-success-light"
|
|
@@ -27,73 +28,165 @@ const ICONS = Object.fromEntries(Object.entries({
|
|
|
27
28
|
name: "cancel",
|
|
28
29
|
className: "text-error-light"
|
|
29
30
|
}
|
|
30
|
-
}).map(([type, icon]) => [type, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons_material_symbol.MaterialSymbol, {
|
|
31
|
-
className: (0, cnfast.cn)("inline-flex shrink-0 items-center [--spark-icon-size:16px]", icon.className),
|
|
32
|
-
name: icon.name
|
|
33
|
-
}, type)]));
|
|
34
|
-
ICONS.loading = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_spinner.Spinner, {
|
|
35
|
-
"aria-hidden": "true",
|
|
36
|
-
className: "flex text-gray-11",
|
|
37
|
-
label: "",
|
|
38
|
-
role: "presentation",
|
|
39
|
-
size: "sm"
|
|
40
|
-
});
|
|
41
|
-
const STYLE_VARS = {
|
|
42
|
-
"--normal-bg": "var(--color-gray-2)",
|
|
43
|
-
"--normal-text": "var(--color-gray-12)",
|
|
44
|
-
"--normal-border": "var(--color-gray-a1)",
|
|
45
|
-
"--border-radius": "var(--radius-lg)",
|
|
46
|
-
"--gray1": "var(--color-gray-1)",
|
|
47
|
-
"--gray2": "var(--color-gray-2)",
|
|
48
|
-
"--gray3": "var(--color-gray-3)",
|
|
49
|
-
"--gray4": "var(--color-gray-4)",
|
|
50
|
-
"--gray5": "var(--color-gray-5)",
|
|
51
|
-
"--gray11": "var(--color-gray-11)",
|
|
52
|
-
"--gray12": "var(--color-gray-12)",
|
|
53
|
-
"--toast-close-button-start": "unset",
|
|
54
|
-
"--toast-close-button-end": "0",
|
|
55
|
-
"--toast-close-button-transform": "translate(35%, -35%)",
|
|
56
|
-
"--success-bg": "var(--color-green-2)",
|
|
57
|
-
"--success-border": "transparent",
|
|
58
|
-
"--success-text": "var(--color-green-11)",
|
|
59
|
-
"--info-bg": "var(--color-blue-2)",
|
|
60
|
-
"--info-border": "transparent",
|
|
61
|
-
"--info-text": "var(--color-blue-11)",
|
|
62
|
-
"--warning-bg": "var(--color-orange-2)",
|
|
63
|
-
"--warning-border": "transparent",
|
|
64
|
-
"--warning-text": "var(--color-orange-11)",
|
|
65
|
-
"--error-bg": "var(--color-red-2)",
|
|
66
|
-
"--error-border": "transparent",
|
|
67
|
-
"--error-text": "var(--color-red-11)"
|
|
68
31
|
};
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
32
|
+
const TONE_CLASSES = {
|
|
33
|
+
success: "border-green-6 bg-green-2 text-green-11",
|
|
34
|
+
info: "border-blue-6 bg-blue-2 text-blue-11",
|
|
35
|
+
warning: "border-orange-6 bg-orange-2 text-orange-11",
|
|
36
|
+
error: "border-red-6 bg-red-2 text-red-11"
|
|
73
37
|
};
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
38
|
+
const POSITION_CLASSES = {
|
|
39
|
+
"top-left": "sm:top-4 sm:right-auto sm:bottom-auto sm:left-4",
|
|
40
|
+
"top-center": "sm:top-4 sm:right-auto sm:bottom-auto sm:left-1/2 sm:-translate-x-1/2",
|
|
41
|
+
"top-right": "sm:top-4 sm:right-4 sm:bottom-auto sm:left-auto",
|
|
42
|
+
"bottom-left": "sm:top-auto sm:right-auto sm:bottom-4 sm:left-4",
|
|
43
|
+
"bottom-center": "sm:top-auto sm:right-auto sm:bottom-4 sm:left-1/2 sm:-translate-x-1/2",
|
|
44
|
+
"bottom-right": "sm:top-auto sm:right-4 sm:bottom-4 sm:left-auto"
|
|
45
|
+
};
|
|
46
|
+
const manager = _base_ui_react_toast.Toast.createToastManager();
|
|
47
|
+
let sequence = 0;
|
|
48
|
+
function actionRest({ label: _label, onClick: _onClick, ...rest }) {
|
|
49
|
+
return rest;
|
|
50
|
+
}
|
|
51
|
+
function toManagerOptions(id, title, type, options) {
|
|
52
|
+
const action = options?.action;
|
|
53
|
+
return {
|
|
54
|
+
id,
|
|
55
|
+
title,
|
|
56
|
+
type,
|
|
57
|
+
description: options?.description,
|
|
58
|
+
timeout: options?.duration,
|
|
59
|
+
priority: options?.priority,
|
|
60
|
+
onClose: options?.onDismiss,
|
|
61
|
+
actionProps: action && {
|
|
62
|
+
...actionRest(action),
|
|
63
|
+
children: action.label,
|
|
64
|
+
onClick: (event) => {
|
|
65
|
+
action.onClick?.(event);
|
|
66
|
+
manager.close(id);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
data: { closeButton: options?.closeButton }
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const emit = (type) => (message, options) => {
|
|
73
|
+
const id = options?.id ?? `spark-toast-${sequence += 1}`;
|
|
74
|
+
return manager.add(toManagerOptions(id, message, type, options));
|
|
75
|
+
};
|
|
76
|
+
const phase = (value, type) => (result) => {
|
|
77
|
+
return {
|
|
78
|
+
title: typeof value === "function" ? value(result) : value,
|
|
79
|
+
type
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
const toast = Object.assign(emit(), {
|
|
83
|
+
success: emit("success"),
|
|
84
|
+
info: emit("info"),
|
|
85
|
+
warning: emit("warning"),
|
|
86
|
+
error: emit("error"),
|
|
87
|
+
loading: emit("loading"),
|
|
88
|
+
/** Dismiss one toast, or every toast when called without an id. */
|
|
89
|
+
dismiss: (id) => manager.close(id),
|
|
90
|
+
promise: (promiseValue, messages) => manager.promise(promiseValue, {
|
|
91
|
+
loading: {
|
|
92
|
+
title: messages.loading,
|
|
93
|
+
type: "loading"
|
|
94
|
+
},
|
|
95
|
+
success: phase(messages.success, "success"),
|
|
96
|
+
error: phase(messages.error, "error")
|
|
97
|
+
})
|
|
94
98
|
});
|
|
99
|
+
function ToastIcon({ type }) {
|
|
100
|
+
const icon = TOAST_ICONS[type];
|
|
101
|
+
if (type !== "loading" && !icon) return null;
|
|
102
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
103
|
+
"aria-hidden": "true",
|
|
104
|
+
className: "flex h-5 w-5 shrink-0 items-center justify-center",
|
|
105
|
+
children: type === "loading" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_spinner.Spinner, {
|
|
106
|
+
className: "text-gray-11",
|
|
107
|
+
label: "",
|
|
108
|
+
role: "presentation",
|
|
109
|
+
size: "sm"
|
|
110
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons_material_symbol.MaterialSymbol, {
|
|
111
|
+
className: (0, cnfast.cn)("[--spark-icon-size:20px]", icon.className),
|
|
112
|
+
name: icon.name
|
|
113
|
+
})
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function ToastItem({ closeButton, richColors, toast: toastObject }) {
|
|
117
|
+
const tone = TONE_CLASSES[toastObject.type];
|
|
118
|
+
const showClose = toastObject.data?.closeButton ?? closeButton;
|
|
119
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_toast.Toast.Root, {
|
|
120
|
+
"data-slot": "toast",
|
|
121
|
+
className: (0, cnfast.cn)("flex items-start gap-2 rounded-md border border-gray-a5 bg-gray-1 p-3 text-gray shadow-md select-none", richColors && tone),
|
|
122
|
+
swipeDirection: [
|
|
123
|
+
"up",
|
|
124
|
+
"down",
|
|
125
|
+
"right"
|
|
126
|
+
],
|
|
127
|
+
toast: toastObject,
|
|
128
|
+
children: [
|
|
129
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToastIcon, { type: toastObject.type }),
|
|
130
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_toast.Toast.Content, {
|
|
131
|
+
className: "flex min-w-0 flex-1 flex-col gap-0.5",
|
|
132
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Title, {
|
|
133
|
+
className: "text-sm font-medium",
|
|
134
|
+
"data-slot": "toast-title"
|
|
135
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Description, {
|
|
136
|
+
className: (0, cnfast.cn)("text-sm", richColors && tone ? "text-inherit" : "text-gray-11"),
|
|
137
|
+
"data-slot": "toast-description"
|
|
138
|
+
})]
|
|
139
|
+
}),
|
|
140
|
+
toastObject.actionProps ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Action, {
|
|
141
|
+
className: (0, cnfast.cn)(require_components_button.buttonVariants({
|
|
142
|
+
size: "small",
|
|
143
|
+
variant: "primary"
|
|
144
|
+
}), "-my-2 shrink-0 self-center rounded-full"),
|
|
145
|
+
"data-slot": "toast-action"
|
|
146
|
+
}) : null,
|
|
147
|
+
showClose ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Close, {
|
|
148
|
+
"aria-label": "Close",
|
|
149
|
+
className: (0, cnfast.cn)(require_components_button.buttonVariants({
|
|
150
|
+
size: "icon-small",
|
|
151
|
+
variant: "tertiary"
|
|
152
|
+
}), "-my-1 -mr-1 size-7 shrink-0 self-center text-gray-11"),
|
|
153
|
+
"data-slot": "toast-close",
|
|
154
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons_material_symbol.MaterialSymbol, {
|
|
155
|
+
"aria-hidden": "true",
|
|
156
|
+
className: "[--spark-icon-size:18px]",
|
|
157
|
+
name: "close"
|
|
158
|
+
})
|
|
159
|
+
}) : null
|
|
160
|
+
]
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function ToastList({ closeButton, richColors }) {
|
|
164
|
+
const { toasts } = _base_ui_react_toast.Toast.useToastManager();
|
|
165
|
+
return toasts.map((toastObject) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToastItem, {
|
|
166
|
+
closeButton,
|
|
167
|
+
richColors,
|
|
168
|
+
toast: toastObject
|
|
169
|
+
}, toastObject.id));
|
|
170
|
+
}
|
|
171
|
+
function Toaster({ className, closeButton = true, duration = 4e3, limit, mobilePosition = "top", position = "bottom-right", richColors = true }) {
|
|
172
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Provider, {
|
|
173
|
+
limit,
|
|
174
|
+
timeout: duration,
|
|
175
|
+
toastManager: manager,
|
|
176
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Viewport, {
|
|
177
|
+
className: (0, cnfast.cn)("fixed inset-x-4 z-50 block h-0 outline-none", mobilePosition === "top" ? "top-4" : "bottom-4", "sm:inset-x-auto sm:w-96 sm:max-w-[calc(100vw-2rem)]", POSITION_CLASSES[position], className),
|
|
178
|
+
"data-mobile-side": mobilePosition,
|
|
179
|
+
"data-side": position.startsWith("top") ? "top" : "bottom",
|
|
180
|
+
"data-slot": "toaster",
|
|
181
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToastList, {
|
|
182
|
+
closeButton,
|
|
183
|
+
richColors
|
|
184
|
+
})
|
|
185
|
+
}) })
|
|
186
|
+
});
|
|
187
|
+
}
|
|
95
188
|
//#endregion
|
|
96
189
|
exports.Toaster = Toaster;
|
|
97
|
-
exports.toast =
|
|
190
|
+
exports.toast = toast;
|
|
98
191
|
|
|
99
192
|
//# sourceMappingURL=toast.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.cjs","names":["MaterialSymbol","Spinner","Sonner"],"sources":["../../src/components/toast.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Toaster as Sonner, toast, type ToasterProps } from 'sonner'\nimport {\n MaterialSymbol,\n type MaterialSymbolIconName,\n} from '../icons/material-symbol'\nimport { cn } from '../utils/cn'\nimport { Spinner } from './spinner'\n\n// sonner's icon slot is a fixed 16px box that does not scale, so the glyphs\n// are pinned to 16px rather than the usual --spark-scaling formula\nconst TOAST_ICONS: Record<\n 'success' | 'info' | 'warning' | 'error',\n { name: MaterialSymbolIconName; className: string }\n> = {\n success: { name: 'check_circle', className: 'text-success-light' },\n info: { name: 'info', className: 'text-info-light' },\n warning: { name: 'warning', className: 'text-warning-light' },\n error: { name: 'cancel', className: 'text-error-light' },\n}\n\nconst ICONS: ToasterProps['icons'] = Object.fromEntries(\n Object.entries(TOAST_ICONS).map(([type, icon]) => [\n type,\n <MaterialSymbol\n className={cn(\n 'inline-flex shrink-0 items-center [--spark-icon-size:16px]',\n icon.className,\n )}\n key={type}\n name={icon.name}\n />,\n ]),\n)\n// decorative: the toast itself announces the loading message, so the spinner\n// must not add its own status live region; `flex` kills the inline baseline\n// gap that pushes it off-center inside sonner's loader wrapper\nICONS.loading = (\n <Spinner\n aria-hidden=\"true\"\n className=\"flex text-gray-11\"\n label=\"\"\n role=\"presentation\"\n size=\"sm\"\n />\n)\n\nconst STYLE_VARS = {\n '--normal-bg': 'var(--color-gray-2)',\n '--normal-text': 'var(--color-gray-12)',\n '--normal-border': 'var(--color-gray-a1)',\n '--border-radius': 'var(--radius-lg)',\n // sonner's own gray scale (close button, cancel button) — remapped so it\n // follows the spark theme instead of sonner's hardcoded light-only values\n '--gray1': 'var(--color-gray-1)',\n '--gray2': 'var(--color-gray-2)',\n '--gray3': 'var(--color-gray-3)',\n '--gray4': 'var(--color-gray-4)',\n '--gray5': 'var(--color-gray-5)',\n '--gray11': 'var(--color-gray-11)',\n '--gray12': 'var(--color-gray-12)',\n // close button on the top-right corner (sonner defaults to top-left in ltr)\n '--toast-close-button-start': 'unset',\n '--toast-close-button-end': '0',\n '--toast-close-button-transform': 'translate(35%, -35%)',\n // rich-color palette — opaque radix steps (bg 2, text 11) so floating\n // toasts don't let page content bleed through the way alpha `-soft`\n // tokens would; borders off per design\n '--success-bg': 'var(--color-green-2)',\n '--success-border': 'transparent',\n '--success-text': 'var(--color-green-11)',\n '--info-bg': 'var(--color-blue-2)',\n '--info-border': 'transparent',\n '--info-text': 'var(--color-blue-11)',\n '--warning-bg': 'var(--color-orange-2)',\n '--warning-border': 'transparent',\n '--warning-text': 'var(--color-orange-11)',\n '--error-bg': 'var(--color-red-2)',\n '--error-border': 'transparent',\n '--error-text': 'var(--color-red-11)',\n} as React.CSSProperties\n\nconst CLASS_NAMES = {\n // sonner hardcodes the description color (#3f3f3f) and its styles are\n // unlayered, so only important utilities win; typed rich toasts restore\n // the tinted inherit (untyped toasts carry data-rich-colors too, so the\n // guard needs both attributes)\n description:\n 'text-gray-11! [[data-rich-colors=true][data-type]_&]:text-inherit!',\n actionButton:\n 'bg-spark-9! text-spark-contrast! hover:bg-spark-10! rounded-md!',\n cancelButton: 'bg-gray-a3! text-gray-12! hover:bg-gray-a4! rounded-md!',\n}\n\n// consumer props merge with (not replace) the spark theming — React itself\n// would wholesale-replace object props like `style`\nconst Toaster = ({\n className,\n closeButton = true,\n icons,\n richColors = true,\n style,\n toastOptions,\n ...props\n}: ToasterProps) => (\n <Sonner\n className={cn('toaster group', className)}\n closeButton={closeButton}\n icons={{ ...ICONS, ...icons }}\n richColors={richColors}\n style={{ ...STYLE_VARS, ...style }}\n toastOptions={{\n ...toastOptions,\n classNames: { ...CLASS_NAMES, ...toastOptions?.classNames },\n }}\n {...props}\n />\n)\n\nexport { Toaster, toast }\nexport type { ToasterProps }\n"],"mappings":";;;;;;;;;;;;AAuBA,MAAM,QAA+B,OAAO,YAC1C,OAAO,QAAQ;CAPf,SAAS;EAAE,MAAM;EAAgB,WAAW;EAAsB;CAClE,MAAM;EAAE,MAAM;EAAQ,WAAW;EAAmB;CACpD,SAAS;EAAE,MAAM;EAAW,WAAW;EAAsB;CAC7D,OAAO;EAAE,MAAM;EAAU,WAAW;EAAoB;CAI9B,CAAC,CAAC,KAAK,CAAC,MAAM,UAAU,CAChD,MACA,iBAAA,GAAA,kBAAA,KAACA,8BAAAA,gBAAD;CACE,YAAA,GAAA,OAAA,IACE,8DACA,KAAK,UACN;CAED,MAAM,KAAK;CACX,EAFK,KAEL,CACH,CAAC,CACH;AAID,MAAM,UACJ,iBAAA,GAAA,kBAAA,KAACC,2BAAAA,SAAD;CACE,eAAY;CACZ,WAAU;CACV,OAAM;CACN,MAAK;CACL,MAAK;CACL,CAAA;AAGJ,MAAM,aAAa;CACjB,eAAe;CACf,iBAAiB;CACjB,mBAAmB;CACnB,mBAAmB;CAGnB,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,YAAY;CACZ,YAAY;CAEZ,8BAA8B;CAC9B,4BAA4B;CAC5B,kCAAkC;CAIlC,gBAAgB;CAChB,oBAAoB;CACpB,kBAAkB;CAClB,aAAa;CACb,iBAAiB;CACjB,eAAe;CACf,gBAAgB;CAChB,oBAAoB;CACpB,kBAAkB;CAClB,cAAc;CACd,kBAAkB;CAClB,gBAAgB;CACjB;AAED,MAAM,cAAc;CAKlB,aACE;CACF,cACE;CACF,cAAc;CACf;AAID,MAAM,WAAW,EACf,WACA,cAAc,MACd,OACA,aAAa,MACb,OACA,cACA,GAAG,YAEH,iBAAA,GAAA,kBAAA,KAACC,OAAAA,SAAD;CACE,YAAA,GAAA,OAAA,IAAc,iBAAiB,UAAU;CAC5B;CACb,OAAO;EAAE,GAAG;EAAO,GAAG;EAAO;CACjB;CACZ,OAAO;EAAE,GAAG;EAAY,GAAG;EAAO;CAClC,cAAc;EACZ,GAAG;EACH,YAAY;GAAE,GAAG;GAAa,GAAG,cAAc;GAAY;EAC5D;CACD,GAAI;CACJ,CAAA"}
|
|
1
|
+
{"version":3,"file":"toast.cjs","names":["ToastPrimitive","Spinner","MaterialSymbol","buttonVariants"],"sources":["../../src/components/toast.tsx"],"sourcesContent":["'use client'\n\nimport { Toast as ToastPrimitive } from '@base-ui/react/toast'\nimport * as React from 'react'\nimport {\n MaterialSymbol,\n type MaterialSymbolIconName,\n} from '../icons/material-symbol'\nimport { cn } from '../utils/cn'\nimport { buttonVariants } from './button'\nimport { Spinner } from './spinner'\n\ntype ToastType = 'success' | 'info' | 'warning' | 'error' | 'loading'\n\ntype ToastPosition =\n | 'top-left'\n | 'top-center'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'bottom-right'\n\n// Per-toast overrides Base UI carries through untouched as opaque `data`.\ntype ToastData = { closeButton?: boolean }\n\n// `label` is the button's content; everything else a `<button>` takes passes\n// straight through, so a caller can set `className`, `disabled`, `type`, and\n// the rest without a new prop for each one.\ntype ToastAction = Omit<\n React.ComponentPropsWithoutRef<'button'>,\n 'children'\n> & {\n label: React.ReactNode\n}\n\ntype ToastOptions = {\n description?: React.ReactNode\n /** Auto-dismiss time in ms. `0` keeps the toast until dismissed. */\n duration?: number\n /** Reuse an id to update a toast in place instead of stacking a new one. */\n id?: string\n closeButton?: boolean\n action?: ToastAction\n onDismiss?: () => void\n /** `high` announces urgently (assertive); the default is polite. */\n priority?: 'low' | 'high'\n}\n\ntype ToastPromiseMessages<Value> = {\n loading: string\n success: string | ((value: Value) => string)\n error: string | ((error: unknown) => string)\n}\n\nconst TOAST_ICONS: Record<\n Exclude<ToastType, 'loading'>,\n { name: MaterialSymbolIconName; className: string }\n> = {\n success: { name: 'check_circle', className: 'text-success-light' },\n info: { name: 'info', className: 'text-info-light' },\n warning: { name: 'warning', className: 'text-warning-light' },\n error: { name: 'cancel', className: 'text-error-light' },\n}\n\n// Opaque radix steps (bg 2, border 6, text 11) so a floating toast never lets\n// page content bleed through the way the alpha `-soft` tokens would. The border\n// carries the tone too, otherwise a tinted toast keeps a grey outline.\nconst TONE_CLASSES: Record<Exclude<ToastType, 'loading'>, string> = {\n success: 'border-green-6 bg-green-2 text-green-11',\n info: 'border-blue-6 bg-blue-2 text-blue-11',\n warning: 'border-orange-6 bg-orange-2 text-orange-11',\n error: 'border-red-6 bg-red-2 text-red-11',\n}\n\n// Mobile-first: every position drops to a full-width stack at the top, which\n// is what the end-customer portal ships. `position` only takes effect from the\n// `sm` breakpoint up.\nconst POSITION_CLASSES: Record<ToastPosition, string> = {\n 'top-left': 'sm:top-4 sm:right-auto sm:bottom-auto sm:left-4',\n 'top-center':\n 'sm:top-4 sm:right-auto sm:bottom-auto sm:left-1/2 sm:-translate-x-1/2',\n 'top-right': 'sm:top-4 sm:right-4 sm:bottom-auto sm:left-auto',\n 'bottom-left': 'sm:top-auto sm:right-auto sm:bottom-4 sm:left-4',\n 'bottom-center':\n 'sm:top-auto sm:right-auto sm:bottom-4 sm:left-1/2 sm:-translate-x-1/2',\n 'bottom-right': 'sm:top-auto sm:right-4 sm:bottom-4 sm:left-auto',\n}\n\nconst manager = ToastPrimitive.createToastManager<ToastData>()\n\nlet sequence = 0\n\n// `label` names the content and `onClick` is wrapped, so neither reaches the\n// DOM button as-is; everything else does.\nfunction actionRest({\n label: _label,\n onClick: _onClick,\n ...rest\n}: ToastAction) {\n return rest\n}\n\nfunction toManagerOptions(\n id: string,\n title: React.ReactNode,\n type: ToastType | undefined,\n options: ToastOptions | undefined,\n) {\n const action = options?.action\n return {\n id,\n title,\n type,\n description: options?.description,\n timeout: options?.duration,\n priority: options?.priority,\n onClose: options?.onDismiss,\n // Base UI leaves the toast open after an action; dismissing matches what\n // callers expect from an \"Undo\" button.\n actionProps: action && {\n ...actionRest(action),\n children: action.label,\n onClick: (event: React.MouseEvent<HTMLButtonElement>) => {\n action.onClick?.(event)\n manager.close(id)\n },\n },\n data: { closeButton: options?.closeButton },\n }\n}\n\nconst emit =\n (type?: ToastType) =>\n (message: React.ReactNode, options?: ToastOptions): string => {\n // an id up front lets the action handler close the toast it belongs to\n const id = options?.id ?? `spark-toast-${(sequence += 1)}`\n return manager.add(toManagerOptions(id, message, type, options))\n }\n\n// A string phase becomes a titled toast of that type; an object phase keeps\n// whatever the caller set and only fills in the type.\nconst phase =\n <Value,>(\n value: ToastPromiseMessages<Value>[keyof ToastPromiseMessages<Value>],\n type: ToastType,\n ) =>\n (result: Value) => {\n const resolved = typeof value === 'function' ? value(result) : value\n return { title: resolved, type }\n }\n\nconst toast = Object.assign(emit(), {\n success: emit('success'),\n info: emit('info'),\n warning: emit('warning'),\n error: emit('error'),\n loading: emit('loading'),\n /** Dismiss one toast, or every toast when called without an id. */\n dismiss: (id?: string) => manager.close(id),\n promise: <Value,>(\n promiseValue: Promise<Value>,\n messages: ToastPromiseMessages<Value>,\n ) =>\n manager.promise(promiseValue, {\n loading: { title: messages.loading, type: 'loading' as const },\n success: phase(messages.success, 'success'),\n error: phase(messages.error as never, 'error'),\n }),\n})\n\nfunction ToastIcon({ type }: { type?: string }) {\n const icon = TOAST_ICONS[type as Exclude<ToastType, 'loading'>]\n if (type !== 'loading' && !icon) return null\n\n // Fixed box matching the title's line height, so the glyph and the spinner\n // both centre on the first line whether or not a description follows.\n return (\n <span\n aria-hidden=\"true\"\n className=\"flex h-5 w-5 shrink-0 items-center justify-center\"\n >\n {type === 'loading' ? (\n // Decorative: the toast already announces the loading message, so the\n // spinner must not add a second status live region.\n <Spinner\n className=\"text-gray-11\"\n label=\"\"\n role=\"presentation\"\n size=\"sm\"\n />\n ) : (\n <MaterialSymbol\n className={cn('[--spark-icon-size:20px]', icon.className)}\n name={icon.name}\n />\n )}\n </span>\n )\n}\n\nfunction ToastItem({\n closeButton,\n richColors,\n toast: toastObject,\n}: {\n closeButton: boolean\n richColors: boolean\n toast: ToastPrimitive.Root.ToastObject<ToastData>\n}) {\n const tone = TONE_CLASSES[toastObject.type as Exclude<ToastType, 'loading'>]\n const showClose = toastObject.data?.closeButton ?? closeButton\n\n return (\n <ToastPrimitive.Root\n data-slot=\"toast\"\n className={cn(\n // Skin only. All geometry (position, stacking, transitions, the\n // pointer bridge) lives in styles/index.css, because Tailwind's\n // `utilities` layer outranks `components` and a stray `bottom-0` here\n // would beat the stylesheet's `bottom: auto` on top-anchored stacks.\n // The border is what makes the cards behind the front one legible.\n 'flex items-start gap-2 rounded-md border border-gray-a5 bg-gray-1 p-3 text-gray shadow-md select-none',\n richColors && tone,\n )}\n // the stack is top-anchored on mobile and bottom-anchored above `sm`, so\n // both vertical directions have to dismiss\n swipeDirection={['up', 'down', 'right']}\n toast={toastObject}\n >\n <ToastIcon type={toastObject.type} />\n <ToastPrimitive.Content className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n <ToastPrimitive.Title\n className=\"text-sm font-medium\"\n data-slot=\"toast-title\"\n />\n <ToastPrimitive.Description\n className={cn(\n 'text-sm',\n richColors && tone ? 'text-inherit' : 'text-gray-11',\n )}\n data-slot=\"toast-description\"\n />\n </ToastPrimitive.Content>\n {toastObject.actionProps ? (\n <ToastPrimitive.Action\n // -my-2 keeps the 36px control from stretching a single-line row past\n // the 20px text; self-center then lands it on the title when there is\n // no description, and mid-block when there is one\n className={cn(\n buttonVariants({ size: 'small', variant: 'primary' }),\n '-my-2 shrink-0 self-center rounded-full',\n )}\n data-slot=\"toast-action\"\n />\n ) : null}\n {showClose ? (\n <ToastPrimitive.Close\n aria-label=\"Close\"\n className={cn(\n buttonVariants({ size: 'icon-small', variant: 'tertiary' }),\n // -my-1: same reason as the action, for a 28px control\n '-my-1 -mr-1 size-7 shrink-0 self-center text-gray-11',\n )}\n data-slot=\"toast-close\"\n >\n <MaterialSymbol\n aria-hidden=\"true\"\n className=\"[--spark-icon-size:18px]\"\n name=\"close\"\n />\n </ToastPrimitive.Close>\n ) : null}\n </ToastPrimitive.Root>\n )\n}\n\nfunction ToastList({\n closeButton,\n richColors,\n}: {\n closeButton: boolean\n richColors: boolean\n}) {\n const { toasts } = ToastPrimitive.useToastManager<ToastData>()\n\n return toasts.map((toastObject) => (\n <ToastItem\n closeButton={closeButton}\n key={toastObject.id}\n richColors={richColors}\n toast={toastObject}\n />\n ))\n}\n\ntype ToasterProps = {\n className?: string\n /** Corner or edge the toasts stack in. */\n position?: ToastPosition\n /** Close button on every toast; a per-toast `closeButton` wins. */\n closeButton?: boolean\n /** Tinted surfaces for success/info/warning/error toasts. */\n richColors?: boolean\n /** Default auto-dismiss time in ms. `0` disables auto-dismiss. */\n duration?: number\n /** Toasts visible at once before older ones are marked `data-limited`. */\n limit?: number\n /**\n * Vertical edge below the `sm` breakpoint, where the stack is always\n * full-width and `position` does not apply. Defaults to `top`, matching the\n * end-customer portal.\n */\n mobilePosition?: 'top' | 'bottom'\n}\n\nfunction Toaster({\n className,\n closeButton = true,\n duration = 4000,\n limit,\n mobilePosition = 'top',\n position = 'bottom-right',\n richColors = true,\n}: ToasterProps) {\n return (\n <ToastPrimitive.Provider\n limit={limit}\n timeout={duration}\n toastManager={manager}\n >\n <ToastPrimitive.Portal>\n <ToastPrimitive.Viewport\n // block + zero height: the toasts are absolutely positioned against\n // this box's bottom edge, the way Base UI's stacked example works\n className={cn(\n 'fixed inset-x-4 z-50 block h-0 outline-none',\n mobilePosition === 'top' ? 'top-4' : 'bottom-4',\n 'sm:inset-x-auto sm:w-96 sm:max-w-[calc(100vw-2rem)]',\n POSITION_CLASSES[position],\n className,\n )}\n data-mobile-side={mobilePosition}\n data-side={position.startsWith('top') ? 'top' : 'bottom'}\n data-slot=\"toaster\"\n >\n <ToastList closeButton={closeButton} richColors={richColors} />\n </ToastPrimitive.Viewport>\n </ToastPrimitive.Portal>\n </ToastPrimitive.Provider>\n )\n}\n\nexport { Toaster, toast }\nexport type {\n ToastAction,\n ToasterProps,\n ToastOptions,\n ToastPosition,\n ToastPromiseMessages,\n ToastType,\n}\n"],"mappings":"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"}
|
|
@@ -1,18 +1,60 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
-
import
|
|
4
|
+
import * as React$1 from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/components/toast.d.ts
|
|
7
|
-
|
|
7
|
+
type ToastType = 'success' | 'info' | 'warning' | 'error' | 'loading';
|
|
8
|
+
type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
9
|
+
type ToastAction = Omit<React$1.ComponentPropsWithoutRef<'button'>, 'children'> & {
|
|
10
|
+
label: React$1.ReactNode;
|
|
11
|
+
};
|
|
12
|
+
type ToastOptions = {
|
|
13
|
+
description?: React$1.ReactNode; /** Auto-dismiss time in ms. `0` keeps the toast until dismissed. */
|
|
14
|
+
duration?: number; /** Reuse an id to update a toast in place instead of stacking a new one. */
|
|
15
|
+
id?: string;
|
|
16
|
+
closeButton?: boolean;
|
|
17
|
+
action?: ToastAction;
|
|
18
|
+
onDismiss?: () => void; /** `high` announces urgently (assertive); the default is polite. */
|
|
19
|
+
priority?: 'low' | 'high';
|
|
20
|
+
};
|
|
21
|
+
type ToastPromiseMessages<Value> = {
|
|
22
|
+
loading: string;
|
|
23
|
+
success: string | ((value: Value) => string);
|
|
24
|
+
error: string | ((error: unknown) => string);
|
|
25
|
+
};
|
|
26
|
+
declare const toast: ((message: React$1.ReactNode, options?: ToastOptions) => string) & {
|
|
27
|
+
success: (message: React$1.ReactNode, options?: ToastOptions) => string;
|
|
28
|
+
info: (message: React$1.ReactNode, options?: ToastOptions) => string;
|
|
29
|
+
warning: (message: React$1.ReactNode, options?: ToastOptions) => string;
|
|
30
|
+
error: (message: React$1.ReactNode, options?: ToastOptions) => string;
|
|
31
|
+
loading: (message: React$1.ReactNode, options?: ToastOptions) => string; /** Dismiss one toast, or every toast when called without an id. */
|
|
32
|
+
dismiss: (id?: string) => void;
|
|
33
|
+
promise: <Value>(promiseValue: Promise<Value>, messages: ToastPromiseMessages<Value>) => Promise<Value>;
|
|
34
|
+
};
|
|
35
|
+
type ToasterProps = {
|
|
36
|
+
className?: string; /** Corner or edge the toasts stack in. */
|
|
37
|
+
position?: ToastPosition; /** Close button on every toast; a per-toast `closeButton` wins. */
|
|
38
|
+
closeButton?: boolean; /** Tinted surfaces for success/info/warning/error toasts. */
|
|
39
|
+
richColors?: boolean; /** Default auto-dismiss time in ms. `0` disables auto-dismiss. */
|
|
40
|
+
duration?: number; /** Toasts visible at once before older ones are marked `data-limited`. */
|
|
41
|
+
limit?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Vertical edge below the `sm` breakpoint, where the stack is always
|
|
44
|
+
* full-width and `position` does not apply. Defaults to `top`, matching the
|
|
45
|
+
* end-customer portal.
|
|
46
|
+
*/
|
|
47
|
+
mobilePosition?: 'top' | 'bottom';
|
|
48
|
+
};
|
|
49
|
+
declare function Toaster({
|
|
8
50
|
className,
|
|
9
51
|
closeButton,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}: ToasterProps)
|
|
52
|
+
duration,
|
|
53
|
+
limit,
|
|
54
|
+
mobilePosition,
|
|
55
|
+
position,
|
|
56
|
+
richColors
|
|
57
|
+
}: ToasterProps): _$react_jsx_runtime0.JSX.Element;
|
|
16
58
|
//#endregion
|
|
17
|
-
export { Toaster, type ToasterProps, toast };
|
|
59
|
+
export { type ToastAction, type ToastOptions, type ToastPosition, type ToastPromiseMessages, type ToastType, Toaster, type ToasterProps, toast };
|
|
18
60
|
//# sourceMappingURL=toast.d.cts.map
|
|
@@ -1,18 +1,60 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import * as React$1 from "react";
|
|
3
4
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
-
import { ToasterProps, toast } from "sonner";
|
|
5
5
|
|
|
6
6
|
//#region src/components/toast.d.ts
|
|
7
|
-
|
|
7
|
+
type ToastType = 'success' | 'info' | 'warning' | 'error' | 'loading';
|
|
8
|
+
type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
9
|
+
type ToastAction = Omit<React$1.ComponentPropsWithoutRef<'button'>, 'children'> & {
|
|
10
|
+
label: React$1.ReactNode;
|
|
11
|
+
};
|
|
12
|
+
type ToastOptions = {
|
|
13
|
+
description?: React$1.ReactNode; /** Auto-dismiss time in ms. `0` keeps the toast until dismissed. */
|
|
14
|
+
duration?: number; /** Reuse an id to update a toast in place instead of stacking a new one. */
|
|
15
|
+
id?: string;
|
|
16
|
+
closeButton?: boolean;
|
|
17
|
+
action?: ToastAction;
|
|
18
|
+
onDismiss?: () => void; /** `high` announces urgently (assertive); the default is polite. */
|
|
19
|
+
priority?: 'low' | 'high';
|
|
20
|
+
};
|
|
21
|
+
type ToastPromiseMessages<Value> = {
|
|
22
|
+
loading: string;
|
|
23
|
+
success: string | ((value: Value) => string);
|
|
24
|
+
error: string | ((error: unknown) => string);
|
|
25
|
+
};
|
|
26
|
+
declare const toast: ((message: React$1.ReactNode, options?: ToastOptions) => string) & {
|
|
27
|
+
success: (message: React$1.ReactNode, options?: ToastOptions) => string;
|
|
28
|
+
info: (message: React$1.ReactNode, options?: ToastOptions) => string;
|
|
29
|
+
warning: (message: React$1.ReactNode, options?: ToastOptions) => string;
|
|
30
|
+
error: (message: React$1.ReactNode, options?: ToastOptions) => string;
|
|
31
|
+
loading: (message: React$1.ReactNode, options?: ToastOptions) => string; /** Dismiss one toast, or every toast when called without an id. */
|
|
32
|
+
dismiss: (id?: string) => void;
|
|
33
|
+
promise: <Value>(promiseValue: Promise<Value>, messages: ToastPromiseMessages<Value>) => Promise<Value>;
|
|
34
|
+
};
|
|
35
|
+
type ToasterProps = {
|
|
36
|
+
className?: string; /** Corner or edge the toasts stack in. */
|
|
37
|
+
position?: ToastPosition; /** Close button on every toast; a per-toast `closeButton` wins. */
|
|
38
|
+
closeButton?: boolean; /** Tinted surfaces for success/info/warning/error toasts. */
|
|
39
|
+
richColors?: boolean; /** Default auto-dismiss time in ms. `0` disables auto-dismiss. */
|
|
40
|
+
duration?: number; /** Toasts visible at once before older ones are marked `data-limited`. */
|
|
41
|
+
limit?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Vertical edge below the `sm` breakpoint, where the stack is always
|
|
44
|
+
* full-width and `position` does not apply. Defaults to `top`, matching the
|
|
45
|
+
* end-customer portal.
|
|
46
|
+
*/
|
|
47
|
+
mobilePosition?: 'top' | 'bottom';
|
|
48
|
+
};
|
|
49
|
+
declare function Toaster({
|
|
8
50
|
className,
|
|
9
51
|
closeButton,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}: ToasterProps)
|
|
52
|
+
duration,
|
|
53
|
+
limit,
|
|
54
|
+
mobilePosition,
|
|
55
|
+
position,
|
|
56
|
+
richColors
|
|
57
|
+
}: ToasterProps): _$react_jsx_runtime0.JSX.Element;
|
|
16
58
|
//#endregion
|
|
17
|
-
export { Toaster, type ToasterProps, toast };
|
|
59
|
+
export { type ToastAction, type ToastOptions, type ToastPosition, type ToastPromiseMessages, type ToastType, Toaster, type ToasterProps, toast };
|
|
18
60
|
//# sourceMappingURL=toast.d.ts.map
|