@rentnerkev/toasts 1.0.1 → 3.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 (40) hide show
  1. package/README.md +138 -79
  2. package/dist/Components/CustomToast.d.ts +1 -1
  3. package/dist/Components/CustomToast.d.ts.map +1 -1
  4. package/dist/Components/CustomToast.js +6 -5
  5. package/dist/Components/CustomToast.js.map +1 -1
  6. package/dist/Components/Toast.d.ts +1 -1
  7. package/dist/Components/Toast.d.ts.map +1 -1
  8. package/dist/Components/Toast.js +5 -3
  9. package/dist/Components/Toast.js.map +1 -1
  10. package/dist/Components/ToastProvider.d.ts +1 -1
  11. package/dist/Components/ToastProvider.d.ts.map +1 -1
  12. package/dist/Components/ToastProvider.js +3 -7
  13. package/dist/Components/ToastProvider.js.map +1 -1
  14. package/dist/Hooks/useCustomToastLogic.d.ts.map +1 -1
  15. package/dist/Hooks/useCustomToastLogic.js +9 -6
  16. package/dist/Hooks/useCustomToastLogic.js.map +1 -1
  17. package/dist/Hooks/useToastLogic.d.ts +3 -7
  18. package/dist/Hooks/useToastLogic.d.ts.map +1 -1
  19. package/dist/Hooks/useToastLogic.js +1 -64
  20. package/dist/Hooks/useToastLogic.js.map +1 -1
  21. package/dist/i18n.d.ts +10 -0
  22. package/dist/i18n.d.ts.map +1 -0
  23. package/dist/i18n.js +21 -0
  24. package/dist/i18n.js.map +1 -0
  25. package/dist/index.d.ts +4 -2
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +2 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/toast.d.ts +3 -0
  30. package/dist/toast.d.ts.map +1 -0
  31. package/dist/toast.js +63 -0
  32. package/dist/toast.js.map +1 -0
  33. package/dist/toastStore.d.ts +8 -0
  34. package/dist/toastStore.d.ts.map +1 -0
  35. package/dist/toastStore.js +100 -0
  36. package/dist/toastStore.js.map +1 -0
  37. package/dist/types.d.ts +42 -2
  38. package/dist/types.d.ts.map +1 -1
  39. package/package.json +31 -10
  40. package/tailwind.css +12 -0
package/README.md CHANGED
@@ -1,107 +1,154 @@
1
1
  # @rentnerkev/toasts
2
2
 
3
- Zugängliche und anpassbare Toast-Benachrichtigungen für React mit vier
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
- bun add @rentnerkev/toasts
10
+ npm install @rentnerkev/toasts
10
11
  ```
11
12
 
12
- oder:
13
+ Or with Bun:
13
14
 
14
15
  ```bash
15
- npm install @rentnerkev/toasts
16
+ bun add @rentnerkev/toasts
16
17
  ```
17
18
 
18
- React, React DOM, Motion und Lucide React werden als Peer Dependencies vom
19
- Consumer bereitgestellt.
20
-
21
- ## Schnellstart
19
+ React, React DOM, Motion, and Lucide React are peer dependencies supplied by the consuming application.
22
20
 
23
- ### Provider einrichten
21
+ ## Set up the provider
24
22
 
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
- ### Toast anzeigen
37
+ ## Show a toast
41
38
 
42
- `customToast` kann innerhalb und außerhalb von React-Komponenten aufgerufen
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 { customToast } from '@rentnerkev/toasts'
42
+ import { toast } from '@rentnerkev/toasts'
47
43
 
48
- const toastId = customToast('Deine Nachricht', 'Erfolg', 'success', 5000)
44
+ const toastId = toast.success('Your changes were saved.', {
45
+ title: 'Saved',
46
+ duration: 5000,
47
+ })
49
48
  ```
50
49
 
51
- ### Toast entfernen
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.
52
51
 
53
- Entferne einen Toast mit der von `customToast` zurückgegebenen ID:
52
+ ## Dismiss and update toasts
53
+
54
+ Dismiss one toast by ID, or clear visible and queued toasts together with all expiration timers:
54
55
 
55
56
  ```tsx
56
- import { removeToast } from '@rentnerkev/toasts'
57
+ toast.dismiss(toastId)
58
+ toast.dismissAll()
59
+ ```
57
60
 
58
- removeToast(toastId)
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
- ## Varianten und Dauer
72
+ The method returns `false` for an unknown or already dismissed ID and `true` after a successful update.
73
+
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
+ ```
62
95
 
63
- Verfügbare Varianten sind `success`, `error`, `info` und `warning`. Die
64
- Signatur lautet:
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 and duration
99
+
100
+ Available variants are `success`, `error`, `info`, and `warning`. Each namespace method uses the same option shape:
65
101
 
66
102
  ```ts
67
- customToast(
68
- content: string,
69
- title?: string,
70
- type?: ToastType,
71
- duration?: number,
72
- ): string
103
+ toast.info(content: string, options?: ToastOptions): ToastId
73
104
  ```
74
105
 
75
- Die Standarddauer beträgt 6000 Millisekunden. `duration: 0` deaktiviert den
76
- automatischen Ablauf; der Toast bleibt bis zu einem manuellen
77
- `removeToast` sichtbar. Negative, nicht endliche oder ungültige Werte fallen
78
- auf die Standarddauer zurück. Positive Werte werden auf eine sichere
79
- `setTimeout`-Grenze begrenzt.
106
+ 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.
107
+
108
+ ## Localization
109
+
110
+ German accessible system messages remain the default. Set `locale="en"` for the English catalog, or override individual messages with a typed `Partial<ToastMessages>`:
80
111
 
81
- ## Styling
112
+ ```tsx
113
+ <ToastProvider
114
+ locale="en"
115
+ messages={{ closeNotification: 'Dismiss notification' }}
116
+ >
117
+ <App />
118
+ </ToastProvider>
119
+ ```
82
120
 
83
- Die Library verwendet Tailwind CSS-Klassen und liefert keine eigene CSS-Datei.
84
- Bei Tailwind CSS v4 muss das Paket als Quelle angegeben werden:
121
+ The message catalog and resolver are exported as `toastMessageCatalog` and `resolveToastMessages`.
122
+
123
+ ## `ToastProvider` props
124
+
125
+ | Prop | Type | Default | Description |
126
+ | -------------- | ------------------------ | ---------------- | ------------------------------------------------------- |
127
+ | `position` | `ToastPosition` | `'bottom-right'` | Screen position used for the toast stack. |
128
+ | `customDesign` | `ToastCustomDesign` | `undefined` | Overrides Tailwind classes for individual visual parts. |
129
+ | `className` | `string` | `undefined` | Additional Tailwind classes applied to every toast. |
130
+ | `locale` | `'de' \| 'en'` | `'de'` | Selects the accessible system-message catalog. |
131
+ | `messages` | `Partial<ToastMessages>` | `undefined` | Overrides individual system messages. |
132
+ | `children` | `ReactNode` | - | Application content rendered by the provider. |
133
+
134
+ ## Tailwind CSS
135
+
136
+ Import the package entry after Tailwind CSS in your application stylesheet:
85
137
 
86
138
  ```css
87
139
  @import 'tailwindcss';
88
- @source "../node_modules/@rentnerkev/toasts";
140
+ @import '@rentnerkev/toasts/tailwind.css';
89
141
  ```
90
142
 
91
- Der `ToastProvider` unterstützt folgende Props:
143
+ 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
144
 
93
- | Prop | Typ | Standard | Beschreibung |
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. |
145
+ ### Custom design
99
146
 
100
- ### Eigenes Design
147
+ Design overrides are Tailwind class strings:
101
148
 
102
149
  ```tsx
103
150
  const customDesign = {
104
- successWrapper: 'bg-green-100 border-l-4 border-green-500',
151
+ successWrapper: 'border-l-4 border-green-500 bg-green-100',
105
152
  successProgress: 'bg-green-600',
106
153
  linkText: 'text-blue-600 hover:underline',
107
154
  titleText: 'font-bold text-green-900',
@@ -115,61 +162,73 @@ const customDesign = {
115
162
  </ToastProvider>
116
163
  ```
117
164
 
118
- Verfügbare `ToastCustomDesign`-Felder:
165
+ Available `ToastCustomDesign` fields:
119
166
 
120
- | Feld | Beschreibung |
121
- | :-------------------------------------------------------------------- | :------------------------------------------- |
122
- | `successWrapper`, `errorWrapper`, `infoWrapper`, `warningWrapper` | Klassen für den jeweiligen Toast-Container. |
123
- | `successIcon`, `errorIcon`, `infoIcon`, `warningIcon` | Klassen für das jeweilige Status-Icon. |
124
- | `successProgress`, `errorProgress`, `infoProgress`, `warningProgress` | Klassen für den Fortschrittsbalken. |
125
- | `titleText` | Klassen für den Titel. |
126
- | `contentText` | Klassen für den Inhalt. |
127
- | `linkText` | Klassen für Markdown-Links. |
128
- | `closeButton` | Klassen für den Schließen-Button. |
129
- | `copyButton` | Klassen für den Kopieren-Button bei Fehlern. |
167
+ | Fields | Purpose |
168
+ | --------------------------------------------------------------------- | ---------------------------------------- |
169
+ | `successWrapper`, `errorWrapper`, `infoWrapper`, `warningWrapper` | Toast container classes for each status. |
170
+ | `successIcon`, `errorIcon`, `infoIcon`, `warningIcon` | Status icon classes. |
171
+ | `successProgress`, `errorProgress`, `infoProgress`, `warningProgress` | Progress indicator classes. |
172
+ | `titleText` | Title classes. |
173
+ | `contentText` | Content classes. |
174
+ | `linkText` | Markdown link classes. |
175
+ | `closeButton` | Dismiss button classes. |
176
+ | `copyButton` | Error-copy button classes. |
130
177
 
131
- ## Links in Toasts
178
+ ## Links and accessibility
132
179
 
133
- Links mit der Markdown-Syntax `[Text](URL)` werden klickbar dargestellt und
134
- öffnen sich in einem neuen Tab. Es werden nur `http`- und `https`-URLs
135
- verlinkt; andere Schemes bleiben als Text sichtbar.
180
+ 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
181
 
137
182
  ```tsx
138
- customToast(
139
- 'Öffne [das Ticket](https://example.com/tickets/45).',
140
- 'Neues Ticket',
141
- 'info',
142
- )
183
+ toast.info('Open [the ticket](https://example.com/tickets/45).', {
184
+ title: 'New ticket',
185
+ })
143
186
  ```
144
187
 
145
- Fehlermeldungen bieten zusätzlich eine Schaltfläche zum Kopieren des Titels
146
- und Inhalts. Die Toast-Varianten verwenden für normale Meldungen eine
147
- polite Live-Region und für Fehler eine assertive Meldung.
188
+ 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
189
 
149
190
  ## TypeScript
150
191
 
151
- Die wichtigsten Typen können direkt aus dem Paket importiert werden:
192
+ Public types are available from the package root:
152
193
 
153
194
  ```tsx
154
195
  import type {
196
+ ToastApi,
197
+ ToastContentOptions,
155
198
  ToastCustomDesign,
199
+ ToastId,
200
+ ToastLocale,
201
+ ToastMessages,
202
+ ToastOptions,
156
203
  ToastPosition,
204
+ ToastPromiseOptions,
157
205
  ToastProviderProps,
158
206
  ToastType,
207
+ ToastUpdateOptions,
159
208
  } from '@rentnerkev/toasts'
160
209
  ```
161
210
 
162
- ## Entwicklung
211
+ ## Public entry points
212
+
213
+ | Entry point | Purpose |
214
+ | --------------------------------- | ---------------------------------------------------- |
215
+ | `@rentnerkev/toasts` | Provider, namespace API, messages, and public types. |
216
+ | `@rentnerkev/toasts/toast` | Namespace API. |
217
+ | `@rentnerkev/toasts/messages` | Locale catalog, resolver, and message types. |
218
+ | `@rentnerkev/toasts/types` | Toast API, provider, and design types. |
219
+ | `@rentnerkev/toasts/tailwind.css` | Tailwind source and shared theme tokens. |
220
+ | `@rentnerkev/toasts/package.json` | Package metadata. |
221
+
222
+ ## Development
163
223
 
164
224
  ```bash
165
225
  bun install
166
- bun run check
226
+ bun run verify
167
227
  bun run playground:dev
168
228
  ```
169
229
 
170
- Der Playground bleibt eine lokale Entwicklungs- und Testumgebung und ist
171
- nicht Bestandteil des npm-Pakets.
230
+ `bun run verify` checks types, lint, formatting, unit tests, browser tests, the package build, and the published package contents. Install the Playwright browser once with `bunx playwright install chromium`. The playground remains a local development and test environment and is not included in the npm package.
172
231
 
173
- ## Lizenz
232
+ ## License
174
233
 
175
- MIT, siehe [LICENSE](./LICENSE).
234
+ 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,+BAiH3B"}
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,+BAwH3B"}
@@ -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
- 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
- ? 'Fehlermeldung kopiert'
16
- : 'Fehlermeldung kopieren', 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": "Benachrichtigung schlie\u00DFen", 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: {
15
+ return (_jsxs(motion.div, { ref: ref, layout: "position", initial: state.initialAnimation, animate: state.animate, exit: state.exitAnimation, transition: state.transition, drag: state.dragEnabled ? 'x' : false, 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: state.dragEnabled ? { scale: 1.15 } : undefined, whileTap: state.dragEnabled ? { scale: 0.85 } : undefined, "aria-label": state.copied
16
+ ? messages.errorCopied
17
+ : messages.copyError, className: "relative group shrink-0 cursor-pointer touch-manipulation rounded-full p-1.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/70 focus-visible:ring-offset-2 focus-visible:ring-offset-black/20", children: [_jsx("span", { className: "absolute inset-0 rounded-full bg-white/10 opacity-0 transition-opacity duration-300 group-hover:opacity-100 motion-reduce:transition-none" }), state.copied ? (_jsx(Check, { size: 14, "aria-hidden": "true", className: `relative z-10 transition-colors duration-300 motion-reduce:transition-none ${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 motion-reduce:transition-none ${customDesign?.copyButton || 'text-gray-400 group-hover:text-white'}` }))] })), _jsxs(motion.button, { type: "button", onClick: () => onRemove(toast.id), whileHover: state.dragEnabled ? { scale: 1.15 } : undefined, whileTap: state.dragEnabled ? { scale: 0.85 } : undefined, "aria-label": messages.closeNotification, className: "relative group shrink-0 cursor-pointer touch-manipulation overflow-hidden rounded-full p-1.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/70 focus-visible:ring-offset-2 focus-visible:ring-offset-black/20", children: [_jsx("span", { className: "absolute inset-0 rounded-full bg-white/10 opacity-0 transition-opacity duration-300 group-hover:opacity-100 motion-reduce:transition-none" }), _jsx(motion.div, { transition: closeButtonIconTransition, variants: closeButtonIconVariants, initial: "idle", whileHover: state.dragEnabled ? 'hover' : undefined, className: "relative z-10", children: _jsx(X, { size: 14, "aria-hidden": "true", className: `transition-colors duration-300 motion-reduce:transition-none ${customDesign?.closeButton || 'text-gray-400 group-hover:text-white'}` }) })] })] }), toast.duration > 0 && (_jsx(motion.div, { initial: { scaleX: state.startingScale }, animate: { scaleX: 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", "data-testid": "toast-progress", className: `absolute bottom-0 left-0 h-1 w-full origin-left ${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;KACZ,CAAC,CAAA;IAEF,OAAO,CACH,MAAC,MAAM,CAAC,GAAG,IACP,GAAG,EAAE,GAAG,EACR,MAAM,EAAC,UAAU,EACjB,OAAO,EAAE,KAAK,CAAC,gBAAgB,EAC/B,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,IAAI,EAAE,KAAK,CAAC,aAAa,EACzB,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,IAAI,EAAC,GAAG,EACR,eAAe,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EACtC,WAAW,EAAE,GAAG,EAChB,SAAS,EAAE,KAAK,CAAC,aAAa,EAC9B,SAAS,EAAE,OAAO,CAAC,aAAa,EAChC,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,eACtC,KAAK,CAAC,IAAI,KA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C,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,EAC3D,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,gBAC7C,QAAQ,CAAC,iBAAiB,EACtC,SAAS,EAAC,yOAAyO,aAEnP,eAAM,SAAS,EAAC,2IAA2I,GAAG,EAC9J,KAAC,MAAM,CAAC,GAAG,IACP,UAAU,EAAE,yBAAyB,EACrC,QAAQ,EAAE,uBAAuB,EACjC,OAAO,EAAC,MAAM,EACd,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EACnD,SAAS,EAAC,eAAe,YAEzB,KAAC,CAAC,IACE,IAAI,EAAE,EAAE,iBACI,MAAM,EAClB,SAAS,EAAE,gEAAgE,YAAY,EAAE,WAAW,IAAI,sCAAsC,EAAE,GAClJ,GACO,IACD,IACd,EAEL,KAAK,CAAC,QAAQ,GAAG,CAAC,IAAI,CACnB,KAAC,MAAM,CAAC,GAAG,IAEP,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,aAAa,EAAE,EACxC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,EACtB,UAAU,EAAE;oBACR,QAAQ,EAAE,KAAK,CAAC,gBAAgB;oBAChC,IAAI,EAAE,QAAQ;iBACjB,iBACW,MAAM,iBACN,gBAAgB,EAC5B,SAAS,EAAE,mDAAmD,KAAK,CAAC,eAAe,EAAE,IAThF,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,SAAS,EAAE,CAUvC,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;AAG7C,wBAAgB,KAAK,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,UAAU,+BA4CtE"}
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,+BAgDZ"}
@@ -1,9 +1,11 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useToastLogic } from '../Hooks/useToastLogic.js';
3
3
  import { CustomToast } from './CustomToast.js';
4
- import { AnimatePresence } from 'motion/react';
5
- export function Toast({ customDesign, position, className }) {
4
+ import { AnimatePresence, MotionConfig } from 'motion/react';
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": "Benachrichtigungen", 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 }, toast.id))) }) }));
25
+ return (_jsx(MotionConfig, { reducedMotion: "user", children: _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;AAE9C,MAAM,UAAU,KAAK,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAc;IACnE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,aAAa,EAAE,CAAA;IAC1C,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,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AM,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,KAAC,YAAY,IAAC,aAAa,EAAC,MAAM,YAC9B,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,GACK,CAClB,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,GACZ,EAAE,kBAAkB,+BAiBpB"}
1
+ {"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../../src/Components/ToastProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAGrD,wBAAgB,aAAa,CAAC,EAC1B,QAAQ,EACR,YAAY,EACZ,QAAyB,EACzB,SAAS,EACT,MAAa,EACb,QAAQ,GACX,EAAE,kBAAkB,+BAiBpB"}
@@ -1,12 +1,8 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { lazy, Suspense } from 'react';
3
2
  import { useToastLogic } from '../Hooks/useToastLogic.js';
4
- const LazyToast = lazy(async () => {
5
- const { Toast } = await import('./Toast.js');
6
- return { default: Toast };
7
- });
8
- export function ToastProvider({ children, customDesign, position = 'bottom-right', className, }) {
3
+ import { Toast } from './Toast.js';
4
+ export function ToastProvider({ children, customDesign, position = 'bottom-right', className, locale = 'de', messages, }) {
9
5
  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 }) }))] }));
6
+ return (_jsxs(_Fragment, { children: [children, state.toasts.length > 0 && (_jsx(Toast, { customDesign: customDesign, position: position, className: className, locale: locale, messages: messages }))] }));
11
7
  }
12
8
  //# sourceMappingURL=ToastProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ToastProvider.js","sourceRoot":"","sources":["../../src/Components/ToastProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,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,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,GACpB,CACL,IACF,CACN,CAAA;AACL,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCustomToastLogic.d.ts","sourceRoot":"","sources":["../../src/Hooks/useCustomToastLogic.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAqE9E,wBAAgB,mBAAmB,CAAC,EAChC,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,SAAS,GACZ,EAAE,gBAAgB,GAAG,yBAAyB,CAyL9C"}
1
+ {"version":3,"file":"useCustomToastLogic.d.ts","sourceRoot":"","sources":["../../src/Hooks/useCustomToastLogic.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAqE9E,wBAAgB,mBAAmB,CAAC,EAChC,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,SAAS,GACZ,EAAE,gBAAgB,GAAG,yBAAyB,CA2L9C"}
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useMemo } from 'react';
3
3
  import { AlertCircle, CheckCircle, Info, TriangleAlert } from 'lucide-react';
4
+ import { useReducedMotion } from 'motion/react';
4
5
  import { getToastExitAnimation, getToastInitialAnimation, toastAnimate, toastDragAnimation, toastTransition, } from '../Animations/toastAnimations.js';
5
6
  import { useCopyToastMessage } from './useCopyToastMessage.js';
6
7
  import { getRemainingToastTime } from './toastTiming.js';
@@ -40,10 +41,9 @@ function parseTextWithLinks(text, linkClassName) {
40
41
  }
41
42
  export function useCustomToastLogic({ toast, position, onRemove, customDesign, className, }) {
42
43
  const { state: copyState, handler: copyHandler } = useCopyToastMessage(toast);
44
+ const prefersReducedMotion = useReducedMotion() === true;
43
45
  const remainingTime = getRemainingToastTime(toast);
44
- const startingWidth = toast.duration === 0
45
- ? '0%'
46
- : `${(remainingTime / toast.duration) * 100}%`;
46
+ const startingScale = toast.duration === 0 ? 0 : remainingTime / toast.duration;
47
47
  const progressDuration = remainingTime / 1000;
48
48
  const initialAnimation = useMemo(() => getToastInitialAnimation(position), [position]);
49
49
  const exitAnimation = useMemo(() => getToastExitAnimation(position), [position]);
@@ -53,7 +53,9 @@ export function useCustomToastLogic({ toast, position, onRemove, customDesign, c
53
53
  }
54
54
  };
55
55
  function getWrapperClasses() {
56
- let baseClasses = 'relative overflow-hidden pointer-events-auto flex items-start gap-3 border backdrop-blur-xl cursor-grab';
56
+ let baseClasses = 'relative overflow-hidden pointer-events-auto flex items-start gap-3 border backdrop-blur-xl';
57
+ if (!prefersReducedMotion)
58
+ baseClasses += ' cursor-grab';
57
59
  if (!className?.includes('w-'))
58
60
  baseClasses += ' w-80';
59
61
  if (!className?.includes('rounded'))
@@ -122,7 +124,7 @@ export function useCustomToastLogic({ toast, position, onRemove, customDesign, c
122
124
  void copyHandler.copyToastMessage();
123
125
  }
124
126
  const linkClassName = customDesign?.linkText ||
125
- 'font-bold underline decoration-2 underline-offset-2 hover:opacity-80 transition-opacity cursor-pointer inline-block pointer-events-auto';
127
+ 'font-bold underline decoration-2 underline-offset-2 hover:opacity-80 motion-safe:transition-opacity cursor-pointer inline-block pointer-events-auto';
126
128
  const parsedTitle = useMemo(() => parseTextWithLinks(toast.title, linkClassName), [toast.title, linkClassName]);
127
129
  const parsedContent = useMemo(() => parseTextWithLinks(toast.content, linkClassName), [toast.content, linkClassName]);
128
130
  return {
@@ -133,13 +135,14 @@ export function useCustomToastLogic({ toast, position, onRemove, customDesign, c
133
135
  progressClasses: getProgressClasses(),
134
136
  parsedTitle,
135
137
  parsedContent,
136
- startingWidth,
138
+ startingScale,
137
139
  progressDuration,
138
140
  initialAnimation,
139
141
  animate: toastAnimate,
140
142
  exitAnimation,
141
143
  transition: toastTransition,
142
144
  dragAnimation: toastDragAnimation,
145
+ dragEnabled: !prefersReducedMotion,
143
146
  },
144
147
  handler: {
145
148
  handleCopyError,
@@ -1 +1 @@
1
- {"version":3,"file":"useCustomToastLogic.js","sourceRoot":"","sources":["../../src/Hooks/useCustomToastLogic.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAmC,MAAM,OAAO,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAG5E,OAAO,EACH,qBAAqB,EACrB,wBAAwB,EACxB,YAAY,EACZ,kBAAkB,EAClB,eAAe,GAClB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,MAAM,mBAAmB,GAAG,yBAAyB,CAAA;AAErD,SAAS,eAAe,CAAC,GAAW;IAChC,IAAI,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,+BAA+B,CAAC,CAAA;QAE/D,OAAO,SAAS,CAAC,QAAQ,KAAK,OAAO,IAAI,SAAS,CAAC,QAAQ,KAAK,QAAQ,CAAA;IAC5E,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAA;IAChB,CAAC;AACL,CAAC;AAED,SAAS,kBAAkB,CACvB,IAAwB,EACxB,aAAqB;IAErB,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAEtB,MAAM,KAAK,GAAgB,EAAE,CAAA;IAC7B,IAAI,SAAS,GAAG,CAAC,CAAA;IACjB,IAAI,KAAK,CAAA;IAET,mBAAmB,CAAC,SAAS,GAAG,CAAC,CAAA;IAEjC,OAAO,CAAC,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACvD,IAAI,KAAK,CAAC,KAAK,GAAG,SA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AU,CAAA;IACrB,CAAC;IAED,SAAS,eAAe,CAAC,KAAoC;QACzD,KAAK,CAAC,eAAe,EAAE,CAAA;QACvB,KAAK,WAAW,CAAC,gBAAgB,EAAE,CAAA;IACvC,CAAC;IAED,MAAM,aAAa,GACf,YAAY,EAAE,QAAQ;QACtB,qJAAqJ,CAAA;IAEzJ,MAAM,WAAW,GAAG,OAAO,CACvB,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,EACpD,CAAC,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,CAC/B,CAAA;IAED,MAAM,aAAa,GAAG,OAAO,CACzB,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,EACtD,CAAC,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,CACjC,CAAA;IAED,OAAO;QACH,KAAK,EAAE;YACH,MAAM,EAAE,SAAS,CAAC,MAAM;YACxB,cAAc,EAAE,iBAAiB,EAAE;YACnC,SAAS,EAAE,OAAO,EAAE;YACpB,eAAe,EAAE,kBAAkB,EAAE;YACrC,WAAW;YACX,aAAa;YACb,aAAa;YACb,gBAAgB;YAChB,gBAAgB;YAChB,OAAO,EAAE,YAAY;YACrB,aAAa;YACb,UAAU,EAAE,eAAe;YAC3B,aAAa,EAAE,kBAAkB;YACjC,WAAW,EAAE,CAAC,oBAAoB;SACrC;QACD,OAAO,EAAE;YACL,eAAe;YACf,aAAa;SAChB;KACJ,CAAA;AACL,CAAC"}
@@ -1,15 +1,11 @@
1
- import type { Toast, ToastType } from '../types.js';
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,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAsBnD,wBAAgB,gBAAgB,YAE/B;AAaD,wBAAgB,WAAW,CACvB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,EACd,IAAI,GAAE,SAAqB,EAC3B,QAAQ,GAAE,MAA+B,GAC1C,MAAM,CAsBR;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,QAcrC;AAED,wBAAgB,cAAc,SAQ7B;AAED,wBAAgB,aAAa;;;;;;;;EAa5B"}
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 { DEFAULT_TOAST_DURATION, normalizeToastDuration, } from './toastTiming.js';
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;AAErD,OAAO,EACH,sBAAsB,EACtB,sBAAsB,GACzB,MAAM,kBAAkB,CAAA;AAEzB,IAAI,WAAW,GAAY,EAAE,CAAA;AAC7B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;AACvC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAoD,CAAA;AAE/E,SAAS,eAAe;IACpB,SAAS,CAAC,OAAO,CAAC,CA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AA;AACL,CAAC"}
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
@@ -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 './Hooks/useToastLogic.js';
3
- export type { ToastCustomDesign, ToastPosition, ToastProviderProps, ToastType, } from './types.js';
2
+ export { 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
@@ -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,0BAA0B,CAAA;AACnE,YAAY,EACR,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,SAAS,GACZ,MAAM,YAAY,CAAA"}
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,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,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 './Hooks/useToastLogic.js';
2
+ export { 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,0BAA0B,CAAA"}
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,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { ToastApi } from './types.js';
2
+ export declare const toast: ToastApi;
3
+ //# 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,EAUX,MAAM,YAAY,CAAA;AAiHnB,eAAO,MAAM,KAAK,EAAE,QAAkC,CAAA"}
package/dist/toast.js ADDED
@@ -0,0 +1,63 @@
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
+ const toastApi = {
53
+ success: (content, options) => showToast('success', content, options),
54
+ error: (content, options) => showToast('error', content, options),
55
+ info: (content, options) => showToast('info', content, options),
56
+ warning: (content, options) => showToast('warning', content, options),
57
+ dismiss: removeToast,
58
+ dismissAll: clearAllToasts,
59
+ update: (id, options) => updateToast(id, options),
60
+ promise: promiseToast,
61
+ };
62
+ export const toast = Object.freeze(toastApi);
63
+ //# 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,EACH,cAAc,EACd,WAAW,EACX,WAAW,EACX,WAAW,GACd,MAAM,iBAAiB,CAAA;AAExB,SAAS,SAAS,CAAC,IAAe,EAAE,OAAe,EAAE,OAAsB;IACvE,OAAO,WAAW,CAAC,OAAO,EAAE,OAAO,EAA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,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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ED,WAAW,GAAG,WAAW,CAAC,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: string;
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: {
@@ -37,13 +76,14 @@ export interface UseCustomToastLogicResult {
37
76
  progressClasses: string;
38
77
  parsedTitle: ReactNode;
39
78
  parsedContent: ReactNode;
40
- startingWidth: string;
79
+ startingScale: number;
41
80
  progressDuration: number;
42
81
  initialAnimation: ReturnType<typeof getToastInitialAnimation>;
43
82
  animate: typeof toastAnimate;
44
83
  exitAnimation: ReturnType<typeof getToastExitAnimation>;
45
84
  transition: typeof toastTransition;
46
85
  dragAnimation: typeof toastDragAnimation;
86
+ dragEnabled: boolean;
47
87
  };
48
88
  handler: {
49
89
  handleCopyError: (e: MouseEvent<HTMLButtonElement>) => void;
@@ -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;AAE/C,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;AAChE,MAAM,MAAM,aAAa,GACnB,UAAU,GACV,WAAW,GACX,aAAa,GACb,cAAc,CAAA;AAEpB,MAAM,WAAW,KAAK;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,SAAS,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CACp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;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": "1.0.1",
3
+ "version": "3.0.0",
4
4
  "description": "Accessible, customizable toast notifications for React.",
5
5
  "keywords": [
6
6
  "react",
@@ -17,14 +17,19 @@
17
17
  "type": "module",
18
18
  "files": [
19
19
  "dist",
20
+ "tailwind.css",
20
21
  "README.md",
21
22
  "LICENSE"
22
23
  ],
23
- "sideEffects": false,
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",
27
30
  "test": "bun test",
31
+ "test:browser": "playwright test --config=playwright.config.ts",
32
+ "playground:install": "bun install --cwd playground --frozen-lockfile",
28
33
  "prepare": "bun run build",
29
34
  "pack:check": "bun pm pack --dry-run --ignore-scripts",
30
35
  "playground:dev": "bun --cwd playground dev",
@@ -34,7 +39,7 @@
34
39
  "format": "oxfmt .",
35
40
  "format:check": "oxfmt --check .",
36
41
  "check": "bun run typecheck && bun run lint && bun run format:check && bun run test && bun run build",
37
- "verify": "bun run check && bun run pack:check"
42
+ "verify": "bun run playground:install && bun run check && bun run test:browser && bun run pack:check"
38
43
  },
39
44
  "repository": {
40
45
  "type": "git",
@@ -51,25 +56,41 @@
51
56
  "peerDependencies": {
52
57
  "lucide-react": "^1.0.0",
53
58
  "motion": "^12.38.0 || ^13.0.0",
54
- "react": "^19.3.0",
55
- "react-dom": "^19.3.0"
59
+ "react": "^19.0.0",
60
+ "react-dom": "^19.0.0"
56
61
  },
57
62
  "devDependencies": {
63
+ "@axe-core/playwright": "^4.13.0",
64
+ "@playwright/test": "^1.63.0",
58
65
  "@types/react": "^19.3.0",
59
66
  "@types/react-dom": "^19.3.0",
60
67
  "lucide-react": "^1.47.0",
61
68
  "motion": "^13.4.0",
69
+ "oxfmt": "^0.68.0",
70
+ "oxlint": "^1.83.0",
62
71
  "react": "^19.3.0",
63
72
  "react-dom": "^19.3.0",
64
- "typescript": "^7.0.2",
65
- "oxfmt": "^0.68.0",
66
- "oxlint": "^1.83.0"
73
+ "typescript": "^7.0.2"
67
74
  },
68
75
  "exports": {
69
76
  ".": {
70
77
  "types": "./dist/index.d.ts",
71
78
  "import": "./dist/index.js"
72
- }
79
+ },
80
+ "./tailwind.css": "./tailwind.css",
81
+ "./toast": {
82
+ "types": "./dist/toast.d.ts",
83
+ "import": "./dist/toast.js"
84
+ },
85
+ "./messages": {
86
+ "types": "./dist/i18n.d.ts",
87
+ "import": "./dist/i18n.js"
88
+ },
89
+ "./types": {
90
+ "types": "./dist/types.d.ts",
91
+ "import": "./dist/types.js"
92
+ },
93
+ "./package.json": "./package.json"
73
94
  },
74
- "packageManager": "bun@1.4.0"
95
+ "packageManager": "bun@1.4.2"
75
96
  }
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
+ }