@tamagui/toast 1.13.2 → 1.13.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/cjs/Toast.js +1 -181
  2. package/dist/cjs/Toast.js.map +3 -3
  3. package/dist/cjs/ToastAnnounce.js +1 -92
  4. package/dist/cjs/ToastAnnounce.js.map +2 -2
  5. package/dist/cjs/ToastImperative.js +1 -110
  6. package/dist/cjs/ToastImperative.js.map +2 -2
  7. package/dist/cjs/ToastImpl.js +1 -352
  8. package/dist/cjs/ToastImpl.js.map +2 -2
  9. package/dist/cjs/ToastProvider.js +1 -119
  10. package/dist/cjs/ToastProvider.js.map +2 -2
  11. package/dist/cjs/ToastViewport.js +1 -312
  12. package/dist/cjs/ToastViewport.js.map +2 -2
  13. package/dist/cjs/constants.js +1 -28
  14. package/dist/cjs/constants.js.map +2 -2
  15. package/dist/cjs/createNativeToast.js +1 -69
  16. package/dist/cjs/createNativeToast.js.map +2 -2
  17. package/dist/cjs/createNativeToast.native.js +1 -43
  18. package/dist/cjs/createNativeToast.native.js.map +2 -2
  19. package/dist/cjs/index.js +1 -18
  20. package/dist/cjs/index.js.map +2 -2
  21. package/dist/cjs/types.js +1 -16
  22. package/dist/cjs/types.js.map +2 -2
  23. package/dist/esm/Toast.js +1 -157
  24. package/dist/esm/Toast.js.map +3 -3
  25. package/dist/esm/Toast.mjs +1 -157
  26. package/dist/esm/Toast.mjs.map +3 -3
  27. package/dist/esm/ToastAnnounce.js +1 -63
  28. package/dist/esm/ToastAnnounce.js.map +2 -2
  29. package/dist/esm/ToastAnnounce.mjs +1 -63
  30. package/dist/esm/ToastAnnounce.mjs.map +2 -2
  31. package/dist/esm/ToastImperative.js +1 -73
  32. package/dist/esm/ToastImperative.js.map +2 -2
  33. package/dist/esm/ToastImperative.mjs +1 -73
  34. package/dist/esm/ToastImperative.mjs.map +2 -2
  35. package/dist/esm/ToastImpl.js +1 -328
  36. package/dist/esm/ToastImpl.js.map +2 -2
  37. package/dist/esm/ToastImpl.mjs +1 -328
  38. package/dist/esm/ToastImpl.mjs.map +2 -2
  39. package/dist/esm/ToastProvider.js +1 -80
  40. package/dist/esm/ToastProvider.js.map +2 -2
  41. package/dist/esm/ToastProvider.mjs +1 -80
  42. package/dist/esm/ToastProvider.mjs.map +2 -2
  43. package/dist/esm/ToastViewport.js +1 -279
  44. package/dist/esm/ToastViewport.js.map +2 -2
  45. package/dist/esm/ToastViewport.mjs +1 -279
  46. package/dist/esm/ToastViewport.mjs.map +2 -2
  47. package/dist/esm/constants.js +1 -4
  48. package/dist/esm/constants.js.map +2 -2
  49. package/dist/esm/constants.mjs +1 -4
  50. package/dist/esm/constants.mjs.map +2 -2
  51. package/dist/esm/createNativeToast.js +1 -44
  52. package/dist/esm/createNativeToast.js.map +2 -2
  53. package/dist/esm/createNativeToast.mjs +1 -44
  54. package/dist/esm/createNativeToast.mjs.map +2 -2
  55. package/dist/esm/createNativeToast.native.js +1 -18
  56. package/dist/esm/createNativeToast.native.js.map +2 -2
  57. package/dist/esm/createNativeToast.native.mjs +1 -18
  58. package/dist/esm/createNativeToast.native.mjs.map +2 -2
  59. package/dist/esm/index.js +1 -1
  60. package/dist/esm/index.js.map +1 -1
  61. package/dist/esm/index.mjs +1 -1
  62. package/dist/esm/index.mjs.map +1 -1
  63. package/dist/jsx/Toast.js +1 -150
  64. package/dist/jsx/Toast.js.map +3 -3
  65. package/dist/jsx/Toast.mjs +1 -150
  66. package/dist/jsx/Toast.mjs.map +3 -3
  67. package/dist/jsx/ToastAnnounce.js +1 -59
  68. package/dist/jsx/ToastAnnounce.js.map +2 -2
  69. package/dist/jsx/ToastAnnounce.mjs +1 -59
  70. package/dist/jsx/ToastAnnounce.mjs.map +2 -2
  71. package/dist/jsx/ToastImperative.js +1 -72
  72. package/dist/jsx/ToastImperative.js.map +2 -2
  73. package/dist/jsx/ToastImperative.mjs +1 -72
  74. package/dist/jsx/ToastImperative.mjs.map +2 -2
  75. package/dist/jsx/ToastImpl.js +1 -307
  76. package/dist/jsx/ToastImpl.js.map +2 -2
  77. package/dist/jsx/ToastImpl.mjs +1 -307
  78. package/dist/jsx/ToastImpl.mjs.map +2 -2
  79. package/dist/jsx/ToastProvider.js +1 -75
  80. package/dist/jsx/ToastProvider.js.map +2 -2
  81. package/dist/jsx/ToastProvider.mjs +1 -75
  82. package/dist/jsx/ToastProvider.mjs.map +2 -2
  83. package/dist/jsx/ToastViewport.js +1 -259
  84. package/dist/jsx/ToastViewport.js.map +2 -2
  85. package/dist/jsx/ToastViewport.mjs +1 -259
  86. package/dist/jsx/ToastViewport.mjs.map +2 -2
  87. package/dist/jsx/constants.js +1 -4
  88. package/dist/jsx/constants.js.map +2 -2
  89. package/dist/jsx/constants.mjs +1 -4
  90. package/dist/jsx/constants.mjs.map +2 -2
  91. package/dist/jsx/createNativeToast.js +1 -44
  92. package/dist/jsx/createNativeToast.js.map +2 -2
  93. package/dist/jsx/createNativeToast.mjs +1 -44
  94. package/dist/jsx/createNativeToast.mjs.map +2 -2
  95. package/dist/jsx/createNativeToast.native.js +1 -18
  96. package/dist/jsx/createNativeToast.native.js.map +2 -2
  97. package/dist/jsx/createNativeToast.native.mjs +1 -18
  98. package/dist/jsx/createNativeToast.native.mjs.map +2 -2
  99. package/dist/jsx/index.js +1 -1
  100. package/dist/jsx/index.js.map +1 -1
  101. package/dist/jsx/index.mjs +1 -1
  102. package/dist/jsx/index.mjs.map +1 -1
  103. package/package.json +13 -13
  104. package/src/Toast.tsx +9 -1
  105. package/types/Toast.d.ts +2 -2
  106. package/types/Toast.d.ts.map +1 -1
@@ -1,353 +1,2 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var ToastImpl_exports = {};
30
- __export(ToastImpl_exports, {
31
- ToastImpl: () => ToastImpl,
32
- ToastImplFrame: () => ToastImplFrame,
33
- useToastInteractiveContext: () => useToastInteractiveContext
34
- });
35
- module.exports = __toCommonJS(ToastImpl_exports);
36
- var import_jsx_runtime = require("react/jsx-runtime");
37
- var import_animate_presence = require("@tamagui/animate-presence");
38
- var import_compose_refs = require("@tamagui/compose-refs");
39
- var import_core = require("@tamagui/core");
40
- var import_dismissable = require("@tamagui/dismissable");
41
- var import_portal = require("@tamagui/portal");
42
- var import_stacks = require("@tamagui/stacks");
43
- var React = __toESM(require("react"));
44
- var import_react_native = require("react-native");
45
- var import_constants = require("./constants");
46
- var import_ToastAnnounce = require("./ToastAnnounce");
47
- var import_ToastProvider = require("./ToastProvider");
48
- var import_ToastViewport = require("./ToastViewport");
49
- const ToastImplFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
50
- name: "ToastImpl",
51
- variants: {
52
- backgrounded: {
53
- true: {
54
- backgroundColor: "$color6"
55
- }
56
- },
57
- unstyled: {
58
- false: {
59
- borderRadius: "$10",
60
- paddingHorizontal: "$5",
61
- paddingVertical: "$2",
62
- marginHorizontal: "auto",
63
- marginVertical: "$1"
64
- }
65
- }
66
- },
67
- defaultVariants: {
68
- backgrounded: true,
69
- unstyled: false
70
- }
71
- });
72
- const [ToastInteractiveProvider, useToastInteractiveContext] = (0, import_ToastProvider.createToastContext)(
73
- import_constants.TOAST_NAME,
74
- {
75
- onClose() {
76
- }
77
- }
78
- );
79
- const ToastImpl = React.forwardRef(
80
- (props, forwardedRef) => {
81
- const {
82
- __scopeToast,
83
- type = "foreground",
84
- duration: durationProp,
85
- open,
86
- onClose,
87
- onEscapeKeyDown,
88
- onPause,
89
- onResume,
90
- onSwipeStart,
91
- onSwipeMove,
92
- onSwipeCancel,
93
- onSwipeEnd,
94
- viewportName,
95
- ...toastProps
96
- } = props;
97
- const isPresent = (0, import_animate_presence.useIsPresent)();
98
- const context = (0, import_ToastProvider.useToastProviderContext)(import_constants.TOAST_NAME, __scopeToast);
99
- const [node, setNode] = React.useState(null);
100
- const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node2) => setNode(node2));
101
- const duration = durationProp || context.duration;
102
- const closeTimerStartTimeRef = React.useRef(0);
103
- const closeTimerRemainingTimeRef = React.useRef(duration);
104
- const closeTimerRef = React.useRef(0);
105
- const { onToastAdd, onToastRemove } = context;
106
- const handleClose = (0, import_core.useEvent)(() => {
107
- var _a;
108
- if (!isPresent) {
109
- return;
110
- }
111
- if (import_core.isWeb) {
112
- const isFocusInToast = node == null ? void 0 : node.contains(document.activeElement);
113
- if (isFocusInToast)
114
- (_a = context.viewport) == null ? void 0 : _a.focus();
115
- }
116
- onClose();
117
- });
118
- const startTimer = React.useCallback(
119
- (duration2) => {
120
- if (!duration2 || duration2 === Infinity)
121
- return;
122
- clearTimeout(closeTimerRef.current);
123
- closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
124
- closeTimerRef.current = setTimeout(handleClose, duration2);
125
- },
126
- [handleClose]
127
- );
128
- const handleResume = React.useCallback(() => {
129
- startTimer(closeTimerRemainingTimeRef.current);
130
- onResume == null ? void 0 : onResume();
131
- }, [onResume, startTimer]);
132
- const handlePause = React.useCallback(() => {
133
- const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef.current;
134
- closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime;
135
- window.clearTimeout(closeTimerRef.current);
136
- onPause == null ? void 0 : onPause();
137
- }, [onPause]);
138
- React.useEffect(() => {
139
- if (!import_core.isWeb)
140
- return;
141
- const viewport = context.viewport;
142
- if (viewport) {
143
- viewport.addEventListener(import_ToastViewport.VIEWPORT_PAUSE, handlePause);
144
- viewport.addEventListener(import_ToastViewport.VIEWPORT_RESUME, handleResume);
145
- return () => {
146
- viewport.removeEventListener(import_ToastViewport.VIEWPORT_PAUSE, handlePause);
147
- viewport.removeEventListener(import_ToastViewport.VIEWPORT_RESUME, handleResume);
148
- };
149
- }
150
- }, [context.viewport, duration, onPause, onResume, startTimer]);
151
- React.useEffect(() => {
152
- if (open && !context.isClosePausedRef.current) {
153
- startTimer(duration);
154
- }
155
- }, [open, duration, context.isClosePausedRef, startTimer]);
156
- React.useEffect(() => {
157
- onToastAdd();
158
- return () => onToastRemove();
159
- }, [onToastAdd, onToastRemove]);
160
- const announceTextContent = React.useMemo(() => {
161
- if (!import_core.isWeb)
162
- return null;
163
- return node ? getAnnounceTextContent(node) : null;
164
- }, [node]);
165
- const isHorizontalSwipe = ["left", "right", "horizontal"].includes(
166
- context.swipeDirection
167
- );
168
- const driver = (0, import_core.useAnimationDriver)();
169
- if (!driver) {
170
- throw new Error("Must set animations in tamagui.config.ts");
171
- }
172
- const { useAnimatedNumber, useAnimatedNumberStyle } = driver;
173
- const animatedNumber = useAnimatedNumber(0);
174
- const AnimatedView = driver["NumberView"] ?? driver.View;
175
- const animatedStyles = useAnimatedNumberStyle(animatedNumber, (val) => {
176
- return {
177
- transform: [isHorizontalSwipe ? { translateX: val } : { translateY: val }]
178
- };
179
- });
180
- const panResponder = React.useMemo(() => {
181
- return import_react_native.PanResponder.create({
182
- onMoveShouldSetPanResponder: (e) => {
183
- onSwipeStart == null ? void 0 : onSwipeStart(e);
184
- return true;
185
- },
186
- onPanResponderGrant: (e) => {
187
- if (!import_core.isWeb) {
188
- handlePause == null ? void 0 : handlePause();
189
- }
190
- },
191
- onPanResponderMove: (e, { dy, dx }) => {
192
- let y = 0;
193
- let x = 0;
194
- if (context.swipeDirection === "horizontal")
195
- x = dx;
196
- else if (context.swipeDirection === "left")
197
- x = Math.min(0, dx);
198
- else if (context.swipeDirection === "right")
199
- x = Math.max(0, dx);
200
- else if (context.swipeDirection === "vertical")
201
- y = dy;
202
- else if (context.swipeDirection === "up")
203
- y = Math.min(0, dy);
204
- else if (context.swipeDirection === "down")
205
- y = Math.max(0, dy);
206
- onSwipeMove == null ? void 0 : onSwipeMove(e);
207
- const delta = { x, y };
208
- animatedNumber.setValue(isHorizontalSwipe ? x : y, { type: "direct" });
209
- if (isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold)) {
210
- onSwipeEnd == null ? void 0 : onSwipeEnd(e);
211
- }
212
- },
213
- onPanResponderEnd: (e, { dx, dy }) => {
214
- if (!isDeltaInDirection(
215
- { x: dx, y: dy },
216
- context.swipeDirection,
217
- context.swipeThreshold
218
- )) {
219
- if (!import_core.isWeb) {
220
- handleResume == null ? void 0 : handleResume();
221
- }
222
- onSwipeCancel == null ? void 0 : onSwipeCancel(e);
223
- animatedNumber.setValue(0, { type: "spring" });
224
- }
225
- }
226
- });
227
- }, [handlePause, handleResume]);
228
- const themeName = (0, import_core.useThemeName)();
229
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
230
- announceTextContent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
231
- import_ToastAnnounce.ToastAnnounce,
232
- {
233
- __scopeToast,
234
- role: "status",
235
- "aria-live": type === "foreground" ? "assertive" : "polite",
236
- "aria-atomic": true,
237
- children: announceTextContent
238
- }
239
- ),
240
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, { hostName: viewportName ?? "default", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
241
- ToastInteractiveProvider,
242
- {
243
- scope: __scopeToast,
244
- onClose: () => {
245
- handleClose();
246
- },
247
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
248
- import_dismissable.Dismissable,
249
- {
250
- onEscapeKeyDown: (0, import_core.composeEventHandlers)(onEscapeKeyDown, () => {
251
- if (!context.isFocusedToastEscapeKeyDownRef.current) {
252
- handleClose();
253
- }
254
- context.isFocusedToastEscapeKeyDownRef.current = false;
255
- }),
256
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, { forceClassName: true, name: themeName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
257
- AnimatedView,
258
- {
259
- ...panResponder == null ? void 0 : panResponder.panHandlers,
260
- style: [{ margin: "auto" }, animatedStyles],
261
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastProvider.Collection.ItemSlot, { scope: __scopeToast, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
262
- ToastImplFrame,
263
- {
264
- role: "status",
265
- "aria-live": "off",
266
- "aria-atomic": true,
267
- tabIndex: 0,
268
- "data-state": open ? "open" : "closed",
269
- "data-swipe-direction": context.swipeDirection,
270
- pointerEvents: "auto",
271
- userSelect: "none",
272
- ...toastProps,
273
- ref: composedRefs,
274
- ...import_core.isWeb && {
275
- onKeyDown: (0, import_core.composeEventHandlers)(
276
- props.onKeyDown,
277
- (event) => {
278
- if (event.key !== "Escape")
279
- return;
280
- onEscapeKeyDown == null ? void 0 : onEscapeKeyDown(event);
281
- onEscapeKeyDown == null ? void 0 : onEscapeKeyDown(event);
282
- if (!event.defaultPrevented) {
283
- context.isFocusedToastEscapeKeyDownRef.current = true;
284
- handleClose();
285
- }
286
- }
287
- )
288
- }
289
- }
290
- ) })
291
- }
292
- ) })
293
- }
294
- )
295
- },
296
- props.id
297
- ) })
298
- ] });
299
- }
300
- );
301
- ToastImpl.propTypes = {
302
- type(props) {
303
- if (props.type && !["foreground", "background"].includes(props.type)) {
304
- const error = `Invalid prop \`type\` supplied to \`${import_constants.TOAST_NAME}\`. Expected \`foreground | background\`.`;
305
- return new Error(error);
306
- }
307
- return null;
308
- }
309
- };
310
- const isDeltaInDirection = (delta, direction, threshold = 0) => {
311
- const deltaX = Math.abs(delta.x);
312
- const deltaY = Math.abs(delta.y);
313
- const isDeltaX = deltaX > deltaY;
314
- if (direction === "left" || direction === "right" || direction === "horizontal") {
315
- return isDeltaX && deltaX > threshold;
316
- } else {
317
- return !isDeltaX && deltaY > threshold;
318
- }
319
- };
320
- function getAnnounceTextContent(container) {
321
- if (!import_core.isWeb)
322
- return "";
323
- const textContent = [];
324
- const childNodes = Array.from(container.childNodes);
325
- childNodes.forEach((node) => {
326
- if (node.nodeType === node.TEXT_NODE && node.textContent)
327
- textContent.push(node.textContent);
328
- if (isHTMLElement(node)) {
329
- const isHidden = node.ariaHidden || node.hidden || node.style.display === "none";
330
- const isExcluded = node.dataset.toastAnnounceExclude === "";
331
- if (!isHidden) {
332
- if (isExcluded) {
333
- const altText = node.dataset.toastAnnounceAlt;
334
- if (altText)
335
- textContent.push(altText);
336
- } else {
337
- textContent.push(...getAnnounceTextContent(node));
338
- }
339
- }
340
- }
341
- });
342
- return textContent;
343
- }
344
- function isHTMLElement(node) {
345
- return node.nodeType === node.ELEMENT_NODE;
346
- }
347
- // Annotate the CommonJS export names for ESM import in node:
348
- 0 && (module.exports = {
349
- ToastImpl,
350
- ToastImplFrame,
351
- useToastInteractiveContext
352
- });
1
+ "use strict";var de=Object.create;var S=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var ve=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var we=(t,o)=>{for(var i in o)S(t,i,{get:o[i],enumerable:!0})},W=(t,o,i,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let u of Te(o))!Ee.call(t,u)&&u!==i&&S(t,u,{get:()=>o[u],enumerable:!(r=fe(o,u))||r.enumerable});return t};var ye=(t,o,i)=>(i=t!=null?de(ve(t)):{},W(o||!t||!t.__esModule?S(i,"default",{value:t,enumerable:!0}):i,t)),Pe=t=>W(S({},"__esModule",{value:!0}),t);var be={};we(be,{ToastImpl:()=>O,ToastImplFrame:()=>_,useToastInteractiveContext:()=>te});module.exports=Pe(be);var c=require("react/jsx-runtime"),q=require("@tamagui/animate-presence"),B=require("@tamagui/compose-refs"),s=require("@tamagui/core"),J=require("@tamagui/dismissable"),Q=require("@tamagui/portal"),Z=require("@tamagui/stacks"),a=ye(require("react")),j=require("react-native"),M=require("./constants"),ee=require("./ToastAnnounce"),E=require("./ToastProvider"),v=require("./ToastViewport");const _=(0,s.styled)(Z.ThemeableStack,{name:"ToastImpl",variants:{backgrounded:{true:{backgroundColor:"$color6"}},unstyled:{false:{borderRadius:"$10",paddingHorizontal:"$5",paddingVertical:"$2",marginHorizontal:"auto",marginVertical:"$1"}}},defaultVariants:{backgrounded:!0,unstyled:!1}}),[ge,te]=(0,E.createToastContext)(M.TOAST_NAME,{onClose(){}}),O=a.forwardRef((t,o)=>{const{__scopeToast:i,type:r="foreground",duration:u,open:l,onClose:I,onEscapeKeyDown:p,onPause:w,onResume:y,onSwipeStart:x,onSwipeMove:A,onSwipeCancel:N,onSwipeEnd:k,viewportName:oe,...ne}=t,se=(0,q.useIsPresent)(),n=(0,E.useToastProviderContext)(M.TOAST_NAME,i),[m,re]=a.useState(null),ie=(0,B.useComposedRefs)(o,e=>re(e)),R=u||n.duration,z=a.useRef(0),H=a.useRef(R),V=a.useRef(0),{onToastAdd:K,onToastRemove:$}=n,P=(0,s.useEvent)(()=>{var e;se&&(s.isWeb&&(m!=null&&m.contains(document.activeElement))&&((e=n.viewport)==null||e.focus()),I())}),g=a.useCallback(e=>{!e||e===1/0||(clearTimeout(V.current),z.current=new Date().getTime(),V.current=setTimeout(P,e))},[P]),d=a.useCallback(()=>{g(H.current),y==null||y()},[y,g]),f=a.useCallback(()=>{const e=new Date().getTime()-z.current;H.current=H.current-e,window.clearTimeout(V.current),w==null||w()},[w]);a.useEffect(()=>{if(!s.isWeb)return;const e=n.viewport;if(e)return e.addEventListener(v.VIEWPORT_PAUSE,f),e.addEventListener(v.VIEWPORT_RESUME,d),()=>{e.removeEventListener(v.VIEWPORT_PAUSE,f),e.removeEventListener(v.VIEWPORT_RESUME,d)}},[n.viewport,R,w,y,g]),a.useEffect(()=>{l&&!n.isClosePausedRef.current&&g(R)},[l,R,n.isClosePausedRef,g]),a.useEffect(()=>(K(),()=>$()),[K,$]);const G=a.useMemo(()=>s.isWeb&&m?Y(m):null,[m]),X=["left","right","horizontal"].includes(n.swipeDirection),C=(0,s.useAnimationDriver)();if(!C)throw new Error("Must set animations in tamagui.config.ts");const{useAnimatedNumber:ae,useAnimatedNumberStyle:ce}=C,L=ae(0),ue=C.NumberView??C.View,le=ce(L,e=>({transform:[X?{translateX:e}:{translateY:e}]})),F=a.useMemo(()=>j.PanResponder.create({onMoveShouldSetPanResponder:e=>(x==null||x(e),!0),onPanResponderGrant:e=>{s.isWeb||f==null||f()},onPanResponderMove:(e,{dy:T,dx:h})=>{let b=0,D=0;n.swipeDirection==="horizontal"?D=h:n.swipeDirection==="left"?D=Math.min(0,h):n.swipeDirection==="right"?D=Math.max(0,h):n.swipeDirection==="vertical"?b=T:n.swipeDirection==="up"?b=Math.min(0,T):n.swipeDirection==="down"&&(b=Math.max(0,T)),A==null||A(e);const me={x:D,y:b};L.setValue(X?D:b,{type:"direct"}),U(me,n.swipeDirection,n.swipeThreshold)&&(k==null||k(e))},onPanResponderEnd:(e,{dx:T,dy:h})=>{U({x:T,y:h},n.swipeDirection,n.swipeThreshold)||(s.isWeb||d==null||d(),N==null||N(e),L.setValue(0,{type:"spring"}))}}),[f,d]),pe=(0,s.useThemeName)();return(0,c.jsxs)(c.Fragment,{children:[G&&(0,c.jsx)(ee.ToastAnnounce,{__scopeToast:i,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:G}),(0,c.jsx)(Q.PortalItem,{hostName:oe??"default",children:(0,c.jsx)(ge,{scope:i,onClose:()=>{P()},children:(0,c.jsx)(J.Dismissable,{onEscapeKeyDown:(0,s.composeEventHandlers)(p,()=>{n.isFocusedToastEscapeKeyDownRef.current||P(),n.isFocusedToastEscapeKeyDownRef.current=!1}),children:(0,c.jsx)(s.Theme,{forceClassName:!0,name:pe,children:(0,c.jsx)(ue,{...F==null?void 0:F.panHandlers,style:[{margin:"auto"},le],children:(0,c.jsx)(E.Collection.ItemSlot,{scope:i,children:(0,c.jsx)(_,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":l?"open":"closed","data-swipe-direction":n.swipeDirection,pointerEvents:"auto",userSelect:"none",...ne,ref:ie,...s.isWeb&&{onKeyDown:(0,s.composeEventHandlers)(t.onKeyDown,e=>{e.key==="Escape"&&(p==null||p(e),p==null||p(e),e.defaultPrevented||(n.isFocusedToastEscapeKeyDownRef.current=!0,P()))})}})})})})})},t.id)})]})});O.propTypes={type(t){if(t.type&&!["foreground","background"].includes(t.type)){const o=`Invalid prop \`type\` supplied to \`${M.TOAST_NAME}\`. Expected \`foreground | background\`.`;return new Error(o)}return null}};const U=(t,o,i=0)=>{const r=Math.abs(t.x),u=Math.abs(t.y),l=r>u;return o==="left"||o==="right"||o==="horizontal"?l&&r>i:!l&&u>i};function Y(t){if(!s.isWeb)return"";const o=[];return Array.from(t.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&o.push(r.textContent),he(r)){const u=r.ariaHidden||r.hidden||r.style.display==="none",l=r.dataset.toastAnnounceExclude==="";if(!u)if(l){const I=r.dataset.toastAnnounceAlt;I&&o.push(I)}else o.push(...Y(r))}}),o}function he(t){return t.nodeType===t.ELEMENT_NODE}0&&(module.exports={ToastImpl,ToastImplFrame,useToastInteractiveContext});
353
2
  //# sourceMappingURL=ToastImpl.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/ToastImpl.tsx"],
4
4
  "sourcesContent": ["import { useIsPresent } from '@tamagui/animate-presence'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n GetProps,\n TamaguiElement,\n Theme,\n composeEventHandlers,\n isWeb,\n styled,\n useAnimationDriver,\n useEvent,\n useThemeName,\n} from '@tamagui/core'\nimport { Dismissable, DismissableProps } from '@tamagui/dismissable'\nimport { PortalItem } from '@tamagui/portal'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { Animated, GestureResponderEvent, PanResponder } from 'react-native'\n\nimport { TOAST_NAME } from './constants'\nimport { ToastAnnounce } from './ToastAnnounce'\nimport {\n Collection,\n ScopedProps,\n SwipeDirection,\n createToastContext,\n useToastProviderContext,\n} from './ToastProvider'\nimport { VIEWPORT_PAUSE, VIEWPORT_RESUME } from './ToastViewport'\n\nconst ToastImplFrame = styled(ThemeableStack, {\n name: 'ToastImpl',\n variants: {\n backgrounded: {\n true: {\n backgroundColor: '$color6',\n },\n },\n unstyled: {\n false: {\n borderRadius: '$10',\n paddingHorizontal: '$5',\n paddingVertical: '$2',\n marginHorizontal: 'auto',\n marginVertical: '$1',\n },\n },\n },\n defaultVariants: {\n backgrounded: true,\n unstyled: false,\n },\n})\ninterface ToastProps extends Omit<ToastImplProps, keyof ToastImplPrivateProps> {\n /**\n * The controlled open state of the dialog. Must be used in conjunction with `onOpenChange`.\n */\n open?: boolean\n /**\n * The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.\n */\n defaultOpen?: boolean\n /**\n * Event handler called when the open state of the dialog changes.\n */\n onOpenChange?(open: boolean): void\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true\n}\n\ntype SwipeEvent = GestureResponderEvent\n\nconst [ToastInteractiveProvider, useToastInteractiveContext] = createToastContext(\n TOAST_NAME,\n {\n onClose() {},\n }\n)\n\ntype ToastImplPrivateProps = { open: boolean; onClose(): void }\ntype ToastImplFrameProps = GetProps<typeof ToastImplFrame>\ntype ToastImplProps = ToastImplPrivateProps &\n ToastImplFrameProps & {\n /**\n * Control the sensitivity of the toast for accessibility purposes.\n * For toasts that are the result of a user action, choose foreground. Toasts generated from background tasks should use background.\n */\n type?: 'foreground' | 'background'\n /**\n * Time in milliseconds that toast should remain visible for. Overrides value given to `ToastProvider`.\n */\n duration?: number\n /**\n * Event handler called when the escape key is down. It can be prevented by calling `event.preventDefault`.\n */\n onEscapeKeyDown?: DismissableProps['onEscapeKeyDown']\n /**\n * Event handler called when the dismiss timer is paused.\n * On web, this occurs when the pointer is moved over the viewport, the viewport is focused or when the window is blurred.\n * On mobile, this occurs when the toast is touched.\n */\n onPause?(): void\n /**\n * Event handler called when the dismiss timer is resumed.\n * On web, this occurs when the pointer is moved away from the viewport, the viewport is blurred or when the window is focused.\n * On mobile, this occurs when the toast is released.\n */\n onResume?(): void\n /**\n * Event handler called when starting a swipe interaction. It can be prevented by calling `event.preventDefault`.\n */\n onSwipeStart?(event: SwipeEvent): void\n /**\n * Event handler called during a swipe interaction. It can be prevented by calling `event.preventDefault`.\n */\n onSwipeMove?(event: SwipeEvent): void\n /**\n * Event handler called at the cancellation of a swipe interaction. It can be prevented by calling `event.preventDefault`.\n */\n onSwipeCancel?(event: SwipeEvent): void\n /**\n * Event handler called at the end of a swipe interaction. It can be prevented by calling `event.preventDefault`.\n */\n onSwipeEnd?(event: SwipeEvent): void\n /**\n * The viewport's name to send the toast to. Used when using multiple viewports and want to forward toasts to different ones.\n *\n * @default \"default\"\n */\n viewportName?: string\n /**\n * \n */\n id?: string\n }\n\nconst ToastImpl = React.forwardRef<TamaguiElement, ToastImplProps>(\n (props: ScopedProps<ToastImplProps>, forwardedRef) => {\n const {\n __scopeToast,\n type = 'foreground',\n duration: durationProp,\n open,\n onClose,\n onEscapeKeyDown,\n onPause,\n onResume,\n onSwipeStart,\n onSwipeMove,\n onSwipeCancel,\n onSwipeEnd,\n viewportName,\n ...toastProps\n } = props\n const isPresent = useIsPresent()\n const context = useToastProviderContext(TOAST_NAME, __scopeToast)\n const [node, setNode] = React.useState<TamaguiElement | null>(null)\n const composedRefs = useComposedRefs(forwardedRef, (node) => setNode(node))\n const duration = durationProp || context.duration\n const closeTimerStartTimeRef = React.useRef(0)\n const closeTimerRemainingTimeRef = React.useRef(duration)\n const closeTimerRef = React.useRef(0)\n const { onToastAdd, onToastRemove } = context\n const handleClose = useEvent(() => {\n if (!isPresent) {\n // already removed from the react tree\n return\n }\n // focus viewport if focus is within toast to read the remaining toast\n // count to SR users and ensure focus isn't lost\n if (isWeb) {\n const isFocusInToast = (node as HTMLDivElement)?.contains(document.activeElement)\n if (isFocusInToast) context.viewport?.focus()\n }\n onClose()\n })\n\n const startTimer = React.useCallback(\n (duration: number) => {\n if (!duration || duration === Infinity) return\n clearTimeout(closeTimerRef.current)\n closeTimerStartTimeRef.current = new Date().getTime()\n closeTimerRef.current = setTimeout(handleClose, duration) as unknown as number\n },\n [handleClose]\n )\n const handleResume = React.useCallback(() => {\n startTimer(closeTimerRemainingTimeRef.current)\n onResume?.()\n }, [onResume, startTimer])\n const handlePause = React.useCallback(() => {\n const elapsedTime = new Date().getTime() - closeTimerStartTimeRef.current\n closeTimerRemainingTimeRef.current =\n closeTimerRemainingTimeRef.current - elapsedTime\n window.clearTimeout(closeTimerRef.current)\n onPause?.()\n }, [onPause])\n\n React.useEffect(() => {\n if (!isWeb) return\n const viewport = context.viewport as HTMLElement\n if (viewport) {\n viewport.addEventListener(VIEWPORT_PAUSE, handlePause)\n viewport.addEventListener(VIEWPORT_RESUME, handleResume)\n return () => {\n viewport.removeEventListener(VIEWPORT_PAUSE, handlePause)\n viewport.removeEventListener(VIEWPORT_RESUME, handleResume)\n }\n }\n }, [context.viewport, duration, onPause, onResume, startTimer])\n\n // start timer when toast opens or duration changes.\n // we include `open` in deps because closed !== unmounted when animating\n // so it could reopen before being completely unmounted\n React.useEffect(() => {\n if (open && !context.isClosePausedRef.current) {\n startTimer(duration)\n }\n }, [open, duration, context.isClosePausedRef, startTimer])\n\n React.useEffect(() => {\n onToastAdd()\n return () => onToastRemove()\n }, [onToastAdd, onToastRemove])\n\n const announceTextContent = React.useMemo(() => {\n if (!isWeb) return null\n return node ? getAnnounceTextContent(node as HTMLDivElement) : null\n }, [node])\n\n const isHorizontalSwipe = ['left', 'right', 'horizontal'].includes(\n context.swipeDirection\n )\n\n const driver = useAnimationDriver()\n if (!driver) {\n throw new Error('Must set animations in tamagui.config.ts')\n }\n\n const { useAnimatedNumber, useAnimatedNumberStyle } = driver\n\n const animatedNumber = useAnimatedNumber(0)\n\n // temp until reanimated useAnimatedNumber fix\n const AnimatedView = (driver['NumberView'] ?? driver.View) as typeof Animated.View\n\n const animatedStyles = useAnimatedNumberStyle(animatedNumber, (val) => {\n return {\n transform: [isHorizontalSwipe ? { translateX: val } : { translateY: val }],\n }\n })\n\n const panResponder = React.useMemo(() => {\n return PanResponder.create({\n onMoveShouldSetPanResponder: (e) => {\n onSwipeStart?.(e)\n return true\n },\n onPanResponderGrant: (e) => {\n if (!isWeb) {\n handlePause?.()\n }\n },\n onPanResponderMove: (e, { dy, dx }) => {\n let y = 0\n let x = 0\n if (context.swipeDirection === 'horizontal') x = dx\n else if (context.swipeDirection === 'left') x = Math.min(0, dx)\n else if (context.swipeDirection === 'right') x = Math.max(0, dx)\n else if (context.swipeDirection === 'vertical') y = dy\n else if (context.swipeDirection === 'up') y = Math.min(0, dy)\n else if (context.swipeDirection === 'down') y = Math.max(0, dy)\n\n onSwipeMove?.(e)\n\n const delta = { x, y }\n animatedNumber.setValue(isHorizontalSwipe ? x : y, { type: 'direct' })\n if (isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold)) {\n onSwipeEnd?.(e)\n }\n },\n onPanResponderEnd: (e, { dx, dy }) => {\n if (\n !isDeltaInDirection(\n { x: dx, y: dy },\n context.swipeDirection,\n context.swipeThreshold\n )\n ) {\n if (!isWeb) {\n handleResume?.()\n }\n onSwipeCancel?.(e)\n animatedNumber.setValue(0, { type: 'spring' })\n }\n },\n })\n }, [handlePause, handleResume])\n\n // need to get the theme name from context and apply it again since portals don't retain the theme\n const themeName = useThemeName()\n\n return (\n <>\n {announceTextContent && (\n <ToastAnnounce\n __scopeToast={__scopeToast}\n // Toasts are always role=status to avoid stuttering issues with role=alert in SRs.\n role=\"status\"\n aria-live={type === 'foreground' ? 'assertive' : 'polite'}\n aria-atomic\n >\n {announceTextContent}\n </ToastAnnounce>\n )}\n\n <PortalItem hostName={viewportName ?? 'default'}>\n <ToastInteractiveProvider\n key={props.id}\n scope={__scopeToast}\n onClose={() => {\n handleClose()\n }}\n >\n <Dismissable\n // asChild\n onEscapeKeyDown={composeEventHandlers(onEscapeKeyDown, () => {\n if (!context.isFocusedToastEscapeKeyDownRef.current) {\n handleClose()\n }\n context.isFocusedToastEscapeKeyDownRef.current = false\n })}\n >\n <Theme forceClassName name={themeName}>\n <AnimatedView\n {...panResponder?.panHandlers}\n style={[{ margin: 'auto' }, animatedStyles]}\n >\n <Collection.ItemSlot scope={__scopeToast}>\n <ToastImplFrame\n // Ensure toasts are announced as status list or status when focused\n role=\"status\"\n aria-live=\"off\"\n aria-atomic\n tabIndex={0}\n data-state={open ? 'open' : 'closed'}\n data-swipe-direction={context.swipeDirection}\n pointerEvents=\"auto\"\n // touchAction=\"none\"\n userSelect=\"none\"\n {...toastProps}\n ref={composedRefs}\n {...(isWeb && {\n onKeyDown: composeEventHandlers(\n (props as any).onKeyDown,\n (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return\n onEscapeKeyDown?.(event)\n onEscapeKeyDown?.(event)\n if (!event.defaultPrevented) {\n context.isFocusedToastEscapeKeyDownRef.current = true\n handleClose()\n }\n }\n ),\n })}\n />\n </Collection.ItemSlot>\n </AnimatedView>\n </Theme>\n </Dismissable>\n </ToastInteractiveProvider>\n </PortalItem>\n </>\n )\n }\n)\n\nToastImpl.propTypes = {\n type(props) {\n if (props.type && !['foreground', 'background'].includes(props.type)) {\n const error = `Invalid prop \\`type\\` supplied to \\`${TOAST_NAME}\\`. Expected \\`foreground | background\\`.`\n return new Error(error)\n }\n return null\n },\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\nconst isDeltaInDirection = (\n delta: { x: number; y: number },\n direction: SwipeDirection,\n threshold = 0\n) => {\n const deltaX = Math.abs(delta.x)\n const deltaY = Math.abs(delta.y)\n const isDeltaX = deltaX > deltaY\n if (direction === 'left' || direction === 'right' || direction === 'horizontal') {\n return isDeltaX && deltaX > threshold\n } else {\n return !isDeltaX && deltaY > threshold\n }\n}\n\nfunction getAnnounceTextContent(container: HTMLElement) {\n if (!isWeb) return ''\n const textContent: string[] = []\n const childNodes = Array.from(container.childNodes)\n\n childNodes.forEach((node) => {\n if (node.nodeType === node.TEXT_NODE && node.textContent)\n textContent.push(node.textContent)\n if (isHTMLElement(node)) {\n const isHidden = node.ariaHidden || node.hidden || node.style.display === 'none'\n const isExcluded = node.dataset.toastAnnounceExclude === ''\n\n if (!isHidden) {\n if (isExcluded) {\n const altText = node.dataset.toastAnnounceAlt\n if (altText) textContent.push(altText)\n } else {\n textContent.push(...getAnnounceTextContent(node))\n }\n }\n }\n })\n\n // We return a collection of text rather than a single concatenated string.\n // This allows SR VO to naturally pause break between nodes while announcing.\n return textContent\n}\n\nfunction isHTMLElement(node: any): node is HTMLElement {\n return node.nodeType === node.ELEMENT_NODE\n}\n\nexport { ToastImpl, ToastImplFrame, ToastImplProps, useToastInteractiveContext }\nexport type { ToastProps }\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkTM;AAlTN,8BAA6B;AAC7B,0BAAgC;AAChC,kBAUO;AACP,yBAA8C;AAC9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AM,IAAI,EAAG,CACpE,MAAMqD,EAAQ,uCAAuC,wDACrD,OAAO,IAAI,MAAMA,CAAK,CACxB,CACA,OAAO,IACT,CACF,EAIA,MAAMH,EAAqB,CACzBD,EACAK,EACAC,EAAY,IACT,CACH,MAAMC,EAAS,KAAK,IAAIP,EAAM,CAAC,EACzBQ,EAAS,KAAK,IAAIR,EAAM,CAAC,EACzBS,EAAWF,EAASC,EAC1B,OAAIH,IAAc,QAAUA,IAAc,SAAWA,IAAc,aAC1DI,GAAYF,EAASD,EAErB,CAACG,GAAYD,EAASF,CAEjC,EAEA,SAASpB,EAAuBwB,EAAwB,CACtD,GAAI,CAAC,QAAO,MAAO,GACnB,MAAMC,EAAwB,CAAC,EAG/B,OAFmB,MAAM,KAAKD,EAAU,UAAU,EAEvC,QAASzC,GAAS,CAG3B,GAFIA,EAAK,WAAaA,EAAK,WAAaA,EAAK,aAC3C0C,EAAY,KAAK1C,EAAK,WAAW,EAC/B2C,GAAc3C,CAAI,EAAG,CACvB,MAAM4C,EAAW5C,EAAK,YAAcA,EAAK,QAAUA,EAAK,MAAM,UAAY,OACpE6C,EAAa7C,EAAK,QAAQ,uBAAyB,GAEzD,GAAI,CAAC4C,EACH,GAAIC,EAAY,CACd,MAAMC,EAAU9C,EAAK,QAAQ,iBACzB8C,GAASJ,EAAY,KAAKI,CAAO,CACvC,MACEJ,EAAY,KAAK,GAAGzB,EAAuBjB,CAAI,CAAC,CAGtD,CACF,CAAC,EAIM0C,CACT,CAEA,SAASC,GAAc3C,EAAgC,CACrD,OAAOA,EAAK,WAAaA,EAAK,YAChC",
6
+ "names": ["ToastImpl_exports", "__export", "ToastImpl", "ToastImplFrame", "useToastInteractiveContext", "__toCommonJS", "import_jsx_runtime", "import_animate_presence", "import_compose_refs", "import_core", "import_dismissable", "import_portal", "import_stacks", "React", "import_react_native", "import_constants", "import_ToastAnnounce", "import_ToastProvider", "import_ToastViewport", "ToastInteractiveProvider", "props", "forwardedRef", "__scopeToast", "type", "durationProp", "open", "onClose", "onEscapeKeyDown", "onPause", "onResume", "onSwipeStart", "onSwipeMove", "onSwipeCancel", "onSwipeEnd", "viewportName", "toastProps", "isPresent", "context", "node", "setNode", "composedRefs", "duration", "closeTimerStartTimeRef", "closeTimerRemainingTimeRef", "closeTimerRef", "onToastAdd", "onToastRemove", "handleClose", "_a", "startTimer", "handleResume", "handlePause", "elapsedTime", "viewport", "announceTextContent", "getAnnounceTextContent", "isHorizontalSwipe", "driver", "useAnimatedNumber", "useAnimatedNumberStyle", "animatedNumber", "AnimatedView", "animatedStyles", "val", "panResponder", "dy", "dx", "y", "x", "delta", "isDeltaInDirection", "themeName", "event", "error", "direction", "threshold", "deltaX", "deltaY", "isDeltaX", "container", "textContent", "isHTMLElement", "isHidden", "isExcluded", "altText"]
7
7
  }
@@ -1,120 +1,2 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var ToastProvider_exports = {};
30
- __export(ToastProvider_exports, {
31
- Collection: () => Collection,
32
- ToastProvider: () => ToastProvider,
33
- createToastContext: () => createToastContext,
34
- createToastScope: () => createToastScope,
35
- useCollection: () => useCollection,
36
- useToastProviderContext: () => useToastProviderContext
37
- });
38
- module.exports = __toCommonJS(ToastProvider_exports);
39
- var import_jsx_runtime = require("react/jsx-runtime");
40
- var import_collection = require("@tamagui/collection");
41
- var import_core = require("@tamagui/core");
42
- var import_create_context = require("@tamagui/create-context");
43
- var React = __toESM(require("react"));
44
- var import_ToastImperative = require("./ToastImperative");
45
- const PROVIDER_NAME = "ToastProvider";
46
- const [Collection, useCollection, createCollectionScope] = (0, import_collection.createCollection)("Toast");
47
- const [createToastContext, createToastScope] = (0, import_create_context.createContextScope)("Toast", [
48
- createCollectionScope
49
- ]);
50
- const [ToastProviderProvider, useToastProviderContext] = createToastContext(PROVIDER_NAME);
51
- const ToastProvider = (props) => {
52
- const {
53
- __scopeToast,
54
- id: providedId,
55
- burntOptions,
56
- native,
57
- notificationOptions,
58
- label = "Notification",
59
- duration = 5e3,
60
- swipeDirection = "right",
61
- swipeThreshold = 50,
62
- children
63
- } = props;
64
- const id = providedId ?? (0, import_core.useId)();
65
- const [viewport, setViewport] = React.useState(null);
66
- const [toastCount, setToastCount] = React.useState(0);
67
- const isFocusedToastEscapeKeyDownRef = React.useRef(false);
68
- const isClosePausedRef = React.useRef(false);
69
- const options = React.useMemo(() => {
70
- return {
71
- duration,
72
- burntOptions,
73
- native,
74
- notificationOptions
75
- };
76
- }, [JSON.stringify([duration, burntOptions, native, notificationOptions])]);
77
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Provider, { scope: __scopeToast, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
78
- ToastProviderProvider,
79
- {
80
- scope: __scopeToast,
81
- id,
82
- label,
83
- duration,
84
- swipeDirection,
85
- swipeThreshold,
86
- toastCount,
87
- viewport,
88
- onViewportChange: setViewport,
89
- onToastAdd: React.useCallback(() => {
90
- setToastCount((prevCount) => prevCount + 1);
91
- }, []),
92
- onToastRemove: React.useCallback(() => {
93
- setToastCount((prevCount) => prevCount - 1);
94
- }, []),
95
- isFocusedToastEscapeKeyDownRef,
96
- isClosePausedRef,
97
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastImperative.ToastImperativeProvider, { options, children })
98
- }
99
- ) });
100
- };
101
- ToastProvider.propTypes = {
102
- label(props) {
103
- if (props.label && typeof props.label === "string" && !props.label.trim()) {
104
- const error = `Invalid prop \`label\` supplied to \`${PROVIDER_NAME}\`. Expected non-empty \`string\`.`;
105
- return new Error(error);
106
- }
107
- return null;
108
- }
109
- };
110
- ToastProvider.displayName = PROVIDER_NAME;
111
- // Annotate the CommonJS export names for ESM import in node:
112
- 0 && (module.exports = {
113
- Collection,
114
- ToastProvider,
115
- createToastContext,
116
- createToastScope,
117
- useCollection,
118
- useToastProviderContext
119
- });
1
+ "use strict";var M=Object.create;var a=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var j=(e,o)=>{for(var t in o)a(e,t,{get:o[t],enumerable:!0})},P=(e,o,t,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of K(o))!B.call(e,i)&&i!==t&&a(e,i,{get:()=>o[i],enumerable:!(s=A(o,i))||s.enumerable});return e};var z=(e,o,t)=>(t=e!=null?M(k(e)):{},P(o||!e||!e.__esModule?a(t,"default",{value:e,enumerable:!0}):t,e)),J=e=>P(a({},"__esModule",{value:!0}),e);var G={};j(G,{Collection:()=>u,ToastProvider:()=>n,createToastContext:()=>T,createToastScope:()=>g,useCollection:()=>R,useToastProviderContext:()=>h});module.exports=J(G);var p=require("react/jsx-runtime"),f=require("@tamagui/collection"),b=require("@tamagui/core"),w=require("@tamagui/create-context"),r=z(require("react")),C=require("./ToastImperative");const d="ToastProvider",[u,R,$]=(0,f.createCollection)("Toast"),[T,g]=(0,w.createContextScope)("Toast",[$]),[q,h]=T(d),n=e=>{const{__scopeToast:o,id:t,burntOptions:s,native:i,notificationOptions:m,label:S="Notification",duration:l=5e3,swipeDirection:y="right",swipeThreshold:D=50,children:E}=e,O=t??(0,b.useId)(),[x,N]=r.useState(null),[V,v]=r.useState(0),I=r.useRef(!1),_=r.useRef(!1),F=r.useMemo(()=>({duration:l,burntOptions:s,native:i,notificationOptions:m}),[JSON.stringify([l,s,i,m])]);return(0,p.jsx)(u.Provider,{scope:o,children:(0,p.jsx)(q,{scope:o,id:O,label:S,duration:l,swipeDirection:y,swipeThreshold:D,toastCount:V,viewport:x,onViewportChange:N,onToastAdd:r.useCallback(()=>{v(c=>c+1)},[]),onToastRemove:r.useCallback(()=>{v(c=>c-1)},[]),isFocusedToastEscapeKeyDownRef:I,isClosePausedRef:_,children:(0,p.jsx)(C.ToastImperativeProvider,{options:F,children:E})})})};n.propTypes={label(e){if(e.label&&typeof e.label=="string"&&!e.label.trim()){const o=`Invalid prop \`label\` supplied to \`${d}\`. Expected non-empty \`string\`.`;return new Error(o)}return null}},n.displayName=d;0&&(module.exports={Collection,ToastProvider,createToastContext,createToastScope,useCollection,useToastProviderContext});
120
2
  //# sourceMappingURL=ToastProvider.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/ToastProvider.tsx"],
4
4
  "sourcesContent": ["import { createCollection } from '@tamagui/collection'\nimport { TamaguiElement, useId } from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport * as React from 'react'\n\nimport { ToastImperativeProvider, ToastNativeValue } from './ToastImperative'\nimport { BurntToastOptions } from './types'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROVIDER_NAME = 'ToastProvider'\n\nconst [Collection, useCollection, createCollectionScope] =\n createCollection<TamaguiElement>('Toast')\n\ntype SwipeDirection = 'vertical' | 'up' | 'down' | 'horizontal' | 'left' | 'right'\ntype ToastProviderContextValue = {\n id: string\n label: string\n duration: number\n swipeDirection: SwipeDirection\n swipeThreshold: number\n toastCount: number\n viewport: TamaguiElement | null\n onViewportChange(viewport: TamaguiElement): void\n onToastAdd(): void\n onToastRemove(): void\n isFocusedToastEscapeKeyDownRef: React.MutableRefObject<boolean>\n isClosePausedRef: React.MutableRefObject<boolean>\n}\n\ntype ScopedProps<P> = P & { __scopeToast?: Scope }\nconst [createToastContext, createToastScope] = createContextScope('Toast', [\n createCollectionScope,\n])\nconst [ToastProviderProvider, useToastProviderContext] =\n createToastContext<ToastProviderContextValue>(PROVIDER_NAME)\n\ninterface ToastProviderProps {\n children?: React.ReactNode\n /**\n * An author-localized label for each toast. Used to help screen reader users\n * associate the interruption with a toast.\n * @defaultValue 'Notification'\n */\n label?: string\n /**\n * Time in milliseconds that each toast should remain visible for.\n * @defaultValue 5000\n */\n duration?: number\n /**\n * Direction of pointer swipe that should close the toast.\n * @defaultValue 'right'\n */\n swipeDirection?: SwipeDirection\n /**\n * Distance in pixels that the swipe must pass before a close is triggered.\n * @defaultValue 50\n */\n swipeThreshold?: number\n /**\n * @defaultValue unique generated identifier\n */\n id?: string\n /**\n * Will show a native toast if is true or is set to the current platform. On iOS, it wraps `SPIndicator` and `SPAlert`. On Android, it wraps `ToastAndroid`. On web, it wraps Notification API. Mobile's native features are handled by `burnt`.\n * Only works with the imperative `useToast` hook.\n */\n native?: ToastNativeValue\n /**\n * Options for the burnt package if you're using native toasts on mobile\n */\n burntOptions?: Omit<BurntToastOptions, 'title' | 'message' | 'duration'>\n /**\n * Options for the notification API if you're using native toasts on web\n */\n notificationOptions?: NotificationOptions\n}\n\nconst ToastProvider: React.FC<ToastProviderProps> = (\n props: ScopedProps<ToastProviderProps>\n) => {\n const {\n __scopeToast,\n id: providedId,\n burntOptions,\n native,\n notificationOptions,\n label = 'Notification',\n duration = 5000,\n swipeDirection = 'right',\n swipeThreshold = 50,\n children,\n } = props\n const id = providedId ?? useId()\n const [viewport, setViewport] = React.useState<TamaguiElement | null>(null)\n const [toastCount, setToastCount] = React.useState(0)\n const isFocusedToastEscapeKeyDownRef = React.useRef(false)\n const isClosePausedRef = React.useRef(false)\n\n // memo context to avoid expensive re-renders\n const options = React.useMemo(() => {\n return {\n duration,\n burntOptions,\n native,\n notificationOptions,\n }\n // nested simple object so JSON.stringify\n }, [JSON.stringify([duration, burntOptions, native, notificationOptions])])\n\n return (\n <Collection.Provider scope={__scopeToast}>\n <ToastProviderProvider\n scope={__scopeToast}\n id={id}\n label={label}\n duration={duration}\n swipeDirection={swipeDirection}\n swipeThreshold={swipeThreshold}\n toastCount={toastCount}\n viewport={viewport}\n onViewportChange={setViewport}\n onToastAdd={React.useCallback(() => {\n setToastCount((prevCount) => prevCount + 1)\n }, [])}\n onToastRemove={React.useCallback(() => {\n setToastCount((prevCount) => prevCount - 1)\n }, [])}\n isFocusedToastEscapeKeyDownRef={isFocusedToastEscapeKeyDownRef}\n isClosePausedRef={isClosePausedRef}\n >\n <ToastImperativeProvider options={options}>{children}</ToastImperativeProvider>\n </ToastProviderProvider>\n </Collection.Provider>\n )\n}\n\nToastProvider.propTypes = {\n label(props) {\n if (props.label && typeof props.label === 'string' && !props.label.trim()) {\n const error = `Invalid prop \\`label\\` supplied to \\`${PROVIDER_NAME}\\`. Expected non-empty \\`string\\`.`\n return new Error(error)\n }\n return null\n },\n}\n\nToastProvider.displayName = PROVIDER_NAME\n\nexport {\n Collection,\n ToastProvider,\n createToastContext,\n createToastScope,\n useCollection,\n useToastProviderContext,\n}\nexport type { ScopedProps, SwipeDirection, ToastProviderProps }\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwIQ;AAxIR,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sB,EAAmBtB,EAAM,OAAO,EAAK,EAGrCuB,EAAUvB,EAAM,QAAQ,KACrB,CACL,SAAAY,EACA,aAAAJ,EACA,OAAAC,EACA,oBAAAC,CACF,GAEC,CAAC,KAAK,UAAU,CAACE,EAAUJ,EAAcC,EAAQC,CAAmB,CAAC,CAAC,CAAC,EAE1E,SACE,OAACrB,EAAW,SAAX,CAAoB,MAAOiB,EAC1B,mBAACF,EAAA,CACC,MAAOE,EACP,GAAIU,EACJ,MAAOL,EACP,SAAUC,EACV,eAAgBC,EAChB,eAAgBC,EAChB,WAAYK,EACZ,SAAUF,EACV,iBAAkBC,EAClB,WAAYlB,EAAM,YAAY,IAAM,CAClCoB,EAAeI,GAAcA,EAAY,CAAC,CAC5C,EAAG,CAAC,CAAC,EACL,cAAexB,EAAM,YAAY,IAAM,CACrCoB,EAAeI,GAAcA,EAAY,CAAC,CAC5C,EAAG,CAAC,CAAC,EACL,+BAAgCH,EAChC,iBAAkBC,EAElB,mBAAC,2BAAwB,QAASC,EAAU,SAAAR,EAAS,EACvD,EACF,CAEJ,EAEAzB,EAAc,UAAY,CACxB,MAAMe,EAAO,CACX,GAAIA,EAAM,OAAS,OAAOA,EAAM,OAAU,UAAY,CAACA,EAAM,MAAM,KAAK,EAAG,CACzE,MAAMoB,EAAQ,wCAAwCvB,sCACtD,OAAO,IAAI,MAAMuB,CAAK,CACxB,CACA,OAAO,IACT,CACF,EAEAnC,EAAc,YAAcY",
6
+ "names": ["ToastProvider_exports", "__export", "Collection", "ToastProvider", "createToastContext", "createToastScope", "useCollection", "useToastProviderContext", "__toCommonJS", "import_jsx_runtime", "import_collection", "import_core", "import_create_context", "React", "import_ToastImperative", "PROVIDER_NAME", "createCollectionScope", "ToastProviderProvider", "props", "__scopeToast", "providedId", "burntOptions", "native", "notificationOptions", "label", "duration", "swipeDirection", "swipeThreshold", "children", "id", "viewport", "setViewport", "toastCount", "setToastCount", "isFocusedToastEscapeKeyDownRef", "isClosePausedRef", "options", "prevCount", "error"]
7
7
  }