@react-spectrum/toast 3.0.0-nightly.1996 → 3.0.0-nightly.2005

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.
Files changed (2) hide show
  1. package/dist/import.mjs +647 -0
  2. package/package.json +17 -12
@@ -0,0 +1,647 @@
1
+ import "./main.css";
2
+ import $jn1ib$react, {useRef as $jn1ib$useRef, useEffect as $jn1ib$useEffect} from "react";
3
+ import {ToastQueue as $jn1ib$ToastQueue, useToastQueue as $jn1ib$useToastQueue} from "@react-stately/toast";
4
+ import {useSyncExternalStore as $jn1ib$useSyncExternalStore} from "use-sync-external-store/shim";
5
+ import $jn1ib$spectrumiconsuiAlertMedium from "@spectrum-icons/ui/AlertMedium";
6
+ import {Button as $jn1ib$Button, ClearButton as $jn1ib$ClearButton} from "@react-spectrum/button";
7
+ import {useDOMRef as $jn1ib$useDOMRef, useStyleProps as $jn1ib$useStyleProps, classNames as $jn1ib$classNames, useIsMobileDevice as $jn1ib$useIsMobileDevice} from "@react-spectrum/utils";
8
+ import $jn1ib$spectrumiconsuiCrossMedium from "@spectrum-icons/ui/CrossMedium";
9
+ import $jn1ib$spectrumiconsuiInfoMedium from "@spectrum-icons/ui/InfoMedium";
10
+ import $jn1ib$spectrumiconsuiSuccessMedium from "@spectrum-icons/ui/SuccessMedium";
11
+ import {useLocalizedStringFormatter as $jn1ib$useLocalizedStringFormatter} from "@react-aria/i18n";
12
+ import {useToast as $jn1ib$useToast, useToastRegion as $jn1ib$useToastRegion} from "@react-aria/toast";
13
+ import {FocusRing as $jn1ib$FocusRing} from "@react-aria/focus";
14
+ import {Provider as $jn1ib$Provider} from "@react-spectrum/provider";
15
+ import $jn1ib$reactdom from "react-dom";
16
+
17
+ function $parcel$interopDefault(a) {
18
+ return a && a.__esModule ? a.default : a;
19
+ }
20
+ function $parcel$export(e, n, v, s) {
21
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
22
+ }
23
+ /*
24
+ * Copyright 2020 Adobe. All rights reserved.
25
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
26
+ * you may not use this file except in compliance with the License. You may obtain a copy
27
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
28
+ *
29
+ * Unless required by applicable law or agreed to in writing, software distributed under
30
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
31
+ * OF ANY KIND, either express or implied. See the License for the specific language
32
+ * governing permissions and limitations under the License.
33
+ */ /// <reference types="css-module-types" />
34
+ /*
35
+ * Copyright 2020 Adobe. All rights reserved.
36
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
37
+ * you may not use this file except in compliance with the License. You may obtain a copy
38
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
39
+ *
40
+ * Unless required by applicable law or agreed to in writing, software distributed under
41
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
42
+ * OF ANY KIND, either express or implied. See the License for the specific language
43
+ * governing permissions and limitations under the License.
44
+ */
45
+ /*
46
+ * Copyright 2020 Adobe. All rights reserved.
47
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
48
+ * you may not use this file except in compliance with the License. You may obtain a copy
49
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
50
+ *
51
+ * Unless required by applicable law or agreed to in writing, software distributed under
52
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
53
+ * OF ANY KIND, either express or implied. See the License for the specific language
54
+ * governing permissions and limitations under the License.
55
+ */
56
+
57
+
58
+
59
+
60
+ var $9b92fa4e52e1872f$exports = {};
61
+ var $4ef3586572b5c0bd$exports = {};
62
+ $4ef3586572b5c0bd$exports = {
63
+ "info": `معلومات`,
64
+ "negative": `خطأ`,
65
+ "positive": `تم بنجاح`
66
+ };
67
+
68
+
69
+ var $9294a3bc0be7c803$exports = {};
70
+ $9294a3bc0be7c803$exports = {
71
+ "info": `Инфо`,
72
+ "negative": `Грешка`,
73
+ "positive": `Успех`
74
+ };
75
+
76
+
77
+ var $2301cc9fa70c79b7$exports = {};
78
+ $2301cc9fa70c79b7$exports = {
79
+ "info": `Informace`,
80
+ "negative": `Chyba`,
81
+ "positive": `Úspěch`
82
+ };
83
+
84
+
85
+ var $db68d63440e07cc2$exports = {};
86
+ $db68d63440e07cc2$exports = {
87
+ "info": `Info`,
88
+ "negative": `Fejl`,
89
+ "positive": `Fuldført`
90
+ };
91
+
92
+
93
+ var $59f85255004b972f$exports = {};
94
+ $59f85255004b972f$exports = {
95
+ "info": `Informationen`,
96
+ "negative": `Fehler`,
97
+ "positive": `Erfolg`
98
+ };
99
+
100
+
101
+ var $897a62d7e05e3ae7$exports = {};
102
+ $897a62d7e05e3ae7$exports = {
103
+ "info": `Πληροφορίες`,
104
+ "negative": `Σφάλμα`,
105
+ "positive": `Επιτυχία`
106
+ };
107
+
108
+
109
+ var $cd5f6f9dc2665e8f$exports = {};
110
+ $cd5f6f9dc2665e8f$exports = {
111
+ "info": `Info`,
112
+ "negative": `Error`,
113
+ "positive": `Success`
114
+ };
115
+
116
+
117
+ var $91da3b58720e2afa$exports = {};
118
+ $91da3b58720e2afa$exports = {
119
+ "info": `Información`,
120
+ "negative": `Error`,
121
+ "positive": `Éxito`
122
+ };
123
+
124
+
125
+ var $d881203a181403bc$exports = {};
126
+ $d881203a181403bc$exports = {
127
+ "info": `Teave`,
128
+ "negative": `Viga`,
129
+ "positive": `Valmis`
130
+ };
131
+
132
+
133
+ var $b39cb8320f170f5d$exports = {};
134
+ $b39cb8320f170f5d$exports = {
135
+ "info": `Tiedot`,
136
+ "negative": `Virhe`,
137
+ "positive": `Onnistui`
138
+ };
139
+
140
+
141
+ var $3dcec82c37bb9c69$exports = {};
142
+ $3dcec82c37bb9c69$exports = {
143
+ "info": `Infos`,
144
+ "negative": `Erreur`,
145
+ "positive": `Succès`
146
+ };
147
+
148
+
149
+ var $70451b8bc8958a93$exports = {};
150
+ $70451b8bc8958a93$exports = {
151
+ "info": `מידע`,
152
+ "negative": `שגיאה`,
153
+ "positive": `הצלחה`
154
+ };
155
+
156
+
157
+ var $8192b2e4907779a9$exports = {};
158
+ $8192b2e4907779a9$exports = {
159
+ "info": `Informacije`,
160
+ "negative": `Pogreška`,
161
+ "positive": `Uspješno`
162
+ };
163
+
164
+
165
+ var $734bda6365304ddb$exports = {};
166
+ $734bda6365304ddb$exports = {
167
+ "info": `Információ`,
168
+ "negative": `Hiba`,
169
+ "positive": `Siker`
170
+ };
171
+
172
+
173
+ var $c985376db8169cb9$exports = {};
174
+ $c985376db8169cb9$exports = {
175
+ "info": `Informazioni`,
176
+ "negative": `Errore`,
177
+ "positive": `Operazione riuscita`
178
+ };
179
+
180
+
181
+ var $0a814f0515b1f941$exports = {};
182
+ $0a814f0515b1f941$exports = {
183
+ "info": `情報`,
184
+ "negative": `エラー`,
185
+ "positive": `成功`
186
+ };
187
+
188
+
189
+ var $87900002a59b18f5$exports = {};
190
+ $87900002a59b18f5$exports = {
191
+ "info": `정보`,
192
+ "negative": `오류`,
193
+ "positive": `성공`
194
+ };
195
+
196
+
197
+ var $b083aee709113368$exports = {};
198
+ $b083aee709113368$exports = {
199
+ "info": `Informacija`,
200
+ "negative": `Klaida`,
201
+ "positive": `Sėkmingai`
202
+ };
203
+
204
+
205
+ var $641d21187f9a9953$exports = {};
206
+ $641d21187f9a9953$exports = {
207
+ "info": `Informācija`,
208
+ "negative": `Kļūda`,
209
+ "positive": `Izdevās`
210
+ };
211
+
212
+
213
+ var $920b9baf5fdd305b$exports = {};
214
+ $920b9baf5fdd305b$exports = {
215
+ "info": `Info`,
216
+ "negative": `Feil`,
217
+ "positive": `Vellykket`
218
+ };
219
+
220
+
221
+ var $ac88c25d97133768$exports = {};
222
+ $ac88c25d97133768$exports = {
223
+ "info": `Info`,
224
+ "negative": `Fout`,
225
+ "positive": `Geslaagd`
226
+ };
227
+
228
+
229
+ var $dea3c2ca37b0afea$exports = {};
230
+ $dea3c2ca37b0afea$exports = {
231
+ "info": `Informacje`,
232
+ "negative": `Błąd`,
233
+ "positive": `Powodzenie`
234
+ };
235
+
236
+
237
+ var $36b701dae6c5c88a$exports = {};
238
+ $36b701dae6c5c88a$exports = {
239
+ "info": `Informações`,
240
+ "negative": `Erro`,
241
+ "positive": `Sucesso`
242
+ };
243
+
244
+
245
+ var $959bf461c37c3856$exports = {};
246
+ $959bf461c37c3856$exports = {
247
+ "info": `Informação`,
248
+ "negative": `Erro`,
249
+ "positive": `Sucesso`
250
+ };
251
+
252
+
253
+ var $584332ecb6a69cb1$exports = {};
254
+ $584332ecb6a69cb1$exports = {
255
+ "info": `Informaţii`,
256
+ "negative": `Eroare`,
257
+ "positive": `Succes`
258
+ };
259
+
260
+
261
+ var $b3a312739e8cca16$exports = {};
262
+ $b3a312739e8cca16$exports = {
263
+ "info": `Информация`,
264
+ "negative": `Ошибка`,
265
+ "positive": `Успешно`
266
+ };
267
+
268
+
269
+ var $531de2843c7d5aa0$exports = {};
270
+ $531de2843c7d5aa0$exports = {
271
+ "info": `Informácie`,
272
+ "negative": `Chyba`,
273
+ "positive": `Úspech`
274
+ };
275
+
276
+
277
+ var $52846db7e4bedb0e$exports = {};
278
+ $52846db7e4bedb0e$exports = {
279
+ "info": `Informacije`,
280
+ "negative": `Napaka`,
281
+ "positive": `Uspešno`
282
+ };
283
+
284
+
285
+ var $20c8bedbc8241336$exports = {};
286
+ $20c8bedbc8241336$exports = {
287
+ "info": `Informacije`,
288
+ "negative": `Greška`,
289
+ "positive": `Uspešno`
290
+ };
291
+
292
+
293
+ var $7a9bac9c7f5066c3$exports = {};
294
+ $7a9bac9c7f5066c3$exports = {
295
+ "info": `Info`,
296
+ "negative": `Fel`,
297
+ "positive": `Lyckades`
298
+ };
299
+
300
+
301
+ var $ef512fc21e0fdf2f$exports = {};
302
+ $ef512fc21e0fdf2f$exports = {
303
+ "info": `Bilgiler`,
304
+ "negative": `Hata`,
305
+ "positive": `Başarılı`
306
+ };
307
+
308
+
309
+ var $6764c871b5447c7a$exports = {};
310
+ $6764c871b5447c7a$exports = {
311
+ "info": `Інформація`,
312
+ "negative": `Помилка`,
313
+ "positive": `Успішно`
314
+ };
315
+
316
+
317
+ var $b1634d37b87f243f$exports = {};
318
+ $b1634d37b87f243f$exports = {
319
+ "info": `信息`,
320
+ "negative": `错误`,
321
+ "positive": `成功`
322
+ };
323
+
324
+
325
+ var $19cbd4230357935e$exports = {};
326
+ $19cbd4230357935e$exports = {
327
+ "info": `資訊`,
328
+ "negative": `錯誤`,
329
+ "positive": `成功`
330
+ };
331
+
332
+
333
+ $9b92fa4e52e1872f$exports = {
334
+ "ar-AE": $4ef3586572b5c0bd$exports,
335
+ "bg-BG": $9294a3bc0be7c803$exports,
336
+ "cs-CZ": $2301cc9fa70c79b7$exports,
337
+ "da-DK": $db68d63440e07cc2$exports,
338
+ "de-DE": $59f85255004b972f$exports,
339
+ "el-GR": $897a62d7e05e3ae7$exports,
340
+ "en-US": $cd5f6f9dc2665e8f$exports,
341
+ "es-ES": $91da3b58720e2afa$exports,
342
+ "et-EE": $d881203a181403bc$exports,
343
+ "fi-FI": $b39cb8320f170f5d$exports,
344
+ "fr-FR": $3dcec82c37bb9c69$exports,
345
+ "he-IL": $70451b8bc8958a93$exports,
346
+ "hr-HR": $8192b2e4907779a9$exports,
347
+ "hu-HU": $734bda6365304ddb$exports,
348
+ "it-IT": $c985376db8169cb9$exports,
349
+ "ja-JP": $0a814f0515b1f941$exports,
350
+ "ko-KR": $87900002a59b18f5$exports,
351
+ "lt-LT": $b083aee709113368$exports,
352
+ "lv-LV": $641d21187f9a9953$exports,
353
+ "nb-NO": $920b9baf5fdd305b$exports,
354
+ "nl-NL": $ac88c25d97133768$exports,
355
+ "pl-PL": $dea3c2ca37b0afea$exports,
356
+ "pt-BR": $36b701dae6c5c88a$exports,
357
+ "pt-PT": $959bf461c37c3856$exports,
358
+ "ro-RO": $584332ecb6a69cb1$exports,
359
+ "ru-RU": $b3a312739e8cca16$exports,
360
+ "sk-SK": $531de2843c7d5aa0$exports,
361
+ "sl-SI": $52846db7e4bedb0e$exports,
362
+ "sr-SP": $20c8bedbc8241336$exports,
363
+ "sv-SE": $7a9bac9c7f5066c3$exports,
364
+ "tr-TR": $ef512fc21e0fdf2f$exports,
365
+ "uk-UA": $6764c871b5447c7a$exports,
366
+ "zh-CN": $b1634d37b87f243f$exports,
367
+ "zh-TW": $19cbd4230357935e$exports
368
+ };
369
+
370
+
371
+
372
+ var $e05a169dc2f4f928$exports = {};
373
+
374
+ $parcel$export($e05a169dc2f4f928$exports, "spectrum-Toast", () => $e05a169dc2f4f928$export$c8747d73d7954b9c, (v) => $e05a169dc2f4f928$export$c8747d73d7954b9c = v);
375
+ $parcel$export($e05a169dc2f4f928$exports, "spectrum-Toast-typeIcon", () => $e05a169dc2f4f928$export$8e9e50fe392680b2, (v) => $e05a169dc2f4f928$export$8e9e50fe392680b2 = v);
376
+ $parcel$export($e05a169dc2f4f928$exports, "spectrum-Toast-content", () => $e05a169dc2f4f928$export$454f092ca47c3462, (v) => $e05a169dc2f4f928$export$454f092ca47c3462 = v);
377
+ $parcel$export($e05a169dc2f4f928$exports, "spectrum-Toast-buttons", () => $e05a169dc2f4f928$export$19218cf016f919e5, (v) => $e05a169dc2f4f928$export$19218cf016f919e5 = v);
378
+ $parcel$export($e05a169dc2f4f928$exports, "spectrum-Button", () => $e05a169dc2f4f928$export$1db4cca5b4ade39a, (v) => $e05a169dc2f4f928$export$1db4cca5b4ade39a = v);
379
+ $parcel$export($e05a169dc2f4f928$exports, "spectrum-ClearButton", () => $e05a169dc2f4f928$export$b752ce409e5660c, (v) => $e05a169dc2f4f928$export$b752ce409e5660c = v);
380
+ $parcel$export($e05a169dc2f4f928$exports, "spectrum-Toast-body", () => $e05a169dc2f4f928$export$36e75d1f579741b3, (v) => $e05a169dc2f4f928$export$36e75d1f579741b3 = v);
381
+ $parcel$export($e05a169dc2f4f928$exports, "spectrum-Toast--negative", () => $e05a169dc2f4f928$export$bd5a0b226e8b302, (v) => $e05a169dc2f4f928$export$bd5a0b226e8b302 = v);
382
+ $parcel$export($e05a169dc2f4f928$exports, "spectrum-Toast--info", () => $e05a169dc2f4f928$export$fcf916881d7253a9, (v) => $e05a169dc2f4f928$export$fcf916881d7253a9 = v);
383
+ $parcel$export($e05a169dc2f4f928$exports, "spectrum-Toast--positive", () => $e05a169dc2f4f928$export$5c8e63d2763f4a55, (v) => $e05a169dc2f4f928$export$5c8e63d2763f4a55 = v);
384
+ var $e05a169dc2f4f928$export$c8747d73d7954b9c;
385
+ var $e05a169dc2f4f928$export$8e9e50fe392680b2;
386
+ var $e05a169dc2f4f928$export$454f092ca47c3462;
387
+ var $e05a169dc2f4f928$export$19218cf016f919e5;
388
+ var $e05a169dc2f4f928$export$1db4cca5b4ade39a;
389
+ var $e05a169dc2f4f928$export$b752ce409e5660c;
390
+ var $e05a169dc2f4f928$export$36e75d1f579741b3;
391
+ var $e05a169dc2f4f928$export$bd5a0b226e8b302;
392
+ var $e05a169dc2f4f928$export$fcf916881d7253a9;
393
+ var $e05a169dc2f4f928$export$5c8e63d2763f4a55;
394
+ $e05a169dc2f4f928$export$c8747d73d7954b9c = "spectrum-Toast_11df86";
395
+ $e05a169dc2f4f928$export$8e9e50fe392680b2 = "spectrum-Toast-typeIcon_11df86";
396
+ $e05a169dc2f4f928$export$454f092ca47c3462 = "spectrum-Toast-content_11df86";
397
+ $e05a169dc2f4f928$export$19218cf016f919e5 = "spectrum-Toast-buttons_11df86";
398
+ $e05a169dc2f4f928$export$1db4cca5b4ade39a = "spectrum-Button_11df86";
399
+ $e05a169dc2f4f928$export$b752ce409e5660c = "spectrum-ClearButton_11df86";
400
+ $e05a169dc2f4f928$export$36e75d1f579741b3 = "spectrum-Toast-body_11df86";
401
+ $e05a169dc2f4f928$export$bd5a0b226e8b302 = "spectrum-Toast--negative_11df86";
402
+ $e05a169dc2f4f928$export$fcf916881d7253a9 = "spectrum-Toast--info_11df86";
403
+ $e05a169dc2f4f928$export$5c8e63d2763f4a55 = "spectrum-Toast--positive_11df86";
404
+
405
+
406
+
407
+ var $f3b51ac952d4aeac$exports = {};
408
+
409
+ $parcel$export($f3b51ac952d4aeac$exports, "react-spectrum-ToastContainer", () => $f3b51ac952d4aeac$export$bed15bd1aa62542d, (v) => $f3b51ac952d4aeac$export$bed15bd1aa62542d = v);
410
+ $parcel$export($f3b51ac952d4aeac$exports, "focus-ring", () => $f3b51ac952d4aeac$export$f39a09f249340e2a, (v) => $f3b51ac952d4aeac$export$f39a09f249340e2a = v);
411
+ $parcel$export($f3b51ac952d4aeac$exports, "spectrum-Toast", () => $f3b51ac952d4aeac$export$c8747d73d7954b9c, (v) => $f3b51ac952d4aeac$export$c8747d73d7954b9c = v);
412
+ $parcel$export($f3b51ac952d4aeac$exports, "slide-in", () => $f3b51ac952d4aeac$export$1c220dee9e4dbe34, (v) => $f3b51ac952d4aeac$export$1c220dee9e4dbe34 = v);
413
+ $parcel$export($f3b51ac952d4aeac$exports, "fade-out", () => $f3b51ac952d4aeac$export$f562fd61c53bdcd9, (v) => $f3b51ac952d4aeac$export$f562fd61c53bdcd9 = v);
414
+ var $f3b51ac952d4aeac$export$bed15bd1aa62542d;
415
+ var $f3b51ac952d4aeac$export$f39a09f249340e2a;
416
+ var $f3b51ac952d4aeac$export$c8747d73d7954b9c;
417
+ var $f3b51ac952d4aeac$export$1c220dee9e4dbe34;
418
+ var $f3b51ac952d4aeac$export$f562fd61c53bdcd9;
419
+ $f3b51ac952d4aeac$export$bed15bd1aa62542d = "react-spectrum-ToastContainer_21a698";
420
+ $f3b51ac952d4aeac$export$f39a09f249340e2a = "focus-ring_21a698";
421
+ $f3b51ac952d4aeac$export$c8747d73d7954b9c = "spectrum-Toast_21a698";
422
+ $f3b51ac952d4aeac$export$1c220dee9e4dbe34 = "slide-in_21a698";
423
+ $f3b51ac952d4aeac$export$f562fd61c53bdcd9 = "fade-out_21a698";
424
+
425
+
426
+
427
+
428
+ const $7e7a2952509f3a56$export$fde44257752a9f60 = {
429
+ info: (0, $jn1ib$spectrumiconsuiInfoMedium),
430
+ negative: (0, $jn1ib$spectrumiconsuiAlertMedium),
431
+ positive: (0, $jn1ib$spectrumiconsuiSuccessMedium)
432
+ };
433
+ function $7e7a2952509f3a56$var$Toast(props, ref) {
434
+ let { toast: { key: key , animation: animation , content: { children: children , variant: variant , actionLabel: actionLabel , onAction: onAction , shouldCloseOnAction: shouldCloseOnAction } } , state: state , ...otherProps } = props;
435
+ let domRef = (0, $jn1ib$useDOMRef)(ref);
436
+ let { closeButtonProps: closeButtonProps , titleProps: titleProps , toastProps: toastProps } = (0, $jn1ib$useToast)(props, state, domRef);
437
+ let { styleProps: styleProps } = (0, $jn1ib$useStyleProps)(otherProps);
438
+ let stringFormatter = (0, $jn1ib$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($9b92fa4e52e1872f$exports))));
439
+ let iconLabel = variant && variant !== "neutral" ? stringFormatter.format(variant) : null;
440
+ let Icon = $7e7a2952509f3a56$export$fde44257752a9f60[variant];
441
+ const handleAction = ()=>{
442
+ if (onAction) onAction();
443
+ if (shouldCloseOnAction) state.close(key);
444
+ };
445
+ return /*#__PURE__*/ (0, $jn1ib$react).createElement("div", {
446
+ ...styleProps,
447
+ ...toastProps,
448
+ ref: domRef,
449
+ className: (0, $jn1ib$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($e05a169dc2f4f928$exports))), "spectrum-Toast", {
450
+ ["spectrum-Toast--" + variant]: variant
451
+ }, styleProps.className, (0, $jn1ib$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($f3b51ac952d4aeac$exports))), "spectrum-Toast")),
452
+ style: {
453
+ ...styleProps.style,
454
+ zIndex: props.toast.priority
455
+ },
456
+ "data-animation": animation,
457
+ onAnimationEnd: ()=>{
458
+ if (animation === "exiting") state.remove(key);
459
+ }
460
+ }, Icon && /*#__PURE__*/ (0, $jn1ib$react).createElement(Icon, {
461
+ "aria-label": iconLabel,
462
+ UNSAFE_className: (0, $jn1ib$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($e05a169dc2f4f928$exports))), "spectrum-Toast-typeIcon")
463
+ }), /*#__PURE__*/ (0, $jn1ib$react).createElement("div", {
464
+ className: (0, $jn1ib$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($e05a169dc2f4f928$exports))), "spectrum-Toast-body")
465
+ }, /*#__PURE__*/ (0, $jn1ib$react).createElement("div", {
466
+ className: (0, $jn1ib$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($e05a169dc2f4f928$exports))), "spectrum-Toast-content"),
467
+ ...titleProps
468
+ }, children), actionLabel && /*#__PURE__*/ (0, $jn1ib$react).createElement((0, $jn1ib$Button), {
469
+ onPress: handleAction,
470
+ UNSAFE_className: (0, $jn1ib$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($e05a169dc2f4f928$exports))), "spectrum-Button"),
471
+ variant: "secondary",
472
+ staticColor: "white"
473
+ }, actionLabel)), /*#__PURE__*/ (0, $jn1ib$react).createElement("div", {
474
+ className: (0, $jn1ib$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($e05a169dc2f4f928$exports))), "spectrum-Toast-buttons")
475
+ }, /*#__PURE__*/ (0, $jn1ib$react).createElement((0, $jn1ib$ClearButton), {
476
+ ...closeButtonProps,
477
+ variant: "overBackground"
478
+ }, /*#__PURE__*/ (0, $jn1ib$react).createElement((0, $jn1ib$spectrumiconsuiCrossMedium), null))));
479
+ }
480
+ let $7e7a2952509f3a56$export$8d8dc7d5f743331b = /*#__PURE__*/ (0, $jn1ib$react).forwardRef($7e7a2952509f3a56$var$Toast);
481
+
482
+
483
+ /*
484
+ * Copyright 2020 Adobe. All rights reserved.
485
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
486
+ * you may not use this file except in compliance with the License. You may obtain a copy
487
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
488
+ *
489
+ * Unless required by applicable law or agreed to in writing, software distributed under
490
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
491
+ * OF ANY KIND, either express or implied. See the License for the specific language
492
+ * governing permissions and limitations under the License.
493
+ */
494
+
495
+
496
+
497
+
498
+
499
+
500
+ function $e46feef4e4c28a4b$export$fb98e3a2a4cd92d7(props) {
501
+ let { children: children , state: state } = props;
502
+ let containerPlacement = (0, $jn1ib$useIsMobileDevice)() ? "center" : "right";
503
+ let ref = (0, $jn1ib$useRef)();
504
+ let { regionProps: regionProps } = (0, $jn1ib$useToastRegion)(props, state, ref);
505
+ let contents = /*#__PURE__*/ (0, $jn1ib$react).createElement((0, $jn1ib$Provider), {
506
+ UNSAFE_style: {
507
+ background: "transparent"
508
+ }
509
+ }, /*#__PURE__*/ (0, $jn1ib$react).createElement((0, $jn1ib$FocusRing), {
510
+ focusRingClass: (0, $jn1ib$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($f3b51ac952d4aeac$exports))), "focus-ring")
511
+ }, /*#__PURE__*/ (0, $jn1ib$react).createElement("div", {
512
+ ...regionProps,
513
+ ref: ref,
514
+ "data-position": "bottom",
515
+ "data-placement": containerPlacement,
516
+ className: (0, $jn1ib$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($f3b51ac952d4aeac$exports))), "react-spectrum-ToastContainer")
517
+ }, children)));
518
+ return /*#__PURE__*/ (0, $jn1ib$reactdom).createPortal(contents, document.body);
519
+ }
520
+
521
+
522
+
523
+
524
+ // There is a single global toast queue instance for the whole app, initialized lazily.
525
+ let $02c59b34bd70955a$var$globalToastQueue = null;
526
+ function $02c59b34bd70955a$var$getGlobalToastQueue() {
527
+ if (!$02c59b34bd70955a$var$globalToastQueue) $02c59b34bd70955a$var$globalToastQueue = new (0, $jn1ib$ToastQueue)({
528
+ maxVisibleToasts: 1,
529
+ hasExitAnimation: true
530
+ });
531
+ return $02c59b34bd70955a$var$globalToastQueue;
532
+ }
533
+ function $02c59b34bd70955a$export$320311f0e4ecb3ae() {
534
+ $02c59b34bd70955a$var$globalToastQueue = null;
535
+ }
536
+ let $02c59b34bd70955a$var$toastProviders = new Set();
537
+ let $02c59b34bd70955a$var$subscriptions = new Set();
538
+ function $02c59b34bd70955a$var$subscribe(fn) {
539
+ $02c59b34bd70955a$var$subscriptions.add(fn);
540
+ return ()=>$02c59b34bd70955a$var$subscriptions.delete(fn);
541
+ }
542
+ function $02c59b34bd70955a$var$getActiveToastContainer() {
543
+ return $02c59b34bd70955a$var$toastProviders.values().next().value;
544
+ }
545
+ function $02c59b34bd70955a$var$useActiveToastContainer() {
546
+ return (0, $jn1ib$useSyncExternalStore)($02c59b34bd70955a$var$subscribe, $02c59b34bd70955a$var$getActiveToastContainer);
547
+ }
548
+ function $02c59b34bd70955a$export$f2815235e76a62b9(props) {
549
+ // Track all toast provider instances in a set.
550
+ // Only the first one will actually render.
551
+ // We use a ref to do this, since it will have a stable identity
552
+ // over the lifetime of the component.
553
+ let ref = (0, $jn1ib$useRef)();
554
+ $02c59b34bd70955a$var$toastProviders.add(ref);
555
+ // eslint-disable-next-line arrow-body-style
556
+ (0, $jn1ib$useEffect)(()=>{
557
+ return ()=>{
558
+ // When this toast provider unmounts, reset all animations so that
559
+ // when the new toast provider renders, it is seamless.
560
+ for (let toast of $02c59b34bd70955a$var$getGlobalToastQueue().visibleToasts)toast.animation = null;
561
+ // Remove this toast provider, and call subscriptions.
562
+ // This will cause all other instances to re-render,
563
+ // and the first one to become the new active toast provider.
564
+ $02c59b34bd70955a$var$toastProviders.delete(ref);
565
+ for (let fn of $02c59b34bd70955a$var$subscriptions)fn();
566
+ };
567
+ }, []);
568
+ // Only render if this is the active toast provider instance, and there are visible toasts.
569
+ let activeToastContainer = $02c59b34bd70955a$var$useActiveToastContainer();
570
+ let state = (0, $jn1ib$useToastQueue)($02c59b34bd70955a$var$getGlobalToastQueue());
571
+ if (ref === activeToastContainer && state.visibleToasts.length > 0) return /*#__PURE__*/ (0, $jn1ib$react).createElement((0, $e46feef4e4c28a4b$export$fb98e3a2a4cd92d7), {
572
+ state: state,
573
+ ...props
574
+ }, state.visibleToasts.map((toast)=>/*#__PURE__*/ (0, $jn1ib$react).createElement((0, $7e7a2952509f3a56$export$8d8dc7d5f743331b), {
575
+ key: toast.key,
576
+ toast: toast,
577
+ state: state
578
+ })));
579
+ return null;
580
+ }
581
+ function $02c59b34bd70955a$var$addToast(children, variant, options = {}) {
582
+ // Dispatch a custom event so that toasts can be intercepted and re-targeted, e.g. when inside an iframe.
583
+ if (typeof CustomEvent !== "undefined" && typeof window !== "undefined") {
584
+ let event = new CustomEvent("react-spectrum-toast", {
585
+ cancelable: true,
586
+ bubbles: true,
587
+ detail: {
588
+ children: children,
589
+ variant: variant,
590
+ options: options
591
+ }
592
+ });
593
+ let shouldContinue = window.dispatchEvent(event);
594
+ if (!shouldContinue) return;
595
+ }
596
+ let value = {
597
+ children: children,
598
+ variant: variant,
599
+ actionLabel: options.actionLabel,
600
+ onAction: options.onAction,
601
+ shouldCloseOnAction: options.shouldCloseOnAction
602
+ };
603
+ // Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible
604
+ // Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.
605
+ // It is debatable whether non-actionable toasts would also fail.
606
+ let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : null;
607
+ let queue = $02c59b34bd70955a$var$getGlobalToastQueue();
608
+ let key = queue.add(value, {
609
+ priority: $02c59b34bd70955a$var$getPriority(variant, options),
610
+ timeout: timeout,
611
+ onClose: options.onClose
612
+ });
613
+ return ()=>queue.close(key);
614
+ }
615
+ const $02c59b34bd70955a$export$f1f8569633bbbec4 = {
616
+ /** Queues a neutral toast. */ neutral (children, options = {}) {
617
+ return $02c59b34bd70955a$var$addToast(children, "neutral", options);
618
+ },
619
+ /** Queues a positive toast. */ positive (children, options = {}) {
620
+ return $02c59b34bd70955a$var$addToast(children, "positive", options);
621
+ },
622
+ /** Queues a negative toast. */ negative (children, options = {}) {
623
+ return $02c59b34bd70955a$var$addToast(children, "negative", options);
624
+ },
625
+ /** Queues an informational toast. */ info (children, options = {}) {
626
+ return $02c59b34bd70955a$var$addToast(children, "info", options);
627
+ }
628
+ };
629
+ // https://spectrum.adobe.com/page/toast/#Priority-queue
630
+ // TODO: if a lower priority toast comes in, no way to know until you dismiss the higher priority one.
631
+ const $02c59b34bd70955a$var$VARIANT_PRIORITY = {
632
+ negative: 10,
633
+ positive: 3,
634
+ info: 2,
635
+ neutral: 1
636
+ };
637
+ function $02c59b34bd70955a$var$getPriority(variant, options) {
638
+ let priority = $02c59b34bd70955a$var$VARIANT_PRIORITY[variant] || 1;
639
+ if (options.onAction) priority += 4;
640
+ return priority;
641
+ }
642
+
643
+
644
+
645
+
646
+ export {$02c59b34bd70955a$export$f2815235e76a62b9 as ToastContainer, $02c59b34bd70955a$export$f1f8569633bbbec4 as ToastQueue};
647
+ //# sourceMappingURL=module.js.map
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-spectrum/toast",
3
- "version": "3.0.0-nightly.1996+be0fae9f7",
3
+ "version": "3.0.0-nightly.2005+93b3c951e",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -31,20 +36,20 @@
31
36
  "url": "https://github.com/adobe/react-spectrum"
32
37
  },
33
38
  "dependencies": {
34
- "@react-aria/focus": "3.0.0-nightly.1996+be0fae9f7",
35
- "@react-aria/i18n": "3.0.0-nightly.1996+be0fae9f7",
36
- "@react-aria/toast": "3.0.0-nightly.1996+be0fae9f7",
37
- "@react-spectrum/button": "3.0.0-nightly.1996+be0fae9f7",
38
- "@react-spectrum/utils": "3.0.0-nightly.1996+be0fae9f7",
39
- "@react-stately/toast": "3.0.0-nightly.3696+be0fae9f7",
40
- "@react-types/shared": "3.0.0-nightly.1996+be0fae9f7",
41
- "@spectrum-icons/ui": "3.0.0-nightly.1996+be0fae9f7",
39
+ "@react-aria/focus": "3.0.0-nightly.2005+93b3c951e",
40
+ "@react-aria/i18n": "3.0.0-nightly.2005+93b3c951e",
41
+ "@react-aria/toast": "3.0.0-nightly.2005+93b3c951e",
42
+ "@react-spectrum/button": "3.0.0-nightly.2005+93b3c951e",
43
+ "@react-spectrum/utils": "3.0.0-nightly.2005+93b3c951e",
44
+ "@react-stately/toast": "3.0.0-nightly.3705+93b3c951e",
45
+ "@react-types/shared": "3.0.0-nightly.2005+93b3c951e",
46
+ "@spectrum-icons/ui": "3.0.0-nightly.2005+93b3c951e",
42
47
  "@swc/helpers": "^0.4.14",
43
48
  "use-sync-external-store": "^1.2.0"
44
49
  },
45
50
  "devDependencies": {
46
- "@adobe/spectrum-css-temp": "3.0.0-nightly.1996+be0fae9f7",
47
- "@react-spectrum/test-utils": "3.0.0-nightly.1996+be0fae9f7",
51
+ "@adobe/spectrum-css-temp": "3.0.0-nightly.2005+93b3c951e",
52
+ "@react-spectrum/test-utils": "3.0.0-nightly.2005+93b3c951e",
48
53
  "@types/use-sync-external-store": "^0.0.3"
49
54
  },
50
55
  "peerDependencies": {
@@ -55,5 +60,5 @@
55
60
  "publishConfig": {
56
61
  "access": "public"
57
62
  },
58
- "gitHead": "be0fae9f7952f4d09823498dc1f251e13842f338"
63
+ "gitHead": "93b3c951eb784b14183f9988f2d188b34de8f42d"
59
64
  }