@react-spectrum/toast 3.0.0-beta.15 → 3.0.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist/ToastContainer.main.js +3 -4
- package/dist/ToastContainer.main.js.map +1 -1
- package/dist/ToastContainer.mjs +3 -4
- package/dist/ToastContainer.module.js +3 -4
- package/dist/ToastContainer.module.js.map +1 -1
- package/dist/Toaster.main.js +1 -1
- package/dist/Toaster.main.js.map +1 -1
- package/dist/Toaster.mjs +1 -1
- package/dist/Toaster.module.js +1 -1
- package/dist/Toaster.module.js.map +1 -1
- package/dist/toastContainer_css.main.js.map +1 -1
- package/dist/toastContainer_css.module.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -15
- package/src/ToastContainer.tsx +5 -5
- package/src/Toaster.tsx +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2019 Adobe
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -69,8 +69,7 @@ function $56cdf77f3be52eaf$export$f2815235e76a62b9(props) {
|
|
|
69
69
|
// Only the first one will actually render.
|
|
70
70
|
// We use a ref to do this, since it will have a stable identity
|
|
71
71
|
// over the lifetime of the component.
|
|
72
|
-
let ref = (0, $5IVGU$react.useRef)(
|
|
73
|
-
// eslint-disable-next-line arrow-body-style
|
|
72
|
+
let ref = (0, $5IVGU$react.useRef)(null);
|
|
74
73
|
(0, $5IVGU$react.useEffect)(()=>{
|
|
75
74
|
$56cdf77f3be52eaf$var$toastProviders.add(ref);
|
|
76
75
|
$56cdf77f3be52eaf$var$triggerSubscriptions();
|
|
@@ -115,7 +114,7 @@ function $56cdf77f3be52eaf$var$addToast(children, variant, options = {}) {
|
|
|
115
114
|
}
|
|
116
115
|
});
|
|
117
116
|
let shouldContinue = window.dispatchEvent(event);
|
|
118
|
-
if (!shouldContinue) return;
|
|
117
|
+
if (!shouldContinue) return ()=>{};
|
|
119
118
|
}
|
|
120
119
|
let value = {
|
|
121
120
|
children: children,
|
|
@@ -128,7 +127,7 @@ function $56cdf77f3be52eaf$var$addToast(children, variant, options = {}) {
|
|
|
128
127
|
// Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible
|
|
129
128
|
// Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.
|
|
130
129
|
// It is debatable whether non-actionable toasts would also fail.
|
|
131
|
-
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) :
|
|
130
|
+
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;
|
|
132
131
|
let queue = $56cdf77f3be52eaf$var$getGlobalToastQueue();
|
|
133
132
|
let key = queue.add(value, {
|
|
134
133
|
timeout: timeout,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AA0BD,uFAAuF;AACvF,IAAI,yCAA0D;AAC9D,SAAS;IACP,IAAI,CAAC,wCACH,yCAAmB,IAAI,CAAA,GAAA,mCAAS,EAAE;QAChC,kBAAkB;QAClB,kBAAkB;IACpB;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,q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G,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 React, {ReactElement, useEffect, 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 interface SpectrumToastContainerProps extends AriaToastRegionProps {}\n\nexport interface SpectrumToastOptions extends Omit<ToastOptions, 'priority'>, 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\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 hasExitAnimation: true\n });\n }\n\n return globalToastQueue;\n}\n\n// For testing. Not exported from the package index.\nexport function clearToastQueue() {\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 // When this toast provider unmounts, reset all animations so that\n // when the new toast provider renders, it is seamless.\n for (let toast of getGlobalToastQueue().visibleToasts) {\n toast.animation = null;\n }\n\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 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.slice().reverse().map((toast) => (\n <li\n key={toast.key}\n className={classNames(toastContainerStyles, 'spectrum-ToastContainer-listitem')}>\n <Toast\n toast={toast}\n state={state} />\n </li>\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"}
|
package/dist/ToastContainer.mjs
CHANGED
|
@@ -62,8 +62,7 @@ function $02c59b34bd70955a$export$f2815235e76a62b9(props) {
|
|
|
62
62
|
// Only the first one will actually render.
|
|
63
63
|
// We use a ref to do this, since it will have a stable identity
|
|
64
64
|
// over the lifetime of the component.
|
|
65
|
-
let ref = (0, $5lmgI$useRef)(
|
|
66
|
-
// eslint-disable-next-line arrow-body-style
|
|
65
|
+
let ref = (0, $5lmgI$useRef)(null);
|
|
67
66
|
(0, $5lmgI$useEffect)(()=>{
|
|
68
67
|
$02c59b34bd70955a$var$toastProviders.add(ref);
|
|
69
68
|
$02c59b34bd70955a$var$triggerSubscriptions();
|
|
@@ -108,7 +107,7 @@ function $02c59b34bd70955a$var$addToast(children, variant, options = {}) {
|
|
|
108
107
|
}
|
|
109
108
|
});
|
|
110
109
|
let shouldContinue = window.dispatchEvent(event);
|
|
111
|
-
if (!shouldContinue) return;
|
|
110
|
+
if (!shouldContinue) return ()=>{};
|
|
112
111
|
}
|
|
113
112
|
let value = {
|
|
114
113
|
children: children,
|
|
@@ -121,7 +120,7 @@ function $02c59b34bd70955a$var$addToast(children, variant, options = {}) {
|
|
|
121
120
|
// Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible
|
|
122
121
|
// Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.
|
|
123
122
|
// It is debatable whether non-actionable toasts would also fail.
|
|
124
|
-
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) :
|
|
123
|
+
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;
|
|
125
124
|
let queue = $02c59b34bd70955a$var$getGlobalToastQueue();
|
|
126
125
|
let key = queue.add(value, {
|
|
127
126
|
timeout: timeout,
|
|
@@ -62,8 +62,7 @@ function $02c59b34bd70955a$export$f2815235e76a62b9(props) {
|
|
|
62
62
|
// Only the first one will actually render.
|
|
63
63
|
// We use a ref to do this, since it will have a stable identity
|
|
64
64
|
// over the lifetime of the component.
|
|
65
|
-
let ref = (0, $5lmgI$useRef)(
|
|
66
|
-
// eslint-disable-next-line arrow-body-style
|
|
65
|
+
let ref = (0, $5lmgI$useRef)(null);
|
|
67
66
|
(0, $5lmgI$useEffect)(()=>{
|
|
68
67
|
$02c59b34bd70955a$var$toastProviders.add(ref);
|
|
69
68
|
$02c59b34bd70955a$var$triggerSubscriptions();
|
|
@@ -108,7 +107,7 @@ function $02c59b34bd70955a$var$addToast(children, variant, options = {}) {
|
|
|
108
107
|
}
|
|
109
108
|
});
|
|
110
109
|
let shouldContinue = window.dispatchEvent(event);
|
|
111
|
-
if (!shouldContinue) return;
|
|
110
|
+
if (!shouldContinue) return ()=>{};
|
|
112
111
|
}
|
|
113
112
|
let value = {
|
|
114
113
|
children: children,
|
|
@@ -121,7 +120,7 @@ function $02c59b34bd70955a$var$addToast(children, variant, options = {}) {
|
|
|
121
120
|
// Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible
|
|
122
121
|
// Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.
|
|
123
122
|
// It is debatable whether non-actionable toasts would also fail.
|
|
124
|
-
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) :
|
|
123
|
+
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;
|
|
125
124
|
let queue = $02c59b34bd70955a$var$getGlobalToastQueue();
|
|
126
125
|
let key = queue.add(value, {
|
|
127
126
|
timeout: timeout,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AA0BD,uFAAuF;AACvF,IAAI,yCAA0D;AAC9D,SAAS;IACP,IAAI,CAAC,wCACH,yCAAmB,IAAI,CAAA,GAAA,iBAAS,EAAE;QAChC,kBAAkB;QAClB,kBAAkB;IACpB;IAGF,OAA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D,GAAG,CAAA,GAAA,qBAAa,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 React, {ReactElement, useEffect, 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 interface SpectrumToastContainerProps extends AriaToastRegionProps {}\n\nexport interface SpectrumToastOptions extends Omit<ToastOptions, 'priority'>, 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\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 hasExitAnimation: true\n });\n }\n\n return globalToastQueue;\n}\n\n// For testing. Not exported from the package index.\nexport function clearToastQueue() {\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 // When this toast provider unmounts, reset all animations so that\n // when the new toast provider renders, it is seamless.\n for (let toast of getGlobalToastQueue().visibleToasts) {\n toast.animation = null;\n }\n\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 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.slice().reverse().map((toast) => (\n <li\n key={toast.key}\n className={classNames(toastContainerStyles, 'spectrum-ToastContainer-listitem')}>\n <Toast\n toast={toast}\n state={state} />\n </li>\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"}
|
package/dist/Toaster.main.js
CHANGED
|
@@ -41,7 +41,7 @@ $parcel$export(module.exports, "Toaster", () => $5b9f2c86c1b1395c$export$fb98e3a
|
|
|
41
41
|
const $5b9f2c86c1b1395c$export$9194c0aa0cd7a9ff = /*#__PURE__*/ (0, $acAHv$react.createContext)(false);
|
|
42
42
|
function $5b9f2c86c1b1395c$export$fb98e3a2a4cd92d7(props) {
|
|
43
43
|
let { children: children, state: state } = props;
|
|
44
|
-
let ref = (0, $acAHv$react.useRef)(
|
|
44
|
+
let ref = (0, $acAHv$react.useRef)(null);
|
|
45
45
|
let { regionProps: regionProps } = (0, $acAHv$reactariatoast.useToastRegion)(props, state, ref);
|
|
46
46
|
let { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $acAHv$reactariafocus.useFocusRing)();
|
|
47
47
|
let { getContainer: getContainer } = (0, $acAHv$reactariaoverlays.useUNSTABLE_PortalContext)();
|
package/dist/Toaster.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAkBM,MAAM,0DAAiB,CAAA,GAAA,0BAAY,EAAE;AAErC,SAAS,0CAAQ,KAA0B;IAChD,IAAI,YACF,QAAQ,SACR,KAAK,EACN,GAAG;IAEJ,IAAI,MAAM,CAAA,GAAA,mBAAK,EAAE;IACjB,IAAI,eAAC,WAAW,EAAC,GAAG,CAAA,GAAA,oCAAa,EAAE,OAAO,OAAO;IACjD,IAAI,cAAC,UAAU,kBAAE,cAAc,EAAC,GAAG,CAAA,GAAA,kCAAW;IAC9C,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,kDAAwB;IAE7C,IAAI,yBACF,0DAAC,CAAA,GAAA,qCAAO;QAAE,cAAc;YAAC,YAAY;QAAa;qBAChD,0DAAC,CAAA,GAAA,gCAAS,uBACR,0DAAC,0CAAe,QAAQ;QAAC,OAAO;qBAC9B,0DAAC;QACE,GAAG,CAAA,GAAA,gCAAS,EAAE,aAAa,WAAW;QACvC,KAAK;QACL,iBAAc;QACd,kBAAe;QACf,WAAW,CAAA,GAAA,oCAAS,EAClB,CAAA,GAAA,mDAAmB,GACnB,iCACA;YAAC,cAAc;QAAc;OAE9B;QAO4B;IAAvC,qBAAO,CAAA,GAAA,yCAAO,EAAE,YAAY,CAAC,UAAU,CAAA,gBAAA,yBAAA,mCAAA,4BAAA,2BAAA,gBAAoB,SAAS,IAAI;AAC1E","sources":["packages/@react-spectrum/toast/src/Toaster.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, useToastRegion} from '@react-aria/toast';\nimport {classNames} from '@react-spectrum/utils';\nimport {FocusScope, useFocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport {Provider} from '@react-spectrum/provider';\nimport React, {createContext, ReactElement, ReactNode, useRef} from 'react';\nimport ReactDOM from 'react-dom';\nimport toastContainerStyles from './toastContainer.css';\nimport {ToastState} from '@react-stately/toast';\nimport {useUNSTABLE_PortalContext} from '@react-aria/overlays';\n\ninterface ToastContainerProps extends AriaToastRegionProps {\n children: ReactNode,\n state: ToastState<unknown>\n}\n\nexport const ToasterContext = createContext(false);\n\nexport function Toaster(props: ToastContainerProps): ReactElement {\n let {\n children,\n state\n } = props;\n\n let ref = useRef(
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAkBM,MAAM,0DAAiB,CAAA,GAAA,0BAAY,EAAE;AAErC,SAAS,0CAAQ,KAA0B;IAChD,IAAI,YACF,QAAQ,SACR,KAAK,EACN,GAAG;IAEJ,IAAI,MAAM,CAAA,GAAA,mBAAK,EAAE;IACjB,IAAI,eAAC,WAAW,EAAC,GAAG,CAAA,GAAA,oCAAa,EAAE,OAAO,OAAO;IACjD,IAAI,cAAC,UAAU,kBAAE,cAAc,EAAC,GAAG,CAAA,GAAA,kCAAW;IAC9C,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,kDAAwB;IAE7C,IAAI,yBACF,0DAAC,CAAA,GAAA,qCAAO;QAAE,cAAc;YAAC,YAAY;QAAa;qBAChD,0DAAC,CAAA,GAAA,gCAAS,uBACR,0DAAC,0CAAe,QAAQ;QAAC,OAAO;qBAC9B,0DAAC;QACE,GAAG,CAAA,GAAA,gCAAS,EAAE,aAAa,WAAW;QACvC,KAAK;QACL,iBAAc;QACd,kBAAe;QACf,WAAW,CAAA,GAAA,oCAAS,EAClB,CAAA,GAAA,mDAAmB,GACnB,iCACA;YAAC,cAAc;QAAc;OAE9B;QAO4B;IAAvC,qBAAO,CAAA,GAAA,yCAAO,EAAE,YAAY,CAAC,UAAU,CAAA,gBAAA,yBAAA,mCAAA,4BAAA,2BAAA,gBAAoB,SAAS,IAAI;AAC1E","sources":["packages/@react-spectrum/toast/src/Toaster.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, useToastRegion} from '@react-aria/toast';\nimport {classNames} from '@react-spectrum/utils';\nimport {FocusScope, useFocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport {Provider} from '@react-spectrum/provider';\nimport React, {createContext, ReactElement, ReactNode, useRef} from 'react';\nimport ReactDOM from 'react-dom';\nimport toastContainerStyles from './toastContainer.css';\nimport {ToastState} from '@react-stately/toast';\nimport {useUNSTABLE_PortalContext} from '@react-aria/overlays';\n\ninterface ToastContainerProps extends AriaToastRegionProps {\n children: ReactNode,\n state: ToastState<unknown>\n}\n\nexport const ToasterContext = createContext(false);\n\nexport function Toaster(props: ToastContainerProps): ReactElement {\n let {\n children,\n state\n } = props;\n\n let ref = useRef(null);\n let {regionProps} = useToastRegion(props, state, ref);\n let {focusProps, isFocusVisible} = useFocusRing();\n let {getContainer} = useUNSTABLE_PortalContext();\n\n let contents = (\n <Provider UNSAFE_style={{background: 'transparent'}}>\n <FocusScope>\n <ToasterContext.Provider value={isFocusVisible}>\n <div\n {...mergeProps(regionProps, focusProps)}\n ref={ref}\n data-position=\"bottom\"\n data-placement=\"center\"\n className={classNames(\n toastContainerStyles,\n 'react-spectrum-ToastContainer',\n {'focus-ring': isFocusVisible}\n )}>\n {children}\n </div>\n </ToasterContext.Provider>\n </FocusScope>\n </Provider>\n );\n\n return ReactDOM.createPortal(contents, getContainer?.() ?? document.body);\n}\n"],"names":[],"version":3,"file":"Toaster.main.js.map"}
|
package/dist/Toaster.mjs
CHANGED
|
@@ -35,7 +35,7 @@ function $parcel$interopDefault(a) {
|
|
|
35
35
|
const $e46feef4e4c28a4b$export$9194c0aa0cd7a9ff = /*#__PURE__*/ (0, $7Pdp8$createContext)(false);
|
|
36
36
|
function $e46feef4e4c28a4b$export$fb98e3a2a4cd92d7(props) {
|
|
37
37
|
let { children: children, state: state } = props;
|
|
38
|
-
let ref = (0, $7Pdp8$useRef)(
|
|
38
|
+
let ref = (0, $7Pdp8$useRef)(null);
|
|
39
39
|
let { regionProps: regionProps } = (0, $7Pdp8$useToastRegion)(props, state, ref);
|
|
40
40
|
let { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $7Pdp8$useFocusRing)();
|
|
41
41
|
let { getContainer: getContainer } = (0, $7Pdp8$useUNSTABLE_PortalContext)();
|
package/dist/Toaster.module.js
CHANGED
|
@@ -35,7 +35,7 @@ function $parcel$interopDefault(a) {
|
|
|
35
35
|
const $e46feef4e4c28a4b$export$9194c0aa0cd7a9ff = /*#__PURE__*/ (0, $7Pdp8$createContext)(false);
|
|
36
36
|
function $e46feef4e4c28a4b$export$fb98e3a2a4cd92d7(props) {
|
|
37
37
|
let { children: children, state: state } = props;
|
|
38
|
-
let ref = (0, $7Pdp8$useRef)(
|
|
38
|
+
let ref = (0, $7Pdp8$useRef)(null);
|
|
39
39
|
let { regionProps: regionProps } = (0, $7Pdp8$useToastRegion)(props, state, ref);
|
|
40
40
|
let { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $7Pdp8$useFocusRing)();
|
|
41
41
|
let { getContainer: getContainer } = (0, $7Pdp8$useUNSTABLE_PortalContext)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAkBM,MAAM,0DAAiB,CAAA,GAAA,oBAAY,EAAE;AAErC,SAAS,0CAAQ,KAA0B;IAChD,IAAI,YACF,QAAQ,SACR,KAAK,EACN,GAAG;IAEJ,IAAI,MAAM,CAAA,GAAA,aAAK,EAAE;IACjB,IAAI,eAAC,WAAW,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE,OAAO,OAAO;IACjD,IAAI,cAAC,UAAU,kBAAE,cAAc,EAAC,GAAG,CAAA,GAAA,mBAAW;IAC9C,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,gCAAwB;IAE7C,IAAI,yBACF,gCAAC,CAAA,GAAA,eAAO;QAAE,cAAc;YAAC,YAAY;QAAa;qBAChD,gCAAC,CAAA,GAAA,iBAAS,uBACR,gCAAC,0CAAe,QAAQ;QAAC,OAAO;qBAC9B,gCAAC;QACE,GAAG,CAAA,GAAA,iBAAS,EAAE,aAAa,WAAW;QACvC,KAAK;QACL,iBAAc;QACd,kBAAe;QACf,WAAW,CAAA,GAAA,iBAAS,EAClB,CAAA,GAAA,2DAAmB,GACnB,iCACA;YAAC,cAAc;QAAc;OAE9B;QAO4B;IAAvC,qBAAO,CAAA,GAAA,eAAO,EAAE,YAAY,CAAC,UAAU,CAAA,gBAAA,yBAAA,mCAAA,4BAAA,2BAAA,gBAAoB,SAAS,IAAI;AAC1E","sources":["packages/@react-spectrum/toast/src/Toaster.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, useToastRegion} from '@react-aria/toast';\nimport {classNames} from '@react-spectrum/utils';\nimport {FocusScope, useFocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport {Provider} from '@react-spectrum/provider';\nimport React, {createContext, ReactElement, ReactNode, useRef} from 'react';\nimport ReactDOM from 'react-dom';\nimport toastContainerStyles from './toastContainer.css';\nimport {ToastState} from '@react-stately/toast';\nimport {useUNSTABLE_PortalContext} from '@react-aria/overlays';\n\ninterface ToastContainerProps extends AriaToastRegionProps {\n children: ReactNode,\n state: ToastState<unknown>\n}\n\nexport const ToasterContext = createContext(false);\n\nexport function Toaster(props: ToastContainerProps): ReactElement {\n let {\n children,\n state\n } = props;\n\n let ref = useRef(
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAkBM,MAAM,0DAAiB,CAAA,GAAA,oBAAY,EAAE;AAErC,SAAS,0CAAQ,KAA0B;IAChD,IAAI,YACF,QAAQ,SACR,KAAK,EACN,GAAG;IAEJ,IAAI,MAAM,CAAA,GAAA,aAAK,EAAE;IACjB,IAAI,eAAC,WAAW,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE,OAAO,OAAO;IACjD,IAAI,cAAC,UAAU,kBAAE,cAAc,EAAC,GAAG,CAAA,GAAA,mBAAW;IAC9C,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,gCAAwB;IAE7C,IAAI,yBACF,gCAAC,CAAA,GAAA,eAAO;QAAE,cAAc;YAAC,YAAY;QAAa;qBAChD,gCAAC,CAAA,GAAA,iBAAS,uBACR,gCAAC,0CAAe,QAAQ;QAAC,OAAO;qBAC9B,gCAAC;QACE,GAAG,CAAA,GAAA,iBAAS,EAAE,aAAa,WAAW;QACvC,KAAK;QACL,iBAAc;QACd,kBAAe;QACf,WAAW,CAAA,GAAA,iBAAS,EAClB,CAAA,GAAA,2DAAmB,GACnB,iCACA;YAAC,cAAc;QAAc;OAE9B;QAO4B;IAAvC,qBAAO,CAAA,GAAA,eAAO,EAAE,YAAY,CAAC,UAAU,CAAA,gBAAA,yBAAA,mCAAA,4BAAA,2BAAA,gBAAoB,SAAS,IAAI;AAC1E","sources":["packages/@react-spectrum/toast/src/Toaster.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, useToastRegion} from '@react-aria/toast';\nimport {classNames} from '@react-spectrum/utils';\nimport {FocusScope, useFocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport {Provider} from '@react-spectrum/provider';\nimport React, {createContext, ReactElement, ReactNode, useRef} from 'react';\nimport ReactDOM from 'react-dom';\nimport toastContainerStyles from './toastContainer.css';\nimport {ToastState} from '@react-stately/toast';\nimport {useUNSTABLE_PortalContext} from '@react-aria/overlays';\n\ninterface ToastContainerProps extends AriaToastRegionProps {\n children: ReactNode,\n state: ToastState<unknown>\n}\n\nexport const ToasterContext = createContext(false);\n\nexport function Toaster(props: ToastContainerProps): ReactElement {\n let {\n children,\n state\n } = props;\n\n let ref = useRef(null);\n let {regionProps} = useToastRegion(props, state, ref);\n let {focusProps, isFocusVisible} = useFocusRing();\n let {getContainer} = useUNSTABLE_PortalContext();\n\n let contents = (\n <Provider UNSAFE_style={{background: 'transparent'}}>\n <FocusScope>\n <ToasterContext.Provider value={isFocusVisible}>\n <div\n {...mergeProps(regionProps, focusProps)}\n ref={ref}\n data-position=\"bottom\"\n data-placement=\"center\"\n className={classNames(\n toastContainerStyles,\n 'react-spectrum-ToastContainer',\n {'focus-ring': isFocusVisible}\n )}>\n {children}\n </div>\n </ToasterContext.Provider>\n </FocusScope>\n </Provider>\n );\n\n return ReactDOM.createPortal(contents, getContainer?.() ?? document.body);\n}\n"],"names":[],"version":3,"file":"Toaster.module.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAZA,4CAA6B,CAAC,eAAe,CAAC;AAC9C;AACA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,4CAAuC,CAAC,0BAA0B,EAAE,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAZA,4CAA6B,CAAC,eAAe,CAAC;AAC9C;AACA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,4CAAuC,CAAC,0BAA0B,EAAE,2CAA2C;AAC/G,4CAAkD,CAAC,qCAAqC,EAAE,2CAAsC;AAChI,4CAA6B,CAAC,eAAe,CAAC;AAC9C;AACA,4CAA8C,CAAC,gCAAgC,CAAC;AAChF,4CAAmC,CAAC,sBAAsB,EAAE,2CAAsC;AAClG,4CAAkD,CAAC,oCAAoC,CAAC;AACxF,4CAAiD,CAAC,mCAAmC,CAAC;AACtF,4CAAqD,CAAC,uCAAuC,CAAC","sources":["packages/@react-spectrum/toast/src/toastContainer.css"],"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\n@import \"../../../@adobe/spectrum-css-temp/components/commons/focus-ring.css\";\n\n.react-spectrum-ToastContainer {\n composes: spectrum-FocusRing;\n --spectrum-focus-ring-border-radius: var(--spectrum-toast-border-radius);\n --spectrum-focus-ring-gap: var(--spectrum-alias-focus-ring-gap);\n --spectrum-focus-ring-size: var(--spectrum-alias-focus-ring-size);\n\n position: fixed;\n inset-inline-start: 0;\n inset-inline-end: 0;\n z-index: 100050; /* above modals */\n display: flex;\n pointer-events: none;\n outline: none;\n /* keep focus ring inside the viewport */\n margin-block-end: 8px;\n margin-inline: 8px;\n\n .spectrum-Toast {\n margin: 8px;\n pointer-events: all;\n }\n\n &[data-position=top] {\n top: 0;\n flex-direction: column;\n --slide-from: translateY(-100%);\n --slide-to: translateY(0);\n }\n\n &[data-position=bottom] {\n bottom: 0;\n flex-direction: column-reverse;\n --slide-from: translateY(100%);\n --slide-to: translateY(0);\n }\n\n &[data-placement=left] {\n align-items: flex-start;\n --slide-from: translateX(-100%);\n --slide-to: translateX(0);\n\n &:dir(rtl) {\n --slide-from: translateX(100%);\n }\n }\n\n &[data-placement=center] {\n align-items: center;\n }\n\n &[data-placement=right] {\n align-items: flex-end;\n --slide-from: translateX(100%);\n --slide-to: translateX(0);\n\n &:dir(rtl) {\n --slide-from: translateX(-100%);\n }\n }\n}\n\n.spectrum-Toast {\n composes: spectrum-FocusRing;\n --spectrum-focus-ring-border-radius: var(--spectrum-toast-border-radius);\n --spectrum-focus-ring-gap: var(--spectrum-alias-focus-ring-gap);\n --spectrum-focus-ring-size: var(--spectrum-alias-focus-ring-size);\n\n position: relative;\n outline: none;\n\n &[data-animation=entering] {\n animation: slide-in 300ms;\n }\n\n &[data-animation=exiting] {\n animation: fade-out 300ms forwards;\n }\n\n .spectrum-Toast-contentWrapper {\n display: inline-flex;\n }\n}\n\n.spectrum-ToastContainer-list {\n display: inherit;\n flex-direction: inherit;\n align-items: inherit;\n list-style-type: none;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding-inline-start: 0;\n}\n\n.spectrum-ToastContainer-listitem {\n display: inline-block;\n}\n\n@keyframes slide-in {\n from {\n transform: var(--slide-from);\n }\n\n to {\n transform: var(--slide-to);\n }\n}\n\n@keyframes fade-out {\n from {\n opacity: 1;\n }\n\n to {\n opacity: 0;\n }\n}\n"],"names":[],"version":3,"file":"toastContainer_css.main.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAZA,4CAA6B,CAAC,eAAe,CAAC;AAC9C;AACA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,4CAAuC,CAAC,0BAA0B,EAAE,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAZA,4CAA6B,CAAC,eAAe,CAAC;AAC9C;AACA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,4CAAuC,CAAC,0BAA0B,EAAE,2CAA2C;AAC/G,4CAAkD,CAAC,qCAAqC,EAAE,2CAAsC;AAChI,4CAA6B,CAAC,eAAe,CAAC;AAC9C;AACA,4CAA8C,CAAC,gCAAgC,CAAC;AAChF,4CAAmC,CAAC,sBAAsB,EAAE,2CAAsC;AAClG,4CAAkD,CAAC,oCAAoC,CAAC;AACxF,4CAAiD,CAAC,mCAAmC,CAAC;AACtF,4CAAqD,CAAC,uCAAuC,CAAC","sources":["packages/@react-spectrum/toast/src/toastContainer.css"],"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\n@import \"../../../@adobe/spectrum-css-temp/components/commons/focus-ring.css\";\n\n.react-spectrum-ToastContainer {\n composes: spectrum-FocusRing;\n --spectrum-focus-ring-border-radius: var(--spectrum-toast-border-radius);\n --spectrum-focus-ring-gap: var(--spectrum-alias-focus-ring-gap);\n --spectrum-focus-ring-size: var(--spectrum-alias-focus-ring-size);\n\n position: fixed;\n inset-inline-start: 0;\n inset-inline-end: 0;\n z-index: 100050; /* above modals */\n display: flex;\n pointer-events: none;\n outline: none;\n /* keep focus ring inside the viewport */\n margin-block-end: 8px;\n margin-inline: 8px;\n\n .spectrum-Toast {\n margin: 8px;\n pointer-events: all;\n }\n\n &[data-position=top] {\n top: 0;\n flex-direction: column;\n --slide-from: translateY(-100%);\n --slide-to: translateY(0);\n }\n\n &[data-position=bottom] {\n bottom: 0;\n flex-direction: column-reverse;\n --slide-from: translateY(100%);\n --slide-to: translateY(0);\n }\n\n &[data-placement=left] {\n align-items: flex-start;\n --slide-from: translateX(-100%);\n --slide-to: translateX(0);\n\n &:dir(rtl) {\n --slide-from: translateX(100%);\n }\n }\n\n &[data-placement=center] {\n align-items: center;\n }\n\n &[data-placement=right] {\n align-items: flex-end;\n --slide-from: translateX(100%);\n --slide-to: translateX(0);\n\n &:dir(rtl) {\n --slide-from: translateX(-100%);\n }\n }\n}\n\n.spectrum-Toast {\n composes: spectrum-FocusRing;\n --spectrum-focus-ring-border-radius: var(--spectrum-toast-border-radius);\n --spectrum-focus-ring-gap: var(--spectrum-alias-focus-ring-gap);\n --spectrum-focus-ring-size: var(--spectrum-alias-focus-ring-size);\n\n position: relative;\n outline: none;\n\n &[data-animation=entering] {\n animation: slide-in 300ms;\n }\n\n &[data-animation=exiting] {\n animation: fade-out 300ms forwards;\n }\n\n .spectrum-Toast-contentWrapper {\n display: inline-flex;\n }\n}\n\n.spectrum-ToastContainer-list {\n display: inherit;\n flex-direction: inherit;\n align-items: inherit;\n list-style-type: none;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding-inline-start: 0;\n}\n\n.spectrum-ToastContainer-listitem {\n display: inline-block;\n}\n\n@keyframes slide-in {\n from {\n transform: var(--slide-from);\n }\n\n to {\n transform: var(--slide-to);\n }\n}\n\n@keyframes fade-out {\n from {\n opacity: 1;\n }\n\n to {\n opacity: 0;\n }\n}\n"],"names":[],"version":3,"file":"toastContainer_css.module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ type CloseFunction = () => void;
|
|
|
17
17
|
* A ToastContainer renders the queued toasts in an application. It should be placed
|
|
18
18
|
* at the root of the app.
|
|
19
19
|
*/
|
|
20
|
-
export function ToastContainer(props: SpectrumToastContainerProps): ReactElement;
|
|
20
|
+
export function ToastContainer(props: SpectrumToastContainerProps): ReactElement | null;
|
|
21
21
|
export const ToastQueue: {
|
|
22
22
|
/** Queues a neutral toast. */
|
|
23
23
|
neutral(children: string, options?: SpectrumToastOptions): CloseFunction;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AEuBA,4CAA6C,SAAQ,oBAAoB;CAAG;AAE5E,qCAAsC,SAAQ,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,EAAE,QAAQ;IACpF,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,gFAAgF;IAChF,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED,qBAAqB,MAAM,IAAI,CAAC;AAyChC;;;GAGG;AACH,+BAA+B,KAAK,EAAE,2BAA2B,GAAG,YAAY,
|
|
1
|
+
{"mappings":";;;;AEuBA,4CAA6C,SAAQ,oBAAoB;CAAG;AAE5E,qCAAsC,SAAQ,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,EAAE,QAAQ;IACpF,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,gFAAgF;IAChF,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED,qBAAqB,MAAM,IAAI,CAAC;AAyChC;;;GAGG;AACH,+BAA+B,KAAK,EAAE,2BAA2B,GAAG,YAAY,GAAG,IAAI,CAkDtF;AAuCD,OAAA,MAAM;IACJ,8BAA8B;sBACZ,MAAM,YAAW,oBAAoB,GAAQ,aAAa;IAG5E,+BAA+B;uBACZ,MAAM,YAAW,oBAAoB,GAAQ,aAAa;IAG7E,+BAA+B;uBACZ,MAAM,YAAW,oBAAoB,GAAQ,aAAa;IAG7E,qCAAqC;mBACtB,MAAM,YAAW,oBAAoB,GAAQ,aAAa;CAG1E,CAAC","sources":["packages/@react-spectrum/toast/src/packages/@react-spectrum/toast/src/Toast.tsx","packages/@react-spectrum/toast/src/packages/@react-spectrum/toast/src/Toaster.tsx","packages/@react-spectrum/toast/src/packages/@react-spectrum/toast/src/ToastContainer.tsx","packages/@react-spectrum/toast/src/packages/@react-spectrum/toast/src/index.ts","packages/@react-spectrum/toast/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\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\n/// <reference types=\"css-module-types\" />\n\nexport {ToastContainer, ToastQueue} from './ToastContainer';\n\nexport type {SpectrumToastOptions, SpectrumToastContainerProps} from './ToastContainer';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/toast",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.17",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"url": "https://github.com/adobe/react-spectrum"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@react-aria/focus": "^3.
|
|
40
|
-
"@react-aria/i18n": "^3.12.
|
|
41
|
-
"@react-aria/overlays": "^3.
|
|
42
|
-
"@react-aria/toast": "3.0.0-beta.
|
|
43
|
-
"@react-aria/utils": "^3.
|
|
44
|
-
"@react-spectrum/button": "^3.16.
|
|
45
|
-
"@react-spectrum/utils": "^3.
|
|
46
|
-
"@react-stately/toast": "3.0.0-beta.
|
|
47
|
-
"@react-types/shared": "^3.
|
|
48
|
-
"@spectrum-icons/ui": "^3.6.
|
|
39
|
+
"@react-aria/focus": "^3.19.0",
|
|
40
|
+
"@react-aria/i18n": "^3.12.4",
|
|
41
|
+
"@react-aria/overlays": "^3.24.0",
|
|
42
|
+
"@react-aria/toast": "3.0.0-beta.18",
|
|
43
|
+
"@react-aria/utils": "^3.26.0",
|
|
44
|
+
"@react-spectrum/button": "^3.16.9",
|
|
45
|
+
"@react-spectrum/utils": "^3.12.0",
|
|
46
|
+
"@react-stately/toast": "3.0.0-beta.7",
|
|
47
|
+
"@react-types/shared": "^3.26.0",
|
|
48
|
+
"@spectrum-icons/ui": "^3.6.11",
|
|
49
49
|
"@swc/helpers": "^0.5.0",
|
|
50
50
|
"use-sync-external-store": "^1.2.0"
|
|
51
51
|
},
|
|
@@ -56,10 +56,11 @@
|
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@react-spectrum/provider": "^3.0.0",
|
|
59
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
|
|
60
|
-
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
59
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
60
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
61
61
|
},
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
|
-
}
|
|
65
|
-
|
|
64
|
+
},
|
|
65
|
+
"gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
|
|
66
|
+
}
|
package/src/ToastContainer.tsx
CHANGED
|
@@ -77,14 +77,14 @@ function useActiveToastContainer() {
|
|
|
77
77
|
* A ToastContainer renders the queued toasts in an application. It should be placed
|
|
78
78
|
* at the root of the app.
|
|
79
79
|
*/
|
|
80
|
-
export function ToastContainer(props: SpectrumToastContainerProps): ReactElement {
|
|
80
|
+
export function ToastContainer(props: SpectrumToastContainerProps): ReactElement | null {
|
|
81
81
|
// Track all toast provider instances in a set.
|
|
82
82
|
// Only the first one will actually render.
|
|
83
83
|
// We use a ref to do this, since it will have a stable identity
|
|
84
84
|
// over the lifetime of the component.
|
|
85
|
-
let ref = useRef(
|
|
85
|
+
let ref = useRef(null);
|
|
86
|
+
|
|
86
87
|
|
|
87
|
-
// eslint-disable-next-line arrow-body-style
|
|
88
88
|
useEffect(() => {
|
|
89
89
|
toastProviders.add(ref);
|
|
90
90
|
triggerSubscriptions();
|
|
@@ -144,7 +144,7 @@ function addToast(children: string, variant: SpectrumToastValue['variant'], opti
|
|
|
144
144
|
|
|
145
145
|
let shouldContinue = window.dispatchEvent(event);
|
|
146
146
|
if (!shouldContinue) {
|
|
147
|
-
return;
|
|
147
|
+
return () => {};
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -160,7 +160,7 @@ function addToast(children: string, variant: SpectrumToastValue['variant'], opti
|
|
|
160
160
|
// Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible
|
|
161
161
|
// Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.
|
|
162
162
|
// It is debatable whether non-actionable toasts would also fail.
|
|
163
|
-
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) :
|
|
163
|
+
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;
|
|
164
164
|
let queue = getGlobalToastQueue();
|
|
165
165
|
let key = queue.add(value, {timeout, onClose: options.onClose});
|
|
166
166
|
return () => queue.close(key);
|
package/src/Toaster.tsx
CHANGED
|
@@ -34,7 +34,7 @@ export function Toaster(props: ToastContainerProps): ReactElement {
|
|
|
34
34
|
state
|
|
35
35
|
} = props;
|
|
36
36
|
|
|
37
|
-
let ref = useRef(
|
|
37
|
+
let ref = useRef(null);
|
|
38
38
|
let {regionProps} = useToastRegion(props, state, ref);
|
|
39
39
|
let {focusProps, isFocusVisible} = useFocusRing();
|
|
40
40
|
let {getContainer} = useUNSTABLE_PortalContext();
|