react-notify-lite 1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 harpinderdev
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 ADDED
@@ -0,0 +1,273 @@
1
+ # react-notify-lite
2
+
3
+ A lightweight and customizable React notification library with TypeScript support.
4
+
5
+ ## Features
6
+
7
+ - Lightweight and fast
8
+ - TypeScript support
9
+ - Multiple notification types (success, error, warning, info)
10
+ - Customizable positioning (6 positions)
11
+ - Auto-dismiss with configurable duration
12
+ - Smooth animations
13
+ - Easy to use API
14
+ - Zero dependencies (except React)
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install react-notify-lite
20
+ ```
21
+
22
+ or
23
+
24
+ ```bash
25
+ yarn add react-notify-lite
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ### 1. Wrap your app with ToastProvider
31
+
32
+ ```tsx
33
+ import React from 'react';
34
+ import { ToastProvider } from 'react-notify-lite';
35
+ import 'react-notify-lite/dist/styles.css';
36
+
37
+ function App() {
38
+ return (
39
+ <ToastProvider>
40
+ <YourApp />
41
+ </ToastProvider>
42
+ );
43
+ }
44
+
45
+ export default App;
46
+ ```
47
+
48
+ ### 2. Use the useNotify hook in your components
49
+
50
+ ```tsx
51
+ import React from 'react';
52
+ import { useNotify } from 'react-notify-lite';
53
+
54
+ function MyComponent() {
55
+ const notify = useNotify();
56
+
57
+ const handleClick = () => {
58
+ // Basic notification
59
+ notify.info('This is an info message');
60
+
61
+ // Success notification
62
+ notify.success('Operation completed successfully!');
63
+
64
+ // Error notification
65
+ notify.error('Something went wrong!');
66
+
67
+ // Warning notification
68
+ notify.warning('This is a warning message');
69
+
70
+ // Custom options
71
+ notify.info('Custom notification', {
72
+ duration: 5000,
73
+ position: 'top-center',
74
+ });
75
+ };
76
+
77
+ return (
78
+ <button onClick={handleClick}>
79
+ Show Notification
80
+ </button>
81
+ );
82
+ }
83
+ ```
84
+
85
+ ## API
86
+
87
+ ### ToastProvider
88
+
89
+ Wrap your application with `ToastProvider` to enable notifications throughout your app.
90
+
91
+ ```tsx
92
+ <ToastProvider>
93
+ {children}
94
+ </ToastProvider>
95
+ ```
96
+
97
+ ### useNotify Hook
98
+
99
+ The `useNotify` hook returns an object with the following methods:
100
+
101
+ #### `notify(message, options?)`
102
+
103
+ Display a notification with custom options.
104
+
105
+ ```tsx
106
+ notify.notify('Message', {
107
+ type: 'info',
108
+ duration: 3000,
109
+ position: 'top-right',
110
+ });
111
+ ```
112
+
113
+ #### `success(message, options?)`
114
+
115
+ Display a success notification.
116
+
117
+ ```tsx
118
+ notify.success('Success message', {
119
+ duration: 3000,
120
+ position: 'top-right',
121
+ });
122
+ ```
123
+
124
+ #### `error(message, options?)`
125
+
126
+ Display an error notification.
127
+
128
+ ```tsx
129
+ notify.error('Error message', {
130
+ duration: 3000,
131
+ position: 'top-right',
132
+ });
133
+ ```
134
+
135
+ #### `warning(message, options?)`
136
+
137
+ Display a warning notification.
138
+
139
+ ```tsx
140
+ notify.warning('Warning message', {
141
+ duration: 3000,
142
+ position: 'top-right',
143
+ });
144
+ ```
145
+
146
+ #### `info(message, options?)`
147
+
148
+ Display an info notification.
149
+
150
+ ```tsx
151
+ notify.info('Info message', {
152
+ duration: 3000,
153
+ position: 'top-right',
154
+ });
155
+ ```
156
+
157
+ ## Options
158
+
159
+ | Option | Type | Default | Description |
160
+ |--------|------|---------|-------------|
161
+ | `type` | `'success' \| 'error' \| 'warning' \| 'info'` | `'info'` | Type of notification |
162
+ | `duration` | `number` | `3000` | Duration in milliseconds before auto-dismiss |
163
+ | `position` | `'top-left' \| 'top-right' \| 'top-center' \| 'bottom-left' \| 'bottom-right' \| 'bottom-center'` | `'top-right'` | Position of the notification |
164
+
165
+ ## Positions
166
+
167
+ The library supports 6 different positions:
168
+
169
+ - `top-left`
170
+ - `top-right` (default)
171
+ - `top-center`
172
+ - `bottom-left`
173
+ - `bottom-right`
174
+ - `bottom-center`
175
+
176
+ ## Customization
177
+
178
+ You can customize the styles by overriding the CSS classes:
179
+
180
+ ```css
181
+ /* Override toast styles */
182
+ .toast {
183
+ /* Your custom styles */
184
+ }
185
+
186
+ .toast-success {
187
+ /* Custom success styles */
188
+ }
189
+
190
+ .toast-error {
191
+ /* Custom error styles */
192
+ }
193
+
194
+ .toast-warning {
195
+ /* Custom warning styles */
196
+ }
197
+
198
+ .toast-info {
199
+ /* Custom info styles */
200
+ }
201
+ ```
202
+
203
+ ## TypeScript
204
+
205
+ This library is written in TypeScript and includes type definitions.
206
+
207
+ ```tsx
208
+ import { ToastType, ToastOptions, Toast } from 'react-notify-lite';
209
+ ```
210
+
211
+ ## Examples
212
+
213
+ ### Multiple Notifications
214
+
215
+ ```tsx
216
+ function Example() {
217
+ const notify = useNotify();
218
+
219
+ const showMultiple = () => {
220
+ notify.success('First notification');
221
+ notify.info('Second notification');
222
+ notify.warning('Third notification');
223
+ };
224
+
225
+ return <button onClick={showMultiple}>Show Multiple</button>;
226
+ }
227
+ ```
228
+
229
+ ### Different Positions
230
+
231
+ ```tsx
232
+ function Example() {
233
+ const notify = useNotify();
234
+
235
+ const showAtPosition = (position: string) => {
236
+ notify.success(`Notification at ${position}`, { position });
237
+ };
238
+
239
+ return (
240
+ <div>
241
+ <button onClick={() => showAtPosition('top-left')}>Top Left</button>
242
+ <button onClick={() => showAtPosition('top-right')}>Top Right</button>
243
+ <button onClick={() => showAtPosition('bottom-center')}>Bottom Center</button>
244
+ </div>
245
+ );
246
+ }
247
+ ```
248
+
249
+ ### Custom Duration
250
+
251
+ ```tsx
252
+ function Example() {
253
+ const notify = useNotify();
254
+
255
+ const showLongNotification = () => {
256
+ notify.info('This will stay for 10 seconds', { duration: 10000 });
257
+ };
258
+
259
+ return <button onClick={showLongNotification}>Show Long Notification</button>;
260
+ }
261
+ ```
262
+
263
+ ## License
264
+
265
+ MIT
266
+
267
+ ## Contributing
268
+
269
+ Contributions are welcome! Please feel free to submit a Pull Request.
270
+
271
+ ## Issues
272
+
273
+ If you find a bug or have a feature request, please open an issue on GitHub.
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { Toast as ToastType } from '../utils/createToast';
3
+ interface ToastProps {
4
+ toast: ToastType;
5
+ onRemove: (id: string) => void;
6
+ }
7
+ declare const Toast: React.FC<ToastProps>;
8
+ export default Toast;
9
+ //# sourceMappingURL=Toast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../src/components/Toast.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE1D,UAAU,UAAU;IAClB,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,QAAA,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAmC/B,CAAC;AAgBF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,16 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { ToastOptions } from '../utils/createToast';
3
+ export interface ToastContextType {
4
+ notify: (message: string, options?: ToastOptions) => void;
5
+ success: (message: string, options?: Omit<ToastOptions, 'type'>) => void;
6
+ error: (message: string, options?: Omit<ToastOptions, 'type'>) => void;
7
+ warning: (message: string, options?: Omit<ToastOptions, 'type'>) => void;
8
+ info: (message: string, options?: Omit<ToastOptions, 'type'>) => void;
9
+ }
10
+ export declare const ToastContext: React.Context<ToastContextType | undefined>;
11
+ interface ToastProviderProps {
12
+ children: ReactNode;
13
+ }
14
+ export declare const ToastProvider: React.FC<ToastProviderProps>;
15
+ export {};
16
+ //# sourceMappingURL=ToastProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../../src/context/ToastProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAwC,SAAS,EAAE,MAAM,OAAO,CAAC;AAE/E,OAAO,EAAsB,YAAY,EAAe,MAAM,sBAAsB,CAAC;AAErF,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1D,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IACzE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IACvE,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IACzE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CACvE;AAED,eAAO,MAAM,YAAY,6CAAyD,CAAC;AAEnF,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAgDtD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { ToastContextType } from '../context/ToastProvider';
2
+ export declare const useNotify: () => ToastContextType;
3
+ //# sourceMappingURL=useNotify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNotify.d.ts","sourceRoot":"","sources":["../../src/hooks/useNotify.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE1E,eAAO,MAAM,SAAS,QAAO,gBAQ5B,CAAC"}
@@ -0,0 +1,93 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ const Toast = ({ toast, onRemove }) => {
6
+ const [isExiting, setIsExiting] = React.useState(false);
7
+ React.useEffect(() => {
8
+ const timer = setTimeout(() => {
9
+ setIsExiting(true);
10
+ setTimeout(() => onRemove(toast.id), 300);
11
+ }, toast.duration);
12
+ return () => clearTimeout(timer);
13
+ }, [toast.id, toast.duration, onRemove]);
14
+ const handleClose = () => {
15
+ setIsExiting(true);
16
+ setTimeout(() => onRemove(toast.id), 300);
17
+ };
18
+ return (React.createElement("div", { className: `toast toast-${toast.type} ${isExiting ? 'toast-exit' : 'toast-enter'}`, role: "alert" },
19
+ React.createElement("div", { className: "toast-content" },
20
+ React.createElement("span", { className: "toast-icon" }, getIcon(toast.type)),
21
+ React.createElement("span", { className: "toast-message" }, toast.message),
22
+ React.createElement("button", { className: "toast-close", onClick: handleClose, "aria-label": "Close notification" }, "\u00D7"))));
23
+ };
24
+ const getIcon = (type) => {
25
+ switch (type) {
26
+ case 'success':
27
+ return '✓';
28
+ case 'error':
29
+ return '✕';
30
+ case 'warning':
31
+ return '⚠';
32
+ case 'info':
33
+ default:
34
+ return 'ℹ';
35
+ }
36
+ };
37
+
38
+ const createToast = (message, options = {}) => {
39
+ const { type = 'info', duration = 3000, position = 'top-right', } = options;
40
+ return {
41
+ id: `toast-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
42
+ message,
43
+ type,
44
+ duration,
45
+ position,
46
+ };
47
+ };
48
+
49
+ const ToastContext = React.createContext(undefined);
50
+ const ToastProvider = ({ children }) => {
51
+ const [toasts, setToasts] = React.useState([]);
52
+ const notify = React.useCallback((message, options) => {
53
+ const toast = createToast(message, options);
54
+ setToasts((prevToasts) => [...prevToasts, toast]);
55
+ }, []);
56
+ const success = React.useCallback((message, options) => {
57
+ notify(message, Object.assign(Object.assign({}, options), { type: 'success' }));
58
+ }, [notify]);
59
+ const error = React.useCallback((message, options) => {
60
+ notify(message, Object.assign(Object.assign({}, options), { type: 'error' }));
61
+ }, [notify]);
62
+ const warning = React.useCallback((message, options) => {
63
+ notify(message, Object.assign(Object.assign({}, options), { type: 'warning' }));
64
+ }, [notify]);
65
+ const info = React.useCallback((message, options) => {
66
+ notify(message, Object.assign(Object.assign({}, options), { type: 'info' }));
67
+ }, [notify]);
68
+ const removeToast = React.useCallback((id) => {
69
+ setToasts((prevToasts) => prevToasts.filter((toast) => toast.id !== id));
70
+ }, []);
71
+ const groupedToasts = toasts.reduce((acc, toast) => {
72
+ if (!acc[toast.position]) {
73
+ acc[toast.position] = [];
74
+ }
75
+ acc[toast.position].push(toast);
76
+ return acc;
77
+ }, {});
78
+ return (React.createElement(ToastContext.Provider, { value: { notify, success, error, warning, info } },
79
+ children,
80
+ Object.entries(groupedToasts).map(([position, positionToasts]) => (React.createElement("div", { key: position, className: `toast-container toast-${position}` }, positionToasts.map((toast) => (React.createElement(Toast, { key: toast.id, toast: toast, onRemove: removeToast }))))))));
81
+ };
82
+
83
+ const useNotify = () => {
84
+ const context = React.useContext(ToastContext);
85
+ if (!context) {
86
+ throw new Error('useNotify must be used within a ToastProvider');
87
+ }
88
+ return context;
89
+ };
90
+
91
+ exports.ToastProvider = ToastProvider;
92
+ exports.useNotify = useNotify;
93
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/components/Toast.tsx","../src/utils/createToast.ts","../src/context/ToastProvider.tsx","../src/hooks/useNotify.ts"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { Toast as ToastType } from '../utils/createToast';\n\ninterface ToastProps {\n toast: ToastType;\n onRemove: (id: string) => void;\n}\n\nconst Toast: React.FC<ToastProps> = ({ toast, onRemove }) => {\n const [isExiting, setIsExiting] = useState(false);\n\n useEffect(() => {\n const timer = setTimeout(() => {\n setIsExiting(true);\n setTimeout(() => onRemove(toast.id), 300);\n }, toast.duration);\n\n return () => clearTimeout(timer);\n }, [toast.id, toast.duration, onRemove]);\n\n const handleClose = () => {\n setIsExiting(true);\n setTimeout(() => onRemove(toast.id), 300);\n };\n\n return (\n <div\n className={`toast toast-${toast.type} ${isExiting ? 'toast-exit' : 'toast-enter'}`}\n role=\"alert\"\n >\n <div className=\"toast-content\">\n <span className=\"toast-icon\">{getIcon(toast.type)}</span>\n <span className=\"toast-message\">{toast.message}</span>\n <button\n className=\"toast-close\"\n onClick={handleClose}\n aria-label=\"Close notification\"\n >\n ×\n </button>\n </div>\n </div>\n );\n};\n\nconst getIcon = (type: string): string => {\n switch (type) {\n case 'success':\n return '✓';\n case 'error':\n return '✕';\n case 'warning':\n return '⚠';\n case 'info':\n default:\n return 'ℹ';\n }\n};\n\nexport default Toast;\n","export type ToastType = 'success' | 'error' | 'warning' | 'info';\n\nexport interface ToastOptions {\n type?: ToastType;\n duration?: number;\n position?: 'top-left' | 'top-right' | 'top-center' | 'bottom-left' | 'bottom-right' | 'bottom-center';\n}\n\nexport interface Toast {\n id: string;\n message: string;\n type: ToastType;\n duration: number;\n position: string;\n}\n\nexport const createToast = (\n message: string,\n options: ToastOptions = {}\n): Toast => {\n const {\n type = 'info',\n duration = 3000,\n position = 'top-right',\n } = options;\n\n return {\n id: `toast-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,\n message,\n type,\n duration,\n position,\n };\n};\n","import React, { createContext, useState, useCallback, ReactNode } from 'react';\nimport Toast from '../components/Toast';\nimport { Toast as ToastType, ToastOptions, createToast } from '../utils/createToast';\n\nexport interface ToastContextType {\n notify: (message: string, options?: ToastOptions) => void;\n success: (message: string, options?: Omit<ToastOptions, 'type'>) => void;\n error: (message: string, options?: Omit<ToastOptions, 'type'>) => void;\n warning: (message: string, options?: Omit<ToastOptions, 'type'>) => void;\n info: (message: string, options?: Omit<ToastOptions, 'type'>) => void;\n}\n\nexport const ToastContext = createContext<ToastContextType | undefined>(undefined);\n\ninterface ToastProviderProps {\n children: ReactNode;\n}\n\nexport const ToastProvider: React.FC<ToastProviderProps> = ({ children }) => {\n const [toasts, setToasts] = useState<ToastType[]>([]);\n\n const notify = useCallback((message: string, options?: ToastOptions) => {\n const toast = createToast(message, options);\n setToasts((prevToasts) => [...prevToasts, toast]);\n }, []);\n\n const success = useCallback((message: string, options?: Omit<ToastOptions, 'type'>) => {\n notify(message, { ...options, type: 'success' });\n }, [notify]);\n\n const error = useCallback((message: string, options?: Omit<ToastOptions, 'type'>) => {\n notify(message, { ...options, type: 'error' });\n }, [notify]);\n\n const warning = useCallback((message: string, options?: Omit<ToastOptions, 'type'>) => {\n notify(message, { ...options, type: 'warning' });\n }, [notify]);\n\n const info = useCallback((message: string, options?: Omit<ToastOptions, 'type'>) => {\n notify(message, { ...options, type: 'info' });\n }, [notify]);\n\n const removeToast = useCallback((id: string) => {\n setToasts((prevToasts) => prevToasts.filter((toast) => toast.id !== id));\n }, []);\n\n const groupedToasts = toasts.reduce((acc, toast) => {\n if (!acc[toast.position]) {\n acc[toast.position] = [];\n }\n acc[toast.position].push(toast);\n return acc;\n }, {} as Record<string, ToastType[]>);\n\n return (\n <ToastContext.Provider value={{ notify, success, error, warning, info }}>\n {children}\n {Object.entries(groupedToasts).map(([position, positionToasts]: [string, ToastType[]]) => (\n <div key={position} className={`toast-container toast-${position}`}>\n {positionToasts.map((toast: ToastType) => (\n <Toast key={toast.id} toast={toast} onRemove={removeToast} />\n ))}\n </div>\n ))}\n </ToastContext.Provider>\n );\n};\n","import { useContext } from 'react';\nimport { ToastContext, ToastContextType } from '../context/ToastProvider';\n\nexport const useNotify = (): ToastContextType => {\n const context = useContext(ToastContext);\n\n if (!context) {\n throw new Error('useNotify must be used within a ToastProvider');\n }\n\n return context;\n};\n"],"names":["useState","useEffect","createContext","useCallback","useContext"],"mappings":";;;;AAQA,MAAM,KAAK,GAAyB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAI;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;IAEjDC,eAAS,CAAC,MAAK;AACb,QAAA,MAAM,KAAK,GAAG,UAAU,CAAC,MAAK;YAC5B,YAAY,CAAC,IAAI,CAAC;AAClB,YAAA,UAAU,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC;AAC3C,QAAA,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC;AAElB,QAAA,OAAO,MAAM,YAAY,CAAC,KAAK,CAAC;AAClC,IAAA,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAExC,MAAM,WAAW,GAAG,MAAK;QACvB,YAAY,CAAC,IAAI,CAAC;AAClB,QAAA,UAAU,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC;AAC3C,IAAA,CAAC;IAED,QACE,6BACE,SAAS,EAAE,e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cAAc,CAAC,GAAG,CAAC,CAAC,KAAgB,MACnC,KAAA,CAAA,aAAA,CAAC,KAAK,EAAA,EAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAA,CAAI,CAC9D,CAAC,CACE,CACP,CAAC,CACoB;AAE5B;;AC/DO,MAAM,SAAS,GAAG,MAAuB;AAC9C,IAAA,MAAM,OAAO,GAAGC,gBAAU,CAAC,YAAY,CAAC;IAExC,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC;IAClE;AAEA,IAAA,OAAO,OAAO;AAChB;;;;;"}
@@ -0,0 +1,4 @@
1
+ export { ToastProvider } from './context/ToastProvider';
2
+ export { useNotify } from './hooks/useNotify';
3
+ export type { ToastType, ToastOptions, Toast } from './utils/createToast';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,90 @@
1
+ import React, { useState, useEffect, createContext, useCallback, useContext } from 'react';
2
+
3
+ const Toast = ({ toast, onRemove }) => {
4
+ const [isExiting, setIsExiting] = useState(false);
5
+ useEffect(() => {
6
+ const timer = setTimeout(() => {
7
+ setIsExiting(true);
8
+ setTimeout(() => onRemove(toast.id), 300);
9
+ }, toast.duration);
10
+ return () => clearTimeout(timer);
11
+ }, [toast.id, toast.duration, onRemove]);
12
+ const handleClose = () => {
13
+ setIsExiting(true);
14
+ setTimeout(() => onRemove(toast.id), 300);
15
+ };
16
+ return (React.createElement("div", { className: `toast toast-${toast.type} ${isExiting ? 'toast-exit' : 'toast-enter'}`, role: "alert" },
17
+ React.createElement("div", { className: "toast-content" },
18
+ React.createElement("span", { className: "toast-icon" }, getIcon(toast.type)),
19
+ React.createElement("span", { className: "toast-message" }, toast.message),
20
+ React.createElement("button", { className: "toast-close", onClick: handleClose, "aria-label": "Close notification" }, "\u00D7"))));
21
+ };
22
+ const getIcon = (type) => {
23
+ switch (type) {
24
+ case 'success':
25
+ return '✓';
26
+ case 'error':
27
+ return '✕';
28
+ case 'warning':
29
+ return '⚠';
30
+ case 'info':
31
+ default:
32
+ return 'ℹ';
33
+ }
34
+ };
35
+
36
+ const createToast = (message, options = {}) => {
37
+ const { type = 'info', duration = 3000, position = 'top-right', } = options;
38
+ return {
39
+ id: `toast-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
40
+ message,
41
+ type,
42
+ duration,
43
+ position,
44
+ };
45
+ };
46
+
47
+ const ToastContext = createContext(undefined);
48
+ const ToastProvider = ({ children }) => {
49
+ const [toasts, setToasts] = useState([]);
50
+ const notify = useCallback((message, options) => {
51
+ const toast = createToast(message, options);
52
+ setToasts((prevToasts) => [...prevToasts, toast]);
53
+ }, []);
54
+ const success = useCallback((message, options) => {
55
+ notify(message, Object.assign(Object.assign({}, options), { type: 'success' }));
56
+ }, [notify]);
57
+ const error = useCallback((message, options) => {
58
+ notify(message, Object.assign(Object.assign({}, options), { type: 'error' }));
59
+ }, [notify]);
60
+ const warning = useCallback((message, options) => {
61
+ notify(message, Object.assign(Object.assign({}, options), { type: 'warning' }));
62
+ }, [notify]);
63
+ const info = useCallback((message, options) => {
64
+ notify(message, Object.assign(Object.assign({}, options), { type: 'info' }));
65
+ }, [notify]);
66
+ const removeToast = useCallback((id) => {
67
+ setToasts((prevToasts) => prevToasts.filter((toast) => toast.id !== id));
68
+ }, []);
69
+ const groupedToasts = toasts.reduce((acc, toast) => {
70
+ if (!acc[toast.position]) {
71
+ acc[toast.position] = [];
72
+ }
73
+ acc[toast.position].push(toast);
74
+ return acc;
75
+ }, {});
76
+ return (React.createElement(ToastContext.Provider, { value: { notify, success, error, warning, info } },
77
+ children,
78
+ Object.entries(groupedToasts).map(([position, positionToasts]) => (React.createElement("div", { key: position, className: `toast-container toast-${position}` }, positionToasts.map((toast) => (React.createElement(Toast, { key: toast.id, toast: toast, onRemove: removeToast }))))))));
79
+ };
80
+
81
+ const useNotify = () => {
82
+ const context = useContext(ToastContext);
83
+ if (!context) {
84
+ throw new Error('useNotify must be used within a ToastProvider');
85
+ }
86
+ return context;
87
+ };
88
+
89
+ export { ToastProvider, useNotify };
90
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/components/Toast.tsx","../src/utils/createToast.ts","../src/context/ToastProvider.tsx","../src/hooks/useNotify.ts"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { Toast as ToastType } from '../utils/createToast';\n\ninterface ToastProps {\n toast: ToastType;\n onRemove: (id: string) => void;\n}\n\nconst Toast: React.FC<ToastProps> = ({ toast, onRemove }) => {\n const [isExiting, setIsExiting] = useState(false);\n\n useEffect(() => {\n const timer = setTimeout(() => {\n setIsExiting(true);\n setTimeout(() => onRemove(toast.id), 300);\n }, toast.duration);\n\n return () => clearTimeout(timer);\n }, [toast.id, toast.duration, onRemove]);\n\n const handleClose = () => {\n setIsExiting(true);\n setTimeout(() => onRemove(toast.id), 300);\n };\n\n return (\n <div\n className={`toast toast-${toast.type} ${isExiting ? 'toast-exit' : 'toast-enter'}`}\n role=\"alert\"\n >\n <div className=\"toast-content\">\n <span className=\"toast-icon\">{getIcon(toast.type)}</span>\n <span className=\"toast-message\">{toast.message}</span>\n <button\n className=\"toast-close\"\n onClick={handleClose}\n aria-label=\"Close notification\"\n >\n ×\n </button>\n </div>\n </div>\n );\n};\n\nconst getIcon = (type: string): string => {\n switch (type) {\n case 'success':\n return '✓';\n case 'error':\n return '✕';\n case 'warning':\n return '⚠';\n case 'info':\n default:\n return 'ℹ';\n }\n};\n\nexport default Toast;\n","export type ToastType = 'success' | 'error' | 'warning' | 'info';\n\nexport interface ToastOptions {\n type?: ToastType;\n duration?: number;\n position?: 'top-left' | 'top-right' | 'top-center' | 'bottom-left' | 'bottom-right' | 'bottom-center';\n}\n\nexport interface Toast {\n id: string;\n message: string;\n type: ToastType;\n duration: number;\n position: string;\n}\n\nexport const createToast = (\n message: string,\n options: ToastOptions = {}\n): Toast => {\n const {\n type = 'info',\n duration = 3000,\n position = 'top-right',\n } = options;\n\n return {\n id: `toast-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,\n message,\n type,\n duration,\n position,\n };\n};\n","import React, { createContext, useState, useCallback, ReactNode } from 'react';\nimport Toast from '../components/Toast';\nimport { Toast as ToastType, ToastOptions, createToast } from '../utils/createToast';\n\nexport interface ToastContextType {\n notify: (message: string, options?: ToastOptions) => void;\n success: (message: string, options?: Omit<ToastOptions, 'type'>) => void;\n error: (message: string, options?: Omit<ToastOptions, 'type'>) => void;\n warning: (message: string, options?: Omit<ToastOptions, 'type'>) => void;\n info: (message: string, options?: Omit<ToastOptions, 'type'>) => void;\n}\n\nexport const ToastContext = createContext<ToastContextType | undefined>(undefined);\n\ninterface ToastProviderProps {\n children: ReactNode;\n}\n\nexport const ToastProvider: React.FC<ToastProviderProps> = ({ children }) => {\n const [toasts, setToasts] = useState<ToastType[]>([]);\n\n const notify = useCallback((message: string, options?: ToastOptions) => {\n const toast = createToast(message, options);\n setToasts((prevToasts) => [...prevToasts, toast]);\n }, []);\n\n const success = useCallback((message: string, options?: Omit<ToastOptions, 'type'>) => {\n notify(message, { ...options, type: 'success' });\n }, [notify]);\n\n const error = useCallback((message: string, options?: Omit<ToastOptions, 'type'>) => {\n notify(message, { ...options, type: 'error' });\n }, [notify]);\n\n const warning = useCallback((message: string, options?: Omit<ToastOptions, 'type'>) => {\n notify(message, { ...options, type: 'warning' });\n }, [notify]);\n\n const info = useCallback((message: string, options?: Omit<ToastOptions, 'type'>) => {\n notify(message, { ...options, type: 'info' });\n }, [notify]);\n\n const removeToast = useCallback((id: string) => {\n setToasts((prevToasts) => prevToasts.filter((toast) => toast.id !== id));\n }, []);\n\n const groupedToasts = toasts.reduce((acc, toast) => {\n if (!acc[toast.position]) {\n acc[toast.position] = [];\n }\n acc[toast.position].push(toast);\n return acc;\n }, {} as Record<string, ToastType[]>);\n\n return (\n <ToastContext.Provider value={{ notify, success, error, warning, info }}>\n {children}\n {Object.entries(groupedToasts).map(([position, positionToasts]: [string, ToastType[]]) => (\n <div key={position} className={`toast-container toast-${position}`}>\n {positionToasts.map((toast: ToastType) => (\n <Toast key={toast.id} toast={toast} onRemove={removeToast} />\n ))}\n </div>\n ))}\n </ToastContext.Provider>\n );\n};\n","import { useContext } from 'react';\nimport { ToastContext, ToastContextType } from '../context/ToastProvider';\n\nexport const useNotify = (): ToastContextType => {\n const context = useContext(ToastContext);\n\n if (!context) {\n throw new Error('useNotify must be used within a ToastProvider');\n }\n\n return context;\n};\n"],"names":[],"mappings":";;AAQA,MAAM,KAAK,GAAyB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAI;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAEjD,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,KAAK,GAAG,UAAU,CAAC,MAAK;YAC5B,YAAY,CAAC,IAAI,CAAC;AAClB,YAAA,UAAU,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC;AAC3C,QAAA,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC;AAElB,QAAA,OAAO,MAAM,YAAY,CAAC,KAAK,CAAC;AAClC,IAAA,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAExC,MAAM,WAAW,GAAG,MAAK;QACvB,YAAY,CAAC,IAAI,CAAC;AAClB,QAAA,UAAU,CAAC,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,EAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAA,sBAAA,EAAyB,QAAQ,CAAA,CAAE,IAC/D,cAAc,CAAC,GAAG,CAAC,CAAC,KAAgB,MACnC,KAAA,CAAA,aAAA,CAAC,KAAK,EAAA,EAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAA,CAAI,CAC9D,CAAC,CACE,CACP,CAAC,CACoB;AAE5B;;AC/DO,MAAM,SAAS,GAAG,MAAuB;AAC9C,IAAA,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC;IAExC,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC;IAClE;AAEA,IAAA,OAAO,OAAO;AAChB;;;;"}
@@ -0,0 +1,15 @@
1
+ export type ToastType = 'success' | 'error' | 'warning' | 'info';
2
+ export interface ToastOptions {
3
+ type?: ToastType;
4
+ duration?: number;
5
+ position?: 'top-left' | 'top-right' | 'top-center' | 'bottom-left' | 'bottom-right' | 'bottom-center';
6
+ }
7
+ export interface Toast {
8
+ id: string;
9
+ message: string;
10
+ type: ToastType;
11
+ duration: number;
12
+ position: string;
13
+ }
14
+ export declare const createToast: (message: string, options?: ToastOptions) => Toast;
15
+ //# sourceMappingURL=createToast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createToast.d.ts","sourceRoot":"","sources":["../../src/utils/createToast.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEjE,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,eAAe,CAAC;CACvG;AAED,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,WAAW,GACtB,SAAS,MAAM,EACf,UAAS,YAAiB,KACzB,KAcF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "react-notify-lite",
3
+ "version": "1.0.0",
4
+ "description": "A lightweight and customizable React notification library with TypeScript support. Features multiple notification types, 6 positioning options, auto-dismiss, and smooth animations.",
5
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/index.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "sideEffects": false,
9
+ "files": [
10
+ "dist",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "scripts": {
15
+ "build": "rollup -c",
16
+ "dev": "rollup -c -w",
17
+ "prepare": "npm run build",
18
+ "prepublishOnly": "npm run build"
19
+ },
20
+ "keywords": [
21
+ "react",
22
+ "react-notification",
23
+ "notification",
24
+ "toast",
25
+ "toast-notification",
26
+ "alert",
27
+ "notify",
28
+ "react-component",
29
+ "react-toast",
30
+ "lightweight",
31
+ "typescript",
32
+ "notifications",
33
+ "message",
34
+ "snackbar",
35
+ "react-alert"
36
+ ],
37
+ "author": "Harpinder Singh",
38
+ "license": "MIT",
39
+ "peerDependencies": {
40
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
41
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
42
+ },
43
+ "devDependencies": {
44
+ "@rollup/plugin-commonjs": "^25.0.7",
45
+ "@rollup/plugin-node-resolve": "^15.2.3",
46
+ "@rollup/plugin-typescript": "^11.1.6",
47
+ "@types/react": "^18.2.48",
48
+ "@types/react-dom": "^18.2.18",
49
+ "postcss": "^8.4.33",
50
+ "react": "^18.2.0",
51
+ "react-dom": "^18.2.0",
52
+ "rollup": "^4.9.6",
53
+ "rollup-plugin-peer-deps-external": "^2.2.4",
54
+ "rollup-plugin-postcss": "^4.0.2",
55
+ "tslib": "^2.6.2",
56
+ "typescript": "^5.3.3"
57
+ },
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "https://github.com/harpinderdev/react-notify-lite.git"
61
+ },
62
+ "bugs": {
63
+ "url": "https://github.com/harpinderdev/react-notify-lite/issues"
64
+ },
65
+ "homepage": "https://github.com/harpinderdev/react-notify-lite#readme"
66
+ }