@radix-ui/react-toast 0.1.2-rc.4 → 0.1.2-rc.42
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +584 -1
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +565 -1
- package/dist/index.module.js.map +1 -1
- package/package.json +13 -13
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Primitive } from "@radix-ui/react-primitive";
|
|
|
5
5
|
type SwipeDirection = 'up' | 'down' | 'left' | 'right';
|
|
6
6
|
export const createToastScope: import("@radix-ui/react-context").CreateScope;
|
|
7
7
|
export interface ToastProviderProps {
|
|
8
|
+
children?: React.ReactNode;
|
|
8
9
|
/**
|
|
9
10
|
* An author-localized label for each toast. Used to help screen reader users
|
|
10
11
|
* associate the interruption with a toast.
|
|
@@ -26,7 +27,6 @@ export interface ToastProviderProps {
|
|
|
26
27
|
* @defaultValue 50
|
|
27
28
|
*/
|
|
28
29
|
swipeThreshold?: number;
|
|
29
|
-
children?: React.ReactNode;
|
|
30
30
|
}
|
|
31
31
|
export const ToastProvider: React.FC<ToastProviderProps>;
|
|
32
32
|
type PrimitiveOrderedListProps = Radix.ComponentPropsWithoutRef<typeof Primitive.ol>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":"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","sources":["packages/react/toast/src/packages/react/toast/src/Toast.tsx","packages/react/toast/src/packages/react/toast/src/index.ts","packages/react/toast/src/index.ts"],"sourcesContent":[null,null,"export * from './Toast';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,585 @@
|
|
|
1
|
-
var
|
|
1
|
+
var $iTyic$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
|
|
2
|
+
var $iTyic$react = require("react");
|
|
3
|
+
var $iTyic$reactdom = require("react-dom");
|
|
4
|
+
var $iTyic$radixuiprimitive = require("@radix-ui/primitive");
|
|
5
|
+
var $iTyic$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
|
|
6
|
+
var $iTyic$radixuireactcontext = require("@radix-ui/react-context");
|
|
7
|
+
var $iTyic$radixuireactdismissablelayer = require("@radix-ui/react-dismissable-layer");
|
|
8
|
+
var $iTyic$radixuireactportal = require("@radix-ui/react-portal");
|
|
9
|
+
var $iTyic$radixuireactpresence = require("@radix-ui/react-presence");
|
|
10
|
+
var $iTyic$radixuireactprimitive = require("@radix-ui/react-primitive");
|
|
11
|
+
var $iTyic$radixuireactusecallbackref = require("@radix-ui/react-use-callback-ref");
|
|
12
|
+
var $iTyic$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
|
|
13
|
+
var $iTyic$radixuireactuselayouteffect = require("@radix-ui/react-use-layout-effect");
|
|
14
|
+
var $iTyic$radixuireactvisuallyhidden = require("@radix-ui/react-visually-hidden");
|
|
15
|
+
|
|
16
|
+
function $parcel$exportWildcard(dest, source) {
|
|
17
|
+
Object.keys(source).forEach(function(key) {
|
|
18
|
+
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Object.defineProperty(dest, key, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function get() {
|
|
25
|
+
return source[key];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return dest;
|
|
31
|
+
}
|
|
32
|
+
function $parcel$interopDefault(a) {
|
|
33
|
+
return a && a.__esModule ? a.default : a;
|
|
34
|
+
}
|
|
35
|
+
function $parcel$export(e, n, v, s) {
|
|
36
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
37
|
+
}
|
|
38
|
+
var $9208a85b3e79d33f$exports = {};
|
|
39
|
+
|
|
40
|
+
$parcel$export($9208a85b3e79d33f$exports, "createToastScope", () => $9208a85b3e79d33f$export$8a359da18fbc9073);
|
|
41
|
+
$parcel$export($9208a85b3e79d33f$exports, "ToastProvider", () => $9208a85b3e79d33f$export$f5d03d415824e0e);
|
|
42
|
+
$parcel$export($9208a85b3e79d33f$exports, "ToastViewport", () => $9208a85b3e79d33f$export$6192c2425ecfd989);
|
|
43
|
+
$parcel$export($9208a85b3e79d33f$exports, "Toast", () => $9208a85b3e79d33f$export$8d8dc7d5f743331b);
|
|
44
|
+
$parcel$export($9208a85b3e79d33f$exports, "ToastTitle", () => $9208a85b3e79d33f$export$16d42d7c29b95a4);
|
|
45
|
+
$parcel$export($9208a85b3e79d33f$exports, "ToastDescription", () => $9208a85b3e79d33f$export$ecddd96c53621d9a);
|
|
46
|
+
$parcel$export($9208a85b3e79d33f$exports, "ToastAction", () => $9208a85b3e79d33f$export$3019feecfda683d2);
|
|
47
|
+
$parcel$export($9208a85b3e79d33f$exports, "ToastClose", () => $9208a85b3e79d33f$export$811e70f61c205839);
|
|
48
|
+
$parcel$export($9208a85b3e79d33f$exports, "Provider", () => $9208a85b3e79d33f$export$2881499e37b75b9a);
|
|
49
|
+
$parcel$export($9208a85b3e79d33f$exports, "Viewport", () => $9208a85b3e79d33f$export$d5c6c08dc2d3ca7);
|
|
50
|
+
$parcel$export($9208a85b3e79d33f$exports, "Root", () => $9208a85b3e79d33f$export$be92b6f5f03c0fe9);
|
|
51
|
+
$parcel$export($9208a85b3e79d33f$exports, "Title", () => $9208a85b3e79d33f$export$f99233281efd08a0);
|
|
52
|
+
$parcel$export($9208a85b3e79d33f$exports, "Description", () => $9208a85b3e79d33f$export$393edc798c47379d);
|
|
53
|
+
$parcel$export($9208a85b3e79d33f$exports, "Action", () => $9208a85b3e79d33f$export$e19cd5f9376f8cee);
|
|
54
|
+
$parcel$export($9208a85b3e79d33f$exports, "Close", () => $9208a85b3e79d33f$export$f39c2d165cd861fe);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
/* -------------------------------------------------------------------------------------------------
|
|
70
|
+
* ToastProvider
|
|
71
|
+
* -----------------------------------------------------------------------------------------------*/ const $9208a85b3e79d33f$var$PROVIDER_NAME = 'ToastProvider';
|
|
72
|
+
const [$9208a85b3e79d33f$var$createToastContext, $9208a85b3e79d33f$export$8a359da18fbc9073] = $iTyic$radixuireactcontext.createContextScope('Toast');
|
|
73
|
+
const [$9208a85b3e79d33f$var$ToastProviderProvider, $9208a85b3e79d33f$var$useToastProviderContext] = $9208a85b3e79d33f$var$createToastContext($9208a85b3e79d33f$var$PROVIDER_NAME);
|
|
74
|
+
const $9208a85b3e79d33f$export$f5d03d415824e0e = (props)=>{
|
|
75
|
+
const { __scopeToast: __scopeToast , label: label = 'Notification' , duration: duration = 5000 , swipeDirection: swipeDirection = 'right' , swipeThreshold: swipeThreshold = 50 , children: children } = props;
|
|
76
|
+
const [viewport, setViewport] = $iTyic$react.useState(null);
|
|
77
|
+
const [toastCount, setToastCount] = $iTyic$react.useState(0);
|
|
78
|
+
const isFocusedToastEscapeKeyDownRef = $iTyic$react.useRef(false);
|
|
79
|
+
const isClosePausedRef = $iTyic$react.useRef(false);
|
|
80
|
+
return /*#__PURE__*/ $iTyic$react.createElement($9208a85b3e79d33f$var$ToastProviderProvider, {
|
|
81
|
+
scope: __scopeToast,
|
|
82
|
+
label: label,
|
|
83
|
+
duration: duration,
|
|
84
|
+
swipeDirection: swipeDirection,
|
|
85
|
+
swipeThreshold: swipeThreshold,
|
|
86
|
+
toastCount: toastCount,
|
|
87
|
+
viewport: viewport,
|
|
88
|
+
onViewportChange: setViewport,
|
|
89
|
+
onToastAdd: $iTyic$react.useCallback(()=>setToastCount((prevCount)=>prevCount + 1
|
|
90
|
+
)
|
|
91
|
+
, []),
|
|
92
|
+
onToastRemove: $iTyic$react.useCallback(()=>setToastCount((prevCount)=>prevCount - 1
|
|
93
|
+
)
|
|
94
|
+
, []),
|
|
95
|
+
isFocusedToastEscapeKeyDownRef: isFocusedToastEscapeKeyDownRef,
|
|
96
|
+
isClosePausedRef: isClosePausedRef
|
|
97
|
+
}, children);
|
|
98
|
+
};
|
|
99
|
+
/*#__PURE__*/ Object.assign($9208a85b3e79d33f$export$f5d03d415824e0e, {
|
|
100
|
+
displayName: $9208a85b3e79d33f$var$PROVIDER_NAME
|
|
101
|
+
});
|
|
102
|
+
/* -------------------------------------------------------------------------------------------------
|
|
103
|
+
* ToastViewport
|
|
104
|
+
* -----------------------------------------------------------------------------------------------*/ const $9208a85b3e79d33f$var$VIEWPORT_NAME = 'ToastViewport';
|
|
105
|
+
const $9208a85b3e79d33f$var$VIEWPORT_DEFAULT_HOTKEY = [
|
|
106
|
+
'F8'
|
|
107
|
+
];
|
|
108
|
+
const $9208a85b3e79d33f$var$VIEWPORT_PAUSE = 'toast.viewportPause';
|
|
109
|
+
const $9208a85b3e79d33f$var$VIEWPORT_RESUME = 'toast.viewportResume';
|
|
110
|
+
const $9208a85b3e79d33f$export$6192c2425ecfd989 = /*#__PURE__*/ $iTyic$react.forwardRef((props, forwardedRef)=>{
|
|
111
|
+
const { __scopeToast: __scopeToast , hotkey: hotkey = $9208a85b3e79d33f$var$VIEWPORT_DEFAULT_HOTKEY , label: label = 'Notifications ({hotkey})' , ...viewportProps } = props;
|
|
112
|
+
const context = $9208a85b3e79d33f$var$useToastProviderContext($9208a85b3e79d33f$var$VIEWPORT_NAME, __scopeToast);
|
|
113
|
+
const wrapperRef = $iTyic$react.useRef(null);
|
|
114
|
+
const ref = $iTyic$react.useRef(null);
|
|
115
|
+
const composedRefs = $iTyic$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref, context.onViewportChange);
|
|
116
|
+
const hotkeyLabel = hotkey.join('+').replace(/Key/g, '').replace(/Digit/g, '');
|
|
117
|
+
$iTyic$react.useEffect(()=>{
|
|
118
|
+
const handleKeyDown = (event)=>{
|
|
119
|
+
var _ref$current;
|
|
120
|
+
// we use `event.code` as it is consistent regardless of meta keys that were pressed.
|
|
121
|
+
// for example, `event.key` for `Control+Alt+t` is `†` and `t !== †`
|
|
122
|
+
const isHotkeyPressed = hotkey.every((key)=>event[key] || event.code === key
|
|
123
|
+
);
|
|
124
|
+
if (isHotkeyPressed) (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.focus();
|
|
125
|
+
};
|
|
126
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
127
|
+
return ()=>document.removeEventListener('keydown', handleKeyDown)
|
|
128
|
+
;
|
|
129
|
+
}, [
|
|
130
|
+
hotkey
|
|
131
|
+
]);
|
|
132
|
+
$iTyic$react.useEffect(()=>{
|
|
133
|
+
const wrapper = wrapperRef.current;
|
|
134
|
+
const viewport = ref.current;
|
|
135
|
+
if (wrapper && viewport) {
|
|
136
|
+
const handlePause = ()=>{
|
|
137
|
+
const pauseEvent = new CustomEvent($9208a85b3e79d33f$var$VIEWPORT_PAUSE);
|
|
138
|
+
viewport.dispatchEvent(pauseEvent);
|
|
139
|
+
context.isClosePausedRef.current = true;
|
|
140
|
+
};
|
|
141
|
+
const handleResume = ()=>{
|
|
142
|
+
const resumeEvent = new CustomEvent($9208a85b3e79d33f$var$VIEWPORT_RESUME);
|
|
143
|
+
viewport.dispatchEvent(resumeEvent);
|
|
144
|
+
context.isClosePausedRef.current = false;
|
|
145
|
+
}; // Toasts are not in the viewport React tree so we need to bind DOM events
|
|
146
|
+
wrapper.addEventListener('focusin', handlePause);
|
|
147
|
+
wrapper.addEventListener('focusout', handleResume);
|
|
148
|
+
wrapper.addEventListener('pointerenter', handlePause);
|
|
149
|
+
wrapper.addEventListener('pointerleave', handleResume);
|
|
150
|
+
window.addEventListener('blur', handlePause);
|
|
151
|
+
window.addEventListener('focus', handleResume);
|
|
152
|
+
return ()=>{
|
|
153
|
+
wrapper.removeEventListener('focusin', handlePause);
|
|
154
|
+
wrapper.removeEventListener('focusout', handleResume);
|
|
155
|
+
wrapper.removeEventListener('pointerenter', handlePause);
|
|
156
|
+
wrapper.removeEventListener('pointerleave', handleResume);
|
|
157
|
+
window.removeEventListener('blur', handlePause);
|
|
158
|
+
window.removeEventListener('focus', handleResume);
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}, [
|
|
162
|
+
context.isClosePausedRef
|
|
163
|
+
]);
|
|
164
|
+
$iTyic$react.useEffect(()=>{
|
|
165
|
+
const viewport = ref.current; // Re-order DOM so most recent toasts are at top of DOM structure to improve tab order
|
|
166
|
+
if (viewport) {
|
|
167
|
+
const prepended = new Set();
|
|
168
|
+
const observer = new MutationObserver((mutations)=>{
|
|
169
|
+
const addedNodes = mutations.map((mutation)=>Array.from(mutation.addedNodes)
|
|
170
|
+
).reduce((a, b)=>a.concat(b)
|
|
171
|
+
);
|
|
172
|
+
addedNodes.forEach((node)=>{
|
|
173
|
+
// mutation will immediately fire again when we prepend so we only prepend if
|
|
174
|
+
// it hasn't just prepended.
|
|
175
|
+
if (!prepended.has(node)) {
|
|
176
|
+
viewport.prepend(node);
|
|
177
|
+
prepended.add(node);
|
|
178
|
+
} else // this else catches the case where the mutation fires immediately after prepend.
|
|
179
|
+
// we remove from cache after it prepends to allow observer to catch future updates
|
|
180
|
+
// to DOM order, e.g. if `key` changes for a toast and is reportalled to bottom.
|
|
181
|
+
prepended.delete(node);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
observer.observe(viewport, {
|
|
185
|
+
childList: true
|
|
186
|
+
});
|
|
187
|
+
return ()=>observer.disconnect()
|
|
188
|
+
;
|
|
189
|
+
}
|
|
190
|
+
}, []);
|
|
191
|
+
return /*#__PURE__*/ $iTyic$react.createElement($iTyic$radixuireactdismissablelayer.Branch, {
|
|
192
|
+
ref: wrapperRef,
|
|
193
|
+
role: "region",
|
|
194
|
+
"aria-label": label.replace('{hotkey}', hotkeyLabel) // Ensure virtual cursor from landmarks menus triggers focus/blur for pause/resume
|
|
195
|
+
,
|
|
196
|
+
tabIndex: -1 // incase list has size when empty (e.g. padding), we remove pointer events so
|
|
197
|
+
,
|
|
198
|
+
style: {
|
|
199
|
+
pointerEvents: context.toastCount > 0 ? undefined : 'none'
|
|
200
|
+
}
|
|
201
|
+
}, /*#__PURE__*/ $iTyic$react.createElement($iTyic$radixuireactprimitive.Primitive.ol, ($parcel$interopDefault($iTyic$babelruntimehelpersextends))({
|
|
202
|
+
tabIndex: -1
|
|
203
|
+
}, viewportProps, {
|
|
204
|
+
ref: composedRefs
|
|
205
|
+
})));
|
|
206
|
+
});
|
|
207
|
+
/*#__PURE__*/ Object.assign($9208a85b3e79d33f$export$6192c2425ecfd989, {
|
|
208
|
+
displayName: $9208a85b3e79d33f$var$VIEWPORT_NAME
|
|
209
|
+
});
|
|
210
|
+
/* -------------------------------------------------------------------------------------------------
|
|
211
|
+
* Toast
|
|
212
|
+
* -----------------------------------------------------------------------------------------------*/ const $9208a85b3e79d33f$var$TOAST_NAME = 'Toast';
|
|
213
|
+
const $9208a85b3e79d33f$var$TOAST_SWIPE_START = 'toast.swipeStart';
|
|
214
|
+
const $9208a85b3e79d33f$var$TOAST_SWIPE_MOVE = 'toast.swipeMove';
|
|
215
|
+
const $9208a85b3e79d33f$var$TOAST_SWIPE_CANCEL = 'toast.swipeCancel';
|
|
216
|
+
const $9208a85b3e79d33f$var$TOAST_SWIPE_END = 'toast.swipeEnd';
|
|
217
|
+
const $9208a85b3e79d33f$export$8d8dc7d5f743331b = /*#__PURE__*/ $iTyic$react.forwardRef((props, forwardedRef)=>{
|
|
218
|
+
const { forceMount: forceMount , open: openProp , defaultOpen: defaultOpen , onOpenChange: onOpenChange , ...toastProps } = props;
|
|
219
|
+
const [open = true, setOpen] = $iTyic$radixuireactusecontrollablestate.useControllableState({
|
|
220
|
+
prop: openProp,
|
|
221
|
+
defaultProp: defaultOpen,
|
|
222
|
+
onChange: onOpenChange
|
|
223
|
+
});
|
|
224
|
+
return /*#__PURE__*/ $iTyic$react.createElement($iTyic$radixuireactpresence.Presence, {
|
|
225
|
+
present: forceMount || open
|
|
226
|
+
}, /*#__PURE__*/ $iTyic$react.createElement($9208a85b3e79d33f$var$ToastImpl, ($parcel$interopDefault($iTyic$babelruntimehelpersextends))({
|
|
227
|
+
open: open
|
|
228
|
+
}, toastProps, {
|
|
229
|
+
ref: forwardedRef,
|
|
230
|
+
onClose: ()=>setOpen(false)
|
|
231
|
+
,
|
|
232
|
+
onSwipeStart: $iTyic$radixuiprimitive.composeEventHandlers(props.onSwipeStart, (event)=>{
|
|
233
|
+
event.currentTarget.setAttribute('data-swipe', 'start');
|
|
234
|
+
}),
|
|
235
|
+
onSwipeMove: $iTyic$radixuiprimitive.composeEventHandlers(props.onSwipeMove, (event)=>{
|
|
236
|
+
const { x: x , y: y } = event.detail.delta;
|
|
237
|
+
event.currentTarget.setAttribute('data-swipe', 'move');
|
|
238
|
+
event.currentTarget.style.setProperty('--radix-toast-swipe-move-x', `${x}px`);
|
|
239
|
+
event.currentTarget.style.setProperty('--radix-toast-swipe-move-y', `${y}px`);
|
|
240
|
+
}),
|
|
241
|
+
onSwipeCancel: $iTyic$radixuiprimitive.composeEventHandlers(props.onSwipeCancel, (event)=>{
|
|
242
|
+
event.currentTarget.setAttribute('data-swipe', 'cancel');
|
|
243
|
+
event.currentTarget.style.removeProperty('--radix-toast-swipe-move-x');
|
|
244
|
+
event.currentTarget.style.removeProperty('--radix-toast-swipe-move-y');
|
|
245
|
+
event.currentTarget.style.removeProperty('--radix-toast-swipe-end-x');
|
|
246
|
+
event.currentTarget.style.removeProperty('--radix-toast-swipe-end-y');
|
|
247
|
+
}),
|
|
248
|
+
onSwipeEnd: $iTyic$radixuiprimitive.composeEventHandlers(props.onSwipeEnd, (event)=>{
|
|
249
|
+
const { x: x , y: y } = event.detail.delta;
|
|
250
|
+
event.currentTarget.setAttribute('data-swipe', 'end');
|
|
251
|
+
event.currentTarget.style.removeProperty('--radix-toast-swipe-move-x');
|
|
252
|
+
event.currentTarget.style.removeProperty('--radix-toast-swipe-move-y');
|
|
253
|
+
event.currentTarget.style.setProperty('--radix-toast-swipe-end-x', `${x}px`);
|
|
254
|
+
event.currentTarget.style.setProperty('--radix-toast-swipe-end-y', `${y}px`);
|
|
255
|
+
setOpen(false);
|
|
256
|
+
})
|
|
257
|
+
})));
|
|
258
|
+
});
|
|
259
|
+
/*#__PURE__*/ Object.assign($9208a85b3e79d33f$export$8d8dc7d5f743331b, {
|
|
260
|
+
displayName: $9208a85b3e79d33f$var$TOAST_NAME
|
|
261
|
+
});
|
|
262
|
+
/* -----------------------------------------------------------------------------------------------*/ const [$9208a85b3e79d33f$var$ToastInteractiveProvider, $9208a85b3e79d33f$var$useToastInteractiveContext] = $9208a85b3e79d33f$var$createToastContext($9208a85b3e79d33f$var$TOAST_NAME, {
|
|
263
|
+
isInteractive: false,
|
|
264
|
+
onClose () {}
|
|
265
|
+
});
|
|
266
|
+
const $9208a85b3e79d33f$var$ToastImpl = /*#__PURE__*/ $iTyic$react.forwardRef((props, forwardedRef)=>{
|
|
267
|
+
const { __scopeToast: __scopeToast , type: type = 'foreground' , duration: durationProp , open: open , onClose: onClose , onEscapeKeyDown: onEscapeKeyDown , onSwipeStart: onSwipeStart , onSwipeMove: onSwipeMove , onSwipeCancel: onSwipeCancel , onSwipeEnd: onSwipeEnd , ...toastProps } = props;
|
|
268
|
+
const context = $9208a85b3e79d33f$var$useToastProviderContext($9208a85b3e79d33f$var$TOAST_NAME, __scopeToast);
|
|
269
|
+
const ref = $iTyic$react.useRef(null);
|
|
270
|
+
const composedRefs = $iTyic$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref);
|
|
271
|
+
const pointerStartRef = $iTyic$react.useRef(null);
|
|
272
|
+
const swipeDeltaRef = $iTyic$react.useRef(null);
|
|
273
|
+
const duration1 = durationProp || context.duration;
|
|
274
|
+
const closeTimerStartTimeRef = $iTyic$react.useRef(0);
|
|
275
|
+
const closeTimerRemainingTimeRef = $iTyic$react.useRef(duration1);
|
|
276
|
+
const closeTimerRef = $iTyic$react.useRef(0);
|
|
277
|
+
const { onToastAdd: onToastAdd , onToastRemove: onToastRemove } = context;
|
|
278
|
+
const handleClose = $iTyic$radixuireactusecallbackref.useCallbackRef(()=>{
|
|
279
|
+
var _ref$current2, _context$viewport;
|
|
280
|
+
// focus viewport if focus is within toast to read the remaining toast
|
|
281
|
+
// count to SR users and ensure focus isn't lost
|
|
282
|
+
const isFocusInToast = (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.contains(document.activeElement);
|
|
283
|
+
if (isFocusInToast) (_context$viewport = context.viewport) === null || _context$viewport === void 0 || _context$viewport.focus();
|
|
284
|
+
onClose();
|
|
285
|
+
});
|
|
286
|
+
const startTimer = $iTyic$react.useCallback((duration)=>{
|
|
287
|
+
if (!duration || duration === Infinity) return;
|
|
288
|
+
window.clearTimeout(closeTimerRef.current);
|
|
289
|
+
closeTimerStartTimeRef.current = new Date().getTime();
|
|
290
|
+
closeTimerRef.current = window.setTimeout(handleClose, duration);
|
|
291
|
+
}, [
|
|
292
|
+
handleClose
|
|
293
|
+
]);
|
|
294
|
+
$iTyic$react.useEffect(()=>{
|
|
295
|
+
const viewport = context.viewport;
|
|
296
|
+
if (viewport) {
|
|
297
|
+
const handleResume = ()=>{
|
|
298
|
+
startTimer(closeTimerRemainingTimeRef.current);
|
|
299
|
+
};
|
|
300
|
+
const handlePause = ()=>{
|
|
301
|
+
const elapsedTime = new Date().getTime() - closeTimerStartTimeRef.current;
|
|
302
|
+
closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime;
|
|
303
|
+
window.clearTimeout(closeTimerRef.current);
|
|
304
|
+
};
|
|
305
|
+
viewport.addEventListener($9208a85b3e79d33f$var$VIEWPORT_PAUSE, handlePause);
|
|
306
|
+
viewport.addEventListener($9208a85b3e79d33f$var$VIEWPORT_RESUME, handleResume);
|
|
307
|
+
return ()=>{
|
|
308
|
+
viewport.removeEventListener($9208a85b3e79d33f$var$VIEWPORT_PAUSE, handlePause);
|
|
309
|
+
viewport.removeEventListener($9208a85b3e79d33f$var$VIEWPORT_RESUME, handleResume);
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
}, [
|
|
313
|
+
context.viewport,
|
|
314
|
+
duration1,
|
|
315
|
+
startTimer
|
|
316
|
+
]); // start timer when toast opens or duration changes.
|
|
317
|
+
// we include `open` in deps because closed !== unmounted when animating
|
|
318
|
+
// so it could reopen before being completely unmounted
|
|
319
|
+
$iTyic$react.useEffect(()=>{
|
|
320
|
+
if (open && !context.isClosePausedRef.current) startTimer(duration1);
|
|
321
|
+
}, [
|
|
322
|
+
open,
|
|
323
|
+
duration1,
|
|
324
|
+
context.isClosePausedRef,
|
|
325
|
+
startTimer
|
|
326
|
+
]);
|
|
327
|
+
$iTyic$react.useEffect(()=>{
|
|
328
|
+
onToastAdd();
|
|
329
|
+
return ()=>onToastRemove()
|
|
330
|
+
;
|
|
331
|
+
}, [
|
|
332
|
+
onToastAdd,
|
|
333
|
+
onToastRemove
|
|
334
|
+
]);
|
|
335
|
+
if (!context.viewport) return null;
|
|
336
|
+
return /*#__PURE__*/ $iTyic$react.createElement($iTyic$react.Fragment, null, /*#__PURE__*/ $iTyic$react.createElement($9208a85b3e79d33f$var$ToastAnnounce, {
|
|
337
|
+
__scopeToast: __scopeToast // Toasts are always role=status to avoid stuttering issues with role=alert in SRs.
|
|
338
|
+
,
|
|
339
|
+
role: "status",
|
|
340
|
+
"aria-live": type === 'foreground' ? 'assertive' : 'polite',
|
|
341
|
+
"aria-atomic": true
|
|
342
|
+
}, props.children), /*#__PURE__*/ $iTyic$react.createElement($9208a85b3e79d33f$var$ToastInteractiveProvider, {
|
|
343
|
+
scope: __scopeToast,
|
|
344
|
+
isInteractive: true,
|
|
345
|
+
onClose: handleClose
|
|
346
|
+
}, /*#__PURE__*/ $iTyic$reactdom.createPortal(/*#__PURE__*/ $iTyic$react.createElement($iTyic$radixuireactdismissablelayer.Root, {
|
|
347
|
+
asChild: true,
|
|
348
|
+
onEscapeKeyDown: $iTyic$radixuiprimitive.composeEventHandlers(onEscapeKeyDown, ()=>{
|
|
349
|
+
if (!context.isFocusedToastEscapeKeyDownRef.current) handleClose();
|
|
350
|
+
context.isFocusedToastEscapeKeyDownRef.current = false;
|
|
351
|
+
})
|
|
352
|
+
}, /*#__PURE__*/ $iTyic$react.createElement($iTyic$radixuireactprimitive.Primitive.li, ($parcel$interopDefault($iTyic$babelruntimehelpersextends))({
|
|
353
|
+
role: "status",
|
|
354
|
+
"aria-live": "off",
|
|
355
|
+
"aria-atomic": true,
|
|
356
|
+
tabIndex: 0,
|
|
357
|
+
"data-state": open ? 'open' : 'closed',
|
|
358
|
+
"data-swipe-direction": context.swipeDirection
|
|
359
|
+
}, toastProps, {
|
|
360
|
+
ref: composedRefs,
|
|
361
|
+
style: {
|
|
362
|
+
userSelect: 'none',
|
|
363
|
+
touchAction: 'none',
|
|
364
|
+
...props.style
|
|
365
|
+
},
|
|
366
|
+
onKeyDown: $iTyic$radixuiprimitive.composeEventHandlers(props.onKeyDown, (event)=>{
|
|
367
|
+
if (event.key !== 'Escape') return;
|
|
368
|
+
onEscapeKeyDown === null || onEscapeKeyDown === void 0 || onEscapeKeyDown(event.nativeEvent);
|
|
369
|
+
if (!event.nativeEvent.defaultPrevented) {
|
|
370
|
+
context.isFocusedToastEscapeKeyDownRef.current = true;
|
|
371
|
+
handleClose();
|
|
372
|
+
}
|
|
373
|
+
}),
|
|
374
|
+
onPointerDown: $iTyic$radixuiprimitive.composeEventHandlers(props.onPointerDown, (event)=>{
|
|
375
|
+
if (event.button !== 0) return;
|
|
376
|
+
pointerStartRef.current = {
|
|
377
|
+
x: event.clientX,
|
|
378
|
+
y: event.clientY
|
|
379
|
+
};
|
|
380
|
+
}),
|
|
381
|
+
onPointerMove: $iTyic$radixuiprimitive.composeEventHandlers(props.onPointerMove, (event)=>{
|
|
382
|
+
if (!pointerStartRef.current) return;
|
|
383
|
+
const x = event.clientX - pointerStartRef.current.x;
|
|
384
|
+
const y = event.clientY - pointerStartRef.current.y;
|
|
385
|
+
const hasSwipeMoveStarted = Boolean(swipeDeltaRef.current);
|
|
386
|
+
const isHorizontalSwipe = [
|
|
387
|
+
'left',
|
|
388
|
+
'right'
|
|
389
|
+
].includes(context.swipeDirection);
|
|
390
|
+
const clamp = [
|
|
391
|
+
'left',
|
|
392
|
+
'up'
|
|
393
|
+
].includes(context.swipeDirection) ? Math.min : Math.max;
|
|
394
|
+
const clampedX = isHorizontalSwipe ? clamp(0, x) : 0;
|
|
395
|
+
const clampedY = !isHorizontalSwipe ? clamp(0, y) : 0;
|
|
396
|
+
const moveStartBuffer = event.pointerType === 'touch' ? 10 : 2;
|
|
397
|
+
const delta = {
|
|
398
|
+
x: clampedX,
|
|
399
|
+
y: clampedY
|
|
400
|
+
};
|
|
401
|
+
const eventDetail = {
|
|
402
|
+
originalEvent: event,
|
|
403
|
+
delta: delta
|
|
404
|
+
};
|
|
405
|
+
if (hasSwipeMoveStarted) {
|
|
406
|
+
swipeDeltaRef.current = delta;
|
|
407
|
+
$9208a85b3e79d33f$var$handleAndDispatchCustomEvent($9208a85b3e79d33f$var$TOAST_SWIPE_MOVE, onSwipeMove, eventDetail, {
|
|
408
|
+
discrete: false
|
|
409
|
+
});
|
|
410
|
+
} else if ($9208a85b3e79d33f$var$isDeltaInDirection(delta, context.swipeDirection, moveStartBuffer)) {
|
|
411
|
+
swipeDeltaRef.current = delta;
|
|
412
|
+
$9208a85b3e79d33f$var$handleAndDispatchCustomEvent($9208a85b3e79d33f$var$TOAST_SWIPE_START, onSwipeStart, eventDetail, {
|
|
413
|
+
discrete: false
|
|
414
|
+
});
|
|
415
|
+
event.target.setPointerCapture(event.pointerId);
|
|
416
|
+
} else if (Math.abs(x) > moveStartBuffer || Math.abs(y) > moveStartBuffer) // User is swiping in wrong direction so we disable swipe gesture
|
|
417
|
+
// for the current pointer down interaction
|
|
418
|
+
pointerStartRef.current = null;
|
|
419
|
+
}),
|
|
420
|
+
onPointerUp: $iTyic$radixuiprimitive.composeEventHandlers(props.onPointerUp, (event1)=>{
|
|
421
|
+
const delta = swipeDeltaRef.current;
|
|
422
|
+
event1.target.releasePointerCapture(event1.pointerId);
|
|
423
|
+
swipeDeltaRef.current = null;
|
|
424
|
+
pointerStartRef.current = null;
|
|
425
|
+
if (delta) {
|
|
426
|
+
const toast = event1.currentTarget;
|
|
427
|
+
const eventDetail = {
|
|
428
|
+
originalEvent: event1,
|
|
429
|
+
delta: delta
|
|
430
|
+
};
|
|
431
|
+
if ($9208a85b3e79d33f$var$isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold)) $9208a85b3e79d33f$var$handleAndDispatchCustomEvent($9208a85b3e79d33f$var$TOAST_SWIPE_END, onSwipeEnd, eventDetail, {
|
|
432
|
+
discrete: true
|
|
433
|
+
});
|
|
434
|
+
else $9208a85b3e79d33f$var$handleAndDispatchCustomEvent($9208a85b3e79d33f$var$TOAST_SWIPE_CANCEL, onSwipeCancel, eventDetail, {
|
|
435
|
+
discrete: true
|
|
436
|
+
});
|
|
437
|
+
// Prevent click event from triggering on items within the toast when
|
|
438
|
+
// pointer up is part of a swipe gesture
|
|
439
|
+
toast.addEventListener('click', (event)=>event.preventDefault()
|
|
440
|
+
, {
|
|
441
|
+
once: true
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
})
|
|
445
|
+
}))), context.viewport)));
|
|
446
|
+
});
|
|
447
|
+
$9208a85b3e79d33f$var$ToastImpl.propTypes = {
|
|
448
|
+
type (props) {
|
|
449
|
+
if (props.type && ![
|
|
450
|
+
'foreground',
|
|
451
|
+
'background'
|
|
452
|
+
].includes(props.type)) {
|
|
453
|
+
const error = `Invalid prop \`type\` supplied to \`${$9208a85b3e79d33f$var$TOAST_NAME}\`. Expected \`foreground | background\`.`;
|
|
454
|
+
throw new Error(error);
|
|
455
|
+
}
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
/* -----------------------------------------------------------------------------------------------*/ const $9208a85b3e79d33f$var$ToastAnnounce = (props)=>{
|
|
460
|
+
const { __scopeToast: __scopeToast , ...announceProps } = props;
|
|
461
|
+
const context = $9208a85b3e79d33f$var$useToastProviderContext($9208a85b3e79d33f$var$TOAST_NAME, __scopeToast);
|
|
462
|
+
const [renderChildren, setRenderChildren] = $iTyic$react.useState(false);
|
|
463
|
+
const [isAnnounced, setIsAnnounced] = $iTyic$react.useState(false); // render children in the next frame to ensure toast is announced in NVDA
|
|
464
|
+
$9208a85b3e79d33f$var$useNextFrame(()=>setRenderChildren(true)
|
|
465
|
+
);
|
|
466
|
+
$iTyic$react.useEffect(()=>{
|
|
467
|
+
const timer = window.setTimeout(()=>setIsAnnounced(true)
|
|
468
|
+
, 1000);
|
|
469
|
+
return ()=>window.clearTimeout(timer)
|
|
470
|
+
;
|
|
471
|
+
}, []);
|
|
472
|
+
return isAnnounced ? null : /*#__PURE__*/ $iTyic$react.createElement($iTyic$radixuireactportal.UnstablePortal, {
|
|
473
|
+
asChild: true
|
|
474
|
+
}, /*#__PURE__*/ $iTyic$react.createElement($iTyic$radixuireactvisuallyhidden.VisuallyHidden, {
|
|
475
|
+
asChild: true
|
|
476
|
+
}, /*#__PURE__*/ $iTyic$react.createElement("div", announceProps, renderChildren && /*#__PURE__*/ $iTyic$react.createElement($iTyic$react.Fragment, null, context.label, " ", props.children))));
|
|
477
|
+
};
|
|
478
|
+
/* -------------------------------------------------------------------------------------------------
|
|
479
|
+
* ToastTitle
|
|
480
|
+
* -----------------------------------------------------------------------------------------------*/ const $9208a85b3e79d33f$var$TITLE_NAME = 'ToastTitle';
|
|
481
|
+
const $9208a85b3e79d33f$export$16d42d7c29b95a4 = /*#__PURE__*/ $iTyic$react.forwardRef((props, forwardedRef)=>{
|
|
482
|
+
const { __scopeToast: __scopeToast , ...titleProps } = props;
|
|
483
|
+
return /*#__PURE__*/ $iTyic$react.createElement($iTyic$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($iTyic$babelruntimehelpersextends))({}, titleProps, {
|
|
484
|
+
ref: forwardedRef
|
|
485
|
+
}));
|
|
486
|
+
});
|
|
487
|
+
/*#__PURE__*/ Object.assign($9208a85b3e79d33f$export$16d42d7c29b95a4, {
|
|
488
|
+
displayName: $9208a85b3e79d33f$var$TITLE_NAME
|
|
489
|
+
});
|
|
490
|
+
/* -------------------------------------------------------------------------------------------------
|
|
491
|
+
* ToastDescription
|
|
492
|
+
* -----------------------------------------------------------------------------------------------*/ const $9208a85b3e79d33f$var$DESCRIPTION_NAME = 'ToastDescription';
|
|
493
|
+
const $9208a85b3e79d33f$export$ecddd96c53621d9a = /*#__PURE__*/ $iTyic$react.forwardRef((props, forwardedRef)=>{
|
|
494
|
+
const { __scopeToast: __scopeToast , ...descriptionProps } = props;
|
|
495
|
+
return /*#__PURE__*/ $iTyic$react.createElement($iTyic$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($iTyic$babelruntimehelpersextends))({}, descriptionProps, {
|
|
496
|
+
ref: forwardedRef
|
|
497
|
+
}));
|
|
498
|
+
});
|
|
499
|
+
/*#__PURE__*/ Object.assign($9208a85b3e79d33f$export$ecddd96c53621d9a, {
|
|
500
|
+
displayName: $9208a85b3e79d33f$var$DESCRIPTION_NAME
|
|
501
|
+
});
|
|
502
|
+
/* -------------------------------------------------------------------------------------------------
|
|
503
|
+
* ToastAction
|
|
504
|
+
* -----------------------------------------------------------------------------------------------*/ const $9208a85b3e79d33f$var$ACTION_NAME = 'ToastAction';
|
|
505
|
+
const $9208a85b3e79d33f$export$3019feecfda683d2 = /*#__PURE__*/ $iTyic$react.forwardRef((props, forwardedRef)=>{
|
|
506
|
+
const { altText: altText , ...actionProps } = props;
|
|
507
|
+
const context = $9208a85b3e79d33f$var$useToastInteractiveContext($9208a85b3e79d33f$var$ACTION_NAME, props.__scopeToast);
|
|
508
|
+
if (!altText) return null;
|
|
509
|
+
return context.isInteractive ? /*#__PURE__*/ $iTyic$react.createElement($9208a85b3e79d33f$export$811e70f61c205839, ($parcel$interopDefault($iTyic$babelruntimehelpersextends))({}, actionProps, {
|
|
510
|
+
ref: forwardedRef
|
|
511
|
+
})) : /*#__PURE__*/ $iTyic$react.createElement("span", null, altText);
|
|
512
|
+
});
|
|
513
|
+
$9208a85b3e79d33f$export$3019feecfda683d2.propTypes = {
|
|
514
|
+
altText (props) {
|
|
515
|
+
if (!props.altText) throw new Error(`Missing prop \`altText\` expected on \`${$9208a85b3e79d33f$var$ACTION_NAME}\``);
|
|
516
|
+
return null;
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
/*#__PURE__*/ Object.assign($9208a85b3e79d33f$export$3019feecfda683d2, {
|
|
520
|
+
displayName: $9208a85b3e79d33f$var$ACTION_NAME
|
|
521
|
+
});
|
|
522
|
+
/* -------------------------------------------------------------------------------------------------
|
|
523
|
+
* ToastClose
|
|
524
|
+
* -----------------------------------------------------------------------------------------------*/ const $9208a85b3e79d33f$var$CLOSE_NAME = 'ToastClose';
|
|
525
|
+
const $9208a85b3e79d33f$export$811e70f61c205839 = /*#__PURE__*/ $iTyic$react.forwardRef((props, forwardedRef)=>{
|
|
526
|
+
const { __scopeToast: __scopeToast , ...closeProps } = props;
|
|
527
|
+
const interactiveContext = $9208a85b3e79d33f$var$useToastInteractiveContext($9208a85b3e79d33f$var$CLOSE_NAME, __scopeToast);
|
|
528
|
+
return interactiveContext.isInteractive ? /*#__PURE__*/ $iTyic$react.createElement($iTyic$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($iTyic$babelruntimehelpersextends))({
|
|
529
|
+
type: "button"
|
|
530
|
+
}, closeProps, {
|
|
531
|
+
ref: forwardedRef,
|
|
532
|
+
onClick: $iTyic$radixuiprimitive.composeEventHandlers(props.onClick, interactiveContext.onClose)
|
|
533
|
+
})) : null;
|
|
534
|
+
});
|
|
535
|
+
/*#__PURE__*/ Object.assign($9208a85b3e79d33f$export$811e70f61c205839, {
|
|
536
|
+
displayName: $9208a85b3e79d33f$var$CLOSE_NAME
|
|
537
|
+
});
|
|
538
|
+
/* ---------------------------------------------------------------------------------------------- */ function $9208a85b3e79d33f$var$handleAndDispatchCustomEvent(name, handler, detail, { discrete: discrete }) {
|
|
539
|
+
const currentTarget = detail.originalEvent.currentTarget;
|
|
540
|
+
const event = new CustomEvent(name, {
|
|
541
|
+
bubbles: true,
|
|
542
|
+
cancelable: true,
|
|
543
|
+
detail: detail
|
|
544
|
+
});
|
|
545
|
+
if (handler) currentTarget.addEventListener(name, handler, {
|
|
546
|
+
once: true
|
|
547
|
+
});
|
|
548
|
+
if (discrete) $iTyic$radixuireactprimitive.dispatchDiscreteCustomEvent(currentTarget, event);
|
|
549
|
+
else currentTarget.dispatchEvent(event);
|
|
550
|
+
}
|
|
551
|
+
const $9208a85b3e79d33f$var$isDeltaInDirection = (delta, direction, threshold = 0)=>{
|
|
552
|
+
const deltaX = Math.abs(delta.x);
|
|
553
|
+
const deltaY = Math.abs(delta.y);
|
|
554
|
+
const isDeltaX = deltaX > deltaY;
|
|
555
|
+
if (direction === 'left' || direction === 'right') return isDeltaX && deltaX > threshold;
|
|
556
|
+
else return !isDeltaX && deltaY > threshold;
|
|
557
|
+
};
|
|
558
|
+
function $9208a85b3e79d33f$var$useNextFrame(callback = ()=>{}) {
|
|
559
|
+
const fn = $iTyic$radixuireactusecallbackref.useCallbackRef(callback);
|
|
560
|
+
$iTyic$radixuireactuselayouteffect.useLayoutEffect(()=>{
|
|
561
|
+
let raf1 = 0;
|
|
562
|
+
let raf2 = 0;
|
|
563
|
+
raf1 = window.requestAnimationFrame(()=>raf2 = window.requestAnimationFrame(fn)
|
|
564
|
+
);
|
|
565
|
+
return ()=>{
|
|
566
|
+
window.cancelAnimationFrame(raf1);
|
|
567
|
+
window.cancelAnimationFrame(raf2);
|
|
568
|
+
};
|
|
569
|
+
}, [
|
|
570
|
+
fn
|
|
571
|
+
]);
|
|
572
|
+
}
|
|
573
|
+
const $9208a85b3e79d33f$export$2881499e37b75b9a = $9208a85b3e79d33f$export$f5d03d415824e0e;
|
|
574
|
+
const $9208a85b3e79d33f$export$d5c6c08dc2d3ca7 = $9208a85b3e79d33f$export$6192c2425ecfd989;
|
|
575
|
+
const $9208a85b3e79d33f$export$be92b6f5f03c0fe9 = $9208a85b3e79d33f$export$8d8dc7d5f743331b;
|
|
576
|
+
const $9208a85b3e79d33f$export$f99233281efd08a0 = $9208a85b3e79d33f$export$16d42d7c29b95a4;
|
|
577
|
+
const $9208a85b3e79d33f$export$393edc798c47379d = $9208a85b3e79d33f$export$ecddd96c53621d9a;
|
|
578
|
+
const $9208a85b3e79d33f$export$e19cd5f9376f8cee = $9208a85b3e79d33f$export$3019feecfda683d2;
|
|
579
|
+
const $9208a85b3e79d33f$export$f39c2d165cd861fe = $9208a85b3e79d33f$export$811e70f61c205839;
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
$parcel$exportWildcard(module.exports, $9208a85b3e79d33f$exports);
|
|
583
|
+
|
|
584
|
+
|
|
2
585
|
//# sourceMappingURL=index.js.map
|