@react-aria/toast 3.0.0-beta.10 → 3.0.0-beta.11

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 (55) hide show
  1. package/dist/ar-AE.mjs +1 -1
  2. package/dist/bg-BG.mjs +1 -1
  3. package/dist/cs-CZ.mjs +1 -1
  4. package/dist/da-DK.mjs +1 -1
  5. package/dist/de-DE.mjs +1 -1
  6. package/dist/el-GR.mjs +1 -1
  7. package/dist/en-US.mjs +1 -1
  8. package/dist/es-ES.mjs +1 -1
  9. package/dist/et-EE.mjs +1 -1
  10. package/dist/fi-FI.mjs +1 -1
  11. package/dist/fr-FR.mjs +1 -1
  12. package/dist/he-IL.mjs +1 -1
  13. package/dist/hr-HR.mjs +1 -1
  14. package/dist/hu-HU.mjs +1 -1
  15. package/dist/import.mjs +3 -245
  16. package/dist/intlStrings.main.js +108 -0
  17. package/dist/intlStrings.main.js.map +1 -0
  18. package/dist/intlStrings.mjs +110 -0
  19. package/dist/intlStrings.module.js +110 -0
  20. package/dist/intlStrings.module.js.map +1 -0
  21. package/dist/it-IT.mjs +1 -1
  22. package/dist/ja-JP.mjs +1 -1
  23. package/dist/ko-KR.mjs +1 -1
  24. package/dist/lt-LT.mjs +1 -1
  25. package/dist/lv-LV.mjs +1 -1
  26. package/dist/main.js +5 -247
  27. package/dist/main.js.map +1 -1
  28. package/dist/module.js +3 -245
  29. package/dist/module.js.map +1 -1
  30. package/dist/nb-NO.mjs +1 -1
  31. package/dist/nl-NL.mjs +1 -1
  32. package/dist/pl-PL.mjs +1 -1
  33. package/dist/pt-BR.mjs +1 -1
  34. package/dist/pt-PT.mjs +1 -1
  35. package/dist/ro-RO.mjs +1 -1
  36. package/dist/ru-RU.mjs +1 -1
  37. package/dist/sk-SK.mjs +1 -1
  38. package/dist/sl-SI.mjs +1 -1
  39. package/dist/sr-SP.mjs +1 -1
  40. package/dist/sv-SE.mjs +1 -1
  41. package/dist/tr-TR.mjs +1 -1
  42. package/dist/uk-UA.mjs +1 -1
  43. package/dist/useToast.main.js +92 -0
  44. package/dist/useToast.main.js.map +1 -0
  45. package/dist/useToast.mjs +87 -0
  46. package/dist/useToast.module.js +87 -0
  47. package/dist/useToast.module.js.map +1 -0
  48. package/dist/useToastRegion.main.js +73 -0
  49. package/dist/useToastRegion.main.js.map +1 -0
  50. package/dist/useToastRegion.mjs +68 -0
  51. package/dist/useToastRegion.module.js +68 -0
  52. package/dist/useToastRegion.module.js.map +1 -0
  53. package/dist/zh-CN.mjs +1 -1
  54. package/dist/zh-TW.mjs +1 -1
  55. package/package.json +9 -9
package/dist/module.js CHANGED
@@ -1,47 +1,6 @@
1
- import $ff9177efc58547ad$exports from "./ar-AE.module.js";
2
- import $25eb7c0c0c45e544$exports from "./bg-BG.module.js";
3
- import $28feffc3d61a8691$exports from "./cs-CZ.module.js";
4
- import $390d441203d25ff4$exports from "./da-DK.module.js";
5
- import $7063c2d0f14f979a$exports from "./de-DE.module.js";
6
- import $2dfc1dbb6590af88$exports from "./el-GR.module.js";
7
- import $9a12ff1caae5a7a5$exports from "./en-US.module.js";
8
- import $f4095fb5a72adbe6$exports from "./es-ES.module.js";
9
- import $75bc5191b9d7826a$exports from "./et-EE.module.js";
10
- import $e4b9aef18b0db8dc$exports from "./fi-FI.module.js";
11
- import $888756784d832bd7$exports from "./fr-FR.module.js";
12
- import $6835949b68a1fabf$exports from "./he-IL.module.js";
13
- import $87ffcbc0b651e40b$exports from "./hr-HR.module.js";
14
- import $dc6e3b2813600d69$exports from "./hu-HU.module.js";
15
- import $fe136bcbacfcfa14$exports from "./it-IT.module.js";
16
- import $8fb53a929b46df83$exports from "./ja-JP.module.js";
17
- import $2c38dbfaf041a865$exports from "./ko-KR.module.js";
18
- import $48f3f33a29908d4c$exports from "./lt-LT.module.js";
19
- import $9867160d996455a0$exports from "./lv-LV.module.js";
20
- import $196258ea25c96487$exports from "./nb-NO.module.js";
21
- import $949061cb954e8000$exports from "./nl-NL.module.js";
22
- import $8189bed27add1ad3$exports from "./pl-PL.module.js";
23
- import $a361756a93b6e28c$exports from "./pt-BR.module.js";
24
- import $034c7393857c8db0$exports from "./pt-PT.module.js";
25
- import $e33d3b3868478b04$exports from "./ro-RO.module.js";
26
- import $9a7dcb914b29cd9f$exports from "./ru-RU.module.js";
27
- import $e43d964a0c7f1266$exports from "./sk-SK.module.js";
28
- import $0bc56cee3275bcaa$exports from "./sl-SI.module.js";
29
- import $7dbdd7289c10d2ba$exports from "./sr-SP.module.js";
30
- import $ccbe6066c10b1e53$exports from "./sv-SE.module.js";
31
- import $9d503476b9d858b7$exports from "./tr-TR.module.js";
32
- import $32ee419c7b9b7a83$exports from "./uk-UA.module.js";
33
- import $122525af1cb737c7$exports from "./zh-CN.module.js";
34
- import $52e8b1b00094e5a3$exports from "./zh-TW.module.js";
35
- import {useEffect as $5bA4N$useEffect, useRef as $5bA4N$useRef} from "react";
36
- 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";
37
- import {useLocalizedStringFormatter as $5bA4N$useLocalizedStringFormatter} from "@react-aria/i18n";
38
- import {useHover as $5bA4N$useHover, useFocusWithin as $5bA4N$useFocusWithin, getInteractionModality as $5bA4N$getInteractionModality} from "@react-aria/interactions";
39
- import {useLandmark as $5bA4N$useLandmark} from "@react-aria/landmark";
1
+ import {useToast as $d6542812f0669241$export$a407b657d3044108} from "./useToast.module.js";
2
+ import {useToastRegion as $6cc546b19ee7130a$export$b8cbbb20a51697de} from "./useToastRegion.module.js";
40
3
 
41
-
42
- function $parcel$interopDefault(a) {
43
- return a && a.__esModule ? a.default : a;
44
- }
45
4
  /*
46
5
  * Copyright 2020 Adobe. All rights reserved.
47
6
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -52,208 +11,7 @@ function $parcel$interopDefault(a) {
52
11
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
53
12
  * OF ANY KIND, either express or implied. See the License for the specific language
54
13
  * governing permissions and limitations under the License.
55
- */ /*
56
- * Copyright 2020 Adobe. All rights reserved.
57
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
58
- * you may not use this file except in compliance with the License. You may obtain a copy
59
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
60
- *
61
- * Unless required by applicable law or agreed to in writing, software distributed under
62
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
63
- * OF ANY KIND, either express or implied. See the License for the specific language
64
- * governing permissions and limitations under the License.
65
- */ var $7853651519a70071$exports = {};
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
- $7853651519a70071$exports = {
101
- "ar-AE": $ff9177efc58547ad$exports,
102
- "bg-BG": $25eb7c0c0c45e544$exports,
103
- "cs-CZ": $28feffc3d61a8691$exports,
104
- "da-DK": $390d441203d25ff4$exports,
105
- "de-DE": $7063c2d0f14f979a$exports,
106
- "el-GR": $2dfc1dbb6590af88$exports,
107
- "en-US": $9a12ff1caae5a7a5$exports,
108
- "es-ES": $f4095fb5a72adbe6$exports,
109
- "et-EE": $75bc5191b9d7826a$exports,
110
- "fi-FI": $e4b9aef18b0db8dc$exports,
111
- "fr-FR": $888756784d832bd7$exports,
112
- "he-IL": $6835949b68a1fabf$exports,
113
- "hr-HR": $87ffcbc0b651e40b$exports,
114
- "hu-HU": $dc6e3b2813600d69$exports,
115
- "it-IT": $fe136bcbacfcfa14$exports,
116
- "ja-JP": $8fb53a929b46df83$exports,
117
- "ko-KR": $2c38dbfaf041a865$exports,
118
- "lt-LT": $48f3f33a29908d4c$exports,
119
- "lv-LV": $9867160d996455a0$exports,
120
- "nb-NO": $196258ea25c96487$exports,
121
- "nl-NL": $949061cb954e8000$exports,
122
- "pl-PL": $8189bed27add1ad3$exports,
123
- "pt-BR": $a361756a93b6e28c$exports,
124
- "pt-PT": $034c7393857c8db0$exports,
125
- "ro-RO": $e33d3b3868478b04$exports,
126
- "ru-RU": $9a7dcb914b29cd9f$exports,
127
- "sk-SK": $e43d964a0c7f1266$exports,
128
- "sl-SI": $0bc56cee3275bcaa$exports,
129
- "sr-SP": $7dbdd7289c10d2ba$exports,
130
- "sv-SE": $ccbe6066c10b1e53$exports,
131
- "tr-TR": $9d503476b9d858b7$exports,
132
- "uk-UA": $32ee419c7b9b7a83$exports,
133
- "zh-CN": $122525af1cb737c7$exports,
134
- "zh-TW": $52e8b1b00094e5a3$exports
135
- };
136
-
137
-
138
-
139
-
140
-
141
- function $d6542812f0669241$export$a407b657d3044108(props, state, ref) {
142
- let { key: key, timer: timer, timeout: timeout, animation: animation } = props.toast;
143
- (0, $5bA4N$useEffect)(()=>{
144
- if (!timer) return;
145
- timer.reset(timeout);
146
- return ()=>{
147
- timer.pause();
148
- };
149
- }, [
150
- timer,
151
- timeout
152
- ]);
153
- // Restore focus to the toast container on unmount.
154
- // If there are no more toasts, the container will be unmounted
155
- // and will restore focus to wherever focus was before the user
156
- // focused the toast region.
157
- let focusOnUnmount = (0, $5bA4N$useRef)(null);
158
- (0, $5bA4N$useLayoutEffect)(()=>{
159
- let container = ref.current.closest("[role=region]");
160
- return ()=>{
161
- if (container && container.contains(document.activeElement)) // Focus must be delayed for focus ring to appear, but we can't wait
162
- // until useEffect cleanup to check if focus was inside the container.
163
- focusOnUnmount.current = container;
164
- };
165
- }, [
166
- ref
167
- ]);
168
- // eslint-disable-next-line
169
- (0, $5bA4N$useEffect)(()=>{
170
- return ()=>{
171
- if (focusOnUnmount.current) focusOnUnmount.current.focus();
172
- };
173
- }, [
174
- ref
175
- ]);
176
- let titleId = (0, $5bA4N$useId)();
177
- let descriptionId = (0, $5bA4N$useSlotId)();
178
- let stringFormatter = (0, $5bA4N$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($7853651519a70071$exports))), "@react-aria/toast");
179
- return {
180
- toastProps: {
181
- role: "alert",
182
- "aria-label": props["aria-label"],
183
- "aria-labelledby": props["aria-labelledby"] || titleId,
184
- "aria-describedby": props["aria-describedby"] || descriptionId,
185
- "aria-details": props["aria-details"],
186
- // Hide toasts that are animating out so VoiceOver doesn't announce them.
187
- "aria-hidden": animation === "exiting" ? "true" : undefined
188
- },
189
- titleProps: {
190
- id: titleId
191
- },
192
- descriptionProps: {
193
- id: descriptionId
194
- },
195
- closeButtonProps: {
196
- "aria-label": stringFormatter.format("close"),
197
- onPress: ()=>state.close(key)
198
- }
199
- };
200
- }
201
-
202
-
203
-
204
-
205
-
206
-
207
-
208
-
209
- function $6cc546b19ee7130a$export$b8cbbb20a51697de(props, state, ref) {
210
- let stringFormatter = (0, $5bA4N$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($7853651519a70071$exports))), "@react-aria/toast");
211
- let { landmarkProps: landmarkProps } = (0, $5bA4N$useLandmark)({
212
- role: "region",
213
- "aria-label": props["aria-label"] || stringFormatter.format("notifications")
214
- }, ref);
215
- let { hoverProps: hoverProps } = (0, $5bA4N$useHover)({
216
- onHoverStart: state.pauseAll,
217
- onHoverEnd: state.resumeAll
218
- });
219
- let lastFocused = (0, $5bA4N$useRef)(null);
220
- let { focusWithinProps: focusWithinProps } = (0, $5bA4N$useFocusWithin)({
221
- onFocusWithin: (e)=>{
222
- state.pauseAll();
223
- lastFocused.current = e.relatedTarget;
224
- },
225
- onBlurWithin: ()=>{
226
- state.resumeAll();
227
- lastFocused.current = null;
228
- }
229
- });
230
- // When the region unmounts, restore focus to the last element that had focus
231
- // before the user moved focus into the region.
232
- // TODO: handle when the element has unmounted like FocusScope does?
233
- // eslint-disable-next-line arrow-body-style
234
- (0, $5bA4N$useEffect)(()=>{
235
- return ()=>{
236
- if (lastFocused.current && document.body.contains(lastFocused.current)) {
237
- if ((0, $5bA4N$getInteractionModality)() === "pointer") (0, $5bA4N$focusWithoutScrolling)(lastFocused.current);
238
- else lastFocused.current.focus();
239
- }
240
- };
241
- }, [
242
- ref
243
- ]);
244
- return {
245
- regionProps: (0, $5bA4N$mergeProps)(landmarkProps, hoverProps, focusWithinProps, {
246
- tabIndex: -1,
247
- // Mark the toast region as a "top layer", so that it:
248
- // - is not aria-hidden when opening an overlay
249
- // - allows focus even outside a containing focus scope
250
- // - doesn’t dismiss overlays when clicking on it, even though it is outside
251
- // @ts-ignore
252
- "data-react-aria-top-layer": true
253
- })
254
- };
255
- }
256
-
14
+ */
257
15
 
258
16
 
259
17
 
@@ -1 +1 @@
1
- {"mappings":"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","sources":["packages/@react-aria/toast/src/index.ts","packages/@react-aria/toast/src/useToast.ts","packages/@react-aria/toast/src/*.js","packages/@react-aria/toast/src/useToastRegion.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useToast} from './useToast';\nexport {useToastRegion} from './useToastRegion';\n\nexport type {AriaToastRegionProps, ToastRegionAria} from './useToastRegion';\nexport type {AriaToastProps, ToastAria} from './useToast';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaLabelingProps, DOMAttributes, FocusableElement} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {QueuedToast, ToastState} from '@react-stately/toast';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {useId, useLayoutEffect, useSlotId} from '@react-aria/utils';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AriaToastProps<T> extends AriaLabelingProps {\n /** The toast object. */\n toast: QueuedToast<T>\n}\n\nexport interface ToastAria {\n /** Props for the toast container element. */\n toastProps: DOMAttributes,\n /** Props for the toast title element. */\n titleProps: DOMAttributes,\n /** Props for the toast description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the toast close button. */\n closeButtonProps: AriaButtonProps\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast component.\n * Toasts display brief, temporary notifications of actions, errors, or other events in an application.\n */\nexport function useToast<T>(props: AriaToastProps<T>, state: ToastState<T>, ref: RefObject<FocusableElement>): ToastAria {\n let {\n key,\n timer,\n timeout,\n animation\n } = props.toast;\n\n useEffect(() => {\n if (!timer) {\n return;\n }\n\n timer.reset(timeout);\n return () => {\n timer.pause();\n };\n }, [timer, timeout]);\n\n // Restore focus to the toast container on unmount.\n // If there are no more toasts, the container will be unmounted\n // and will restore focus to wherever focus was before the user\n // focused the toast region.\n let focusOnUnmount = useRef(null);\n useLayoutEffect(() => {\n let container = ref.current.closest('[role=region]') as HTMLElement;\n return () => {\n if (container && container.contains(document.activeElement)) {\n // Focus must be delayed for focus ring to appear, but we can't wait\n // until useEffect cleanup to check if focus was inside the container.\n focusOnUnmount.current = container;\n }\n };\n }, [ref]);\n\n // eslint-disable-next-line\n useEffect(() => {\n return () => {\n if (focusOnUnmount.current) {\n focusOnUnmount.current.focus();\n }\n };\n }, [ref]);\n\n let titleId = useId();\n let descriptionId = useSlotId();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n\n return {\n toastProps: {\n role: 'alert',\n 'aria-label': props['aria-label'],\n 'aria-labelledby': props['aria-labelledby'] || titleId,\n 'aria-describedby': props['aria-describedby'] || descriptionId,\n 'aria-details': props['aria-details'],\n // Hide toasts that are animating out so VoiceOver doesn't announce them.\n 'aria-hidden': animation === 'exiting' ? 'true' : undefined\n },\n titleProps: {\n id: titleId\n },\n descriptionProps: {\n id: descriptionId\n },\n closeButtonProps: {\n 'aria-label': stringFormatter.format('close'),\n onPress: () => state.close(key)\n }\n };\n}\n","const _temp0 = require(\"../intl/ar-AE.json\");\nconst _temp1 = require(\"../intl/bg-BG.json\");\nconst _temp2 = require(\"../intl/cs-CZ.json\");\nconst _temp3 = require(\"../intl/da-DK.json\");\nconst _temp4 = require(\"../intl/de-DE.json\");\nconst _temp5 = require(\"../intl/el-GR.json\");\nconst _temp6 = require(\"../intl/en-US.json\");\nconst _temp7 = require(\"../intl/es-ES.json\");\nconst _temp8 = require(\"../intl/et-EE.json\");\nconst _temp9 = require(\"../intl/fi-FI.json\");\nconst _temp10 = require(\"../intl/fr-FR.json\");\nconst _temp11 = require(\"../intl/he-IL.json\");\nconst _temp12 = require(\"../intl/hr-HR.json\");\nconst _temp13 = require(\"../intl/hu-HU.json\");\nconst _temp14 = require(\"../intl/it-IT.json\");\nconst _temp15 = require(\"../intl/ja-JP.json\");\nconst _temp16 = require(\"../intl/ko-KR.json\");\nconst _temp17 = require(\"../intl/lt-LT.json\");\nconst _temp18 = require(\"../intl/lv-LV.json\");\nconst _temp19 = require(\"../intl/nb-NO.json\");\nconst _temp20 = require(\"../intl/nl-NL.json\");\nconst _temp21 = require(\"../intl/pl-PL.json\");\nconst _temp22 = require(\"../intl/pt-BR.json\");\nconst _temp23 = require(\"../intl/pt-PT.json\");\nconst _temp24 = require(\"../intl/ro-RO.json\");\nconst _temp25 = require(\"../intl/ru-RU.json\");\nconst _temp26 = require(\"../intl/sk-SK.json\");\nconst _temp27 = require(\"../intl/sl-SI.json\");\nconst _temp28 = require(\"../intl/sr-SP.json\");\nconst _temp29 = require(\"../intl/sv-SE.json\");\nconst _temp30 = require(\"../intl/tr-TR.json\");\nconst _temp31 = require(\"../intl/uk-UA.json\");\nconst _temp32 = require(\"../intl/zh-CN.json\");\nconst _temp33 = require(\"../intl/zh-TW.json\");\nmodule.exports = {\n \"ar-AE\": _temp0,\n \"bg-BG\": _temp1,\n \"cs-CZ\": _temp2,\n \"da-DK\": _temp3,\n \"de-DE\": _temp4,\n \"el-GR\": _temp5,\n \"en-US\": _temp6,\n \"es-ES\": _temp7,\n \"et-EE\": _temp8,\n \"fi-FI\": _temp9,\n \"fr-FR\": _temp10,\n \"he-IL\": _temp11,\n \"hr-HR\": _temp12,\n \"hu-HU\": _temp13,\n \"it-IT\": _temp14,\n \"ja-JP\": _temp15,\n \"ko-KR\": _temp16,\n \"lt-LT\": _temp17,\n \"lv-LV\": _temp18,\n \"nb-NO\": _temp19,\n \"nl-NL\": _temp20,\n \"pl-PL\": _temp21,\n \"pt-BR\": _temp22,\n \"pt-PT\": _temp23,\n \"ro-RO\": _temp24,\n \"ru-RU\": _temp25,\n \"sk-SK\": _temp26,\n \"sl-SI\": _temp27,\n \"sr-SP\": _temp28,\n \"sv-SE\": _temp29,\n \"tr-TR\": _temp30,\n \"uk-UA\": _temp31,\n \"zh-CN\": _temp32,\n \"zh-TW\": _temp33\n}","import {AriaLabelingProps, DOMAttributes} from '@react-types/shared';\nimport {focusWithoutScrolling, mergeProps} from '@react-aria/utils';\nimport {getInteractionModality, useFocusWithin, useHover} from '@react-aria/interactions';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {ToastState} from '@react-stately/toast';\nimport {useLandmark} from '@react-aria/landmark';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AriaToastRegionProps extends AriaLabelingProps {\n /**\n * An accessibility label for the toast region.\n * @default \"Notifications\"\n */\n 'aria-label'?: string\n}\n\nexport interface ToastRegionAria {\n /** Props for the landmark region element. */\n regionProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast region containing one or more toasts.\n * Toasts display brief, temporary notifications of actions, errors, or other events in an application.\n */\nexport function useToastRegion<T>(props: AriaToastRegionProps, state: ToastState<T>, ref: RefObject<HTMLElement>): ToastRegionAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n let {landmarkProps} = useLandmark({\n role: 'region',\n 'aria-label': props['aria-label'] || stringFormatter.format('notifications')\n }, ref);\n\n let {hoverProps} = useHover({\n onHoverStart: state.pauseAll,\n onHoverEnd: state.resumeAll\n });\n\n let lastFocused = useRef(null);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: (e) => {\n state.pauseAll();\n lastFocused.current = e.relatedTarget;\n },\n onBlurWithin: () => {\n state.resumeAll();\n lastFocused.current = null;\n }\n });\n\n // When the region unmounts, restore focus to the last element that had focus\n // before the user moved focus into the region.\n // TODO: handle when the element has unmounted like FocusScope does?\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n if (lastFocused.current && document.body.contains(lastFocused.current)) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n }\n };\n }, [ref]);\n\n return {\n regionProps: mergeProps(landmarkProps, hoverProps, focusWithinProps, {\n tabIndex: -1,\n // Mark the toast region as a \"top layer\", so that it:\n // - is not aria-hidden when opening an overlay\n // - allows focus even outside a containing focus scope\n // - doesn’t dismiss overlays when clicking on it, even though it is outside\n // @ts-ignore\n 'data-react-aria-top-layer': true\n })\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/toast/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useToast} from './useToast';\nexport {useToastRegion} from './useToastRegion';\n\nexport type {AriaToastRegionProps, ToastRegionAria} from './useToastRegion';\nexport type {AriaToastProps, ToastAria} from './useToast';\n"],"names":[],"version":3,"file":"module.js.map"}
package/dist/nb-NO.mjs CHANGED
@@ -6,4 +6,4 @@ $196258ea25c96487$exports = {
6
6
 
7
7
 
8
8
  export {$196258ea25c96487$exports as default};
9
- //# sourceMappingURL=nb-NO.module.js.map
9
+ //# sourceMappingURL=nb-NO.mjs.map
package/dist/nl-NL.mjs CHANGED
@@ -6,4 +6,4 @@ $949061cb954e8000$exports = {
6
6
 
7
7
 
8
8
  export {$949061cb954e8000$exports as default};
9
- //# sourceMappingURL=nl-NL.module.js.map
9
+ //# sourceMappingURL=nl-NL.mjs.map
package/dist/pl-PL.mjs CHANGED
@@ -6,4 +6,4 @@ $8189bed27add1ad3$exports = {
6
6
 
7
7
 
8
8
  export {$8189bed27add1ad3$exports as default};
9
- //# sourceMappingURL=pl-PL.module.js.map
9
+ //# sourceMappingURL=pl-PL.mjs.map
package/dist/pt-BR.mjs CHANGED
@@ -6,4 +6,4 @@ $a361756a93b6e28c$exports = {
6
6
 
7
7
 
8
8
  export {$a361756a93b6e28c$exports as default};
9
- //# sourceMappingURL=pt-BR.module.js.map
9
+ //# sourceMappingURL=pt-BR.mjs.map
package/dist/pt-PT.mjs CHANGED
@@ -6,4 +6,4 @@ $034c7393857c8db0$exports = {
6
6
 
7
7
 
8
8
  export {$034c7393857c8db0$exports as default};
9
- //# sourceMappingURL=pt-PT.module.js.map
9
+ //# sourceMappingURL=pt-PT.mjs.map
package/dist/ro-RO.mjs CHANGED
@@ -6,4 +6,4 @@ $e33d3b3868478b04$exports = {
6
6
 
7
7
 
8
8
  export {$e33d3b3868478b04$exports as default};
9
- //# sourceMappingURL=ro-RO.module.js.map
9
+ //# sourceMappingURL=ro-RO.mjs.map
package/dist/ru-RU.mjs CHANGED
@@ -6,4 +6,4 @@ $9a7dcb914b29cd9f$exports = {
6
6
 
7
7
 
8
8
  export {$9a7dcb914b29cd9f$exports as default};
9
- //# sourceMappingURL=ru-RU.module.js.map
9
+ //# sourceMappingURL=ru-RU.mjs.map
package/dist/sk-SK.mjs CHANGED
@@ -6,4 +6,4 @@ $e43d964a0c7f1266$exports = {
6
6
 
7
7
 
8
8
  export {$e43d964a0c7f1266$exports as default};
9
- //# sourceMappingURL=sk-SK.module.js.map
9
+ //# sourceMappingURL=sk-SK.mjs.map
package/dist/sl-SI.mjs CHANGED
@@ -6,4 +6,4 @@ $0bc56cee3275bcaa$exports = {
6
6
 
7
7
 
8
8
  export {$0bc56cee3275bcaa$exports as default};
9
- //# sourceMappingURL=sl-SI.module.js.map
9
+ //# sourceMappingURL=sl-SI.mjs.map
package/dist/sr-SP.mjs CHANGED
@@ -6,4 +6,4 @@ $7dbdd7289c10d2ba$exports = {
6
6
 
7
7
 
8
8
  export {$7dbdd7289c10d2ba$exports as default};
9
- //# sourceMappingURL=sr-SP.module.js.map
9
+ //# sourceMappingURL=sr-SP.mjs.map
package/dist/sv-SE.mjs CHANGED
@@ -6,4 +6,4 @@ $ccbe6066c10b1e53$exports = {
6
6
 
7
7
 
8
8
  export {$ccbe6066c10b1e53$exports as default};
9
- //# sourceMappingURL=sv-SE.module.js.map
9
+ //# sourceMappingURL=sv-SE.mjs.map
package/dist/tr-TR.mjs CHANGED
@@ -6,4 +6,4 @@ $9d503476b9d858b7$exports = {
6
6
 
7
7
 
8
8
  export {$9d503476b9d858b7$exports as default};
9
- //# sourceMappingURL=tr-TR.module.js.map
9
+ //# sourceMappingURL=tr-TR.mjs.map
package/dist/uk-UA.mjs CHANGED
@@ -6,4 +6,4 @@ $32ee419c7b9b7a83$exports = {
6
6
 
7
7
 
8
8
  export {$32ee419c7b9b7a83$exports as default};
9
- //# sourceMappingURL=uk-UA.module.js.map
9
+ //# sourceMappingURL=uk-UA.mjs.map
@@ -0,0 +1,92 @@
1
+ var $f49b2d6c91681304$exports = require("./intlStrings.main.js");
2
+ var $ijFUR$react = require("react");
3
+ var $ijFUR$reactariautils = require("@react-aria/utils");
4
+ var $ijFUR$reactariai18n = require("@react-aria/i18n");
5
+
6
+
7
+ function $parcel$interopDefault(a) {
8
+ return a && a.__esModule ? a.default : a;
9
+ }
10
+
11
+ function $parcel$export(e, n, v, s) {
12
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
13
+ }
14
+
15
+ $parcel$export(module.exports, "useToast", () => $ec537504faac71d2$export$a407b657d3044108);
16
+ /*
17
+ * Copyright 2020 Adobe. All rights reserved.
18
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License. You may obtain a copy
20
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software distributed under
23
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
+ * OF ANY KIND, either express or implied. See the License for the specific language
25
+ * governing permissions and limitations under the License.
26
+ */
27
+
28
+
29
+
30
+ function $ec537504faac71d2$export$a407b657d3044108(props, state, ref) {
31
+ let { key: key, timer: timer, timeout: timeout, animation: animation } = props.toast;
32
+ (0, $ijFUR$react.useEffect)(()=>{
33
+ if (!timer) return;
34
+ timer.reset(timeout);
35
+ return ()=>{
36
+ timer.pause();
37
+ };
38
+ }, [
39
+ timer,
40
+ timeout
41
+ ]);
42
+ // Restore focus to the toast container on unmount.
43
+ // If there are no more toasts, the container will be unmounted
44
+ // and will restore focus to wherever focus was before the user
45
+ // focused the toast region.
46
+ let focusOnUnmount = (0, $ijFUR$react.useRef)(null);
47
+ (0, $ijFUR$reactariautils.useLayoutEffect)(()=>{
48
+ let container = ref.current.closest("[role=region]");
49
+ return ()=>{
50
+ if (container && container.contains(document.activeElement)) // Focus must be delayed for focus ring to appear, but we can't wait
51
+ // until useEffect cleanup to check if focus was inside the container.
52
+ focusOnUnmount.current = container;
53
+ };
54
+ }, [
55
+ ref
56
+ ]);
57
+ // eslint-disable-next-line
58
+ (0, $ijFUR$react.useEffect)(()=>{
59
+ return ()=>{
60
+ if (focusOnUnmount.current) focusOnUnmount.current.focus();
61
+ };
62
+ }, [
63
+ ref
64
+ ]);
65
+ let titleId = (0, $ijFUR$reactariautils.useId)();
66
+ let descriptionId = (0, $ijFUR$reactariautils.useSlotId)();
67
+ let stringFormatter = (0, $ijFUR$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($f49b2d6c91681304$exports))), "@react-aria/toast");
68
+ return {
69
+ toastProps: {
70
+ role: "alert",
71
+ "aria-label": props["aria-label"],
72
+ "aria-labelledby": props["aria-labelledby"] || titleId,
73
+ "aria-describedby": props["aria-describedby"] || descriptionId,
74
+ "aria-details": props["aria-details"],
75
+ // Hide toasts that are animating out so VoiceOver doesn't announce them.
76
+ "aria-hidden": animation === "exiting" ? "true" : undefined
77
+ },
78
+ titleProps: {
79
+ id: titleId
80
+ },
81
+ descriptionProps: {
82
+ id: descriptionId
83
+ },
84
+ closeButtonProps: {
85
+ "aria-label": stringFormatter.format("close"),
86
+ onPress: ()=>state.close(key)
87
+ }
88
+ };
89
+ }
90
+
91
+
92
+ //# sourceMappingURL=useToast.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA+BM,SAAS,0CAAY,KAAwB,EAAE,KAAoB,EAAE,GAAgC;IAC1G,IAAI,OACF,GAAG,SACH,KAAK,WACL,OAAO,aACP,SAAS,EACV,GAAG,MAAM,KAAK;IAEf,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,CAAC,OACH;QAGF,MAAM,KAAK,CAAC;QACZ,OAAO;YACL,MAAM,KAAK;QACb;IACF,GAAG;QAAC;QAAO;KAAQ;IAEnB,mDAAmD;IACnD,+DAA+D;IAC/D,+DAA+D;IAC/D,4BAA4B;IAC5B,IAAI,iBAAiB,CAAA,GAAA,mBAAK,EAAE;IAC5B,CAAA,GAAA,qCAAc,EAAE;QACd,IAAI,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC;QACpC,OAAO;YACL,IAAI,aAAa,UAAU,QAAQ,CAAC,SAAS,aAAa,GACxD,oEAAoE;YACpE,sEAAsE;YACtE,eAAe,OAAO,GAAG;QAE7B;IACF,GAAG;QAAC;KAAI;IAER,2BAA2B;IAC3B,CAAA,GAAA,sBAAQ,EAAE;QACR,OAAO;YACL,IAAI,eAAe,OAAO,EACxB,eAAe,OAAO,CAAC,KAAK;QAEhC;IACF,GAAG;QAAC;KAAI;IAER,IAAI,UAAU,CAAA,GAAA,2BAAI;IAClB,IAAI,gBAAgB,CAAA,GAAA,+BAAQ;IAC5B,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,OAAO;QACL,YAAY;YACV,MAAM;YACN,cAAc,KAAK,CAAC,aAAa;YACjC,mBAAmB,KAAK,CAAC,kBAAkB,IAAI;YAC/C,oBAAoB,KAAK,CAAC,mBAAmB,IAAI;YACjD,gBAAgB,KAAK,CAAC,eAAe;YACrC,yEAAyE;YACzE,eAAe,cAAc,YAAY,SAAS;QACpD;QACA,YAAY;YACV,IAAI;QACN;QACA,kBAAkB;YAChB,IAAI;QACN;QACA,kBAAkB;YAChB,cAAc,gBAAgB,MAAM,CAAC;YACrC,SAAS,IAAM,MAAM,KAAK,CAAC;QAC7B;IACF;AACF","sources":["packages/@react-aria/toast/src/useToast.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaLabelingProps, DOMAttributes, FocusableElement} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {QueuedToast, ToastState} from '@react-stately/toast';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {useId, useLayoutEffect, useSlotId} from '@react-aria/utils';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AriaToastProps<T> extends AriaLabelingProps {\n /** The toast object. */\n toast: QueuedToast<T>\n}\n\nexport interface ToastAria {\n /** Props for the toast container element. */\n toastProps: DOMAttributes,\n /** Props for the toast title element. */\n titleProps: DOMAttributes,\n /** Props for the toast description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the toast close button. */\n closeButtonProps: AriaButtonProps\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast component.\n * Toasts display brief, temporary notifications of actions, errors, or other events in an application.\n */\nexport function useToast<T>(props: AriaToastProps<T>, state: ToastState<T>, ref: RefObject<FocusableElement>): ToastAria {\n let {\n key,\n timer,\n timeout,\n animation\n } = props.toast;\n\n useEffect(() => {\n if (!timer) {\n return;\n }\n\n timer.reset(timeout);\n return () => {\n timer.pause();\n };\n }, [timer, timeout]);\n\n // Restore focus to the toast container on unmount.\n // If there are no more toasts, the container will be unmounted\n // and will restore focus to wherever focus was before the user\n // focused the toast region.\n let focusOnUnmount = useRef(null);\n useLayoutEffect(() => {\n let container = ref.current.closest('[role=region]') as HTMLElement;\n return () => {\n if (container && container.contains(document.activeElement)) {\n // Focus must be delayed for focus ring to appear, but we can't wait\n // until useEffect cleanup to check if focus was inside the container.\n focusOnUnmount.current = container;\n }\n };\n }, [ref]);\n\n // eslint-disable-next-line\n useEffect(() => {\n return () => {\n if (focusOnUnmount.current) {\n focusOnUnmount.current.focus();\n }\n };\n }, [ref]);\n\n let titleId = useId();\n let descriptionId = useSlotId();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n\n return {\n toastProps: {\n role: 'alert',\n 'aria-label': props['aria-label'],\n 'aria-labelledby': props['aria-labelledby'] || titleId,\n 'aria-describedby': props['aria-describedby'] || descriptionId,\n 'aria-details': props['aria-details'],\n // Hide toasts that are animating out so VoiceOver doesn't announce them.\n 'aria-hidden': animation === 'exiting' ? 'true' : undefined\n },\n titleProps: {\n id: titleId\n },\n descriptionProps: {\n id: descriptionId\n },\n closeButtonProps: {\n 'aria-label': stringFormatter.format('close'),\n onPress: () => state.close(key)\n }\n };\n}\n"],"names":[],"version":3,"file":"useToast.main.js.map"}
@@ -0,0 +1,87 @@
1
+ import $7WpW4$intlStringsmodulejs from "./intlStrings.mjs";
2
+ import {useEffect as $7WpW4$useEffect, useRef as $7WpW4$useRef} from "react";
3
+ import {useLayoutEffect as $7WpW4$useLayoutEffect, useId as $7WpW4$useId, useSlotId as $7WpW4$useSlotId} from "@react-aria/utils";
4
+ import {useLocalizedStringFormatter as $7WpW4$useLocalizedStringFormatter} from "@react-aria/i18n";
5
+
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
+
22
+
23
+
24
+ function $d6542812f0669241$export$a407b657d3044108(props, state, ref) {
25
+ let { key: key, timer: timer, timeout: timeout, animation: animation } = props.toast;
26
+ (0, $7WpW4$useEffect)(()=>{
27
+ if (!timer) return;
28
+ timer.reset(timeout);
29
+ return ()=>{
30
+ timer.pause();
31
+ };
32
+ }, [
33
+ timer,
34
+ timeout
35
+ ]);
36
+ // Restore focus to the toast container on unmount.
37
+ // If there are no more toasts, the container will be unmounted
38
+ // and will restore focus to wherever focus was before the user
39
+ // focused the toast region.
40
+ let focusOnUnmount = (0, $7WpW4$useRef)(null);
41
+ (0, $7WpW4$useLayoutEffect)(()=>{
42
+ let container = ref.current.closest("[role=region]");
43
+ return ()=>{
44
+ if (container && container.contains(document.activeElement)) // Focus must be delayed for focus ring to appear, but we can't wait
45
+ // until useEffect cleanup to check if focus was inside the container.
46
+ focusOnUnmount.current = container;
47
+ };
48
+ }, [
49
+ ref
50
+ ]);
51
+ // eslint-disable-next-line
52
+ (0, $7WpW4$useEffect)(()=>{
53
+ return ()=>{
54
+ if (focusOnUnmount.current) focusOnUnmount.current.focus();
55
+ };
56
+ }, [
57
+ ref
58
+ ]);
59
+ let titleId = (0, $7WpW4$useId)();
60
+ let descriptionId = (0, $7WpW4$useSlotId)();
61
+ let stringFormatter = (0, $7WpW4$useLocalizedStringFormatter)((0, ($parcel$interopDefault($7WpW4$intlStringsmodulejs))), "@react-aria/toast");
62
+ return {
63
+ toastProps: {
64
+ role: "alert",
65
+ "aria-label": props["aria-label"],
66
+ "aria-labelledby": props["aria-labelledby"] || titleId,
67
+ "aria-describedby": props["aria-describedby"] || descriptionId,
68
+ "aria-details": props["aria-details"],
69
+ // Hide toasts that are animating out so VoiceOver doesn't announce them.
70
+ "aria-hidden": animation === "exiting" ? "true" : undefined
71
+ },
72
+ titleProps: {
73
+ id: titleId
74
+ },
75
+ descriptionProps: {
76
+ id: descriptionId
77
+ },
78
+ closeButtonProps: {
79
+ "aria-label": stringFormatter.format("close"),
80
+ onPress: ()=>state.close(key)
81
+ }
82
+ };
83
+ }
84
+
85
+
86
+ export {$d6542812f0669241$export$a407b657d3044108 as useToast};
87
+ //# sourceMappingURL=useToast.mjs.map