@react-spectrum/toast 3.1.6 → 3.2.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.
Files changed (218) hide show
  1. package/dist/import.mjs +2 -2
  2. package/dist/main.js +3 -3
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +2 -2
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +2 -0
  7. package/package.json +13 -35
  8. package/src/index.ts +2 -2
  9. package/dist/Toast.main.js +0 -109
  10. package/dist/Toast.main.js.map +0 -1
  11. package/dist/Toast.mjs +0 -104
  12. package/dist/Toast.module.js +0 -104
  13. package/dist/Toast.module.js.map +0 -1
  14. package/dist/ToastContainer.main.js +0 -180
  15. package/dist/ToastContainer.main.js.map +0 -1
  16. package/dist/ToastContainer.mjs +0 -174
  17. package/dist/ToastContainer.module.js +0 -174
  18. package/dist/ToastContainer.module.js.map +0 -1
  19. package/dist/Toaster.main.js +0 -78
  20. package/dist/Toaster.main.js.map +0 -1
  21. package/dist/Toaster.mjs +0 -73
  22. package/dist/Toaster.module.js +0 -73
  23. package/dist/Toaster.module.js.map +0 -1
  24. package/dist/ar-AE.main.js +0 -8
  25. package/dist/ar-AE.main.js.map +0 -1
  26. package/dist/ar-AE.mjs +0 -10
  27. package/dist/ar-AE.module.js +0 -10
  28. package/dist/ar-AE.module.js.map +0 -1
  29. package/dist/bg-BG.main.js +0 -8
  30. package/dist/bg-BG.main.js.map +0 -1
  31. package/dist/bg-BG.mjs +0 -10
  32. package/dist/bg-BG.module.js +0 -10
  33. package/dist/bg-BG.module.js.map +0 -1
  34. package/dist/cs-CZ.main.js +0 -8
  35. package/dist/cs-CZ.main.js.map +0 -1
  36. package/dist/cs-CZ.mjs +0 -10
  37. package/dist/cs-CZ.module.js +0 -10
  38. package/dist/cs-CZ.module.js.map +0 -1
  39. package/dist/da-DK.main.js +0 -8
  40. package/dist/da-DK.main.js.map +0 -1
  41. package/dist/da-DK.mjs +0 -10
  42. package/dist/da-DK.module.js +0 -10
  43. package/dist/da-DK.module.js.map +0 -1
  44. package/dist/de-DE.main.js +0 -8
  45. package/dist/de-DE.main.js.map +0 -1
  46. package/dist/de-DE.mjs +0 -10
  47. package/dist/de-DE.module.js +0 -10
  48. package/dist/de-DE.module.js.map +0 -1
  49. package/dist/el-GR.main.js +0 -8
  50. package/dist/el-GR.main.js.map +0 -1
  51. package/dist/el-GR.mjs +0 -10
  52. package/dist/el-GR.module.js +0 -10
  53. package/dist/el-GR.module.js.map +0 -1
  54. package/dist/en-US.main.js +0 -8
  55. package/dist/en-US.main.js.map +0 -1
  56. package/dist/en-US.mjs +0 -10
  57. package/dist/en-US.module.js +0 -10
  58. package/dist/en-US.module.js.map +0 -1
  59. package/dist/es-ES.main.js +0 -8
  60. package/dist/es-ES.main.js.map +0 -1
  61. package/dist/es-ES.mjs +0 -10
  62. package/dist/es-ES.module.js +0 -10
  63. package/dist/es-ES.module.js.map +0 -1
  64. package/dist/et-EE.main.js +0 -8
  65. package/dist/et-EE.main.js.map +0 -1
  66. package/dist/et-EE.mjs +0 -10
  67. package/dist/et-EE.module.js +0 -10
  68. package/dist/et-EE.module.js.map +0 -1
  69. package/dist/fi-FI.main.js +0 -8
  70. package/dist/fi-FI.main.js.map +0 -1
  71. package/dist/fi-FI.mjs +0 -10
  72. package/dist/fi-FI.module.js +0 -10
  73. package/dist/fi-FI.module.js.map +0 -1
  74. package/dist/fr-FR.main.js +0 -8
  75. package/dist/fr-FR.main.js.map +0 -1
  76. package/dist/fr-FR.mjs +0 -10
  77. package/dist/fr-FR.module.js +0 -10
  78. package/dist/fr-FR.module.js.map +0 -1
  79. package/dist/he-IL.main.js +0 -8
  80. package/dist/he-IL.main.js.map +0 -1
  81. package/dist/he-IL.mjs +0 -10
  82. package/dist/he-IL.module.js +0 -10
  83. package/dist/he-IL.module.js.map +0 -1
  84. package/dist/hr-HR.main.js +0 -8
  85. package/dist/hr-HR.main.js.map +0 -1
  86. package/dist/hr-HR.mjs +0 -10
  87. package/dist/hr-HR.module.js +0 -10
  88. package/dist/hr-HR.module.js.map +0 -1
  89. package/dist/hu-HU.main.js +0 -8
  90. package/dist/hu-HU.main.js.map +0 -1
  91. package/dist/hu-HU.mjs +0 -10
  92. package/dist/hu-HU.module.js +0 -10
  93. package/dist/hu-HU.module.js.map +0 -1
  94. package/dist/intlStrings.main.js +0 -108
  95. package/dist/intlStrings.main.js.map +0 -1
  96. package/dist/intlStrings.mjs +0 -110
  97. package/dist/intlStrings.module.js +0 -110
  98. package/dist/intlStrings.module.js.map +0 -1
  99. package/dist/it-IT.main.js +0 -8
  100. package/dist/it-IT.main.js.map +0 -1
  101. package/dist/it-IT.mjs +0 -10
  102. package/dist/it-IT.module.js +0 -10
  103. package/dist/it-IT.module.js.map +0 -1
  104. package/dist/ja-JP.main.js +0 -8
  105. package/dist/ja-JP.main.js.map +0 -1
  106. package/dist/ja-JP.mjs +0 -10
  107. package/dist/ja-JP.module.js +0 -10
  108. package/dist/ja-JP.module.js.map +0 -1
  109. package/dist/ko-KR.main.js +0 -8
  110. package/dist/ko-KR.main.js.map +0 -1
  111. package/dist/ko-KR.mjs +0 -10
  112. package/dist/ko-KR.module.js +0 -10
  113. package/dist/ko-KR.module.js.map +0 -1
  114. package/dist/lt-LT.main.js +0 -8
  115. package/dist/lt-LT.main.js.map +0 -1
  116. package/dist/lt-LT.mjs +0 -10
  117. package/dist/lt-LT.module.js +0 -10
  118. package/dist/lt-LT.module.js.map +0 -1
  119. package/dist/lv-LV.main.js +0 -8
  120. package/dist/lv-LV.main.js.map +0 -1
  121. package/dist/lv-LV.mjs +0 -10
  122. package/dist/lv-LV.module.js +0 -10
  123. package/dist/lv-LV.module.js.map +0 -1
  124. package/dist/nb-NO.main.js +0 -8
  125. package/dist/nb-NO.main.js.map +0 -1
  126. package/dist/nb-NO.mjs +0 -10
  127. package/dist/nb-NO.module.js +0 -10
  128. package/dist/nb-NO.module.js.map +0 -1
  129. package/dist/nl-NL.main.js +0 -8
  130. package/dist/nl-NL.main.js.map +0 -1
  131. package/dist/nl-NL.mjs +0 -10
  132. package/dist/nl-NL.module.js +0 -10
  133. package/dist/nl-NL.module.js.map +0 -1
  134. package/dist/pl-PL.main.js +0 -8
  135. package/dist/pl-PL.main.js.map +0 -1
  136. package/dist/pl-PL.mjs +0 -10
  137. package/dist/pl-PL.module.js +0 -10
  138. package/dist/pl-PL.module.js.map +0 -1
  139. package/dist/pt-BR.main.js +0 -8
  140. package/dist/pt-BR.main.js.map +0 -1
  141. package/dist/pt-BR.mjs +0 -10
  142. package/dist/pt-BR.module.js +0 -10
  143. package/dist/pt-BR.module.js.map +0 -1
  144. package/dist/pt-PT.main.js +0 -8
  145. package/dist/pt-PT.main.js.map +0 -1
  146. package/dist/pt-PT.mjs +0 -10
  147. package/dist/pt-PT.module.js +0 -10
  148. package/dist/pt-PT.module.js.map +0 -1
  149. package/dist/ro-RO.main.js +0 -8
  150. package/dist/ro-RO.main.js.map +0 -1
  151. package/dist/ro-RO.mjs +0 -10
  152. package/dist/ro-RO.module.js +0 -10
  153. package/dist/ro-RO.module.js.map +0 -1
  154. package/dist/ru-RU.main.js +0 -8
  155. package/dist/ru-RU.main.js.map +0 -1
  156. package/dist/ru-RU.mjs +0 -10
  157. package/dist/ru-RU.module.js +0 -10
  158. package/dist/ru-RU.module.js.map +0 -1
  159. package/dist/sk-SK.main.js +0 -8
  160. package/dist/sk-SK.main.js.map +0 -1
  161. package/dist/sk-SK.mjs +0 -10
  162. package/dist/sk-SK.module.js +0 -10
  163. package/dist/sk-SK.module.js.map +0 -1
  164. package/dist/sl-SI.main.js +0 -8
  165. package/dist/sl-SI.main.js.map +0 -1
  166. package/dist/sl-SI.mjs +0 -10
  167. package/dist/sl-SI.module.js +0 -10
  168. package/dist/sl-SI.module.js.map +0 -1
  169. package/dist/sr-SP.main.js +0 -8
  170. package/dist/sr-SP.main.js.map +0 -1
  171. package/dist/sr-SP.mjs +0 -10
  172. package/dist/sr-SP.module.js +0 -10
  173. package/dist/sr-SP.module.js.map +0 -1
  174. package/dist/sv-SE.main.js +0 -8
  175. package/dist/sv-SE.main.js.map +0 -1
  176. package/dist/sv-SE.mjs +0 -10
  177. package/dist/sv-SE.module.js +0 -10
  178. package/dist/sv-SE.module.js.map +0 -1
  179. package/dist/toast.62356566.css +0 -91
  180. package/dist/toast.62356566.css.map +0 -1
  181. package/dist/toast.69f125e3.css +0 -187
  182. package/dist/toast.69f125e3.css.map +0 -1
  183. package/dist/toastContainer_css.main.js +0 -65
  184. package/dist/toastContainer_css.main.js.map +0 -1
  185. package/dist/toastContainer_css.mjs +0 -67
  186. package/dist/toastContainer_css.module.js +0 -67
  187. package/dist/toastContainer_css.module.js.map +0 -1
  188. package/dist/toast_vars_css.main.js +0 -38
  189. package/dist/toast_vars_css.main.js.map +0 -1
  190. package/dist/toast_vars_css.mjs +0 -40
  191. package/dist/toast_vars_css.module.js +0 -40
  192. package/dist/toast_vars_css.module.js.map +0 -1
  193. package/dist/tr-TR.main.js +0 -8
  194. package/dist/tr-TR.main.js.map +0 -1
  195. package/dist/tr-TR.mjs +0 -10
  196. package/dist/tr-TR.module.js +0 -10
  197. package/dist/tr-TR.module.js.map +0 -1
  198. package/dist/types.d.ts +0 -34
  199. package/dist/types.d.ts.map +0 -1
  200. package/dist/uk-UA.main.js +0 -8
  201. package/dist/uk-UA.main.js.map +0 -1
  202. package/dist/uk-UA.mjs +0 -10
  203. package/dist/uk-UA.module.js +0 -10
  204. package/dist/uk-UA.module.js.map +0 -1
  205. package/dist/zh-CN.main.js +0 -8
  206. package/dist/zh-CN.main.js.map +0 -1
  207. package/dist/zh-CN.mjs +0 -10
  208. package/dist/zh-CN.module.js +0 -10
  209. package/dist/zh-CN.module.js.map +0 -1
  210. package/dist/zh-TW.main.js +0 -8
  211. package/dist/zh-TW.main.js.map +0 -1
  212. package/dist/zh-TW.mjs +0 -10
  213. package/dist/zh-TW.module.js +0 -10
  214. package/dist/zh-TW.module.js.map +0 -1
  215. package/src/Toast.tsx +0 -135
  216. package/src/ToastContainer.tsx +0 -216
  217. package/src/Toaster.tsx +0 -71
  218. package/src/toastContainer.css +0 -154
@@ -1,180 +0,0 @@
1
- var $6c5bd1047ecc310e$exports = require("./Toast.main.js");
2
- require("./toast.69f125e3.css");
3
- var $e20782d0579ed886$exports = require("./toastContainer_css.main.js");
4
- var $5b9f2c86c1b1395c$exports = require("./Toaster.main.js");
5
- var $5IVGU$reactspectrumutils = require("@react-spectrum/utils");
6
- var $5IVGU$reactariautils = require("@react-aria/utils");
7
- var $5IVGU$reactdom = require("react-dom");
8
- var $5IVGU$react = require("react");
9
- var $5IVGU$reactstatelytoast = require("@react-stately/toast");
10
- var $5IVGU$usesyncexternalstoreshimindexjs = require("use-sync-external-store/shim/index.js");
11
-
12
-
13
- function $parcel$interopDefault(a) {
14
- return a && a.__esModule ? a.default : a;
15
- }
16
-
17
- function $parcel$export(e, n, v, s) {
18
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
19
- }
20
-
21
- $parcel$export(module.exports, "ToastContainer", () => $56cdf77f3be52eaf$export$f2815235e76a62b9);
22
- $parcel$export(module.exports, "ToastQueue", () => $56cdf77f3be52eaf$export$f1f8569633bbbec4);
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
- */
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
- function $56cdf77f3be52eaf$var$wrapInViewTransition(fn) {
43
- if ('startViewTransition' in document) document.startViewTransition(()=>{
44
- (0, $5IVGU$reactdom.flushSync)(fn);
45
- }).ready.catch(()=>{});
46
- else fn();
47
- }
48
- // There is a single global toast queue instance for the whole app, initialized lazily.
49
- let $56cdf77f3be52eaf$var$globalToastQueue = null;
50
- function $56cdf77f3be52eaf$var$getGlobalToastQueue() {
51
- if (!$56cdf77f3be52eaf$var$globalToastQueue) $56cdf77f3be52eaf$var$globalToastQueue = new (0, $5IVGU$reactstatelytoast.ToastQueue)({
52
- maxVisibleToasts: Infinity,
53
- wrapUpdate: $56cdf77f3be52eaf$var$wrapInViewTransition
54
- });
55
- return $56cdf77f3be52eaf$var$globalToastQueue;
56
- }
57
- function $56cdf77f3be52eaf$export$320311f0e4ecb3ae() {
58
- $56cdf77f3be52eaf$var$globalToastQueue = null;
59
- }
60
- let $56cdf77f3be52eaf$var$toastProviders = new Set();
61
- let $56cdf77f3be52eaf$var$subscriptions = new Set();
62
- function $56cdf77f3be52eaf$var$subscribe(fn) {
63
- $56cdf77f3be52eaf$var$subscriptions.add(fn);
64
- return ()=>$56cdf77f3be52eaf$var$subscriptions.delete(fn);
65
- }
66
- function $56cdf77f3be52eaf$var$triggerSubscriptions() {
67
- for (let fn of $56cdf77f3be52eaf$var$subscriptions)fn();
68
- }
69
- function $56cdf77f3be52eaf$var$getActiveToastContainer() {
70
- return $56cdf77f3be52eaf$var$toastProviders.values().next().value;
71
- }
72
- function $56cdf77f3be52eaf$var$useActiveToastContainer() {
73
- return (0, $5IVGU$usesyncexternalstoreshimindexjs.useSyncExternalStore)($56cdf77f3be52eaf$var$subscribe, $56cdf77f3be52eaf$var$getActiveToastContainer, $56cdf77f3be52eaf$var$getActiveToastContainer);
74
- }
75
- function $56cdf77f3be52eaf$export$f2815235e76a62b9(props) {
76
- // Track all toast provider instances in a set.
77
- // Only the first one will actually render.
78
- // We use a ref to do this, since it will have a stable identity
79
- // over the lifetime of the component.
80
- let ref = (0, $5IVGU$react.useRef)(null);
81
- (0, $5IVGU$react.useEffect)(()=>{
82
- $56cdf77f3be52eaf$var$toastProviders.add(ref);
83
- $56cdf77f3be52eaf$var$triggerSubscriptions();
84
- return ()=>{
85
- // Remove this toast provider, and call subscriptions.
86
- // This will cause all other instances to re-render,
87
- // and the first one to become the new active toast provider.
88
- $56cdf77f3be52eaf$var$toastProviders.delete(ref);
89
- $56cdf77f3be52eaf$var$triggerSubscriptions();
90
- };
91
- }, []);
92
- // Only render if this is the active toast provider instance, and there are visible toasts.
93
- let activeToastContainer = $56cdf77f3be52eaf$var$useActiveToastContainer();
94
- let state = (0, $5IVGU$reactstatelytoast.useToastQueue)($56cdf77f3be52eaf$var$getGlobalToastQueue());
95
- let { placement: placement, isCentered: isCentered } = (0, $5IVGU$react.useMemo)(()=>{
96
- var _props_placement;
97
- let placements = ((_props_placement = props.placement) !== null && _props_placement !== void 0 ? _props_placement : 'bottom').split(' ');
98
- let placement = placements[placements.length - 1];
99
- let isCentered = placements.length === 1;
100
- return {
101
- placement: placement,
102
- isCentered: isCentered
103
- };
104
- }, [
105
- props.placement
106
- ]);
107
- if (ref === activeToastContainer && state.visibleToasts.length > 0) return /*#__PURE__*/ (0, ($parcel$interopDefault($5IVGU$react))).createElement((0, $5b9f2c86c1b1395c$exports.Toaster), {
108
- state: state,
109
- ...props
110
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($5IVGU$react))).createElement("ol", {
111
- className: (0, $5IVGU$reactspectrumutils.classNames)((0, ($parcel$interopDefault($e20782d0579ed886$exports))), 'spectrum-ToastContainer-list')
112
- }, state.visibleToasts.map((toast, index)=>{
113
- let shouldFade = isCentered && index !== 0;
114
- return /*#__PURE__*/ (0, ($parcel$interopDefault($5IVGU$react))).createElement("li", {
115
- key: toast.key,
116
- className: (0, $5IVGU$reactspectrumutils.classNames)((0, ($parcel$interopDefault($e20782d0579ed886$exports))), 'spectrum-ToastContainer-listitem'),
117
- style: {
118
- viewTransitionName: toast.key,
119
- viewTransitionClass: (0, $5IVGU$reactspectrumutils.classNames)((0, ($parcel$interopDefault($e20782d0579ed886$exports))), 'toast', placement, {
120
- 'fadeOnly': shouldFade
121
- })
122
- }
123
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($5IVGU$react))).createElement((0, $6c5bd1047ecc310e$exports.Toast), {
124
- toast: toast,
125
- state: state
126
- }));
127
- })));
128
- return null;
129
- }
130
- function $56cdf77f3be52eaf$var$addToast(children, variant, options = {}) {
131
- // Dispatch a custom event so that toasts can be intercepted and re-targeted, e.g. when inside an iframe.
132
- if (typeof CustomEvent !== 'undefined' && typeof window !== 'undefined') {
133
- let event = new CustomEvent('react-spectrum-toast', {
134
- cancelable: true,
135
- bubbles: true,
136
- detail: {
137
- children: children,
138
- variant: variant,
139
- options: options
140
- }
141
- });
142
- let shouldContinue = window.dispatchEvent(event);
143
- if (!shouldContinue) return ()=>{};
144
- }
145
- let value = {
146
- children: children,
147
- variant: variant,
148
- actionLabel: options.actionLabel,
149
- onAction: options.onAction,
150
- shouldCloseOnAction: options.shouldCloseOnAction,
151
- ...(0, $5IVGU$reactariautils.filterDOMProps)(options)
152
- };
153
- // Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible
154
- // Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.
155
- // It is debatable whether non-actionable toasts would also fail.
156
- let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;
157
- let queue = $56cdf77f3be52eaf$var$getGlobalToastQueue();
158
- let key = queue.add(value, {
159
- timeout: timeout,
160
- onClose: options.onClose
161
- });
162
- return ()=>queue.close(key);
163
- }
164
- const $56cdf77f3be52eaf$export$f1f8569633bbbec4 = {
165
- /** Queues a neutral toast. */ neutral (children, options = {}) {
166
- return $56cdf77f3be52eaf$var$addToast(children, 'neutral', options);
167
- },
168
- /** Queues a positive toast. */ positive (children, options = {}) {
169
- return $56cdf77f3be52eaf$var$addToast(children, 'positive', options);
170
- },
171
- /** Queues a negative toast. */ negative (children, options = {}) {
172
- return $56cdf77f3be52eaf$var$addToast(children, 'negative', options);
173
- },
174
- /** Queues an informational toast. */ info (children, options = {}) {
175
- return $56cdf77f3be52eaf$var$addToast(children, 'info', options);
176
- }
177
- };
178
-
179
-
180
- //# sourceMappingURL=ToastContainer.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AA+BD,SAAS,2CAAqB,EAAc;IAC1C,IAAI,yBAAyB,UAC3B,SAAS,mBAAmB,CAAC;QAC3B,CAAA,GAAA,yBAAQ,EAAE;IACZ,GAAG,KAAK,CAAC,KAAK,CAAC,KAAO;SAEtB;AAEJ;AAEA,uFAAuF;AACvF,IAAI,yCAA0D;AAC9D,SAAS;IACP,IAAI,CAAC,wCACH,yCAAmB,IAAI,CAAA,GAAA,mCAAS,EAAE;QAChC,kBAAkB;QAClB,YAAY;IACd;IAGF,OAAO;AACT;AAGO,SAAS;IACd,yCAAmB;AACrB;AAEA,IAAI,uCAAiB,IAAI;AACzB,IAAI,sCAAgB,IAAI;AACxB,SAAS,gCAAU,EAAc;IAC/B,oCAAc,GAAG,CAAC;IAClB,OAAO,IAAM,oCAAc,MAAM,CAAC;AACpC;AAEA,SAAS;IACP,KAAK,IAAI,MAAM,oCACb;AAEJ;AAEA,SAAS;IACP,OAAO,qCAAe,MAAM,GAAG,IAAI,GAAG,KAAK;AAC7C;AAEA,SAAS;IACP,OAAO,CAAA,GAAA,2DAAmB,EAAE,iCAAW,+CAAyB;AAClE;AAMO,SAAS,0CAAe,KAAkC;IAC/D,+CAA+C;IAC/C,2CAA2C;IAC3C,gEAAgE;IAChE,sCAAsC;IACtC,IAAI,MAAM,CAAA,GAAA,mBAAK,EAAE;IAGjB,CAAA,GAAA,sBAAQ,EAAE;QACR,qCAAe,GAAG,CAAC;QACnB;QAEA,OAAO;YACL,sDAAsD;YACtD,oDAAoD;YACpD,6DAA6D;YAC7D,qCAAe,MAAM,CAAC;YACtB;QACF;IACF,GAAG,EAAE;IAEL,2FAA2F;IAC3F,IAAI,uBAAuB;IAC3B,IAAI,QAAQ,CA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iBAAiB,OAAO,aAAa,CAAC;QAC1C,IAAI,CAAC,gBACH,OAAO,KAAO;IAElB;IAEA,IAAI,QAAQ;kBACV;iBACA;QACA,aAAa,QAAQ,WAAW;QAChC,UAAU,QAAQ,QAAQ;QAC1B,qBAAqB,QAAQ,mBAAmB;QAChD,GAAG,CAAA,GAAA,oCAAa,EAAE,QAAQ;IAC5B;IAEA,kFAAkF;IAClF,6EAA6E;IAC7E,iEAAiE;IACjE,IAAI,UAAU,QAAQ,OAAO,IAAI,CAAC,QAAQ,QAAQ,GAAG,KAAK,GAAG,CAAC,QAAQ,OAAO,EAAE,QAAQ;IACvF,IAAI,QAAQ;IACZ,IAAI,MAAM,MAAM,GAAG,CAAC,OAAO;iBAAC;QAAS,SAAS,QAAQ,OAAO;IAAA;IAC7D,OAAO,IAAM,MAAM,KAAK,CAAC;AAC3B;AAEA,MAAM,4CAAqB;IACzB,4BAA4B,GAC5B,SAAQ,QAAgB,EAAE,UAAgC,CAAC,CAAC;QAC1D,OAAO,+BAAS,UAAU,WAAW;IACvC;IACA,6BAA6B,GAC7B,UAAS,QAAgB,EAAE,UAAgC,CAAC,CAAC;QAC3D,OAAO,+BAAS,UAAU,YAAY;IACxC;IACA,6BAA6B,GAC7B,UAAS,QAAgB,EAAE,UAAgC,CAAC,CAAC;QAC3D,OAAO,+BAAS,UAAU,YAAY;IACxC;IACA,mCAAmC,GACnC,MAAK,QAAgB,EAAE,UAAgC,CAAC,CAAC;QACvD,OAAO,+BAAS,UAAU,QAAQ;IACpC;AACF","sources":["packages/@react-spectrum/toast/src/ToastContainer.tsx"],"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 {AriaToastRegionProps} from '@react-aria/toast';\nimport {classNames} from '@react-spectrum/utils';\nimport {DOMProps} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {flushSync} from 'react-dom';\nimport React, {ReactElement, useEffect, useMemo, useRef} from 'react';\nimport {SpectrumToastValue, Toast} from './Toast';\nimport toastContainerStyles from './toastContainer.css';\nimport {Toaster} from './Toaster';\nimport {ToastOptions, ToastQueue, useToastQueue} from '@react-stately/toast';\nimport {useSyncExternalStore} from 'use-sync-external-store/shim/index.js';\n\nexport type ToastPlacement = 'top' | 'top end' | 'bottom' | 'bottom end';\n\nexport interface SpectrumToastContainerProps extends AriaToastRegionProps {\n placement?: ToastPlacement\n}\n\nexport interface SpectrumToastOptions extends ToastOptions, DOMProps {\n /** A label for the action button within the toast. */\n actionLabel?: string,\n /** Handler that is called when the action button is pressed. */\n onAction?: () => void,\n /** Whether the toast should automatically close when an action is performed. */\n shouldCloseOnAction?: boolean\n}\n\ntype CloseFunction = () => void;\n\nfunction wrapInViewTransition(fn: () => void): void {\n if ('startViewTransition' in document) {\n document.startViewTransition(() => {\n flushSync(fn);\n }).ready.catch(() => {});\n } else {\n fn();\n }\n}\n\n// There is a single global toast queue instance for the whole app, initialized lazily.\nlet globalToastQueue: ToastQueue<SpectrumToastValue> | null = null;\nfunction getGlobalToastQueue() {\n if (!globalToastQueue) {\n globalToastQueue = new ToastQueue({\n maxVisibleToasts: Infinity,\n wrapUpdate: wrapInViewTransition\n });\n }\n\n return globalToastQueue;\n}\n\n// For testing. Not exported from the package index.\nexport function clearToastQueue(): void {\n globalToastQueue = null;\n}\n\nlet toastProviders = new Set();\nlet subscriptions = new Set<() => void>();\nfunction subscribe(fn: () => void) {\n subscriptions.add(fn);\n return () => subscriptions.delete(fn);\n}\n\nfunction triggerSubscriptions() {\n for (let fn of subscriptions) {\n fn();\n }\n}\n\nfunction getActiveToastContainer() {\n return toastProviders.values().next().value;\n}\n\nfunction useActiveToastContainer() {\n return useSyncExternalStore(subscribe, getActiveToastContainer, getActiveToastContainer);\n}\n\n/**\n * A ToastContainer renders the queued toasts in an application. It should be placed\n * at the root of the app.\n */\nexport function ToastContainer(props: SpectrumToastContainerProps): ReactElement | null {\n // Track all toast provider instances in a set.\n // Only the first one will actually render.\n // We use a ref to do this, since it will have a stable identity\n // over the lifetime of the component.\n let ref = useRef(null);\n\n\n useEffect(() => {\n toastProviders.add(ref);\n triggerSubscriptions();\n\n return () => {\n // Remove this toast provider, and call subscriptions.\n // This will cause all other instances to re-render,\n // and the first one to become the new active toast provider.\n toastProviders.delete(ref);\n triggerSubscriptions();\n };\n }, []);\n\n // Only render if this is the active toast provider instance, and there are visible toasts.\n let activeToastContainer = useActiveToastContainer();\n let state = useToastQueue(getGlobalToastQueue());\n\n let {placement, isCentered} = useMemo(() => {\n let placements = (props.placement ?? 'bottom').split(' ');\n let placement = placements[placements.length - 1];\n let isCentered = placements.length === 1;\n return {placement, isCentered};\n }, [props.placement]);\n\n if (ref === activeToastContainer && state.visibleToasts.length > 0) {\n return (\n <Toaster state={state} {...props}>\n <ol className={classNames(toastContainerStyles, 'spectrum-ToastContainer-list')}>\n {state.visibleToasts.map((toast, index) => {\n let shouldFade = isCentered && index !== 0;\n return (\n <li\n key={toast.key}\n className={classNames(toastContainerStyles, 'spectrum-ToastContainer-listitem')}\n style={{\n viewTransitionName: toast.key,\n viewTransitionClass: classNames(\n toastContainerStyles,\n 'toast',\n placement,\n {'fadeOnly': shouldFade}\n )\n }}>\n <Toast\n toast={toast}\n state={state} />\n </li>\n );\n })}\n </ol>\n </Toaster>\n );\n }\n\n return null;\n}\n\nfunction addToast(children: string, variant: SpectrumToastValue['variant'], options: SpectrumToastOptions = {}) {\n // Dispatch a custom event so that toasts can be intercepted and re-targeted, e.g. when inside an iframe.\n if (typeof CustomEvent !== 'undefined' && typeof window !== 'undefined') {\n let event = new CustomEvent('react-spectrum-toast', {\n cancelable: true,\n bubbles: true,\n detail: {\n children,\n variant,\n options\n }\n });\n\n let shouldContinue = window.dispatchEvent(event);\n if (!shouldContinue) {\n return () => {};\n }\n }\n\n let value = {\n children,\n variant,\n actionLabel: options.actionLabel,\n onAction: options.onAction,\n shouldCloseOnAction: options.shouldCloseOnAction,\n ...filterDOMProps(options)\n };\n\n // Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible\n // Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.\n // It is debatable whether non-actionable toasts would also fail.\n let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;\n let queue = getGlobalToastQueue();\n let key = queue.add(value, {timeout, onClose: options.onClose});\n return () => queue.close(key);\n}\n\nconst SpectrumToastQueue = {\n /** Queues a neutral toast. */\n neutral(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'neutral', options);\n },\n /** Queues a positive toast. */\n positive(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'positive', options);\n },\n /** Queues a negative toast. */\n negative(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'negative', options);\n },\n /** Queues an informational toast. */\n info(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'info', options);\n }\n};\n\nexport {SpectrumToastQueue as ToastQueue};\n"],"names":[],"version":3,"file":"ToastContainer.main.js.map"}
@@ -1,174 +0,0 @@
1
- import {Toast as $7e7a2952509f3a56$export$8d8dc7d5f743331b} from "./Toast.mjs";
2
- import "./toast.69f125e3.css";
3
- import $5lmgI$toastContainer_cssmodulejs from "./toastContainer_css.mjs";
4
- import {Toaster as $e46feef4e4c28a4b$export$fb98e3a2a4cd92d7} from "./Toaster.mjs";
5
- import {classNames as $5lmgI$classNames} from "@react-spectrum/utils";
6
- import {filterDOMProps as $5lmgI$filterDOMProps} from "@react-aria/utils";
7
- import {flushSync as $5lmgI$flushSync} from "react-dom";
8
- import $5lmgI$react, {useRef as $5lmgI$useRef, useEffect as $5lmgI$useEffect, useMemo as $5lmgI$useMemo} from "react";
9
- import {ToastQueue as $5lmgI$ToastQueue, useToastQueue as $5lmgI$useToastQueue} from "@react-stately/toast";
10
- import {useSyncExternalStore as $5lmgI$useSyncExternalStore} from "use-sync-external-store/shim/index.js";
11
-
12
-
13
- function $parcel$interopDefault(a) {
14
- return a && a.__esModule ? a.default : a;
15
- }
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
-
31
-
32
-
33
-
34
-
35
- function $02c59b34bd70955a$var$wrapInViewTransition(fn) {
36
- if ('startViewTransition' in document) document.startViewTransition(()=>{
37
- (0, $5lmgI$flushSync)(fn);
38
- }).ready.catch(()=>{});
39
- else fn();
40
- }
41
- // There is a single global toast queue instance for the whole app, initialized lazily.
42
- let $02c59b34bd70955a$var$globalToastQueue = null;
43
- function $02c59b34bd70955a$var$getGlobalToastQueue() {
44
- if (!$02c59b34bd70955a$var$globalToastQueue) $02c59b34bd70955a$var$globalToastQueue = new (0, $5lmgI$ToastQueue)({
45
- maxVisibleToasts: Infinity,
46
- wrapUpdate: $02c59b34bd70955a$var$wrapInViewTransition
47
- });
48
- return $02c59b34bd70955a$var$globalToastQueue;
49
- }
50
- function $02c59b34bd70955a$export$320311f0e4ecb3ae() {
51
- $02c59b34bd70955a$var$globalToastQueue = null;
52
- }
53
- let $02c59b34bd70955a$var$toastProviders = new Set();
54
- let $02c59b34bd70955a$var$subscriptions = new Set();
55
- function $02c59b34bd70955a$var$subscribe(fn) {
56
- $02c59b34bd70955a$var$subscriptions.add(fn);
57
- return ()=>$02c59b34bd70955a$var$subscriptions.delete(fn);
58
- }
59
- function $02c59b34bd70955a$var$triggerSubscriptions() {
60
- for (let fn of $02c59b34bd70955a$var$subscriptions)fn();
61
- }
62
- function $02c59b34bd70955a$var$getActiveToastContainer() {
63
- return $02c59b34bd70955a$var$toastProviders.values().next().value;
64
- }
65
- function $02c59b34bd70955a$var$useActiveToastContainer() {
66
- return (0, $5lmgI$useSyncExternalStore)($02c59b34bd70955a$var$subscribe, $02c59b34bd70955a$var$getActiveToastContainer, $02c59b34bd70955a$var$getActiveToastContainer);
67
- }
68
- function $02c59b34bd70955a$export$f2815235e76a62b9(props) {
69
- // Track all toast provider instances in a set.
70
- // Only the first one will actually render.
71
- // We use a ref to do this, since it will have a stable identity
72
- // over the lifetime of the component.
73
- let ref = (0, $5lmgI$useRef)(null);
74
- (0, $5lmgI$useEffect)(()=>{
75
- $02c59b34bd70955a$var$toastProviders.add(ref);
76
- $02c59b34bd70955a$var$triggerSubscriptions();
77
- return ()=>{
78
- // Remove this toast provider, and call subscriptions.
79
- // This will cause all other instances to re-render,
80
- // and the first one to become the new active toast provider.
81
- $02c59b34bd70955a$var$toastProviders.delete(ref);
82
- $02c59b34bd70955a$var$triggerSubscriptions();
83
- };
84
- }, []);
85
- // Only render if this is the active toast provider instance, and there are visible toasts.
86
- let activeToastContainer = $02c59b34bd70955a$var$useActiveToastContainer();
87
- let state = (0, $5lmgI$useToastQueue)($02c59b34bd70955a$var$getGlobalToastQueue());
88
- let { placement: placement, isCentered: isCentered } = (0, $5lmgI$useMemo)(()=>{
89
- var _props_placement;
90
- let placements = ((_props_placement = props.placement) !== null && _props_placement !== void 0 ? _props_placement : 'bottom').split(' ');
91
- let placement = placements[placements.length - 1];
92
- let isCentered = placements.length === 1;
93
- return {
94
- placement: placement,
95
- isCentered: isCentered
96
- };
97
- }, [
98
- props.placement
99
- ]);
100
- if (ref === activeToastContainer && state.visibleToasts.length > 0) return /*#__PURE__*/ (0, $5lmgI$react).createElement((0, $e46feef4e4c28a4b$export$fb98e3a2a4cd92d7), {
101
- state: state,
102
- ...props
103
- }, /*#__PURE__*/ (0, $5lmgI$react).createElement("ol", {
104
- className: (0, $5lmgI$classNames)((0, ($parcel$interopDefault($5lmgI$toastContainer_cssmodulejs))), 'spectrum-ToastContainer-list')
105
- }, state.visibleToasts.map((toast, index)=>{
106
- let shouldFade = isCentered && index !== 0;
107
- return /*#__PURE__*/ (0, $5lmgI$react).createElement("li", {
108
- key: toast.key,
109
- className: (0, $5lmgI$classNames)((0, ($parcel$interopDefault($5lmgI$toastContainer_cssmodulejs))), 'spectrum-ToastContainer-listitem'),
110
- style: {
111
- viewTransitionName: toast.key,
112
- viewTransitionClass: (0, $5lmgI$classNames)((0, ($parcel$interopDefault($5lmgI$toastContainer_cssmodulejs))), 'toast', placement, {
113
- 'fadeOnly': shouldFade
114
- })
115
- }
116
- }, /*#__PURE__*/ (0, $5lmgI$react).createElement((0, $7e7a2952509f3a56$export$8d8dc7d5f743331b), {
117
- toast: toast,
118
- state: state
119
- }));
120
- })));
121
- return null;
122
- }
123
- function $02c59b34bd70955a$var$addToast(children, variant, options = {}) {
124
- // Dispatch a custom event so that toasts can be intercepted and re-targeted, e.g. when inside an iframe.
125
- if (typeof CustomEvent !== 'undefined' && typeof window !== 'undefined') {
126
- let event = new CustomEvent('react-spectrum-toast', {
127
- cancelable: true,
128
- bubbles: true,
129
- detail: {
130
- children: children,
131
- variant: variant,
132
- options: options
133
- }
134
- });
135
- let shouldContinue = window.dispatchEvent(event);
136
- if (!shouldContinue) return ()=>{};
137
- }
138
- let value = {
139
- children: children,
140
- variant: variant,
141
- actionLabel: options.actionLabel,
142
- onAction: options.onAction,
143
- shouldCloseOnAction: options.shouldCloseOnAction,
144
- ...(0, $5lmgI$filterDOMProps)(options)
145
- };
146
- // Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible
147
- // Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.
148
- // It is debatable whether non-actionable toasts would also fail.
149
- let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;
150
- let queue = $02c59b34bd70955a$var$getGlobalToastQueue();
151
- let key = queue.add(value, {
152
- timeout: timeout,
153
- onClose: options.onClose
154
- });
155
- return ()=>queue.close(key);
156
- }
157
- const $02c59b34bd70955a$export$f1f8569633bbbec4 = {
158
- /** Queues a neutral toast. */ neutral (children, options = {}) {
159
- return $02c59b34bd70955a$var$addToast(children, 'neutral', options);
160
- },
161
- /** Queues a positive toast. */ positive (children, options = {}) {
162
- return $02c59b34bd70955a$var$addToast(children, 'positive', options);
163
- },
164
- /** Queues a negative toast. */ negative (children, options = {}) {
165
- return $02c59b34bd70955a$var$addToast(children, 'negative', options);
166
- },
167
- /** Queues an informational toast. */ info (children, options = {}) {
168
- return $02c59b34bd70955a$var$addToast(children, 'info', options);
169
- }
170
- };
171
-
172
-
173
- export {$02c59b34bd70955a$export$320311f0e4ecb3ae as clearToastQueue, $02c59b34bd70955a$export$f2815235e76a62b9 as ToastContainer, $02c59b34bd70955a$export$f1f8569633bbbec4 as ToastQueue};
174
- //# sourceMappingURL=ToastContainer.module.js.map
@@ -1,174 +0,0 @@
1
- import {Toast as $7e7a2952509f3a56$export$8d8dc7d5f743331b} from "./Toast.module.js";
2
- import "./toast.69f125e3.css";
3
- import $5lmgI$toastContainer_cssmodulejs from "./toastContainer_css.module.js";
4
- import {Toaster as $e46feef4e4c28a4b$export$fb98e3a2a4cd92d7} from "./Toaster.module.js";
5
- import {classNames as $5lmgI$classNames} from "@react-spectrum/utils";
6
- import {filterDOMProps as $5lmgI$filterDOMProps} from "@react-aria/utils";
7
- import {flushSync as $5lmgI$flushSync} from "react-dom";
8
- import $5lmgI$react, {useRef as $5lmgI$useRef, useEffect as $5lmgI$useEffect, useMemo as $5lmgI$useMemo} from "react";
9
- import {ToastQueue as $5lmgI$ToastQueue, useToastQueue as $5lmgI$useToastQueue} from "@react-stately/toast";
10
- import {useSyncExternalStore as $5lmgI$useSyncExternalStore} from "use-sync-external-store/shim/index.js";
11
-
12
-
13
- function $parcel$interopDefault(a) {
14
- return a && a.__esModule ? a.default : a;
15
- }
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
-
31
-
32
-
33
-
34
-
35
- function $02c59b34bd70955a$var$wrapInViewTransition(fn) {
36
- if ('startViewTransition' in document) document.startViewTransition(()=>{
37
- (0, $5lmgI$flushSync)(fn);
38
- }).ready.catch(()=>{});
39
- else fn();
40
- }
41
- // There is a single global toast queue instance for the whole app, initialized lazily.
42
- let $02c59b34bd70955a$var$globalToastQueue = null;
43
- function $02c59b34bd70955a$var$getGlobalToastQueue() {
44
- if (!$02c59b34bd70955a$var$globalToastQueue) $02c59b34bd70955a$var$globalToastQueue = new (0, $5lmgI$ToastQueue)({
45
- maxVisibleToasts: Infinity,
46
- wrapUpdate: $02c59b34bd70955a$var$wrapInViewTransition
47
- });
48
- return $02c59b34bd70955a$var$globalToastQueue;
49
- }
50
- function $02c59b34bd70955a$export$320311f0e4ecb3ae() {
51
- $02c59b34bd70955a$var$globalToastQueue = null;
52
- }
53
- let $02c59b34bd70955a$var$toastProviders = new Set();
54
- let $02c59b34bd70955a$var$subscriptions = new Set();
55
- function $02c59b34bd70955a$var$subscribe(fn) {
56
- $02c59b34bd70955a$var$subscriptions.add(fn);
57
- return ()=>$02c59b34bd70955a$var$subscriptions.delete(fn);
58
- }
59
- function $02c59b34bd70955a$var$triggerSubscriptions() {
60
- for (let fn of $02c59b34bd70955a$var$subscriptions)fn();
61
- }
62
- function $02c59b34bd70955a$var$getActiveToastContainer() {
63
- return $02c59b34bd70955a$var$toastProviders.values().next().value;
64
- }
65
- function $02c59b34bd70955a$var$useActiveToastContainer() {
66
- return (0, $5lmgI$useSyncExternalStore)($02c59b34bd70955a$var$subscribe, $02c59b34bd70955a$var$getActiveToastContainer, $02c59b34bd70955a$var$getActiveToastContainer);
67
- }
68
- function $02c59b34bd70955a$export$f2815235e76a62b9(props) {
69
- // Track all toast provider instances in a set.
70
- // Only the first one will actually render.
71
- // We use a ref to do this, since it will have a stable identity
72
- // over the lifetime of the component.
73
- let ref = (0, $5lmgI$useRef)(null);
74
- (0, $5lmgI$useEffect)(()=>{
75
- $02c59b34bd70955a$var$toastProviders.add(ref);
76
- $02c59b34bd70955a$var$triggerSubscriptions();
77
- return ()=>{
78
- // Remove this toast provider, and call subscriptions.
79
- // This will cause all other instances to re-render,
80
- // and the first one to become the new active toast provider.
81
- $02c59b34bd70955a$var$toastProviders.delete(ref);
82
- $02c59b34bd70955a$var$triggerSubscriptions();
83
- };
84
- }, []);
85
- // Only render if this is the active toast provider instance, and there are visible toasts.
86
- let activeToastContainer = $02c59b34bd70955a$var$useActiveToastContainer();
87
- let state = (0, $5lmgI$useToastQueue)($02c59b34bd70955a$var$getGlobalToastQueue());
88
- let { placement: placement, isCentered: isCentered } = (0, $5lmgI$useMemo)(()=>{
89
- var _props_placement;
90
- let placements = ((_props_placement = props.placement) !== null && _props_placement !== void 0 ? _props_placement : 'bottom').split(' ');
91
- let placement = placements[placements.length - 1];
92
- let isCentered = placements.length === 1;
93
- return {
94
- placement: placement,
95
- isCentered: isCentered
96
- };
97
- }, [
98
- props.placement
99
- ]);
100
- if (ref === activeToastContainer && state.visibleToasts.length > 0) return /*#__PURE__*/ (0, $5lmgI$react).createElement((0, $e46feef4e4c28a4b$export$fb98e3a2a4cd92d7), {
101
- state: state,
102
- ...props
103
- }, /*#__PURE__*/ (0, $5lmgI$react).createElement("ol", {
104
- className: (0, $5lmgI$classNames)((0, ($parcel$interopDefault($5lmgI$toastContainer_cssmodulejs))), 'spectrum-ToastContainer-list')
105
- }, state.visibleToasts.map((toast, index)=>{
106
- let shouldFade = isCentered && index !== 0;
107
- return /*#__PURE__*/ (0, $5lmgI$react).createElement("li", {
108
- key: toast.key,
109
- className: (0, $5lmgI$classNames)((0, ($parcel$interopDefault($5lmgI$toastContainer_cssmodulejs))), 'spectrum-ToastContainer-listitem'),
110
- style: {
111
- viewTransitionName: toast.key,
112
- viewTransitionClass: (0, $5lmgI$classNames)((0, ($parcel$interopDefault($5lmgI$toastContainer_cssmodulejs))), 'toast', placement, {
113
- 'fadeOnly': shouldFade
114
- })
115
- }
116
- }, /*#__PURE__*/ (0, $5lmgI$react).createElement((0, $7e7a2952509f3a56$export$8d8dc7d5f743331b), {
117
- toast: toast,
118
- state: state
119
- }));
120
- })));
121
- return null;
122
- }
123
- function $02c59b34bd70955a$var$addToast(children, variant, options = {}) {
124
- // Dispatch a custom event so that toasts can be intercepted and re-targeted, e.g. when inside an iframe.
125
- if (typeof CustomEvent !== 'undefined' && typeof window !== 'undefined') {
126
- let event = new CustomEvent('react-spectrum-toast', {
127
- cancelable: true,
128
- bubbles: true,
129
- detail: {
130
- children: children,
131
- variant: variant,
132
- options: options
133
- }
134
- });
135
- let shouldContinue = window.dispatchEvent(event);
136
- if (!shouldContinue) return ()=>{};
137
- }
138
- let value = {
139
- children: children,
140
- variant: variant,
141
- actionLabel: options.actionLabel,
142
- onAction: options.onAction,
143
- shouldCloseOnAction: options.shouldCloseOnAction,
144
- ...(0, $5lmgI$filterDOMProps)(options)
145
- };
146
- // Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible
147
- // Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.
148
- // It is debatable whether non-actionable toasts would also fail.
149
- let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;
150
- let queue = $02c59b34bd70955a$var$getGlobalToastQueue();
151
- let key = queue.add(value, {
152
- timeout: timeout,
153
- onClose: options.onClose
154
- });
155
- return ()=>queue.close(key);
156
- }
157
- const $02c59b34bd70955a$export$f1f8569633bbbec4 = {
158
- /** Queues a neutral toast. */ neutral (children, options = {}) {
159
- return $02c59b34bd70955a$var$addToast(children, 'neutral', options);
160
- },
161
- /** Queues a positive toast. */ positive (children, options = {}) {
162
- return $02c59b34bd70955a$var$addToast(children, 'positive', options);
163
- },
164
- /** Queues a negative toast. */ negative (children, options = {}) {
165
- return $02c59b34bd70955a$var$addToast(children, 'negative', options);
166
- },
167
- /** Queues an informational toast. */ info (children, options = {}) {
168
- return $02c59b34bd70955a$var$addToast(children, 'info', options);
169
- }
170
- };
171
-
172
-
173
- export {$02c59b34bd70955a$export$320311f0e4ecb3ae as clearToastQueue, $02c59b34bd70955a$export$f2815235e76a62b9 as ToastContainer, $02c59b34bd70955a$export$f1f8569633bbbec4 as ToastQueue};
174
- //# sourceMappingURL=ToastContainer.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AA+BD,SAAS,2CAAqB,EAAc;IAC1C,IAAI,yBAAyB,UAC3B,SAAS,mBAAmB,CAAC;QAC3B,CAAA,GAAA,gBAAQ,EAAE;IACZ,GAAG,KAAK,CAAC,KAAK,CAAC,KAAO;SAEtB;AAEJ;AAEA,uFAAuF;AACvF,IAAI,yCAA0D;AAC9D,SAAS;IACP,IAAI,CAAC,wCACH,yCAAmB,IAAI,CAAA,GAAA,iBAAS,EAAE;QAChC,kBAAkB;QAClB,YAAY;IACd;IAGF,OAAO;AACT;AAGO,SAAS;IACd,yCAAmB;AACrB;AAEA,IAAI,uCAAiB,IAAI;AACzB,IAAI,sCAAgB,IAAI;AACxB,SAAS,gCAAU,EAAc;IAC/B,oCAAc,GAAG,CAAC;IAClB,OAAO,IAAM,oCAAc,MAAM,CAAC;AACpC;AAEA,SAAS;IACP,KAAK,IA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QAC3D,OAAO,+BAAS,UAAU,YAAY;IACxC;IACA,6BAA6B,GAC7B,UAAS,QAAgB,EAAE,UAAgC,CAAC,CAAC;QAC3D,OAAO,+BAAS,UAAU,YAAY;IACxC;IACA,mCAAmC,GACnC,MAAK,QAAgB,EAAE,UAAgC,CAAC,CAAC;QACvD,OAAO,+BAAS,UAAU,QAAQ;IACpC;AACF","sources":["packages/@react-spectrum/toast/src/ToastContainer.tsx"],"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 {AriaToastRegionProps} from '@react-aria/toast';\nimport {classNames} from '@react-spectrum/utils';\nimport {DOMProps} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {flushSync} from 'react-dom';\nimport React, {ReactElement, useEffect, useMemo, useRef} from 'react';\nimport {SpectrumToastValue, Toast} from './Toast';\nimport toastContainerStyles from './toastContainer.css';\nimport {Toaster} from './Toaster';\nimport {ToastOptions, ToastQueue, useToastQueue} from '@react-stately/toast';\nimport {useSyncExternalStore} from 'use-sync-external-store/shim/index.js';\n\nexport type ToastPlacement = 'top' | 'top end' | 'bottom' | 'bottom end';\n\nexport interface SpectrumToastContainerProps extends AriaToastRegionProps {\n placement?: ToastPlacement\n}\n\nexport interface SpectrumToastOptions extends ToastOptions, DOMProps {\n /** A label for the action button within the toast. */\n actionLabel?: string,\n /** Handler that is called when the action button is pressed. */\n onAction?: () => void,\n /** Whether the toast should automatically close when an action is performed. */\n shouldCloseOnAction?: boolean\n}\n\ntype CloseFunction = () => void;\n\nfunction wrapInViewTransition(fn: () => void): void {\n if ('startViewTransition' in document) {\n document.startViewTransition(() => {\n flushSync(fn);\n }).ready.catch(() => {});\n } else {\n fn();\n }\n}\n\n// There is a single global toast queue instance for the whole app, initialized lazily.\nlet globalToastQueue: ToastQueue<SpectrumToastValue> | null = null;\nfunction getGlobalToastQueue() {\n if (!globalToastQueue) {\n globalToastQueue = new ToastQueue({\n maxVisibleToasts: Infinity,\n wrapUpdate: wrapInViewTransition\n });\n }\n\n return globalToastQueue;\n}\n\n// For testing. Not exported from the package index.\nexport function clearToastQueue(): void {\n globalToastQueue = null;\n}\n\nlet toastProviders = new Set();\nlet subscriptions = new Set<() => void>();\nfunction subscribe(fn: () => void) {\n subscriptions.add(fn);\n return () => subscriptions.delete(fn);\n}\n\nfunction triggerSubscriptions() {\n for (let fn of subscriptions) {\n fn();\n }\n}\n\nfunction getActiveToastContainer() {\n return toastProviders.values().next().value;\n}\n\nfunction useActiveToastContainer() {\n return useSyncExternalStore(subscribe, getActiveToastContainer, getActiveToastContainer);\n}\n\n/**\n * A ToastContainer renders the queued toasts in an application. It should be placed\n * at the root of the app.\n */\nexport function ToastContainer(props: SpectrumToastContainerProps): ReactElement | null {\n // Track all toast provider instances in a set.\n // Only the first one will actually render.\n // We use a ref to do this, since it will have a stable identity\n // over the lifetime of the component.\n let ref = useRef(null);\n\n\n useEffect(() => {\n toastProviders.add(ref);\n triggerSubscriptions();\n\n return () => {\n // Remove this toast provider, and call subscriptions.\n // This will cause all other instances to re-render,\n // and the first one to become the new active toast provider.\n toastProviders.delete(ref);\n triggerSubscriptions();\n };\n }, []);\n\n // Only render if this is the active toast provider instance, and there are visible toasts.\n let activeToastContainer = useActiveToastContainer();\n let state = useToastQueue(getGlobalToastQueue());\n\n let {placement, isCentered} = useMemo(() => {\n let placements = (props.placement ?? 'bottom').split(' ');\n let placement = placements[placements.length - 1];\n let isCentered = placements.length === 1;\n return {placement, isCentered};\n }, [props.placement]);\n\n if (ref === activeToastContainer && state.visibleToasts.length > 0) {\n return (\n <Toaster state={state} {...props}>\n <ol className={classNames(toastContainerStyles, 'spectrum-ToastContainer-list')}>\n {state.visibleToasts.map((toast, index) => {\n let shouldFade = isCentered && index !== 0;\n return (\n <li\n key={toast.key}\n className={classNames(toastContainerStyles, 'spectrum-ToastContainer-listitem')}\n style={{\n viewTransitionName: toast.key,\n viewTransitionClass: classNames(\n toastContainerStyles,\n 'toast',\n placement,\n {'fadeOnly': shouldFade}\n )\n }}>\n <Toast\n toast={toast}\n state={state} />\n </li>\n );\n })}\n </ol>\n </Toaster>\n );\n }\n\n return null;\n}\n\nfunction addToast(children: string, variant: SpectrumToastValue['variant'], options: SpectrumToastOptions = {}) {\n // Dispatch a custom event so that toasts can be intercepted and re-targeted, e.g. when inside an iframe.\n if (typeof CustomEvent !== 'undefined' && typeof window !== 'undefined') {\n let event = new CustomEvent('react-spectrum-toast', {\n cancelable: true,\n bubbles: true,\n detail: {\n children,\n variant,\n options\n }\n });\n\n let shouldContinue = window.dispatchEvent(event);\n if (!shouldContinue) {\n return () => {};\n }\n }\n\n let value = {\n children,\n variant,\n actionLabel: options.actionLabel,\n onAction: options.onAction,\n shouldCloseOnAction: options.shouldCloseOnAction,\n ...filterDOMProps(options)\n };\n\n // Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible\n // Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.\n // It is debatable whether non-actionable toasts would also fail.\n let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;\n let queue = getGlobalToastQueue();\n let key = queue.add(value, {timeout, onClose: options.onClose});\n return () => queue.close(key);\n}\n\nconst SpectrumToastQueue = {\n /** Queues a neutral toast. */\n neutral(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'neutral', options);\n },\n /** Queues a positive toast. */\n positive(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'positive', options);\n },\n /** Queues a negative toast. */\n negative(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'negative', options);\n },\n /** Queues an informational toast. */\n info(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'info', options);\n }\n};\n\nexport {SpectrumToastQueue as ToastQueue};\n"],"names":[],"version":3,"file":"ToastContainer.module.js.map"}
@@ -1,78 +0,0 @@
1
- require("./toast.69f125e3.css");
2
- var $e20782d0579ed886$exports = require("./toastContainer_css.main.js");
3
- var $acAHv$reactariatoast = require("@react-aria/toast");
4
- var $acAHv$reactspectrumutils = require("@react-spectrum/utils");
5
- var $acAHv$reactariafocus = require("@react-aria/focus");
6
- var $acAHv$reactariautils = require("@react-aria/utils");
7
- var $acAHv$reactspectrumprovider = require("@react-spectrum/provider");
8
- var $acAHv$react = require("react");
9
- var $acAHv$reactdom = require("react-dom");
10
- var $acAHv$reactariaoverlays = require("@react-aria/overlays");
11
-
12
-
13
- function $parcel$interopDefault(a) {
14
- return a && a.__esModule ? a.default : a;
15
- }
16
-
17
- function $parcel$export(e, n, v, s) {
18
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
19
- }
20
-
21
- $parcel$export(module.exports, "Toaster", () => $5b9f2c86c1b1395c$export$fb98e3a2a4cd92d7);
22
- /*
23
- * Copyright 2020 Adobe. All rights reserved.
24
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
25
- * you may not use this file except in compliance with the License. You may obtain a copy
26
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
27
- *
28
- * Unless required by applicable law or agreed to in writing, software distributed under
29
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
30
- * OF ANY KIND, either express or implied. See the License for the specific language
31
- * governing permissions and limitations under the License.
32
- */
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
- const $5b9f2c86c1b1395c$export$9194c0aa0cd7a9ff = /*#__PURE__*/ (0, $acAHv$react.createContext)(false);
42
- function $5b9f2c86c1b1395c$export$fb98e3a2a4cd92d7(props) {
43
- let { children: children, state: state } = props;
44
- let ref = (0, $acAHv$react.useRef)(null);
45
- let { regionProps: regionProps } = (0, $acAHv$reactariatoast.useToastRegion)(props, state, ref);
46
- let { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $acAHv$reactariafocus.useFocusRing)();
47
- let { getContainer: getContainer } = (0, $acAHv$reactariaoverlays.useUNSAFE_PortalContext)();
48
- let [position, placement] = (0, $acAHv$react.useMemo)(()=>{
49
- var _props_placement;
50
- let [pos = 'bottom', place = 'center'] = ((_props_placement = props.placement) === null || _props_placement === void 0 ? void 0 : _props_placement.split(' ')) || [];
51
- return [
52
- pos,
53
- place
54
- ];
55
- }, [
56
- props.placement
57
- ]);
58
- let contents = /*#__PURE__*/ (0, ($parcel$interopDefault($acAHv$react))).createElement((0, $acAHv$reactspectrumprovider.Provider), {
59
- UNSAFE_style: {
60
- background: 'transparent'
61
- }
62
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($acAHv$react))).createElement((0, $acAHv$reactariafocus.FocusScope), null, /*#__PURE__*/ (0, ($parcel$interopDefault($acAHv$react))).createElement($5b9f2c86c1b1395c$export$9194c0aa0cd7a9ff.Provider, {
63
- value: isFocusVisible
64
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($acAHv$react))).createElement("div", {
65
- ...(0, $acAHv$reactariautils.mergeProps)(regionProps, focusProps),
66
- ref: ref,
67
- "data-position": position,
68
- "data-placement": placement,
69
- className: (0, $acAHv$reactspectrumutils.classNames)((0, ($parcel$interopDefault($e20782d0579ed886$exports))), 'react-spectrum-ToastContainer', {
70
- 'focus-ring': isFocusVisible
71
- })
72
- }, children))));
73
- var _getContainer;
74
- return /*#__PURE__*/ (0, ($parcel$interopDefault($acAHv$reactdom))).createPortal(contents, (_getContainer = getContainer === null || getContainer === void 0 ? void 0 : getContainer()) !== null && _getContainer !== void 0 ? _getContainer : document.body);
75
- }
76
-
77
-
78
- //# sourceMappingURL=Toaster.main.js.map