@react-aria/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 +430 -0
  2. package/package.json +14 -9
@@ -0,0 +1,430 @@
1
+ import {useEffect as $5bA4N$useEffect, useRef as $5bA4N$useRef} from "react";
2
+ import {useLayoutEffect as $5bA4N$useLayoutEffect, useId as $5bA4N$useId, useSlotId as $5bA4N$useSlotId, focusWithoutScrolling as $5bA4N$focusWithoutScrolling, mergeProps as $5bA4N$mergeProps} from "@react-aria/utils";
3
+ import {useLocalizedStringFormatter as $5bA4N$useLocalizedStringFormatter} from "@react-aria/i18n";
4
+ import {useHover as $5bA4N$useHover, useFocusWithin as $5bA4N$useFocusWithin, getInteractionModality as $5bA4N$getInteractionModality} from "@react-aria/interactions";
5
+ import {useLandmark as $5bA4N$useLandmark} from "@react-aria/landmark";
6
+
7
+ function $parcel$interopDefault(a) {
8
+ return a && a.__esModule ? a.default : a;
9
+ }
10
+ /*
11
+ * Copyright 2020 Adobe. All rights reserved.
12
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License. You may obtain a copy
14
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software distributed under
17
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
+ * OF ANY KIND, either express or implied. See the License for the specific language
19
+ * governing permissions and limitations under the License.
20
+ */ /*
21
+ * Copyright 2020 Adobe. All rights reserved.
22
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
23
+ * you may not use this file except in compliance with the License. You may obtain a copy
24
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software distributed under
27
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
28
+ * OF ANY KIND, either express or implied. See the License for the specific language
29
+ * governing permissions and limitations under the License.
30
+ */ var $ebf9e0ddd819695a$exports = {};
31
+ var $ff9177efc58547ad$exports = {};
32
+ $ff9177efc58547ad$exports = {
33
+ "close": `إغلاق`,
34
+ "notifications": `إشعارات`
35
+ };
36
+
37
+
38
+ var $25eb7c0c0c45e544$exports = {};
39
+ $25eb7c0c0c45e544$exports = {
40
+ "close": `Затвори`,
41
+ "notifications": `Известия`
42
+ };
43
+
44
+
45
+ var $28feffc3d61a8691$exports = {};
46
+ $28feffc3d61a8691$exports = {
47
+ "close": `Zavřít`,
48
+ "notifications": `Upozornění`
49
+ };
50
+
51
+
52
+ var $390d441203d25ff4$exports = {};
53
+ $390d441203d25ff4$exports = {
54
+ "close": `Luk`,
55
+ "notifications": `Påmindelser`
56
+ };
57
+
58
+
59
+ var $7063c2d0f14f979a$exports = {};
60
+ $7063c2d0f14f979a$exports = {
61
+ "close": `Schließen`,
62
+ "notifications": `Benachrichtigungen`
63
+ };
64
+
65
+
66
+ var $2dfc1dbb6590af88$exports = {};
67
+ $2dfc1dbb6590af88$exports = {
68
+ "close": `Κλείσιμο`,
69
+ "notifications": `Ειδοποιήσεις`
70
+ };
71
+
72
+
73
+ var $9a12ff1caae5a7a5$exports = {};
74
+ $9a12ff1caae5a7a5$exports = {
75
+ "close": `Close`,
76
+ "notifications": `Notifications`
77
+ };
78
+
79
+
80
+ var $f4095fb5a72adbe6$exports = {};
81
+ $f4095fb5a72adbe6$exports = {
82
+ "close": `Cerrar`,
83
+ "notifications": `Notificaciones`
84
+ };
85
+
86
+
87
+ var $75bc5191b9d7826a$exports = {};
88
+ $75bc5191b9d7826a$exports = {
89
+ "close": `Sule`,
90
+ "notifications": `Teated`
91
+ };
92
+
93
+
94
+ var $e4b9aef18b0db8dc$exports = {};
95
+ $e4b9aef18b0db8dc$exports = {
96
+ "close": `Sulje`,
97
+ "notifications": `Ilmoitukset`
98
+ };
99
+
100
+
101
+ var $888756784d832bd7$exports = {};
102
+ $888756784d832bd7$exports = {
103
+ "close": `Fermer`,
104
+ "notifications": `Notifications`
105
+ };
106
+
107
+
108
+ var $6835949b68a1fabf$exports = {};
109
+ $6835949b68a1fabf$exports = {
110
+ "close": `סגור`,
111
+ "notifications": `התראות`
112
+ };
113
+
114
+
115
+ var $87ffcbc0b651e40b$exports = {};
116
+ $87ffcbc0b651e40b$exports = {
117
+ "close": `Zatvori`,
118
+ "notifications": `Obavijesti`
119
+ };
120
+
121
+
122
+ var $dc6e3b2813600d69$exports = {};
123
+ $dc6e3b2813600d69$exports = {
124
+ "close": `Bezárás`,
125
+ "notifications": `Értesítések`
126
+ };
127
+
128
+
129
+ var $fe136bcbacfcfa14$exports = {};
130
+ $fe136bcbacfcfa14$exports = {
131
+ "close": `Chiudi`,
132
+ "notifications": `Notifiche`
133
+ };
134
+
135
+
136
+ var $8fb53a929b46df83$exports = {};
137
+ $8fb53a929b46df83$exports = {
138
+ "close": `閉じる`,
139
+ "notifications": `通知`
140
+ };
141
+
142
+
143
+ var $2c38dbfaf041a865$exports = {};
144
+ $2c38dbfaf041a865$exports = {
145
+ "close": `닫기`,
146
+ "notifications": `알림`
147
+ };
148
+
149
+
150
+ var $48f3f33a29908d4c$exports = {};
151
+ $48f3f33a29908d4c$exports = {
152
+ "close": `Uždaryti`,
153
+ "notifications": `Pranešimai`
154
+ };
155
+
156
+
157
+ var $9867160d996455a0$exports = {};
158
+ $9867160d996455a0$exports = {
159
+ "close": `Aizvērt`,
160
+ "notifications": `Paziņojumi`
161
+ };
162
+
163
+
164
+ var $196258ea25c96487$exports = {};
165
+ $196258ea25c96487$exports = {
166
+ "close": `Lukk`,
167
+ "notifications": `Varsler`
168
+ };
169
+
170
+
171
+ var $949061cb954e8000$exports = {};
172
+ $949061cb954e8000$exports = {
173
+ "close": `Sluiten`,
174
+ "notifications": `Meldingen`
175
+ };
176
+
177
+
178
+ var $8189bed27add1ad3$exports = {};
179
+ $8189bed27add1ad3$exports = {
180
+ "close": `Zamknij`,
181
+ "notifications": `Powiadomienia`
182
+ };
183
+
184
+
185
+ var $a361756a93b6e28c$exports = {};
186
+ $a361756a93b6e28c$exports = {
187
+ "close": `Fechar`,
188
+ "notifications": `Notificações`
189
+ };
190
+
191
+
192
+ var $034c7393857c8db0$exports = {};
193
+ $034c7393857c8db0$exports = {
194
+ "close": `Fechar`,
195
+ "notifications": `Notificações`
196
+ };
197
+
198
+
199
+ var $e33d3b3868478b04$exports = {};
200
+ $e33d3b3868478b04$exports = {
201
+ "close": `Închideţi`,
202
+ "notifications": `Notificări`
203
+ };
204
+
205
+
206
+ var $9a7dcb914b29cd9f$exports = {};
207
+ $9a7dcb914b29cd9f$exports = {
208
+ "close": `Закрыть`,
209
+ "notifications": `Уведомления`
210
+ };
211
+
212
+
213
+ var $e43d964a0c7f1266$exports = {};
214
+ $e43d964a0c7f1266$exports = {
215
+ "close": `Zatvoriť`,
216
+ "notifications": `Oznámenia`
217
+ };
218
+
219
+
220
+ var $0bc56cee3275bcaa$exports = {};
221
+ $0bc56cee3275bcaa$exports = {
222
+ "close": `Zapri`,
223
+ "notifications": `Obvestila`
224
+ };
225
+
226
+
227
+ var $7dbdd7289c10d2ba$exports = {};
228
+ $7dbdd7289c10d2ba$exports = {
229
+ "close": `Zatvori`,
230
+ "notifications": `Obaveštenja`
231
+ };
232
+
233
+
234
+ var $ccbe6066c10b1e53$exports = {};
235
+ $ccbe6066c10b1e53$exports = {
236
+ "close": `Stäng`,
237
+ "notifications": `Aviseringar`
238
+ };
239
+
240
+
241
+ var $9d503476b9d858b7$exports = {};
242
+ $9d503476b9d858b7$exports = {
243
+ "close": `Kapat`,
244
+ "notifications": `Bildirimler`
245
+ };
246
+
247
+
248
+ var $32ee419c7b9b7a83$exports = {};
249
+ $32ee419c7b9b7a83$exports = {
250
+ "close": `Закрити`,
251
+ "notifications": `Сповіщення`
252
+ };
253
+
254
+
255
+ var $122525af1cb737c7$exports = {};
256
+ $122525af1cb737c7$exports = {
257
+ "close": `关闭`,
258
+ "notifications": `通知`
259
+ };
260
+
261
+
262
+ var $52e8b1b00094e5a3$exports = {};
263
+ $52e8b1b00094e5a3$exports = {
264
+ "close": `關閉`,
265
+ "notifications": `通知`
266
+ };
267
+
268
+
269
+ $ebf9e0ddd819695a$exports = {
270
+ "ar-AE": $ff9177efc58547ad$exports,
271
+ "bg-BG": $25eb7c0c0c45e544$exports,
272
+ "cs-CZ": $28feffc3d61a8691$exports,
273
+ "da-DK": $390d441203d25ff4$exports,
274
+ "de-DE": $7063c2d0f14f979a$exports,
275
+ "el-GR": $2dfc1dbb6590af88$exports,
276
+ "en-US": $9a12ff1caae5a7a5$exports,
277
+ "es-ES": $f4095fb5a72adbe6$exports,
278
+ "et-EE": $75bc5191b9d7826a$exports,
279
+ "fi-FI": $e4b9aef18b0db8dc$exports,
280
+ "fr-FR": $888756784d832bd7$exports,
281
+ "he-IL": $6835949b68a1fabf$exports,
282
+ "hr-HR": $87ffcbc0b651e40b$exports,
283
+ "hu-HU": $dc6e3b2813600d69$exports,
284
+ "it-IT": $fe136bcbacfcfa14$exports,
285
+ "ja-JP": $8fb53a929b46df83$exports,
286
+ "ko-KR": $2c38dbfaf041a865$exports,
287
+ "lt-LT": $48f3f33a29908d4c$exports,
288
+ "lv-LV": $9867160d996455a0$exports,
289
+ "nb-NO": $196258ea25c96487$exports,
290
+ "nl-NL": $949061cb954e8000$exports,
291
+ "pl-PL": $8189bed27add1ad3$exports,
292
+ "pt-BR": $a361756a93b6e28c$exports,
293
+ "pt-PT": $034c7393857c8db0$exports,
294
+ "ro-RO": $e33d3b3868478b04$exports,
295
+ "ru-RU": $9a7dcb914b29cd9f$exports,
296
+ "sk-SK": $e43d964a0c7f1266$exports,
297
+ "sl-SI": $0bc56cee3275bcaa$exports,
298
+ "sr-SP": $7dbdd7289c10d2ba$exports,
299
+ "sv-SE": $ccbe6066c10b1e53$exports,
300
+ "tr-TR": $9d503476b9d858b7$exports,
301
+ "uk-UA": $32ee419c7b9b7a83$exports,
302
+ "zh-CN": $122525af1cb737c7$exports,
303
+ "zh-TW": $52e8b1b00094e5a3$exports
304
+ };
305
+
306
+
307
+
308
+
309
+
310
+ function $d6542812f0669241$export$a407b657d3044108(props, state, ref) {
311
+ let { key: key , timer: timer , timeout: timeout , animation: animation } = props.toast;
312
+ (0, $5bA4N$useEffect)(()=>{
313
+ if (!timer) return;
314
+ timer.reset(timeout);
315
+ return ()=>{
316
+ timer.pause();
317
+ };
318
+ }, [
319
+ timer,
320
+ timeout
321
+ ]);
322
+ // Restore focus to the toast container on unmount.
323
+ // If there are no more toasts, the container will be unmounted
324
+ // and will restore focus to wherever focus was before the user
325
+ // focused the toast region.
326
+ let focusOnUnmount = (0, $5bA4N$useRef)(null);
327
+ (0, $5bA4N$useLayoutEffect)(()=>{
328
+ let container = ref.current.closest("[role=region]");
329
+ return ()=>{
330
+ if (container && container.contains(document.activeElement)) // Focus must be delayed for focus ring to appear, but we can't wait
331
+ // until useEffect cleanup to check if focus was inside the container.
332
+ focusOnUnmount.current = container;
333
+ };
334
+ }, [
335
+ ref
336
+ ]);
337
+ // eslint-disable-next-line
338
+ (0, $5bA4N$useEffect)(()=>{
339
+ return ()=>{
340
+ if (focusOnUnmount.current) focusOnUnmount.current.focus();
341
+ };
342
+ }, [
343
+ ref
344
+ ]);
345
+ let titleId = (0, $5bA4N$useId)();
346
+ let descriptionId = (0, $5bA4N$useSlotId)();
347
+ let stringFormatter = (0, $5bA4N$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($ebf9e0ddd819695a$exports))));
348
+ return {
349
+ toastProps: {
350
+ role: "alert",
351
+ "aria-label": props["aria-label"],
352
+ "aria-labelledby": props["aria-labelledby"] || titleId,
353
+ "aria-describedby": props["aria-describedby"] || descriptionId,
354
+ "aria-details": props["aria-details"],
355
+ // Hide toasts that are animating out so VoiceOver doesn't announce them.
356
+ "aria-hidden": animation === "exiting" ? "true" : undefined
357
+ },
358
+ titleProps: {
359
+ id: titleId
360
+ },
361
+ descriptionProps: {
362
+ id: descriptionId
363
+ },
364
+ closeButtonProps: {
365
+ "aria-label": stringFormatter.format("close"),
366
+ onPress: ()=>state.close(key)
367
+ }
368
+ };
369
+ }
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+ function $6cc546b19ee7130a$export$b8cbbb20a51697de(props, state, ref) {
379
+ let stringFormatter = (0, $5bA4N$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($ebf9e0ddd819695a$exports))));
380
+ let { landmarkProps: landmarkProps } = (0, $5bA4N$useLandmark)({
381
+ role: "region",
382
+ "aria-label": props["aria-label"] || stringFormatter.format("notifications")
383
+ }, ref);
384
+ let { hoverProps: hoverProps } = (0, $5bA4N$useHover)({
385
+ onHoverStart: state.pauseAll,
386
+ onHoverEnd: state.resumeAll
387
+ });
388
+ let lastFocused = (0, $5bA4N$useRef)(null);
389
+ let { focusWithinProps: focusWithinProps } = (0, $5bA4N$useFocusWithin)({
390
+ onFocusWithin: (e)=>{
391
+ state.pauseAll();
392
+ lastFocused.current = e.relatedTarget;
393
+ },
394
+ onBlurWithin: ()=>{
395
+ state.resumeAll();
396
+ lastFocused.current = null;
397
+ }
398
+ });
399
+ // When the region unmounts, restore focus to the last element that had focus
400
+ // before the user moved focus into the region.
401
+ // TODO: handle when the element has unmounted like FocusScope does?
402
+ // eslint-disable-next-line arrow-body-style
403
+ (0, $5bA4N$useEffect)(()=>{
404
+ return ()=>{
405
+ if (lastFocused.current && document.body.contains(lastFocused.current)) {
406
+ if ((0, $5bA4N$getInteractionModality)() === "pointer") (0, $5bA4N$focusWithoutScrolling)(lastFocused.current);
407
+ else lastFocused.current.focus();
408
+ }
409
+ };
410
+ }, [
411
+ ref
412
+ ]);
413
+ return {
414
+ regionProps: (0, $5bA4N$mergeProps)(landmarkProps, hoverProps, focusWithinProps, {
415
+ tabIndex: -1,
416
+ // Mark the toast region as a "top layer", so that it:
417
+ // - is not aria-hidden when opening an overlay
418
+ // - allows focus even outside a containing focus scope
419
+ // - doesn’t dismiss overlays when clicking on it, even though it is outside
420
+ // @ts-ignore
421
+ "data-react-aria-top-layer": true
422
+ })
423
+ };
424
+ }
425
+
426
+
427
+
428
+
429
+ export {$d6542812f0669241$export$a407b657d3044108 as useToast, $6cc546b19ee7130a$export$b8cbbb20a51697de as useToastRegion};
430
+ //# sourceMappingURL=module.js.map
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/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": [
@@ -17,13 +22,13 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@react-aria/i18n": "3.0.0-nightly.1996+be0fae9f7",
21
- "@react-aria/interactions": "3.0.0-nightly.1996+be0fae9f7",
22
- "@react-aria/landmark": "3.0.0-nightly.3696+be0fae9f7",
23
- "@react-aria/utils": "3.0.0-nightly.1996+be0fae9f7",
24
- "@react-stately/toast": "3.0.0-nightly.3696+be0fae9f7",
25
- "@react-types/button": "3.7.1-nightly.3696+be0fae9f7",
26
- "@react-types/shared": "3.0.0-nightly.1996+be0fae9f7",
25
+ "@react-aria/i18n": "3.0.0-nightly.2005+93b3c951e",
26
+ "@react-aria/interactions": "3.0.0-nightly.2005+93b3c951e",
27
+ "@react-aria/landmark": "3.0.0-nightly.3705+93b3c951e",
28
+ "@react-aria/utils": "3.0.0-nightly.2005+93b3c951e",
29
+ "@react-stately/toast": "3.0.0-nightly.3705+93b3c951e",
30
+ "@react-types/button": "3.7.1-nightly.3705+93b3c951e",
31
+ "@react-types/shared": "3.0.0-nightly.2005+93b3c951e",
27
32
  "@swc/helpers": "^0.4.14"
28
33
  },
29
34
  "peerDependencies": {
@@ -32,5 +37,5 @@
32
37
  "publishConfig": {
33
38
  "access": "public"
34
39
  },
35
- "gitHead": "be0fae9f7952f4d09823498dc1f251e13842f338"
40
+ "gitHead": "93b3c951eb784b14183f9988f2d188b34de8f42d"
36
41
  }