react-native-bread 0.1.1 → 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 (68) hide show
  1. package/README.md +2 -1
  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
package/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # React Native Bread 🍞
2
2
 
3
- An opinionated toast component for React Native. Inspired by @emilkowalski's Sonner, built for mobile with smooth 60fps animations and intuitive swipe gestures.
3
+ An opinionated toast component for React Native. Inspired by @emilkowalski's Sonner, built for mobile with smooth 60fps animations and intuitive swipe gestures. Extremely lightweight.
4
4
 
5
5
  https://github.com/user-attachments/assets/8a862dba-422c-4573-9f12-0a36cf6efe49
6
6
 
7
7
  ## Features
8
8
 
9
+ - **Extremely lightweight** package, only 13.8KB packed size
9
10
  - Clean, imperative API inspired by [Sonner](https://sonner.emilkowal.ski/)
10
11
  - Zero setup - add one component, start toasting. No hooks, no providers
11
12
  - Built for mobile with smooth 60fps animations via Reanimated 3
@@ -1,22 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CloseIcon = void 0;
7
- var _reactNativeSvg = _interopRequireWildcard(require("react-native-svg"));
8
- var _jsxRuntime = require("react/jsx-runtime");
9
- 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); }
10
- const CloseIcon = props => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.default, {
11
- viewBox: "0 0 24 24",
12
- width: 24,
13
- height: 24,
14
- fill: "none",
15
- ...props,
16
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Path, {
17
- fill: props.fill ?? "#8993A4",
18
- 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"
19
- })
20
- });
21
- exports.CloseIcon = CloseIcon;
22
- //# sourceMappingURL=CloseIcon.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CloseIcon=void 0;var e=function(e,t){if("function"==typeof WeakMap)var r=new WeakMap,n=new WeakMap;return 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)}(require("react-native-svg")),t=require("react/jsx-runtime");exports.CloseIcon=r=>(0,t.jsx)(e.default,{viewBox:"0 0 24 24",width:24,height:24,fill:"none",...r,children:(0,t.jsx)(e.Path,{fill:r.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,27 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.GreenCheck = void 0;
7
- var _reactNativeSvg = _interopRequireWildcard(require("react-native-svg"));
8
- var _jsxRuntime = require("react/jsx-runtime");
9
- 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); }
10
- const GreenCheck = props => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.default, {
11
- viewBox: "0 0 30 31",
12
- width: 30,
13
- height: 31,
14
- fill: "none",
15
- ...props,
16
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Path, {
17
- fill: props.fill ?? "#28B770",
18
- fillRule: "evenodd",
19
- 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",
20
- clipRule: "evenodd"
21
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Path, {
22
- fill: "#fff",
23
- 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"
24
- })]
25
- });
26
- exports.GreenCheck = GreenCheck;
27
- //# sourceMappingURL=GreenCheck.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GreenCheck=void 0;var e=function(e,t){if("function"==typeof WeakMap)var r=new WeakMap,n=new WeakMap;return function(e,t){if(!t&&e&&e.__esModule)return e;var i,l,a={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return a;if(i=t?n:r){if(i.has(e))return i.get(e);i.set(e,a)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((l=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(l.get||l.set)?i(a,t,l):a[t]=e[t]);return a}(e,t)}(require("react-native-svg")),t=require("react/jsx-runtime");exports.GreenCheck=r=>(0,t.jsxs)(e.default,{viewBox:"0 0 30 31",width:30,height:31,fill:"none",...r,children:[(0,t.jsx)(e.Path,{fill:r.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"}),(0,t.jsx)(e.Path,{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,24 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.InfoIcon = void 0;
7
- var _reactNativeSvg = _interopRequireWildcard(require("react-native-svg"));
8
- var _jsxRuntime = require("react/jsx-runtime");
9
- 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); }
10
- const InfoIcon = props => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.default, {
11
- viewBox: "0 0 24 24",
12
- width: 24,
13
- height: 24,
14
- fill: "none",
15
- ...props,
16
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Path, {
17
- fill: props.fill ?? "#EDBE43",
18
- fillRule: "evenodd",
19
- 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",
20
- clipRule: "evenodd"
21
- })
22
- });
23
- exports.InfoIcon = InfoIcon;
24
- //# sourceMappingURL=InfoIcon.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.InfoIcon=void 0;var e=function(e,t){if("function"==typeof WeakMap)var r=new WeakMap,n=new WeakMap;return 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)}(require("react-native-svg")),t=require("react/jsx-runtime");exports.InfoIcon=r=>(0,t.jsx)(e.default,{viewBox:"0 0 24 24",width:24,height:24,fill:"none",...r,children:(0,t.jsx)(e.Path,{fill:r.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,27 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.RedX = void 0;
7
- var _reactNativeSvg = _interopRequireWildcard(require("react-native-svg"));
8
- var _jsxRuntime = require("react/jsx-runtime");
9
- 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); }
10
- const RedX = props => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.default, {
11
- viewBox: "0 0 24 24",
12
- width: 24,
13
- height: 24,
14
- fill: "none",
15
- ...props,
16
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Path, {
17
- fill: props.fill ?? "#F05964",
18
- fillRule: "evenodd",
19
- 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",
20
- clipRule: "evenodd"
21
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Path, {
22
- fill: "#fff",
23
- 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"
24
- })]
25
- });
26
- exports.RedX = RedX;
27
- //# sourceMappingURL=RedX.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RedX=void 0;var e=function(e,t){if("function"==typeof WeakMap)var r=new WeakMap,l=new WeakMap;return function(e,t){if(!t&&e&&e.__esModule)return e;var n,a,i={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return i;if(n=t?l:r){if(n.has(e))return n.get(e);n.set(e,i)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((a=(n=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?n(i,t,a):i[t]=e[t]);return i}(e,t)}(require("react-native-svg")),t=require("react/jsx-runtime");exports.RedX=r=>(0,t.jsxs)(e.default,{viewBox:"0 0 24 24",width:24,height:24,fill:"none",...r,children:[(0,t.jsx)(e.Path,{fill:r.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"}),(0,t.jsx)(e.Path,{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,34 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "CloseIcon", {
7
- enumerable: true,
8
- get: function () {
9
- return _CloseIcon.CloseIcon;
10
- }
11
- });
12
- Object.defineProperty(exports, "GreenCheck", {
13
- enumerable: true,
14
- get: function () {
15
- return _GreenCheck.GreenCheck;
16
- }
17
- });
18
- Object.defineProperty(exports, "InfoIcon", {
19
- enumerable: true,
20
- get: function () {
21
- return _InfoIcon.InfoIcon;
22
- }
23
- });
24
- Object.defineProperty(exports, "RedX", {
25
- enumerable: true,
26
- get: function () {
27
- return _RedX.RedX;
28
- }
29
- });
30
- var _CloseIcon = require("./CloseIcon.js");
31
- var _GreenCheck = require("./GreenCheck.js");
32
- var _InfoIcon = require("./InfoIcon.js");
33
- var _RedX = require("./RedX.js");
34
- //# sourceMappingURL=index.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"CloseIcon",{enumerable:!0,get:function(){return e.CloseIcon}}),Object.defineProperty(exports,"GreenCheck",{enumerable:!0,get:function(){return r.GreenCheck}}),Object.defineProperty(exports,"InfoIcon",{enumerable:!0,get:function(){return n.InfoIcon}}),Object.defineProperty(exports,"RedX",{enumerable:!0,get:function(){return t.RedX}});var e=require("./CloseIcon.js"),r=require("./GreenCheck.js"),n=require("./InfoIcon.js"),t=require("./RedX.js");
@@ -1,59 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "BreadLoaf", {
7
- enumerable: true,
8
- get: function () {
9
- return _toastProvider.BreadLoaf;
10
- }
11
- });
12
- Object.defineProperty(exports, "CloseIcon", {
13
- enumerable: true,
14
- get: function () {
15
- return _index.CloseIcon;
16
- }
17
- });
18
- Object.defineProperty(exports, "GreenCheck", {
19
- enumerable: true,
20
- get: function () {
21
- return _index.GreenCheck;
22
- }
23
- });
24
- Object.defineProperty(exports, "InfoIcon", {
25
- enumerable: true,
26
- get: function () {
27
- return _index.InfoIcon;
28
- }
29
- });
30
- Object.defineProperty(exports, "RedX", {
31
- enumerable: true,
32
- get: function () {
33
- return _index.RedX;
34
- }
35
- });
36
- Object.defineProperty(exports, "ToastContainer", {
37
- enumerable: true,
38
- get: function () {
39
- return _toast.ToastContainer;
40
- }
41
- });
42
- Object.defineProperty(exports, "toast", {
43
- enumerable: true,
44
- get: function () {
45
- return _toastApi.toast;
46
- }
47
- });
48
- Object.defineProperty(exports, "toastStore", {
49
- enumerable: true,
50
- get: function () {
51
- return _toastStore.toastStore;
52
- }
53
- });
54
- var _index = require("./icons/index.js");
55
- var _toast = require("./toast.js");
56
- var _toastApi = require("./toast-api.js");
57
- var _toastProvider = require("./toast-provider.js");
58
- var _toastStore = require("./toast-store.js");
59
- //# sourceMappingURL=index.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"BreadLoaf",{enumerable:!0,get:function(){return n.BreadLoaf}}),Object.defineProperty(exports,"CloseIcon",{enumerable:!0,get:function(){return e.CloseIcon}}),Object.defineProperty(exports,"GreenCheck",{enumerable:!0,get:function(){return e.GreenCheck}}),Object.defineProperty(exports,"InfoIcon",{enumerable:!0,get:function(){return e.InfoIcon}}),Object.defineProperty(exports,"RedX",{enumerable:!0,get:function(){return e.RedX}}),Object.defineProperty(exports,"ToastContainer",{enumerable:!0,get:function(){return t.ToastContainer}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return r.toast}}),Object.defineProperty(exports,"toastStore",{enumerable:!0,get:function(){return o.toastStore}});var e=require("./icons/index.js"),t=require("./toast.js"),r=require("./toast-api.js"),n=require("./toast-provider.js"),o=require("./toast-store.js");
@@ -1,127 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.toast = void 0;
7
- var _toastStore = require("./toast-store.js");
8
- /** Second parameter can be a string (description) or options object */
9
-
10
- const _toast = (title, description, type, duration) => {
11
- _toastStore.toastStore.show(title, description, type, duration);
12
- };
13
-
14
- /** Helper to parse the second argument which can be string or options */
15
- const parseDescriptionOrOptions = arg => {
16
- if (!arg) return {};
17
- if (typeof arg === "string") return {
18
- description: arg
19
- };
20
- return {
21
- description: arg.description,
22
- duration: arg.duration,
23
- options: arg
24
- };
25
- };
26
- const parseMessage = input => typeof input === "string" ? {
27
- title: input
28
- } : input;
29
- const parseErrorMessage = (input, error) => {
30
- if (typeof input === "function") {
31
- return parseMessage(input(error));
32
- }
33
- return parseMessage(input);
34
- };
35
- const promiseToast = async (promise, messages) => {
36
- const loadingCfg = parseMessage(messages.loading);
37
-
38
- // Very long duration so it stays visible until we resolve/reject
39
- const toastId = _toastStore.toastStore.show(loadingCfg.title, loadingCfg.description, "loading", loadingCfg.duration ?? 60 * 60 * 1000);
40
- try {
41
- const result = await promise;
42
- const successCfg = parseMessage(messages.success);
43
- _toastStore.toastStore.updateToast(toastId, {
44
- title: successCfg.title,
45
- description: successCfg.description,
46
- type: "success",
47
- duration: successCfg.duration ?? 4000
48
- });
49
- return {
50
- data: result,
51
- success: true
52
- };
53
- } catch (err) {
54
- const error = err instanceof Error ? err : new Error(String(err));
55
- const errorCfg = parseErrorMessage(messages.error, error);
56
- _toastStore.toastStore.updateToast(toastId, {
57
- title: errorCfg.title,
58
- description: errorCfg.description,
59
- type: "error",
60
- duration: errorCfg.duration ?? 4000
61
- });
62
- return {
63
- error,
64
- success: false
65
- };
66
- }
67
- };
68
- // Build the toast API
69
- const toastFn = _toast;
70
- toastFn.success = (title, descriptionOrOptions, duration) => {
71
- const {
72
- description,
73
- duration: optDuration,
74
- options
75
- } = parseDescriptionOrOptions(descriptionOrOptions);
76
- _toastStore.toastStore.show(title, description, "success", duration ?? optDuration, options);
77
- };
78
- toastFn.error = (title, descriptionOrOptions, duration) => {
79
- const {
80
- description,
81
- duration: optDuration,
82
- options
83
- } = parseDescriptionOrOptions(descriptionOrOptions);
84
- _toastStore.toastStore.show(title, description, "error", duration ?? optDuration, options);
85
- };
86
- toastFn.info = (title, descriptionOrOptions, duration) => {
87
- const {
88
- description,
89
- duration: optDuration,
90
- options
91
- } = parseDescriptionOrOptions(descriptionOrOptions);
92
- _toastStore.toastStore.show(title, description, "info", duration ?? optDuration, options);
93
- };
94
- toastFn.promise = promiseToast;
95
- toastFn.dismiss = id => {
96
- _toastStore.toastStore.hide(id);
97
- };
98
- toastFn.dismissAll = () => {
99
- _toastStore.toastStore.hideAll();
100
- };
101
-
102
- /**
103
- * Toast API for showing notifications.
104
- *
105
- * @example
106
- * ```ts
107
- * import { toast } from 'react-native-bread';
108
- *
109
- * // Basic toasts
110
- * toast.success("Saved!", "Your changes have been saved");
111
- * toast.error("Error", "Something went wrong");
112
- * toast.info("Tip", "Swipe up to dismiss");
113
- *
114
- * // Promise toast (loading → success/error)
115
- * toast.promise(apiCall(), {
116
- * loading: { title: "Loading..." },
117
- * success: { title: "Done!" },
118
- * error: (err) => ({ title: "Failed", description: err.message }),
119
- * });
120
- *
121
- * // Dismiss toasts
122
- * toast.dismiss(id);
123
- * toast.dismissAll();
124
- * ```
125
- */
126
- const toast = exports.toast = toastFn;
127
- //# sourceMappingURL=toast-api.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.toast=void 0;var t=require("./toast-store.js");const o=t=>t?"string"==typeof t?{description:t}:{description:t.description,duration:t.duration,options:t}:{},s=t=>"string"==typeof t?{title:t}:t,r=(o,s,r,e)=>{t.toastStore.show(o,s,r,e)};r.success=(s,r,e)=>{const{description:i,duration:n,options:a}=o(r);t.toastStore.show(s,i,"success",e??n,a)},r.error=(s,r,e)=>{const{description:i,duration:n,options:a}=o(r);t.toastStore.show(s,i,"error",e??n,a)},r.info=(s,r,e)=>{const{description:i,duration:n,options:a}=o(r);t.toastStore.show(s,i,"info",e??n,a)},r.promise=async(o,r)=>{const e=s(r.loading),i=t.toastStore.show(e.title,e.description,"loading",e.duration??36e5);try{const e=await o,n=s(r.success);return t.toastStore.updateToast(i,{title:n.title,description:n.description,type:"success",duration:n.duration??4e3}),{data:e,success:!0}}catch(o){const e=o instanceof Error?o:new Error(String(o)),n=((t,o)=>s("function"==typeof t?t(o):t))(r.error,e);return t.toastStore.updateToast(i,{title:n.title,description:n.description,type:"error",duration:n.duration??4e3}),{error:e,success:!1}}},r.dismiss=o=>{t.toastStore.hide(o)},r.dismissAll=()=>{t.toastStore.hideAll()};exports.toast=r;
@@ -1,66 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.BreadLoaf = BreadLoaf;
7
- var _react = require("react");
8
- var _reactNative = require("react-native");
9
- var _toast = require("./toast.js");
10
- var _toastStore = require("./toast-store.js");
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- /**
13
- * Toast component that enables toast notifications in your app.
14
- * Add `<BreadLoaf />` to your root layout to start showing toasts.
15
- *
16
- * @example
17
- * ```tsx
18
- * import { BreadLoaf } from 'react-native-bread';
19
- *
20
- * // Basic usage - add to your root layout
21
- * export default function RootLayout() {
22
- * return (
23
- * <>
24
- * <Stack />
25
- * <BreadLoaf />
26
- * </>
27
- * );
28
- * }
29
- *
30
- * // With configuration
31
- * <BreadLoaf
32
- * config={{
33
- * position: 'bottom',
34
- * stacking: false,
35
- * defaultDuration: 5000,
36
- * colors: {
37
- * success: { accent: '#22c55e', background: '#f0fdf4' },
38
- * error: { accent: '#ef4444', background: '#fef2f2' },
39
- * },
40
- * toastStyle: { borderRadius: 12 },
41
- * }}
42
- * />
43
- * ```
44
- */
45
- function BreadLoaf({
46
- config
47
- }) {
48
- (0, _react.useEffect)(() => {
49
- _toastStore.toastStore.setConfig(config);
50
- return () => {
51
- _toastStore.toastStore.setConfig(undefined);
52
- };
53
- }, [config]);
54
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
55
- style: styles.container,
56
- pointerEvents: "box-none",
57
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_toast.ToastContainer, {})
58
- });
59
- }
60
- const styles = _reactNative.StyleSheet.create({
61
- container: {
62
- ..._reactNative.StyleSheet.absoluteFillObject,
63
- zIndex: 9999
64
- }
65
- });
66
- //# sourceMappingURL=toast-provider.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BreadLoaf=function({config:i}){return(0,e.useEffect)(()=>(o.toastStore.setConfig(i),()=>{o.toastStore.setConfig(void 0)}),[i]),(0,s.jsx)(t.View,{style:n.container,pointerEvents:"box-none",children:(0,s.jsx)(r.ToastContainer,{})})};var e=require("react"),t=require("react-native"),r=require("./toast.js"),o=require("./toast-store.js"),s=require("react/jsx-runtime");const n=t.StyleSheet.create({container:{...t.StyleSheet.absoluteFillObject,zIndex:9999}});