@rockshin/tao-ui 0.0.15 → 0.0.16
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.
|
@@ -30,17 +30,81 @@
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
[data-tao-sonner-toast] {
|
|
33
|
+
--tao-sonner-enter-y: 100%;
|
|
34
|
+
--tao-sonner-scale: 1;
|
|
35
|
+
--tao-sonner-y: translateY(var(--tao-sonner-enter-y));
|
|
33
36
|
pointer-events: auto;
|
|
34
37
|
border: 1px solid var(--tao-color-border);
|
|
35
38
|
background: var(--tao-color-bg-elevated);
|
|
36
39
|
color: var(--tao-color-text);
|
|
37
40
|
border-radius: var(--tao-radius-lg);
|
|
38
41
|
box-shadow: var(--tao-box-shadow-secondary);
|
|
42
|
+
opacity: 0;
|
|
43
|
+
min-width: 320px;
|
|
44
|
+
height: auto;
|
|
45
|
+
z-index: var(--tao-sonner-z-index, 1);
|
|
46
|
+
transform: var(--tao-sonner-y) scale(var(--tao-sonner-scale));
|
|
47
|
+
transition: transform var(--tao-motion-duration-slow) var(--tao-motion-ease-out-quint),
|
|
48
|
+
opacity var(--tao-motion-duration-slow) var(--tao-motion-ease-out-quint),
|
|
49
|
+
height var(--tao-motion-duration-slow) var(--tao-motion-ease-out-quint),
|
|
50
|
+
box-shadow var(--tao-motion-duration-mid) var(--tao-motion-ease-out);
|
|
39
51
|
align-items: flex-start;
|
|
40
52
|
gap: 12px;
|
|
41
|
-
min-width: 320px;
|
|
42
53
|
padding: 14px;
|
|
43
54
|
display: flex;
|
|
55
|
+
position: relative;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
[data-tao-sonner-toast][data-tao-y-position="top"] {
|
|
59
|
+
--tao-sonner-enter-y: -100%;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
[data-tao-sonner-toast][data-tao-mounted="true"] {
|
|
63
|
+
opacity: 1;
|
|
64
|
+
--tao-sonner-y: translateY(0);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[data-tao-sonner-toast][data-tao-mounted="true"][data-tao-expanded="true"][data-tao-y-position="bottom"], [data-tao-sonner-toast][data-tao-mounted="true"][data-tao-expanded="true"][data-tao-y-position="top"] {
|
|
68
|
+
--tao-sonner-y: translateY(0);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
[data-tao-sonner-toast][data-tao-expanded="false"][data-tao-front="false"] {
|
|
72
|
+
height: var(--tao-sonner-front-height, auto);
|
|
73
|
+
--tao-sonner-scale: calc(1 - min(var(--tao-sonner-toasts-before), 2) * .03);
|
|
74
|
+
box-shadow: var(--tao-box-shadow-tertiary, var(--tao-box-shadow-secondary));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
[data-tao-sonner-toast][data-tao-expanded="false"][data-tao-front="false"][data-tao-y-position="bottom"] {
|
|
78
|
+
--tao-sonner-y: translateY(calc(var(--tao-sonner-toasts-before) * -.65 * var(--tao-sonner-gap, 12px)));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
[data-tao-sonner-toast][data-tao-expanded="false"][data-tao-front="false"][data-tao-y-position="top"] {
|
|
82
|
+
--tao-sonner-y: translateY(calc(var(--tao-sonner-toasts-before) * .65 * var(--tao-sonner-gap, 12px)));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
[data-tao-sonner-toast][data-tao-expanded="false"][data-tao-front="false"] > * {
|
|
86
|
+
opacity: .18;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
[data-tao-sonner-toast][data-tao-visible="false"] {
|
|
90
|
+
opacity: 0;
|
|
91
|
+
pointer-events: none;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
[data-tao-sonner-toast][data-tao-removing="true"] {
|
|
95
|
+
opacity: 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
[data-tao-sonner-toast][data-tao-removing="true"][data-tao-front="true"][data-tao-y-position="top"] {
|
|
99
|
+
--tao-sonner-y: translateY(-100%);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
[data-tao-sonner-toast][data-tao-removing="true"][data-tao-front="true"][data-tao-y-position="bottom"] {
|
|
103
|
+
--tao-sonner-y: translateY(100%);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
[data-tao-sonner-toast][data-tao-removing="true"][data-tao-front="false"][data-tao-y-position="top"], [data-tao-sonner-toast][data-tao-removing="true"][data-tao-front="false"][data-tao-y-position="bottom"] {
|
|
107
|
+
--tao-sonner-y: translateY(40%);
|
|
44
108
|
}
|
|
45
109
|
|
|
46
110
|
[data-tao-sonner-toast][data-tao-type="success"] {
|
|
@@ -59,13 +123,24 @@
|
|
|
59
123
|
}
|
|
60
124
|
|
|
61
125
|
[data-tao-sonner-toast][data-tao-type="info"] {
|
|
62
|
-
background:
|
|
126
|
+
background: var(--tao-primary-bg);
|
|
63
127
|
border-color: var(--tao-primary-border);
|
|
128
|
+
color: var(--tao-color-primary);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
[data-tao-sonner-toast][data-tao-type="info"] [data-tao-sonner-description] {
|
|
132
|
+
color: inherit;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
[data-tao-sonner-toast][data-tao-type="info"] [data-tao-sonner-close] {
|
|
136
|
+
color: var(--tao-color-primary);
|
|
64
137
|
}
|
|
65
138
|
|
|
66
139
|
[data-tao-sonner-content] {
|
|
67
|
-
flex: 1;
|
|
68
140
|
min-width: 0;
|
|
141
|
+
transition: opacity var(--tao-motion-duration-slow) var(--tao-motion-ease-out-quint);
|
|
142
|
+
flex: 1;
|
|
143
|
+
padding-right: 28px;
|
|
69
144
|
}
|
|
70
145
|
|
|
71
146
|
[data-tao-sonner-title] {
|
|
@@ -82,28 +157,56 @@
|
|
|
82
157
|
}
|
|
83
158
|
|
|
84
159
|
[data-tao-sonner-actions] {
|
|
160
|
+
transition: opacity var(--tao-motion-duration-slow) var(--tao-motion-ease-out-quint);
|
|
85
161
|
flex-shrink: 0;
|
|
86
|
-
align-items:
|
|
162
|
+
align-items: flex-start;
|
|
87
163
|
gap: 8px;
|
|
88
164
|
display: flex;
|
|
89
165
|
}
|
|
90
166
|
|
|
167
|
+
[data-tao-sonner-actions]:not([data-tao-close-only]) {
|
|
168
|
+
padding-right: 22px;
|
|
169
|
+
position: relative;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
[data-tao-sonner-actions][data-tao-close-only] {
|
|
173
|
+
position: absolute;
|
|
174
|
+
top: 12px;
|
|
175
|
+
right: 12px;
|
|
176
|
+
}
|
|
177
|
+
|
|
91
178
|
[data-tao-sonner-close] {
|
|
92
179
|
appearance: none;
|
|
93
180
|
color: var(--tao-color-text-tertiary);
|
|
94
|
-
border-radius: var(--tao-radius-sm);
|
|
95
181
|
cursor: pointer;
|
|
96
|
-
width:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
182
|
+
width: 18px;
|
|
183
|
+
min-width: 18px;
|
|
184
|
+
height: 18px;
|
|
185
|
+
transition: color var(--tao-motion-duration-fast) var(--tao-motion-ease-out);
|
|
100
186
|
background: none;
|
|
101
187
|
border: 0;
|
|
188
|
+
justify-content: center;
|
|
189
|
+
align-items: center;
|
|
190
|
+
padding: 0;
|
|
191
|
+
font-size: 18px;
|
|
192
|
+
line-height: 1;
|
|
193
|
+
display: inline-flex;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
[data-tao-sonner-actions][data-tao-close-only] [data-tao-sonner-close] {
|
|
197
|
+
position: absolute;
|
|
198
|
+
top: 0;
|
|
199
|
+
right: 0;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
[data-tao-sonner-actions]:not([data-tao-close-only]) [data-tao-sonner-close] {
|
|
203
|
+
position: absolute;
|
|
204
|
+
top: 1px;
|
|
205
|
+
right: 0;
|
|
102
206
|
}
|
|
103
207
|
|
|
104
208
|
[data-tao-sonner-close]:hover {
|
|
105
209
|
color: var(--tao-color-text);
|
|
106
|
-
background: var(--tao-color-fill-secondary);
|
|
107
210
|
}
|
|
108
211
|
|
|
109
212
|
@media (width <= 640px) {
|
|
@@ -2,7 +2,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { TaoPortalScope, useTaoConfig } from "../../provider/tao-provider.js";
|
|
3
3
|
import { cx } from "../../utils/semantic.js";
|
|
4
4
|
import { Button } from "../button/button.js";
|
|
5
|
-
import { useEffect, useMemo, useSyncExternalStore } from "react";
|
|
5
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
6
6
|
import "./sonner.css";
|
|
7
7
|
const listeners = new Set();
|
|
8
8
|
let state = {
|
|
@@ -10,6 +10,8 @@ let state = {
|
|
|
10
10
|
};
|
|
11
11
|
let seed = 0;
|
|
12
12
|
const timers = new Map();
|
|
13
|
+
const removeTimers = new Map();
|
|
14
|
+
const REMOVE_DELAY = 220;
|
|
13
15
|
function emit() {
|
|
14
16
|
listeners.forEach((listener)=>listener());
|
|
15
17
|
}
|
|
@@ -27,20 +29,51 @@ function clearTimer(id) {
|
|
|
27
29
|
timers.delete(id);
|
|
28
30
|
}
|
|
29
31
|
}
|
|
32
|
+
function clearRemoveTimer(id) {
|
|
33
|
+
const timer = removeTimers.get(id);
|
|
34
|
+
if (timer) {
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
removeTimers.delete(id);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
30
39
|
function dismiss(id) {
|
|
31
40
|
if (!id) {
|
|
32
41
|
state.toasts.forEach((toast)=>clearTimer(toast.id));
|
|
42
|
+
state.toasts.forEach((toast)=>clearRemoveTimer(toast.id));
|
|
33
43
|
state = {
|
|
34
|
-
toasts:
|
|
44
|
+
toasts: state.toasts.map((toast)=>({
|
|
45
|
+
...toast,
|
|
46
|
+
removing: true
|
|
47
|
+
}))
|
|
35
48
|
};
|
|
36
49
|
emit();
|
|
50
|
+
state.toasts.forEach((toast)=>{
|
|
51
|
+
removeTimers.set(toast.id, setTimeout(()=>{
|
|
52
|
+
removeTimers.delete(toast.id);
|
|
53
|
+
state = {
|
|
54
|
+
toasts: state.toasts.filter((item)=>item.id !== toast.id)
|
|
55
|
+
};
|
|
56
|
+
emit();
|
|
57
|
+
}, REMOVE_DELAY));
|
|
58
|
+
});
|
|
37
59
|
return;
|
|
38
60
|
}
|
|
39
61
|
clearTimer(id);
|
|
62
|
+
clearRemoveTimer(id);
|
|
40
63
|
state = {
|
|
41
|
-
toasts: state.toasts.
|
|
64
|
+
toasts: state.toasts.map((toast)=>toast.id === id ? {
|
|
65
|
+
...toast,
|
|
66
|
+
removing: true
|
|
67
|
+
} : toast)
|
|
42
68
|
};
|
|
43
69
|
emit();
|
|
70
|
+
removeTimers.set(id, setTimeout(()=>{
|
|
71
|
+
removeTimers.delete(id);
|
|
72
|
+
state = {
|
|
73
|
+
toasts: state.toasts.filter((toast)=>toast.id !== id)
|
|
74
|
+
};
|
|
75
|
+
emit();
|
|
76
|
+
}, REMOVE_DELAY));
|
|
44
77
|
}
|
|
45
78
|
function scheduleDismiss(id, duration) {
|
|
46
79
|
clearTimer(id);
|
|
@@ -107,6 +140,7 @@ function renderPromiseState(stateValue, payload) {
|
|
|
107
140
|
function Sonner({ position = 'bottom-right', visibleToasts = 3, offset = 24, gap = 12, expand = true, richColors = false, closeButton = false, duration = 4000, className, style, classNames, styles }) {
|
|
108
141
|
useTaoConfig();
|
|
109
142
|
const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
143
|
+
const [heights, setHeights] = useState([]);
|
|
110
144
|
useEffect(()=>{
|
|
111
145
|
for (const toast of snapshot.toasts)if (!timers.has(toast.id)) scheduleDismiss(toast.id, toast.duration ?? duration);
|
|
112
146
|
}, [
|
|
@@ -122,6 +156,7 @@ function Sonner({ position = 'bottom-right', visibleToasts = 3, offset = 24, gap
|
|
|
122
156
|
snapshot.toasts,
|
|
123
157
|
visibleToasts
|
|
124
158
|
]);
|
|
159
|
+
const frontToastHeight = heights[0]?.height ?? 0;
|
|
125
160
|
return /*#__PURE__*/ jsx(TaoPortalScope, {
|
|
126
161
|
children: /*#__PURE__*/ jsx("div", {
|
|
127
162
|
className: cx(classNames?.viewport, className),
|
|
@@ -129,86 +164,166 @@ function Sonner({ position = 'bottom-right', visibleToasts = 3, offset = 24, gap
|
|
|
129
164
|
...styles?.viewport,
|
|
130
165
|
...style,
|
|
131
166
|
['--tao-sonner-offset']: `${offset}px`,
|
|
132
|
-
['--tao-sonner-gap']: `${gap}px
|
|
167
|
+
['--tao-sonner-gap']: `${gap}px`,
|
|
168
|
+
['--tao-sonner-front-height']: `${frontToastHeight}px`
|
|
133
169
|
},
|
|
134
170
|
"data-tao-sonner-viewport": "",
|
|
135
171
|
"data-tao-position": position,
|
|
136
|
-
children: visible.map((toast_0)=>{
|
|
172
|
+
children: visible.map((toast_0, index)=>{
|
|
137
173
|
const showClose = toast_0.closable ?? closeButton;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
toast_0.title ? /*#__PURE__*/ jsx("div", {
|
|
154
|
-
className: cx(classNames?.title),
|
|
155
|
-
style: styles?.title,
|
|
156
|
-
"data-tao-sonner-title": "",
|
|
157
|
-
children: toast_0.title
|
|
158
|
-
}) : null,
|
|
159
|
-
toast_0.description ? /*#__PURE__*/ jsx("div", {
|
|
160
|
-
className: cx(classNames?.description),
|
|
161
|
-
style: styles?.description,
|
|
162
|
-
"data-tao-sonner-description": "",
|
|
163
|
-
children: toast_0.description
|
|
164
|
-
}) : null
|
|
165
|
-
]
|
|
166
|
-
}),
|
|
167
|
-
(toast_0.action || toast_0.cancel || showClose) && /*#__PURE__*/ jsxs("div", {
|
|
168
|
-
className: cx(classNames?.actions),
|
|
169
|
-
style: styles?.actions,
|
|
170
|
-
"data-tao-sonner-actions": "",
|
|
171
|
-
children: [
|
|
172
|
-
toast_0.cancel ? /*#__PURE__*/ jsx(Button, {
|
|
173
|
-
variant: "ghost",
|
|
174
|
-
size: "small",
|
|
175
|
-
className: cx(classNames?.cancel),
|
|
176
|
-
style: styles?.cancel,
|
|
177
|
-
onClick: ()=>{
|
|
178
|
-
toast_0.cancel?.onClick?.();
|
|
179
|
-
dismiss(toast_0.id);
|
|
180
|
-
},
|
|
181
|
-
children: toast_0.cancel.label
|
|
182
|
-
}) : null,
|
|
183
|
-
toast_0.action ? /*#__PURE__*/ jsx(Button, {
|
|
184
|
-
variant: "secondary",
|
|
185
|
-
size: "small",
|
|
186
|
-
className: cx(classNames?.action),
|
|
187
|
-
style: styles?.action,
|
|
188
|
-
onClick: ()=>{
|
|
189
|
-
toast_0.action?.onClick?.();
|
|
190
|
-
dismiss(toast_0.id);
|
|
191
|
-
},
|
|
192
|
-
children: toast_0.action.label
|
|
193
|
-
}) : null,
|
|
194
|
-
showClose ? /*#__PURE__*/ jsx("button", {
|
|
195
|
-
type: "button",
|
|
196
|
-
"aria-label": "Close notification",
|
|
197
|
-
className: cx(classNames?.close),
|
|
198
|
-
style: styles?.close,
|
|
199
|
-
"data-tao-sonner-close": "",
|
|
200
|
-
onClick: ()=>dismiss(toast_0.id),
|
|
201
|
-
children: "\xd7"
|
|
202
|
-
}) : null
|
|
203
|
-
]
|
|
204
|
-
})
|
|
205
|
-
]
|
|
206
|
-
})
|
|
174
|
+
const yPosition = position.startsWith('top') ? 'top' : 'bottom';
|
|
175
|
+
return /*#__PURE__*/ jsx(ToastView, {
|
|
176
|
+
toast: toast_0,
|
|
177
|
+
richColors: richColors,
|
|
178
|
+
showClose: showClose,
|
|
179
|
+
yPosition: yPosition,
|
|
180
|
+
index: index,
|
|
181
|
+
visibleToasts: visible.length,
|
|
182
|
+
expanded: expand,
|
|
183
|
+
gap: gap,
|
|
184
|
+
heights: heights,
|
|
185
|
+
frontToastHeight: frontToastHeight,
|
|
186
|
+
setHeights: setHeights,
|
|
187
|
+
classNames: classNames,
|
|
188
|
+
styles: styles
|
|
207
189
|
}, toast_0.id);
|
|
208
190
|
})
|
|
209
191
|
})
|
|
210
192
|
});
|
|
211
193
|
}
|
|
194
|
+
function ToastView({ toast, richColors, showClose, yPosition, index, visibleToasts, expanded, gap, heights, frontToastHeight, setHeights, classNames, styles }) {
|
|
195
|
+
const [mounted, setMounted] = useState(false);
|
|
196
|
+
const [offsetBeforeRemove, setOffsetBeforeRemove] = useState(0);
|
|
197
|
+
const ref = useRef(null);
|
|
198
|
+
const offset = useMemo(()=>heights.slice(0, index).reduce((sum, item)=>sum + item.height, 0) + index * gap, [
|
|
199
|
+
gap,
|
|
200
|
+
heights,
|
|
201
|
+
index
|
|
202
|
+
]);
|
|
203
|
+
useEffect(()=>{
|
|
204
|
+
const frame = requestAnimationFrame(()=>setMounted(true));
|
|
205
|
+
return ()=>cancelAnimationFrame(frame);
|
|
206
|
+
}, []);
|
|
207
|
+
useEffect(()=>{
|
|
208
|
+
if (toast.removing) setOffsetBeforeRemove(offset);
|
|
209
|
+
}, [
|
|
210
|
+
offset,
|
|
211
|
+
toast.removing
|
|
212
|
+
]);
|
|
213
|
+
useLayoutEffect(()=>{
|
|
214
|
+
const node = ref.current;
|
|
215
|
+
if (!node) return;
|
|
216
|
+
const nextHeight = node.getBoundingClientRect().height;
|
|
217
|
+
setHeights((current)=>{
|
|
218
|
+
const filtered = current.filter((item_0)=>item_0.id !== toast.id);
|
|
219
|
+
return [
|
|
220
|
+
...filtered,
|
|
221
|
+
{
|
|
222
|
+
id: toast.id,
|
|
223
|
+
height: nextHeight
|
|
224
|
+
}
|
|
225
|
+
];
|
|
226
|
+
});
|
|
227
|
+
return ()=>{
|
|
228
|
+
setHeights((current_0)=>current_0.filter((item_1)=>item_1.id !== toast.id));
|
|
229
|
+
};
|
|
230
|
+
}, [
|
|
231
|
+
setHeights,
|
|
232
|
+
toast.description,
|
|
233
|
+
toast.id,
|
|
234
|
+
toast.title,
|
|
235
|
+
toast.action,
|
|
236
|
+
toast.cancel,
|
|
237
|
+
toast.custom
|
|
238
|
+
]);
|
|
239
|
+
const isFront = 0 === index;
|
|
240
|
+
const isVisible = index < visibleToasts;
|
|
241
|
+
const activeOffset = toast.removing ? offsetBeforeRemove : offset;
|
|
242
|
+
return /*#__PURE__*/ jsx("div", {
|
|
243
|
+
ref: ref,
|
|
244
|
+
className: cx(classNames?.toast),
|
|
245
|
+
role: "status",
|
|
246
|
+
"aria-live": "polite",
|
|
247
|
+
"aria-label": getAriaLabel(toast.type),
|
|
248
|
+
"data-tao-sonner-toast": "",
|
|
249
|
+
"data-tao-type": resolveDataType(toast.type, richColors),
|
|
250
|
+
"data-tao-mounted": mounted,
|
|
251
|
+
"data-tao-y-position": yPosition,
|
|
252
|
+
"data-tao-removing": toast.removing ? 'true' : 'false',
|
|
253
|
+
"data-tao-front": isFront ? 'true' : 'false',
|
|
254
|
+
"data-tao-expanded": expanded ? 'true' : 'false',
|
|
255
|
+
"data-tao-visible": isVisible ? 'true' : 'false',
|
|
256
|
+
style: {
|
|
257
|
+
...styles?.toast,
|
|
258
|
+
['--tao-sonner-toasts-before']: String(index),
|
|
259
|
+
['--tao-sonner-offset-y']: `${activeOffset}px`,
|
|
260
|
+
['--tao-sonner-front-height']: `${frontToastHeight}px`,
|
|
261
|
+
['--tao-sonner-z-index']: String(visibleToasts - index)
|
|
262
|
+
},
|
|
263
|
+
children: toast.custom ? toast.custom : /*#__PURE__*/ jsxs(Fragment, {
|
|
264
|
+
children: [
|
|
265
|
+
/*#__PURE__*/ jsxs("div", {
|
|
266
|
+
className: cx(classNames?.content),
|
|
267
|
+
style: styles?.content,
|
|
268
|
+
"data-tao-sonner-content": "",
|
|
269
|
+
children: [
|
|
270
|
+
toast.title ? /*#__PURE__*/ jsx("div", {
|
|
271
|
+
className: cx(classNames?.title),
|
|
272
|
+
style: styles?.title,
|
|
273
|
+
"data-tao-sonner-title": "",
|
|
274
|
+
children: toast.title
|
|
275
|
+
}) : null,
|
|
276
|
+
toast.description ? /*#__PURE__*/ jsx("div", {
|
|
277
|
+
className: cx(classNames?.description),
|
|
278
|
+
style: styles?.description,
|
|
279
|
+
"data-tao-sonner-description": "",
|
|
280
|
+
children: toast.description
|
|
281
|
+
}) : null
|
|
282
|
+
]
|
|
283
|
+
}),
|
|
284
|
+
(toast.action || toast.cancel || showClose) && /*#__PURE__*/ jsxs("div", {
|
|
285
|
+
className: cx(classNames?.actions),
|
|
286
|
+
style: styles?.actions,
|
|
287
|
+
"data-tao-sonner-actions": "",
|
|
288
|
+
"data-tao-close-only": toast.action || toast.cancel || !showClose ? void 0 : '',
|
|
289
|
+
children: [
|
|
290
|
+
toast.cancel ? /*#__PURE__*/ jsx(Button, {
|
|
291
|
+
variant: "ghost",
|
|
292
|
+
size: "small",
|
|
293
|
+
className: cx(classNames?.cancel),
|
|
294
|
+
style: styles?.cancel,
|
|
295
|
+
onClick: ()=>{
|
|
296
|
+
toast.cancel?.onClick?.();
|
|
297
|
+
dismiss(toast.id);
|
|
298
|
+
},
|
|
299
|
+
children: toast.cancel.label
|
|
300
|
+
}) : null,
|
|
301
|
+
toast.action ? /*#__PURE__*/ jsx(Button, {
|
|
302
|
+
variant: "secondary",
|
|
303
|
+
size: "small",
|
|
304
|
+
className: cx(classNames?.action),
|
|
305
|
+
style: styles?.action,
|
|
306
|
+
onClick: ()=>{
|
|
307
|
+
toast.action?.onClick?.();
|
|
308
|
+
dismiss(toast.id);
|
|
309
|
+
},
|
|
310
|
+
children: toast.action.label
|
|
311
|
+
}) : null,
|
|
312
|
+
showClose ? /*#__PURE__*/ jsx("button", {
|
|
313
|
+
type: "button",
|
|
314
|
+
"aria-label": "Close notification",
|
|
315
|
+
className: cx(classNames?.close),
|
|
316
|
+
style: styles?.close,
|
|
317
|
+
"data-tao-sonner-close": "",
|
|
318
|
+
onClick: ()=>dismiss(toast.id),
|
|
319
|
+
children: "\xd7"
|
|
320
|
+
}) : null
|
|
321
|
+
]
|
|
322
|
+
})
|
|
323
|
+
]
|
|
324
|
+
})
|
|
325
|
+
});
|
|
326
|
+
}
|
|
212
327
|
const baseToast = (options)=>create('default', options);
|
|
213
328
|
const sonner_toast = Object.assign(baseToast, {
|
|
214
329
|
success: (options)=>create('success', options),
|