@react-spectrum/s2 3.0.0-nightly-58d96cace-250410 → 3.0.0-nightly-9723225d6-250413
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/dist/Card.cjs +1 -1
- package/dist/Card.cjs.map +1 -1
- package/dist/Card.css.map +1 -1
- package/dist/Card.mjs +1 -1
- package/dist/Card.mjs.map +1 -1
- package/dist/ColorSwatchPicker.cjs +2 -2
- package/dist/ColorSwatchPicker.cjs.map +1 -1
- package/dist/ColorSwatchPicker.css.map +1 -1
- package/dist/ColorSwatchPicker.mjs +2 -2
- package/dist/ColorSwatchPicker.mjs.map +1 -1
- package/dist/Content.cjs +6 -6
- package/dist/Content.cjs.map +1 -1
- package/dist/Content.mjs +6 -6
- package/dist/Content.mjs.map +1 -1
- package/dist/TableView.cjs +28 -16
- package/dist/TableView.cjs.map +1 -1
- package/dist/TableView.css.map +1 -1
- package/dist/TableView.mjs +29 -17
- package/dist/TableView.mjs.map +1 -1
- package/dist/Toast.cjs +557 -0
- package/dist/Toast.cjs.map +1 -0
- package/dist/Toast.css +461 -0
- package/dist/Toast.css.map +1 -0
- package/dist/Toast.mjs +551 -0
- package/dist/Toast.mjs.map +1 -0
- package/dist/Toast_module.cjs +70 -0
- package/dist/Toast_module.cjs.map +1 -0
- package/dist/Toast_module.css +119 -0
- package/dist/Toast_module.css.map +1 -0
- package/dist/Toast_module.mjs +72 -0
- package/dist/Toast_module.mjs.map +1 -0
- package/dist/ar-AE.cjs +4 -1
- package/dist/ar-AE.cjs.map +1 -1
- package/dist/ar-AE.mjs +4 -1
- package/dist/ar-AE.mjs.map +1 -1
- package/dist/bg-BG.cjs +4 -1
- package/dist/bg-BG.cjs.map +1 -1
- package/dist/bg-BG.mjs +4 -1
- package/dist/bg-BG.mjs.map +1 -1
- package/dist/cs-CZ.cjs +4 -1
- package/dist/cs-CZ.cjs.map +1 -1
- package/dist/cs-CZ.mjs +4 -1
- package/dist/cs-CZ.mjs.map +1 -1
- package/dist/da-DK.cjs +4 -1
- package/dist/da-DK.cjs.map +1 -1
- package/dist/da-DK.mjs +4 -1
- package/dist/da-DK.mjs.map +1 -1
- package/dist/de-DE.cjs +4 -1
- package/dist/de-DE.cjs.map +1 -1
- package/dist/de-DE.mjs +4 -1
- package/dist/de-DE.mjs.map +1 -1
- package/dist/el-GR.cjs +4 -1
- package/dist/el-GR.cjs.map +1 -1
- package/dist/el-GR.mjs +4 -1
- package/dist/el-GR.mjs.map +1 -1
- package/dist/en-US.cjs +5 -1
- package/dist/en-US.cjs.map +1 -1
- package/dist/en-US.mjs +5 -1
- package/dist/en-US.mjs.map +1 -1
- package/dist/es-ES.cjs +4 -1
- package/dist/es-ES.cjs.map +1 -1
- package/dist/es-ES.mjs +4 -1
- package/dist/es-ES.mjs.map +1 -1
- package/dist/et-EE.cjs +4 -1
- package/dist/et-EE.cjs.map +1 -1
- package/dist/et-EE.mjs +4 -1
- package/dist/et-EE.mjs.map +1 -1
- package/dist/fi-FI.cjs +4 -1
- package/dist/fi-FI.cjs.map +1 -1
- package/dist/fi-FI.mjs +4 -1
- package/dist/fi-FI.mjs.map +1 -1
- package/dist/fr-FR.cjs +4 -1
- package/dist/fr-FR.cjs.map +1 -1
- package/dist/fr-FR.mjs +4 -1
- package/dist/fr-FR.mjs.map +1 -1
- package/dist/he-IL.cjs +4 -1
- package/dist/he-IL.cjs.map +1 -1
- package/dist/he-IL.mjs +4 -1
- package/dist/he-IL.mjs.map +1 -1
- package/dist/hr-HR.cjs +4 -1
- package/dist/hr-HR.cjs.map +1 -1
- package/dist/hr-HR.mjs +4 -1
- package/dist/hr-HR.mjs.map +1 -1
- package/dist/hu-HU.cjs +4 -1
- package/dist/hu-HU.cjs.map +1 -1
- package/dist/hu-HU.mjs +4 -1
- package/dist/hu-HU.mjs.map +1 -1
- package/dist/it-IT.cjs +4 -1
- package/dist/it-IT.cjs.map +1 -1
- package/dist/it-IT.mjs +4 -1
- package/dist/it-IT.mjs.map +1 -1
- package/dist/ja-JP.cjs +4 -1
- package/dist/ja-JP.cjs.map +1 -1
- package/dist/ja-JP.mjs +4 -1
- package/dist/ja-JP.mjs.map +1 -1
- package/dist/ko-KR.cjs +4 -1
- package/dist/ko-KR.cjs.map +1 -1
- package/dist/ko-KR.mjs +4 -1
- package/dist/ko-KR.mjs.map +1 -1
- package/dist/lt-LT.cjs +4 -1
- package/dist/lt-LT.cjs.map +1 -1
- package/dist/lt-LT.mjs +4 -1
- package/dist/lt-LT.mjs.map +1 -1
- package/dist/lv-LV.cjs +4 -1
- package/dist/lv-LV.cjs.map +1 -1
- package/dist/lv-LV.mjs +4 -1
- package/dist/lv-LV.mjs.map +1 -1
- package/dist/main.cjs +4 -0
- package/dist/main.cjs.map +1 -1
- package/dist/module.mjs +3 -1
- package/dist/module.mjs.map +1 -1
- package/dist/nb-NO.cjs +4 -1
- package/dist/nb-NO.cjs.map +1 -1
- package/dist/nb-NO.mjs +4 -1
- package/dist/nb-NO.mjs.map +1 -1
- package/dist/nl-NL.cjs +4 -1
- package/dist/nl-NL.cjs.map +1 -1
- package/dist/nl-NL.mjs +4 -1
- package/dist/nl-NL.mjs.map +1 -1
- package/dist/pl-PL.cjs +4 -1
- package/dist/pl-PL.cjs.map +1 -1
- package/dist/pl-PL.mjs +4 -1
- package/dist/pl-PL.mjs.map +1 -1
- package/dist/pt-BR.cjs +4 -1
- package/dist/pt-BR.cjs.map +1 -1
- package/dist/pt-BR.mjs +4 -1
- package/dist/pt-BR.mjs.map +1 -1
- package/dist/pt-PT.cjs +4 -1
- package/dist/pt-PT.cjs.map +1 -1
- package/dist/pt-PT.mjs +4 -1
- package/dist/pt-PT.mjs.map +1 -1
- package/dist/ro-RO.cjs +4 -1
- package/dist/ro-RO.cjs.map +1 -1
- package/dist/ro-RO.mjs +4 -1
- package/dist/ro-RO.mjs.map +1 -1
- package/dist/ru-RU.cjs +4 -1
- package/dist/ru-RU.cjs.map +1 -1
- package/dist/ru-RU.mjs +4 -1
- package/dist/ru-RU.mjs.map +1 -1
- package/dist/sk-SK.cjs +4 -1
- package/dist/sk-SK.cjs.map +1 -1
- package/dist/sk-SK.mjs +4 -1
- package/dist/sk-SK.mjs.map +1 -1
- package/dist/sl-SI.cjs +4 -1
- package/dist/sl-SI.cjs.map +1 -1
- package/dist/sl-SI.mjs +4 -1
- package/dist/sl-SI.mjs.map +1 -1
- package/dist/sr-SP.cjs +4 -1
- package/dist/sr-SP.cjs.map +1 -1
- package/dist/sr-SP.mjs +4 -1
- package/dist/sr-SP.mjs.map +1 -1
- package/dist/sv-SE.cjs +4 -1
- package/dist/sv-SE.cjs.map +1 -1
- package/dist/sv-SE.mjs +4 -1
- package/dist/sv-SE.mjs.map +1 -1
- package/dist/tr-TR.cjs +4 -1
- package/dist/tr-TR.cjs.map +1 -1
- package/dist/tr-TR.mjs +4 -1
- package/dist/tr-TR.mjs.map +1 -1
- package/dist/types.d.ts +47 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.cjs +4 -1
- package/dist/uk-UA.cjs.map +1 -1
- package/dist/uk-UA.mjs +4 -1
- package/dist/uk-UA.mjs.map +1 -1
- package/dist/zh-CN.cjs +4 -1
- package/dist/zh-CN.cjs.map +1 -1
- package/dist/zh-CN.mjs +4 -1
- package/dist/zh-CN.mjs.map +1 -1
- package/dist/zh-TW.cjs +4 -1
- package/dist/zh-TW.cjs.map +1 -1
- package/dist/zh-TW.mjs +4 -1
- package/dist/zh-TW.mjs.map +1 -1
- package/package.json +20 -19
- package/src/Card.tsx +1 -1
- package/src/ColorSwatchPicker.tsx +2 -1
- package/src/Content.tsx +6 -6
- package/src/TableView.tsx +45 -29
- package/src/Toast.module.css +153 -0
- package/src/Toast.tsx +579 -0
- package/src/index.ts +2 -0
package/dist/Toast.mjs
ADDED
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
import "./Toast.css";
|
|
2
|
+
import {ActionButton as $da878a05ab4a403e$export$cfc7921d29ef7b80} from "./ActionButton.mjs";
|
|
3
|
+
import $e17a4836f4b6cc28$export$2e2bcd8739ae039 from "../icons/AlertTriangle.mjs";
|
|
4
|
+
import {Button as $067ea9f64ccd4e8e$export$353f5b6fc5456de1} from "./Button.mjs";
|
|
5
|
+
import {CenterBaseline as $1f4b04be3f24aae3$export$768dac55bb57081d} from "./CenterBaseline.mjs";
|
|
6
|
+
import $22a7d72fc05e138d$export$2e2bcd8739ae039 from "../icons/CheckmarkCircle.mjs";
|
|
7
|
+
import $e59ae2a33cca2ebf$export$2e2bcd8739ae039 from "../icons/ChevronDown.mjs";
|
|
8
|
+
import {CloseButton as $a9cda54c4f47ce52$export$de65de8213222d10} from "./CloseButton.mjs";
|
|
9
|
+
import $4c8f17dac3ecefd9$export$2e2bcd8739ae039 from "../icons/InfoCircle.mjs";
|
|
10
|
+
import $jeXmD$intlStringsmjs from "./intlStrings.mjs";
|
|
11
|
+
import {mergeStyles as $feb886035e0d4633$export$e618dc39ac9ad607} from "../icons/runtime.mjs";
|
|
12
|
+
import {Text as $8e847109a6ab556d$export$5f1af8db9871e1d6} from "./Content.mjs";
|
|
13
|
+
import "./Toast_module.css";
|
|
14
|
+
import $jeXmD$Toast_modulemjs from "./Toast_module.mjs";
|
|
15
|
+
import {jsx as $jeXmD$jsx, jsxs as $jeXmD$jsxs} from "react/jsx-runtime";
|
|
16
|
+
import {createContext as $jeXmD$createContext, useRef as $jeXmD$useRef, useMemo as $jeXmD$useMemo, useEffect as $jeXmD$useEffect, useContext as $jeXmD$useContext} from "react";
|
|
17
|
+
import {filterDOMProps as $jeXmD$filterDOMProps, useEvent as $jeXmD$useEvent} from "@react-aria/utils";
|
|
18
|
+
import {flushSync as $jeXmD$flushSync} from "react-dom";
|
|
19
|
+
import {useModalOverlay as $jeXmD$useModalOverlay, FocusScope as $jeXmD$FocusScope} from "react-aria";
|
|
20
|
+
import {UNSTABLE_ToastQueue as $jeXmD$UNSTABLE_ToastQueue, UNSTABLE_ToastRegion as $jeXmD$UNSTABLE_ToastRegion, UNSTABLE_ToastList as $jeXmD$UNSTABLE_ToastList, UNSTABLE_ToastStateContext as $jeXmD$UNSTABLE_ToastStateContext, UNSTABLE_Toast as $jeXmD$UNSTABLE_Toast, UNSTABLE_ToastContent as $jeXmD$UNSTABLE_ToastContent} from "react-aria-components";
|
|
21
|
+
import {useLocalizedStringFormatter as $jeXmD$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
22
|
+
import {useMediaQuery as $jeXmD$useMediaQuery} from "@react-spectrum/utils";
|
|
23
|
+
import {useOverlayTriggerState as $jeXmD$useOverlayTriggerState} from "react-stately";
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
function $parcel$interopDefault(a) {
|
|
27
|
+
return a && a.__esModule ? a.default : a;
|
|
28
|
+
}
|
|
29
|
+
/*
|
|
30
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
31
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
32
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
33
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
34
|
+
*
|
|
35
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
36
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
37
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
38
|
+
* governing permissions and limitations under the License.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
function $6e462db325878d1a$var$startViewTransition(fn, type) {
|
|
61
|
+
if ('startViewTransition' in document) {
|
|
62
|
+
// Safari doesn't support :active-view-transition-type() yet, so we fall back to a class on the html element.
|
|
63
|
+
document.documentElement.classList.add((0, ($parcel$interopDefault($jeXmD$Toast_modulemjs)))[type]);
|
|
64
|
+
let viewTransition = document.startViewTransition({
|
|
65
|
+
update: ()=>(0, $jeXmD$flushSync)(fn),
|
|
66
|
+
types: [
|
|
67
|
+
(0, ($parcel$interopDefault($jeXmD$Toast_modulemjs)))[type]
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
viewTransition.ready.catch(()=>{});
|
|
71
|
+
viewTransition.finished.then(()=>{
|
|
72
|
+
document.documentElement.classList.remove((0, ($parcel$interopDefault($jeXmD$Toast_modulemjs)))[type]);
|
|
73
|
+
});
|
|
74
|
+
} else fn();
|
|
75
|
+
}
|
|
76
|
+
// There is a single global toast queue instance for the whole app, initialized lazily.
|
|
77
|
+
let $6e462db325878d1a$var$globalToastQueue = null;
|
|
78
|
+
function $6e462db325878d1a$var$getGlobalToastQueue() {
|
|
79
|
+
if (!$6e462db325878d1a$var$globalToastQueue) $6e462db325878d1a$var$globalToastQueue = new (0, $jeXmD$UNSTABLE_ToastQueue)({
|
|
80
|
+
maxVisibleToasts: Infinity,
|
|
81
|
+
wrapUpdate (fn, action) {
|
|
82
|
+
$6e462db325878d1a$var$startViewTransition(fn, `toast-${action}`);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return $6e462db325878d1a$var$globalToastQueue;
|
|
86
|
+
}
|
|
87
|
+
function $6e462db325878d1a$var$addToast(children, variant, options = {}) {
|
|
88
|
+
let value = {
|
|
89
|
+
children: children,
|
|
90
|
+
variant: variant,
|
|
91
|
+
actionLabel: options.actionLabel,
|
|
92
|
+
onAction: options.onAction,
|
|
93
|
+
shouldCloseOnAction: options.shouldCloseOnAction,
|
|
94
|
+
...(0, $jeXmD$filterDOMProps)(options)
|
|
95
|
+
};
|
|
96
|
+
// Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible
|
|
97
|
+
// Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.
|
|
98
|
+
// It is debatable whether non-actionable toasts would also fail.
|
|
99
|
+
let timeout = options.timeout && !options.actionLabel ? Math.max(options.timeout, 5000) : undefined;
|
|
100
|
+
let queue = $6e462db325878d1a$var$getGlobalToastQueue();
|
|
101
|
+
let key = queue.add(value, {
|
|
102
|
+
timeout: timeout,
|
|
103
|
+
onClose: options.onClose
|
|
104
|
+
});
|
|
105
|
+
return ()=>queue.close(key);
|
|
106
|
+
}
|
|
107
|
+
const $6e462db325878d1a$export$f1f8569633bbbec4 = {
|
|
108
|
+
/** Queues a neutral toast. */ neutral (children, options = {}) {
|
|
109
|
+
return $6e462db325878d1a$var$addToast(children, 'neutral', options);
|
|
110
|
+
},
|
|
111
|
+
/** Queues a positive toast. */ positive (children, options = {}) {
|
|
112
|
+
return $6e462db325878d1a$var$addToast(children, 'positive', options);
|
|
113
|
+
},
|
|
114
|
+
/** Queues a negative toast. */ negative (children, options = {}) {
|
|
115
|
+
return $6e462db325878d1a$var$addToast(children, 'negative', options);
|
|
116
|
+
},
|
|
117
|
+
/** Queues an informational toast. */ info (children, options = {}) {
|
|
118
|
+
return $6e462db325878d1a$var$addToast(children, 'info', options);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const $6e462db325878d1a$var$toastRegion = function anonymous(props) {
|
|
122
|
+
let rules = " .";
|
|
123
|
+
if (props.isFocusVisible) rules += ' _Mb';
|
|
124
|
+
else rules += ' _Ma';
|
|
125
|
+
rules += ' da_____M';
|
|
126
|
+
rules += ' dx';
|
|
127
|
+
rules += ' _Oc';
|
|
128
|
+
rules += ' _N-3t1z';
|
|
129
|
+
rules += ' _0d';
|
|
130
|
+
if (props.placement === "bottom") rules += ' _7d';
|
|
131
|
+
else if (props.placement === "top") rules += ' _7b';
|
|
132
|
+
rules += ' Vb';
|
|
133
|
+
rules += ' Wa';
|
|
134
|
+
rules += ' Xa';
|
|
135
|
+
rules += ' le';
|
|
136
|
+
if (props.placement === "top") {
|
|
137
|
+
if (props.isExpanded) rules += ' Ya';
|
|
138
|
+
else rules += ' Yf';
|
|
139
|
+
}
|
|
140
|
+
if (props.placement === "bottom") {
|
|
141
|
+
if (props.isExpanded) rules += ' _aa';
|
|
142
|
+
else rules += ' _af';
|
|
143
|
+
}
|
|
144
|
+
if (props.align === "end") rules += ' y_d';
|
|
145
|
+
else if (props.align === "center") rules += ' y_d';
|
|
146
|
+
else if (props.align === "start") rules += ' yf';
|
|
147
|
+
if (props.align === "end") rules += ' zf';
|
|
148
|
+
else if (props.align === "center") rules += ' z_d';
|
|
149
|
+
else if (props.align === "start") rules += ' z_d';
|
|
150
|
+
rules += ' __oa';
|
|
151
|
+
rules += ' pn';
|
|
152
|
+
rules += ' _wd';
|
|
153
|
+
rules += ' _xd';
|
|
154
|
+
rules += ' _yd';
|
|
155
|
+
rules += ' _zd';
|
|
156
|
+
return rules;
|
|
157
|
+
};
|
|
158
|
+
const $6e462db325878d1a$var$toastList = function anonymous(props) {
|
|
159
|
+
let rules = " .";
|
|
160
|
+
rules += ' Vc';
|
|
161
|
+
rules += ' __a-3t1y';
|
|
162
|
+
rules += ' _0d';
|
|
163
|
+
rules += ' id';
|
|
164
|
+
rules += ' jd';
|
|
165
|
+
if (props.placement === "bottom") rules += ' _7d';
|
|
166
|
+
else if (props.placement === "top") rules += ' _7b';
|
|
167
|
+
rules += ' __oa';
|
|
168
|
+
rules += ' Aa';
|
|
169
|
+
rules += ' Ba';
|
|
170
|
+
if (props.isExpanded) {
|
|
171
|
+
if (props.placement === "bottom") rules += ' Ed';
|
|
172
|
+
else if (props.placement === "top") rules += ' Ef';
|
|
173
|
+
}
|
|
174
|
+
if (props.isExpanded) {
|
|
175
|
+
if (props.placement === "bottom") rules += ' Ff';
|
|
176
|
+
else if (props.placement === "top") rules += ' Fd';
|
|
177
|
+
}
|
|
178
|
+
if (props.isExpanded) rules += ' Cd';
|
|
179
|
+
else rules += ' Ca';
|
|
180
|
+
if (props.isExpanded) rules += ' Dd';
|
|
181
|
+
else rules += ' Da';
|
|
182
|
+
if (props.isExpanded) rules += ' yL';
|
|
183
|
+
else rules += ' ya';
|
|
184
|
+
if (props.isExpanded) rules += ' zL';
|
|
185
|
+
else rules += ' za';
|
|
186
|
+
if (props.isExpanded) rules += ' __wa';
|
|
187
|
+
if (props.isExpanded) rules += ' __xa';
|
|
188
|
+
return rules;
|
|
189
|
+
};
|
|
190
|
+
// Separate style macro for focus ring and toast so that
|
|
191
|
+
// isFocusVisible doesn't cause toast background to change.
|
|
192
|
+
const $6e462db325878d1a$var$toastFocusRing = function anonymous(props) {
|
|
193
|
+
let rules = " .";
|
|
194
|
+
if (props.isFocusVisible) rules += ' _Mb';
|
|
195
|
+
else rules += ' _Ma';
|
|
196
|
+
if (props.isExpanded) rules += ' dc';
|
|
197
|
+
else {
|
|
198
|
+
rules += ' da_____M';
|
|
199
|
+
rules += ' dx';
|
|
200
|
+
}
|
|
201
|
+
rules += ' _Oc';
|
|
202
|
+
rules += ' _N-3t1z';
|
|
203
|
+
return rules;
|
|
204
|
+
};
|
|
205
|
+
const $6e462db325878d1a$var$toastStyle = function anonymous(props) {
|
|
206
|
+
let rules = " .";
|
|
207
|
+
rules += ' _0d';
|
|
208
|
+
rules += ' if';
|
|
209
|
+
rules += ' jf';
|
|
210
|
+
rules += ' Cf';
|
|
211
|
+
rules += ' Dd';
|
|
212
|
+
rules += ' Ee';
|
|
213
|
+
rules += ' Fe';
|
|
214
|
+
rules += ' _wd';
|
|
215
|
+
rules += ' _xd';
|
|
216
|
+
rules += ' _yd';
|
|
217
|
+
rules += ' _zd';
|
|
218
|
+
rules += ' o_i';
|
|
219
|
+
rules += ' -jkruo5_r-_____P';
|
|
220
|
+
rules += ' r-w2xrw6';
|
|
221
|
+
rules += ' __oa';
|
|
222
|
+
rules += ' _9-3t1x';
|
|
223
|
+
rules += ' _d-bc1l9oh';
|
|
224
|
+
rules += ' _d-1uotwbwg';
|
|
225
|
+
rules += ' _d-eo0c6sf';
|
|
226
|
+
rules += ' _d-enzzrge';
|
|
227
|
+
rules += ' _d-enzykdd';
|
|
228
|
+
rules += ' _d-enzwzjc';
|
|
229
|
+
rules += ' _d-enzrfpb';
|
|
230
|
+
rules += ' _da';
|
|
231
|
+
rules += ' _ebf';
|
|
232
|
+
rules += ' _ee';
|
|
233
|
+
rules += ' _fb';
|
|
234
|
+
rules += ' _g-1x99dlob';
|
|
235
|
+
rules += ' _ga';
|
|
236
|
+
rules += ' ac';
|
|
237
|
+
if (props.variant === "negative") {
|
|
238
|
+
if (props.isPressed) rules += ' b_____Y';
|
|
239
|
+
else if (props.isFocusVisible) rules += ' b_____Y';
|
|
240
|
+
else if (props.isHovered) rules += ' b_____Y';
|
|
241
|
+
else rules += ' b_____X';
|
|
242
|
+
} else if (props.variant === "positive") {
|
|
243
|
+
if (props.isPressed) rules += ' b_____1';
|
|
244
|
+
else if (props.isFocusVisible) rules += ' b_____1';
|
|
245
|
+
else if (props.isHovered) rules += ' b_____1';
|
|
246
|
+
else rules += ' b_____0';
|
|
247
|
+
} else if (props.variant === "info") {
|
|
248
|
+
if (props.isPressed) rules += ' b_____S';
|
|
249
|
+
else if (props.isFocusVisible) rules += ' b_____S';
|
|
250
|
+
else if (props.isHovered) rules += ' b_____S';
|
|
251
|
+
else rules += ' b_____R';
|
|
252
|
+
} else if (props.variant === "neutral") {
|
|
253
|
+
if (props.isPressed) rules += ' b_____V';
|
|
254
|
+
else if (props.isFocusVisible) rules += ' b_____V';
|
|
255
|
+
else if (props.isHovered) rules += ' b_____V';
|
|
256
|
+
else rules += ' b_____U';
|
|
257
|
+
}
|
|
258
|
+
rules += ' -rwx0fg_e-b';
|
|
259
|
+
if (props.isExpanded) rules += ' _ud';
|
|
260
|
+
else rules += ' _ub';
|
|
261
|
+
return rules;
|
|
262
|
+
};
|
|
263
|
+
const $6e462db325878d1a$var$toastBody = function anonymous(props) {
|
|
264
|
+
let rules = " .";
|
|
265
|
+
if (props.isSingle) rules += ' _0d';
|
|
266
|
+
else rules += ' _0f';
|
|
267
|
+
rules += ' __i-1a6w430';
|
|
268
|
+
rules += ' __k-rbzbwq';
|
|
269
|
+
rules += ' __a-3t1y';
|
|
270
|
+
rules += ' _8a';
|
|
271
|
+
rules += ' _2c';
|
|
272
|
+
rules += ' jh';
|
|
273
|
+
rules += ' id';
|
|
274
|
+
return rules;
|
|
275
|
+
};
|
|
276
|
+
const $6e462db325878d1a$var$toastContent = " _0d id jd _2d __b-drkpd0 __c-drkpd0 __d-drkpd0 __e-drkpd0 __Ib le";
|
|
277
|
+
const $6e462db325878d1a$var$controls = function anonymous(props) {
|
|
278
|
+
let rules = " .";
|
|
279
|
+
rules += ' _Ba';
|
|
280
|
+
if (props.isExpanded) rules += ' _0d';
|
|
281
|
+
else rules += ' _0j';
|
|
282
|
+
rules += ' _3c';
|
|
283
|
+
rules += ' id';
|
|
284
|
+
rules += ' jd';
|
|
285
|
+
if (props.isExpanded) rules += ' _L-3t1y';
|
|
286
|
+
else rules += ' _L-3t1x';
|
|
287
|
+
return rules;
|
|
288
|
+
};
|
|
289
|
+
const $6e462db325878d1a$var$ICONS = {
|
|
290
|
+
info: (0, $4c8f17dac3ecefd9$export$2e2bcd8739ae039),
|
|
291
|
+
negative: (0, $e17a4836f4b6cc28$export$2e2bcd8739ae039),
|
|
292
|
+
positive: (0, $22a7d72fc05e138d$export$2e2bcd8739ae039)
|
|
293
|
+
};
|
|
294
|
+
const $6e462db325878d1a$var$ToastContainerContext = /*#__PURE__*/ (0, $jeXmD$createContext)(null);
|
|
295
|
+
function $6e462db325878d1a$export$f2815235e76a62b9(props) {
|
|
296
|
+
let { placement: placement = 'bottom' } = props;
|
|
297
|
+
let queue = $6e462db325878d1a$var$getGlobalToastQueue();
|
|
298
|
+
let align = 'center';
|
|
299
|
+
[placement, align = 'center'] = placement.split(' ');
|
|
300
|
+
let stringFormatter = (0, $jeXmD$useLocalizedStringFormatter)((0, ($parcel$interopDefault($jeXmD$intlStringsmjs))), '@react-spectrum/s2');
|
|
301
|
+
let regionRef = (0, $jeXmD$useRef)(null);
|
|
302
|
+
let state = (0, $jeXmD$useOverlayTriggerState)({});
|
|
303
|
+
let { isOpen: isExpanded, close: close, toggle: toggle } = state;
|
|
304
|
+
let ctx = (0, $jeXmD$useMemo)(()=>({
|
|
305
|
+
isExpanded: isExpanded,
|
|
306
|
+
toggleExpanded () {
|
|
307
|
+
if (!isExpanded && queue.visibleToasts.length <= 1) return;
|
|
308
|
+
$6e462db325878d1a$var$startViewTransition(()=>toggle(), isExpanded ? 'toast-collapse' : 'toast-expand');
|
|
309
|
+
}
|
|
310
|
+
}), [
|
|
311
|
+
isExpanded,
|
|
312
|
+
toggle,
|
|
313
|
+
queue
|
|
314
|
+
]);
|
|
315
|
+
// Set the state to collapsed whenever the queue is emptied.
|
|
316
|
+
(0, $jeXmD$useEffect)(()=>{
|
|
317
|
+
return queue.subscribe(()=>{
|
|
318
|
+
if (queue.visibleToasts.length === 0 && isExpanded) close();
|
|
319
|
+
});
|
|
320
|
+
}, [
|
|
321
|
+
queue,
|
|
322
|
+
isExpanded,
|
|
323
|
+
close
|
|
324
|
+
]);
|
|
325
|
+
let collapse = ()=>{
|
|
326
|
+
regionRef.current?.focus();
|
|
327
|
+
ctx.toggleExpanded();
|
|
328
|
+
};
|
|
329
|
+
// Prevent scroll, aria hide outside, and contain focus when expanded, since we take over the whole screen.
|
|
330
|
+
// Attach event handler to the ref since ToastRegion doesn't pass through onKeyDown.
|
|
331
|
+
(0, $jeXmD$useModalOverlay)({}, state, regionRef);
|
|
332
|
+
(0, $jeXmD$useEvent)(regionRef, 'keydown', isExpanded ? (e)=>{
|
|
333
|
+
if (e.key === 'Escape') collapse();
|
|
334
|
+
} : undefined);
|
|
335
|
+
return /*#__PURE__*/ (0, $jeXmD$jsx)((0, $jeXmD$UNSTABLE_ToastRegion), {
|
|
336
|
+
...props,
|
|
337
|
+
ref: regionRef,
|
|
338
|
+
queue: queue,
|
|
339
|
+
className: (renderProps)=>$6e462db325878d1a$var$toastRegion({
|
|
340
|
+
...renderProps,
|
|
341
|
+
placement: placement,
|
|
342
|
+
align: align,
|
|
343
|
+
isExpanded: isExpanded
|
|
344
|
+
}),
|
|
345
|
+
children: /*#__PURE__*/ (0, $jeXmD$jsx)((0, $jeXmD$FocusScope), {
|
|
346
|
+
contain: isExpanded,
|
|
347
|
+
children: /*#__PURE__*/ (0, $jeXmD$jsxs)($6e462db325878d1a$var$ToastContainerContext.Provider, {
|
|
348
|
+
value: ctx,
|
|
349
|
+
children: [
|
|
350
|
+
isExpanded && // eslint-disable-next-line
|
|
351
|
+
/*#__PURE__*/ (0, $jeXmD$jsx)("div", {
|
|
352
|
+
className: (0, ($parcel$interopDefault($jeXmD$Toast_modulemjs)))['toast-background'] + " Vb Ya _aa Wa Xa b_____o",
|
|
353
|
+
onClick: collapse
|
|
354
|
+
}),
|
|
355
|
+
/*#__PURE__*/ (0, $jeXmD$jsx)($6e462db325878d1a$var$SpectrumToastList, {
|
|
356
|
+
placement: placement,
|
|
357
|
+
align: align
|
|
358
|
+
}),
|
|
359
|
+
/*#__PURE__*/ (0, $jeXmD$jsxs)("div", {
|
|
360
|
+
className: (0, ($parcel$interopDefault($jeXmD$Toast_modulemjs)))['toast-controls'] + $6e462db325878d1a$var$controls({
|
|
361
|
+
isExpanded: isExpanded
|
|
362
|
+
}),
|
|
363
|
+
children: [
|
|
364
|
+
/*#__PURE__*/ (0, $jeXmD$jsx)((0, $da878a05ab4a403e$export$cfc7921d29ef7b80), {
|
|
365
|
+
size: "S",
|
|
366
|
+
onPress: ()=>queue.clear(),
|
|
367
|
+
// Default focus ring does not have enough contrast against gray background.
|
|
368
|
+
UNSAFE_style: {
|
|
369
|
+
outlineColor: 'white'
|
|
370
|
+
},
|
|
371
|
+
children: stringFormatter.format('toast.clearAll')
|
|
372
|
+
}),
|
|
373
|
+
/*#__PURE__*/ (0, $jeXmD$jsx)((0, $da878a05ab4a403e$export$cfc7921d29ef7b80), {
|
|
374
|
+
size: "S",
|
|
375
|
+
onPress: collapse,
|
|
376
|
+
UNSAFE_style: {
|
|
377
|
+
outlineColor: 'white'
|
|
378
|
+
},
|
|
379
|
+
children: stringFormatter.format('toast.collapse')
|
|
380
|
+
})
|
|
381
|
+
]
|
|
382
|
+
})
|
|
383
|
+
]
|
|
384
|
+
})
|
|
385
|
+
})
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
function $6e462db325878d1a$var$SpectrumToastList({ placement: placement, align: align }) {
|
|
389
|
+
let { isExpanded: isExpanded, toggleExpanded: toggleExpanded } = (0, $jeXmD$useContext)($6e462db325878d1a$var$ToastContainerContext);
|
|
390
|
+
// Attach click handler to ref since ToastList doesn't pass through onClick/onPress.
|
|
391
|
+
let toastListRef = (0, $jeXmD$useRef)(null);
|
|
392
|
+
(0, $jeXmD$useEvent)(toastListRef, 'click', (e)=>{
|
|
393
|
+
// Have to check if this is a button because stopPropagation in react events doesn't affect native events.
|
|
394
|
+
if (!isExpanded && !e.target?.closest('button')) toggleExpanded();
|
|
395
|
+
});
|
|
396
|
+
let reduceMotion = (0, $jeXmD$useMediaQuery)('(prefers-reduced-motion)');
|
|
397
|
+
return /*#__PURE__*/ (0, $jeXmD$jsx)((0, $jeXmD$UNSTABLE_ToastList), {
|
|
398
|
+
ref: toastListRef,
|
|
399
|
+
style: ({ isHovered: isHovered })=>{
|
|
400
|
+
let origin = isHovered ? 95 : 55;
|
|
401
|
+
return {
|
|
402
|
+
perspective: 80,
|
|
403
|
+
perspectiveOrigin: 'center ' + (placement === 'top' ? `calc(100% + ${origin}px)` : `${-origin}px`),
|
|
404
|
+
transition: 'perspective-origin 400ms'
|
|
405
|
+
};
|
|
406
|
+
},
|
|
407
|
+
className: (0, ($parcel$interopDefault($jeXmD$Toast_modulemjs)))[isExpanded ? 'toast-list-expanded' : 'toast-list-collapsed'] + $6e462db325878d1a$var$toastList({
|
|
408
|
+
placement: placement,
|
|
409
|
+
align: align,
|
|
410
|
+
isExpanded: isExpanded
|
|
411
|
+
}),
|
|
412
|
+
children: ({ toast: toast })=>/*#__PURE__*/ (0, $jeXmD$jsx)($6e462db325878d1a$export$f9b1e1c88454fa08, {
|
|
413
|
+
toast: toast,
|
|
414
|
+
placement: placement,
|
|
415
|
+
align: align,
|
|
416
|
+
reduceMotion: reduceMotion
|
|
417
|
+
})
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
function $6e462db325878d1a$export$f9b1e1c88454fa08(props) {
|
|
421
|
+
let { toast: toast, placement: placement = 'bottom', align: align = 'center' } = props;
|
|
422
|
+
let variant = toast.content.variant || 'info';
|
|
423
|
+
let Icon = $6e462db325878d1a$var$ICONS[variant];
|
|
424
|
+
let state = (0, $jeXmD$useContext)((0, $jeXmD$UNSTABLE_ToastStateContext));
|
|
425
|
+
let visibleToasts = state.visibleToasts;
|
|
426
|
+
let index = visibleToasts.indexOf(toast);
|
|
427
|
+
let isMain = index <= 0;
|
|
428
|
+
let ctx = (0, $jeXmD$useContext)($6e462db325878d1a$var$ToastContainerContext);
|
|
429
|
+
let isExpanded = ctx?.isExpanded || false;
|
|
430
|
+
let toastRef = (0, $jeXmD$useRef)(null);
|
|
431
|
+
let stringFormatter = (0, $jeXmD$useLocalizedStringFormatter)((0, ($parcel$interopDefault($jeXmD$intlStringsmjs))), '@react-spectrum/s2');
|
|
432
|
+
// When not expanded, use a presentational div for the toasts behind the top one.
|
|
433
|
+
// The content is invisible, all we show is the background color.
|
|
434
|
+
if (!isMain && ctx && !ctx.isExpanded) return /*#__PURE__*/ (0, $jeXmD$jsx)("div", {
|
|
435
|
+
role: "presentation",
|
|
436
|
+
style: {
|
|
437
|
+
position: 'absolute',
|
|
438
|
+
[placement === 'top' ? 'bottom' : 'top']: 0,
|
|
439
|
+
left: 0,
|
|
440
|
+
width: '100%',
|
|
441
|
+
translate: `0 0 ${-12 * index}px`,
|
|
442
|
+
// Only 3 toasts are visible in the stack at once, but all toasts are in the DOM.
|
|
443
|
+
// This allows view transitions to smoothly animate them from where they would be
|
|
444
|
+
// in the collapsed stack to their final position in the expanded list.
|
|
445
|
+
opacity: index >= 3 ? 0 : 1,
|
|
446
|
+
zIndex: visibleToasts.length - index - 1,
|
|
447
|
+
// When reduced motion is enabled, use append index to view-transition-name
|
|
448
|
+
// so that adding/removing a toast cross fades instead of transitioning the position.
|
|
449
|
+
// This works because the toasts are seen as separate elements instead of the same one when their index changes.
|
|
450
|
+
viewTransitionName: toast.key + (props.reduceMotion ? '-' + index : ''),
|
|
451
|
+
viewTransitionClass: [
|
|
452
|
+
(0, ($parcel$interopDefault($jeXmD$Toast_modulemjs))).toast,
|
|
453
|
+
(0, ($parcel$interopDefault($jeXmD$Toast_modulemjs)))['background-toast']
|
|
454
|
+
].map((c)=>CSS.escape(c)).join(' ')
|
|
455
|
+
},
|
|
456
|
+
className: (0, ($parcel$interopDefault($jeXmD$Toast_modulemjs))).toast + $6e462db325878d1a$var$toastStyle({
|
|
457
|
+
variant: toast.content.variant || 'info',
|
|
458
|
+
index: index,
|
|
459
|
+
isExpanded: isExpanded
|
|
460
|
+
})
|
|
461
|
+
});
|
|
462
|
+
return /*#__PURE__*/ (0, $jeXmD$jsxs)((0, $jeXmD$UNSTABLE_Toast), {
|
|
463
|
+
ref: toastRef,
|
|
464
|
+
toast: toast,
|
|
465
|
+
style: {
|
|
466
|
+
zIndex: visibleToasts.length - index - 1,
|
|
467
|
+
viewTransitionName: toast.key,
|
|
468
|
+
viewTransitionClass: [
|
|
469
|
+
(0, ($parcel$interopDefault($jeXmD$Toast_modulemjs))).toast,
|
|
470
|
+
!isMain ? (0, ($parcel$interopDefault($jeXmD$Toast_modulemjs)))['background-toast'] : '',
|
|
471
|
+
(0, ($parcel$interopDefault($jeXmD$Toast_modulemjs)))[placement],
|
|
472
|
+
(0, ($parcel$interopDefault($jeXmD$Toast_modulemjs)))[align]
|
|
473
|
+
].filter(Boolean).map((c)=>CSS.escape(c)).join(' ')
|
|
474
|
+
},
|
|
475
|
+
className: (renderProps)=>(0, ($parcel$interopDefault($jeXmD$Toast_modulemjs))).toast + (0, $feb886035e0d4633$export$e618dc39ac9ad607)($6e462db325878d1a$var$toastFocusRing({
|
|
476
|
+
...renderProps,
|
|
477
|
+
isExpanded: isExpanded
|
|
478
|
+
}), $6e462db325878d1a$var$toastStyle({
|
|
479
|
+
variant: toast.content.variant || 'info',
|
|
480
|
+
index: index,
|
|
481
|
+
isExpanded: isExpanded
|
|
482
|
+
})),
|
|
483
|
+
children: [
|
|
484
|
+
/*#__PURE__*/ (0, $jeXmD$jsxs)("div", {
|
|
485
|
+
role: "presentation",
|
|
486
|
+
className: $6e462db325878d1a$var$toastBody({
|
|
487
|
+
isSingle: !isMain || visibleToasts.length <= 1 || isExpanded
|
|
488
|
+
}),
|
|
489
|
+
children: [
|
|
490
|
+
/*#__PURE__*/ (0, $jeXmD$jsxs)((0, $jeXmD$UNSTABLE_ToastContent), {
|
|
491
|
+
className: $6e462db325878d1a$var$toastContent + (ctx && isMain ? ` ${(0, ($parcel$interopDefault($jeXmD$Toast_modulemjs)))['toast-content']}` : null),
|
|
492
|
+
children: [
|
|
493
|
+
Icon && /*#__PURE__*/ (0, $jeXmD$jsx)((0, $1f4b04be3f24aae3$export$768dac55bb57081d), {
|
|
494
|
+
children: /*#__PURE__*/ (0, $jeXmD$jsx)(Icon, {})
|
|
495
|
+
}),
|
|
496
|
+
/*#__PURE__*/ (0, $jeXmD$jsx)((0, $8e847109a6ab556d$export$5f1af8db9871e1d6), {
|
|
497
|
+
slot: "title",
|
|
498
|
+
children: toast.content.children
|
|
499
|
+
})
|
|
500
|
+
]
|
|
501
|
+
}),
|
|
502
|
+
!isExpanded && visibleToasts.length > 1 && /*#__PURE__*/ (0, $jeXmD$jsxs)((0, $da878a05ab4a403e$export$cfc7921d29ef7b80), {
|
|
503
|
+
isQuiet: true,
|
|
504
|
+
staticColor: "white",
|
|
505
|
+
styles: " __b-pb684p __c-pb684p __d-pb684p __e-pb684p",
|
|
506
|
+
// Make the chevron line up with the toast text, even though there is padding within the button.
|
|
507
|
+
UNSAFE_style: {
|
|
508
|
+
marginInlineStart: variant === 'neutral' ? -10 : 14
|
|
509
|
+
},
|
|
510
|
+
UNSAFE_className: ctx && isMain ? (0, ($parcel$interopDefault($jeXmD$Toast_modulemjs)))['toast-expand'] : undefined,
|
|
511
|
+
onPress: ()=>{
|
|
512
|
+
// This button disappears when clicked, so move focus to the toast.
|
|
513
|
+
toastRef.current?.focus();
|
|
514
|
+
ctx?.toggleExpanded();
|
|
515
|
+
},
|
|
516
|
+
children: [
|
|
517
|
+
/*#__PURE__*/ (0, $jeXmD$jsx)((0, $8e847109a6ab556d$export$5f1af8db9871e1d6), {
|
|
518
|
+
children: stringFormatter.format('toast.showAll')
|
|
519
|
+
}),
|
|
520
|
+
/*#__PURE__*/ (0, $jeXmD$jsx)((0, $e59ae2a33cca2ebf$export$2e2bcd8739ae039), {
|
|
521
|
+
UNSAFE_style: {
|
|
522
|
+
rotate: placement === 'bottom' ? '180deg' : undefined
|
|
523
|
+
}
|
|
524
|
+
})
|
|
525
|
+
]
|
|
526
|
+
}),
|
|
527
|
+
toast.content.actionLabel && /*#__PURE__*/ (0, $jeXmD$jsx)((0, $067ea9f64ccd4e8e$export$353f5b6fc5456de1), {
|
|
528
|
+
variant: "secondary",
|
|
529
|
+
fillStyle: "outline",
|
|
530
|
+
staticColor: "white",
|
|
531
|
+
onPress: ()=>{
|
|
532
|
+
toast.content.onAction?.();
|
|
533
|
+
if (toast.content.shouldCloseOnAction) state.close(toast.key);
|
|
534
|
+
},
|
|
535
|
+
UNSAFE_className: ctx && isMain ? (0, ($parcel$interopDefault($jeXmD$Toast_modulemjs)))['toast-action'] : undefined,
|
|
536
|
+
styles: " y_d __b-1wfgop3 __c-1wfgop3 __d-1wfgop3 __e-1wfgop3",
|
|
537
|
+
children: toast.content.actionLabel
|
|
538
|
+
})
|
|
539
|
+
]
|
|
540
|
+
}),
|
|
541
|
+
/*#__PURE__*/ (0, $jeXmD$jsx)((0, $a9cda54c4f47ce52$export$de65de8213222d10), {
|
|
542
|
+
staticColor: "white",
|
|
543
|
+
UNSAFE_className: ctx && isMain ? (0, ($parcel$interopDefault($jeXmD$Toast_modulemjs)))['toast-close'] : undefined
|
|
544
|
+
})
|
|
545
|
+
]
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
export {$6e462db325878d1a$export$f1f8569633bbbec4 as ToastQueue, $6e462db325878d1a$export$f2815235e76a62b9 as ToastContainer, $6e462db325878d1a$export$f9b1e1c88454fa08 as SpectrumToast};
|
|
551
|
+
//# sourceMappingURL=Toast.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;AAyDD,SAAS,0CAAoB,EAAc,EAAE,IAAY;IACvD,IAAI,yBAAyB,UAAU;QACrC,6GAA6G;QAC7G,SAAS,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA,GAAA,gDAAO,CAAC,CAAC,KAAK;QACrD,IAAI,iBAAiB,SAAS,mBAAmB,CAAC;YAChD,QAAQ,IAAM,CAAA,GAAA,gBAAQ,EAAE;YACxB,OAAO;gBAAC,CAAA,GAAA,gDAAO,CAAC,CAAC,KAAK;aAAC;QACzB;QAEA,eAAe,KAAK,CAAC,KAAK,CAAC,KAAO;QAClC,eAAe,QAAQ,CAAC,IAAI,CAAC;YAC3B,SAAS,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA,GAAA,gDAAO,CAAC,CAAC,KAAK;QAC1D;IACF,OACE;AAEJ;AAEA,uFAAuF;AACvF,IAAI,yCAA0D;AAC9D,SAAS;IACP,IAAI,CAAC,wCACH,yCAAmB,IAAI,CAAA,GAAA,0BAAS,EAAE;QAChC,kBAAkB;QAClB,YAAW,EAAE,EAAE,MAAM;YACnB,0CAAoB,IAAI,CAAC,MAAM,EAAE,QAAQ;QAC3C;IACF;IAGF,OAAO;AACT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;;AAGpE","sources":["packages/@react-spectrum/s2/src/Toast.tsx"],"sourcesContent":["/*\n * Copyright 2025 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 {ActionButton} from './ActionButton';\nimport AlertIcon from '../s2wf-icons/S2_Icon_AlertTriangle_20_N.svg';\nimport {Button} from './Button';\nimport {CenterBaseline} from './CenterBaseline';\nimport CheckmarkIcon from '../s2wf-icons/S2_Icon_CheckmarkCircle_20_N.svg';\nimport Chevron from '../s2wf-icons/S2_Icon_ChevronDown_20_N.svg';\nimport {CloseButton} from './CloseButton';\nimport {createContext, ReactNode, useContext, useEffect, useMemo, useRef} from 'react';\nimport {DOMProps} from '@react-types/shared';\nimport {filterDOMProps, useEvent} from '@react-aria/utils';\nimport {flushSync} from 'react-dom';\nimport {focusRing, style} from '../style' with {type: 'macro'};\nimport {FocusScope, useModalOverlay} from 'react-aria';\nimport InfoIcon from '../s2wf-icons/S2_Icon_InfoCircle_20_N.svg';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {mergeStyles} from '../style/runtime';\nimport {ToastOptions as RACToastOptions, UNSTABLE_Toast as Toast, UNSTABLE_ToastContent as ToastContent, UNSTABLE_ToastList as ToastList, ToastProps, UNSTABLE_ToastQueue as ToastQueue, UNSTABLE_ToastRegion as ToastRegion, ToastRegionProps, UNSTABLE_ToastStateContext as ToastStateContext} from 'react-aria-components';\nimport {Text} from './Content';\nimport toastCss from './Toast.module.css';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMediaQuery} from '@react-spectrum/utils';\nimport {useOverlayTriggerState} from 'react-stately';\n\nexport type ToastPlacement = 'top' | 'top end' | 'bottom' | 'bottom end';\nexport interface ToastContainerProps extends Omit<ToastRegionProps<SpectrumToastValue>, 'queue' | 'children'> {\n /**\n * Placement of the toast container on the page.\n * @default \"bottom\"\n */\n placement?: ToastPlacement\n}\n\nexport interface ToastOptions extends Omit<RACToastOptions, '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\nexport interface SpectrumToastValue extends DOMProps {\n /** The content of the toast. */\n children: string,\n /** The variant (i.e. color) of the toast. */\n variant: 'positive' | 'negative' | 'info' | 'neutral',\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\nfunction startViewTransition(fn: () => void, type: string) {\n if ('startViewTransition' in document) {\n // Safari doesn't support :active-view-transition-type() yet, so we fall back to a class on the html element.\n document.documentElement.classList.add(toastCss[type]);\n let viewTransition = document.startViewTransition({\n update: () => flushSync(fn),\n types: [toastCss[type]]\n });\n\n viewTransition.ready.catch(() => {});\n viewTransition.finished.then(() => {\n document.documentElement.classList.remove(toastCss[type]);\n });\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(fn, action) {\n startViewTransition(fn, `toast-${action}`);\n }\n });\n }\n\n return globalToastQueue;\n}\n\nfunction addToast(children: string, variant: SpectrumToastValue['variant'], options: ToastOptions = {}) {\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.actionLabel ? 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\ntype CloseFunction = () => void;\n\nconst SpectrumToastQueue = {\n /** Queues a neutral toast. */\n neutral(children: string, options: ToastOptions = {}): CloseFunction {\n return addToast(children, 'neutral', options);\n },\n /** Queues a positive toast. */\n positive(children: string, options: ToastOptions = {}): CloseFunction {\n return addToast(children, 'positive', options);\n },\n /** Queues a negative toast. */\n negative(children: string, options: ToastOptions = {}): CloseFunction {\n return addToast(children, 'negative', options);\n },\n /** Queues an informational toast. */\n info(children: string, options: ToastOptions = {}): CloseFunction {\n return addToast(children, 'info', options);\n }\n};\n\nexport {SpectrumToastQueue as ToastQueue};\n\nconst toastRegion = style({\n ...focusRing(),\n display: 'flex',\n flexDirection: {\n placement: {\n top: 'column',\n bottom: 'column-reverse'\n }\n },\n position: 'fixed',\n insetX: 0,\n width: 'fit',\n top: {\n placement: {\n top: {\n default: 16,\n isExpanded: 0\n }\n }\n },\n bottom: {\n placement: {\n bottom: {\n default: 16,\n isExpanded: 0\n }\n }\n },\n marginStart: {\n align: {\n start: 16,\n center: 'auto',\n end: 'auto'\n }\n },\n marginEnd: {\n align: {\n start: 'auto',\n center: 'auto',\n end: 16\n }\n },\n boxSizing: 'border-box',\n maxHeight: 'screen',\n borderRadius: 'lg'\n});\n\nconst toastList = style({\n position: 'relative',\n flexGrow: 1,\n display: 'flex',\n gap: 8,\n flexDirection: {\n placement: {\n top: 'column',\n bottom: 'column-reverse'\n }\n },\n boxSizing: 'border-box',\n marginY: 0,\n padding: {\n default: 0,\n // Add padding when expanded to account for focus ring.\n isExpanded: 8\n },\n paddingBottom: {\n isExpanded: {\n placement: {\n top: 8,\n bottom: 16\n }\n }\n },\n paddingTop: {\n isExpanded: {\n placement: {\n top: 16,\n bottom: 8\n }\n }\n },\n margin: 0,\n marginX: {\n default: 0,\n // Undo padding for focus ring.\n isExpanded: -8\n },\n overflow: {\n isExpanded: 'auto'\n }\n});\n\n// Separate style macro for focus ring and toast so that\n// isFocusVisible doesn't cause toast background to change.\nconst toastFocusRing = style({\n ...focusRing(),\n outlineColor: {\n default: 'focus-ring',\n isExpanded: 'white'\n }\n});\n\nconst toastStyle = style({\n display: 'flex',\n gap: 16,\n paddingStart: 16,\n paddingEnd: 8,\n paddingY: 12,\n borderRadius: 'lg',\n minHeight: 56,\n '--maxWidth': {\n type: 'maxWidth',\n value: 336\n },\n maxWidth: '[min(var(--maxWidth), 90vw)]',\n boxSizing: 'border-box',\n flexShrink: 0,\n font: 'ui',\n color: 'white',\n backgroundColor: {\n variant: {\n neutral: 'neutral-subdued',\n info: 'informative',\n positive: 'positive',\n negative: 'negative'\n }\n },\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n },\n boxShadow: {\n default: 'elevated',\n isExpanded: 'none'\n }\n});\n\nconst toastBody = style({\n // The top toast in a non-expanded stack has the expand button, so it is rendered as a grid.\n // Otherwise it uses flex so the content can wrap when needed.\n display: {\n default: 'grid',\n isSingle: 'flex'\n },\n gridTemplateColumns: ['auto', '1fr', 'auto'],\n gridTemplateAreas: [\n 'content content content',\n 'expand . action'\n ],\n flexGrow: 1,\n flexWrap: 'wrap',\n alignItems: 'center',\n columnGap: 24,\n rowGap: 8\n});\n\nconst toastContent = style({\n display: 'flex',\n gap: 8,\n alignItems: 'baseline',\n gridArea: 'content',\n cursor: 'default',\n width: 'fit'\n});\n\nconst controls = style({\n colorScheme: 'light',\n display: {\n default: 'none',\n isExpanded: 'flex'\n },\n justifyContent: 'end',\n gap: 8,\n opacity: {\n default: 0,\n isExpanded: 1\n }\n});\n\nconst ICONS = {\n info: InfoIcon,\n negative: AlertIcon,\n positive: CheckmarkIcon\n};\n\ninterface ToastContainerContextValue {\n isExpanded: boolean,\n toggleExpanded: () => void\n}\n\nconst ToastContainerContext = createContext<ToastContainerContextValue | null>(null);\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: ToastContainerProps): ReactNode {\n let {\n placement = 'bottom'\n } = props;\n let queue = getGlobalToastQueue();\n let align = 'center';\n [placement, align = 'center'] = placement.split(' ') as any;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n let regionRef = useRef<HTMLDivElement | null>(null);\n\n let state = useOverlayTriggerState({});\n let {isOpen: isExpanded, close, toggle} = state;\n let ctx = useMemo(() => ({\n isExpanded,\n toggleExpanded() {\n if (!isExpanded && queue.visibleToasts.length <= 1) {\n return;\n }\n\n startViewTransition(\n () => toggle(),\n isExpanded ? 'toast-collapse' : 'toast-expand'\n );\n }\n }), [isExpanded, toggle, queue]);\n\n // Set the state to collapsed whenever the queue is emptied.\n useEffect(() => {\n return queue.subscribe(() => {\n if (queue.visibleToasts.length === 0 && isExpanded) {\n close();\n }\n });\n }, [queue, isExpanded, close]);\n\n let collapse = () => {\n regionRef.current?.focus();\n ctx.toggleExpanded();\n };\n\n // Prevent scroll, aria hide outside, and contain focus when expanded, since we take over the whole screen.\n // Attach event handler to the ref since ToastRegion doesn't pass through onKeyDown.\n useModalOverlay({}, state, regionRef);\n useEvent(regionRef, 'keydown', isExpanded ? (e) => {\n if (e.key === 'Escape') {\n collapse();\n }\n } : undefined);\n\n return (\n <ToastRegion\n {...props}\n ref={regionRef}\n queue={queue}\n className={renderProps => toastRegion({\n ...renderProps,\n placement,\n align,\n isExpanded\n })}>\n <FocusScope contain={isExpanded}>\n <ToastContainerContext.Provider value={ctx}>\n {isExpanded && (\n // eslint-disable-next-line\n <div\n className={toastCss['toast-background'] + style({position: 'fixed', inset: 0, backgroundColor: 'transparent-black-500'})}\n onClick={collapse} />\n )}\n <SpectrumToastList placement={placement} align={align} />\n <div className={toastCss['toast-controls'] + controls({isExpanded})}>\n <ActionButton\n size=\"S\"\n onPress={() => queue.clear()}\n // Default focus ring does not have enough contrast against gray background.\n UNSAFE_style={{outlineColor: 'white'}}>\n {stringFormatter.format('toast.clearAll')}\n </ActionButton>\n <ActionButton\n size=\"S\"\n onPress={collapse}\n UNSAFE_style={{outlineColor: 'white'}}>\n {stringFormatter.format('toast.collapse')}\n </ActionButton>\n </div>\n </ToastContainerContext.Provider>\n </FocusScope>\n </ToastRegion>\n );\n}\n\nfunction SpectrumToastList({placement, align}) {\n let {isExpanded, toggleExpanded} = useContext(ToastContainerContext)!;\n\n // Attach click handler to ref since ToastList doesn't pass through onClick/onPress.\n let toastListRef = useRef(null);\n useEvent(toastListRef, 'click', (e) => {\n // Have to check if this is a button because stopPropagation in react events doesn't affect native events.\n if (!isExpanded && !(e.target as Element)?.closest('button')) {\n toggleExpanded();\n }\n });\n\n let reduceMotion = useMediaQuery('(prefers-reduced-motion)');\n\n return (\n <ToastList<SpectrumToastValue>\n ref={toastListRef}\n style={({isHovered}) => {\n let origin = isHovered ? 95 : 55;\n return {\n perspective: 80,\n perspectiveOrigin: 'center ' + (placement === 'top' ? `calc(100% + ${origin}px)` : `${-origin}px`),\n transition: 'perspective-origin 400ms'\n };\n }}\n className={toastCss[isExpanded ? 'toast-list-expanded' : 'toast-list-collapsed'] + toastList({placement, align, isExpanded})}>\n {({toast}) => (\n <SpectrumToast\n toast={toast}\n placement={placement}\n align={align}\n reduceMotion={reduceMotion} />\n )}\n </ToastList>\n );\n}\n\ninterface SpectrumToastProps extends ToastProps<SpectrumToastValue> {\n placement?: 'top' | 'bottom',\n align?: 'start' | 'center' | 'end',\n reduceMotion?: boolean\n}\n\n// Exported locally for stories.\nexport function SpectrumToast(props: SpectrumToastProps): ReactNode {\n let {toast, placement = 'bottom', align = 'center'} = props;\n let variant = toast.content.variant || 'info';\n let Icon = ICONS[variant];\n let state = useContext(ToastStateContext)!;\n let visibleToasts = state.visibleToasts;\n let index = visibleToasts.indexOf(toast);\n let isMain = index <= 0;\n let ctx = useContext(ToastContainerContext);\n let isExpanded = ctx?.isExpanded || false;\n let toastRef = useRef<HTMLDivElement | null>(null);\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n\n // When not expanded, use a presentational div for the toasts behind the top one.\n // The content is invisible, all we show is the background color.\n if (!isMain && ctx && !ctx.isExpanded) {\n return (\n <div\n role=\"presentation\"\n style={{\n position: 'absolute',\n [placement === 'top' ? 'bottom' : 'top']: 0,\n left: 0,\n width: '100%',\n translate: `0 0 ${(-12 * index)}px`,\n // Only 3 toasts are visible in the stack at once, but all toasts are in the DOM.\n // This allows view transitions to smoothly animate them from where they would be \n // in the collapsed stack to their final position in the expanded list.\n opacity: index >= 3 ? 0 : 1,\n zIndex: visibleToasts.length - index - 1,\n // When reduced motion is enabled, use append index to view-transition-name\n // so that adding/removing a toast cross fades instead of transitioning the position.\n // This works because the toasts are seen as separate elements instead of the same one when their index changes.\n viewTransitionName: toast.key + (props.reduceMotion ? '-' + index : ''),\n viewTransitionClass: [toastCss.toast, toastCss['background-toast']].map(c => CSS.escape(c)).join(' ')\n }}\n className={toastCss.toast + toastStyle({variant: toast.content.variant || 'info', index, isExpanded})} />\n );\n }\n\n return (\n <Toast\n ref={toastRef}\n toast={toast}\n style={{\n zIndex: visibleToasts.length - index - 1,\n viewTransitionName: toast.key,\n viewTransitionClass: [toastCss.toast, !isMain ? toastCss['background-toast'] : '', toastCss[placement], toastCss[align]].filter(Boolean).map(c => CSS.escape(c)).join(' ')\n }}\n className={renderProps => toastCss.toast + mergeStyles(\n toastFocusRing({...renderProps, isExpanded}),\n toastStyle({\n variant: toast.content.variant || 'info',\n index,\n isExpanded\n })\n )}>\n <div role=\"presentation\" className={toastBody({isSingle: !isMain || visibleToasts.length <= 1 || isExpanded})}>\n <ToastContent className={toastContent + (ctx && isMain ? ` ${toastCss['toast-content']}` : null)}>\n {Icon &&\n <CenterBaseline>\n <Icon />\n </CenterBaseline>\n }\n <Text slot=\"title\">{toast.content.children}</Text>\n </ToastContent>\n {!isExpanded && visibleToasts.length > 1 && \n <ActionButton\n isQuiet\n staticColor=\"white\"\n styles={style({gridArea: 'expand'})}\n // Make the chevron line up with the toast text, even though there is padding within the button.\n UNSAFE_style={{marginInlineStart: variant === 'neutral' ? -10 : 14}}\n UNSAFE_className={ctx && isMain ? toastCss['toast-expand'] : undefined}\n onPress={() => {\n // This button disappears when clicked, so move focus to the toast.\n toastRef.current?.focus();\n ctx?.toggleExpanded();\n }}>\n <Text>{stringFormatter.format('toast.showAll')}</Text>\n {/* @ts-ignore */}\n <Chevron UNSAFE_style={{rotate: placement === 'bottom' ? '180deg' : undefined}} />\n </ActionButton>\n }\n {toast.content.actionLabel &&\n <Button\n variant=\"secondary\"\n fillStyle=\"outline\"\n staticColor=\"white\"\n onPress={() => {\n toast.content.onAction?.();\n if (toast.content.shouldCloseOnAction) {\n state.close(toast.key);\n }\n }}\n UNSAFE_className={ctx && isMain ? toastCss['toast-action'] : undefined}\n styles={style({marginStart: 'auto', gridArea: 'action'})}>\n {toast.content.actionLabel}\n </Button>\n }\n </div>\n <CloseButton\n staticColor=\"white\"\n UNSAFE_className={ctx && isMain ? toastCss['toast-close'] : undefined} />\n </Toast>\n );\n}\n"],"names":[],"version":3,"file":"Toast.mjs.map"}
|