@rentnerkev/toasts 1.0.1 → 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.
- package/README.md +146 -74
- package/dist/Components/CustomToast.d.ts +1 -1
- package/dist/Components/CustomToast.d.ts.map +1 -1
- package/dist/Components/CustomToast.js +5 -4
- package/dist/Components/CustomToast.js.map +1 -1
- package/dist/Components/Toast.d.ts +1 -1
- package/dist/Components/Toast.d.ts.map +1 -1
- package/dist/Components/Toast.js +4 -2
- package/dist/Components/Toast.js.map +1 -1
- package/dist/Components/ToastProvider.d.ts +1 -1
- package/dist/Components/ToastProvider.d.ts.map +1 -1
- package/dist/Components/ToastProvider.js +2 -2
- package/dist/Components/ToastProvider.js.map +1 -1
- package/dist/Hooks/useToastLogic.d.ts +3 -7
- package/dist/Hooks/useToastLogic.d.ts.map +1 -1
- package/dist/Hooks/useToastLogic.js +1 -64
- package/dist/Hooks/useToastLogic.js.map +1 -1
- package/dist/i18n.d.ts +10 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +21 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/toast.d.ts +6 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/toast.js +67 -0
- package/dist/toast.js.map +1 -0
- package/dist/toastStore.d.ts +8 -0
- package/dist/toastStore.d.ts.map +1 -0
- package/dist/toastStore.js +100 -0
- package/dist/toastStore.js.map +1 -0
- package/dist/types.d.ts +40 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +22 -5
- package/tailwind.css +12 -0
package/README.md
CHANGED
|
@@ -1,67 +1,109 @@
|
|
|
1
1
|
# @rentnerkev/toasts
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
Statusvarianten, Fortschrittsanzeige, Markdown-Links und Tailwind CSS.
|
|
3
|
+
Accessible and customizable React toast notifications with four status variants, progress indicators, safe Markdown links, localization, and Tailwind CSS styling.
|
|
5
4
|
|
|
6
5
|
## Installation
|
|
7
6
|
|
|
7
|
+
Install the package with npm:
|
|
8
|
+
|
|
8
9
|
```bash
|
|
9
|
-
|
|
10
|
+
npm install @rentnerkev/toasts
|
|
10
11
|
```
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
Or with Bun:
|
|
13
14
|
|
|
14
15
|
```bash
|
|
15
|
-
|
|
16
|
+
bun add @rentnerkev/toasts
|
|
16
17
|
```
|
|
17
18
|
|
|
18
|
-
React, React DOM, Motion
|
|
19
|
-
Consumer bereitgestellt.
|
|
19
|
+
React, React DOM, Motion, and Lucide React are peer dependencies supplied by the consuming application.
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Set up the provider
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Der `ToastProvider` rendert die Toasts. Binde ihn einmal oberhalb des
|
|
26
|
-
Bereichs ein, aus dem Toasts angezeigt werden sollen:
|
|
23
|
+
Render `ToastProvider` once above the part of the application that creates notifications:
|
|
27
24
|
|
|
28
25
|
```tsx
|
|
29
26
|
import { ToastProvider } from '@rentnerkev/toasts'
|
|
30
27
|
|
|
31
28
|
export function App() {
|
|
32
29
|
return (
|
|
33
|
-
<ToastProvider position="bottom-right">
|
|
30
|
+
<ToastProvider position="bottom-right" locale="en">
|
|
34
31
|
<MainApp />
|
|
35
32
|
</ToastProvider>
|
|
36
33
|
)
|
|
37
34
|
}
|
|
38
35
|
```
|
|
39
36
|
|
|
40
|
-
|
|
37
|
+
## Show a toast
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
werden. Die Funktion liefert die ID des neuen Toasts zurück:
|
|
39
|
+
The namespace API provides a named method for each status variant. Every method returns the new toast ID:
|
|
44
40
|
|
|
45
41
|
```tsx
|
|
46
|
-
import {
|
|
42
|
+
import { toast } from '@rentnerkev/toasts'
|
|
47
43
|
|
|
48
|
-
const toastId =
|
|
44
|
+
const toastId = toast.success('Your changes were saved.', {
|
|
45
|
+
title: 'Saved',
|
|
46
|
+
duration: 5000,
|
|
47
|
+
})
|
|
49
48
|
```
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
The imperative methods are intended for browser event handlers and other client-only functions. The store lives once per JavaScript process, so never call them during server rendering. Guard any mount effect against React Strict Mode's repeated development execution to avoid creating duplicate toasts.
|
|
51
|
+
|
|
52
|
+
## Dismiss and update toasts
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
Dismiss one toast by ID, or clear visible and queued toasts together with all expiration timers:
|
|
54
55
|
|
|
55
56
|
```tsx
|
|
56
|
-
|
|
57
|
+
toast.dismiss(toastId)
|
|
58
|
+
toast.dismissAll()
|
|
59
|
+
```
|
|
57
60
|
|
|
58
|
-
|
|
61
|
+
`update()` keeps the toast ID and position. Only provided fields change; `title: null` removes an existing title. A new `duration` restarts expiration and the progress indicator:
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
const updated = toast.update(toastId, {
|
|
65
|
+
content: 'The file was saved.',
|
|
66
|
+
title: 'Complete',
|
|
67
|
+
type: 'success',
|
|
68
|
+
duration: 4000,
|
|
69
|
+
})
|
|
59
70
|
```
|
|
60
71
|
|
|
61
|
-
|
|
72
|
+
The method returns `false` for an unknown or already dismissed ID and `true` after a successful update.
|
|
62
73
|
|
|
63
|
-
|
|
64
|
-
|
|
74
|
+
## Track a promise
|
|
75
|
+
|
|
76
|
+
`toast.promise()` immediately creates a persistent info toast, then updates the same ID to `success` or `error`. The returned promise preserves the original fulfillment value or rejection reason:
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
const user = await toast.promise(
|
|
80
|
+
() => fetch('/api/user').then((response) => response.json()),
|
|
81
|
+
{
|
|
82
|
+
loading: 'Loading user…',
|
|
83
|
+
success: (result) => ({
|
|
84
|
+
content: `${result.name} was loaded.`,
|
|
85
|
+
title: 'Complete',
|
|
86
|
+
}),
|
|
87
|
+
error: (error) => ({
|
|
88
|
+
content: error instanceof Error ? error.message : 'Unknown error',
|
|
89
|
+
title: 'Loading failed',
|
|
90
|
+
}),
|
|
91
|
+
duration: 5000,
|
|
92
|
+
},
|
|
93
|
+
)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The `success` and `error` values accept text, an object containing `content`, `title`, and `duration`, or a resolver function. A status-specific duration overrides the shared duration. If the loading toast is dismissed before the promise settles, it is not recreated.
|
|
97
|
+
|
|
98
|
+
## Variants, duration, and compatibility
|
|
99
|
+
|
|
100
|
+
Available variants are `success`, `error`, `info`, and `warning`. Each shorthand method uses the same option shape:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
toast.info(content: string, options?: ToastOptions): ToastId
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The previous positional API remains available as a backward-compatible alias:
|
|
65
107
|
|
|
66
108
|
```ts
|
|
67
109
|
customToast(
|
|
@@ -69,39 +111,57 @@ customToast(
|
|
|
69
111
|
title?: string,
|
|
70
112
|
type?: ToastType,
|
|
71
113
|
duration?: number,
|
|
72
|
-
):
|
|
114
|
+
): ToastId
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`removeToast(toastId)` also remains available as the compatible single-toast removal function.
|
|
118
|
+
|
|
119
|
+
The default duration is 6000 milliseconds. Set `duration: 0` to disable automatic expiration. Negative, non-finite, and otherwise invalid values fall back to the default; positive values are capped at a safe `setTimeout` limit.
|
|
120
|
+
|
|
121
|
+
## Localization
|
|
122
|
+
|
|
123
|
+
German accessible system messages remain the default for backward compatibility. Set `locale="en"` for the English catalog, or override individual messages with a typed `Partial<ToastMessages>`:
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
<ToastProvider
|
|
127
|
+
locale="en"
|
|
128
|
+
messages={{ closeNotification: 'Dismiss notification' }}
|
|
129
|
+
>
|
|
130
|
+
<App />
|
|
131
|
+
</ToastProvider>
|
|
73
132
|
```
|
|
74
133
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
`
|
|
78
|
-
|
|
79
|
-
|
|
134
|
+
The message catalog and resolver are exported as `toastMessageCatalog` and `resolveToastMessages`.
|
|
135
|
+
|
|
136
|
+
## `ToastProvider` props
|
|
137
|
+
|
|
138
|
+
| Prop | Type | Default | Description |
|
|
139
|
+
| -------------- | ------------------------ | ---------------- | ------------------------------------------------------- |
|
|
140
|
+
| `position` | `ToastPosition` | `'bottom-right'` | Screen position used for the toast stack. |
|
|
141
|
+
| `customDesign` | `ToastCustomDesign` | `undefined` | Overrides Tailwind classes for individual visual parts. |
|
|
142
|
+
| `className` | `string` | `undefined` | Additional Tailwind classes applied to every toast. |
|
|
143
|
+
| `locale` | `'de' \| 'en'` | `'de'` | Selects the accessible system-message catalog. |
|
|
144
|
+
| `messages` | `Partial<ToastMessages>` | `undefined` | Overrides individual system messages. |
|
|
145
|
+
| `children` | `ReactNode` | - | Application content rendered by the provider. |
|
|
80
146
|
|
|
81
|
-
##
|
|
147
|
+
## Tailwind CSS
|
|
82
148
|
|
|
83
|
-
|
|
84
|
-
Bei Tailwind CSS v4 muss das Paket als Quelle angegeben werden:
|
|
149
|
+
Import the package entry after Tailwind CSS in your application stylesheet:
|
|
85
150
|
|
|
86
151
|
```css
|
|
87
152
|
@import 'tailwindcss';
|
|
88
|
-
@
|
|
153
|
+
@import '@rentnerkev/toasts/tailwind.css';
|
|
89
154
|
```
|
|
90
155
|
|
|
91
|
-
|
|
156
|
+
The package entry scans only the published JavaScript under `dist` and provides the shared theme tokens `primary`, `primary-hover`, `background-dark`, `surface-dark`, `input-dark`, `border-dark`, `secondary-text`, and `muted-foreground`. Override them with a later `@theme` block when needed.
|
|
92
157
|
|
|
93
|
-
|
|
94
|
-
| :------------- | :------------------ | :--------------- | :---------------------------------------------------- |
|
|
95
|
-
| `position` | `ToastPosition` | `'bottom-right'` | Position der Toasts. |
|
|
96
|
-
| `customDesign` | `ToastCustomDesign` | `undefined` | Überschreibt die Tailwind-Klassen einzelner Bereiche. |
|
|
97
|
-
| `className` | `string` | `undefined` | Zusätzliche Tailwind-Klassen für jeden Toast. |
|
|
98
|
-
| `children` | `ReactNode` | – | Inhalt der Anwendung. |
|
|
158
|
+
### Custom design
|
|
99
159
|
|
|
100
|
-
|
|
160
|
+
Design overrides are Tailwind class strings:
|
|
101
161
|
|
|
102
162
|
```tsx
|
|
103
163
|
const customDesign = {
|
|
104
|
-
successWrapper: '
|
|
164
|
+
successWrapper: 'border-l-4 border-green-500 bg-green-100',
|
|
105
165
|
successProgress: 'bg-green-600',
|
|
106
166
|
linkText: 'text-blue-600 hover:underline',
|
|
107
167
|
titleText: 'font-bold text-green-900',
|
|
@@ -115,61 +175,73 @@ const customDesign = {
|
|
|
115
175
|
</ToastProvider>
|
|
116
176
|
```
|
|
117
177
|
|
|
118
|
-
|
|
178
|
+
Available `ToastCustomDesign` fields:
|
|
119
179
|
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
| `successWrapper`, `errorWrapper`, `infoWrapper`, `warningWrapper` |
|
|
123
|
-
| `successIcon`, `errorIcon`, `infoIcon`, `warningIcon` |
|
|
124
|
-
| `successProgress`, `errorProgress`, `infoProgress`, `warningProgress` |
|
|
125
|
-
| `titleText` |
|
|
126
|
-
| `contentText` |
|
|
127
|
-
| `linkText` |
|
|
128
|
-
| `closeButton` |
|
|
129
|
-
| `copyButton` |
|
|
180
|
+
| Fields | Purpose |
|
|
181
|
+
| --------------------------------------------------------------------- | ---------------------------------------- |
|
|
182
|
+
| `successWrapper`, `errorWrapper`, `infoWrapper`, `warningWrapper` | Toast container classes for each status. |
|
|
183
|
+
| `successIcon`, `errorIcon`, `infoIcon`, `warningIcon` | Status icon classes. |
|
|
184
|
+
| `successProgress`, `errorProgress`, `infoProgress`, `warningProgress` | Progress indicator classes. |
|
|
185
|
+
| `titleText` | Title classes. |
|
|
186
|
+
| `contentText` | Content classes. |
|
|
187
|
+
| `linkText` | Markdown link classes. |
|
|
188
|
+
| `closeButton` | Dismiss button classes. |
|
|
189
|
+
| `copyButton` | Error-copy button classes. |
|
|
130
190
|
|
|
131
|
-
## Links
|
|
191
|
+
## Links and accessibility
|
|
132
192
|
|
|
133
|
-
|
|
134
|
-
öffnen sich in einem neuen Tab. Es werden nur `http`- und `https`-URLs
|
|
135
|
-
verlinkt; andere Schemes bleiben als Text sichtbar.
|
|
193
|
+
Markdown links written as `[label](URL)` are interactive and open in a new tab. Only `http` and `https` URLs become links; unsupported schemes remain visible as plain text.
|
|
136
194
|
|
|
137
195
|
```tsx
|
|
138
|
-
|
|
139
|
-
'
|
|
140
|
-
|
|
141
|
-
'info',
|
|
142
|
-
)
|
|
196
|
+
toast.info('Open [the ticket](https://example.com/tickets/45).', {
|
|
197
|
+
title: 'New ticket',
|
|
198
|
+
})
|
|
143
199
|
```
|
|
144
200
|
|
|
145
|
-
|
|
146
|
-
und Inhalts. Die Toast-Varianten verwenden für normale Meldungen eine
|
|
147
|
-
polite Live-Region und für Fehler eine assertive Meldung.
|
|
201
|
+
Error toasts also provide a button that copies the title and content. Normal notifications use a polite live region; errors use an assertive announcement.
|
|
148
202
|
|
|
149
203
|
## TypeScript
|
|
150
204
|
|
|
151
|
-
|
|
205
|
+
Public types are available from the package root:
|
|
152
206
|
|
|
153
207
|
```tsx
|
|
154
208
|
import type {
|
|
209
|
+
ToastApi,
|
|
210
|
+
ToastContentOptions,
|
|
155
211
|
ToastCustomDesign,
|
|
212
|
+
ToastId,
|
|
213
|
+
ToastLocale,
|
|
214
|
+
ToastMessages,
|
|
215
|
+
ToastOptions,
|
|
156
216
|
ToastPosition,
|
|
217
|
+
ToastPromiseOptions,
|
|
157
218
|
ToastProviderProps,
|
|
158
219
|
ToastType,
|
|
220
|
+
ToastUpdateOptions,
|
|
159
221
|
} from '@rentnerkev/toasts'
|
|
160
222
|
```
|
|
161
223
|
|
|
162
|
-
##
|
|
224
|
+
## Public entry points
|
|
225
|
+
|
|
226
|
+
| Entry point | Purpose |
|
|
227
|
+
| --------------------------------- | ----------------------------------------------------------------------------- |
|
|
228
|
+
| `@rentnerkev/toasts` | Provider, namespace API, compatibility functions, messages, and public types. |
|
|
229
|
+
| `@rentnerkev/toasts/toast` | Namespace API and compatibility functions. |
|
|
230
|
+
| `@rentnerkev/toasts/messages` | Locale catalog, resolver, and message types. |
|
|
231
|
+
| `@rentnerkev/toasts/types` | Toast API, provider, and design types. |
|
|
232
|
+
| `@rentnerkev/toasts/tailwind.css` | Tailwind source and shared theme tokens. |
|
|
233
|
+
| `@rentnerkev/toasts/package.json` | Package metadata. |
|
|
234
|
+
|
|
235
|
+
## Development
|
|
163
236
|
|
|
164
237
|
```bash
|
|
165
238
|
bun install
|
|
166
|
-
bun run
|
|
239
|
+
bun run verify
|
|
167
240
|
bun run playground:dev
|
|
168
241
|
```
|
|
169
242
|
|
|
170
|
-
|
|
171
|
-
nicht Bestandteil des npm-Pakets.
|
|
243
|
+
`bun run verify` checks types, lint, formatting, tests, the package build, and the published package contents. The playground remains a local development and test environment and is not included in the npm package.
|
|
172
244
|
|
|
173
|
-
##
|
|
245
|
+
## License
|
|
174
246
|
|
|
175
|
-
MIT
|
|
247
|
+
MIT. See [LICENSE](./LICENSE).
|
|
@@ -3,6 +3,6 @@ import type { CustomToastProps } from '../types.js';
|
|
|
3
3
|
type CustomToastComponentProps = CustomToastProps & {
|
|
4
4
|
ref?: Ref<HTMLDivElement>;
|
|
5
5
|
};
|
|
6
|
-
export declare function CustomToast({ toast, position, onRemove, customDesign, className, ref, }: CustomToastComponentProps): import("react").JSX.Element;
|
|
6
|
+
export declare function CustomToast({ toast, position, onRemove, customDesign, className, messages, ref, }: CustomToastComponentProps): import("react").JSX.Element;
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=CustomToast.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomToast.d.ts","sourceRoot":"","sources":["../../src/Components/CustomToast.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAQnD,KAAK,yBAAyB,GAAG,gBAAgB,GAAG;IAChD,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAA;CAC5B,CAAA;AAED,wBAAgB,WAAW,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,GAAG,GACN,EAAE,yBAAyB,+
|
|
1
|
+
{"version":3,"file":"CustomToast.d.ts","sourceRoot":"","sources":["../../src/Components/CustomToast.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAQnD,KAAK,yBAAyB,GAAG,gBAAgB,GAAG;IAChD,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAA;CAC5B,CAAA;AAED,wBAAgB,WAAW,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,GAAG,GACN,EAAE,yBAAyB,+BAmH3B"}
|
|
@@ -3,19 +3,20 @@ import { Check, Copy, X } from 'lucide-react';
|
|
|
3
3
|
import { motion } from 'motion/react';
|
|
4
4
|
import { closeButtonIconTransition, closeButtonIconVariants, } from '../Animations/toastAnimations.js';
|
|
5
5
|
import { useCustomToastLogic } from '../Hooks/useCustomToastLogic.js';
|
|
6
|
-
export function CustomToast({ toast, position, onRemove, customDesign, className, ref, }) {
|
|
6
|
+
export function CustomToast({ toast, position, onRemove, customDesign, className, messages, ref, }) {
|
|
7
7
|
const { state, handler } = useCustomToastLogic({
|
|
8
8
|
toast,
|
|
9
9
|
position,
|
|
10
10
|
onRemove,
|
|
11
11
|
customDesign,
|
|
12
12
|
className,
|
|
13
|
+
messages,
|
|
13
14
|
});
|
|
14
15
|
return (_jsxs(motion.div, { ref: ref, layout: "position", initial: state.initialAnimation, animate: state.animate, exit: state.exitAnimation, transition: state.transition, drag: "x", dragConstraints: { left: 0, right: 0 }, dragElastic: 0.7, whileDrag: state.dragAnimation, onDragEnd: handler.handleDragEnd, role: toast.type === 'error' ? 'alert' : 'status', "aria-live": toast.type === 'error' ? 'assertive' : 'polite', "aria-atomic": "true", className: state.wrapperClasses, children: [_jsx("div", { className: "mt-0.5 shrink-0", children: state.toastIcon }), _jsxs("div", { className: "flex flex-col gap-1 flex-1 min-w-0", children: [toast.title && (_jsx("span", { className: `text-sm font-semibold tracking-tight wrap-break-word ${customDesign?.titleText || 'text-gray-50'}`, children: state.parsedTitle })), _jsx("span", { className: `text-sm wrap-break-word leading-snug ${toast.title ? customDesign?.contentText || 'text-gray-300' : 'font-medium'}`, children: state.parsedContent })] }), _jsxs("div", { className: "-mr-1.5 -mt-1.5 flex shrink-0 items-center gap-1", children: [toast.type === 'error' && (_jsxs(motion.button, { type: "button", onClick: handler.handleCopyError, whileHover: { scale: 1.15 }, whileTap: { scale: 0.85 }, "aria-label": state.copied
|
|
15
|
-
?
|
|
16
|
-
:
|
|
16
|
+
? messages.errorCopied
|
|
17
|
+
: messages.copyError, className: "relative group p-1.5 cursor-pointer rounded-full shrink-0", children: [_jsx("span", { className: "absolute inset-0 rounded-full bg-white/10 opacity-0 group-hover:opacity-100 transition-opacity duration-300" }), state.copied ? (_jsx(Check, { size: 14, "aria-hidden": "true", className: `relative z-10 transition-colors duration-300 ${customDesign?.copyButton || 'text-emerald-300 group-hover:text-emerald-200'}` })) : (_jsx(Copy, { size: 14, "aria-hidden": "true", className: `relative z-10 transition-colors duration-300 ${customDesign?.copyButton || 'text-gray-400 group-hover:text-white'}` }))] })), _jsxs(motion.button, { type: "button", onClick: () => onRemove(toast.id), whileHover: { scale: 1.15 }, whileTap: { scale: 0.85 }, "aria-label": messages.closeNotification, className: "relative group p-1.5 cursor-pointer rounded-full shrink-0 overflow-hidden", children: [_jsx("span", { className: "absolute inset-0 rounded-full bg-white/10 opacity-0 group-hover:opacity-100 transition-opacity duration-300" }), _jsx(motion.div, { transition: closeButtonIconTransition, variants: closeButtonIconVariants, initial: "idle", whileHover: "hover", className: "relative z-10", children: _jsx(X, { size: 14, "aria-hidden": "true", className: `transition-colors duration-300 ${customDesign?.closeButton || 'text-gray-400 group-hover:text-white'}` }) })] })] }), toast.duration > 0 && (_jsx(motion.div, { initial: { width: state.startingWidth }, animate: { width: '0%' }, transition: {
|
|
17
18
|
duration: state.progressDuration,
|
|
18
19
|
ease: 'linear',
|
|
19
|
-
}, "aria-hidden": "true", className: `absolute bottom-0 left-0 h-1 ${state.progressClasses}` }))] }));
|
|
20
|
+
}, "aria-hidden": "true", className: `absolute bottom-0 left-0 h-1 ${state.progressClasses}` }, `${toast.id}-${toast.createdAt}`))] }));
|
|
20
21
|
}
|
|
21
22
|
//# sourceMappingURL=CustomToast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomToast.js","sourceRoot":"","sources":["../../src/Components/CustomToast.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EACH,yBAAyB,EACzB,uBAAuB,GAC1B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AAMrE,MAAM,UAAU,WAAW,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,GAAG,GACqB;IACxB,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,mBAAmB,CAAC;QAC3C,KAAK;QACL,QAAQ;QACR,QAAQ;QACR,YAAY;QACZ,SAAS;
|
|
1
|
+
{"version":3,"file":"CustomToast.js","sourceRoot":"","sources":["../../src/Components/CustomToast.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE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B,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,gBACb,QAAQ,CAAC,iBAAiB,EACtC,SAAS,EAAC,2EAA2E,aAErF,eAAM,SAAS,EAAC,6GAA6G,GAAG,EAChI,KAAC,MAAM,CAAC,GAAG,IACP,UAAU,EAAE,yBAAyB,EACrC,QAAQ,EAAE,uBAAuB,EACjC,OAAO,EAAC,MAAM,EACd,UAAU,EAAC,OAAO,EAClB,SAAS,EAAC,eAAe,YAEzB,KAAC,CAAC,IACE,IAAI,EAAE,EAAE,iBACI,MAAM,EAClB,SAAS,EAAE,kCAAkC,YAAY,EAAE,WAAW,IAAI,sCAAsC,EAAE,GACpH,GACO,IACD,IACd,EAEL,KAAK,CAAC,QAAQ,GAAG,CAAC,IAAI,CACnB,KAAC,MAAM,CAAC,GAAG,IAEP,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,aAAa,EAAE,EACvC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EACxB,UAAU,EAAE;oBACR,QAAQ,EAAE,KAAK,CAAC,gBAAgB;oBAChC,IAAI,EAAE,QAAQ;iBACjB,iBACW,MAAM,EAClB,SAAS,EAAE,gCAAgC,KAAK,CAAC,eAAe,EAAE,IAR7D,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,SAAS,EAAE,CASvC,CACL,IACQ,CAChB,CAAA;AACL,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ToastProps } from '../types.js';
|
|
2
|
-
export declare function Toast({ customDesign, position, className }: ToastProps): import("react").JSX.Element;
|
|
2
|
+
export declare function Toast({ customDesign, position, className, locale, messages, }: ToastProps): import("react").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=Toast.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../src/Components/Toast.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../src/Components/Toast.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAI7C,wBAAgB,KAAK,CAAC,EAClB,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,MAAa,EACb,QAAQ,GACX,EAAE,UAAU,+BA8CZ"}
|
package/dist/Components/Toast.js
CHANGED
|
@@ -2,8 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useToastLogic } from '../Hooks/useToastLogic.js';
|
|
3
3
|
import { CustomToast } from './CustomToast.js';
|
|
4
4
|
import { AnimatePresence } from 'motion/react';
|
|
5
|
-
|
|
5
|
+
import { resolveToastMessages } from '../i18n.js';
|
|
6
|
+
export function Toast({ customDesign, position, className, locale = 'de', messages, }) {
|
|
6
7
|
const { state, handler } = useToastLogic();
|
|
8
|
+
const resolvedMessages = resolveToastMessages(locale, messages);
|
|
7
9
|
const anchorX = position.includes('right') ? 'right' : 'left';
|
|
8
10
|
const anchorY = position.includes('bottom') ? 'bottom' : 'top';
|
|
9
11
|
function getPositionClasses() {
|
|
@@ -20,6 +22,6 @@ export function Toast({ customDesign, position, className }) {
|
|
|
20
22
|
return 'bottom-0 right-0 p-4 flex-col';
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
return (_jsx("div", { role: "region", "aria-label":
|
|
25
|
+
return (_jsx("div", { role: "region", "aria-label": resolvedMessages.regionLabel, className: `fixed z-[99999] flex gap-3 pointer-events-none ${getPositionClasses()}`, children: _jsx(AnimatePresence, { mode: "popLayout", anchorX: anchorX, anchorY: anchorY, children: state.visibleToasts.map((toast) => (_jsx(CustomToast, { toast: toast, position: position, onRemove: handler.removeToast, customDesign: customDesign, className: className, messages: resolvedMessages }, toast.id))) }) }));
|
|
24
26
|
}
|
|
25
27
|
//# sourceMappingURL=Toast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.js","sourceRoot":"","sources":["../../src/Components/Toast.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"Toast.js","sourceRoot":"","sources":["../../src/Components/Toast.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEjD,MAAM,UAAU,KAAK,CAAC,EAClB,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,MAAM,GAAG,IAAI,EACb,QAAQ,GACC;IACT,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,aAAa,EAAE,CAAA;IAC1C,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAC/D,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAA;IAC7D,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAA;IAE9D,SAAS,kBAAkB;QACvB,QAAQ,QAAQ,EAAE,CAAC;YACf,KAAK,UAAU;gBACX,OAAO,mCAAmC,CAAA;YAC9C,KAAK,WAAW;gBACZ,OAAO,oCAAoC,CAAA;YAC/C,KAAK,aAAa;gBACd,OAAO,8BAA8B,CAAA;YACzC,KAAK,cAAc;gBACf,OAAO,+BAA+B,CAAA;YAC1C;gBACI,OAAO,+BAA+B,CAAA;QAC9C,CAAC;IACL,CAAC;IAED,OAAO,CACH,cACI,IAAI,EAAC,QAAQ,gBACD,gBAAgB,CAAC,WAAW,EACxC,SAAS,EAAE,kDAAkD,kBAAkB,EAAE,EAAE,YAEnF,KAAC,eAAe,IACZ,IAAI,EAAC,WAAW,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,YAEf,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAChC,KAAC,WAAW,IAER,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,OAAO,CAAC,WAAW,EAC7B,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,gBAAgB,IANrB,KAAK,CAAC,EAAE,CAOf,CACL,CAAC,GACY,GAChB,CACT,CAAA;AACL,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ToastProviderProps } from '../types.js';
|
|
2
|
-
export declare function ToastProvider({ children, customDesign, position, className, }: ToastProviderProps): import("react").JSX.Element;
|
|
2
|
+
export declare function ToastProvider({ children, customDesign, position, className, locale, messages, }: ToastProviderProps): import("react").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=ToastProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../../src/Components/ToastProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAQrD,wBAAgB,aAAa,CAAC,EAC1B,QAAQ,EACR,YAAY,EACZ,QAAyB,EACzB,SAAS,
|
|
1
|
+
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../../src/Components/ToastProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAQrD,wBAAgB,aAAa,CAAC,EAC1B,QAAQ,EACR,YAAY,EACZ,QAAyB,EACzB,SAAS,EACT,MAAa,EACb,QAAQ,GACX,EAAE,kBAAkB,+BAmBpB"}
|
|
@@ -5,8 +5,8 @@ const LazyToast = lazy(async () => {
|
|
|
5
5
|
const { Toast } = await import('./Toast.js');
|
|
6
6
|
return { default: Toast };
|
|
7
7
|
});
|
|
8
|
-
export function ToastProvider({ children, customDesign, position = 'bottom-right', className, }) {
|
|
8
|
+
export function ToastProvider({ children, customDesign, position = 'bottom-right', className, locale = 'de', messages, }) {
|
|
9
9
|
const { state } = useToastLogic();
|
|
10
|
-
return (_jsxs(_Fragment, { children: [children, state.toasts.length > 0 && (_jsx(Suspense, { fallback: null, children: _jsx(LazyToast, { customDesign: customDesign, position: position, className: className }) }))] }));
|
|
10
|
+
return (_jsxs(_Fragment, { children: [children, state.toasts.length > 0 && (_jsx(Suspense, { fallback: null, children: _jsx(LazyToast, { customDesign: customDesign, position: position, className: className, locale: locale, messages: messages }) }))] }));
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=ToastProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastProvider.js","sourceRoot":"","sources":["../../src/Components/ToastProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAGzD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE;IAC9B,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAA;IAE5C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;AAC7B,CAAC,CAAC,CAAA;AAEF,MAAM,UAAU,aAAa,CAAC,EAC1B,QAAQ,EACR,YAAY,EACZ,QAAQ,GAAG,cAAc,EACzB,SAAS,
|
|
1
|
+
{"version":3,"file":"ToastProvider.js","sourceRoot":"","sources":["../../src/Components/ToastProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAGzD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE;IAC9B,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAA;IAE5C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;AAC7B,CAAC,CAAC,CAAA;AAEF,MAAM,UAAU,aAAa,CAAC,EAC1B,QAAQ,EACR,YAAY,EACZ,QAAQ,GAAG,cAAc,EACzB,SAAS,EACT,MAAM,GAAG,IAAI,EACb,QAAQ,GACS;IACjB,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,EAAE,CAAA;IAEjC,OAAO,CACH,8BACK,QAAQ,EACR,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CACxB,KAAC,QAAQ,IAAC,QAAQ,EAAE,IAAI,YACpB,KAAC,SAAS,IACN,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,GACpB,GACK,CACd,IACF,CACN,CAAA;AACL,CAAC"}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare function getToastSnapshot(): Toast[];
|
|
3
|
-
export declare function customToast(content: string, title?: string, type?: ToastType, duration?: number): string;
|
|
4
|
-
export declare function removeToast(id: string): void;
|
|
5
|
-
export declare function clearAllToasts(): void;
|
|
1
|
+
import { removeToast } from '../toastStore.js';
|
|
6
2
|
export declare function useToastLogic(): {
|
|
7
3
|
handler: {
|
|
8
4
|
removeToast: typeof removeToast;
|
|
9
5
|
};
|
|
10
6
|
state: {
|
|
11
|
-
toasts: Toast[];
|
|
12
|
-
visibleToasts: Toast[];
|
|
7
|
+
toasts: import("../types.js").Toast[];
|
|
8
|
+
visibleToasts: import("../types.js").Toast[];
|
|
13
9
|
};
|
|
14
10
|
};
|
|
15
11
|
//# sourceMappingURL=useToastLogic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToastLogic.d.ts","sourceRoot":"","sources":["../../src/Hooks/useToastLogic.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"useToastLogic.d.ts","sourceRoot":"","sources":["../../src/Hooks/useToastLogic.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,WAAW,EAEd,MAAM,kBAAkB,CAAA;AAEzB,wBAAgB,aAAa;;;;;;;;EAa5B"}
|
|
@@ -1,68 +1,5 @@
|
|
|
1
1
|
import { useMemo, useSyncExternalStore } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
let toastsState = [];
|
|
4
|
-
const listeners = new Set();
|
|
5
|
-
const toastTimers = new Map();
|
|
6
|
-
function notifyListeners() {
|
|
7
|
-
listeners.forEach((listener) => listener());
|
|
8
|
-
}
|
|
9
|
-
function subscribeToToasts(listener) {
|
|
10
|
-
listeners.add(listener);
|
|
11
|
-
return () => {
|
|
12
|
-
listeners.delete(listener);
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export function getToastSnapshot() {
|
|
16
|
-
return toastsState;
|
|
17
|
-
}
|
|
18
|
-
function scheduleAutoDismiss(id, duration) {
|
|
19
|
-
if (duration === 0)
|
|
20
|
-
return;
|
|
21
|
-
const timer = globalThis.setTimeout(() => {
|
|
22
|
-
toastTimers.delete(id);
|
|
23
|
-
removeToast(id);
|
|
24
|
-
}, duration);
|
|
25
|
-
toastTimers.set(id, timer);
|
|
26
|
-
}
|
|
27
|
-
export function customToast(content, title, type = 'success', duration = DEFAULT_TOAST_DURATION) {
|
|
28
|
-
const normalizedDuration = normalizeToastDuration(duration);
|
|
29
|
-
const id = globalThis.crypto?.randomUUID?.() ??
|
|
30
|
-
`${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
31
|
-
toastsState = [
|
|
32
|
-
...toastsState,
|
|
33
|
-
{
|
|
34
|
-
id,
|
|
35
|
-
content,
|
|
36
|
-
title,
|
|
37
|
-
type,
|
|
38
|
-
duration: normalizedDuration,
|
|
39
|
-
createdAt: Date.now(),
|
|
40
|
-
},
|
|
41
|
-
];
|
|
42
|
-
notifyListeners();
|
|
43
|
-
scheduleAutoDismiss(id, normalizedDuration);
|
|
44
|
-
return id;
|
|
45
|
-
}
|
|
46
|
-
export function removeToast(id) {
|
|
47
|
-
const timer = toastTimers.get(id);
|
|
48
|
-
if (timer !== undefined) {
|
|
49
|
-
globalThis.clearTimeout(timer);
|
|
50
|
-
toastTimers.delete(id);
|
|
51
|
-
}
|
|
52
|
-
const nextToastsState = toastsState.filter((toast) => toast.id !== id);
|
|
53
|
-
if (nextToastsState.length === toastsState.length)
|
|
54
|
-
return;
|
|
55
|
-
toastsState = nextToastsState;
|
|
56
|
-
notifyListeners();
|
|
57
|
-
}
|
|
58
|
-
export function clearAllToasts() {
|
|
59
|
-
toastTimers.forEach((timer) => globalThis.clearTimeout(timer));
|
|
60
|
-
toastTimers.clear();
|
|
61
|
-
if (toastsState.length === 0)
|
|
62
|
-
return;
|
|
63
|
-
toastsState = [];
|
|
64
|
-
notifyListeners();
|
|
65
|
-
}
|
|
2
|
+
import { getToastSnapshot, removeToast, subscribeToToasts, } from '../toastStore.js';
|
|
66
3
|
export function useToastLogic() {
|
|
67
4
|
const toasts = useSyncExternalStore(subscribeToToasts, getToastSnapshot, getToastSnapshot);
|
|
68
5
|
const visibleToasts = useMemo(() => toasts.slice(-3), [toasts]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToastLogic.js","sourceRoot":"","sources":["../../src/Hooks/useToastLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"useToastLogic.js","sourceRoot":"","sources":["../../src/Hooks/useToastLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AACrD,OAAO,EACH,gBAAgB,EAChB,WAAW,EACX,iBAAiB,GACpB,MAAM,kBAAkB,CAAA;AAEzB,MAAM,UAAU,aAAa;IACzB,MAAM,MAAM,GAAG,oBAAoB,CAC/B,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,CACnB,CAAA;IAED,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;IAE/D,OAAO;QACH,OAAO,EAAE,EAAE,WAAW,EAAE;QACxB,KAAK,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE;KACnC,CAAA;AACL,CAAC"}
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ToastLocale = 'de' | 'en';
|
|
2
|
+
export interface ToastMessages {
|
|
3
|
+
regionLabel: string;
|
|
4
|
+
closeNotification: string;
|
|
5
|
+
copyError: string;
|
|
6
|
+
errorCopied: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const toastMessageCatalog: Record<ToastLocale, ToastMessages>;
|
|
9
|
+
export declare function resolveToastMessages(locale?: ToastLocale, messages?: Partial<ToastMessages>): ToastMessages;
|
|
10
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,CAAA;AAErC,MAAM,WAAW,aAAa;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,iBAAiB,EAAE,MAAM,CAAA;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACtB;AAED,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,WAAW,EAAE,aAAa,CAalE,CAAA;AAED,wBAAgB,oBAAoB,CAChC,MAAM,GAAE,WAAkB,EAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAClC,aAAa,CAKf"}
|
package/dist/i18n.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const toastMessageCatalog = {
|
|
2
|
+
de: {
|
|
3
|
+
regionLabel: 'Benachrichtigungen',
|
|
4
|
+
closeNotification: 'Benachrichtigung schließen',
|
|
5
|
+
copyError: 'Fehlermeldung kopieren',
|
|
6
|
+
errorCopied: 'Fehlermeldung kopiert',
|
|
7
|
+
},
|
|
8
|
+
en: {
|
|
9
|
+
regionLabel: 'Notifications',
|
|
10
|
+
closeNotification: 'Close notification',
|
|
11
|
+
copyError: 'Copy error message',
|
|
12
|
+
errorCopied: 'Error message copied',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export function resolveToastMessages(locale = 'de', messages) {
|
|
16
|
+
return {
|
|
17
|
+
...toastMessageCatalog[locale],
|
|
18
|
+
...messages,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=i18n.js.map
|
package/dist/i18n.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,mBAAmB,GAAuC;IACnE,EAAE,EAAE;QACA,WAAW,EAAE,oBAAoB;QACjC,iBAAiB,EAAE,4BAA4B;QAC/C,SAAS,EAAE,wBAAwB;QACnC,WAAW,EAAE,uBAAuB;KACvC;IACD,EAAE,EAAE;QACA,WAAW,EAAE,eAAe;QAC5B,iBAAiB,EAAE,oBAAoB;QACvC,SAAS,EAAE,oBAAoB;QAC/B,WAAW,EAAE,sBAAsB;KACtC;CACJ,CAAA;AAED,MAAM,UAAU,oBAAoB,CAChC,MAAM,GAAgB,IAAI,EAC1B,QAAiC;IAEjC,OAAO;QACH,GAAG,mBAAmB,CAAC,MAAM,CAAC;QAC9B,GAAG,QAAQ;KACd,CAAA;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { ToastProvider } from './Components/ToastProvider.js';
|
|
2
|
-
export { customToast, removeToast } from './
|
|
3
|
-
export
|
|
2
|
+
export { customToast, removeToast, toast } from './toast.js';
|
|
3
|
+
export { resolveToastMessages, toastMessageCatalog } from './i18n.js';
|
|
4
|
+
export type { ToastCustomDesign, ToastApi, ToastContentOptions, ToastId, ToastOptions, ToastPosition, ToastPromiseInput, ToastPromiseLoadingMessage, ToastPromiseMessage, ToastPromiseOptions, ToastProviderProps, ToastType, ToastUpdateOptions, } from './types.js';
|
|
5
|
+
export type { ToastLocale, ToastMessages } from './i18n.js';
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AACrE,YAAY,EACR,iBAAiB,EACjB,QAAQ,EACR,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,SAAS,EACT,kBAAkB,GACrB,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { ToastProvider } from './Components/ToastProvider.js';
|
|
2
|
-
export { customToast, removeToast } from './
|
|
2
|
+
export { customToast, removeToast, toast } from './toast.js';
|
|
3
|
+
export { resolveToastMessages, toastMessageCatalog } from './i18n.js';
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/toast.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ToastApi, ToastId, ToastType } from './types.js';
|
|
2
|
+
import { removeToast } from './toastStore.js';
|
|
3
|
+
export declare function customToast(content: string, title?: string, type?: ToastType, duration?: number): ToastId;
|
|
4
|
+
export { removeToast };
|
|
5
|
+
export declare const toast: ToastApi;
|
|
6
|
+
//# sourceMappingURL=toast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../src/toast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,QAAQ,EAER,OAAO,EAMP,SAAS,EAEZ,MAAM,YAAY,CAAA;AAEnB,OAAO,EAGH,WAAW,EAEd,MAAM,iBAAiB,CAAA;AA8FxB,wBAAgB,WAAW,CACvB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,EACd,IAAI,GAAE,SAAqB,EAC3B,QAAQ,GAAE,MAA+B,GAC1C,OAAO,CAET;AAED,OAAO,EAAE,WAAW,EAAE,CAAA;AActB,eAAO,MAAM,KAAK,EAAE,QAAkC,CAAA"}
|
package/dist/toast.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DEFAULT_TOAST_DURATION } from './Hooks/toastTiming.js';
|
|
2
|
+
import { clearAllToasts, createToast, removeToast, updateToast, } from './toastStore.js';
|
|
3
|
+
function showToast(type, content, options) {
|
|
4
|
+
return createToast(content, options?.title, type, options?.duration);
|
|
5
|
+
}
|
|
6
|
+
function resolveLoadingMessage(message) {
|
|
7
|
+
return typeof message === 'string' ? { content: message } : message;
|
|
8
|
+
}
|
|
9
|
+
function resolvePromiseMessage(message, value) {
|
|
10
|
+
const resolvedMessage = typeof message === 'function' ? message(value) : message;
|
|
11
|
+
return typeof resolvedMessage === 'string'
|
|
12
|
+
? { content: resolvedMessage }
|
|
13
|
+
: resolvedMessage;
|
|
14
|
+
}
|
|
15
|
+
function settlePromiseToast(id, type, message, value, duration) {
|
|
16
|
+
try {
|
|
17
|
+
const resolvedMessage = resolvePromiseMessage(message, value);
|
|
18
|
+
updateToast(id, {
|
|
19
|
+
content: resolvedMessage.content,
|
|
20
|
+
title: resolvedMessage.title ?? null,
|
|
21
|
+
type,
|
|
22
|
+
duration: resolvedMessage.duration ?? duration ?? DEFAULT_TOAST_DURATION,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
updateToast(id, {
|
|
27
|
+
title: null,
|
|
28
|
+
type,
|
|
29
|
+
duration: duration ?? DEFAULT_TOAST_DURATION,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function runPromise(input) {
|
|
34
|
+
try {
|
|
35
|
+
return Promise.resolve(typeof input === 'function' ? input() : input);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return Promise.reject(error);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function promiseToast(input, options) {
|
|
42
|
+
const loadingMessage = resolveLoadingMessage(options.loading);
|
|
43
|
+
const id = createToast(loadingMessage.content, loadingMessage.title, 'info', 0);
|
|
44
|
+
return runPromise(input).then((value) => {
|
|
45
|
+
settlePromiseToast(id, 'success', options.success, value, options.duration);
|
|
46
|
+
return value;
|
|
47
|
+
}, (error) => {
|
|
48
|
+
settlePromiseToast(id, 'error', options.error, error, options.duration);
|
|
49
|
+
throw error;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export function customToast(content, title, type = 'success', duration = DEFAULT_TOAST_DURATION) {
|
|
53
|
+
return createToast(content, title, type, duration);
|
|
54
|
+
}
|
|
55
|
+
export { removeToast };
|
|
56
|
+
const toastApi = {
|
|
57
|
+
success: (content, options) => showToast('success', content, options),
|
|
58
|
+
error: (content, options) => showToast('error', content, options),
|
|
59
|
+
info: (content, options) => showToast('info', content, options),
|
|
60
|
+
warning: (content, options) => showToast('warning', content, options),
|
|
61
|
+
dismiss: removeToast,
|
|
62
|
+
dismissAll: clearAllToasts,
|
|
63
|
+
update: (id, options) => updateToast(id, options),
|
|
64
|
+
promise: promiseToast,
|
|
65
|
+
};
|
|
66
|
+
export const toast = Object.freeze(toastApi);
|
|
67
|
+
//# sourceMappingURL=toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast.js","sourceRoot":"","sources":["../src/toast.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAC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AE,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC;IACrE,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;IACjE,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC;IAC/D,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC;IACrE,OAAO,EAAE,WAAW;IACpB,UAAU,EAAE,cAAc;IAC1B,MAAM,EAAE,CAAC,EAAW,EAAE,OAA2B,EAAE,EAAE,CACjD,WAAW,CAAC,EAAE,EAAE,OAAO,CAAC;IAC5B,OAAO,EAAE,YAAY;CACxB,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAAa,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Toast, ToastId, ToastType, ToastUpdateOptions } from './types.js';
|
|
2
|
+
export declare function subscribeToToasts(listener: () => void): () => void;
|
|
3
|
+
export declare function getToastSnapshot(): Toast[];
|
|
4
|
+
export declare function createToast(content: string, title?: string, type?: ToastType, duration?: number): ToastId;
|
|
5
|
+
export declare function updateToast(id: ToastId, options: ToastUpdateOptions): boolean;
|
|
6
|
+
export declare function removeToast(id: ToastId): void;
|
|
7
|
+
export declare function clearAllToasts(): void;
|
|
8
|
+
//# sourceMappingURL=toastStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toastStore.d.ts","sourceRoot":"","sources":["../src/toastStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AA4C/E,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,IAAI,cAMrD;AAED,wBAAgB,gBAAgB,YAE/B;AAED,wBAAgB,WAAW,CACvB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,EACd,IAAI,GAAE,SAAqB,EAC3B,QAAQ,GAAE,MAA+B,GAC1C,OAAO,CAqBT;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,WAmCnE;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,OAAO,QAStC;AAED,wBAAgB,cAAc,SAQ7B"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { DEFAULT_TOAST_DURATION, normalizeToastDuration, } from './Hooks/toastTiming.js';
|
|
2
|
+
let toastsState = [];
|
|
3
|
+
const listeners = new Set();
|
|
4
|
+
const toastTimers = new Map();
|
|
5
|
+
function notifyListeners() {
|
|
6
|
+
listeners.forEach((listener) => listener());
|
|
7
|
+
}
|
|
8
|
+
function cancelAutoDismiss(id) {
|
|
9
|
+
const timer = toastTimers.get(id);
|
|
10
|
+
if (timer === undefined)
|
|
11
|
+
return;
|
|
12
|
+
globalThis.clearTimeout(timer.handle);
|
|
13
|
+
toastTimers.delete(id);
|
|
14
|
+
}
|
|
15
|
+
function scheduleAutoDismiss(id, duration) {
|
|
16
|
+
cancelAutoDismiss(id);
|
|
17
|
+
if (duration === 0)
|
|
18
|
+
return;
|
|
19
|
+
const token = Symbol(id);
|
|
20
|
+
const handle = globalThis.setTimeout(() => {
|
|
21
|
+
if (toastTimers.get(id)?.token !== token)
|
|
22
|
+
return;
|
|
23
|
+
toastTimers.delete(id);
|
|
24
|
+
removeToast(id);
|
|
25
|
+
}, duration);
|
|
26
|
+
toastTimers.set(id, { handle, token });
|
|
27
|
+
}
|
|
28
|
+
export function subscribeToToasts(listener) {
|
|
29
|
+
listeners.add(listener);
|
|
30
|
+
return () => {
|
|
31
|
+
listeners.delete(listener);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function getToastSnapshot() {
|
|
35
|
+
return toastsState;
|
|
36
|
+
}
|
|
37
|
+
export function createToast(content, title, type = 'success', duration = DEFAULT_TOAST_DURATION) {
|
|
38
|
+
const normalizedDuration = normalizeToastDuration(duration);
|
|
39
|
+
const id = globalThis.crypto?.randomUUID?.() ??
|
|
40
|
+
`${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
41
|
+
toastsState = [
|
|
42
|
+
...toastsState,
|
|
43
|
+
{
|
|
44
|
+
id,
|
|
45
|
+
content,
|
|
46
|
+
title,
|
|
47
|
+
type,
|
|
48
|
+
duration: normalizedDuration,
|
|
49
|
+
createdAt: Date.now(),
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
scheduleAutoDismiss(id, normalizedDuration);
|
|
53
|
+
notifyListeners();
|
|
54
|
+
return id;
|
|
55
|
+
}
|
|
56
|
+
export function updateToast(id, options) {
|
|
57
|
+
const toastIndex = toastsState.findIndex((toast) => toast.id === id);
|
|
58
|
+
if (toastIndex === -1)
|
|
59
|
+
return false;
|
|
60
|
+
const currentToast = toastsState[toastIndex];
|
|
61
|
+
const resetsDuration = options.duration !== undefined;
|
|
62
|
+
const duration = resetsDuration
|
|
63
|
+
? normalizeToastDuration(options.duration)
|
|
64
|
+
: currentToast.duration;
|
|
65
|
+
const nextToast = {
|
|
66
|
+
...currentToast,
|
|
67
|
+
content: options.content ?? currentToast.content,
|
|
68
|
+
title: options.title === null
|
|
69
|
+
? undefined
|
|
70
|
+
: (options.title ?? currentToast.title),
|
|
71
|
+
type: options.type ?? currentToast.type,
|
|
72
|
+
duration,
|
|
73
|
+
createdAt: resetsDuration
|
|
74
|
+
? Math.max(Date.now(), currentToast.createdAt + 1)
|
|
75
|
+
: currentToast.createdAt,
|
|
76
|
+
};
|
|
77
|
+
toastsState = toastsState.map((toast, index) => index === toastIndex ? nextToast : toast);
|
|
78
|
+
if (resetsDuration) {
|
|
79
|
+
scheduleAutoDismiss(id, duration);
|
|
80
|
+
}
|
|
81
|
+
notifyListeners();
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
export function removeToast(id) {
|
|
85
|
+
cancelAutoDismiss(id);
|
|
86
|
+
const nextToastsState = toastsState.filter((toast) => toast.id !== id);
|
|
87
|
+
if (nextToastsState.length === toastsState.length)
|
|
88
|
+
return;
|
|
89
|
+
toastsState = nextToastsState;
|
|
90
|
+
notifyListeners();
|
|
91
|
+
}
|
|
92
|
+
export function clearAllToasts() {
|
|
93
|
+
toastTimers.forEach(({ handle }) => globalThis.clearTimeout(handle));
|
|
94
|
+
toastTimers.clear();
|
|
95
|
+
if (toastsState.length === 0)
|
|
96
|
+
return;
|
|
97
|
+
toastsState = [];
|
|
98
|
+
notifyListeners();
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=toastStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toastStore.js","sourceRoot":"","sources":["../src/toastStore.ts"],"names":[],"mappings":"AACA,OAAO,EACH,sBAAsB,EACtB,sBAAsB,GACzB,MAAM,wBAAwB,CAAA;AAO/B,IAAI,WAAW,GAAY,EAAE,CAAA;AAC7B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;AACvC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAA;AAElD,SAAS,eAAe;IACpB,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;AAC/C,CAAC;AAED,SAAS,iBAAiB,CAAC,EAAW;IAClC,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAEjC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAM;IAE/B,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IACrC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAC1B,C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AAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAC3C,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAC3C,CAAA;IAED,IAAI,cAAc,EAAE,CAAC;QACjB,mBAAmB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;IACrC,CAAC;IAED,eAAe,EAAE,CAAA;IAEjB,OAAO,IAAI,CAAA;AACf,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,EAAW;IACnC,iBAAiB,CAAC,EAAE,CAAC,CAAA;IAErB,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;IAEtE,IAAI,eAAe,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM;QAAE,OAAM;IAEzD,WAAW,GAAG,eAAe,CAAA;IAC7B,eAAe,EAAE,CAAA;AACrB,CAAC;AAED,MAAM,UAAU,cAAc;IAC1B,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAA;IACpE,WAAW,CAAC,KAAK,EAAE,CAAA;IAEnB,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAM;IAEpC,WAAW,GAAG,EAAE,CAAA;IAChB,eAAe,EAAE,CAAA;AACrB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,33 +1,72 @@
|
|
|
1
1
|
import type { ReactNode, MouseEvent } from 'react';
|
|
2
2
|
import type { getToastExitAnimation, getToastInitialAnimation, toastAnimate, toastDragAnimation, toastTransition } from './Animations/toastAnimations.js';
|
|
3
3
|
import type { MotionProps } from 'motion/react';
|
|
4
|
+
import type { ToastLocale, ToastMessages } from './i18n.js';
|
|
4
5
|
export type ToastType = 'success' | 'error' | 'info' | 'warning';
|
|
6
|
+
export type ToastId = string;
|
|
5
7
|
export type ToastPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
6
8
|
export interface Toast {
|
|
7
|
-
id:
|
|
9
|
+
id: ToastId;
|
|
8
10
|
content: string;
|
|
9
11
|
title?: string;
|
|
10
12
|
type: ToastType;
|
|
11
13
|
duration: number;
|
|
12
14
|
createdAt: number;
|
|
13
15
|
}
|
|
16
|
+
export interface ToastOptions {
|
|
17
|
+
title?: string;
|
|
18
|
+
duration?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface ToastContentOptions extends ToastOptions {
|
|
21
|
+
content: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ToastUpdateOptions {
|
|
24
|
+
content?: string;
|
|
25
|
+
title?: string | null;
|
|
26
|
+
type?: ToastType;
|
|
27
|
+
duration?: number;
|
|
28
|
+
}
|
|
29
|
+
export type ToastPromiseMessage<T> = string | ToastContentOptions | ((value: T) => string | ToastContentOptions);
|
|
30
|
+
export type ToastPromiseLoadingMessage = string | Omit<ToastContentOptions, 'duration'>;
|
|
31
|
+
export interface ToastPromiseOptions<T> {
|
|
32
|
+
loading: ToastPromiseLoadingMessage;
|
|
33
|
+
success: ToastPromiseMessage<T>;
|
|
34
|
+
error: ToastPromiseMessage<unknown>;
|
|
35
|
+
duration?: number;
|
|
36
|
+
}
|
|
37
|
+
export type ToastPromiseInput<T> = PromiseLike<T> | (() => PromiseLike<T>);
|
|
38
|
+
export interface ToastApi {
|
|
39
|
+
success: (content: string, options?: ToastOptions) => ToastId;
|
|
40
|
+
error: (content: string, options?: ToastOptions) => ToastId;
|
|
41
|
+
info: (content: string, options?: ToastOptions) => ToastId;
|
|
42
|
+
warning: (content: string, options?: ToastOptions) => ToastId;
|
|
43
|
+
dismiss: (id: ToastId) => void;
|
|
44
|
+
dismissAll: () => void;
|
|
45
|
+
update: (id: ToastId, options: ToastUpdateOptions) => boolean;
|
|
46
|
+
promise: <T>(input: ToastPromiseInput<T>, options: ToastPromiseOptions<T>) => Promise<T>;
|
|
47
|
+
}
|
|
14
48
|
export interface CustomToastProps {
|
|
15
49
|
toast: Toast;
|
|
16
50
|
position: ToastPosition;
|
|
17
51
|
onRemove: (id: string) => void;
|
|
18
52
|
customDesign?: ToastCustomDesign;
|
|
19
53
|
className?: string;
|
|
54
|
+
messages: ToastMessages;
|
|
20
55
|
}
|
|
21
56
|
export interface ToastProps {
|
|
22
57
|
customDesign?: ToastCustomDesign;
|
|
23
58
|
position: ToastPosition;
|
|
24
59
|
className?: string;
|
|
60
|
+
locale?: ToastLocale;
|
|
61
|
+
messages?: Partial<ToastMessages>;
|
|
25
62
|
}
|
|
26
63
|
export interface ToastProviderProps {
|
|
27
64
|
children: ReactNode;
|
|
28
65
|
customDesign?: ToastCustomDesign;
|
|
29
66
|
position?: ToastPosition;
|
|
30
67
|
className?: string;
|
|
68
|
+
locale?: ToastLocale;
|
|
69
|
+
messages?: Partial<ToastMessages>;
|
|
31
70
|
}
|
|
32
71
|
export interface UseCustomToastLogicResult {
|
|
33
72
|
state: {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,KAAK,EACR,qBAAqB,EACrB,wBAAwB,EACxB,YAAY,EACZ,kBAAkB,EAClB,eAAe,EAClB,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,KAAK,EACR,qBAAqB,EACrB,wBAAwB,EACxB,YAAY,EACZ,kBAAkB,EAClB,eAAe,EAClB,MAAM,iC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,iBAAiB;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rentnerkev/toasts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Accessible, customizable toast notifications for React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -17,10 +17,13 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"files": [
|
|
19
19
|
"dist",
|
|
20
|
+
"tailwind.css",
|
|
20
21
|
"README.md",
|
|
21
22
|
"LICENSE"
|
|
22
23
|
],
|
|
23
|
-
"sideEffects":
|
|
24
|
+
"sideEffects": [
|
|
25
|
+
"./tailwind.css"
|
|
26
|
+
],
|
|
24
27
|
"scripts": {
|
|
25
28
|
"build": "bun -e \"import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true })\" && tsc",
|
|
26
29
|
"typecheck": "tsc --noEmit",
|
|
@@ -51,8 +54,8 @@
|
|
|
51
54
|
"peerDependencies": {
|
|
52
55
|
"lucide-react": "^1.0.0",
|
|
53
56
|
"motion": "^12.38.0 || ^13.0.0",
|
|
54
|
-
"react": "^19.
|
|
55
|
-
"react-dom": "^19.
|
|
57
|
+
"react": "^19.0.0",
|
|
58
|
+
"react-dom": "^19.0.0"
|
|
56
59
|
},
|
|
57
60
|
"devDependencies": {
|
|
58
61
|
"@types/react": "^19.3.0",
|
|
@@ -69,7 +72,21 @@
|
|
|
69
72
|
".": {
|
|
70
73
|
"types": "./dist/index.d.ts",
|
|
71
74
|
"import": "./dist/index.js"
|
|
72
|
-
}
|
|
75
|
+
},
|
|
76
|
+
"./tailwind.css": "./tailwind.css",
|
|
77
|
+
"./toast": {
|
|
78
|
+
"types": "./dist/toast.d.ts",
|
|
79
|
+
"import": "./dist/toast.js"
|
|
80
|
+
},
|
|
81
|
+
"./messages": {
|
|
82
|
+
"types": "./dist/i18n.d.ts",
|
|
83
|
+
"import": "./dist/i18n.js"
|
|
84
|
+
},
|
|
85
|
+
"./types": {
|
|
86
|
+
"types": "./dist/types.d.ts",
|
|
87
|
+
"import": "./dist/types.js"
|
|
88
|
+
},
|
|
89
|
+
"./package.json": "./package.json"
|
|
73
90
|
},
|
|
74
91
|
"packageManager": "bun@1.4.0"
|
|
75
92
|
}
|
package/tailwind.css
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@source "./dist/**/*.js";
|
|
2
|
+
|
|
3
|
+
@theme {
|
|
4
|
+
--color-primary: #13ecd6;
|
|
5
|
+
--color-primary-hover: #0fbdaa;
|
|
6
|
+
--color-background-dark: #0f1014;
|
|
7
|
+
--color-surface-dark: #181a1f;
|
|
8
|
+
--color-input-dark: #22252b;
|
|
9
|
+
--color-border-dark: #2e323b;
|
|
10
|
+
--color-secondary-text: #9ca3af;
|
|
11
|
+
--color-muted-foreground: #9ca3af;
|
|
12
|
+
}
|