react-native-notitoast 0.0.0-stage → 2.0.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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +201 -2
  3. package/lib/commonjs/ToastItem.js +504 -0
  4. package/lib/commonjs/ToastItem.js.map +1 -0
  5. package/lib/commonjs/ToastProvider.js +84 -0
  6. package/lib/commonjs/ToastProvider.js.map +1 -0
  7. package/lib/commonjs/index.js +26 -0
  8. package/lib/commonjs/index.js.map +1 -0
  9. package/lib/commonjs/package.json +1 -0
  10. package/lib/commonjs/theme.js +41 -0
  11. package/lib/commonjs/theme.js.map +1 -0
  12. package/lib/commonjs/toast.js +39 -0
  13. package/lib/commonjs/toast.js.map +1 -0
  14. package/lib/commonjs/types.js +6 -0
  15. package/lib/commonjs/types.js.map +1 -0
  16. package/lib/module/ToastItem.js +500 -0
  17. package/lib/module/ToastItem.js.map +1 -0
  18. package/lib/module/ToastProvider.js +80 -0
  19. package/lib/module/ToastProvider.js.map +1 -0
  20. package/lib/module/index.js +5 -0
  21. package/lib/module/index.js.map +1 -0
  22. package/lib/module/theme.js +37 -0
  23. package/lib/module/theme.js.map +1 -0
  24. package/lib/module/toast.js +33 -0
  25. package/lib/module/toast.js.map +1 -0
  26. package/lib/module/types.js +4 -0
  27. package/lib/module/types.js.map +1 -0
  28. package/lib/typescript/src/ToastItem.d.ts +12 -0
  29. package/lib/typescript/src/ToastItem.d.ts.map +1 -0
  30. package/lib/typescript/src/ToastProvider.d.ts +7 -0
  31. package/lib/typescript/src/ToastProvider.d.ts.map +1 -0
  32. package/lib/typescript/src/index.d.ts +6 -0
  33. package/lib/typescript/src/index.d.ts.map +1 -0
  34. package/lib/typescript/src/theme.d.ts +21 -0
  35. package/lib/typescript/src/theme.d.ts.map +1 -0
  36. package/lib/typescript/src/toast.d.ts +23 -0
  37. package/lib/typescript/src/toast.d.ts.map +1 -0
  38. package/lib/typescript/src/types.d.ts +93 -0
  39. package/lib/typescript/src/types.d.ts.map +1 -0
  40. package/package.json +77 -6
  41. package/src/ToastItem.tsx +597 -0
  42. package/src/ToastProvider.tsx +93 -0
  43. package/src/index.ts +14 -0
  44. package/src/theme.ts +39 -0
  45. package/src/toast.ts +51 -0
  46. package/src/types.ts +109 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vasanthakumar A
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,202 @@
1
- # Temporary Holding Version
1
+ # react-native-notitoast
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Neat, **mobile-notification-style** toasts for React Native — success, error, warning and info, with images, app icon, variants and full customization.
4
+ Zero dependencies · TypeScript · Expo & bare RN · light/dark mode · swipe to dismiss.
5
+
6
+ ![Options reference 1](https://raw.githubusercontent.com/vasanthakumar2k/react-native-notitoast/main/docs/notitoast-reference-1.png)
7
+ ![Options reference 2](https://raw.githubusercontent.com/vasanthakumar2k/react-native-notitoast/main/docs/notitoast-reference-2.png)
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install react-native-notitoast
13
+ ```
14
+
15
+ Requires `react-native >= 0.72`. Works in Expo Go — no native code.
16
+
17
+ ## Setup
18
+
19
+ ```tsx
20
+ import { ToastProvider } from 'react-native-notitoast';
21
+
22
+ export default function App() {
23
+ return (
24
+ <ToastProvider>
25
+ <RootNavigator />
26
+ </ToastProvider>
27
+ );
28
+ }
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ```tsx
34
+ import { toast } from 'react-native-notitoast';
35
+
36
+ toast.success('Payment successful', '₹499 paid to Arun Stores');
37
+ toast.error('Upload failed', 'Check your internet connection');
38
+ toast.warning('Low storage', 'Only 200 MB left on device');
39
+ toast.info('New update', 'Version 2.1 is available');
40
+ ```
41
+
42
+ Every option below works **globally** (as a `<ToastProvider>` prop) and **per toast** (third argument). Per-toast values win.
43
+
44
+ ## Customization recipes
45
+
46
+ ### Image left or right
47
+
48
+ ```tsx
49
+ toast.info('Priya sent a photo', 'Check out this view!', {
50
+ image: { uri: 'https://example.com/photo.jpg' },
51
+ imagePosition: 'left', // default 'right'
52
+ });
53
+ ```
54
+
55
+ A left image takes the icon's place, with a small type badge on its corner (`showTypeBadge: false` to remove).
56
+
57
+ ### App icon (basic Android-toast style)
58
+
59
+ ```tsx
60
+ <ToastProvider appIcon={require('./assets/icon.png')}>
61
+ ```
62
+
63
+ Leave `appIcon` unset and nothing shows there.
64
+
65
+ ### No icons — still clean
66
+
67
+ ```tsx
68
+ <ToastProvider showIcon={false}>
69
+ ```
70
+
71
+ Without a left icon, a thin colored accent stripe marks the type automatically. Turn that off too with `showAccentBar: false` for a plain text card.
72
+
73
+ ### Duration
74
+
75
+ ```tsx
76
+ <ToastProvider duration={3000} /> // all toasts
77
+ <ToastProvider durations={{ error: 6000, success: 2000 }} /> // per type
78
+ toast.success('Saved', undefined, { duration: 1500 }); // one toast
79
+ toast.info('Read me', 'Stays until closed', { duration: 0 }); // sticky
80
+ ```
81
+
82
+ Defaults: error 5000ms, warning 4000ms, success/info 3500ms.
83
+
84
+ ### Progress bar (off by default)
85
+
86
+ ```tsx
87
+ <ToastProvider showProgress />
88
+ toast.success('Saved', 'Draft saved', { showProgress: true });
89
+ ```
90
+
91
+ ### Lines
92
+
93
+ ```tsx
94
+ toast.info('A long title that can wrap', 'Long message…', {
95
+ titleLines: 2, // default 1
96
+ messageLines: 0, // default 3, 0 = unlimited
97
+ });
98
+ ```
99
+
100
+ ### Size
101
+
102
+ ```tsx
103
+ <ToastProvider width="90%" maxWidth={420} minHeight={64} borderRadius={14} iconSize={36} imageSize={48} />
104
+ toast.info('Fixed height', 'This one is 80px', { height: 80 });
105
+ ```
106
+
107
+ ### Card color and variants
108
+
109
+ ```tsx
110
+ <ToastProvider variant="tinted" /> // 'default' | 'tinted' | 'filled'
111
+ toast.error('Payment failed', 'Card declined', { variant: 'filled' });
112
+
113
+ toast.info('Custom', 'Any colors you like', {
114
+ backgroundColor: '#0F172A',
115
+ borderColor: '#1E293B',
116
+ titleColor: '#F8FAFC',
117
+ messageColor: '#CBD5E1',
118
+ accentColor: '#A855F7',
119
+ });
120
+
121
+ <ToastProvider colors={{ success: '#10B981', info: '#6366F1' }} />
122
+ ```
123
+
124
+ ### Update a toast in place
125
+
126
+ ```tsx
127
+ const id = toast.info('Uploading…', 'Please wait', { duration: 0 });
128
+ toast.success('Uploaded', 'Your file is live', { id });
129
+ ```
130
+
131
+ ### Hide
132
+
133
+ ```tsx
134
+ toast.hide(id); toast.hide(); toast.hideAll();
135
+ ```
136
+
137
+ Hook form: `const toast = useToast();`
138
+
139
+ ## All options
140
+
141
+ ### Appearance (provider **and** per toast)
142
+
143
+ | Option | Type | Default |
144
+ | --- | --- | --- |
145
+ | `position` | `'top' \| 'bottom'` | `'top'` |
146
+ | `duration` | ms, `0` = sticky | per type |
147
+ | `showProgress` | `boolean` | `false` |
148
+ | `swipeable` | `boolean` — `false` turns off all swipe directions | `true` |
149
+ | `swipeLeft` `swipeRight` | `boolean` — swipe sideways to dismiss | `true` |
150
+ | `swipeUp` | `boolean` | `true` on top toasts, `false` on bottom |
151
+ | `swipeDown` | `boolean` | `true` on bottom toasts, `false` on top |
152
+ | `showIcon` | `boolean` | `true` |
153
+ | `showTypeBadge` | `boolean` — badge on left image / app icon | `true` |
154
+ | `showAccentBar` | `boolean` | auto (on when no left icon) |
155
+ | `imagePosition` | `'left' \| 'right'` | `'right'` |
156
+ | `appIcon` | `ImageSourcePropType` | — (hidden) |
157
+ | `variant` | `'default' \| 'tinted' \| 'filled'` | `'default'` |
158
+ | `backgroundColor` `borderColor` `titleColor` `messageColor` | `string` | theme |
159
+ | `titleLines` | `number`, `0` = unlimited | `1` |
160
+ | `messageLines` | `number`, `0` = unlimited | `3` |
161
+ | `width` `maxWidth` `minHeight` `height` | number or `'%'` | `'100%'`, `560`, —, — |
162
+ | `borderRadius` | `number` | `18` |
163
+ | `iconSize` | `number` | `40` |
164
+ | `imageSize` | `number` | `44` |
165
+ | `style` `titleStyle` `messageStyle` | style overrides | — |
166
+
167
+ ### Per toast only
168
+
169
+ | Option | Type |
170
+ | --- | --- |
171
+ | `type` | `'success' \| 'error' \| 'warning' \| 'info'` |
172
+ | `title`, `message` | `string` |
173
+ | `image` | `ImageSourcePropType` |
174
+ | `icon` | `ImageSourcePropType` — custom left icon / avatar |
175
+ | `accentColor` | `string` |
176
+ | `id` | `string` — reuse to update |
177
+ | `onPress`, `onHide` | `() => void` |
178
+
179
+ ### Provider only
180
+
181
+ | Prop | Type | Default |
182
+ | --- | --- | --- |
183
+ | `theme` | `'light' \| 'dark' \| 'system'` | `'system'` |
184
+ | `colors` | `{ success?, error?, warning?, info? }` | green / red / amber / blue |
185
+ | `durations` | `{ success?, error?, warning?, info? }` | 3500 / 5000 / 4000 / 3500 |
186
+ | `topOffset` | `number` | iOS 54, Android status bar + 8 |
187
+ | `bottomOffset` | `number` | `40` |
188
+
189
+ **Left slot priority:** left `image` → `icon` → `appIcon` → type icon → accent stripe.
190
+
191
+ **Safe area tip:** `<ToastProvider topOffset={useSafeAreaInsets().top + 8}>`
192
+
193
+ ## Behaviour
194
+
195
+ - Toasts queue: one at a time, the next slides in after.
196
+ - Swipe left, right or up (down for bottom toasts) to dismiss. Turn any direction off, e.g. `swipeLeft={false}`, or all of them with `swipeable={false}`. Press and hold pauses the timer.
197
+ - Announced to screen readers.
198
+ - Toasts render behind an open React Native `<Modal>`. Put another `<ToastProvider>` inside the modal if needed.
199
+
200
+ ## License
201
+
202
+ MIT