sonner-wc 0.1.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/LICENSE +28 -0
- package/README.md +144 -0
- package/dist/constants.d.ts +10 -0
- package/dist/icons.d.ts +8 -0
- package/dist/index.d.ts +12 -0
- package/dist/registry.d.ts +11 -0
- package/dist/sonner-toast.d.ts +29 -0
- package/dist/sonner-toaster.d.ts +20 -0
- package/dist/sonner-wc.bundle.js +742 -0
- package/dist/sonner-wc.bundle.js.map +17 -0
- package/dist/sonner-wc.js +1962 -0
- package/dist/sonner-wc.js.map +17 -0
- package/dist/styles.d.ts +16 -0
- package/dist/toast.d.ts +21 -0
- package/dist/types.d.ts +85 -0
- package/package.json +69 -0
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
var Z=3;var y=4000,$=356,b=14,W=45,p=0.11,V=200,E=["altKey","KeyT"];var G='<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',ra=Array.from({length:12},()=>'<div class="sonner-loading-bar"></div>').join(""),ba='<div class="sonner-loading-wrapper" data-visible="true"><div class="sonner-spinner">'+ra+"</div></div>";function U(a){switch(a){case"success":return'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd"/></svg>';case"info":return'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z" clip-rule="evenodd"/></svg>';case"warning":return'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" height="20" width="20"><path fill-rule="evenodd" d="M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z" clip-rule="evenodd"/></svg>';case"error":return'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"/></svg>';case"loading":return null;default:return null}}var w=new Map,u=new Set,ta=1;function k(){return ta++}function j(a){w.set(a.toastId,a)}function H(a){if(w.get(a.toastId)===a)w.delete(a.toastId)}function v(a){return w.get(a)}function C(a){u.add(a)}function L(a){u.delete(a)}function M(){let a;for(let r of u)a=r;return a}function R(){for(let a of u)a.dismissAll()}var P=`:host {
|
|
2
|
+
position: fixed;
|
|
3
|
+
width: var(--width);
|
|
4
|
+
font-family:
|
|
5
|
+
ui-sans-serif,
|
|
6
|
+
system-ui,
|
|
7
|
+
-apple-system,
|
|
8
|
+
BlinkMacSystemFont,
|
|
9
|
+
Segoe UI,
|
|
10
|
+
Roboto,
|
|
11
|
+
Helvetica Neue,
|
|
12
|
+
Arial,
|
|
13
|
+
Noto Sans,
|
|
14
|
+
sans-serif,
|
|
15
|
+
Apple Color Emoji,
|
|
16
|
+
Segoe UI Emoji,
|
|
17
|
+
Segoe UI Symbol,
|
|
18
|
+
Noto Color Emoji;
|
|
19
|
+
--gray1: hsl(0, 0%, 99%);
|
|
20
|
+
--gray2: hsl(0, 0%, 97.3%);
|
|
21
|
+
--gray3: hsl(0, 0%, 95.1%);
|
|
22
|
+
--gray4: hsl(0, 0%, 93%);
|
|
23
|
+
--gray5: hsl(0, 0%, 90.9%);
|
|
24
|
+
--gray6: hsl(0, 0%, 88.7%);
|
|
25
|
+
--gray7: hsl(0, 0%, 85.8%);
|
|
26
|
+
--gray8: hsl(0, 0%, 78%);
|
|
27
|
+
--gray9: hsl(0, 0%, 56.1%);
|
|
28
|
+
--gray10: hsl(0, 0%, 52.3%);
|
|
29
|
+
--gray11: hsl(0, 0%, 43.5%);
|
|
30
|
+
--gray12: hsl(0, 0%, 9%);
|
|
31
|
+
--border-radius: 8px;
|
|
32
|
+
--width: 356px;
|
|
33
|
+
--gap: 14px;
|
|
34
|
+
--offset-top: 24px;
|
|
35
|
+
--offset-right: 24px;
|
|
36
|
+
--offset-bottom: 24px;
|
|
37
|
+
--offset-left: 24px;
|
|
38
|
+
--mobile-offset-top: 16px;
|
|
39
|
+
--mobile-offset-right: 16px;
|
|
40
|
+
--mobile-offset-bottom: 16px;
|
|
41
|
+
--mobile-offset-left: 16px;
|
|
42
|
+
--toast-icon-margin-start: -3px;
|
|
43
|
+
--toast-icon-margin-end: 4px;
|
|
44
|
+
--toast-svg-margin-start: -1px;
|
|
45
|
+
--toast-svg-margin-end: 0px;
|
|
46
|
+
--toast-button-margin-start: auto;
|
|
47
|
+
--toast-button-margin-end: 0;
|
|
48
|
+
--toast-close-button-start: 0;
|
|
49
|
+
--toast-close-button-end: unset;
|
|
50
|
+
--toast-close-button-transform: translate(-35%, -35%);
|
|
51
|
+
box-sizing: border-box;
|
|
52
|
+
padding: 0;
|
|
53
|
+
margin: 0;
|
|
54
|
+
outline: none;
|
|
55
|
+
z-index: 999999999;
|
|
56
|
+
transition: transform 400ms ease;
|
|
57
|
+
display: block;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
[data-frame] {
|
|
61
|
+
display: block;
|
|
62
|
+
width: 100%;
|
|
63
|
+
height: 100%;
|
|
64
|
+
box-sizing: border-box;
|
|
65
|
+
font-family: inherit;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
:host([dir='rtl']) {
|
|
69
|
+
--toast-icon-margin-start: 4px;
|
|
70
|
+
--toast-icon-margin-end: -3px;
|
|
71
|
+
--toast-svg-margin-start: 0px;
|
|
72
|
+
--toast-svg-margin-end: -1px;
|
|
73
|
+
--toast-button-margin-start: 0;
|
|
74
|
+
--toast-button-margin-end: auto;
|
|
75
|
+
--toast-close-button-start: unset;
|
|
76
|
+
--toast-close-button-end: 0;
|
|
77
|
+
--toast-close-button-transform: translate(35%, -35%);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
:host([data-x-position='right']) {
|
|
81
|
+
right: var(--offset-right);
|
|
82
|
+
}
|
|
83
|
+
:host([data-x-position='left']) {
|
|
84
|
+
left: var(--offset-left);
|
|
85
|
+
}
|
|
86
|
+
:host([data-x-position='center']) {
|
|
87
|
+
left: 50%;
|
|
88
|
+
transform: translateX(-50%);
|
|
89
|
+
}
|
|
90
|
+
:host([data-y-position='top']) {
|
|
91
|
+
top: var(--offset-top);
|
|
92
|
+
}
|
|
93
|
+
:host([data-y-position='bottom']) {
|
|
94
|
+
bottom: var(--offset-bottom);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@media (hover: none) and (pointer: coarse) {
|
|
98
|
+
:host([data-lifted='true']) {
|
|
99
|
+
transform: none;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Theme palette via light-dark(). The \`theme\` attribute on <sonner-toaster>
|
|
104
|
+
* (light / dark, or resolved from \`system\`) drives \`color-scheme\` on the host,
|
|
105
|
+
* which determines which side of each light-dark() pair wins. */
|
|
106
|
+
:host([data-sonner-theme='light']) { color-scheme: light; }
|
|
107
|
+
:host([data-sonner-theme='dark']) { color-scheme: dark; }
|
|
108
|
+
|
|
109
|
+
:host {
|
|
110
|
+
--normal-bg: light-dark(#fff, #000);
|
|
111
|
+
--normal-bg-hover: light-dark(var(--gray2), hsl(0, 0%, 12%));
|
|
112
|
+
--normal-border: light-dark(var(--gray4), hsl(0, 0%, 20%));
|
|
113
|
+
--normal-border-hover: light-dark(var(--gray5), hsl(0, 0%, 25%));
|
|
114
|
+
--normal-text: light-dark(var(--gray12), var(--gray1));
|
|
115
|
+
--invert-bg: light-dark(#000, #fff);
|
|
116
|
+
--invert-border: light-dark(hsl(0, 0%, 20%), var(--gray3));
|
|
117
|
+
--invert-text: light-dark(var(--gray1), var(--gray12));
|
|
118
|
+
--description-color: light-dark(#3f3f3f, hsl(0, 0%, 91%));
|
|
119
|
+
--cancel-bg: light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.3));
|
|
120
|
+
--success-bg: light-dark(hsl(143, 85%, 96%), hsl(150, 100%, 6%));
|
|
121
|
+
--success-border: light-dark(hsl(145, 92%, 87%), hsl(147, 100%, 12%));
|
|
122
|
+
--success-text: light-dark(hsl(140, 100%, 27%), hsl(150, 86%, 65%));
|
|
123
|
+
--info-bg: light-dark(hsl(208, 100%, 97%), hsl(215, 100%, 6%));
|
|
124
|
+
--info-border: light-dark(hsl(221, 91%, 93%), hsl(223, 43%, 17%));
|
|
125
|
+
--info-text: light-dark(hsl(210, 92%, 45%), hsl(216, 87%, 65%));
|
|
126
|
+
--warning-bg: light-dark(hsl(49, 100%, 97%), hsl(64, 100%, 6%));
|
|
127
|
+
--warning-border: light-dark(hsl(49, 91%, 84%), hsl(60, 100%, 9%));
|
|
128
|
+
--warning-text: light-dark(hsl(31, 92%, 45%), hsl(46, 87%, 65%));
|
|
129
|
+
--error-bg: light-dark(hsl(359, 100%, 97%), hsl(358, 76%, 10%));
|
|
130
|
+
--error-border: light-dark(hsl(359, 100%, 94%), hsl(357, 89%, 16%));
|
|
131
|
+
--error-text: light-dark(hsl(360, 100%, 45%), hsl(358, 100%, 81%));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@media (max-width: 600px) {
|
|
135
|
+
/* width is intentionally \`auto\` so that the toaster respects BOTH offsets
|
|
136
|
+
* and fits between them. Sonner's reference CSS uses width: 100% here, but
|
|
137
|
+
* that's over-constrained with both left and right set — the right offset
|
|
138
|
+
* gets ignored and the element extends past the viewport's right edge by
|
|
139
|
+
* --mobile-offset-right (visible unless body has overflow-x: hidden). */
|
|
140
|
+
:host {
|
|
141
|
+
position: fixed;
|
|
142
|
+
right: var(--mobile-offset-right);
|
|
143
|
+
left: var(--mobile-offset-left);
|
|
144
|
+
width: auto;
|
|
145
|
+
}
|
|
146
|
+
:host([dir='rtl']) {
|
|
147
|
+
left: calc(var(--mobile-offset-left) * -1);
|
|
148
|
+
}
|
|
149
|
+
:host([data-x-position='left']) {
|
|
150
|
+
left: var(--mobile-offset-left);
|
|
151
|
+
}
|
|
152
|
+
:host([data-x-position='right']) {
|
|
153
|
+
right: var(--mobile-offset-right);
|
|
154
|
+
}
|
|
155
|
+
:host([data-y-position='bottom']) {
|
|
156
|
+
bottom: var(--mobile-offset-bottom);
|
|
157
|
+
}
|
|
158
|
+
:host([data-y-position='top']) {
|
|
159
|
+
top: var(--mobile-offset-top);
|
|
160
|
+
}
|
|
161
|
+
:host([data-x-position='center']) {
|
|
162
|
+
left: var(--mobile-offset-left);
|
|
163
|
+
right: var(--mobile-offset-right);
|
|
164
|
+
transform: none;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
`;var q=`:host {
|
|
168
|
+
--y: translateY(100%);
|
|
169
|
+
--lift-amount: calc(var(--lift) * var(--gap, 14px));
|
|
170
|
+
z-index: var(--z-index);
|
|
171
|
+
position: absolute;
|
|
172
|
+
opacity: 0;
|
|
173
|
+
transform: var(--y);
|
|
174
|
+
touch-action: none;
|
|
175
|
+
transition:
|
|
176
|
+
transform 400ms,
|
|
177
|
+
opacity 400ms,
|
|
178
|
+
height 400ms,
|
|
179
|
+
box-shadow 200ms;
|
|
180
|
+
/* Enables the height transition to interpolate to/from auto (intrinsic size).
|
|
181
|
+
* Supported in Chromium ≥129; in other engines the transition gracefully falls
|
|
182
|
+
* back to snapping, same as the React Sonner reference. */
|
|
183
|
+
interpolate-size: allow-keywords;
|
|
184
|
+
box-sizing: border-box;
|
|
185
|
+
width: var(--width);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
[data-frame] {
|
|
189
|
+
display: flex;
|
|
190
|
+
align-items: center;
|
|
191
|
+
gap: 6px;
|
|
192
|
+
font-family: inherit;
|
|
193
|
+
font-size: 13px;
|
|
194
|
+
font-weight: 400;
|
|
195
|
+
font-style: normal;
|
|
196
|
+
line-height: normal;
|
|
197
|
+
letter-spacing: normal;
|
|
198
|
+
text-align: start;
|
|
199
|
+
text-transform: none;
|
|
200
|
+
color: var(--normal-text);
|
|
201
|
+
outline: none;
|
|
202
|
+
overflow-wrap: anywhere;
|
|
203
|
+
width: 100%;
|
|
204
|
+
height: 100%;
|
|
205
|
+
box-sizing: border-box;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
:host([data-styled='true']) [data-frame] {
|
|
209
|
+
padding: 16px;
|
|
210
|
+
background: var(--normal-bg);
|
|
211
|
+
border: 1px solid var(--normal-border);
|
|
212
|
+
color: var(--normal-text);
|
|
213
|
+
border-radius: var(--border-radius);
|
|
214
|
+
box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* Unstyled (toast.custom): hide built-in chrome, let the slotted content fill the host. */
|
|
218
|
+
:host([data-styled='false']) [data-frame] {
|
|
219
|
+
display: block;
|
|
220
|
+
}
|
|
221
|
+
:host([data-styled='false']) [data-icon],
|
|
222
|
+
:host([data-styled='false']) [data-content],
|
|
223
|
+
:host([data-styled='false']) [data-close-button] {
|
|
224
|
+
display: none;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/* Hide the icon container when no icon has been slotted AND no built-in spinner is
|
|
228
|
+
* showing (default-type toasts have no built-in icon, so otherwise its fixed 16x16 +
|
|
229
|
+
* side margins reserve a phantom gap).
|
|
230
|
+
* The element toggles data-has-icon / data-has-description on slotchange. */
|
|
231
|
+
:host(:not([data-has-icon]):not([data-type='loading'])) [data-icon] {
|
|
232
|
+
display: none;
|
|
233
|
+
}
|
|
234
|
+
:host(:not([data-has-description])) [data-description] {
|
|
235
|
+
display: none;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* Spinner lives in the shadow DOM so its CSS can match its descendants (slotted
|
|
239
|
+
* elements can't be styled past their host from a shadow stylesheet). It is hidden
|
|
240
|
+
* by default and only revealed when type='loading' AND no user icon was slotted. */
|
|
241
|
+
:host([data-type='loading']:not([data-has-icon])) .sonner-loading-wrapper {
|
|
242
|
+
display: block;
|
|
243
|
+
}
|
|
244
|
+
:host(:not([data-type='loading']):not([data-has-icon])) .sonner-loading-wrapper,
|
|
245
|
+
:host([data-has-icon]) .sonner-loading-wrapper {
|
|
246
|
+
display: none;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
:host(:focus-visible) [data-frame] {
|
|
250
|
+
box-shadow:
|
|
251
|
+
0px 4px 12px rgba(0, 0, 0, 0.1),
|
|
252
|
+
0 0 0 2px rgba(0, 0, 0, 0.2);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
:host([data-y-position='top']) {
|
|
256
|
+
top: 0;
|
|
257
|
+
--y: translateY(-100%);
|
|
258
|
+
--lift: 1;
|
|
259
|
+
--lift-amount: calc(1 * var(--gap, 14px));
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
:host([data-y-position='bottom']) {
|
|
263
|
+
bottom: 0;
|
|
264
|
+
--y: translateY(100%);
|
|
265
|
+
--lift: -1;
|
|
266
|
+
--lift-amount: calc(var(--lift) * var(--gap, 14px));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
:host([data-x-position='right']) {
|
|
270
|
+
right: 0;
|
|
271
|
+
}
|
|
272
|
+
:host([data-x-position='left']) {
|
|
273
|
+
left: 0;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
[data-content] {
|
|
277
|
+
display: flex;
|
|
278
|
+
flex-direction: column;
|
|
279
|
+
gap: 2px;
|
|
280
|
+
flex: 1;
|
|
281
|
+
min-width: 0;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
[data-title],
|
|
285
|
+
::slotted([slot='title']) {
|
|
286
|
+
font-weight: 500;
|
|
287
|
+
line-height: 1.5;
|
|
288
|
+
color: inherit;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
[data-description] {
|
|
292
|
+
font-weight: 400;
|
|
293
|
+
line-height: 1.4;
|
|
294
|
+
color: var(--description-color, #3f3f3f);
|
|
295
|
+
}
|
|
296
|
+
:host([data-rich-colors='true']) [data-description] {
|
|
297
|
+
color: inherit;
|
|
298
|
+
}
|
|
299
|
+
::slotted([slot='description']) {
|
|
300
|
+
color: inherit;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
[data-icon] {
|
|
304
|
+
display: flex;
|
|
305
|
+
height: 16px;
|
|
306
|
+
width: 16px;
|
|
307
|
+
position: relative;
|
|
308
|
+
justify-content: flex-start;
|
|
309
|
+
align-items: center;
|
|
310
|
+
flex-shrink: 0;
|
|
311
|
+
margin-left: var(--toast-icon-margin-start);
|
|
312
|
+
margin-right: var(--toast-icon-margin-end);
|
|
313
|
+
}
|
|
314
|
+
[data-icon] > * {
|
|
315
|
+
flex-shrink: 0;
|
|
316
|
+
}
|
|
317
|
+
[data-icon] svg {
|
|
318
|
+
margin-left: var(--toast-svg-margin-start);
|
|
319
|
+
margin-right: var(--toast-svg-margin-end);
|
|
320
|
+
}
|
|
321
|
+
:host([data-promise='true']) [data-icon] > svg {
|
|
322
|
+
opacity: 0;
|
|
323
|
+
transform: scale(0.8);
|
|
324
|
+
transform-origin: center;
|
|
325
|
+
animation: sonner-fade-in 300ms ease forwards;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
[data-button],
|
|
329
|
+
::slotted(button[slot='action']),
|
|
330
|
+
::slotted(button[slot='cancel']) {
|
|
331
|
+
border-radius: 4px;
|
|
332
|
+
padding-left: 8px;
|
|
333
|
+
padding-right: 8px;
|
|
334
|
+
height: 24px;
|
|
335
|
+
font-size: 12px;
|
|
336
|
+
background: var(--normal-text);
|
|
337
|
+
color: contrast-color(var(--normal-text));
|
|
338
|
+
margin-left: var(--toast-button-margin-start);
|
|
339
|
+
margin-right: var(--toast-button-margin-end);
|
|
340
|
+
border: none;
|
|
341
|
+
font-weight: 500;
|
|
342
|
+
cursor: pointer;
|
|
343
|
+
outline: none;
|
|
344
|
+
display: flex;
|
|
345
|
+
align-items: center;
|
|
346
|
+
flex-shrink: 0;
|
|
347
|
+
transition:
|
|
348
|
+
opacity 400ms,
|
|
349
|
+
box-shadow 200ms;
|
|
350
|
+
font-family: inherit;
|
|
351
|
+
}
|
|
352
|
+
[data-button]:focus-visible {
|
|
353
|
+
box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4);
|
|
354
|
+
}
|
|
355
|
+
[data-cancel],
|
|
356
|
+
::slotted(button[slot='cancel']) {
|
|
357
|
+
color: var(--normal-text);
|
|
358
|
+
background: var(--cancel-bg, rgba(0, 0, 0, 0.08));
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
[data-close-button] {
|
|
362
|
+
position: absolute;
|
|
363
|
+
left: var(--toast-close-button-start);
|
|
364
|
+
right: var(--toast-close-button-end);
|
|
365
|
+
top: 0;
|
|
366
|
+
height: 20px;
|
|
367
|
+
width: 20px;
|
|
368
|
+
display: flex;
|
|
369
|
+
justify-content: center;
|
|
370
|
+
align-items: center;
|
|
371
|
+
padding: 0;
|
|
372
|
+
color: var(--normal-text);
|
|
373
|
+
background: var(--normal-bg);
|
|
374
|
+
border: 1px solid var(--normal-border);
|
|
375
|
+
transform: var(--toast-close-button-transform);
|
|
376
|
+
border-radius: 50%;
|
|
377
|
+
cursor: pointer;
|
|
378
|
+
z-index: 1;
|
|
379
|
+
transition:
|
|
380
|
+
opacity 100ms,
|
|
381
|
+
background 200ms,
|
|
382
|
+
border-color 200ms;
|
|
383
|
+
font: inherit;
|
|
384
|
+
}
|
|
385
|
+
[data-close-button][hidden] {
|
|
386
|
+
display: none;
|
|
387
|
+
}
|
|
388
|
+
[data-close-button]:focus-visible {
|
|
389
|
+
box-shadow:
|
|
390
|
+
0px 4px 12px rgba(0, 0, 0, 0.1),
|
|
391
|
+
0 0 0 2px rgba(0, 0, 0, 0.2);
|
|
392
|
+
}
|
|
393
|
+
:host(:hover) [data-close-button]:hover {
|
|
394
|
+
background: var(--normal-bg-hover, var(--gray2));
|
|
395
|
+
border-color: var(--normal-border-hover, var(--gray5));
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
:host([data-swiping='true'])::before {
|
|
399
|
+
content: '';
|
|
400
|
+
position: absolute;
|
|
401
|
+
left: -100%;
|
|
402
|
+
right: -100%;
|
|
403
|
+
height: 100%;
|
|
404
|
+
z-index: -1;
|
|
405
|
+
}
|
|
406
|
+
:host([data-y-position='top'][data-swiping='true'])::before {
|
|
407
|
+
bottom: 50%;
|
|
408
|
+
transform: scaleY(3) translateY(50%);
|
|
409
|
+
}
|
|
410
|
+
:host([data-y-position='bottom'][data-swiping='true'])::before {
|
|
411
|
+
top: 50%;
|
|
412
|
+
transform: scaleY(3) translateY(-50%);
|
|
413
|
+
}
|
|
414
|
+
:host([data-swiping='false'][data-removed='true'])::before {
|
|
415
|
+
content: '';
|
|
416
|
+
position: absolute;
|
|
417
|
+
inset: 0;
|
|
418
|
+
transform: scaleY(2);
|
|
419
|
+
}
|
|
420
|
+
:host([data-expanded='true'])::after {
|
|
421
|
+
content: '';
|
|
422
|
+
position: absolute;
|
|
423
|
+
left: 0;
|
|
424
|
+
height: calc(var(--gap, 14px) + 1px);
|
|
425
|
+
bottom: 100%;
|
|
426
|
+
width: 100%;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
:host([data-mounted='true']) {
|
|
430
|
+
--y: translateY(0);
|
|
431
|
+
opacity: 1;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/* Heights, driven entirely by CSS. With interpolate-size:allow-keywords on :host,
|
|
435
|
+
* transitions between auto (front collapsed) and the pixel var()s animate smoothly. */
|
|
436
|
+
:host([data-mounted='true'][data-front='true'][data-expanded='false']) {
|
|
437
|
+
height: auto;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
:host([data-expanded='false'][data-front='false']) {
|
|
441
|
+
--scale: var(--toasts-before) * 0.05 + 1;
|
|
442
|
+
--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));
|
|
443
|
+
height: var(--front-toast-height);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
[data-frame] > * {
|
|
447
|
+
transition: opacity 400ms;
|
|
448
|
+
}
|
|
449
|
+
:host([data-expanded='false'][data-front='false'][data-styled='true']) [data-frame] > * {
|
|
450
|
+
opacity: 0;
|
|
451
|
+
}
|
|
452
|
+
:host([data-visible='false']) {
|
|
453
|
+
opacity: 0;
|
|
454
|
+
pointer-events: none;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
:host([data-mounted='true'][data-expanded='true']) {
|
|
458
|
+
--y: translateY(calc(var(--lift) * var(--offset)));
|
|
459
|
+
height: var(--initial-height);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
:host([data-removed='true'][data-front='true'][data-swipe-out='false']) {
|
|
463
|
+
--y: translateY(calc(var(--lift) * -100%));
|
|
464
|
+
opacity: 0;
|
|
465
|
+
}
|
|
466
|
+
:host([data-removed='true'][data-front='false'][data-swipe-out='false'][data-expanded='true']) {
|
|
467
|
+
--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));
|
|
468
|
+
opacity: 0;
|
|
469
|
+
}
|
|
470
|
+
:host([data-removed='true'][data-front='false'][data-swipe-out='false'][data-expanded='false']) {
|
|
471
|
+
--y: translateY(40%);
|
|
472
|
+
opacity: 0;
|
|
473
|
+
transition:
|
|
474
|
+
transform 500ms,
|
|
475
|
+
opacity 200ms;
|
|
476
|
+
}
|
|
477
|
+
:host([data-removed='true'][data-front='false'])::before {
|
|
478
|
+
height: calc(var(--initial-height) + 20%);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
:host([data-swiping='true']) {
|
|
482
|
+
transform: var(--y) translateY(var(--swipe-amount-y, 0px)) translateX(var(--swipe-amount-x, 0px));
|
|
483
|
+
transition: none;
|
|
484
|
+
}
|
|
485
|
+
:host([data-swiped='true']) {
|
|
486
|
+
user-select: none;
|
|
487
|
+
-webkit-user-select: none;
|
|
488
|
+
}
|
|
489
|
+
:host([data-swipe-out='true'][data-y-position='bottom']),
|
|
490
|
+
:host([data-swipe-out='true'][data-y-position='top']) {
|
|
491
|
+
animation-duration: 200ms;
|
|
492
|
+
animation-timing-function: ease-out;
|
|
493
|
+
animation-fill-mode: forwards;
|
|
494
|
+
}
|
|
495
|
+
:host([data-swipe-out='true'][data-swipe-direction='left']) {
|
|
496
|
+
animation-name: swipe-out-left;
|
|
497
|
+
}
|
|
498
|
+
:host([data-swipe-out='true'][data-swipe-direction='right']) {
|
|
499
|
+
animation-name: swipe-out-right;
|
|
500
|
+
}
|
|
501
|
+
:host([data-swipe-out='true'][data-swipe-direction='up']) {
|
|
502
|
+
animation-name: swipe-out-up;
|
|
503
|
+
}
|
|
504
|
+
:host([data-swipe-out='true'][data-swipe-direction='down']) {
|
|
505
|
+
animation-name: swipe-out-down;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
:host([data-invert='true']) {
|
|
509
|
+
--normal-bg: var(--invert-bg);
|
|
510
|
+
--normal-border: var(--invert-border);
|
|
511
|
+
--normal-text: var(--invert-text);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
:host([data-rich-colors='true'][data-type='success']) [data-frame] {
|
|
515
|
+
background: var(--success-bg);
|
|
516
|
+
border-color: var(--success-border);
|
|
517
|
+
color: var(--success-text);
|
|
518
|
+
}
|
|
519
|
+
:host([data-rich-colors='true'][data-type='success']) [data-close-button] {
|
|
520
|
+
background: var(--success-bg);
|
|
521
|
+
border-color: var(--success-border);
|
|
522
|
+
color: var(--success-text);
|
|
523
|
+
}
|
|
524
|
+
:host([data-rich-colors='true'][data-type='info']) [data-frame] {
|
|
525
|
+
background: var(--info-bg);
|
|
526
|
+
border-color: var(--info-border);
|
|
527
|
+
color: var(--info-text);
|
|
528
|
+
}
|
|
529
|
+
:host([data-rich-colors='true'][data-type='info']) [data-close-button] {
|
|
530
|
+
background: var(--info-bg);
|
|
531
|
+
border-color: var(--info-border);
|
|
532
|
+
color: var(--info-text);
|
|
533
|
+
}
|
|
534
|
+
:host([data-rich-colors='true'][data-type='warning']) [data-frame] {
|
|
535
|
+
background: var(--warning-bg);
|
|
536
|
+
border-color: var(--warning-border);
|
|
537
|
+
color: var(--warning-text);
|
|
538
|
+
}
|
|
539
|
+
:host([data-rich-colors='true'][data-type='warning']) [data-close-button] {
|
|
540
|
+
background: var(--warning-bg);
|
|
541
|
+
border-color: var(--warning-border);
|
|
542
|
+
color: var(--warning-text);
|
|
543
|
+
}
|
|
544
|
+
:host([data-rich-colors='true'][data-type='error']) [data-frame] {
|
|
545
|
+
background: var(--error-bg);
|
|
546
|
+
border-color: var(--error-border);
|
|
547
|
+
color: var(--error-text);
|
|
548
|
+
}
|
|
549
|
+
:host([data-rich-colors='true'][data-type='error']) [data-close-button] {
|
|
550
|
+
background: var(--error-bg);
|
|
551
|
+
border-color: var(--error-border);
|
|
552
|
+
color: var(--error-text);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
@keyframes swipe-out-left {
|
|
556
|
+
from {
|
|
557
|
+
transform: var(--y) translateX(var(--swipe-amount-x));
|
|
558
|
+
opacity: 1;
|
|
559
|
+
}
|
|
560
|
+
to {
|
|
561
|
+
transform: var(--y) translateX(calc(var(--swipe-amount-x) - 100%));
|
|
562
|
+
opacity: 0;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
@keyframes swipe-out-right {
|
|
566
|
+
from {
|
|
567
|
+
transform: var(--y) translateX(var(--swipe-amount-x));
|
|
568
|
+
opacity: 1;
|
|
569
|
+
}
|
|
570
|
+
to {
|
|
571
|
+
transform: var(--y) translateX(calc(var(--swipe-amount-x) + 100%));
|
|
572
|
+
opacity: 0;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
@keyframes swipe-out-up {
|
|
576
|
+
from {
|
|
577
|
+
transform: var(--y) translateY(var(--swipe-amount-y));
|
|
578
|
+
opacity: 1;
|
|
579
|
+
}
|
|
580
|
+
to {
|
|
581
|
+
transform: var(--y) translateY(calc(var(--swipe-amount-y) - 100%));
|
|
582
|
+
opacity: 0;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
@keyframes swipe-out-down {
|
|
586
|
+
from {
|
|
587
|
+
transform: var(--y) translateY(var(--swipe-amount-y));
|
|
588
|
+
opacity: 1;
|
|
589
|
+
}
|
|
590
|
+
to {
|
|
591
|
+
transform: var(--y) translateY(calc(var(--swipe-amount-y) + 100%));
|
|
592
|
+
opacity: 0;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
.sonner-loading-wrapper {
|
|
597
|
+
--size: 16px;
|
|
598
|
+
height: var(--size);
|
|
599
|
+
width: var(--size);
|
|
600
|
+
position: absolute;
|
|
601
|
+
inset: 0;
|
|
602
|
+
z-index: 10;
|
|
603
|
+
}
|
|
604
|
+
/* The wrapper is shown/hidden by the :host([data-type='loading']…) rules above; no
|
|
605
|
+
* data-visible attribute needed here. */
|
|
606
|
+
.sonner-spinner {
|
|
607
|
+
position: relative;
|
|
608
|
+
top: 50%;
|
|
609
|
+
left: 50%;
|
|
610
|
+
height: var(--size);
|
|
611
|
+
width: var(--size);
|
|
612
|
+
}
|
|
613
|
+
.sonner-loading-bar {
|
|
614
|
+
animation: sonner-spin 1.2s linear infinite;
|
|
615
|
+
background: var(--gray11, hsl(0, 0%, 43.5%));
|
|
616
|
+
border-radius: 6px;
|
|
617
|
+
height: 8%;
|
|
618
|
+
left: -10%;
|
|
619
|
+
position: absolute;
|
|
620
|
+
top: -3.9%;
|
|
621
|
+
width: 24%;
|
|
622
|
+
}
|
|
623
|
+
.sonner-loading-bar:nth-child(1) {
|
|
624
|
+
animation-delay: -1.2s;
|
|
625
|
+
transform: rotate(0.0001deg) translate(146%);
|
|
626
|
+
}
|
|
627
|
+
.sonner-loading-bar:nth-child(2) {
|
|
628
|
+
animation-delay: -1.1s;
|
|
629
|
+
transform: rotate(30deg) translate(146%);
|
|
630
|
+
}
|
|
631
|
+
.sonner-loading-bar:nth-child(3) {
|
|
632
|
+
animation-delay: -1s;
|
|
633
|
+
transform: rotate(60deg) translate(146%);
|
|
634
|
+
}
|
|
635
|
+
.sonner-loading-bar:nth-child(4) {
|
|
636
|
+
animation-delay: -0.9s;
|
|
637
|
+
transform: rotate(90deg) translate(146%);
|
|
638
|
+
}
|
|
639
|
+
.sonner-loading-bar:nth-child(5) {
|
|
640
|
+
animation-delay: -0.8s;
|
|
641
|
+
transform: rotate(120deg) translate(146%);
|
|
642
|
+
}
|
|
643
|
+
.sonner-loading-bar:nth-child(6) {
|
|
644
|
+
animation-delay: -0.7s;
|
|
645
|
+
transform: rotate(150deg) translate(146%);
|
|
646
|
+
}
|
|
647
|
+
.sonner-loading-bar:nth-child(7) {
|
|
648
|
+
animation-delay: -0.6s;
|
|
649
|
+
transform: rotate(180deg) translate(146%);
|
|
650
|
+
}
|
|
651
|
+
.sonner-loading-bar:nth-child(8) {
|
|
652
|
+
animation-delay: -0.5s;
|
|
653
|
+
transform: rotate(210deg) translate(146%);
|
|
654
|
+
}
|
|
655
|
+
.sonner-loading-bar:nth-child(9) {
|
|
656
|
+
animation-delay: -0.4s;
|
|
657
|
+
transform: rotate(240deg) translate(146%);
|
|
658
|
+
}
|
|
659
|
+
.sonner-loading-bar:nth-child(10) {
|
|
660
|
+
animation-delay: -0.3s;
|
|
661
|
+
transform: rotate(270deg) translate(146%);
|
|
662
|
+
}
|
|
663
|
+
.sonner-loading-bar:nth-child(11) {
|
|
664
|
+
animation-delay: -0.2s;
|
|
665
|
+
transform: rotate(300deg) translate(146%);
|
|
666
|
+
}
|
|
667
|
+
.sonner-loading-bar:nth-child(12) {
|
|
668
|
+
animation-delay: -0.1s;
|
|
669
|
+
transform: rotate(330deg) translate(146%);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
@keyframes sonner-fade-in {
|
|
673
|
+
0% {
|
|
674
|
+
opacity: 0;
|
|
675
|
+
transform: scale(0.8);
|
|
676
|
+
}
|
|
677
|
+
100% {
|
|
678
|
+
opacity: 1;
|
|
679
|
+
transform: scale(1);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
@keyframes sonner-fade-out {
|
|
683
|
+
0% {
|
|
684
|
+
opacity: 1;
|
|
685
|
+
transform: scale(1);
|
|
686
|
+
}
|
|
687
|
+
100% {
|
|
688
|
+
opacity: 0;
|
|
689
|
+
transform: scale(0.8);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
@keyframes sonner-spin {
|
|
693
|
+
0% {
|
|
694
|
+
opacity: 1;
|
|
695
|
+
}
|
|
696
|
+
100% {
|
|
697
|
+
opacity: 0.15;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
@media (prefers-reduced-motion) {
|
|
702
|
+
:host,
|
|
703
|
+
[data-frame],
|
|
704
|
+
[data-frame] > *,
|
|
705
|
+
.sonner-loading-bar {
|
|
706
|
+
transition: none !important;
|
|
707
|
+
animation: none !important;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/* Mobile: toasts fill the toaster's full width instead of staying pinned to
|
|
712
|
+
* --width (356px). Mirrors Sonner's mobile rule on [data-sonner-toast].
|
|
713
|
+
* Breakpoint matches the toaster's own mobile threshold. */
|
|
714
|
+
@media (max-width: 600px) {
|
|
715
|
+
:host([data-styled='true']),
|
|
716
|
+
:host([data-styled='false']) {
|
|
717
|
+
left: 0;
|
|
718
|
+
right: 0;
|
|
719
|
+
width: 100%;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
`;var S=null,Y=null;function B(){if(!S)S=new CSSStyleSheet,S.replaceSync(P);return S}function A(){if(!Y)Y=new CSSStyleSheet,Y.replaceSync(q);return Y}var da=typeof HTMLElement!=="undefined"?HTMLElement:class{};function K(a){return a==="error"||a==="warning"}function N(a,r,t){for(let n of Array.from(a.children))if(n.getAttribute("slot")===r)a.removeChild(n);if(t==null||t==="")return;let o=typeof t==="function"?t():t;if(o instanceof Node){if(o instanceof Element)o.setAttribute("slot",r);a.appendChild(o)}else{let n=document.createElement("span");n.setAttribute("slot",r),n.textContent=String(o),a.appendChild(n)}}function F(a,r,t,o){for(let h of Array.from(a.children))if(h.getAttribute("slot")===r)a.removeChild(h);if(!t)return;if(t instanceof HTMLElement){t.setAttribute("slot",r),a.appendChild(t);return}let n=document.createElement("button");if(n.setAttribute("slot",r),n.setAttribute("type","button"),r==="cancel")n.setAttribute("data-cancel","");else n.setAttribute("data-action","");n.textContent=t.label,n.addEventListener("click",(h)=>{if(t.onClick?.(h),h.defaultPrevented&&r==="action")return;o()}),a.appendChild(n)}var ha=Array.from({length:12},()=>'<div class="sonner-loading-bar"></div>').join(""),ia=`
|
|
723
|
+
<div data-frame part="frame">
|
|
724
|
+
<button type="button" data-close-button part="close-button" hidden aria-label="Close toast"></button>
|
|
725
|
+
<div data-icon part="icon">
|
|
726
|
+
<slot name="icon"></slot>
|
|
727
|
+
<div class="sonner-loading-wrapper" aria-hidden="true">
|
|
728
|
+
<div class="sonner-spinner">${ha}</div>
|
|
729
|
+
</div>
|
|
730
|
+
</div>
|
|
731
|
+
<div data-content part="content">
|
|
732
|
+
<div data-title part="title"><slot name="title"></slot></div>
|
|
733
|
+
<div data-description part="description"><slot name="description"></slot></div>
|
|
734
|
+
</div>
|
|
735
|
+
<slot name="cancel"></slot>
|
|
736
|
+
<slot name="action"></slot>
|
|
737
|
+
<slot part="custom"></slot>
|
|
738
|
+
</div>
|
|
739
|
+
`;class l extends da{static get observedAttributes(){return["type","duration","dismissible","position","close-button","rich-colors","invert"]}toastId=0;#o;#e;#w;#c;#t;#f=null;#d=y;#a=null;#s=0;#n=new Set;#h=null;#b=0;#i=null;#m=null;#x=!1;#g=!1;#Y=!1;#y;#u;#k=null;#l=null;constructor(){super();this.#o=this.attachShadow({mode:"open"}),this.#o.adoptedStyleSheets=[A()];let a=document.createElement("template");a.innerHTML=ia,this.#o.appendChild(a.content.cloneNode(!0)),this.#e=this.#o.querySelector("[data-close-button]"),this.#w=this.#o.querySelector("[data-icon]"),this.#c=this.#o.querySelector("[data-title]"),this.#t=this.#o.querySelector("[data-description]"),this.#e.innerHTML=G,this.#e.addEventListener("click",()=>this.dismiss());let r=this.#o.querySelector('slot[name="icon"]'),t=this.#o.querySelector('slot[name="description"]');r.addEventListener("slotchange",()=>this.#X("icon",r)),t.addEventListener("slotchange",()=>this.#X("description",t)),this.addEventListener("pointerdown",this.#H),this.addEventListener("pointermove",this.#C),this.addEventListener("pointerup",this.#U),this.addEventListener("pointercancel",this.#U),this.addEventListener("mouseenter",()=>this.#Z("hover-self")),this.addEventListener("mouseleave",()=>this.#$("hover-self")),this.addEventListener("focusin",(o)=>{if(this.#Z("focus-self"),this.#l)return;let n=o.relatedTarget;if(n&&!this.contains(n))this.#l=n}),this.addEventListener("focusout",()=>this.#$("focus-self")),this.addEventListener("keydown",(o)=>{if(o.key==="Escape"&&this.#W())o.stopPropagation(),this.dismiss()})}connectedCallback(){if(!this.toastId)this.toastId=this.getAttribute("id")||0;if(!this.hasAttribute("tabindex"))this.tabIndex=0;if(this.#_(),this.#J(),this.#K(),this.#S(),this.#Q(),this.#v(),this.setAttribute("data-sonner-toast",""),!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true");if(this.setAttribute("data-mounted","false"),this.setAttribute("data-removed","false"),this.setAttribute("data-swiping","false"),this.setAttribute("data-swiped","false"),this.setAttribute("data-swipe-out","false"),!this.hasAttribute("data-styled"))this.setAttribute("data-styled","true");j(this),document.addEventListener("visibilitychange",this.#G),requestAnimationFrame(()=>{this.#x=!0,this.setAttribute("data-mounted","true"),this.dispatchEvent(new CustomEvent("sonner-toast-mounted",{bubbles:!0,composed:!0})),this.#p()})}disconnectedCallback(){if(this.#a)clearTimeout(this.#a);document.removeEventListener("visibilitychange",this.#G),H(this)}attributeChangedCallback(a,r,t){if(!this.isConnected)return;switch(a){case"type":this.#_();break;case"duration":this.#f=this.#V(),this.#d=this.#f??y;break;case"dismissible":this.#J();break;case"position":this.#K();break;case"close-button":this.#v();break;case"rich-colors":this.#S();break;case"invert":this.#Q();break}}get toastType(){return this.getAttribute("type")||"default"}dismiss(){if(this.#g||this.#Y)return;if(this.#Y=!0,this.#g=!0,this.setAttribute("data-removed","true"),this.#a)clearTimeout(this.#a);this.dispatchEvent(new CustomEvent("sonner-toast-dismissed",{bubbles:!0,composed:!0})),setTimeout(()=>{this.#r(),this.#y?.(this),this.remove()},V)}#r(){if(!this.#l)return;let a=document.activeElement;if(!a||!this.contains(a))return;let r=this.#l;if(!r.isConnected||typeof r.focus!=="function")return;r.focus()}update(a){let r=a.type!==void 0&&a.type!==this.toastType,t=K(this.toastType);if(a.type!==void 0)this.setAttribute("type",a.type);let o=!1;if(a.duration!==void 0)this.setAttribute("duration",String(a.duration)),this.#f=a.duration,this.#d=a.duration,o=!0;else if(r)this.#f=null,this.removeAttribute("duration"),this.#d=0,o=!0;if(a.dismissible!==void 0)if(a.dismissible)this.setAttribute("dismissible","");else this.removeAttribute("dismissible");if(a.position!==void 0)this.setAttribute("position",a.position);if(a.closeButton!==void 0)if(a.closeButton)this.setAttribute("close-button","");else this.removeAttribute("close-button");if(a.richColors!==void 0)if(a.richColors)this.setAttribute("rich-colors","");else this.removeAttribute("rich-colors");if(a.invert!==void 0)if(a.invert)this.setAttribute("invert","");else this.removeAttribute("invert");if(a.icon!==void 0)this.setIcon(a.icon);if(a.title!==void 0)this.setTitle(a.title);if(a.description!==void 0)this.setDescription(a.description);if(a.action!==void 0)F(this,"action",a.action,()=>this.dismiss());if(a.cancel!==void 0)F(this,"cancel",a.cancel,()=>this.dismiss());if(a.className)this.className=a.className;if(a.testId!==void 0)this.setAttribute("data-testid",a.testId);if(a.closeButtonAriaLabel!==void 0)this.#k=a.closeButtonAriaLabel||null,this.#z();if(a.onDismiss)this.#y=a.onDismiss;if(a.onAutoClose)this.#u=a.onAutoClose;if(o)this.#j();if(this.#x&&r&&!t&&K(this.toastType)){let h=Array.from(this.children).find((e)=>e.getAttribute("slot")==="title")?.textContent?.trim();if(h)this.closest("sonner-toaster")?.announceUrgent(h)}this.dispatchEvent(new CustomEvent("sonner-toast-updated",{bubbles:!0,composed:!0}))}setTitle(a){N(this,"title",a),this.#z()}#z(){if(this.#k){this.#e.setAttribute("aria-label",this.#k);return}let r=Array.from(this.children).find((t)=>t.getAttribute("slot")==="title")?.textContent?.trim();this.#e.setAttribute("aria-label",r?`Close: ${r}`:"Close toast")}setDescription(a){N(this,"description",a)}setIcon(a){for(let r of Array.from(this.children))if(r.getAttribute("slot")==="icon")this.removeChild(r);if(a==null)return;if(a instanceof Node){if(a instanceof Element)a.setAttribute("slot","icon");this.appendChild(a)}else{let r=document.createElement("template");r.innerHTML=a;let t=r.content.firstElementChild;if(t)t.setAttribute("slot","icon"),this.appendChild(t)}}setHandlers(a){this.#y=a.onDismiss,this.#u=a.onAutoClose}setPaused(a){if(a)this.#Z("toaster");else this.#$("toaster")}#X(a,r){if(r.assignedNodes().length>0)this.setAttribute(`data-has-${a}`,"");else this.removeAttribute(`data-has-${a}`)}#_(){let a=this.toastType;this.setAttribute("data-type",a);let r=K(a);if(this.setAttribute("role",r?"alert":"status"),this.setAttribute("aria-live",r?"assertive":"polite"),a==="loading"){this.setAttribute("data-promise","true");for(let t of Array.from(this.children))if(t.getAttribute("slot")==="icon"&&t.hasAttribute("data-sonner-default-icon"))this.removeChild(t)}else if(this.removeAttribute("data-promise"),!Array.from(this.children).some((o)=>{if(o.getAttribute("slot")!=="icon")return!1;return!o.hasAttribute("data-sonner-default-icon")})){for(let n of Array.from(this.children))if(n.getAttribute("slot")==="icon"&&n.hasAttribute("data-sonner-default-icon"))this.removeChild(n);let o=U(a);if(o){let n=document.createElement("template");n.innerHTML=o;let h=n.content.firstElementChild;if(h)h.setAttribute("slot","icon"),h.setAttribute("data-sonner-default-icon",""),this.appendChild(h)}}}#J(){let a=this.getAttribute("dismissible")!=="false";this.setAttribute("data-dismissible",String(a))}#K(){let a=this.getAttribute("position");if(!a)return;let[r,t]=a.split("-");if(r)this.setAttribute("data-y-position",r);if(t)this.setAttribute("data-x-position",t)}#v(){let a=this.hasAttribute("close-button")&&this.getAttribute("close-button")!=="false";this.#e.hidden=!a}#S(){let a=this.hasAttribute("rich-colors")&&this.getAttribute("rich-colors")!=="false";this.setAttribute("data-rich-colors",String(a))}#Q(){let a=this.hasAttribute("invert")&&this.getAttribute("invert")!=="false";this.setAttribute("data-invert",String(a))}#V(){let a=this.getAttribute("duration");if(a==null)return null;if(a==="Infinity")return 1/0;let r=Number(a);return Number.isFinite(r)||r===1/0?r:null}#E(){let a=this.#f??this.#V();if(a!==null)return a;if(this.toastType==="loading")return 1/0;return y}#p(){if(!this.#x||this.#g)return;if(this.#n.size>0)return;if(this.#a!==null)return;let a=this.#E();if(a===1/0)return;this.#d=this.#d>0?this.#d:a,this.#s=Date.now(),this.#a=setTimeout(()=>{this.#a=null,this.#u?.(this),this.dispatchEvent(new CustomEvent("sonner-toast-autoclosed",{bubbles:!0,composed:!0})),this.dismiss()},this.#d)}#Z(a){let r=this.#n.size===0;if(this.#n.add(a),r&&this.#a!==null){clearTimeout(this.#a),this.#a=null;let t=Date.now()-this.#s;this.#d=Math.max(0,this.#d-t)}}#$(a){if(!this.#n.delete(a))return;if(this.#n.size===0&&!this.#g)this.#p()}#j(){if(this.#a)clearTimeout(this.#a),this.#a=null;this.#d=this.#E(),this.#p()}#G=()=>{if(document.visibilityState==="hidden")this.#Z("doc-hidden");else this.#$("doc-hidden")};#W(){return this.getAttribute("dismissible")!=="false"}#H=(a)=>{if(a.button===2)return;if(this.toastType==="loading"||!this.#W())return;let r=a.composedPath()[0];if(r){if(r.tagName==="BUTTON"||typeof r.closest==="function"&&r.closest("button"))return}this.#b=Date.now();try{this.setPointerCapture(a.pointerId)}catch{}if(this.setAttribute("data-swiping","true"),this.#h={x:a.clientX,y:a.clientY},!this.#m){let t=this.getAttribute("data-y-position"),o=this.getAttribute("data-x-position"),n=[];if(t==="top"||t==="bottom")n.push(t);if(o==="left"||o==="right")n.push(o);this.#m=n.length>0?n:["bottom","right"]}};#C=(a)=>{if(!this.#h||!this.#W())return;if((window.getSelection()?.toString().length??0)>0)return;let r=a.clientY-this.#h.y,t=a.clientX-this.#h.x,o=this.#m;if(!this.#i&&(Math.abs(t)>1||Math.abs(r)>1))this.#i=Math.abs(t)>Math.abs(r)?"x":"y";let n=(d)=>1/(1.5+Math.abs(d)/20),h=0,e=0;if(this.#i==="y"){if(o.includes("top")||o.includes("bottom"))if(o.includes("top")&&r<0||o.includes("bottom")&&r>0)e=r;else{let d=r*n(r);e=Math.abs(d)<Math.abs(r)?d:r}}else if(this.#i==="x"){if(o.includes("left")||o.includes("right"))if(o.includes("left")&&t<0||o.includes("right")&&t>0)h=t;else{let d=t*n(t);h=Math.abs(d)<Math.abs(t)?d:t}}if(Math.abs(h)>0||Math.abs(e)>0)this.setAttribute("data-swiped","true");this.style.setProperty("--swipe-amount-x",`${h}px`),this.style.setProperty("--swipe-amount-y",`${e}px`)};#U=()=>{if(this.getAttribute("data-swipe-out")==="true"||!this.#W()){this.#h=null,this.#i=null,this.setAttribute("data-swiping","false");return}let a=parseFloat(this.style.getPropertyValue("--swipe-amount-x"))||0,r=parseFloat(this.style.getPropertyValue("--swipe-amount-y"))||0,t=Math.max(1,Date.now()-this.#b),o=this.#i==="x"?a:r,n=Math.abs(o)/t;if(Math.abs(o)>=W||n>p){if(this.#i==="x")this.setAttribute("data-swipe-direction",a>0?"right":"left");else this.setAttribute("data-swipe-direction",r>0?"down":"up");this.setAttribute("data-swipe-out","true"),this.dismiss()}else this.style.setProperty("--swipe-amount-x","0px"),this.style.setProperty("--swipe-amount-y","0px"),this.setAttribute("data-swiped","false");this.setAttribute("data-swiping","false"),this.#h=null,this.#i=null}}if(typeof customElements!=="undefined"&&!customElements.get("sonner-toast"))customElements.define("sonner-toast",l);var ea=typeof HTMLElement!=="undefined"?HTMLElement:class{};function O(a,r){if(a==null)return r;if(typeof a==="number")return`${a}px`;return a}function I(a,r,t,o){let n=["top","right","bottom","left"];if(r==null||typeof r==="string"||typeof r==="number"){let h=O(r,o);for(let e of n)a.style.setProperty(`${t}-${e}`,h)}else for(let h of n)a.style.setProperty(`${t}-${h}`,O(r[h],o))}class m extends ea{static get observedAttributes(){return["position","theme","rich-colors","expand","duration","gap","visible-toasts","close-button","invert","dir","offset","mobile-offset","hotkey","container-aria-label"]}#o;#e;#w;#c;#t=[];#f=new Map;#d=!1;#a=!1;#s=!1;#n=null;#h=null;constructor(){super();this.#o=this.attachShadow({mode:"open"}),this.#o.adoptedStyleSheets=[B()],this.#o.innerHTML='<div data-frame part="frame"><slot></slot></div><div data-alert-announcer role="alert" aria-live="assertive" aria-atomic="true" style="position:absolute;left:0;top:0;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0;pointer-events:none"></div>',this.#e=this.#o.querySelector("[data-alert-announcer]"),this.#w=new MutationObserver((a)=>{let r=!1;for(let t of a){for(let o of Array.from(t.addedNodes))if(o instanceof l)this.#t.unshift(o),this.#c.observe(o),this.#l(o),r=!0;for(let o of Array.from(t.removedNodes))if(o instanceof l)this.#t=this.#t.filter((n)=>n!==o),this.#f.delete(o),this.#c.unobserve(o),r=!0}if(r)this.#r({remeasure:!0})}),this.#c=new ResizeObserver(()=>this.#r({remeasure:!1})),this.addEventListener("mouseenter",this.#X),this.addEventListener("mouseleave",this.#_),this.addEventListener("focusin",this.#J),this.addEventListener("focusout",this.#K),this.addEventListener("sonner-toast-dismissed",()=>this.#r({remeasure:!1})),this.addEventListener("sonner-toast-updated",()=>this.#r({remeasure:!0})),this.addEventListener("sonner-toast-mounted",()=>this.#r({remeasure:!0}))}connectedCallback(){if(!this.hasAttribute("tabindex"))this.tabIndex=-1;if(!this.hasAttribute("role"))this.setAttribute("role","region");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("container-aria-label")??"Notifications");this.setAttribute("data-sonner-toaster",""),this.#i(),this.#m(),this.#x(),this.#g(),this.#Y(),this.#y(),this.#w.observe(this,{childList:!0});for(let a of Array.from(this.children))if(a instanceof l)this.#t.unshift(a),this.#c.observe(a),this.#l(a);document.addEventListener("keydown",this.#S),window.addEventListener("resize",this.#v),C(this),this.#r({remeasure:!0})}disconnectedCallback(){if(this.#w.disconnect(),this.#c.disconnect(),document.removeEventListener("keydown",this.#S),window.removeEventListener("resize",this.#v),this.#n&&this.#h)this.#n.removeEventListener("change",this.#h);L(this)}attributeChangedCallback(a,r,t){if(!this.isConnected)return;switch(a){case"position":this.#i(),this.#u(),this.#r();break;case"theme":this.#m();break;case"dir":this.#x();break;case"gap":this.#g(),this.#r();break;case"visible-toasts":this.#r();break;case"expand":this.#a=this.hasAttribute("expand");for(let o of this.#t)o.setPaused(this.#a||this.#s);this.#r();break;case"close-button":case"rich-colors":case"invert":this.#k(a);break;case"offset":case"mobile-offset":this.#y();break;case"container-aria-label":this.setAttribute("aria-label",this.getAttribute("container-aria-label")??"Notifications");break}}addToast(a){return this.appendChild(a),a}announceUrgent(a){this.#e.textContent="",requestAnimationFrame(()=>{this.#e.textContent=a})}dismissAll(){for(let a of Array.from(this.children))if(a instanceof l)a.dismiss()}#b(){return this.getAttribute("position")||"bottom-right"}#i(){let[a,r]=this.#b().split("-");if(a)this.setAttribute("data-y-position",a);if(r)this.setAttribute("data-x-position",r)}#m(){if(this.#n&&this.#h)this.#n.removeEventListener("change",this.#h),this.#n=null,this.#h=null;let a=this.getAttribute("theme")||"light";if(a==="system"){this.#n=window.matchMedia("(prefers-color-scheme: dark)");let r=(t)=>{this.setAttribute("data-sonner-theme",t.matches?"dark":"light")};this.#h=r,this.#n.addEventListener("change",r),r(this.#n)}else this.setAttribute("data-sonner-theme",a)}#x(){let a=this.getAttribute("dir");if(a==="auto"||!a){let r=window.getComputedStyle(document.documentElement).direction||"ltr";this.setAttribute("dir",r)}}#g(){let a=this.getAttribute("gap"),r=a?Number(a):b;this.style.setProperty("--gap",`${Number.isFinite(r)?r:b}px`)}#Y(){this.style.setProperty("--width",`${$}px`)}#y(){let a=this.getAttribute("offset"),r=this.getAttribute("mobile-offset");I(this,a??void 0,"--offset","24px"),I(this,r??void 0,"--mobile-offset","16px")}#u(){for(let a of this.#t)if(!a.hasAttribute("position")){let[r,t]=this.#b().split("-");if(r)a.setAttribute("data-y-position",r);if(t)a.setAttribute("data-x-position",t)}}#k(a){let r=this.hasAttribute(a);for(let t of this.#t){if(t.getAttribute(a)==="false")continue;if(r)t.setAttribute(a,"");else t.removeAttribute(a)}}#l(a){if(!a.hasAttribute("position")){let[r,t]=this.#b().split("-");if(r)a.setAttribute("data-y-position",r);if(t)a.setAttribute("data-x-position",t)}if(!a.hasAttribute("duration")){let r=this.getAttribute("duration");if(r)a.setAttribute("duration",r)}if(!a.hasAttribute("close-button")&&this.hasAttribute("close-button"))a.setAttribute("close-button","");if(!a.hasAttribute("rich-colors")&&this.hasAttribute("rich-colors"))a.setAttribute("rich-colors","");if(!a.hasAttribute("invert")&&this.hasAttribute("invert"))a.setAttribute("invert","")}#r(a={remeasure:!1}){let r=Number(this.getAttribute("visible-toasts")??Z);if(a.remeasure){this.#d=!0;for(let d of this.#t){if(d.getAttribute("data-removed")==="true")continue;let i=d.style.height;d.style.height="auto",this.#f.set(d,d.getBoundingClientRect().height),d.style.height=i}this.#d=!1}let t=this.#t.filter((d)=>d.getAttribute("data-removed")!=="true"),o=t.length>0?this.#f.get(t[0])??0:0,n=this.#z(),h=this.#a||this.#s,e=0;this.style.setProperty("--front-toast-height",`${o}px`);for(let d=0;d<t.length;d++){let i=t[d],s=this.#f.get(i)??0,x=d===0,c=d===0?0:e+d*n;if(e+=s,i.style.setProperty("--index",String(d)),i.style.setProperty("--toasts-before",String(d)),i.style.setProperty("--z-index",String(t.length-d)),i.style.setProperty("--offset",`${c}px`),i.style.setProperty("--initial-height",`${s}px`),i.setAttribute("data-index",String(d)),i.setAttribute("data-front",String(x)),i.setAttribute("data-visible",String(d+1<=r)),i.setAttribute("data-expanded",String(h)),h||x)i.removeAttribute("aria-hidden");else i.setAttribute("aria-hidden","true")}}#z(){let a=this.getAttribute("gap"),r=a?Number(a):b;return Number.isFinite(r)?r:b}#X=()=>{this.#s=!0;for(let a of this.#t)a.setPaused(!0);this.#r()};#_=()=>{this.#s=!1;for(let a of this.#t)a.setPaused(!1);this.#r()};#J=()=>{this.#s=!0;for(let a of this.#t)a.setPaused(!0);this.#r()};#K=(a)=>{let r=a.relatedTarget;if(r&&this.contains(r))return;this.#s=!1;for(let t of this.#t)t.setPaused(!1);this.#r()};#v=()=>this.#r({remeasure:!0});#S=(a)=>{let r=a.target;if(r){let n=r.tagName;if(n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||r.isContentEditable)return}if(this.#Q().every((n)=>{if(n==="altKey"||n==="ctrlKey"||n==="shiftKey"||n==="metaKey")return a[n];return a.code===n})){this.#a=!0;for(let n of this.#t)n.setPaused(!0);this.focus(),this.#r();return}if(a.key==="Escape"&&this.#a&&this.contains(document.activeElement)){this.#a=!1;for(let n of this.#t)n.setPaused(!1);this.#r()}};#Q(){let a=this.getAttribute("hotkey");if(!a)return E;return a.split("+").map((r)=>r.trim())}}if(typeof customElements!=="undefined"&&!customElements.get("sonner-toaster"))customElements.define("sonner-toaster",m);function D(a){if(a){let t=document.getElementById(a);if(t instanceof m)return t}let r=M();if(!r)r=document.createElement("sonner-toaster"),document.body.appendChild(r);return r}function _(a){let r=a.id??k(),t=v(r);if(t)return t.update(a),t;let o=document.createElement("sonner-toast");return o.toastId=r,o.update(a),o.setHandlers({onDismiss:a.onDismiss,onAutoClose:a.onAutoClose}),D(a.toasterId).addToast(o),o}function z(a){return(r,t)=>_({...t,type:a,title:r})}function T(a,r){return _({...r,type:"default",title:a})}function fa(a){if(a!==void 0){v(a)?.dismiss();return}R()}function sa(a,r){let t=r?.id??k(),o=document.createElement("sonner-toast");if(o.toastId=t,o.setAttribute("data-styled","false"),r?.duration!==void 0)o.setAttribute("duration",String(r.duration));if(r?.dismissible===!1)o.setAttribute("dismissible","false");if(r?.position)o.setAttribute("position",r.position);if(r?.testId!==void 0)o.setAttribute("data-testid",r.testId);let n=a(t);return o.appendChild(n),o.setHandlers({onDismiss:r?.onDismiss,onAutoClose:r?.onAutoClose}),D(r?.toasterId).addToast(o),o}async function X(a,r){if(a===void 0)return;if(typeof a==="function")return a.length===0?a():a(r);return a}function ca(a,r){let t=r.id??k(),{loading:o,success:n,error:h,description:e,finally:d,...i}=r,s=_({...i,id:t,type:"loading",title:r.loading,duration:1/0,dismissible:r.dismissible??!1}),x=Promise.resolve(typeof a==="function"?a():a),c=null,aa=x.then(async(f)=>{c=["resolve",f];let g=await X(r.success,f),J=await X(r.description,f);if(g!==void 0)s.update({...i,id:t,type:"success",title:g,description:J,duration:r.duration,dismissible:r.dismissible??!0});else s.dismiss()}).catch(async(f)=>{c=["reject",f];let g=await X(r.error,f),J=await X(r.description,f);if(g!==void 0)s.update({...i,id:t,type:"error",title:g,description:J,duration:r.duration,dismissible:r.dismissible??!0});else s.dismiss()}).finally(()=>r.finally?.());return Object.assign(s,{unwrap:()=>new Promise((f,g)=>{aa.then(()=>{if(!c)return g(new Error("promise toast settled without a result"));if(c[0]==="resolve")f(c[1]);else g(c[1])})})})}var Q=Object.assign(T,{success:z("success"),error:z("error"),info:z("info"),warning:z("warning"),loading:(a,r)=>_({...r,type:"loading",title:a,duration:r?.duration??1/0}),message:T,promise:ca,custom:sa,dismiss:fa,getToast:v});if(typeof window!=="undefined")window.toast=Q;export{Q as toast,m as SonnerToaster,l as SonnerToast};
|
|
740
|
+
|
|
741
|
+
//# debugId=F44C4561DFB2B55264756E2164756E21
|
|
742
|
+
//# sourceMappingURL=sonner-wc.bundle.js.map
|