@rentnerkev/toasts 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +175 -0
- package/dist/Animations/toastAnimations.d.ts +66 -0
- package/dist/Animations/toastAnimations.d.ts.map +1 -0
- package/dist/Animations/toastAnimations.js +47 -0
- package/dist/Animations/toastAnimations.js.map +1 -0
- package/dist/Components/CustomToast.d.ts +8 -0
- package/dist/Components/CustomToast.d.ts.map +1 -0
- package/dist/Components/CustomToast.js +21 -0
- package/dist/Components/CustomToast.js.map +1 -0
- package/dist/Components/Toast.d.ts +3 -0
- package/dist/Components/Toast.d.ts.map +1 -0
- package/dist/Components/Toast.js +25 -0
- package/dist/Components/Toast.js.map +1 -0
- package/dist/Components/ToastProvider.d.ts +3 -0
- package/dist/Components/ToastProvider.d.ts.map +1 -0
- package/dist/Components/ToastProvider.js +12 -0
- package/dist/Components/ToastProvider.js.map +1 -0
- package/dist/Hooks/toastTiming.d.ts +6 -0
- package/dist/Hooks/toastTiming.d.ts.map +1 -0
- package/dist/Hooks/toastTiming.js +18 -0
- package/dist/Hooks/toastTiming.js.map +1 -0
- package/dist/Hooks/useCopyToastMessage.d.ts +16 -0
- package/dist/Hooks/useCopyToastMessage.d.ts.map +1 -0
- package/dist/Hooks/useCopyToastMessage.js +36 -0
- package/dist/Hooks/useCopyToastMessage.js.map +1 -0
- package/dist/Hooks/useCustomToastLogic.d.ts +3 -0
- package/dist/Hooks/useCustomToastLogic.d.ts.map +1 -0
- package/dist/Hooks/useCustomToastLogic.js +150 -0
- package/dist/Hooks/useCustomToastLogic.js.map +1 -0
- package/dist/Hooks/useToastLogic.d.ts +15 -0
- package/dist/Hooks/useToastLogic.d.ts.map +1 -0
- package/dist/Hooks/useToastLogic.js +74 -0
- package/dist/Hooks/useToastLogic.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +72 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RentnerKev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# @rentnerkev/toasts
|
|
2
|
+
|
|
3
|
+
Zugängliche und anpassbare Toast-Benachrichtigungen für React mit vier
|
|
4
|
+
Statusvarianten, Fortschrittsanzeige, Markdown-Links und Tailwind CSS.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
bun add @rentnerkev/toasts
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
oder:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @rentnerkev/toasts
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
React, React DOM, Motion und Lucide React werden als Peer Dependencies vom
|
|
19
|
+
Consumer bereitgestellt.
|
|
20
|
+
|
|
21
|
+
## Schnellstart
|
|
22
|
+
|
|
23
|
+
### Provider einrichten
|
|
24
|
+
|
|
25
|
+
Der `ToastProvider` rendert die Toasts. Binde ihn einmal oberhalb des
|
|
26
|
+
Bereichs ein, aus dem Toasts angezeigt werden sollen:
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { ToastProvider } from '@rentnerkev/toasts'
|
|
30
|
+
|
|
31
|
+
export function App() {
|
|
32
|
+
return (
|
|
33
|
+
<ToastProvider position="bottom-right">
|
|
34
|
+
<MainApp />
|
|
35
|
+
</ToastProvider>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Toast anzeigen
|
|
41
|
+
|
|
42
|
+
`customToast` kann innerhalb und außerhalb von React-Komponenten aufgerufen
|
|
43
|
+
werden. Die Funktion liefert die ID des neuen Toasts zurück:
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { customToast } from '@rentnerkev/toasts'
|
|
47
|
+
|
|
48
|
+
const toastId = customToast('Deine Nachricht', 'Erfolg', 'success', 5000)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Toast entfernen
|
|
52
|
+
|
|
53
|
+
Entferne einen Toast mit der von `customToast` zurückgegebenen ID:
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { removeToast } from '@rentnerkev/toasts'
|
|
57
|
+
|
|
58
|
+
removeToast(toastId)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Varianten und Dauer
|
|
62
|
+
|
|
63
|
+
Verfügbare Varianten sind `success`, `error`, `info` und `warning`. Die
|
|
64
|
+
Signatur lautet:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
customToast(
|
|
68
|
+
content: string,
|
|
69
|
+
title?: string,
|
|
70
|
+
type?: ToastType,
|
|
71
|
+
duration?: number,
|
|
72
|
+
): string
|
|
73
|
+
```
|
|
74
|
+
|
|
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.
|
|
80
|
+
|
|
81
|
+
## Styling
|
|
82
|
+
|
|
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:
|
|
85
|
+
|
|
86
|
+
```css
|
|
87
|
+
@import 'tailwindcss';
|
|
88
|
+
@source "../node_modules/@rentnerkev/toasts";
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Der `ToastProvider` unterstützt folgende Props:
|
|
92
|
+
|
|
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. |
|
|
99
|
+
|
|
100
|
+
### Eigenes Design
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
const customDesign = {
|
|
104
|
+
successWrapper: 'bg-green-100 border-l-4 border-green-500',
|
|
105
|
+
successProgress: 'bg-green-600',
|
|
106
|
+
linkText: 'text-blue-600 hover:underline',
|
|
107
|
+
titleText: 'font-bold text-green-900',
|
|
108
|
+
contentText: 'text-green-700',
|
|
109
|
+
closeButton: 'text-green-500 hover:text-green-700',
|
|
110
|
+
copyButton: 'text-blue-500 hover:text-blue-700',
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
<ToastProvider customDesign={customDesign}>
|
|
114
|
+
<App />
|
|
115
|
+
</ToastProvider>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Verfügbare `ToastCustomDesign`-Felder:
|
|
119
|
+
|
|
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. |
|
|
130
|
+
|
|
131
|
+
## Links in Toasts
|
|
132
|
+
|
|
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.
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
customToast(
|
|
139
|
+
'Öffne [das Ticket](https://example.com/tickets/45).',
|
|
140
|
+
'Neues Ticket',
|
|
141
|
+
'info',
|
|
142
|
+
)
|
|
143
|
+
```
|
|
144
|
+
|
|
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.
|
|
148
|
+
|
|
149
|
+
## TypeScript
|
|
150
|
+
|
|
151
|
+
Die wichtigsten Typen können direkt aus dem Paket importiert werden:
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
import type {
|
|
155
|
+
ToastCustomDesign,
|
|
156
|
+
ToastPosition,
|
|
157
|
+
ToastProviderProps,
|
|
158
|
+
ToastType,
|
|
159
|
+
} from '@rentnerkev/toasts'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Entwicklung
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
bun install
|
|
166
|
+
bun run check
|
|
167
|
+
bun run playground:dev
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Der Playground bleibt eine lokale Entwicklungs- und Testumgebung und ist
|
|
171
|
+
nicht Bestandteil des npm-Pakets.
|
|
172
|
+
|
|
173
|
+
## Lizenz
|
|
174
|
+
|
|
175
|
+
MIT, siehe [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ToastPosition } from '../types.js';
|
|
2
|
+
export declare function getToastInitialAnimation(position: ToastPosition): {
|
|
3
|
+
opacity: number;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
scale: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function getToastExitAnimation(position: ToastPosition): {
|
|
9
|
+
opacity: number;
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
scale: number;
|
|
13
|
+
transition: {
|
|
14
|
+
duration: number;
|
|
15
|
+
ease: "easeOut";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare const toastAnimate: {
|
|
19
|
+
opacity: number;
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
scale: number;
|
|
23
|
+
};
|
|
24
|
+
export declare const toastTransition: {
|
|
25
|
+
layout: {
|
|
26
|
+
type: "tween";
|
|
27
|
+
duration: number;
|
|
28
|
+
ease: "easeOut";
|
|
29
|
+
};
|
|
30
|
+
x: {
|
|
31
|
+
type: "spring";
|
|
32
|
+
stiffness: number;
|
|
33
|
+
damping: number;
|
|
34
|
+
};
|
|
35
|
+
y: {
|
|
36
|
+
type: "spring";
|
|
37
|
+
stiffness: number;
|
|
38
|
+
damping: number;
|
|
39
|
+
};
|
|
40
|
+
scale: {
|
|
41
|
+
type: "spring";
|
|
42
|
+
stiffness: number;
|
|
43
|
+
damping: number;
|
|
44
|
+
};
|
|
45
|
+
opacity: {
|
|
46
|
+
duration: number;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export declare const toastDragAnimation: {
|
|
50
|
+
scale: number;
|
|
51
|
+
cursor: string;
|
|
52
|
+
};
|
|
53
|
+
export declare const closeButtonIconTransition: {
|
|
54
|
+
type: "spring";
|
|
55
|
+
stiffness: number;
|
|
56
|
+
damping: number;
|
|
57
|
+
};
|
|
58
|
+
export declare const closeButtonIconVariants: {
|
|
59
|
+
idle: {
|
|
60
|
+
rotate: number;
|
|
61
|
+
};
|
|
62
|
+
hover: {
|
|
63
|
+
rotate: number;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=toastAnimations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toastAnimations.d.ts","sourceRoot":"","sources":["../../src/Animations/toastAnimations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAShD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,aAAa;;;;;EAI/D;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa;;;;;;;;;EAU5D;AAED,eAAO,MAAM,YAAY;;;;;CAKS,CAAA;AAElC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;QAKb,QAAQ;;CACc,CAAA;AAErC,eAAO,MAAM,kBAAkB;;;CAGK,CAAA;AAEpC,eAAO,MAAM,yBAAyB;;;;CAID,CAAA;AAErC,eAAO,MAAM,uBAAuB;;QACxB,MAAM;;;QACL,MAAM;;CACgB,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
function getToastCornerOffset(position) {
|
|
2
|
+
return {
|
|
3
|
+
x: position.includes('right') ? 100 : -100,
|
|
4
|
+
y: position.includes('top') ? -80 : 80,
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function getToastInitialAnimation(position) {
|
|
8
|
+
const { x, y } = getToastCornerOffset(position);
|
|
9
|
+
return { opacity: 0, x, y, scale: 0.9 };
|
|
10
|
+
}
|
|
11
|
+
export function getToastExitAnimation(position) {
|
|
12
|
+
const { x, y } = getToastCornerOffset(position);
|
|
13
|
+
return {
|
|
14
|
+
opacity: 0,
|
|
15
|
+
x,
|
|
16
|
+
y,
|
|
17
|
+
scale: 0.9,
|
|
18
|
+
transition: { duration: 0.3, ease: 'easeOut' },
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export const toastAnimate = {
|
|
22
|
+
opacity: 1,
|
|
23
|
+
x: 0,
|
|
24
|
+
y: 0,
|
|
25
|
+
scale: 1,
|
|
26
|
+
};
|
|
27
|
+
export const toastTransition = {
|
|
28
|
+
layout: { type: 'tween', duration: 0.22, ease: 'easeOut' },
|
|
29
|
+
x: { type: 'spring', stiffness: 200, damping: 24 },
|
|
30
|
+
y: { type: 'spring', stiffness: 200, damping: 24 },
|
|
31
|
+
scale: { type: 'spring', stiffness: 200, damping: 24 },
|
|
32
|
+
opacity: { duration: 0.2 },
|
|
33
|
+
};
|
|
34
|
+
export const toastDragAnimation = {
|
|
35
|
+
scale: 1.02,
|
|
36
|
+
cursor: 'grabbing',
|
|
37
|
+
};
|
|
38
|
+
export const closeButtonIconTransition = {
|
|
39
|
+
type: 'spring',
|
|
40
|
+
stiffness: 300,
|
|
41
|
+
damping: 20,
|
|
42
|
+
};
|
|
43
|
+
export const closeButtonIconVariants = {
|
|
44
|
+
idle: { rotate: 0 },
|
|
45
|
+
hover: { rotate: 90 },
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=toastAnimations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toastAnimations.js","sourceRoot":"","sources":["../../src/Animations/toastAnimations.ts"],"names":[],"mappings":"AAGA,SAAS,oBAAoB,CAAC,QAAuB;IACjD,OAAO;QACH,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG;QAC1C,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;KACzC,CAAA;AACL,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,QAAuB;IAC5D,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IAE/C,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAmC,CAAA;AAC5E,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,QAAuB;IACzD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IAE/C,OAAO;QACH,OAAO,EAAE,CAAC;QACV,CAAC;QACD,CAAC;QACD,KAAK,EAAE,GAAG;QACV,UAAU,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE;KACnB,CAAA;AACnC,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,OAAO,EAAE,CAAC;IACV,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,KAAK,EAAE,CAAC;CACsB,CAAA;AAElC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;IAC1D,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IAClD,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IAClD,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IACtD,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;CACO,CAAA;AAErC,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAC9B,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,UAAU;CACc,CAAA;AAEpC,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACrC,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,GAAG;IACd,OAAO,EAAE,EAAE;CACsB,CAAA;AAErC,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACnC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE;IACnB,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;CACU,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Ref } from 'react';
|
|
2
|
+
import type { CustomToastProps } from '../types.js';
|
|
3
|
+
type CustomToastComponentProps = CustomToastProps & {
|
|
4
|
+
ref?: Ref<HTMLDivElement>;
|
|
5
|
+
};
|
|
6
|
+
export declare function CustomToast({ toast, position, onRemove, customDesign, className, ref, }: CustomToastComponentProps): import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=CustomToast.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check, Copy, X } from 'lucide-react';
|
|
3
|
+
import { motion } from 'motion/react';
|
|
4
|
+
import { closeButtonIconTransition, closeButtonIconVariants, } from '../Animations/toastAnimations.js';
|
|
5
|
+
import { useCustomToastLogic } from '../Hooks/useCustomToastLogic.js';
|
|
6
|
+
export function CustomToast({ toast, position, onRemove, customDesign, className, ref, }) {
|
|
7
|
+
const { state, handler } = useCustomToastLogic({
|
|
8
|
+
toast,
|
|
9
|
+
position,
|
|
10
|
+
onRemove,
|
|
11
|
+
customDesign,
|
|
12
|
+
className,
|
|
13
|
+
});
|
|
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: {
|
|
17
|
+
duration: state.progressDuration,
|
|
18
|
+
ease: 'linear',
|
|
19
|
+
}, "aria-hidden": "true", className: `absolute bottom-0 left-0 h-1 ${state.progressClasses}` }))] }));
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=CustomToast.js.map
|
|
@@ -0,0 +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,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[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7C,wBAAgB,KAAK,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,UAAU,+BA4CtE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useToastLogic } from '../Hooks/useToastLogic.js';
|
|
3
|
+
import { CustomToast } from './CustomToast.js';
|
|
4
|
+
import { AnimatePresence } from 'motion/react';
|
|
5
|
+
export function Toast({ customDesign, position, className }) {
|
|
6
|
+
const { state, handler } = useToastLogic();
|
|
7
|
+
const anchorX = position.includes('right') ? 'right' : 'left';
|
|
8
|
+
const anchorY = position.includes('bottom') ? 'bottom' : 'top';
|
|
9
|
+
function getPositionClasses() {
|
|
10
|
+
switch (position) {
|
|
11
|
+
case 'top-left':
|
|
12
|
+
return 'top-0 left-0 p-4 flex-col-reverse';
|
|
13
|
+
case 'top-right':
|
|
14
|
+
return 'top-0 right-0 p-4 flex-col-reverse';
|
|
15
|
+
case 'bottom-left':
|
|
16
|
+
return 'bottom-0 left-0 p-4 flex-col';
|
|
17
|
+
case 'bottom-right':
|
|
18
|
+
return 'bottom-0 right-0 p-4 flex-col';
|
|
19
|
+
default:
|
|
20
|
+
return 'bottom-0 right-0 p-4 flex-col';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
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))) }) }));
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=Toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.js","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C,WAAW,EAC7B,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,IALf,KAAK,CAAC,EAAE,CAMf,CACL,CAAC,GACY,GAChB,CACT,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { lazy, Suspense } from 'react';
|
|
3
|
+
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, }) {
|
|
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 }) }))] }));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ToastProvider.js.map
|
|
@@ -0,0 +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,GACQ;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,GACtB,GACK,CACd,IACF,CACN,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Toast } from '../types.js';
|
|
2
|
+
export declare const DEFAULT_TOAST_DURATION = 6000;
|
|
3
|
+
export declare const MAX_TOAST_DURATION = 2147483647;
|
|
4
|
+
export declare function normalizeToastDuration(duration?: number): number;
|
|
5
|
+
export declare function getRemainingToastTime(toast: Pick<Toast, 'duration' | 'createdAt'>): number;
|
|
6
|
+
//# sourceMappingURL=toastTiming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toastTiming.d.ts","sourceRoot":"","sources":["../../src/Hooks/toastTiming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,eAAO,MAAM,sBAAsB,OAAO,CAAA;AAC1C,eAAO,MAAM,kBAAkB,aAAgB,CAAA;AAE/C,wBAAgB,sBAAsB,CAAC,QAAQ,CAAC,EAAE,MAAM,UAUvD;AAED,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAAC,UAO/C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const DEFAULT_TOAST_DURATION = 6000;
|
|
2
|
+
export const MAX_TOAST_DURATION = 2_147_483_647;
|
|
3
|
+
export function normalizeToastDuration(duration) {
|
|
4
|
+
if (duration === undefined || duration === 0) {
|
|
5
|
+
return duration ?? DEFAULT_TOAST_DURATION;
|
|
6
|
+
}
|
|
7
|
+
if (!Number.isFinite(duration) || duration < 0) {
|
|
8
|
+
return DEFAULT_TOAST_DURATION;
|
|
9
|
+
}
|
|
10
|
+
return Math.min(Math.max(Math.round(duration), 1), MAX_TOAST_DURATION);
|
|
11
|
+
}
|
|
12
|
+
export function getRemainingToastTime(toast) {
|
|
13
|
+
if (toast.duration === 0)
|
|
14
|
+
return 0;
|
|
15
|
+
const elapsedTime = Math.max(0, Date.now() - toast.createdAt);
|
|
16
|
+
return Math.min(toast.duration, Math.max(0, toast.duration - elapsedTime));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=toastTiming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toastTiming.js","sourceRoot":"","sources":["../../src/Hooks/toastTiming.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAA;AAC1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAA;AAE/C,MAAM,UAAU,sBAAsB,CAAC,QAAiB;IACpD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAO,QAAQ,IAAI,sBAAsB,CAAA;IAC7C,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QAC7C,OAAO,sBAAsB,CAAA;IACjC,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAA;AAC1E,CAAC;AAED,MAAM,UAAU,qBAAqB,CACjC,KAA4C;IAE5C,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC;QAAE,OAAO,CAAC,CAAA;IAElC,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,CAAA;IAE7D,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAA;AAC9E,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Toast } from '../types.js';
|
|
2
|
+
interface UseCopyToastMessageResult {
|
|
3
|
+
state: {
|
|
4
|
+
copied: boolean;
|
|
5
|
+
};
|
|
6
|
+
handler: {
|
|
7
|
+
clearCopiedTimeout: () => void;
|
|
8
|
+
copyToastMessage: () => Promise<boolean>;
|
|
9
|
+
};
|
|
10
|
+
setter: {
|
|
11
|
+
setCopied: (copied: boolean) => void;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function useCopyToastMessage(toast: Toast): UseCopyToastMessageResult;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=useCopyToastMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopyToastMessage.d.ts","sourceRoot":"","sources":["../../src/Hooks/useCopyToastMessage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,UAAU,yBAAyB;IAC/B,KAAK,EAAE;QACH,MAAM,EAAE,OAAO,CAAA;KAClB,CAAA;IACD,OAAO,EAAE;QACL,kBAAkB,EAAE,MAAM,IAAI,CAAA;QAC9B,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;KAC3C,CAAA;IACD,MAAM,EAAE;QACJ,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;KACvC,CAAA;CACJ;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,yBAAyB,CA0C3E"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
export function useCopyToastMessage(toast) {
|
|
3
|
+
const [copied, setCopied] = useState(false);
|
|
4
|
+
const copiedTimeoutRef = useRef(null);
|
|
5
|
+
const toastMessage = useMemo(() => [toast.title, toast.content].filter(Boolean).join('\n'), [toast.title, toast.content]);
|
|
6
|
+
const clearCopiedTimeout = useCallback(() => {
|
|
7
|
+
if (copiedTimeoutRef.current === null)
|
|
8
|
+
return;
|
|
9
|
+
window.clearTimeout(copiedTimeoutRef.current);
|
|
10
|
+
copiedTimeoutRef.current = null;
|
|
11
|
+
}, []);
|
|
12
|
+
const copyToastMessage = useCallback(async () => {
|
|
13
|
+
try {
|
|
14
|
+
await navigator.clipboard.writeText(toastMessage);
|
|
15
|
+
clearCopiedTimeout();
|
|
16
|
+
setCopied(true);
|
|
17
|
+
copiedTimeoutRef.current = window.setTimeout(() => {
|
|
18
|
+
setCopied(false);
|
|
19
|
+
copiedTimeoutRef.current = null;
|
|
20
|
+
}, 1500);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
clearCopiedTimeout();
|
|
25
|
+
setCopied(false);
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}, [clearCopiedTimeout, toastMessage]);
|
|
29
|
+
useEffect(() => clearCopiedTimeout, [clearCopiedTimeout]);
|
|
30
|
+
return {
|
|
31
|
+
state: { copied },
|
|
32
|
+
handler: { clearCopiedTimeout, copyToastMessage },
|
|
33
|
+
setter: { setCopied },
|
|
34
|
+
};
|
|
35
|
+
}
|
|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C,CAAA;gBAChB,gBAAgB,CAAC,OAAO,GAAG,IAAI,CAAA;YACnC,CAAC,EAAE,IAAI,CAAC,CAAA;YAER,OAAO,IAAI,CAAA;QACf,CAAC;QAAC,MAAM,CAAC;YACL,kBAAkB,EAAE,CAAA;YACpB,SAAS,CAAC,KAAK,CAAC,CAAA;YAEhB,OAAO,KAAK,CAAA;QAChB,CAAC;IACL,CAAC,EAAE,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC,CAAA;IAEtC,SAAS,CAAC,GAAG,EAAE,CAAC,kBAAkB,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAA;IAEzD,OAAO;QACH,KAAK,EAAE,EAAE,MAAM,EAAE;QACjB,OAAO,EAAE,EAAE,kBAAkB,EAAE,gBAAgB,EAAE;QACjD,MAAM,EAAE,EAAE,SAAS,EAAE;KACxB,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CustomToastProps, UseCustomToastLogicResult } from '../types.js';
|
|
2
|
+
export declare function useCustomToastLogic({ toast, position, onRemove, customDesign, className, }: CustomToastProps): UseCustomToastLogicResult;
|
|
3
|
+
//# sourceMappingURL=useCustomToastLogic.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { AlertCircle, CheckCircle, Info, TriangleAlert } from 'lucide-react';
|
|
4
|
+
import { getToastExitAnimation, getToastInitialAnimation, toastAnimate, toastDragAnimation, toastTransition, } from '../Animations/toastAnimations.js';
|
|
5
|
+
import { useCopyToastMessage } from './useCopyToastMessage.js';
|
|
6
|
+
import { getRemainingToastTime } from './toastTiming.js';
|
|
7
|
+
const MARKDOWN_LINK_REGEX = /\[([^\]]+)]\(([^)]+)\)/g;
|
|
8
|
+
function isSafeToastLink(url) {
|
|
9
|
+
try {
|
|
10
|
+
const parsedUrl = new URL(url, 'https://rentnertoasts.invalid');
|
|
11
|
+
return parsedUrl.protocol === 'http:' || parsedUrl.protocol === 'https:';
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function parseTextWithLinks(text, linkClassName) {
|
|
18
|
+
if (!text)
|
|
19
|
+
return null;
|
|
20
|
+
const parts = [];
|
|
21
|
+
let lastIndex = 0;
|
|
22
|
+
let match;
|
|
23
|
+
MARKDOWN_LINK_REGEX.lastIndex = 0;
|
|
24
|
+
while ((match = MARKDOWN_LINK_REGEX.exec(text)) !== null) {
|
|
25
|
+
if (match.index > lastIndex) {
|
|
26
|
+
parts.push(text.substring(lastIndex, match.index));
|
|
27
|
+
}
|
|
28
|
+
if (!isSafeToastLink(match[2])) {
|
|
29
|
+
parts.push(match[0]);
|
|
30
|
+
lastIndex = MARKDOWN_LINK_REGEX.lastIndex;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
parts.push(_jsx("a", { href: match[2], target: "_blank", rel: "noopener noreferrer", className: linkClassName, onClick: (event) => event.stopPropagation(), children: match[1] }, match.index));
|
|
34
|
+
lastIndex = MARKDOWN_LINK_REGEX.lastIndex;
|
|
35
|
+
}
|
|
36
|
+
if (lastIndex < text.length) {
|
|
37
|
+
parts.push(text.substring(lastIndex));
|
|
38
|
+
}
|
|
39
|
+
return parts;
|
|
40
|
+
}
|
|
41
|
+
export function useCustomToastLogic({ toast, position, onRemove, customDesign, className, }) {
|
|
42
|
+
const { state: copyState, handler: copyHandler } = useCopyToastMessage(toast);
|
|
43
|
+
const remainingTime = getRemainingToastTime(toast);
|
|
44
|
+
const startingWidth = toast.duration === 0
|
|
45
|
+
? '0%'
|
|
46
|
+
: `${(remainingTime / toast.duration) * 100}%`;
|
|
47
|
+
const progressDuration = remainingTime / 1000;
|
|
48
|
+
const initialAnimation = useMemo(() => getToastInitialAnimation(position), [position]);
|
|
49
|
+
const exitAnimation = useMemo(() => getToastExitAnimation(position), [position]);
|
|
50
|
+
const handleDragEnd = (_e, info) => {
|
|
51
|
+
if (Math.abs(info.offset.x) > 80 || Math.abs(info.velocity.x) > 400) {
|
|
52
|
+
onRemove(toast.id);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
function getWrapperClasses() {
|
|
56
|
+
let baseClasses = 'relative overflow-hidden pointer-events-auto flex items-start gap-3 border backdrop-blur-xl cursor-grab';
|
|
57
|
+
if (!className?.includes('w-'))
|
|
58
|
+
baseClasses += ' w-80';
|
|
59
|
+
if (!className?.includes('rounded'))
|
|
60
|
+
baseClasses += ' rounded-xl';
|
|
61
|
+
if (!className?.includes('p-') &&
|
|
62
|
+
!className?.includes('px-') &&
|
|
63
|
+
!className?.includes('py-')) {
|
|
64
|
+
baseClasses += ' px-4 py-4';
|
|
65
|
+
}
|
|
66
|
+
if (!className?.includes('shadow')) {
|
|
67
|
+
baseClasses += ' shadow-2xl';
|
|
68
|
+
}
|
|
69
|
+
if (className) {
|
|
70
|
+
baseClasses += ` ${className}`;
|
|
71
|
+
}
|
|
72
|
+
if (toast.type === 'success') {
|
|
73
|
+
return `${baseClasses} ${customDesign?.successWrapper ||
|
|
74
|
+
'bg-emerald-950/95 border-emerald-500/30 text-emerald-50'}`;
|
|
75
|
+
}
|
|
76
|
+
if (toast.type === 'error') {
|
|
77
|
+
return `${baseClasses} ${customDesign?.errorWrapper ||
|
|
78
|
+
'bg-rose-950/95 border-rose-500/30 text-rose-50'}`;
|
|
79
|
+
}
|
|
80
|
+
if (toast.type === 'info') {
|
|
81
|
+
return `${baseClasses} ${customDesign?.infoWrapper ||
|
|
82
|
+
'bg-blue-950/95 border-blue-500/30 text-blue-50'}`;
|
|
83
|
+
}
|
|
84
|
+
if (toast.type === 'warning') {
|
|
85
|
+
return `${baseClasses} ${customDesign?.warningWrapper ||
|
|
86
|
+
'bg-amber-950/95 border-amber-500/30 text-amber-50'}`;
|
|
87
|
+
}
|
|
88
|
+
return baseClasses;
|
|
89
|
+
}
|
|
90
|
+
function getIcon() {
|
|
91
|
+
if (toast.type === 'success') {
|
|
92
|
+
return (_jsx(CheckCircle, { size: 18, "aria-hidden": "true", className: customDesign?.successIcon || 'text-emerald-400' }));
|
|
93
|
+
}
|
|
94
|
+
if (toast.type === 'error') {
|
|
95
|
+
return (_jsx(AlertCircle, { size: 18, "aria-hidden": "true", className: customDesign?.errorIcon || 'text-rose-400' }));
|
|
96
|
+
}
|
|
97
|
+
if (toast.type === 'info') {
|
|
98
|
+
return (_jsx(Info, { size: 18, "aria-hidden": "true", className: customDesign?.infoIcon || 'text-blue-400' }));
|
|
99
|
+
}
|
|
100
|
+
if (toast.type === 'warning') {
|
|
101
|
+
return (_jsx(TriangleAlert, { size: 18, "aria-hidden": "true", className: customDesign?.warningIcon || 'text-amber-400' }));
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
function getProgressClasses() {
|
|
106
|
+
if (toast.type === 'success') {
|
|
107
|
+
return customDesign?.successProgress || 'bg-emerald-500';
|
|
108
|
+
}
|
|
109
|
+
if (toast.type === 'error') {
|
|
110
|
+
return customDesign?.errorProgress || 'bg-rose-500';
|
|
111
|
+
}
|
|
112
|
+
if (toast.type === 'info') {
|
|
113
|
+
return customDesign?.infoProgress || 'bg-blue-500';
|
|
114
|
+
}
|
|
115
|
+
if (toast.type === 'warning') {
|
|
116
|
+
return customDesign?.warningProgress || 'bg-amber-500';
|
|
117
|
+
}
|
|
118
|
+
return 'bg-white';
|
|
119
|
+
}
|
|
120
|
+
function handleCopyError(event) {
|
|
121
|
+
event.stopPropagation();
|
|
122
|
+
void copyHandler.copyToastMessage();
|
|
123
|
+
}
|
|
124
|
+
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';
|
|
126
|
+
const parsedTitle = useMemo(() => parseTextWithLinks(toast.title, linkClassName), [toast.title, linkClassName]);
|
|
127
|
+
const parsedContent = useMemo(() => parseTextWithLinks(toast.content, linkClassName), [toast.content, linkClassName]);
|
|
128
|
+
return {
|
|
129
|
+
state: {
|
|
130
|
+
copied: copyState.copied,
|
|
131
|
+
wrapperClasses: getWrapperClasses(),
|
|
132
|
+
toastIcon: getIcon(),
|
|
133
|
+
progressClasses: getProgressClasses(),
|
|
134
|
+
parsedTitle,
|
|
135
|
+
parsedContent,
|
|
136
|
+
startingWidth,
|
|
137
|
+
progressDuration,
|
|
138
|
+
initialAnimation,
|
|
139
|
+
animate: toastAnimate,
|
|
140
|
+
exitAnimation,
|
|
141
|
+
transition: toastTransition,
|
|
142
|
+
dragAnimation: toastDragAnimation,
|
|
143
|
+
},
|
|
144
|
+
handler: {
|
|
145
|
+
handleCopyError,
|
|
146
|
+
handleDragEnd,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=useCustomToastLogic.js.map
|
|
@@ -0,0 +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,eA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AAe;YACf,aAAa;SAChB;KACJ,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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;
|
|
6
|
+
export declare function useToastLogic(): {
|
|
7
|
+
handler: {
|
|
8
|
+
removeToast: typeof removeToast;
|
|
9
|
+
};
|
|
10
|
+
state: {
|
|
11
|
+
toasts: Toast[];
|
|
12
|
+
visibleToasts: Toast[];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useToastLogic.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
}
|
|
66
|
+
export function useToastLogic() {
|
|
67
|
+
const toasts = useSyncExternalStore(subscribeToToasts, getToastSnapshot, getToastSnapshot);
|
|
68
|
+
const visibleToasts = useMemo(() => toasts.slice(-3), [toasts]);
|
|
69
|
+
return {
|
|
70
|
+
handler: { removeToast },
|
|
71
|
+
state: { toasts, visibleToasts },
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=useToastLogic.js.map
|
|
@@ -0,0 +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,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;AAC/C,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAoB;IAC3C,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAEvB,OAAO,GAAG,EAAE;QACR,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC9B,CAAC,CAAA;AACL,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC5B,OAAO,WAAW,CAAA;AACtB,CAAC;AAED,SAAS,mBAAmB,CAAC,EAAU,EAAE,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ED
|
@@ -0,0 +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"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ReactNode, MouseEvent } from 'react';
|
|
2
|
+
import type { getToastExitAnimation, getToastInitialAnimation, toastAnimate, toastDragAnimation, toastTransition } from './Animations/toastAnimations.js';
|
|
3
|
+
import type { MotionProps } from 'motion/react';
|
|
4
|
+
export type ToastType = 'success' | 'error' | 'info' | 'warning';
|
|
5
|
+
export type ToastPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
6
|
+
export interface Toast {
|
|
7
|
+
id: string;
|
|
8
|
+
content: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
type: ToastType;
|
|
11
|
+
duration: number;
|
|
12
|
+
createdAt: number;
|
|
13
|
+
}
|
|
14
|
+
export interface CustomToastProps {
|
|
15
|
+
toast: Toast;
|
|
16
|
+
position: ToastPosition;
|
|
17
|
+
onRemove: (id: string) => void;
|
|
18
|
+
customDesign?: ToastCustomDesign;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ToastProps {
|
|
22
|
+
customDesign?: ToastCustomDesign;
|
|
23
|
+
position: ToastPosition;
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ToastProviderProps {
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
customDesign?: ToastCustomDesign;
|
|
29
|
+
position?: ToastPosition;
|
|
30
|
+
className?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface UseCustomToastLogicResult {
|
|
33
|
+
state: {
|
|
34
|
+
copied: boolean;
|
|
35
|
+
wrapperClasses: string;
|
|
36
|
+
toastIcon: ReactNode;
|
|
37
|
+
progressClasses: string;
|
|
38
|
+
parsedTitle: ReactNode;
|
|
39
|
+
parsedContent: ReactNode;
|
|
40
|
+
startingWidth: string;
|
|
41
|
+
progressDuration: number;
|
|
42
|
+
initialAnimation: ReturnType<typeof getToastInitialAnimation>;
|
|
43
|
+
animate: typeof toastAnimate;
|
|
44
|
+
exitAnimation: ReturnType<typeof getToastExitAnimation>;
|
|
45
|
+
transition: typeof toastTransition;
|
|
46
|
+
dragAnimation: typeof toastDragAnimation;
|
|
47
|
+
};
|
|
48
|
+
handler: {
|
|
49
|
+
handleCopyError: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
50
|
+
handleDragEnd: NonNullable<MotionProps['onDragEnd']>;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export interface ToastCustomDesign {
|
|
54
|
+
successWrapper?: string;
|
|
55
|
+
errorWrapper?: string;
|
|
56
|
+
infoWrapper?: string;
|
|
57
|
+
warningWrapper?: string;
|
|
58
|
+
successIcon?: string;
|
|
59
|
+
errorIcon?: string;
|
|
60
|
+
infoIcon?: string;
|
|
61
|
+
warningIcon?: string;
|
|
62
|
+
successProgress?: string;
|
|
63
|
+
errorProgress?: string;
|
|
64
|
+
infoProgress?: string;
|
|
65
|
+
warningProgress?: string;
|
|
66
|
+
titleText?: string;
|
|
67
|
+
contentText?: string;
|
|
68
|
+
closeButton?: string;
|
|
69
|
+
copyButton?: string;
|
|
70
|
+
linkText?: string;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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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ACxB,gBAAgB,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAA;QAC7D,OAAO,EAAE,OAAO,YAAY,CAAA;QAC5B,aAAa,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAA;QACvD,UAAU,EAAE,OAAO,eAAe,CAAA;QAClC,aAAa,EAAE,OAAO,kBAAkB,CAAA;KAC3C,CAAA;IACD,OAAO,EAAE;QACL,eAAe,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAA;QAC3D,aAAa,EAAE,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAA;KACvD,CAAA;CACJ;AAED,MAAM,WAAW,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/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rentnerkev/toasts",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Accessible, customizable toast notifications for React.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"toast",
|
|
8
|
+
"notifications",
|
|
9
|
+
"typescript",
|
|
10
|
+
"tailwindcss"
|
|
11
|
+
],
|
|
12
|
+
"author": "RentnerKev",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "bun -e \"import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true })\" && tsc",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"test": "bun test",
|
|
28
|
+
"prepare": "bun run build",
|
|
29
|
+
"pack:check": "bun pm pack --dry-run --ignore-scripts",
|
|
30
|
+
"playground:dev": "bun --cwd playground dev",
|
|
31
|
+
"playground:build": "bun --cwd playground build",
|
|
32
|
+
"lint": "oxlint .",
|
|
33
|
+
"lint:fix": "oxlint --fix .",
|
|
34
|
+
"format": "oxfmt .",
|
|
35
|
+
"format:check": "oxfmt --check .",
|
|
36
|
+
"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"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/RentnerKev/RentnerToasts.git"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/RentnerKev/RentnerToasts#readme",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/RentnerKev/RentnerToasts/issues"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public",
|
|
49
|
+
"registry": "https://registry.npmjs.org"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"lucide-react": "^1.0.0",
|
|
53
|
+
"motion": "^12.38.0 || ^13.0.0",
|
|
54
|
+
"react": "^19.3.0",
|
|
55
|
+
"react-dom": "^19.3.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/react": "^19.3.0",
|
|
59
|
+
"@types/react-dom": "^19.3.0",
|
|
60
|
+
"lucide-react": "^1.46.0",
|
|
61
|
+
"motion": "^13.2.0",
|
|
62
|
+
"oxfmt": "^0.68.0",
|
|
63
|
+
"oxlint": "^1.83.0",
|
|
64
|
+
"react": "^19.3.0",
|
|
65
|
+
"react-dom": "^19.3.0",
|
|
66
|
+
"typescript": "^7.0.2"
|
|
67
|
+
},
|
|
68
|
+
"exports": {
|
|
69
|
+
".": {
|
|
70
|
+
"types": "./dist/index.d.ts",
|
|
71
|
+
"import": "./dist/index.js"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"packageManager": "bun@1.4.0"
|
|
75
|
+
}
|