react-native-bread 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +148 -0
- package/lib/commonjs/icons/CloseIcon.js +22 -0
- package/lib/commonjs/icons/CloseIcon.js.map +1 -0
- package/lib/commonjs/icons/GreenCheck.js +27 -0
- package/lib/commonjs/icons/GreenCheck.js.map +1 -0
- package/lib/commonjs/icons/InfoIcon.js +24 -0
- package/lib/commonjs/icons/InfoIcon.js.map +1 -0
- package/lib/commonjs/icons/RedX.js +27 -0
- package/lib/commonjs/icons/RedX.js.map +1 -0
- package/lib/commonjs/icons/index.js +34 -0
- package/lib/commonjs/icons/index.js.map +1 -0
- package/lib/commonjs/index.js +59 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/toast-api.js +127 -0
- package/lib/commonjs/toast-api.js.map +1 -0
- package/lib/commonjs/toast-provider.js +71 -0
- package/lib/commonjs/toast-provider.js.map +1 -0
- package/lib/commonjs/toast-store.js +278 -0
- package/lib/commonjs/toast-store.js.map +1 -0
- package/lib/commonjs/toast.js +445 -0
- package/lib/commonjs/toast.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/icons/CloseIcon.js +16 -0
- package/lib/module/icons/CloseIcon.js.map +1 -0
- package/lib/module/icons/GreenCheck.js +21 -0
- package/lib/module/icons/GreenCheck.js.map +1 -0
- package/lib/module/icons/InfoIcon.js +18 -0
- package/lib/module/icons/InfoIcon.js.map +1 -0
- package/lib/module/icons/RedX.js +21 -0
- package/lib/module/icons/RedX.js.map +1 -0
- package/lib/module/icons/index.js +7 -0
- package/lib/module/icons/index.js.map +1 -0
- package/lib/module/index.js +14 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/toast-api.js +124 -0
- package/lib/module/toast-api.js.map +1 -0
- package/lib/module/toast-provider.js +67 -0
- package/lib/module/toast-provider.js.map +1 -0
- package/lib/module/toast-store.js +274 -0
- package/lib/module/toast-store.js.map +1 -0
- package/lib/module/toast.js +439 -0
- package/lib/module/toast.js.map +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/icons/CloseIcon.d.ts +3 -0
- package/lib/typescript/icons/CloseIcon.d.ts.map +1 -0
- package/lib/typescript/icons/GreenCheck.d.ts +3 -0
- package/lib/typescript/icons/GreenCheck.d.ts.map +1 -0
- package/lib/typescript/icons/InfoIcon.d.ts +3 -0
- package/lib/typescript/icons/InfoIcon.d.ts.map +1 -0
- package/lib/typescript/icons/RedX.d.ts +3 -0
- package/lib/typescript/icons/RedX.d.ts.map +1 -0
- package/lib/typescript/icons/index.d.ts +5 -0
- package/lib/typescript/icons/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +7 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/toast-api.d.ts +109 -0
- package/lib/typescript/toast-api.d.ts.map +1 -0
- package/lib/typescript/toast-provider.d.ts +52 -0
- package/lib/typescript/toast-provider.d.ts.map +1 -0
- package/lib/typescript/toast-store.d.ts +26 -0
- package/lib/typescript/toast-store.d.ts.map +1 -0
- package/lib/typescript/toast.d.ts +2 -0
- package/lib/typescript/toast.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +101 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/package.json +87 -0
- package/src/icons/CloseIcon.tsx +10 -0
- package/src/icons/GreenCheck.tsx +16 -0
- package/src/icons/InfoIcon.tsx +12 -0
- package/src/icons/RedX.tsx +16 -0
- package/src/icons/index.ts +4 -0
- package/src/index.ts +26 -0
- package/src/toast-api.ts +213 -0
- package/src/toast-provider.tsx +81 -0
- package/src/toast-store.ts +270 -0
- package/src/toast.tsx +417 -0
- package/src/types.ts +121 -0
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# 🍞 react-native-bread
|
|
2
|
+
|
|
3
|
+
Drop-in toast notifications for React Native. Clean Sonner like API, buttery 60fps animations, swipe-to-dismiss, and fully customizable.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
toast.success('Saved!'); // That's it. No hooks, no context.
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
https://github.com/user-attachments/assets/8a862dba-422c-4573-9f12-0a36cf6efe49
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bun add react-native-bread
|
|
19
|
+
# or any package manager
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Peer Dependencies
|
|
23
|
+
|
|
24
|
+
You'll need these installed and configured in your project:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
bun add react-native-reanimated react-native-gesture-handler react-native-safe-area-context react-native-svg react-native-worklets
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
Wrap your app with `<BreadLoaf>` and you're good to go:
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { BreadLoaf } from 'react-native-bread';
|
|
37
|
+
|
|
38
|
+
export default function App() {
|
|
39
|
+
return (
|
|
40
|
+
<BreadLoaf>
|
|
41
|
+
<YourApp />
|
|
42
|
+
</BreadLoaf>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Then show toasts from anywhere:
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import { toast } from 'react-native-bread';
|
|
51
|
+
|
|
52
|
+
// Basic toasts
|
|
53
|
+
toast.success('Saved!', 'Your changes have been saved');
|
|
54
|
+
toast.error('Error', 'Something went wrong');
|
|
55
|
+
toast.info('Tip', 'Swipe to dismiss');
|
|
56
|
+
|
|
57
|
+
// Promise toast - shows loading, then success/error
|
|
58
|
+
toast.promise(fetchData(), {
|
|
59
|
+
loading: { title: 'Loading...', description: 'Please wait' },
|
|
60
|
+
success: { title: 'Done!', description: 'Data loaded' },
|
|
61
|
+
error: (err) => ({ title: 'Failed', description: err.message }),
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## API
|
|
66
|
+
|
|
67
|
+
### Toast Methods
|
|
68
|
+
|
|
69
|
+
| Method | Description |
|
|
70
|
+
|--------|-------------|
|
|
71
|
+
| `toast.success(title, description?)` | Green checkmark toast |
|
|
72
|
+
| `toast.error(title, description?)` | Red X toast |
|
|
73
|
+
| `toast.info(title, description?)` | Yellow info toast |
|
|
74
|
+
| `toast.promise(promise, messages)` | Loading → success/error toast |
|
|
75
|
+
| `toast.dismiss(id)` | Dismiss a specific toast |
|
|
76
|
+
| `toast.dismissAll()` | Dismiss all toasts |
|
|
77
|
+
|
|
78
|
+
### Per-Toast Options
|
|
79
|
+
|
|
80
|
+
Instead of a description string, you can pass an options object as the second argument:
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
toast.success('Saved!', {
|
|
84
|
+
description: 'Your changes have been saved',
|
|
85
|
+
duration: 5000,
|
|
86
|
+
icon: <CustomIcon />,
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
| Option | Type | Description |
|
|
91
|
+
|--------|------|-------------|
|
|
92
|
+
| `description` | `string` | Toast description text |
|
|
93
|
+
| `duration` | `number` | Display time in ms |
|
|
94
|
+
| `icon` | `ReactNode \| (props) => ReactNode` | Custom icon component |
|
|
95
|
+
| `style` | `ViewStyle` | Toast container style overrides |
|
|
96
|
+
| `titleStyle` | `TextStyle` | Title text style overrides |
|
|
97
|
+
| `descriptionStyle` | `TextStyle` | Description text style overrides |
|
|
98
|
+
| `dismissible` | `boolean` | Enable/disable swipe to dismiss |
|
|
99
|
+
| `showCloseButton` | `boolean` | Show/hide the X button |
|
|
100
|
+
|
|
101
|
+
### BreadLoaf Config
|
|
102
|
+
|
|
103
|
+
Customize all toasts globally via the `config` prop:
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
<BreadLoaf config={{ position: 'bottom', stacking: false }}>
|
|
107
|
+
<App />
|
|
108
|
+
</BreadLoaf>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
| Option | Type | Default | Description |
|
|
112
|
+
|--------|------|---------|-------------|
|
|
113
|
+
| `position` | `'top' \| 'bottom'` | `'top'` | Where toasts appear |
|
|
114
|
+
| `offset` | `number` | `0` | Extra spacing from screen edge (px) |
|
|
115
|
+
| `stacking` | `boolean` | `true` | Show multiple toasts stacked |
|
|
116
|
+
| `maxStack` | `number` | `3` | Max visible toasts when stacking |
|
|
117
|
+
| `dismissible` | `boolean` | `true` | Allow swipe to dismiss |
|
|
118
|
+
| `showCloseButton` | `boolean` | `true` | Show X button (except loading toasts) |
|
|
119
|
+
| `defaultDuration` | `number` | `4000` | Default display time (ms) |
|
|
120
|
+
| `colors` | `object` | — | Colors per toast type (see below) |
|
|
121
|
+
| `icons` | `object` | — | Custom icons per toast type |
|
|
122
|
+
| `toastStyle` | `ViewStyle` | — | Global toast container styles |
|
|
123
|
+
| `titleStyle` | `TextStyle` | — | Global title text styles |
|
|
124
|
+
| `descriptionStyle` | `TextStyle` | — | Global description text styles |
|
|
125
|
+
|
|
126
|
+
#### Colors
|
|
127
|
+
|
|
128
|
+
Each toast type (`success`, `error`, `info`, `loading`) accepts:
|
|
129
|
+
|
|
130
|
+
| Property | Description |
|
|
131
|
+
|----------|-------------|
|
|
132
|
+
| `accent` | Icon and title color |
|
|
133
|
+
| `background` | Toast background color |
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
colors: {
|
|
137
|
+
success: { accent: '#22c55e', background: '#f0fdf4' },
|
|
138
|
+
error: { accent: '#ef4444', background: '#fef2f2' },
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Known Limitations
|
|
143
|
+
|
|
144
|
+
### Toasts Behind Modals
|
|
145
|
+
|
|
146
|
+
When you trigger a toast while opening a native modal (or transparent modal), the toast may appear **behind** the modal. This happens because React Native modals are mounted natively on top of everything.
|
|
147
|
+
|
|
148
|
+
**Workaround**: Use a "contained" modal approach — render your modal content inside your regular component tree with absolute positioning, rather than using React Native's `<Modal>` component. This way toasts will appear on top as expected.
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeSvg","_interopRequireWildcard","require","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","CloseIcon","props","jsx","viewBox","width","height","fill","children","Path","d","exports"],"sourceRoot":"../../../src","sources":["icons/CloseIcon.tsx"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA4D,IAAAC,WAAA,GAAAD,OAAA;AAAA,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAErD,MAAMkB,SAAS,GAAIC,KAAe,iBACvC,IAAArB,WAAA,CAAAsB,GAAA,EAACzB,eAAA,CAAAc,OAAG;EAACY,OAAO,EAAC,WAAW;EAACC,KAAK,EAAE,EAAG;EAACC,MAAM,EAAE,EAAG;EAACC,IAAI,EAAC,MAAM;EAAA,GAAKL,KAAK;EAAAM,QAAA,eACnE,IAAA3B,WAAA,CAAAsB,GAAA,EAACzB,eAAA,CAAA+B,IAAI;IACHF,IAAI,EAAEL,KAAK,CAACK,IAAI,IAAI,SAAU;IAC9BG,CAAC,EAAC;EAA+G,CAClH;AAAC,CACC,CACN;AAACC,OAAA,CAAAV,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeSvg","_interopRequireWildcard","require","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","GreenCheck","props","jsxs","viewBox","width","height","fill","children","jsx","Path","fillRule","d","clipRule","exports"],"sourceRoot":"../../../src","sources":["icons/GreenCheck.tsx"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA4D,IAAAC,WAAA,GAAAD,OAAA;AAAA,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAA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AI,SAAU;IAC9BI,QAAQ,EAAC,SAAS;IAClBC,CAAC,EAAC,4SAA4S;IAC9SC,QAAQ,EAAC;EAAS,CACnB,CAAC,eACF,IAAAhC,WAAA,CAAA4B,GAAA,EAAC/B,eAAA,CAAAgC,IAAI;IACHH,IAAI,EAAC,MAAM;IACXK,CAAC,EAAC;EAA6I,CAChJ,CAAC;AAAA,CACC,CACN;AAACE,OAAA,CAAAb,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeSvg","_interopRequireWildcard","require","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","InfoIcon","props","jsx","viewBox","width","height","fill","children","Path","fillRule","d","clipRule","exports"],"sourceRoot":"../../../src","sources":["icons/InfoIcon.tsx"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA4D,IAAAC,WAAA,GAAAD,OAAA;AAAA,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAErD,MAAMkB,QAAQ,GAAIC,KAAe,iBACtC,IAAArB,WAAA,CAAAsB,GAAA,EAACzB,eAAA,CAAAc,OAAG;EAACY,OAAO,EAAC,WAAW;EAACC,KAAK,EAAE,EAAG;EAACC,MAAM,EAAE,EAAG;EAACC,IAAI,EAAC,MAAM;EAAA,GAAKL,KAAK;EAAAM,QAAA,eACnE,IAAA3B,WAAA,CAAAsB,GAAA,EAACzB,eAAA,CAAA+B,IAAI;IACHF,IAAI,EAAEL,KAAK,CAACK,IAAI,IAAI,SAAU;IAC9BG,QAAQ,EAAC,SAAS;IAClBC,CAAC,EAAC,kGAAkG;IACpGC,QAAQ,EAAC;EAAS,CACnB;AAAC,CACC,CACN;AAACC,OAAA,CAAAZ,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeSvg","_interopRequireWildcard","require","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","RedX","props","jsxs","viewBox","width","height","fill","children","jsx","Path","fillRule","d","clipRule","exports"],"sourceRoot":"../../../src","sources":["icons/RedX.tsx"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA4D,IAAAC,WAAA,GAAAD,OAAA;AAAA,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAErD,MAAMkB,IAAI,GAAIC,KAAe,iBAClC,IAAArB,WAAA,CAAAsB,IAAA,EAACzB,eAAA,CAAAc,OAAG;EAACY,OAAO,EAAC,WAAW;EAACC,KAAK,EAAE,EAAG;EAACC,MAAM,EAAE,EAAG;EAACC,IAAI,EAAC,MAAM;EAAA,GAAKL,KAAK;EAAAM,QAAA,gBACnE,IAAA3B,WAAA,CAAA4B,GAAA,EAAC/B,eAAA,CAAAgC,IAAI;IACHH,IAAI,EAAEL,KAAK,CAACK,IAAI,IAAI,SAAU;IAC9BI,QAAQ,EAAC,SAAS;IAClBC,CAAC,EAAC,4YAA4Y;IAC9YC,QAAQ,EAAC;EAAS,CACnB,CAAC,eACF,IAAAhC,WAAA,CAAA4B,GAAA,EAAC/B,eAAA,CAAAgC,IAAI;IACHH,IAAI,EAAC,MAAM;IACXK,CAAC,EAAC;EAA8O,CACjP,CAAC;AAAA,CACC,CACN;AAACE,OAAA,CAAAb,IAAA,GAAAA,IAAA","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_CloseIcon","require","_GreenCheck","_InfoIcon","_RedX"],"sourceRoot":"../../../src","sources":["icons/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_index","require","_toast","_toastApi","_toastProvider","_toastStore"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAGA,IAAAI,WAAA,GAAAJ,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,127 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_toastStore","require","_toast","title","description","type","duration","toastStore","show","parseDescriptionOrOptions","arg","options","parseMessage","input","parseErrorMessage","error","promiseToast","promise","messages","loadingCfg","loading","toastId","result","successCfg","success","updateToast","data","err","Error","String","errorCfg","toastFn","descriptionOrOptions","optDuration","info","dismiss","id","hide","dismissAll","hideAll","toast","exports"],"sourceRoot":"../../src","sources":["toast-api.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAUA;;AAGA,MAAMC,MAAM,GAAGA,CAACC,KAAa,EAAEC,WAAoB,EAAEC,IAAgB,EAAEC,QAAiB,KAAK;EAC3FC,sBAAU,CAACC,IAAI,CAACL,KAAK,EAAEC,WAAW,EAAEC,IAAI,EAAEC,QAAQ,CAAC;AACrD,CAAC;;AAED;AACA,MAAMG,yBAAyB,GAC7BC,GAA0B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AACL,KAAK,EAAEC,WAAW,EAAE,OAAO,EAAEE,QAAQ,IAAI2B,WAAW,EAAEtB,OAAO,CAAC;AAChF,CAAC;AAEDoB,OAAO,CAACG,IAAI,GAAG,CAAC/B,KAAa,EAAE6B,oBAA2C,EAAE1B,QAAiB,KAAK;EAChG,MAAM;IAAEF,WAAW;IAAEE,QAAQ,EAAE2B,WAAW;IAAEtB;EAAQ,CAAC,GAAGF,yBAAyB,CAACuB,oBAAoB,CAAC;EACvGzB,sBAAU,CAACC,IAAI,CAACL,KAAK,EAAEC,WAAW,EAAE,MAAM,EAAEE,QAAQ,IAAI2B,WAAW,EAAEtB,OAAO,CAAC;AAC/E,CAAC;AAEDoB,OAAO,CAACd,OAAO,GAAGD,YAAY;AAE9Be,OAAO,CAACI,OAAO,GAAIC,EAAU,IAAK;EAChC7B,sBAAU,CAAC8B,IAAI,CAACD,EAAE,CAAC;AACrB,CAAC;AAEDL,OAAO,CAACO,UAAU,GAAG,MAAM;EACzB/B,sBAAU,CAACgC,OAAO,CAAC,CAAC;AACtB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAGT,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
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 provider component that enables toast notifications in your app.
|
|
14
|
+
* Wrap your root component with `<BreadLoaf>` to start showing toasts.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { BreadLoaf } from 'react-native-bread';
|
|
19
|
+
*
|
|
20
|
+
* // Basic usage
|
|
21
|
+
* <BreadLoaf>
|
|
22
|
+
* <App />
|
|
23
|
+
* </BreadLoaf>
|
|
24
|
+
*
|
|
25
|
+
* // With configuration
|
|
26
|
+
* <BreadLoaf
|
|
27
|
+
* config={{
|
|
28
|
+
* position: 'bottom',
|
|
29
|
+
* stacking: false,
|
|
30
|
+
* defaultDuration: 5000,
|
|
31
|
+
* colors: {
|
|
32
|
+
* success: { accent: '#22c55e', background: '#f0fdf4' },
|
|
33
|
+
* error: { accent: '#ef4444', background: '#fef2f2' },
|
|
34
|
+
* },
|
|
35
|
+
* toastStyle: { borderRadius: 12 },
|
|
36
|
+
* }}
|
|
37
|
+
* >
|
|
38
|
+
* <App />
|
|
39
|
+
* </BreadLoaf>
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
function BreadLoaf({
|
|
43
|
+
children,
|
|
44
|
+
config
|
|
45
|
+
}) {
|
|
46
|
+
(0, _react.useEffect)(() => {
|
|
47
|
+
_toastStore.toastStore.setConfig(config);
|
|
48
|
+
return () => {
|
|
49
|
+
// Reset to defaults when this provider unmounts
|
|
50
|
+
_toastStore.toastStore.setConfig(undefined);
|
|
51
|
+
};
|
|
52
|
+
}, [config]);
|
|
53
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
54
|
+
style: styles.root,
|
|
55
|
+
children: [children, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
56
|
+
style: styles.portalContainer,
|
|
57
|
+
pointerEvents: "box-none",
|
|
58
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_toast.ToastContainer, {})
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const styles = _reactNative.StyleSheet.create({
|
|
63
|
+
root: {
|
|
64
|
+
flex: 1
|
|
65
|
+
},
|
|
66
|
+
portalContainer: {
|
|
67
|
+
..._reactNative.StyleSheet.absoluteFillObject,
|
|
68
|
+
zIndex: 9999
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=toast-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_toast","_toastStore","_jsxRuntime","BreadLoaf","children","config","useEffect","toastStore","setConfig","undefined","jsxs","View","style","styles","root","jsx","portalContainer","pointerEvents","ToastContainer","StyleSheet","create","flex","absoluteFillObject","zIndex"],"sourceRoot":"../../src","sources":["toast-provider.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAA2C,IAAAI,WAAA,GAAAJ,OAAA;AAqB3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,SAASA,CAAC;EAAEC,QAAQ;EAAEC;AAAuB,CAAC,EAAE;EAC9D,IAAAC,gBAAS,EAAC,MAAM;IACdC,sBAAU,CAACC,SAAS,CAACH,MAAM,CAAC;IAC5B,OAAO,MAAM;MACX;MACAE,sBAAU,CAACC,SAAS,CAACC,SAAS,CAAC;IACjC,CAAC;EACH,CAAC,EAAE,CAACJ,MAAM,CAAC,CAAC;EACZ,oBACE,IAAAH,WAAA,CAAAQ,IAAA,EAACX,YAAA,CAAAY,IAAI;IAACC,KAAK,EAAEC,MAAM,CAACC,IAAK;IAAAV,QAAA,GACtBA,QAAQ,eACT,IAAAF,WAAA,CAAAa,GAAA,EAAChB,YAAA,CAAAY,IAAI;MAACC,KAAK,EAAEC,MAAM,CAACG,eAAgB;MAACC,aAAa,EAAC,UAAU;MAAAb,QAAA,eAC3D,IAAAF,WAAA,CAAAa,GAAA,EAACf,MAAA,CAAAkB,cAAc,IAAE;IAAC,CACd,CAAC;EAAA,CACH,CAAC;AAEX;AAEA,MAAML,MAAM,GAAGM,uBAAU,CAACC,MAAM,CAAC;EAC/BN,IAAI,EAAE;IACJO,IAAI,EAAE;EACR,CAAC;EACDL,eAAe,EAAE;IACf,GAAGG,uBAAU,CAACG,kBAAkB;IAChCC,MAAM,EAAE;EACV;AACF,CAAC,CAAC","ignoreList":[]}
|