react-native-bread 0.1.1 → 0.1.3

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 (68) hide show
  1. package/README.md +4 -3
  2. package/lib/commonjs/icons/CloseIcon.js +1 -22
  3. package/lib/commonjs/icons/GreenCheck.js +1 -27
  4. package/lib/commonjs/icons/InfoIcon.js +1 -24
  5. package/lib/commonjs/icons/RedX.js +1 -27
  6. package/lib/commonjs/icons/index.js +1 -34
  7. package/lib/commonjs/index.js +1 -59
  8. package/lib/commonjs/toast-api.js +1 -127
  9. package/lib/commonjs/toast-provider.js +1 -66
  10. package/lib/commonjs/toast-store.js +1 -278
  11. package/lib/commonjs/toast.js +1 -481
  12. package/lib/commonjs/types.js +1 -6
  13. package/lib/module/icons/CloseIcon.js +1 -16
  14. package/lib/module/icons/GreenCheck.js +1 -21
  15. package/lib/module/icons/InfoIcon.js +1 -18
  16. package/lib/module/icons/RedX.js +1 -21
  17. package/lib/module/icons/index.js +1 -7
  18. package/lib/module/index.js +1 -14
  19. package/lib/module/toast-api.js +1 -124
  20. package/lib/module/toast-provider.js +1 -62
  21. package/lib/module/toast-store.js +1 -274
  22. package/lib/module/toast.js +1 -475
  23. package/lib/module/types.js +1 -4
  24. package/package.json +7 -6
  25. package/lib/commonjs/icons/CloseIcon.js.map +0 -1
  26. package/lib/commonjs/icons/GreenCheck.js.map +0 -1
  27. package/lib/commonjs/icons/InfoIcon.js.map +0 -1
  28. package/lib/commonjs/icons/RedX.js.map +0 -1
  29. package/lib/commonjs/icons/index.js.map +0 -1
  30. package/lib/commonjs/index.js.map +0 -1
  31. package/lib/commonjs/toast-api.js.map +0 -1
  32. package/lib/commonjs/toast-provider.js.map +0 -1
  33. package/lib/commonjs/toast-store.js.map +0 -1
  34. package/lib/commonjs/toast.js.map +0 -1
  35. package/lib/commonjs/types.js.map +0 -1
  36. package/lib/module/icons/CloseIcon.js.map +0 -1
  37. package/lib/module/icons/GreenCheck.js.map +0 -1
  38. package/lib/module/icons/InfoIcon.js.map +0 -1
  39. package/lib/module/icons/RedX.js.map +0 -1
  40. package/lib/module/icons/index.js.map +0 -1
  41. package/lib/module/index.js.map +0 -1
  42. package/lib/module/toast-api.js.map +0 -1
  43. package/lib/module/toast-provider.js.map +0 -1
  44. package/lib/module/toast-store.js.map +0 -1
  45. package/lib/module/toast.js.map +0 -1
  46. package/lib/module/types.js.map +0 -1
  47. package/lib/typescript/icons/CloseIcon.d.ts.map +0 -1
  48. package/lib/typescript/icons/GreenCheck.d.ts.map +0 -1
  49. package/lib/typescript/icons/InfoIcon.d.ts.map +0 -1
  50. package/lib/typescript/icons/RedX.d.ts.map +0 -1
  51. package/lib/typescript/icons/index.d.ts.map +0 -1
  52. package/lib/typescript/index.d.ts.map +0 -1
  53. package/lib/typescript/toast-api.d.ts.map +0 -1
  54. package/lib/typescript/toast-provider.d.ts.map +0 -1
  55. package/lib/typescript/toast-store.d.ts.map +0 -1
  56. package/lib/typescript/toast.d.ts.map +0 -1
  57. package/lib/typescript/types.d.ts.map +0 -1
  58. package/src/icons/CloseIcon.tsx +0 -10
  59. package/src/icons/GreenCheck.tsx +0 -16
  60. package/src/icons/InfoIcon.tsx +0 -12
  61. package/src/icons/RedX.tsx +0 -16
  62. package/src/icons/index.ts +0 -4
  63. package/src/index.ts +0 -26
  64. package/src/toast-api.ts +0 -213
  65. package/src/toast-provider.tsx +0 -77
  66. package/src/toast-store.ts +0 -270
  67. package/src/toast.tsx +0 -466
  68. package/src/types.ts +0 -121
@@ -1,481 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ToastContainer = void 0;
7
- var _react = require("react");
8
- var _reactNative = require("react-native");
9
- var _reactNativeGestureHandler = require("react-native-gesture-handler");
10
- var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
11
- var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
12
- var _reactNativeWorklets = require("react-native-worklets");
13
- var _index = require("./icons/index.js");
14
- var _toastStore = require("./toast-store.js");
15
- var _jsxRuntime = require("react/jsx-runtime");
16
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
17
- const ICON_SIZE = 28;
18
-
19
- /** Memoized default icons to prevent SVG re-renders */
20
- const MemoizedGreenCheck = /*#__PURE__*/(0, _react.memo)(({
21
- fill
22
- }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.GreenCheck, {
23
- width: 36,
24
- height: 36,
25
- fill: fill
26
- }));
27
- const MemoizedRedX = /*#__PURE__*/(0, _react.memo)(({
28
- fill
29
- }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.RedX, {
30
- width: ICON_SIZE,
31
- height: ICON_SIZE,
32
- fill: fill
33
- }));
34
- const MemoizedInfoIcon = /*#__PURE__*/(0, _react.memo)(({
35
- fill
36
- }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.InfoIcon, {
37
- width: ICON_SIZE,
38
- height: ICON_SIZE,
39
- fill: fill
40
- }));
41
- const MemoizedCloseIcon = /*#__PURE__*/(0, _react.memo)(() => /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.CloseIcon, {
42
- width: 20,
43
- height: 20
44
- }));
45
-
46
- /** Default icon for each toast type - memoized */
47
- const DefaultIcon = /*#__PURE__*/(0, _react.memo)(({
48
- type,
49
- accentColor
50
- }) => {
51
- switch (type) {
52
- case "success":
53
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(MemoizedGreenCheck, {
54
- fill: accentColor
55
- });
56
- case "error":
57
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(MemoizedRedX, {
58
- fill: accentColor
59
- });
60
- case "loading":
61
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
62
- size: ICON_SIZE,
63
- color: accentColor
64
- });
65
- case "info":
66
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(MemoizedInfoIcon, {
67
- fill: accentColor
68
- });
69
- default:
70
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(MemoizedGreenCheck, {
71
- fill: accentColor
72
- });
73
- }
74
- });
75
- /** Resolves the icon to render - checks per-toast, then config, then default */
76
- const resolveIcon = (type, accentColor, customIcon, configIcon) => {
77
- if (customIcon) {
78
- if (typeof customIcon === "function") {
79
- return customIcon({
80
- color: accentColor,
81
- size: ICON_SIZE
82
- });
83
- }
84
- return customIcon;
85
- }
86
- if (configIcon) {
87
- return configIcon({
88
- color: accentColor,
89
- size: ICON_SIZE
90
- });
91
- }
92
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(DefaultIcon, {
93
- type: type,
94
- accentColor: accentColor
95
- });
96
- };
97
-
98
- /** Animated icon wrapper with scale/fade animation */
99
- const AnimatedIcon = /*#__PURE__*/(0, _react.memo)(({
100
- type,
101
- accentColor,
102
- customIcon,
103
- configIcon
104
- }) => {
105
- const progress = (0, _reactNativeReanimated.useSharedValue)(0);
106
- (0, _react.useEffect)(() => {
107
- progress.value = (0, _reactNativeReanimated.withTiming)(1, {
108
- duration: 350,
109
- easing: _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.back(1.5))
110
- });
111
- }, [progress]);
112
- const style = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
113
- opacity: progress.value,
114
- transform: [{
115
- scale: 0.7 + progress.value * 0.3
116
- }]
117
- }));
118
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
119
- style: style,
120
- children: resolveIcon(type, accentColor, customIcon, configIcon)
121
- });
122
- });
123
- /** Memoized toast content to prevent inline JSX recreation */
124
- const ToastContent = /*#__PURE__*/(0, _react.memo)(({
125
- type,
126
- title,
127
- description,
128
- accentColor,
129
- customIcon,
130
- configIcon,
131
- showCloseButton,
132
- onDismiss,
133
- titleStyle,
134
- descriptionStyle,
135
- optionsTitleStyle,
136
- optionsDescriptionStyle
137
- }) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
138
- style: styles.content,
139
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
140
- style: styles.icon,
141
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedIcon, {
142
- type: type,
143
- accentColor: accentColor,
144
- customIcon: customIcon,
145
- configIcon: configIcon
146
- }, type)
147
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
148
- style: styles.textContainer,
149
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
150
- maxFontSizeMultiplier: 1.35,
151
- allowFontScaling: false,
152
- style: [styles.title, {
153
- color: accentColor
154
- }, titleStyle, optionsTitleStyle],
155
- children: title
156
- }), description && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
157
- allowFontScaling: false,
158
- maxFontSizeMultiplier: 1.35,
159
- style: [styles.description, descriptionStyle, optionsDescriptionStyle],
160
- children: description
161
- })]
162
- }), showCloseButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
163
- style: styles.closeButton,
164
- onPress: onDismiss,
165
- hitSlop: 12,
166
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(MemoizedCloseIcon, {})
167
- })]
168
- }));
169
-
170
- // singleton instance
171
- const ToastContainer = () => {
172
- const [visibleToasts, setVisibleToasts] = (0, _react.useState)([]);
173
- const [theme, setTheme] = (0, _react.useState)(() => _toastStore.toastStore.getTheme());
174
- const {
175
- top,
176
- bottom
177
- } = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
178
- (0, _react.useEffect)(() => {
179
- const initialState = _toastStore.toastStore.getState();
180
- setVisibleToasts(initialState.visibleToasts);
181
- setTheme(_toastStore.toastStore.getTheme());
182
- return _toastStore.toastStore.subscribe(state => {
183
- setVisibleToasts(state.visibleToasts);
184
- setTheme(_toastStore.toastStore.getTheme());
185
- });
186
- }, []);
187
-
188
- // Calculate visual index for each toast (exiting toasts don't count)
189
- const getVisualIndex = (0, _react.useCallback)(toastId => {
190
- let visualIndex = 0;
191
- for (const t of visibleToasts) {
192
- if (t.id === toastId) break;
193
- if (!t.isExiting) visualIndex++;
194
- }
195
- return visualIndex;
196
- }, [visibleToasts]);
197
-
198
- // Memoize the reversed array to avoid recreating on each render
199
- const reversedToasts = (0, _react.useMemo)(() => [...visibleToasts].reverse(), [visibleToasts]);
200
- if (visibleToasts.length === 0) {
201
- return null;
202
- }
203
- const isBottom = theme.position === "bottom";
204
- const inset = isBottom ? bottom : top;
205
- const positionStyle = isBottom ? {
206
- bottom: inset + theme.offset + 2
207
- } : {
208
- top: inset + theme.offset + 2
209
- };
210
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
211
- style: [styles.container, positionStyle],
212
- pointerEvents: "box-none",
213
- children: reversedToasts.map(toast => {
214
- const index = toast.isExiting ? -1 : getVisualIndex(toast.id);
215
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(MemoizedToastItem, {
216
- toast: toast,
217
- index: index,
218
- theme: theme,
219
- position: theme.position
220
- }, toast.id);
221
- })
222
- });
223
- };
224
- exports.ToastContainer = ToastContainer;
225
- const EASING = _reactNativeReanimated.Easing.bezier(0.25, 0.1, 0.25, 1.0);
226
- const ToY = 0;
227
- const Duration = 400;
228
- const ExitDuration = 350;
229
- const MaxDragDown = 60;
230
- const ToastItem = ({
231
- toast,
232
- index,
233
- theme,
234
- position
235
- }) => {
236
- const progress = (0, _reactNativeReanimated.useSharedValue)(0);
237
- const translationY = (0, _reactNativeReanimated.useSharedValue)(0);
238
- const isBeingDragged = (0, _reactNativeReanimated.useSharedValue)(false);
239
- const shouldDismiss = (0, _reactNativeReanimated.useSharedValue)(false);
240
-
241
- // Position-based animation values
242
- const isBottom = position === "bottom";
243
- const entryFromY = isBottom ? 80 : -80;
244
- const exitToY = isBottom ? 100 : -100;
245
-
246
- // Stack position animation
247
- const stackIndex = (0, _reactNativeReanimated.useSharedValue)(index);
248
-
249
- // Refs for tracking previous values to avoid unnecessary animations
250
- const lastHandledType = (0, _react.useRef)(toast.type);
251
- const prevIndex = (0, _react.useRef)(index);
252
- const hasEntered = (0, _react.useRef)(false);
253
- (0, _react.useEffect)(() => {
254
- // Entry animation (only once on mount)
255
- if (!hasEntered.current && !toast.isExiting) {
256
- progress.value = (0, _reactNativeReanimated.withTiming)(1, {
257
- duration: Duration,
258
- easing: EASING
259
- });
260
- hasEntered.current = true;
261
- }
262
-
263
- // Exit animation when isExiting becomes true
264
- if (toast.isExiting) {
265
- progress.value = (0, _reactNativeReanimated.withTiming)(0, {
266
- duration: ExitDuration,
267
- easing: EASING
268
- });
269
- translationY.value = (0, _reactNativeReanimated.withTiming)(exitToY, {
270
- duration: ExitDuration,
271
- easing: EASING
272
- });
273
- }
274
-
275
- // Track type changes (for icon animation via key)
276
- if (toast.type !== lastHandledType.current) {
277
- lastHandledType.current = toast.type;
278
- }
279
-
280
- // Stack position animation when index changes
281
- if (index >= 0 && prevIndex.current !== index) {
282
- stackIndex.value = (0, _reactNativeReanimated.withTiming)(index, {
283
- duration: 300,
284
- easing: EASING
285
- });
286
- prevIndex.current = index;
287
- }
288
- }, [toast.isExiting, toast.type, index, progress, translationY, stackIndex, exitToY]);
289
- const dismissToast = (0, _react.useCallback)(() => {
290
- _toastStore.toastStore.hide(toast.id);
291
- }, [toast.id]);
292
- const panGesture = (0, _react.useMemo)(() => _reactNativeGestureHandler.Gesture.Pan().onStart(() => {
293
- "worklet";
294
-
295
- isBeingDragged.value = true;
296
- shouldDismiss.value = false;
297
- }).onUpdate(event => {
298
- "worklet";
299
-
300
- const rawY = event.translationY;
301
- // For top: negative Y = dismiss direction, positive Y = resistance
302
- // For bottom: positive Y = dismiss direction, negative Y = resistance
303
- const dismissDrag = isBottom ? rawY : -rawY;
304
- const resistDrag = isBottom ? -rawY : rawY;
305
- if (dismissDrag > 0) {
306
- // Moving toward dismiss direction
307
- const clampedY = isBottom ? Math.min(rawY, 180) : Math.max(rawY, -180);
308
- translationY.value = clampedY;
309
- if (dismissDrag > 40 || (isBottom ? event.velocityY > 300 : event.velocityY < -300)) {
310
- shouldDismiss.value = true;
311
- }
312
- } else {
313
- // Moving away from edge - apply resistance
314
- const exponentialDrag = MaxDragDown * (1 - Math.exp(-resistDrag / 250));
315
- translationY.value = isBottom ? -Math.min(exponentialDrag, MaxDragDown) : Math.min(exponentialDrag, MaxDragDown);
316
- shouldDismiss.value = false;
317
- }
318
- }).onEnd(() => {
319
- "worklet";
320
-
321
- isBeingDragged.value = false;
322
- if (shouldDismiss.value) {
323
- progress.value = (0, _reactNativeReanimated.withTiming)(0, {
324
- duration: ExitDuration,
325
- easing: EASING
326
- });
327
- const exitOffset = isBottom ? 200 : -200;
328
- translationY.value = (0, _reactNativeReanimated.withTiming)(translationY.value + exitOffset, {
329
- duration: ExitDuration,
330
- easing: EASING
331
- });
332
- (0, _reactNativeWorklets.scheduleOnRN)(dismissToast);
333
- } else {
334
- translationY.value = (0, _reactNativeReanimated.withTiming)(0, {
335
- duration: 650,
336
- easing: EASING
337
- });
338
- }
339
- }), [isBottom, dismissToast, progress, translationY, shouldDismiss, isBeingDragged]);
340
-
341
- // Memoize disabled gesture to avoid recreation on every render
342
- const disabledGesture = (0, _react.useMemo)(() => _reactNativeGestureHandler.Gesture.Pan().enabled(false), []);
343
-
344
- // Derive zIndex separately - it's not animatable and shouldn't trigger worklet re-runs
345
- const zIndex = (0, _reactNativeReanimated.useDerivedValue)(() => 1000 - Math.round(stackIndex.value));
346
- const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
347
- const baseTranslateY = (0, _reactNativeReanimated.interpolate)(progress.value, [0, 1], [entryFromY, ToY]);
348
-
349
- // Stack offset: each toast behind moves away from edge (up for top, down for bottom)
350
- const stackOffsetY = isBottom ? stackIndex.value * 10 : stackIndex.value * -10;
351
-
352
- // Stack scale: each toast behind scales down by 0.05
353
- const stackScale = 1 - stackIndex.value * 0.05;
354
- const finalTranslateY = baseTranslateY + translationY.value + stackOffsetY;
355
- const progressOpacity = (0, _reactNativeReanimated.interpolate)(progress.value, [0, 1], [0, 1]);
356
- // For top: dragging up (negative) fades out. For bottom: dragging down (positive) fades out
357
- const dismissDirection = isBottom ? translationY.value : -translationY.value;
358
- const dragOpacity = dismissDirection > 0 ? (0, _reactNativeReanimated.interpolate)(dismissDirection, [0, 130], [1, 0], "clamp") : 1;
359
- const opacity = progressOpacity * dragOpacity;
360
- const dragScale = (0, _reactNativeReanimated.interpolate)(Math.abs(translationY.value), [0, 50], [1, 0.98], "clamp");
361
- const scale = stackScale * dragScale;
362
- return {
363
- transform: [{
364
- translateY: finalTranslateY
365
- }, {
366
- scale
367
- }],
368
- opacity,
369
- zIndex: zIndex.value
370
- };
371
- });
372
- const accentColor = theme.colors[toast.type].accent;
373
- const backgroundColor = theme.colors[toast.type].background;
374
- const verticalAnchor = isBottom ? {
375
- bottom: 0
376
- } : {
377
- top: 0
378
- };
379
-
380
- // Per-toast overrides from options
381
- const {
382
- options
383
- } = toast;
384
- const customIcon = options?.icon;
385
- const configIcon = theme.icons[toast.type];
386
-
387
- // Resolve dismissible and showCloseButton (per-toast overrides config)
388
- const isDismissible = options?.dismissible ?? theme.dismissible;
389
- const shouldShowCloseButton = toast.type !== "loading" && (options?.showCloseButton ?? theme.showCloseButton);
390
-
391
- // Enable/disable gesture based on dismissible setting
392
- const gesture = isDismissible ? panGesture : disabledGesture;
393
- const animStyle = [styles.toast, verticalAnchor, {
394
- backgroundColor
395
- }, theme.toastStyle, options?.style, animatedStyle];
396
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector, {
397
- gesture: gesture,
398
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
399
- style: animStyle,
400
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ToastContent, {
401
- type: toast.type,
402
- title: toast.title,
403
- description: toast.description,
404
- accentColor: accentColor,
405
- customIcon: customIcon,
406
- configIcon: configIcon,
407
- showCloseButton: shouldShowCloseButton,
408
- onDismiss: dismissToast,
409
- titleStyle: theme.titleStyle,
410
- descriptionStyle: theme.descriptionStyle,
411
- optionsTitleStyle: options?.titleStyle,
412
- optionsDescriptionStyle: options?.descriptionStyle
413
- })
414
- })
415
- });
416
- };
417
-
418
- // Custom comparison to prevent re-renders when toast object reference changes but content is same
419
- const MemoizedToastItem = /*#__PURE__*/(0, _react.memo)(ToastItem, (prev, next) => {
420
- return prev.toast.id === next.toast.id && prev.toast.type === next.toast.type && prev.toast.title === next.toast.title && prev.toast.description === next.toast.description && prev.toast.isExiting === next.toast.isExiting && prev.index === next.index && prev.position === next.position && prev.theme === next.theme;
421
- });
422
- const styles = _reactNative.StyleSheet.create({
423
- container: {
424
- position: "absolute",
425
- left: 16,
426
- right: 16,
427
- zIndex: 1000
428
- },
429
- closeButton: {
430
- padding: 4,
431
- alignItems: "center",
432
- justifyContent: "center"
433
- },
434
- icon: {
435
- width: 48,
436
- height: 48,
437
- alignItems: "center",
438
- justifyContent: "center",
439
- marginLeft: 8
440
- },
441
- content: {
442
- alignItems: "center",
443
- flexDirection: "row",
444
- gap: 12,
445
- minHeight: 36
446
- },
447
- description: {
448
- color: "#6B7280",
449
- fontSize: 12,
450
- fontWeight: "500",
451
- lineHeight: 16
452
- },
453
- textContainer: {
454
- flex: 1,
455
- gap: 1,
456
- justifyContent: "center"
457
- },
458
- title: {
459
- fontSize: 14,
460
- fontWeight: "700",
461
- lineHeight: 20
462
- },
463
- toast: {
464
- borderRadius: 20,
465
- borderCurve: "continuous",
466
- position: "absolute",
467
- left: 0,
468
- right: 0,
469
- paddingHorizontal: 12,
470
- paddingVertical: 10,
471
- shadowColor: "#000",
472
- shadowOffset: {
473
- width: 0,
474
- height: 8
475
- },
476
- shadowOpacity: 0.05,
477
- shadowRadius: 24,
478
- elevation: 8
479
- }
480
- });
481
- //# sourceMappingURL=toast.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ToastContainer=void 0;var e=require("react"),t=require("react-native"),i=require("react-native-gesture-handler"),o=function(e,t){if("function"==typeof WeakMap)var i=new WeakMap,o=new WeakMap;return function(e,t){if(!t&&e&&e.__esModule)return e;var n,s,r={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return r;if(n=t?o:i){if(n.has(e))return n.get(e);n.set(e,r)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((s=(n=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(s.get||s.set)?n(r,t,s):r[t]=e[t]);return r}(e,t)}(require("react-native-reanimated")),n=require("react-native-safe-area-context"),s=require("react-native-worklets"),r=require("./icons/index.js"),a=require("./toast-store.js"),l=require("react/jsx-runtime");const c=28,u=(0,e.memo)(({fill:e})=>(0,l.jsx)(r.GreenCheck,{width:36,height:36,fill:e})),d=(0,e.memo)(({fill:e})=>(0,l.jsx)(r.RedX,{width:c,height:c,fill:e})),p=(0,e.memo)(({fill:e})=>(0,l.jsx)(r.InfoIcon,{width:c,height:c,fill:e})),h=(0,e.memo)(()=>(0,l.jsx)(r.CloseIcon,{width:20,height:20})),f=(0,e.memo)(({type:e,accentColor:i})=>{switch(e){case"success":default:return(0,l.jsx)(u,{fill:i});case"error":return(0,l.jsx)(d,{fill:i});case"loading":return(0,l.jsx)(t.ActivityIndicator,{size:c,color:i});case"info":return(0,l.jsx)(p,{fill:i})}}),g=(e,t,i,o)=>i?"function"==typeof i?i({color:t,size:c}):i:o?o({color:t,size:c}):(0,l.jsx)(f,{type:e,accentColor:t}),m=(0,e.memo)(({type:t,accentColor:i,customIcon:n,configIcon:s})=>{const r=(0,o.useSharedValue)(0);(0,e.useEffect)(()=>{r.value=(0,o.withTiming)(1,{duration:350,easing:o.Easing.out(o.Easing.back(1.5))})},[r]);const a=(0,o.useAnimatedStyle)(()=>({opacity:r.value,transform:[{scale:.7+.3*r.value}]}));return(0,l.jsx)(o.default.View,{style:a,children:g(t,i,n,s)})}),y=(0,e.memo)(({type:e,title:i,description:o,accentColor:n,customIcon:s,configIcon:r,showCloseButton:a,onDismiss:c,titleStyle:u,descriptionStyle:d,optionsTitleStyle:p,optionsDescriptionStyle:f})=>(0,l.jsxs)(t.View,{style:j.content,children:[(0,l.jsx)(t.View,{style:j.icon,children:(0,l.jsx)(m,{type:e,accentColor:n,customIcon:s,configIcon:r},e)}),(0,l.jsxs)(t.View,{style:j.textContainer,children:[(0,l.jsx)(t.Text,{maxFontSizeMultiplier:1.35,allowFontScaling:!1,style:[j.title,{color:n},u,p],children:i}),o&&(0,l.jsx)(t.Text,{allowFontScaling:!1,maxFontSizeMultiplier:1.35,style:[j.description,d,f],children:o})]}),a&&(0,l.jsx)(t.Pressable,{style:j.closeButton,onPress:c,hitSlop:12,children:(0,l.jsx)(h,{})})]}));exports.ToastContainer=()=>{const[i,o]=(0,e.useState)([]),[s,r]=(0,e.useState)(()=>a.toastStore.getTheme()),{top:c,bottom:u}=(0,n.useSafeAreaInsets)();(0,e.useEffect)(()=>{const e=a.toastStore.getState();return o(e.visibleToasts),r(a.toastStore.getTheme()),a.toastStore.subscribe(e=>{o(e.visibleToasts),r(a.toastStore.getTheme())})},[]);const d=(0,e.useCallback)(e=>{let t=0;for(const o of i){if(o.id===e)break;o.isExiting||t++}return t},[i]),p=(0,e.useMemo)(()=>[...i].reverse(),[i]);if(0===i.length)return null;const h="bottom"===s.position,f=h?u:c,g=h?{bottom:f+s.offset+2}:{top:f+s.offset+2};return(0,l.jsx)(t.View,{style:[j.container,g],pointerEvents:"box-none",children:p.map(e=>{const t=e.isExiting?-1:d(e.id);return(0,l.jsx)(w,{toast:e,index:t,theme:s,position:s.position},e.id)})})};const x=o.Easing.bezier(.25,.1,.25,1),v=350,S=({toast:t,index:n,theme:r,position:c})=>{const u=(0,o.useSharedValue)(0),d=(0,o.useSharedValue)(0),p=(0,o.useSharedValue)(!1),h=(0,o.useSharedValue)(!1),f="bottom"===c,g=f?80:-80,m=f?100:-100,S=(0,o.useSharedValue)(n),w=(0,e.useRef)(t.type),b=(0,e.useRef)(n),C=(0,e.useRef)(!1);(0,e.useEffect)(()=>{C.current||t.isExiting||(u.value=(0,o.withTiming)(1,{duration:400,easing:x}),C.current=!0),t.isExiting&&(u.value=(0,o.withTiming)(0,{duration:v,easing:x}),d.value=(0,o.withTiming)(m,{duration:v,easing:x})),t.type!==w.current&&(w.current=t.type),n>=0&&b.current!==n&&(S.value=(0,o.withTiming)(n,{duration:300,easing:x}),b.current=n)},[t.isExiting,t.type,n,u,d,S,m]);const T=(0,e.useCallback)(()=>{a.toastStore.hide(t.id)},[t.id]),I=(0,e.useMemo)(()=>i.Gesture.Pan().onStart(()=>{"worklet";p.value=!0,h.value=!1}).onUpdate(e=>{"worklet";const t=e.translationY,i=f?t:-t,o=f?-t:t;if(i>0){const o=f?Math.min(t,180):Math.max(t,-180);d.value=o,(i>40||(f?e.velocityY>300:e.velocityY<-300))&&(h.value=!0)}else{const e=60*(1-Math.exp(-o/250));d.value=f?-Math.min(e,60):Math.min(e,60),h.value=!1}}).onEnd(()=>{"worklet";if(p.value=!1,h.value){u.value=(0,o.withTiming)(0,{duration:v,easing:x});const e=f?200:-200;d.value=(0,o.withTiming)(d.value+e,{duration:v,easing:x}),(0,s.scheduleOnRN)(T)}else d.value=(0,o.withTiming)(0,{duration:650,easing:x})}),[f,T,u,d,h,p]),M=(0,e.useMemo)(()=>i.Gesture.Pan().enabled(!1),[]),E=(0,o.useDerivedValue)(()=>1e3-Math.round(S.value)),k=(0,o.useAnimatedStyle)(()=>{const e=(0,o.interpolate)(u.value,[0,1],[g,0]),t=f?10*S.value:-10*S.value,i=1-.05*S.value,n=e+d.value+t,s=(0,o.interpolate)(u.value,[0,1],[0,1]),r=f?d.value:-d.value,a=s*(r>0?(0,o.interpolate)(r,[0,130],[1,0],"clamp"):1);return{transform:[{translateY:n},{scale:i*(0,o.interpolate)(Math.abs(d.value),[0,50],[1,.98],"clamp")}],opacity:a,zIndex:E.value}}),V=r.colors[t.type].accent,z=r.colors[t.type].background,q=f?{bottom:0}:{top:0},{options:D}=t,O=D?.icon,P=r.icons[t.type],_=D?.dismissible??r.dismissible,B="loading"!==t.type&&(D?.showCloseButton??r.showCloseButton),R=_?I:M,W=[j.toast,q,{backgroundColor:z},r.toastStyle,D?.style,k];return(0,l.jsx)(i.GestureDetector,{gesture:R,children:(0,l.jsx)(o.default.View,{style:W,children:(0,l.jsx)(y,{type:t.type,title:t.title,description:t.description,accentColor:V,customIcon:O,configIcon:P,showCloseButton:B,onDismiss:T,titleStyle:r.titleStyle,descriptionStyle:r.descriptionStyle,optionsTitleStyle:D?.titleStyle,optionsDescriptionStyle:D?.descriptionStyle})})})},w=(0,e.memo)(S,(e,t)=>e.toast.id===t.toast.id&&e.toast.type===t.toast.type&&e.toast.title===t.toast.title&&e.toast.description===t.toast.description&&e.toast.isExiting===t.toast.isExiting&&e.index===t.index&&e.position===t.position&&e.theme===t.theme),j=t.StyleSheet.create({container:{position:"absolute",left:16,right:16,zIndex:1e3},closeButton:{padding:4,alignItems:"center",justifyContent:"center"},icon:{width:48,height:48,alignItems:"center",justifyContent:"center",marginLeft:8},content:{alignItems:"center",flexDirection:"row",gap:12,minHeight:36},description:{color:"#6B7280",fontSize:12,fontWeight:"500",lineHeight:16},textContainer:{flex:1,gap:1,justifyContent:"center"},title:{fontSize:14,fontWeight:"700",lineHeight:20},toast:{borderRadius:20,borderCurve:"continuous",position:"absolute",left:0,right:0,paddingHorizontal:12,paddingVertical:10,shadowColor:"#000",shadowOffset:{width:0,height:8},shadowOpacity:.05,shadowRadius:24,elevation:8}});
@@ -1,6 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- //# sourceMappingURL=types.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -1,16 +1 @@
1
- "use strict";
2
-
3
- import Svg, { Path } from "react-native-svg";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- export const CloseIcon = props => /*#__PURE__*/_jsx(Svg, {
6
- viewBox: "0 0 24 24",
7
- width: 24,
8
- height: 24,
9
- fill: "none",
10
- ...props,
11
- children: /*#__PURE__*/_jsx(Path, {
12
- fill: props.fill ?? "#8993A4",
13
- d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"
14
- })
15
- });
16
- //# sourceMappingURL=CloseIcon.js.map
1
+ "use strict";import i,{Path as t}from"react-native-svg";import{jsx as e}from"react/jsx-runtime";export const CloseIcon=o=>e(i,{viewBox:"0 0 24 24",width:24,height:24,fill:"none",...o,children:e(t,{fill:o.fill??"#8993A4",d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"})});
@@ -1,21 +1 @@
1
- "use strict";
2
-
3
- import Svg, { Path } from "react-native-svg";
4
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
- export const GreenCheck = props => /*#__PURE__*/_jsxs(Svg, {
6
- viewBox: "0 0 30 31",
7
- width: 30,
8
- height: 31,
9
- fill: "none",
10
- ...props,
11
- children: [/*#__PURE__*/_jsx(Path, {
12
- fill: props.fill ?? "#28B770",
13
- fillRule: "evenodd",
14
- d: "m19.866 13.152-5.772 5.773a.933.933 0 0 1-1.326 0L9.88 16.039a.938.938 0 0 1 1.325-1.327l2.225 2.224 5.109-5.11a.938.938 0 1 1 1.326 1.326Zm.28-9.652H9.602C5.654 3.5 3 6.276 3 10.409v9.935c0 4.131 2.654 6.906 6.602 6.906h10.543c3.95 0 6.605-2.775 6.605-6.906v-9.935c0-4.133-2.654-6.909-6.604-6.909Z",
15
- clipRule: "evenodd"
16
- }), /*#__PURE__*/_jsx(Path, {
17
- fill: "#fff",
18
- d: "m19.866 13.152-5.772 5.773a.933.933 0 0 1-1.326 0L9.88 16.039a.938.938 0 0 1 1.325-1.327l2.225 2.224 5.109-5.11a.938.938 0 1 1 1.326 1.326Z"
19
- })]
20
- });
21
- //# sourceMappingURL=GreenCheck.js.map
1
+ "use strict";import e,{Path as l}from"react-native-svg";import{jsx as i,jsxs as t}from"react/jsx-runtime";export const GreenCheck=a=>t(e,{viewBox:"0 0 30 31",width:30,height:31,fill:"none",...a,children:[i(l,{fill:a.fill??"#28B770",fillRule:"evenodd",d:"m19.866 13.152-5.772 5.773a.933.933 0 0 1-1.326 0L9.88 16.039a.938.938 0 0 1 1.325-1.327l2.225 2.224 5.109-5.11a.938.938 0 1 1 1.326 1.326Zm.28-9.652H9.602C5.654 3.5 3 6.276 3 10.409v9.935c0 4.131 2.654 6.906 6.602 6.906h10.543c3.95 0 6.605-2.775 6.605-6.906v-9.935c0-4.133-2.654-6.909-6.604-6.909Z",clipRule:"evenodd"}),i(l,{fill:"#fff",d:"m19.866 13.152-5.772 5.773a.933.933 0 0 1-1.326 0L9.88 16.039a.938.938 0 0 1 1.325-1.327l2.225 2.224 5.109-5.11a.938.938 0 1 1 1.326 1.326Z"})]});
@@ -1,18 +1 @@
1
- "use strict";
2
-
3
- import Svg, { Path } from "react-native-svg";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- export const InfoIcon = props => /*#__PURE__*/_jsx(Svg, {
6
- viewBox: "0 0 24 24",
7
- width: 24,
8
- height: 24,
9
- fill: "none",
10
- ...props,
11
- children: /*#__PURE__*/_jsx(Path, {
12
- fill: props.fill ?? "#EDBE43",
13
- fillRule: "evenodd",
14
- d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm1 15h-2v-6h2v6Zm0-8h-2V7h2v2Z",
15
- clipRule: "evenodd"
16
- })
17
- });
18
- //# sourceMappingURL=InfoIcon.js.map
1
+ "use strict";import e,{Path as i}from"react-native-svg";import{jsx as l}from"react/jsx-runtime";export const InfoIcon=o=>l(e,{viewBox:"0 0 24 24",width:24,height:24,fill:"none",...o,children:l(i,{fill:o.fill??"#EDBE43",fillRule:"evenodd",d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm1 15h-2v-6h2v6Zm0-8h-2V7h2v2Z",clipRule:"evenodd"})});
@@ -1,21 +1 @@
1
- "use strict";
2
-
3
- import Svg, { Path } from "react-native-svg";
4
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
- export const RedX = props => /*#__PURE__*/_jsxs(Svg, {
6
- viewBox: "0 0 24 24",
7
- width: 24,
8
- height: 24,
9
- fill: "none",
10
- ...props,
11
- children: [/*#__PURE__*/_jsx(Path, {
12
- fill: props.fill ?? "#F05964",
13
- fillRule: "evenodd",
14
- d: "M15.58 15.572a.935.935 0 0 1-1.326 0l-2.258-2.258-2.251 2.252a.938.938 0 0 1-1.326-1.325l2.251-2.252-2.252-2.254A.936.936 0 1 1 9.742 8.41l2.253 2.252 2.252-2.25a.939.939 0 0 1 1.325 1.325l-2.25 2.252 2.257 2.257a.938.938 0 0 1 0 1.326ZM17.271.126H6.727C2.777.125.125 2.9.125 7.032v9.936c0 4.13 2.652 6.907 6.603 6.907H17.27c3.95 0 6.605-2.776 6.605-6.907V7.032c0-4.132-2.654-6.907-6.604-6.907Z",
15
- clipRule: "evenodd"
16
- }), /*#__PURE__*/_jsx(Path, {
17
- fill: "#fff",
18
- d: "M15.58 15.572a.935.935 0 0 1-1.326 0l-2.258-2.258-2.251 2.252a.938.938 0 0 1-1.326-1.325l2.251-2.252-2.252-2.254A.936.936 0 1 1 9.742 8.41l2.253 2.252 2.252-2.25a.939.939 0 0 1 1.325 1.325l-2.25 2.252 2.257 2.257a.938.938 0 0 1 0 1.326Z"
19
- })]
20
- });
21
- //# sourceMappingURL=RedX.js.map
1
+ "use strict";import l,{Path as e}from"react-native-svg";import{jsx as i,jsxs as a}from"react/jsx-runtime";export const RedX=t=>a(l,{viewBox:"0 0 24 24",width:24,height:24,fill:"none",...t,children:[i(e,{fill:t.fill??"#F05964",fillRule:"evenodd",d:"M15.58 15.572a.935.935 0 0 1-1.326 0l-2.258-2.258-2.251 2.252a.938.938 0 0 1-1.326-1.325l2.251-2.252-2.252-2.254A.936.936 0 1 1 9.742 8.41l2.253 2.252 2.252-2.25a.939.939 0 0 1 1.325 1.325l-2.25 2.252 2.257 2.257a.938.938 0 0 1 0 1.326ZM17.271.126H6.727C2.777.125.125 2.9.125 7.032v9.936c0 4.13 2.652 6.907 6.603 6.907H17.27c3.95 0 6.605-2.776 6.605-6.907V7.032c0-4.132-2.654-6.907-6.604-6.907Z",clipRule:"evenodd"}),i(e,{fill:"#fff",d:"M15.58 15.572a.935.935 0 0 1-1.326 0l-2.258-2.258-2.251 2.252a.938.938 0 0 1-1.326-1.325l2.251-2.252-2.252-2.254A.936.936 0 1 1 9.742 8.41l2.253 2.252 2.252-2.25a.939.939 0 0 1 1.325 1.325l-2.25 2.252 2.257 2.257a.938.938 0 0 1 0 1.326Z"})]});
@@ -1,7 +1 @@
1
- "use strict";
2
-
3
- export { CloseIcon } from "./CloseIcon.js";
4
- export { GreenCheck } from "./GreenCheck.js";
5
- export { InfoIcon } from "./InfoIcon.js";
6
- export { RedX } from "./RedX.js";
7
- //# sourceMappingURL=index.js.map
1
+ "use strict";export{CloseIcon}from"./CloseIcon.js";export{GreenCheck}from"./GreenCheck.js";export{InfoIcon}from"./InfoIcon.js";export{RedX}from"./RedX.js";
@@ -1,14 +1 @@
1
- "use strict";
2
-
3
- // Main exports
4
-
5
- // Icons (for customization)
6
- export { CloseIcon, GreenCheck, InfoIcon, RedX } from "./icons/index.js";
7
- export { ToastContainer } from "./toast.js";
8
- export { toast } from "./toast-api.js";
9
- export { BreadLoaf } from "./toast-provider.js";
10
-
11
- // Store (for advanced usage)
12
- export { toastStore } from "./toast-store.js";
13
- // Types
14
- //# sourceMappingURL=index.js.map
1
+ "use strict";export{CloseIcon,GreenCheck,InfoIcon,RedX}from"./icons/index.js";export{ToastContainer}from"./toast.js";export{toast}from"./toast-api.js";export{BreadLoaf}from"./toast-provider.js";export{toastStore}from"./toast-store.js";