react-native-bread 0.1.0 → 0.1.2

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 (69) hide show
  1. package/README.md +102 -84
  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 -71
  10. package/lib/commonjs/toast-store.js +1 -278
  11. package/lib/commonjs/toast.js +1 -445
  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 -67
  21. package/lib/module/toast-store.js +1 -274
  22. package/lib/module/toast.js +1 -439
  23. package/lib/module/types.js +1 -4
  24. package/lib/typescript/toast-provider.d.ts +13 -12
  25. package/package.json +7 -6
  26. package/lib/commonjs/icons/CloseIcon.js.map +0 -1
  27. package/lib/commonjs/icons/GreenCheck.js.map +0 -1
  28. package/lib/commonjs/icons/InfoIcon.js.map +0 -1
  29. package/lib/commonjs/icons/RedX.js.map +0 -1
  30. package/lib/commonjs/icons/index.js.map +0 -1
  31. package/lib/commonjs/index.js.map +0 -1
  32. package/lib/commonjs/toast-api.js.map +0 -1
  33. package/lib/commonjs/toast-provider.js.map +0 -1
  34. package/lib/commonjs/toast-store.js.map +0 -1
  35. package/lib/commonjs/toast.js.map +0 -1
  36. package/lib/commonjs/types.js.map +0 -1
  37. package/lib/module/icons/CloseIcon.js.map +0 -1
  38. package/lib/module/icons/GreenCheck.js.map +0 -1
  39. package/lib/module/icons/InfoIcon.js.map +0 -1
  40. package/lib/module/icons/RedX.js.map +0 -1
  41. package/lib/module/icons/index.js.map +0 -1
  42. package/lib/module/index.js.map +0 -1
  43. package/lib/module/toast-api.js.map +0 -1
  44. package/lib/module/toast-provider.js.map +0 -1
  45. package/lib/module/toast-store.js.map +0 -1
  46. package/lib/module/toast.js.map +0 -1
  47. package/lib/module/types.js.map +0 -1
  48. package/lib/typescript/icons/CloseIcon.d.ts.map +0 -1
  49. package/lib/typescript/icons/GreenCheck.d.ts.map +0 -1
  50. package/lib/typescript/icons/InfoIcon.d.ts.map +0 -1
  51. package/lib/typescript/icons/RedX.d.ts.map +0 -1
  52. package/lib/typescript/icons/index.d.ts.map +0 -1
  53. package/lib/typescript/index.d.ts.map +0 -1
  54. package/lib/typescript/toast-api.d.ts.map +0 -1
  55. package/lib/typescript/toast-provider.d.ts.map +0 -1
  56. package/lib/typescript/toast-store.d.ts.map +0 -1
  57. package/lib/typescript/toast.d.ts.map +0 -1
  58. package/lib/typescript/types.d.ts.map +0 -1
  59. package/src/icons/CloseIcon.tsx +0 -10
  60. package/src/icons/GreenCheck.tsx +0 -16
  61. package/src/icons/InfoIcon.tsx +0 -12
  62. package/src/icons/RedX.tsx +0 -16
  63. package/src/icons/index.ts +0 -4
  64. package/src/index.ts +0 -26
  65. package/src/toast-api.ts +0 -213
  66. package/src/toast-provider.tsx +0 -81
  67. package/src/toast-store.ts +0 -270
  68. package/src/toast.tsx +0 -417
  69. package/src/types.ts +0 -121
@@ -1,445 +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
- /** Default icon for each toast type */
20
- const DefaultIcon = ({
21
- type,
22
- accentColor
23
- }) => {
24
- switch (type) {
25
- case "success":
26
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.GreenCheck, {
27
- width: 36,
28
- height: 36,
29
- fill: accentColor
30
- });
31
- case "error":
32
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.RedX, {
33
- width: ICON_SIZE,
34
- height: ICON_SIZE,
35
- fill: accentColor
36
- });
37
- case "loading":
38
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
39
- size: ICON_SIZE,
40
- color: accentColor
41
- });
42
- case "info":
43
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.InfoIcon, {
44
- width: ICON_SIZE,
45
- height: ICON_SIZE,
46
- fill: accentColor
47
- });
48
- default:
49
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.GreenCheck, {
50
- width: 36,
51
- height: 36,
52
- fill: accentColor
53
- });
54
- }
55
- };
56
-
57
- /** Resolves the icon to render - checks per-toast, then config, then default */
58
- const resolveIcon = (type, accentColor, customIcon, configIcon) => {
59
- // Per-toast custom icon takes priority
60
- if (customIcon) {
61
- if (typeof customIcon === "function") {
62
- return customIcon({
63
- color: accentColor,
64
- size: ICON_SIZE
65
- });
66
- }
67
- return customIcon;
68
- }
69
-
70
- // Config-level custom icon
71
- if (configIcon) {
72
- return configIcon({
73
- color: accentColor,
74
- size: ICON_SIZE
75
- });
76
- }
77
-
78
- // Default icon
79
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(DefaultIcon, {
80
- type: type,
81
- accentColor: accentColor
82
- });
83
- };
84
- const AnimatedIcon = ({
85
- type,
86
- accentColor,
87
- customIcon,
88
- configIcon
89
- }) => {
90
- const progress = (0, _reactNativeReanimated.useSharedValue)(0);
91
- (0, _react.useEffect)(() => {
92
- progress.value = (0, _reactNativeReanimated.withTiming)(1, {
93
- duration: 350,
94
- easing: _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.back(1.5))
95
- });
96
- }, [progress]);
97
- const style = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
98
- opacity: progress.value,
99
- transform: [{
100
- scale: 0.7 + progress.value * 0.3
101
- }]
102
- }));
103
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
104
- style: style,
105
- children: resolveIcon(type, accentColor, customIcon, configIcon)
106
- });
107
- };
108
-
109
- // singleton instance
110
- const ToastContainer = () => {
111
- const [visibleToasts, setVisibleToasts] = (0, _react.useState)([]);
112
- const [theme, setTheme] = (0, _react.useState)(() => _toastStore.toastStore.getTheme());
113
- const {
114
- top,
115
- bottom
116
- } = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
117
- (0, _react.useEffect)(() => {
118
- const initialState = _toastStore.toastStore.getState();
119
- setVisibleToasts(initialState.visibleToasts);
120
- setTheme(_toastStore.toastStore.getTheme());
121
- return _toastStore.toastStore.subscribe(state => {
122
- setVisibleToasts(state.visibleToasts);
123
- setTheme(_toastStore.toastStore.getTheme());
124
- });
125
- }, []);
126
-
127
- // Calculate visual index for each toast (exiting toasts don't count)
128
- const getVisualIndex = (0, _react.useCallback)(toastId => {
129
- let visualIndex = 0;
130
- for (const t of visibleToasts) {
131
- if (t.id === toastId) break;
132
- if (!t.isExiting) visualIndex++;
133
- }
134
- return visualIndex;
135
- }, [visibleToasts]);
136
-
137
- // Memoize the reversed array to avoid recreating on each render
138
- const reversedToasts = (0, _react.useMemo)(() => [...visibleToasts].reverse(), [visibleToasts]);
139
- if (visibleToasts.length === 0) {
140
- return null;
141
- }
142
- const isBottom = theme.position === "bottom";
143
- const inset = isBottom ? bottom : top;
144
- const positionStyle = isBottom ? {
145
- bottom: inset + theme.offset + 2
146
- } : {
147
- top: inset + theme.offset + 2
148
- };
149
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
150
- style: [styles.container, positionStyle],
151
- pointerEvents: "box-none",
152
- children: reversedToasts.map(toast => {
153
- const index = toast.isExiting ? -1 : getVisualIndex(toast.id);
154
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(MemoizedToastItem, {
155
- toast: toast,
156
- index: index,
157
- theme: theme,
158
- position: theme.position
159
- }, toast.id);
160
- })
161
- });
162
- };
163
- exports.ToastContainer = ToastContainer;
164
- const EASING = _reactNativeReanimated.Easing.bezier(0.25, 0.1, 0.25, 1.0);
165
- const ToY = 0;
166
- const Duration = 400;
167
- const ExitDuration = 350;
168
- const MaxDragDown = 60;
169
- const ToastItem = ({
170
- toast,
171
- index,
172
- theme,
173
- position
174
- }) => {
175
- const progress = (0, _reactNativeReanimated.useSharedValue)(0);
176
- const translationY = (0, _reactNativeReanimated.useSharedValue)(0);
177
- const isBeingDragged = (0, _reactNativeReanimated.useSharedValue)(false);
178
- const shouldDismiss = (0, _reactNativeReanimated.useSharedValue)(false);
179
-
180
- // Position-based animation values
181
- const isBottom = position === "bottom";
182
- const entryFromY = isBottom ? 80 : -80;
183
- const exitToY = isBottom ? 100 : -100;
184
-
185
- // Stack position animation
186
- const stackIndex = (0, _reactNativeReanimated.useSharedValue)(index);
187
-
188
- // Title color animation on variant change
189
- const colorProgress = (0, _reactNativeReanimated.useSharedValue)(1);
190
- const fromColor = (0, _reactNativeReanimated.useSharedValue)(theme.colors[toast.type].accent);
191
- const toColor = (0, _reactNativeReanimated.useSharedValue)(theme.colors[toast.type].accent);
192
-
193
- // Refs for tracking previous values to avoid unnecessary animations
194
- const lastHandledType = (0, _react.useRef)(toast.type);
195
- const prevIndex = (0, _react.useRef)(index);
196
- const hasEntered = (0, _react.useRef)(false);
197
-
198
- // Combined animation effect for entry, exit, color transitions, and stack position
199
- (0, _react.useEffect)(() => {
200
- // Entry animation (only once on mount)
201
- if (!hasEntered.current && !toast.isExiting) {
202
- progress.value = (0, _reactNativeReanimated.withTiming)(1, {
203
- duration: Duration,
204
- easing: EASING
205
- });
206
- hasEntered.current = true;
207
- }
208
-
209
- // Exit animation when isExiting becomes true
210
- if (toast.isExiting) {
211
- progress.value = (0, _reactNativeReanimated.withTiming)(0, {
212
- duration: ExitDuration,
213
- easing: EASING
214
- });
215
- translationY.value = (0, _reactNativeReanimated.withTiming)(exitToY, {
216
- duration: ExitDuration,
217
- easing: EASING
218
- });
219
- }
220
-
221
- // Color transition when type changes
222
- if (toast.type !== lastHandledType.current) {
223
- fromColor.value = theme.colors[lastHandledType.current].accent;
224
- toColor.value = theme.colors[toast.type].accent;
225
- lastHandledType.current = toast.type;
226
- colorProgress.value = 0;
227
- colorProgress.value = (0, _reactNativeReanimated.withTiming)(1, {
228
- duration: 300,
229
- easing: EASING
230
- });
231
- }
232
-
233
- // Stack position animation when index changes
234
- if (index >= 0 && prevIndex.current !== index) {
235
- stackIndex.value = (0, _reactNativeReanimated.withTiming)(index, {
236
- duration: 300,
237
- easing: EASING
238
- });
239
- prevIndex.current = index;
240
- }
241
- }, [toast.isExiting, toast.type, index, progress, translationY, fromColor, toColor, colorProgress, stackIndex, exitToY, theme.colors]);
242
- const titleColorStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
243
- color: (0, _reactNativeReanimated.interpolateColor)(colorProgress.value, [0, 1], [fromColor.value, toColor.value])
244
- }));
245
- const dismissToast = (0, _react.useCallback)(() => {
246
- _toastStore.toastStore.hide(toast.id);
247
- }, [toast.id]);
248
- const panGesture = _reactNativeGestureHandler.Gesture.Pan().onStart(() => {
249
- "worklet";
250
-
251
- isBeingDragged.value = true;
252
- shouldDismiss.value = false;
253
- }).onUpdate(event => {
254
- "worklet";
255
-
256
- const rawY = event.translationY;
257
- // For top: negative Y = dismiss direction, positive Y = resistance
258
- // For bottom: positive Y = dismiss direction, negative Y = resistance
259
- const dismissDrag = isBottom ? rawY : -rawY;
260
- const resistDrag = isBottom ? -rawY : rawY;
261
- if (dismissDrag > 0) {
262
- // Moving toward dismiss direction
263
- const clampedY = isBottom ? Math.min(rawY, 180) : Math.max(rawY, -180);
264
- translationY.value = clampedY;
265
- if (dismissDrag > 40 || (isBottom ? event.velocityY > 300 : event.velocityY < -300)) {
266
- shouldDismiss.value = true;
267
- }
268
- } else {
269
- // Moving away from edge - apply resistance
270
- const exponentialDrag = MaxDragDown * (1 - Math.exp(-resistDrag / 250));
271
- translationY.value = isBottom ? -Math.min(exponentialDrag, MaxDragDown) : Math.min(exponentialDrag, MaxDragDown);
272
- shouldDismiss.value = false;
273
- }
274
- }).onEnd(() => {
275
- "worklet";
276
-
277
- isBeingDragged.value = false;
278
- if (shouldDismiss.value) {
279
- progress.value = (0, _reactNativeReanimated.withTiming)(0, {
280
- duration: ExitDuration,
281
- easing: EASING
282
- });
283
- const exitOffset = isBottom ? 200 : -200;
284
- translationY.value = (0, _reactNativeReanimated.withTiming)(translationY.value + exitOffset, {
285
- duration: ExitDuration,
286
- easing: EASING
287
- });
288
- (0, _reactNativeWorklets.scheduleOnRN)(dismissToast);
289
- } else {
290
- translationY.value = (0, _reactNativeReanimated.withTiming)(0, {
291
- duration: 650,
292
- easing: EASING
293
- });
294
- }
295
- });
296
- const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
297
- const baseTranslateY = (0, _reactNativeReanimated.interpolate)(progress.value, [0, 1], [entryFromY, ToY]);
298
-
299
- // Stack offset: each toast behind moves away from edge (up for top, down for bottom)
300
- const stackOffsetY = isBottom ? stackIndex.value * 10 : stackIndex.value * -10;
301
-
302
- // Stack scale: each toast behind scales down by 0.05
303
- const stackScale = 1 - stackIndex.value * 0.05;
304
- const finalTranslateY = baseTranslateY + translationY.value + stackOffsetY;
305
- const progressOpacity = (0, _reactNativeReanimated.interpolate)(progress.value, [0, 1], [0, 1]);
306
- // For top: dragging up (negative) fades out. For bottom: dragging down (positive) fades out
307
- const dismissDirection = isBottom ? translationY.value : -translationY.value;
308
- const dragOpacity = dismissDirection > 0 ? (0, _reactNativeReanimated.interpolate)(dismissDirection, [0, 130], [1, 0], "clamp") : 1;
309
- const opacity = progressOpacity * dragOpacity;
310
- const dragScale = (0, _reactNativeReanimated.interpolate)(Math.abs(translationY.value), [0, 50], [1, 0.98], "clamp");
311
- const scale = stackScale * dragScale;
312
- return {
313
- transform: [{
314
- translateY: finalTranslateY
315
- }, {
316
- scale
317
- }],
318
- opacity,
319
- zIndex: 1000 - stackIndex.value
320
- };
321
- });
322
- const accentColor = theme.colors[toast.type].accent;
323
- const backgroundColor = theme.colors[toast.type].background;
324
- const verticalAnchor = isBottom ? {
325
- bottom: 0
326
- } : {
327
- top: 0
328
- };
329
-
330
- // Per-toast overrides from options
331
- const {
332
- options
333
- } = toast;
334
- const customIcon = options?.icon;
335
- const configIcon = theme.icons[toast.type];
336
-
337
- // Resolve dismissible and showCloseButton (per-toast overrides config)
338
- const isDismissible = options?.dismissible ?? theme.dismissible;
339
- const shouldShowCloseButton = toast.type !== "loading" && (options?.showCloseButton ?? theme.showCloseButton);
340
-
341
- // Enable/disable gesture based on dismissible setting
342
- const gesture = isDismissible ? panGesture : _reactNativeGestureHandler.Gesture.Pan().enabled(false);
343
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector, {
344
- gesture: gesture,
345
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
346
- style: [styles.toast, verticalAnchor, {
347
- backgroundColor
348
- }, theme.toastStyle, options?.style, animatedStyle],
349
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
350
- style: styles.content,
351
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
352
- style: styles.icon,
353
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedIcon, {
354
- type: toast.type,
355
- accentColor: accentColor,
356
- customIcon: customIcon,
357
- configIcon: configIcon
358
- }, toast.type)
359
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
360
- style: styles.textContainer,
361
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.Text, {
362
- maxFontSizeMultiplier: 1.35,
363
- allowFontScaling: false,
364
- style: [styles.title, theme.titleStyle, options?.titleStyle, titleColorStyle],
365
- children: toast.title
366
- }), toast.description && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
367
- allowFontScaling: false,
368
- maxFontSizeMultiplier: 1.35,
369
- style: [styles.description, theme.descriptionStyle, options?.descriptionStyle],
370
- children: toast.description
371
- })]
372
- }), shouldShowCloseButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
373
- style: styles.closeButton,
374
- onPress: dismissToast,
375
- hitSlop: 12,
376
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.CloseIcon, {
377
- width: 20,
378
- height: 20
379
- })
380
- })]
381
- })
382
- })
383
- });
384
- };
385
- const MemoizedToastItem = /*#__PURE__*/(0, _react.memo)(ToastItem);
386
- const styles = _reactNative.StyleSheet.create({
387
- container: {
388
- position: "absolute",
389
- left: 16,
390
- right: 16,
391
- zIndex: 1000
392
- },
393
- closeButton: {
394
- padding: 4,
395
- alignItems: "center",
396
- justifyContent: "center"
397
- },
398
- icon: {
399
- width: 48,
400
- height: 48,
401
- alignItems: "center",
402
- justifyContent: "center",
403
- marginLeft: 8
404
- },
405
- content: {
406
- alignItems: "center",
407
- flexDirection: "row",
408
- gap: 12,
409
- minHeight: 36
410
- },
411
- description: {
412
- color: "#6B7280",
413
- fontSize: 12,
414
- fontWeight: "500",
415
- lineHeight: 16
416
- },
417
- textContainer: {
418
- flex: 1,
419
- gap: 1,
420
- justifyContent: "center"
421
- },
422
- title: {
423
- fontSize: 14,
424
- fontWeight: "700",
425
- lineHeight: 20
426
- },
427
- toast: {
428
- borderRadius: 20,
429
- borderCurve: "continuous",
430
- position: "absolute",
431
- left: 0,
432
- right: 0,
433
- paddingHorizontal: 12,
434
- paddingVertical: 10,
435
- shadowColor: "#000",
436
- shadowOffset: {
437
- width: 0,
438
- height: 8
439
- },
440
- shadowOpacity: 0.05,
441
- shadowRadius: 24,
442
- elevation: 8
443
- }
444
- });
445
- //# 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";