toast-23 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +113 -102
- package/dist/context.d.ts.map +1 -1
- package/dist/devtools.d.ts +24 -0
- package/dist/devtools.d.ts.map +1 -0
- package/dist/headless-store.d.ts +3 -0
- package/dist/headless-store.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1464 -279
- package/dist/index.mjs.map +1 -1
- package/dist/inject-styles.d.ts +13 -0
- package/dist/inject-styles.d.ts.map +1 -0
- package/dist/notification.d.ts +4 -0
- package/dist/notification.d.ts.map +1 -0
- package/dist/provider.d.ts.map +1 -1
- package/dist/sound.d.ts +3 -0
- package/dist/sound.d.ts.map +1 -0
- package/dist/standalone.d.ts +14 -22
- package/dist/standalone.d.ts.map +1 -1
- package/dist/toast-23.css +1 -1
- package/dist/toast-container.d.ts +5 -5
- package/dist/toast-container.d.ts.map +1 -1
- package/dist/toast-item.d.ts +16 -3
- package/dist/toast-item.d.ts.map +1 -1
- package/dist/types.d.ts +137 -39
- package/dist/types.d.ts.map +1 -1
- package/dist/use-toast-headless.d.ts +14 -0
- package/dist/use-toast-headless.d.ts.map +1 -0
- package/dist/use-toast.d.ts.map +1 -1
- package/dist/utils.d.ts +4 -6
- package/dist/utils.d.ts.map +1 -1
- package/package.json +9 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Thabit S (Its-sultan)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,103 +1,46 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<div style=
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
<div style="position: relative; display:inline-block; max-width:100%;">
|
|
3
|
+
<img src="./assets/toast-23-image.png" alt="toast-23 preview" style="width:100%; max-width:1900px; height:auto; border-radius:12px;" />
|
|
5
4
|
</div>
|
|
6
|
-
<br/>
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
<
|
|
10
|
-
style="
|
|
11
|
-
font-weight: 900;
|
|
12
|
-
margin-left: 12px;
|
|
13
|
-
vertical-align: middle;
|
|
14
|
-
margin-bottom:10px;
|
|
15
|
-
"
|
|
16
|
-
>
|
|
17
|
-
toast-23
|
|
18
|
-
</h2>
|
|
19
|
-
|
|
20
|
-
</div>
|
|
21
|
-
|
|
5
|
+
<br />
|
|
6
|
+
<img src="./assets/toast-23-logo.png" alt="toast-23 logo" width="60" style="vertical-align: middle;" />
|
|
7
|
+
<h2 style="font-weight: 900; margin-bottom:10px;">toast-23</h2>
|
|
8
|
+
<p>A lightweight, accessible, fully-typed React toast notification library.</p>
|
|
22
9
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
[](https://www.npmjs.com/package/toast-23)
|
|
28
|
-
[](https://bundlephobia.com/package/toast-23)
|
|
29
|
-
[](./LICENSE)
|
|
10
|
+
[](https://www.npmjs.com/package/toast-23)
|
|
11
|
+
[](https://bundlephobia.com/package/toast-23)
|
|
12
|
+
[](./LICENSE)
|
|
30
13
|
|
|
14
|
+
[Website](https://toast-23.com/) · [Documentation](https://toast-23.com/docs)
|
|
31
15
|
</div>
|
|
32
|
-
<br/>
|
|
33
|
-
<div align="center">
|
|
34
|
-
<a href="https://toast-23.vercel.app/">Website</a>
|
|
35
|
-
<span> · </span>
|
|
36
|
-
<a href="https://toast-23.vercel.app/docs">Documentation</a>
|
|
37
|
-
<!-- <span> · </span>
|
|
38
|
-
<a href="https://twitter.com/">Twitter</a> -->
|
|
39
|
-
</div>
|
|
40
|
-
|
|
41
|
-
<br />
|
|
42
|
-
<div align="center">
|
|
43
|
-
<sub>Made by <a href="https://github.com/Its-sultan">Thabit S</a> 🧑🏽💻</sub>
|
|
44
|
-
</div>
|
|
45
|
-
<br/>
|
|
46
16
|
|
|
47
17
|
---
|
|
48
18
|
|
|
49
|
-
##
|
|
19
|
+
## Overview
|
|
20
|
+
|
|
21
|
+
toast-23 is a zero-dependency toast notification library for React. It ships with CSS animations, dark mode, a promise tracking API, a queue system, and full TypeScript support all in a minimal footprint.
|
|
50
22
|
|
|
51
|
-
|
|
52
|
-
- 📍 **6 positions** — top-right, top-left, top-center, bottom-right, bottom-left, bottom-center
|
|
53
|
-
- ⏳ **Promise API** — track async operations with loading → success / error
|
|
54
|
-
- ⏳ **Loading toast** — `toast.loading()` with manual update
|
|
55
|
-
- 🧩 **Custom JSX** — `toast.custom()` for fully custom content
|
|
56
|
-
- 🔄 **Update & Deduplicate** — update existing toasts via `id`, prevent duplicates
|
|
57
|
-
- 📦 **Queue system** — configurable max visible toasts with +N badge
|
|
58
|
-
- 🧹 **Dismiss & Remove** — dismiss all, remove instantly, configurable `removeDelay`
|
|
59
|
-
- 🌙 **Dark mode** — automatic (`prefers-color-scheme`) + manual (`.dark` class)
|
|
60
|
-
- ♿ **Accessible** — ARIA live regions, keyboard-navigable dismiss
|
|
61
|
-
- 🎭 **CSS animations** — smooth enter/exit transitions, hover-pause with progress reversal
|
|
62
|
-
- 🪶 **Lightweight** — zero runtime dependencies beyond React
|
|
63
|
-
- 🔒 **Fully typed** — complete TypeScript API
|
|
64
|
-
- 🌲 **Tree-shakeable** — ESM + CJS dual output
|
|
65
|
-
- 🌐 **Standalone API** — `createToast23()` for Angular, Vue, Svelte, vanilla JS
|
|
23
|
+
**v2 removes the manual CSS import.** Styles inject automatically on first mount. The subpath export `toast-23/styles.css` remains available for SSR, FOUC prevention, or build-time extraction.
|
|
66
24
|
|
|
67
25
|
---
|
|
68
26
|
|
|
69
27
|
## Installation
|
|
70
28
|
|
|
71
|
-
#### With npm
|
|
72
|
-
|
|
73
29
|
```bash
|
|
74
30
|
npm install toast-23
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
#### With yarn
|
|
78
|
-
|
|
79
|
-
```bash
|
|
31
|
+
# or
|
|
80
32
|
yarn add toast-23
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
#### With pnpm
|
|
84
|
-
|
|
85
|
-
```bash
|
|
33
|
+
# or
|
|
86
34
|
pnpm add toast-23
|
|
35
|
+
# or
|
|
36
|
+
bun add toast-23
|
|
87
37
|
```
|
|
88
38
|
|
|
89
39
|
---
|
|
90
40
|
|
|
91
41
|
## Quick Start
|
|
92
42
|
|
|
93
|
-
### 1.
|
|
94
|
-
|
|
95
|
-
```tsx
|
|
96
|
-
// In your app entry (e.g., main.tsx or layout.tsx)
|
|
97
|
-
import "toast-23/styles.css";
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### 2. Wrap your app with the provider
|
|
43
|
+
### 1. Add the provider
|
|
101
44
|
|
|
102
45
|
```tsx
|
|
103
46
|
import { Toast23Provider } from "toast-23";
|
|
@@ -111,7 +54,7 @@ function App() {
|
|
|
111
54
|
}
|
|
112
55
|
```
|
|
113
56
|
|
|
114
|
-
###
|
|
57
|
+
### 2. Call toasts from any component
|
|
115
58
|
|
|
116
59
|
```tsx
|
|
117
60
|
import { useToast } from "toast-23";
|
|
@@ -122,13 +65,9 @@ function MyComponent() {
|
|
|
122
65
|
return (
|
|
123
66
|
<div>
|
|
124
67
|
<button onClick={() => toast("Hello world!")}>Default</button>
|
|
125
|
-
<button onClick={() => toast.success("Saved successfully!")}>
|
|
126
|
-
Success
|
|
127
|
-
</button>
|
|
68
|
+
<button onClick={() => toast.success("Saved successfully!")}>Success</button>
|
|
128
69
|
<button onClick={() => toast.error("Something went wrong")}>Error</button>
|
|
129
|
-
<button onClick={() => toast.warning("Please check your input")}>
|
|
130
|
-
Warning
|
|
131
|
-
</button>
|
|
70
|
+
<button onClick={() => toast.warning("Please check your input")}>Warning</button>
|
|
132
71
|
<button onClick={() => toast.info("New update available")}>Info</button>
|
|
133
72
|
</div>
|
|
134
73
|
);
|
|
@@ -137,51 +76,123 @@ function MyComponent() {
|
|
|
137
76
|
|
|
138
77
|
---
|
|
139
78
|
|
|
140
|
-
##
|
|
79
|
+
## Features
|
|
80
|
+
|
|
81
|
+
### Core
|
|
82
|
+
|
|
83
|
+
| Feature | Description |
|
|
84
|
+
|---|---|
|
|
85
|
+
| Variants | `success`, `error`, `warning`, `info`, `default`, `loading` |
|
|
86
|
+
| Positions | 6 positions with per-toast override |
|
|
87
|
+
| Promise API | `toast.promise()` — loading → success / error with optional progress callbacks |
|
|
88
|
+
| Custom content | `toast.custom()` accepts any JSX |
|
|
89
|
+
| Deduplication | Toasts sharing an `id` update in place rather than stacking |
|
|
90
|
+
| Queue | Overflow collapses into a `+N more` badge, respecting `maxVisible` |
|
|
91
|
+
|
|
92
|
+
### v2 Additions
|
|
93
|
+
|
|
94
|
+
| Feature | Description |
|
|
95
|
+
|---|---|
|
|
96
|
+
| Zero-config styles | CSS auto-injects on provider mount no import required |
|
|
97
|
+
| Action buttons | `toast.success("Saved", { action: { label: "Undo", onClick } })` |
|
|
98
|
+
| Confirm toasts | `await toast.confirm("Delete?")` returns `Promise<boolean>` |
|
|
99
|
+
| Toast groups | `dismissGroup("id")` / `removeGroup("id")` |
|
|
100
|
+
| Global pause | `toast.pauseAll()` / `toast.resumeAll()` |
|
|
101
|
+
| History | `toast.history()` returns the last N dismissed toasts |
|
|
102
|
+
| Swipe-to-dismiss | Configurable threshold, fires on animation end |
|
|
103
|
+
| Stack layout | Sonner-style stacked view, expands on hover (`layout="stack"`) |
|
|
104
|
+
| Headless hook | `useToast23Headless()` for fully custom rendering |
|
|
105
|
+
| DevTools | `<Toast23DevTools />` inspect the live queue during development |
|
|
106
|
+
| Inline mode | Render toasts inside any container via the `target` prop |
|
|
107
|
+
| CSS variable theming | Every color, size, and timing token is overridable |
|
|
108
|
+
| RTL | Full right-to-left support via `dir="rtl"` |
|
|
109
|
+
| Keyboard shortcut | F8 (configurable) jumps focus to the toast region |
|
|
110
|
+
| Reduced motion | Respects `prefers-reduced-motion` |
|
|
111
|
+
| Sound cues | Optional per-variant audio feedback |
|
|
112
|
+
| OS notifications | Falls back to browser notifications when the tab is hidden |
|
|
113
|
+
| Dark mode | Automatic via `prefers-color-scheme`, or manual via `.dark` |
|
|
114
|
+
| Accessibility | ARIA live regions; error toasts use `assertive`, others use `polite` |
|
|
115
|
+
| Standalone API | `createToast23()` works outside React (Angular, Vue, Svelte, vanilla JS) |
|
|
116
|
+
| Tree-shakeable | Ships ESM + CJS |
|
|
117
|
+
|
|
118
|
+
---
|
|
141
119
|
|
|
142
|
-
|
|
120
|
+
## API Reference
|
|
121
|
+
|
|
122
|
+
Full documentation is available at [toast-23.com/docs](https://toast-23.com/docs).
|
|
123
|
+
|
|
124
|
+
---
|
|
143
125
|
|
|
144
126
|
## Testing
|
|
145
127
|
|
|
146
|
-
toast-23 uses [Vitest](https://vitest.dev/) with [Testing Library](https://testing-library.com/)
|
|
128
|
+
toast-23 uses [Vitest](https://vitest.dev/) with [Testing Library](https://testing-library.com/).
|
|
147
129
|
|
|
148
130
|
```bash
|
|
149
|
-
# Run tests
|
|
131
|
+
# Run all tests
|
|
150
132
|
npm test
|
|
151
133
|
|
|
152
134
|
# Watch mode
|
|
153
135
|
npm run test:watch
|
|
154
136
|
|
|
155
|
-
# Coverage
|
|
137
|
+
# Coverage report
|
|
156
138
|
npm run test:coverage
|
|
157
139
|
```
|
|
158
140
|
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Feedback after Using
|
|
146
|
+
|
|
147
|
+
Full documentation is available at [toast-23.com/comments](https://toast-23.com/comments).
|
|
148
|
+
|
|
159
149
|
---
|
|
150
|
+
|
|
160
151
|
|
|
161
152
|
## CI/CD
|
|
162
153
|
|
|
163
|
-
GitHub Actions workflow at `.github/workflows/ci.yml
|
|
154
|
+
The GitHub Actions workflow at `.github/workflows/ci.yml` runs on every push:
|
|
164
155
|
|
|
165
156
|
- **Lint** — TypeScript type checking
|
|
166
|
-
- **Test** — Vitest
|
|
167
|
-
- **Build** — Vite library build with
|
|
168
|
-
|
|
157
|
+
- **Test** — Vitest suite against Node 18, 20, and 22
|
|
158
|
+
- **Build** — Vite library build with declaration file generation
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Local Development
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
npm install
|
|
166
|
+
npm run dev
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Opens an interactive playground at `http://localhost:5173`. Every feature is wired to a live control dark mode, position switcher, stack layout, RTL, sounds, swipe-to-dismiss, headless view, inline mode, and DevTools.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Changelog
|
|
174
|
+
|
|
175
|
+
### v2.0.0
|
|
176
|
+
|
|
177
|
+
- **Independent timers** — adding or dismissing a toast no longer resets the countdown or progress bar of other visible toasts. Each toast runs its own timer.
|
|
178
|
+
- **Isolated instances** — `useToast23Headless()` and `<Toast23DevTools />` now read from a per-provider store. Multiple `<Toast23Provider>` instances and `createToast23()` calls remain fully separated.
|
|
179
|
+
- **Bounded history** — the internal dismissed-ID set is pruned on removal, preventing unbounded growth in long-running apps. Reused IDs can re-enter history correctly.
|
|
180
|
+
- **Pre-mount IDs** — `createToast23()` calls made before the React tree mounts now return the real toast ID, so an early `dismiss(id)` works as expected.
|
|
181
|
+
- **Accessibility fix** — non-error toasts use `role="status"` (polite); error toasts remain `role="alert"` (assertive). The previous combination of `role="alert"` and `aria-live="polite"` was conflicting.
|
|
182
|
+
- **Swipe polish** — dismissal fires exactly when the off-screen fling animation completes, not before.
|
|
169
183
|
|
|
170
184
|
---
|
|
171
185
|
|
|
172
|
-
##
|
|
186
|
+
## Roadmap
|
|
173
187
|
|
|
174
|
-
-
|
|
175
|
-
-
|
|
176
|
-
-
|
|
177
|
-
-
|
|
178
|
-
-
|
|
179
|
-
- [ ] Rich content: icons, avatars, action buttons
|
|
180
|
-
- [ ] Sound notifications
|
|
181
|
-
- [ ] Persistent toasts (survive page navigation)
|
|
188
|
+
- React Native port via the headless hook
|
|
189
|
+
- Persistent toasts that survive page navigation (localStorage)
|
|
190
|
+
- Rich-content recipes: avatars, multi-line layouts
|
|
191
|
+
- Additional locale support for default labels
|
|
192
|
+
- Theming presets for Material, Tailwind, and shadcn
|
|
182
193
|
|
|
183
194
|
---
|
|
184
195
|
|
|
185
196
|
## License
|
|
186
197
|
|
|
187
|
-
MIT ©
|
|
198
|
+
MIT © [Thabit S](https://github.com/Its-sultan)
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,mBAAmB,EACpB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,cAAc,qDAAkD,CAAC;AAE9E,wBAAgB,cAAc,CAC5B,KAAK,EAAE,aAAa,EAAE,EACtB,MAAM,EAAE,aAAa,GACpB,aAAa,EAAE,CA2DjB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* toast-23 — DevTools overlay
|
|
3
|
+
*
|
|
4
|
+
* An optional inspector panel for the toast queue. Drop `<Toast23DevTools />`
|
|
5
|
+
* inside the provider (or at the app root). Three states:
|
|
6
|
+
* - chip: a small floating pill, just a count
|
|
7
|
+
* - compact: ~360x480 panel with tabs (default expanded state)
|
|
8
|
+
* - expanded: enlarged panel for serious inspection
|
|
9
|
+
*
|
|
10
|
+
* Tabs:
|
|
11
|
+
* - Queue: live active toasts, dismiss/remove/copy
|
|
12
|
+
* - History: dismissed toasts, replay/copy
|
|
13
|
+
* - Settings: provider config readout, position/duration test overrides,
|
|
14
|
+
* spawn-test buttons, and a sound preview row
|
|
15
|
+
*/
|
|
16
|
+
import * as React from "react";
|
|
17
|
+
export interface Toast23DevToolsProps {
|
|
18
|
+
/** Screen corner to dock the panel. @default "bottom-left" */
|
|
19
|
+
position?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
20
|
+
/** Start in the small chip state. @default true */
|
|
21
|
+
collapsed?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const Toast23DevTools: React.FC<Toast23DevToolsProps>;
|
|
24
|
+
//# sourceMappingURL=devtools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../src/devtools.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAoB/B,MAAM,WAAW,oBAAoB;IACnC,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,cAAc,CAAC;IACrE,mDAAmD;IACnD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAsCD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA+xB1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headless-store.d.ts","sourceRoot":"","sources":["../src/headless-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,SAAS,CAAC;AAE5D,wBAAgB,mBAAmB,IAAI,aAAa,CAoBnD"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),c=require("react"),M=require("react-dom/client");function S(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const w=S(c),j=c.createContext(null);function N(e,r){switch(r.type){case"ADD":return[...e,r.toast];case"UPSERT":return e.some(i=>i.id===r.toast.id)?e.map(i=>i.id===r.toast.id?{...i,...r.toast,version:i.version+1,isExiting:!1}:i):[...e,r.toast];case"UPDATE":return e.map(t=>t.id===r.id?{...t,...r.updates,version:t.version+1,isExiting:!1}:t);case"DISMISS":return r.id?e.map(t=>t.id===r.id?{...t,isExiting:!0}:t):e.map(t=>({...t,isExiting:!0}));case"REMOVE":return r.id?e.filter(t=>t.id!==r.id):[];default:return e}}const L=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"1.25em",height:"1.25em",fill:"none",...e,children:[o.jsx("circle",{cx:12,cy:12,r:10,fill:"currentColor"}),o.jsx("path",{d:"M8 12.5l2.5 2.5 5-5",stroke:"#fff",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}),P=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"1.25em",height:"1.25em",fill:"none",...e,children:[o.jsx("circle",{cx:12,cy:12,r:10,fill:"currentColor"}),o.jsx("line",{x1:12,y1:8,x2:12,y2:13,stroke:"#fff",strokeWidth:2,strokeLinecap:"round"}),o.jsx("circle",{cx:12,cy:16,r:1,fill:"#fff"})]}),A=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"1.25em",height:"1.25em",fill:"none",...e,children:[o.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z",fill:"currentColor"}),o.jsx("line",{x1:12,y1:9.5,x2:12,y2:14,stroke:"#fff",strokeWidth:2,strokeLinecap:"round"}),o.jsx("circle",{cx:12,cy:17,r:1,fill:"#fff"})]}),y=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"1.25em",height:"1.25em",fill:"none",...e,children:[o.jsx("circle",{cx:12,cy:12,r:10,fill:"currentColor"}),o.jsx("line",{x1:12,y1:11,x2:12,y2:16,stroke:"#fff",strokeWidth:2,strokeLinecap:"round"}),o.jsx("circle",{cx:12,cy:8,r:1,fill:"#fff"})]}),R=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"0.875em",height:"0.875em",...e,children:[o.jsx("line",{x1:18,y1:6,x2:6,y2:18}),o.jsx("line",{x1:6,y1:6,x2:18,y2:18})]}),_=e=>o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"1.25em",height:"1.25em",className:"toast23-spinner",...e,children:o.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})});let D=0;function q(){return`t23-${++D}-${Math.random().toString(36).slice(2,9)}`}function p(...e){return e.filter(Boolean).join(" ")}const B={success:L,error:P,warning:A,info:y,default:y,loading:_},$=300,b=w.memo(({toast:e,onDismiss:r,onRemove:t})=>{const[i,m]=c.useState(!1);c.useEffect(()=>{const h=requestAnimationFrame(()=>m(!0));return()=>cancelAnimationFrame(h)},[]),c.useEffect(()=>{if(!e.isExiting)return;const h=e.removeDelay??$,I=setTimeout(()=>t(e.id),h);return()=>clearTimeout(I)},[e.isExiting,e.id,e.removeDelay,t]);const[u,x]=c.useState(!1),d=c.useRef(e.duration),[a,f]=c.useState(100),[g,n]=c.useState("none");c.useEffect(()=>{d.current=e.duration,f(100),n("none")},[e.version,e.duration]),c.useEffect(()=>{if(e.duration<=0||e.variant==="loading"||!i||e.isExiting)return;if(u){n("width 200ms ease-out"),f(100);return}f(100),requestAnimationFrame(()=>{n(`width ${e.duration}ms linear`),f(0)});const h=setTimeout(()=>{r(e.id)},e.duration);return()=>clearTimeout(h)},[u,e.duration,e.variant,e.isExiting,e.id,i,r]);const s=c.useCallback(()=>x(!0),[]),l=c.useCallback(()=>x(!1),[]),v=B[e.variant]??y;return e.isCustom?o.jsx("div",{className:p("toast23-item toast23-item--custom",!i&&"toast23-item--entering",e.isExiting&&"toast23-item--exiting"),role:"alert","aria-live":"polite","aria-atomic":"true",onMouseEnter:s,onMouseLeave:l,children:e.message}):o.jsxs("div",{className:p("toast23-item",`toast23-item--${e.variant}`,!i&&"toast23-item--entering",e.isExiting&&"toast23-item--exiting"),role:"alert","aria-live":e.variant==="error"?"assertive":"polite","aria-atomic":"true",onMouseEnter:s,onMouseLeave:l,children:[o.jsx("span",{className:p("toast23-icon",`toast23-icon--${e.variant}`),children:o.jsx(v,{})}),o.jsxs("div",{className:"toast23-content",children:[e.title&&o.jsx("div",{className:"toast23-title",children:e.title}),o.jsx("div",{className:p("toast23-message",e.title&&"toast23-message--with-title"),children:e.message})]}),e.dismissible&&o.jsx("button",{type:"button",className:"toast23-dismiss",onClick:()=>r(e.id),"aria-label":"Dismiss notification",children:o.jsx(R,{})}),e.duration>0&&e.variant!=="loading"&&o.jsx("div",{className:p("toast23-progress",`toast23-progress--${e.variant}`),style:{width:`${a}%`,transition:g}})]})});b.displayName="ToastItem";const k=w.memo(({position:e,toasts:r,maxVisible:t})=>{const i=c.useContext(j);if(!i)return null;const m=r.filter(a=>!a.isExiting),u=r.filter(a=>a.isExiting),x=[...m.slice(0,t),...u];if(x.length===0)return null;const d=Math.max(0,m.length-t);return o.jsxs("div",{className:p("toast23-container",`toast23-container--${e}`),"aria-label":"Notifications",role:"region",children:[x.map(a=>o.jsx(b,{toast:a,onDismiss:i.dismissToast,onRemove:i.removeToast},a.id)),d>0&&o.jsxs("div",{className:"toast23-queue-badge","aria-live":"polite",children:["+",d," more"]})]})});k.displayName="ToastContainer";const W=["top-right","top-left","top-center","bottom-right","bottom-left","bottom-center"],E=({children:e,maxVisible:r=5,position:t="top-right",duration:i=5e3})=>{const[m,u]=c.useReducer(N,[]),x=c.useCallback((s,l)=>{const v=l?.id??q(),h={id:v,message:s,title:l?.title,variant:l?.variant??"default",duration:l?.duration??i,position:l?.position??t,dismissible:l?.dismissible??!0,removeDelay:l?.removeDelay??1e3,isExiting:!1,createdAt:Date.now(),version:0,isCustom:l?.isCustom};return l?.id?u({type:"UPSERT",toast:h}):u({type:"ADD",toast:h}),v},[i,t]),d=c.useCallback((s,l)=>{u({type:"UPDATE",id:s,updates:l})},[]),a=c.useCallback(s=>{u({type:"DISMISS",id:s})},[]),f=c.useCallback(s=>{u({type:"REMOVE",id:s})},[]),g=c.useMemo(()=>({addToast:x,updateToast:d,dismissToast:a,removeToast:f,config:{maxVisible:r,position:t,duration:i}}),[x,d,a,f,r,t,i]),n=c.useMemo(()=>{const s={"top-right":[],"top-left":[],"top-center":[],"bottom-right":[],"bottom-left":[],"bottom-center":[]};for(const l of m)s[l.position].push(l);return s},[m]);return o.jsxs(j.Provider,{value:g,children:[e,W.map(s=>n[s].length>0?o.jsx(k,{position:s,toasts:n[s],maxVisible:r},s):null)]})};E.displayName="Toast23Provider";function C(){const e=c.useContext(j);if(!e)throw new Error("[toast-23] useToast() must be used inside a <Toast23Provider>. Wrap your application root with <Toast23Provider> to fix this.");return c.useMemo(()=>{const r=((t,i)=>e.addToast(t,i));return r.success=(t,i)=>e.addToast(t,{...i,variant:"success"}),r.error=(t,i)=>e.addToast(t,{...i,variant:"error"}),r.warning=(t,i)=>e.addToast(t,{...i,variant:"warning"}),r.info=(t,i)=>e.addToast(t,{...i,variant:"info"}),r.loading=(t,i)=>e.addToast(t,{...i,variant:"loading",duration:i?.duration??0,dismissible:i?.dismissible??!1}),r.custom=(t,i)=>e.addToast(t,{...i,variant:"default",isCustom:!0}),r.dismiss=t=>e.dismissToast(t),r.remove=t=>e.removeToast(t),r.promise=async(t,i,m)=>{const u=e.addToast(i.loading,{...m,variant:"loading",duration:0,dismissible:!1}),x=typeof t=="function"?t():t;try{const d=await x,a=typeof i.success=="function"?i.success(d):i.success;return e.updateToast(u,{message:a,variant:"success",duration:m?.duration??e.config.duration,dismissible:!0}),d}catch(d){const a=typeof i.error=="function"?i.error(d):i.error;throw e.updateToast(u,{message:a,variant:"error",duration:m?.duration??e.config.duration,dismissible:!0}),d}},r},[e.addToast,e.updateToast,e.dismissToast,e.removeToast,e.config.duration])}let T=null;function O(){const e=C();return w.useEffect(()=>{T&&(T(e),T=null)},[e]),null}function U(e={}){const{position:r="top-right",maxVisible:t=5,duration:i=5e3}=e,m=document.createElement("div");m.setAttribute("data-toast23-standalone",""),m.style.display="contents",document.body.appendChild(m);let u=M.createRoot(m);const x=new Promise(n=>{T=n}),d=[];let a=null;x.then(n=>{a=n;for(const s of d)s.method==="__call__"?n(...s.args):n[s.method](...s.args);d.length=0}),u.render(w.createElement(E,{position:r,maxVisible:t,duration:i},w.createElement(O)));const f=(n,...s)=>a?a[n](...s):(d.push({method:n,args:s}),"queued"),g=((n,s)=>a?a(n,s):(d.push({method:"__call__",args:[n,s]}),"queued"));return g.success=(n,s)=>f("success",n,s),g.error=(n,s)=>f("error",n,s),g.warning=(n,s)=>f("warning",n,s),g.info=(n,s)=>f("info",n,s),g.loading=(n,s)=>f("loading",n,s),g.custom=(n,s)=>f("custom",n,s),g.dismiss=n=>f("dismiss",n),g.remove=n=>f("remove",n),g.promise=(n,s,l)=>a?a.promise(n,s,l):x.then(v=>v.promise(n,s,l)),g.destroy=()=>{u&&(u.unmount(),u=null),m.remove(),a=null},g}exports.Toast23Provider=E;exports.createToast23=U;exports.useToast=C;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),a=require("react"),xt=require("react-dom"),ht=require("react-dom/client");function yt(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const i=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(n,o,i.get?i:{enumerable:!0,get:()=>t[o]})}}return n.default=t,Object.freeze(n)}const X=yt(a),V=a.createContext(null);function vt(t,n){switch(n.type){case"ADD":return[...t,n.toast];case"UPSERT":return t.some(i=>i.id===n.toast.id)?t.map(i=>i.id===n.toast.id?{...i,...n.toast,version:i.version+1,isExiting:!1}:i):[...t,n.toast];case"UPDATE":return t.map(o=>o.id===n.id?{...o,...n.updates,version:o.version+1,isExiting:!1}:o);case"DISMISS":return n.id?t.map(o=>o.id===n.id&&!o.isExiting?{...o,isExiting:!0}:o):t.map(o=>o.isExiting?o:{...o,isExiting:!0});case"REMOVE":return n.id?t.filter(o=>o.id!==n.id):[];case"DISMISS_GROUP":return t.map(o=>o.group===n.group&&!o.isExiting?{...o,isExiting:!0}:o);case"REMOVE_GROUP":return t.filter(o=>o.group!==n.group);default:return t}}const wt=t=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"1.25em",height:"1.25em",fill:"none",...t,children:[s.jsx("circle",{cx:12,cy:12,r:10,fill:"currentColor"}),s.jsx("path",{d:"M8 12.5l2.5 2.5 5-5",stroke:"#fff",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}),kt=t=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"1.25em",height:"1.25em",fill:"none",...t,children:[s.jsx("circle",{cx:12,cy:12,r:10,fill:"currentColor"}),s.jsx("line",{x1:12,y1:8,x2:12,y2:13,stroke:"#fff",strokeWidth:2,strokeLinecap:"round"}),s.jsx("circle",{cx:12,cy:16,r:1,fill:"#fff"})]}),jt=t=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"1.25em",height:"1.25em",fill:"none",...t,children:[s.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z",fill:"currentColor"}),s.jsx("line",{x1:12,y1:9.5,x2:12,y2:14,stroke:"#fff",strokeWidth:2,strokeLinecap:"round"}),s.jsx("circle",{cx:12,cy:17,r:1,fill:"#fff"})]}),et=t=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"1.25em",height:"1.25em",fill:"none",...t,children:[s.jsx("circle",{cx:12,cy:12,r:10,fill:"currentColor"}),s.jsx("line",{x1:12,y1:11,x2:12,y2:16,stroke:"#fff",strokeWidth:2,strokeLinecap:"round"}),s.jsx("circle",{cx:12,cy:8,r:1,fill:"#fff"})]}),Tt=t=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"0.875em",height:"0.875em",...t,children:[s.jsx("line",{x1:18,y1:6,x2:6,y2:18}),s.jsx("line",{x1:6,y1:6,x2:18,y2:18})]}),Ct=t=>s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"1.25em",height:"1.25em",className:"toast23-spinner",...t,children:s.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})});let St=0;function Q(){return`t23-${++St}-${Math.random().toString(36).slice(2,9)}`}function G(...t){return t.filter(Boolean).join(" ")}function At(t){return t.endsWith("right")?1:t.endsWith("left")?-1:0}const Et={success:wt,error:kt,warning:jt,info:et,default:et,loading:Ct},Rt=200,Z=180,at=X.memo(({toast:t,onDismiss:n,onRemove:o,globallyPaused:i,swipeEnabled:p,swipeThreshold:m,stackIndex:S,stackMode:g,stackExpanded:h,stackIsBottom:M,dir:D})=>{const[w,A]=a.useState(!1);a.useEffect(()=>{const v=requestAnimationFrame(()=>A(!0));return()=>cancelAnimationFrame(v)},[]),a.useEffect(()=>{if(!t.isExiting)return;const v=setTimeout(()=>o(t.id),t.removeDelay);return()=>clearTimeout(v)},[t.isExiting,t.id,t.removeDelay,o]);const[b,k]=a.useState(!1),T=b||i,[R,I]=a.useState(1),[y,x]=a.useState("none");a.useEffect(()=>{I(1),x("none")},[t.version,t.duration]);const j=typeof t.progress=="number";a.useEffect(()=>{j&&(x("transform 120ms linear"),I(t.progress??0))},[t.progress,j]),a.useEffect(()=>{if(j||t.duration<=0||t.variant==="loading"||!w||t.isExiting)return;if(T){x(`transform ${Rt}ms ease-out`),I(1);return}x("none"),I(1);const v=requestAnimationFrame(()=>{x(`transform ${t.duration}ms linear`),I(0)}),B=setTimeout(()=>n(t.id),t.duration);return()=>{cancelAnimationFrame(v),clearTimeout(B)}},[T,w,t.isExiting,t.duration,t.variant,t.id,t.version,j,n]);const u=a.useRef({startX:0,startY:0,dx:0,isDragging:!1,pointerId:-1}),[l,c]=a.useState(0),[C,E]=a.useState(""),L=At(t.position),_=a.useCallback(v=>{!p||v.button!==void 0&&v.button!==0||v.target.closest("button")||(u.current.startX=v.clientX,u.current.startY=v.clientY,u.current.dx=0,u.current.isDragging=!0,u.current.pointerId=v.pointerId,E(""))},[p]),$=a.useCallback(v=>{if(!u.current.isDragging||v.pointerId!==u.current.pointerId)return;const B=v.clientX-u.current.startX,U=v.clientY-u.current.startY;if(Math.abs(U)>Math.abs(B)&&Math.abs(U)>10)return;const st=L===0?B:L===1?Math.max(0,B):Math.min(0,B);u.current.dx=st,c(st)},[L]),q=a.useCallback(v=>{if(!u.current.isDragging||v.pointerId!==u.current.pointerId)return;u.current.isDragging=!1;const B=u.current.dx;Math.abs(B)>=m?(E(`transform ${Z}ms ease-out, opacity ${Z}ms ease-out`),c(B>0?window.innerWidth:-window.innerWidth),setTimeout(()=>n(t.id),Z)):(E("transform 180ms ease-out"),c(0))},[m,n,t.id]),z=10,r=.06,O=Math.min(S,3),W=(()=>{if(!g||h)return"";const B=(M?1:-1)*O*z,U=1-O*r;return`translateY(${B}px) scale(${U})`})(),F=g&&!h&&O>0?Math.max(.4,1-O*.25):void 0,H=l!==0?`translateX(${l}px)`:W,d=l!==0?Math.max(0,1-Math.abs(l)/(m*2)):void 0,e=a.useCallback(()=>k(!0),[]),f=a.useCallback(()=>k(!1),[]),N=Et[t.variant]??et,P=a.useCallback(()=>n(t.id),[n,t.id]),pt=a.useCallback(()=>{if(!t.action)return;const v=t.action.dismissOnClick!==!1;t.action.onClick(P),v&&P()},[t.action,P]),mt=a.useCallback(()=>{if(!t.cancelAction)return;const v=t.cancelAction.dismissOnClick!==!1;t.cancelAction.onClick(P),v&&P()},[t.cancelAction,P]);if(t.isCustom)return s.jsx("div",{className:G("toast23-item toast23-item--custom",!w&&"toast23-item--entering",t.isExiting&&"toast23-item--exiting"),role:"status","aria-live":"polite","aria-atomic":"true",style:{transform:H||void 0,opacity:d??F,transition:C||void 0,pointerEvents:g&&!h&&O>0?"none":void 0},onMouseEnter:e,onMouseLeave:f,onPointerDown:_,onPointerMove:$,onPointerUp:q,onPointerCancel:q,children:t.message});const bt=!!(t.action&&t.cancelAction);return s.jsxs("div",{className:G("toast23-item",`toast23-item--${t.variant}`,!w&&"toast23-item--entering",t.isExiting&&"toast23-item--exiting",g&&"toast23-item--stack",bt&&"toast23-item--confirm"),role:t.variant==="error"?"alert":"status","aria-live":t.variant==="error"?"assertive":"polite","aria-atomic":"true",style:{transform:H||void 0,opacity:d??F,transition:C||void 0},onMouseEnter:e,onMouseLeave:f,onPointerDown:_,onPointerMove:$,onPointerUp:q,onPointerCancel:q,children:[s.jsx("span",{className:G("toast23-icon",`toast23-icon--${t.variant}`),children:s.jsx(N,{})}),s.jsxs("div",{className:"toast23-content",children:[t.title&&s.jsx("div",{className:"toast23-title",children:t.title}),s.jsx("div",{className:G("toast23-message",t.title&&"toast23-message--with-title"),children:t.message})]}),(t.action||t.cancelAction)&&s.jsxs("div",{className:"toast23-actions",children:[t.cancelAction&&s.jsx("button",{type:"button",className:G("toast23-action toast23-action--cancel",t.cancelAction.className),onClick:mt,children:t.cancelAction.label}),t.action&&s.jsx("button",{type:"button",className:G("toast23-action",t.action.className),onClick:pt,children:t.action.label})]}),t.dismissible&&s.jsx("button",{type:"button",className:"toast23-dismiss",onClick:()=>n(t.id),"aria-label":"Dismiss notification",children:s.jsx(Tt,{})}),(t.duration>0||j)&&t.variant!=="loading"&&s.jsx("div",{className:G("toast23-progress",`toast23-progress--${t.variant}`),style:{transform:`scaleX(${R})`,transition:y}})]})});at.displayName="ToastItem";const lt=X.memo(({position:t,toasts:n,maxVisible:o,layout:i,dir:p,theme:m,inline:S})=>{const g=a.useContext(V),[h,M]=a.useState(!1),D=a.useCallback(()=>M(!0),[]),w=a.useCallback(()=>M(!1),[]);if(!g)return null;const A=n.filter(y=>!y.isExiting),b=n.filter(y=>y.isExiting),k=[...A.slice(0,o),...b],T=Math.max(0,A.length-o);if(k.length===0)return null;const R=i==="stack",I=t.startsWith("bottom");return s.jsxs("div",{className:G("toast23-container",`toast23-container--${t}`,R&&"toast23-container--stack",R&&h&&"toast23-container--expanded",S&&"toast23-container--inline",p==="rtl"&&"toast23-container--rtl",m==="dark"&&"toast23-container--dark",m==="light"&&"toast23-container--light"),dir:p,"aria-label":"Notifications",role:"region",tabIndex:-1,"data-toast23-region":"true",onMouseEnter:R?D:void 0,onMouseLeave:R?w:void 0,children:[k.map((y,x)=>{const j=R?x:0;return s.jsx(at,{toast:y,stackIndex:j,stackMode:R,stackExpanded:h,stackIsBottom:I,dir:p,onDismiss:g.dismissToast,onRemove:g.removeToast,globallyPaused:g.isPausedGlobally,swipeEnabled:g.config.swipeEnabled,swipeThreshold:g.config.swipeThreshold},y.id)}),T>0&&s.jsxs("div",{className:"toast23-queue-badge","aria-live":"polite",children:["+",T," more"]})]})});lt.displayName="ToastContainer";const Mt=':root{--toast23-z: 9999;--toast23-min-width: 320px;--toast23-max-width: 26rem;--toast23-radius: .75rem;--toast23-gap: .75rem;--toast23-padding: .875rem 1rem;--toast23-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;--toast23-shadow: 0 4px 6px -1px rgba(0, 0, 0, .08), 0 2px 4px -2px rgba(0, 0, 0, .05);--toast23-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -4px rgba(0, 0, 0, .06);--toast23-bg-default: rgba(249, 250, 251, .95);--toast23-bg-success: rgba(240, 253, 244, .95);--toast23-bg-error: rgba(254, 242, 242, .95);--toast23-bg-warning: rgba(254, 252, 232, .95);--toast23-bg-info: rgba(239, 246, 255, .95);--toast23-border-default: #e5e7eb;--toast23-border-success: #bbf7d0;--toast23-border-error: #fecaca;--toast23-border-warning: #fef08a;--toast23-border-info: #bfdbfe;--toast23-color-success: #22c55e;--toast23-color-error: #ef4444;--toast23-color-warning: #eab308;--toast23-color-info: #3b82f6;--toast23-color-default: #6b7280;--toast23-color-loading: #3b82f6;--toast23-text-title: #111827;--toast23-text-body: #1f2937;--toast23-text-muted: #6b7280;--toast23-action-bg: rgba(0, 0, 0, .06);--toast23-action-bg-hover: rgba(0, 0, 0, .1);--toast23-action-text: #111827;--toast23-cancel-bg: #d1d5db;--toast23-cancel-bg-hover: #9ca3af;--toast23-cancel-text: #111827;--toast23-queue-bg: rgba(255, 255, 255, .8);--toast23-enter-duration: .3s;--toast23-exit-duration: .3s;--toast23-easing: cubic-bezier(.4, 0, .2, 1)}.toast23-container,.toast23-container *,.toast23-container *:before,.toast23-container *:after{box-sizing:border-box;margin:0;padding:0}.toast23-container{position:fixed;z-index:var(--toast23-z);display:flex;flex-direction:column;gap:var(--toast23-gap);padding:1rem;pointer-events:none;max-height:100vh;overflow:visible}.toast23-container--inline{position:absolute;inset:0;height:100%;pointer-events:none}.toast23-container--top-right{top:0;right:0}.toast23-container--top-left{top:0;left:0}.toast23-container--top-center{top:0;left:50%;transform:translate(-50%);align-items:center}.toast23-container--bottom-right{bottom:0;right:0;flex-direction:column-reverse}.toast23-container--bottom-left{bottom:0;left:0;flex-direction:column-reverse}.toast23-container--bottom-center{bottom:0;left:50%;transform:translate(-50%);flex-direction:column-reverse;align-items:center}.toast23-container--rtl.toast23-container--top-right,.toast23-container--rtl.toast23-container--bottom-right{right:auto;left:0}.toast23-container--rtl.toast23-container--top-left,.toast23-container--rtl.toast23-container--bottom-left{left:auto;right:0}.toast23-item{pointer-events:auto;position:relative;display:flex;align-items:flex-start;gap:.75rem;min-width:var(--toast23-min-width);max-width:var(--toast23-max-width);padding:var(--toast23-padding);border-radius:var(--toast23-radius);overflow:hidden;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);font-family:var(--toast23-font);line-height:1.5;box-shadow:inset 0 0 0 1px var(--toast23-item-border, transparent),var(--toast23-shadow);transform:translate(0);opacity:1;transition:transform var(--toast23-enter-duration) var(--toast23-easing),opacity var(--toast23-enter-duration) var(--toast23-easing),box-shadow .15s ease;cursor:default;touch-action:pan-y}.toast23-item:hover{box-shadow:inset 0 0 0 1px var(--toast23-item-border, transparent),var(--toast23-shadow-hover)}.toast23-container--top-right .toast23-item--entering,.toast23-container--top-right .toast23-item--exiting,.toast23-container--bottom-right .toast23-item--entering,.toast23-container--bottom-right .toast23-item--exiting{transform:translate(calc(100% + 1rem));opacity:0}.toast23-container--top-left .toast23-item--entering,.toast23-container--top-left .toast23-item--exiting,.toast23-container--bottom-left .toast23-item--entering,.toast23-container--bottom-left .toast23-item--exiting{transform:translate(calc(-100% - 1rem));opacity:0}.toast23-container--top-center .toast23-item--entering,.toast23-container--top-center .toast23-item--exiting{transform:translateY(-100%);opacity:0}.toast23-container--bottom-center .toast23-item--entering,.toast23-container--bottom-center .toast23-item--exiting{transform:translateY(100%);opacity:0}.toast23-container--stack .toast23-item--stack{transition:transform .25s var(--toast23-easing),opacity .25s var(--toast23-easing),box-shadow .15s ease}.toast23-item--success{background:var(--toast23-bg-success);--toast23-item-border: var(--toast23-border-success)}.toast23-item--error{background:var(--toast23-bg-error);--toast23-item-border: var(--toast23-border-error)}.toast23-item--warning{background:var(--toast23-bg-warning);--toast23-item-border: var(--toast23-border-warning)}.toast23-item--info{background:var(--toast23-bg-info);--toast23-item-border: var(--toast23-border-info)}.toast23-item--default,.toast23-item--loading{background:var(--toast23-bg-default);--toast23-item-border: var(--toast23-border-default)}@media(prefers-color-scheme:dark){:root{--toast23-bg-default: rgba(55, 65, 81, .5);--toast23-bg-success: rgba(22, 101, 52, .25);--toast23-bg-error: rgba(153, 27, 27, .25);--toast23-bg-warning: rgba(133, 77, 14, .25);--toast23-bg-info: rgba(30, 64, 175, .25);--toast23-border-default: #4b5563;--toast23-border-success: #166534;--toast23-border-error: #991b1b;--toast23-border-warning: #854d0e;--toast23-border-info: #1e40af;--toast23-text-title: #f9fafb;--toast23-text-body: #e5e7eb;--toast23-text-muted: #d1d5db;--toast23-action-bg: rgba(255, 255, 255, .08);--toast23-action-bg-hover: rgba(255, 255, 255, .15);--toast23-action-text: #f9fafb;--toast23-cancel-bg: #374151;--toast23-cancel-bg-hover: #4b5563;--toast23-cancel-text: #f9fafb;--toast23-queue-bg: rgba(55, 65, 81, .7)}}.dark,.toast23-container--dark{--toast23-bg-default: rgba(55, 65, 81, .5);--toast23-bg-success: rgba(22, 101, 52, .25);--toast23-bg-error: rgba(153, 27, 27, .25);--toast23-bg-warning: rgba(133, 77, 14, .25);--toast23-bg-info: rgba(30, 64, 175, .25);--toast23-border-default: #4b5563;--toast23-border-success: #166534;--toast23-border-error: #991b1b;--toast23-border-warning: #854d0e;--toast23-border-info: #1e40af;--toast23-text-title: #f9fafb;--toast23-text-body: #e5e7eb;--toast23-text-muted: #d1d5db;--toast23-action-bg: rgba(255, 255, 255, .08);--toast23-action-bg-hover: rgba(255, 255, 255, .15);--toast23-action-text: #f9fafb;--toast23-cancel-bg: #374151;--toast23-cancel-bg-hover: #4b5563;--toast23-cancel-text: #f9fafb;--toast23-queue-bg: rgba(55, 65, 81, .7)}.toast23-container--light{--toast23-bg-default: rgba(249, 250, 251, .95);--toast23-bg-success: rgba(240, 253, 244, .95);--toast23-bg-error: rgba(254, 242, 242, .95);--toast23-bg-warning: rgba(254, 252, 232, .95);--toast23-bg-info: rgba(239, 246, 255, .95);--toast23-border-default: #e5e7eb;--toast23-border-success: #bbf7d0;--toast23-border-error: #fecaca;--toast23-border-warning: #fef08a;--toast23-border-info: #bfdbfe;--toast23-text-title: #111827;--toast23-text-body: #1f2937;--toast23-text-muted: #6b7280;--toast23-action-bg: rgba(0, 0, 0, .06);--toast23-action-bg-hover: rgba(0, 0, 0, .1);--toast23-action-text: #111827;--toast23-cancel-bg: #d1d5db;--toast23-cancel-bg-hover: #9ca3af;--toast23-cancel-text: #111827;--toast23-queue-bg: rgba(255, 255, 255, .8)}.toast23-icon{display:flex;align-items:center;flex-shrink:0;margin-top:1px}.toast23-icon--success{color:var(--toast23-color-success)}.toast23-icon--error{color:var(--toast23-color-error)}.toast23-icon--warning{color:var(--toast23-color-warning)}.toast23-icon--info{color:var(--toast23-color-info)}.toast23-icon--default{color:var(--toast23-color-default)}.toast23-icon--loading{color:var(--toast23-color-loading)}.toast23-content{flex:1;min-width:0}.toast23-title{font-size:.875rem;font-weight:600;color:var(--toast23-text-title);margin-bottom:.125rem;line-height:1.3}.toast23-message{font-size:.875rem;font-weight:500;color:var(--toast23-text-body);word-break:break-word}.toast23-message--with-title{color:var(--toast23-text-muted);font-weight:400}.toast23-actions{display:flex;gap:.375rem;align-items:center;flex-shrink:0;margin-left:.25rem}.toast23-item--confirm{flex-wrap:wrap;padding-right:2.5rem}.toast23-item--confirm .toast23-dismiss{position:absolute;top:.5rem;right:.5rem;margin:0}.toast23-item--confirm .toast23-actions{flex-basis:100%;margin-left:0;margin-top:.625rem;gap:.5rem;justify-content:stretch}.toast23-item--confirm .toast23-action{flex:1 1 0;justify-content:center;padding:.5rem .85rem;font-size:.875rem}.toast23-action{display:inline-flex;align-items:center;justify-content:center;padding:.3rem .65rem;border:none;background:var(--toast23-action-bg);color:var(--toast23-action-text);font:600 .8125rem var(--toast23-font);border-radius:.375rem;cursor:pointer;transition:background-color .15s ease;white-space:nowrap}.toast23-action:hover{background:var(--toast23-action-bg-hover)}.toast23-action:focus-visible{outline:2px solid var(--toast23-color-info);outline-offset:1px}.toast23-action--cancel{background:var(--toast23-cancel-bg);color:var(--toast23-cancel-text);font-weight:600}.toast23-action--cancel:hover{background:var(--toast23-cancel-bg-hover)}.toast23-action--confirm{background:var(--toast23-color-info);color:#fff;box-shadow:0 1px 2px #00000014,0 0 0 1px #0000000d}.toast23-action--confirm:hover{filter:brightness(1.08)}.toast23-action--confirm:active{filter:brightness(.95)}.toast23-dismiss{display:flex;align-items:center;justify-content:center;flex-shrink:0;width:1.5rem;height:1.5rem;border:none;background:transparent;color:var(--toast23-text-muted);cursor:pointer;border-radius:.25rem;transition:color .15s ease,background-color .15s ease;margin:-.125rem -.25rem 0 0;padding:0}.toast23-dismiss:hover{color:var(--toast23-text-title);background:#0000000d}.toast23-dismiss:focus-visible{outline:2px solid var(--toast23-color-info);outline-offset:1px}.toast23-progress{position:absolute;bottom:0;left:0;width:100%;height:3.5px;transform-origin:left center;will-change:transform;border-radius:0 0 0 var(--toast23-radius)}.toast23-container--rtl .toast23-progress{transform-origin:right center;left:auto;right:0;border-radius:0 0 var(--toast23-radius) 0}.toast23-progress--success{background:var(--toast23-color-success)}.toast23-progress--error{background:var(--toast23-color-error)}.toast23-progress--warning{background:var(--toast23-color-warning)}.toast23-progress--info{background:var(--toast23-color-info)}.toast23-progress--default{background:var(--toast23-color-default)}.toast23-queue-badge{font-family:inherit;font-size:.75rem;font-weight:500;color:var(--toast23-text-muted);background:var(--toast23-queue-bg);border:1px solid var(--toast23-border-default);border-radius:9999px;padding:.25rem .75rem;text-align:center;pointer-events:none;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.toast23-spinner{animation:toast23-spin .7s linear infinite}@keyframes toast23-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.toast23-item,.toast23-item--entering,.toast23-item--exiting,.toast23-progress{transition-duration:1ms!important;transform:none!important}.toast23-item--entering,.toast23-item--exiting{opacity:0}.toast23-spinner{animation:none}}@media(max-width:480px){.toast23-container{padding:.75rem;left:0!important;right:0!important}.toast23-item{min-width:0;max-width:100%}}',rt="data-toast23-styles";function ct(){if(typeof document>"u"||document.querySelector(`style[${rt}]`))return;const t=document.createElement("style");t.setAttribute(rt,""),t.textContent=Mt,document.head.appendChild(t)}let J=null;function It(){if(typeof window>"u")return null;if(J)return J;const t=window.AudioContext??window.webkitAudioContext;if(!t)return null;try{return J=new t,J}catch{return null}}const Nt={success:[{freq:660,ms:90,gain:.18,type:"sine"},{freq:880,ms:130,gain:.18,type:"sine"}],error:[{freq:622,ms:140,gain:.3,type:"triangle"},{freq:415,ms:220,gain:.3,type:"triangle"}],warning:[{freq:880,ms:110,gain:.24,type:"triangle"},{freq:880,ms:110,gain:.24,type:"triangle"}],info:[{freq:784,ms:130,gain:.18,type:"sine"}],default:[{freq:660,ms:100,gain:.16,type:"sine"}],loading:[]};function Pt(t,n,o){const i=n.ms/1e3,p=t.createOscillator(),m=t.createGain();p.type=n.type,p.frequency.value=n.freq;const S=.008;return m.gain.setValueAtTime(1e-4,o),m.gain.exponentialRampToValueAtTime(n.gain,o+S),m.gain.exponentialRampToValueAtTime(1e-4,o+i),p.connect(m).connect(t.destination),p.start(o),p.stop(o+i),o+i}function nt(t,n){try{let o=t.currentTime+.03;const i=.02;for(const p of n)o=Pt(t,p,o)+i}catch{}}function dt(t){const n=It();if(!n)return;const o=Nt[t];if(!(!o||o.length===0)){if(n.state==="suspended"){n.resume().then(()=>nt(n,o),()=>{});return}nt(n,o)}}function Bt(){return typeof document>"u"||typeof Notification>"u"?!1:document.hidden}let it=!1;function Dt(t,n,o){if(!Bt())return;const i=()=>{try{new Notification(o??`[${n}]`,{body:t,tag:"toast-23"})}catch{}};if(Notification.permission==="granted"){i();return}Notification.permission==="default"&&!it&&(it=!0,Notification.requestPermission().then(p=>{p==="granted"&&i()}).catch(()=>{}))}function ut(){let t=[];const n=new Set;return{publish(o){t!==o&&(t=o,n.forEach(i=>i()))},getSnapshot(){return t},subscribe(o){return n.add(o),()=>{n.delete(o)}}}}ct();const qt=["top-right","top-left","top-center","bottom-right","bottom-left","bottom-center"],ot=({children:t,maxVisible:n=5,position:o="top-right",duration:i=5e3,layout:p="default",dir:m="ltr",theme:S="auto",target:g=null,historySize:h=50,focusShortcut:M="F8",swipeThreshold:D=80,swipeEnabled:w=!0,sound:A=!1,fallbackToNotification:b=!1})=>{const[k,T]=a.useReducer(vt,[]),[R,I]=a.useState(!1),y=a.useRef(k);y.current=k;const x=a.useRef();x.current||(x.current=ut());const j=x.current,u=a.useRef([]),l=a.useRef(new Set),c=a.useCallback(d=>{if(l.current.has(d.id))return;l.current.add(d.id);const e={id:d.id,message:d.message,title:d.title,variant:d.variant==="loading"?"info":d.variant,dismissedAt:Date.now(),group:d.group};if(u.current=[e,...u.current].slice(0,h),d.onDismiss)try{d.onDismiss()}catch{}},[h]),C=a.useCallback((d,e)=>{const f=e?.id??Q(),N=e?.variant??"default",P={id:f,message:d,title:e?.title,variant:N,duration:e?.duration??i,position:e?.position??o,dismissible:e?.dismissible??!0,removeDelay:e?.removeDelay??300,isExiting:!1,createdAt:Date.now(),version:0,isCustom:e?.isCustom,action:e?.action,cancelAction:e?.cancelAction,onDismiss:e?.onDismiss,group:e?.group,sound:e?.sound??A,fallbackToNotification:e?.fallbackToNotification??b};return e?.id?T({type:"UPSERT",toast:P}):T({type:"ADD",toast:P}),P.sound&&dt(N),P.fallbackToNotification&&typeof d=="string"&&Dt(d,N,P.title),f},[i,o,A,b]),E=a.useCallback((d,e)=>{T({type:"UPDATE",id:d,updates:e})},[]),L=a.useCallback(d=>{if(d){const e=y.current.find(f=>f.id===d);e&&c(e)}else y.current.forEach(c);T({type:"DISMISS",id:d})},[c]),_=a.useCallback(d=>{if(d){const e=y.current.find(f=>f.id===d);e&&c(e),T({type:"REMOVE",id:d}),l.current.delete(d)}else y.current.forEach(c),T({type:"REMOVE",id:d}),l.current.clear()},[c]),$=a.useCallback(d=>{y.current.filter(e=>e.group===d).forEach(c),T({type:"DISMISS_GROUP",group:d})},[c]),q=a.useCallback(d=>{const e=y.current.filter(f=>f.group===d);e.forEach(c),T({type:"REMOVE_GROUP",group:d});for(const f of e)l.current.delete(f.id)},[c]),z=a.useCallback(()=>I(!0),[]),r=a.useCallback(()=>I(!1),[]),K=a.useCallback(()=>u.current,[]),O=a.useMemo(()=>({addToast:C,updateToast:E,dismissToast:L,removeToast:_,dismissGroup:$,removeGroup:q,pauseAll:z,resumeAll:r,history:K,headlessStore:j,config:{maxVisible:n,position:o,duration:i,layout:p,dir:m,theme:S,swipeThreshold:D,swipeEnabled:w,sound:A,fallbackToNotification:b},isPausedGlobally:R}),[C,E,L,_,$,q,z,r,K,j,n,o,i,p,m,S,D,w,A,b,R]);a.useEffect(()=>{j.publish(k)},[k,j]),a.useEffect(()=>{if(!M||typeof window>"u")return;const d=e=>{if(e.key!==M)return;const f=document.querySelector('[data-toast23-region="true"]');f&&(e.preventDefault(),f.focus())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[M]);const W=a.useMemo(()=>{const d={"top-right":[],"top-left":[],"top-center":[],"bottom-right":[],"bottom-left":[],"bottom-center":[]};for(const e of k)(d[e.position]??d[o]).push(e);return d},[k,o]),F=s.jsx(s.Fragment,{children:qt.map(d=>W[d].length>0?s.jsx(lt,{position:d,toasts:W[d],maxVisible:n,layout:p,dir:m,theme:S,inline:g!=null},d):null)}),H=g??(typeof document<"u"?document.body:null);return s.jsxs(V.Provider,{value:O,children:[t,H?xt.createPortal(F,H):F]})};ot.displayName="Toast23Provider";const tt=["default","success","info","warning","error","loading"],Ot=["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"],Y={success:"#16a34a",error:"#dc2626",warning:"#ca8a04",info:"#2563eb",loading:"#7c3aed",default:"#6b7280"},Lt={compact:{width:360,height:480},expanded:{width:620,height:720}},$t=ut(),ft=({position:t="bottom-left",collapsed:n=!0})=>{const o=a.useContext(V),[i,p]=a.useState(n),[m,S]=a.useState("compact"),[g,h]=a.useState("queue"),[M,D]=a.useState(new Set),[w,A]=a.useState(null),[b,k]=a.useState(""),[T,R]=a.useState(4e3),I=o?.headlessStore??$t,y=a.useSyncExternalStore(I.subscribe,I.getSnapshot,I.getSnapshot),x=a.useMemo(()=>o?o.history():[],[o,y]),j=a.useCallback(e=>{D(f=>{const N=new Set(f);return N.has(e)?N.delete(e):N.add(e),N})},[]),u=a.useCallback(e=>{A(e),window.setTimeout(()=>{A(f=>f===e?null:f)},1200)},[]),l=a.useCallback((e,f)=>{const N=JSON.stringify(e,null,2);try{navigator?.clipboard?.writeText?navigator.clipboard.writeText(N).then(()=>u(f),()=>u(f)):u(f)}catch{u(f)}},[u]);if(!o)return null;const c=y.filter(e=>!M.has(e.variant)),C=x.filter(e=>!M.has(e.variant)),E=y.length,L=e=>{o.addToast(e.message,{variant:e.variant,title:e.title,group:e.group})},_=e=>{o.addToast(`Test ${e} toast`,{variant:e,title:e==="default"?void 0:e.toUpperCase(),duration:T,position:b||void 0})},$=Lt[m],q=t.startsWith("top"),z=t.endsWith("right"),r={chip:{position:"fixed",[q?"top":"bottom"]:16,[z?"right":"left"]:16,zIndex:1e5,display:"inline-flex",alignItems:"center",gap:6,padding:"6px 12px",background:"rgba(17, 24, 39, 0.96)",color:"#f9fafb",borderRadius:999,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:11,lineHeight:1,boxShadow:"0 6px 20px rgba(0,0,0,0.25)",border:"1px solid rgba(255,255,255,0.08)",cursor:"pointer",userSelect:"none"},panel:{position:"fixed",[q?"top":"bottom"]:16,[z?"right":"left"]:16,zIndex:1e5,width:`min(${$.width}px, calc(100vw - 32px))`,height:`min(${$.height}px, calc(100vh - 32px))`,background:"rgba(17, 24, 39, 0.97)",color:"#f9fafb",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:11,lineHeight:1.5,borderRadius:10,boxShadow:"0 10px 30px rgba(0,0,0,0.35)",border:"1px solid rgba(255,255,255,0.08)",overflow:"hidden",display:"flex",flexDirection:"column"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"8px 10px",borderBottom:"1px solid rgba(255,255,255,0.08)"},title:{display:"inline-flex",alignItems:"center",gap:6,fontWeight:700,letterSpacing:.3},badge:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:18,height:18,padding:"0 5px",borderRadius:999,background:"#3b82f6",color:"#fff",fontSize:10,fontWeight:700},iconBtn:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,borderRadius:4,background:"transparent",color:"#cbd5e1",border:"1px solid rgba(255,255,255,0.12)",cursor:"pointer",fontSize:12,fontFamily:"inherit"},tabs:{display:"flex",gap:4,padding:"8px 10px 0"},tab:{flex:1,padding:"5px 8px",borderRadius:6,background:"transparent",color:"#9ca3af",border:"1px solid transparent",cursor:"pointer",fontSize:10,fontFamily:"inherit",fontWeight:600,textTransform:"uppercase",letterSpacing:.5},tabActive:{background:"rgba(59, 130, 246, 0.15)",color:"#bfdbfe",borderColor:"rgba(59, 130, 246, 0.4)"},chipRow:{display:"flex",flexWrap:"wrap",gap:4,padding:"8px 10px",borderBottom:"1px solid rgba(255,255,255,0.05)"},filterChip:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 7px",borderRadius:999,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.04)",color:"#e5e7eb",fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:.4,cursor:"pointer",fontFamily:"inherit"},filterChipOff:{opacity:.35,textDecoration:"line-through"},body:{flex:1,overflow:"auto"},empty:{padding:"20px 12px",color:"#6b7280",textAlign:"center"},row:{padding:"8px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)"},rowTop:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,marginBottom:4},variantTag:{fontSize:9,padding:"1px 6px",borderRadius:3,color:"#fff",textTransform:"uppercase",letterSpacing:.3,fontWeight:700},rowMeta:{color:"#9ca3af",fontSize:10,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},rowMessage:{color:"#e5e7eb",whiteSpace:"pre-wrap",wordBreak:"break-word"},rowActions:{display:"flex",gap:4,marginTop:6},smallBtn:{flex:1,padding:"3px 7px",borderRadius:4,background:"rgba(255,255,255,0.06)",color:"#f9fafb",border:"1px solid rgba(255,255,255,0.1)",cursor:"pointer",fontSize:10,fontFamily:"inherit"},smallBtnActive:{background:"rgba(34, 197, 94, 0.18)",borderColor:"rgba(34, 197, 94, 0.5)",color:"#bbf7d0"},footer:{display:"flex",gap:4,padding:"8px 10px",borderTop:"1px solid rgba(255,255,255,0.08)",background:"rgba(0,0,0,0.2)"},section:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)"},sectionTitle:{fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:.6,color:"#9ca3af",marginBottom:8},grid3:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:4},grid6:{display:"grid",gridTemplateColumns:"repeat(6, 1fr)",gap:4},kvRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"3px 0",color:"#cbd5e1",fontSize:10},kvKey:{color:"#9ca3af"},inputRow:{display:"flex",alignItems:"center",gap:6,marginBottom:8},input:{flex:1,padding:"3px 6px",borderRadius:4,background:"rgba(255,255,255,0.06)",color:"#f9fafb",border:"1px solid rgba(255,255,255,0.1)",fontSize:10,fontFamily:"inherit"}},K=e=>({...r.variantTag,background:Y[e]}),O=s.jsxs("button",{type:"button",style:r.chip,onClick:()=>p(!1),"data-toast23-devtools":"chip","aria-label":`Open toast-23 devtools (${E} active)`,children:[s.jsx("span",{style:{fontWeight:700,letterSpacing:.3},children:"toast-23 devtools"}),s.jsx("span",{style:r.badge,children:E}),o.isPausedGlobally&&s.jsx("span",{style:{...r.badge,background:"#dc2626"},children:"paused"})]});if(i)return O;const W=s.jsx("div",{style:r.chipRow,children:tt.map(e=>{const f=M.has(e);return s.jsxs("button",{type:"button",onClick:()=>j(e),style:{...r.filterChip,...f?r.filterChipOff:null,borderColor:f?"rgba(255,255,255,0.12)":Y[e]+"80"},"aria-pressed":!f,title:f?`Show ${e}`:`Hide ${e}`,children:[s.jsx("span",{style:{width:6,height:6,borderRadius:999,background:Y[e],display:"inline-block"}}),e]},e)})}),F=s.jsxs(s.Fragment,{children:[W,s.jsxs("div",{style:r.body,children:[c.length===0&&s.jsx("div",{style:r.empty,children:y.length===0?"Queue is empty.":"All variants filtered out."}),c.map(e=>{const f=`q-${e.id}`;return s.jsxs("div",{style:r.row,children:[s.jsxs("div",{style:r.rowTop,children:[s.jsx("span",{style:K(e.variant),children:e.variant}),s.jsx("span",{style:r.rowMeta,title:e.id,children:e.id})]}),s.jsx("div",{style:r.rowMessage,children:typeof e.message=="string"?e.message:"[ReactNode message]"}),s.jsxs("div",{style:{...r.rowMeta,marginTop:2},children:[e.duration,"ms · ",e.position,e.group&&` · group: ${e.group}`,e.isExiting&&" · exiting"]}),s.jsxs("div",{style:r.rowActions,children:[s.jsx("button",{type:"button",style:r.smallBtn,onClick:()=>o.dismissToast(e.id),children:"Dismiss"}),s.jsx("button",{type:"button",style:r.smallBtn,onClick:()=>o.removeToast(e.id),children:"Remove"}),s.jsx("button",{type:"button",style:w===f?{...r.smallBtn,...r.smallBtnActive}:r.smallBtn,onClick:()=>l({id:e.id,variant:e.variant,message:typeof e.message=="string"?e.message:"[ReactNode]",title:e.title,duration:e.duration,position:e.position,group:e.group,createdAt:e.createdAt},f),children:w===f?"Copied":"Copy"})]})]},e.id)})]}),s.jsxs("div",{style:r.footer,children:[s.jsx("button",{type:"button",style:r.smallBtn,onClick:()=>o.isPausedGlobally?o.resumeAll():o.pauseAll(),children:o.isPausedGlobally?"Resume all":"Pause all"}),s.jsx("button",{type:"button",style:r.smallBtn,onClick:()=>o.dismissToast(),children:"Dismiss all"}),s.jsx("button",{type:"button",style:r.smallBtn,onClick:()=>o.removeToast(),children:"Clear"})]})]}),H=s.jsxs(s.Fragment,{children:[W,s.jsxs("div",{style:r.body,children:[C.length===0&&s.jsx("div",{style:r.empty,children:x.length===0?"No dismissed toasts yet. Fire a toast and dismiss it.":"All variants filtered out."}),C.map(e=>{const f=`h-${e.id}`,N=Gt(Date.now()-e.dismissedAt);return s.jsxs("div",{style:r.row,children:[s.jsxs("div",{style:r.rowTop,children:[s.jsx("span",{style:K(e.variant),children:e.variant}),s.jsx("span",{style:r.rowMeta,title:new Date(e.dismissedAt).toISOString(),children:N})]}),e.title&&s.jsx("div",{style:{fontWeight:700,color:"#f9fafb",marginBottom:2},children:e.title}),s.jsx("div",{style:r.rowMessage,children:typeof e.message=="string"?e.message:"[ReactNode message]"}),e.group&&s.jsxs("div",{style:{...r.rowMeta,marginTop:2},children:["group: ",e.group]}),s.jsxs("div",{style:r.rowActions,children:[s.jsx("button",{type:"button",style:r.smallBtn,onClick:()=>L(e),title:"Re-fire this toast",children:"Replay"}),s.jsx("button",{type:"button",style:w===f?{...r.smallBtn,...r.smallBtnActive}:r.smallBtn,onClick:()=>l({id:e.id,variant:e.variant,message:typeof e.message=="string"?e.message:"[ReactNode]",title:e.title,group:e.group,dismissedAt:e.dismissedAt},f),children:w===f?"Copied":"Copy"})]})]},e.id)})]}),s.jsx("div",{style:r.footer,children:s.jsxs("span",{style:{...r.rowMeta,alignSelf:"center",flex:1},children:[x.length," entries · cap ",x.length>=50?"reached":"ok"]})})]}),d=s.jsxs("div",{style:r.body,children:[s.jsxs("div",{style:r.section,children:[s.jsx("div",{style:r.sectionTitle,children:"Spawn test toast"}),s.jsx("div",{style:r.grid6,children:tt.map(e=>s.jsx("button",{type:"button",style:{...r.smallBtn,background:Y[e]+"33",borderColor:Y[e]+"80",color:"#fff"},onClick:()=>_(e),title:`Fire a ${e} toast`,children:e},e))})]}),s.jsxs("div",{style:r.section,children:[s.jsx("div",{style:r.sectionTitle,children:"Sound preview"}),s.jsx("div",{style:r.grid6,children:tt.map(e=>s.jsxs("button",{type:"button",style:r.smallBtn,onClick:()=>dt(e),title:`Play ${e} tone`,children:["♪ ",e.slice(0,4)]},e))}),s.jsx("div",{style:{...r.rowMeta,marginTop:6},children:"Plays the tone patch directly. Requires a prior user gesture (browser autoplay policy)."})]}),s.jsxs("div",{style:r.section,children:[s.jsx("div",{style:r.sectionTitle,children:"Test overrides"}),s.jsxs("div",{style:r.inputRow,children:[s.jsx("span",{style:r.kvKey,children:"duration"}),s.jsx("input",{type:"number",min:0,step:500,value:T,onChange:e=>R(Number(e.target.value)||0),style:r.input}),s.jsx("span",{style:r.kvKey,children:"ms"})]}),s.jsx("div",{style:{...r.kvKey,marginBottom:4,fontSize:10},children:"position"}),s.jsxs("div",{style:r.grid3,children:[s.jsx("button",{type:"button",style:b===""?{...r.smallBtn,...r.smallBtnActive}:r.smallBtn,onClick:()=>k(""),children:"inherit"}),Ot.map(e=>s.jsx("button",{type:"button",style:b===e?{...r.smallBtn,...r.smallBtnActive}:r.smallBtn,onClick:()=>k(e),title:e,children:e.replace("top-","↑").replace("bottom-","↓")},e))]})]}),s.jsxs("div",{style:r.section,children:[s.jsxs("div",{style:{...r.sectionTitle,display:"flex",justifyContent:"space-between"},children:[s.jsx("span",{children:"Provider config"}),s.jsx("button",{type:"button",style:w==="config"?{...r.smallBtn,...r.smallBtnActive,flex:"0 0 auto",padding:"2px 8px"}:{...r.smallBtn,flex:"0 0 auto",padding:"2px 8px"},onClick:()=>l({...o.config},"config"),children:w==="config"?"Copied":"Copy JSON"})]}),Object.entries(o.config).map(([e,f])=>s.jsxs("div",{style:r.kvRow,children:[s.jsx("span",{style:r.kvKey,children:e}),s.jsx("span",{children:String(f)})]},e)),s.jsxs("div",{style:{...r.kvRow,marginTop:6},children:[s.jsx("span",{style:r.kvKey,children:"paused"}),s.jsx("span",{children:o.isPausedGlobally?"yes":"no"})]})]})]});return s.jsxs("div",{style:r.panel,"data-toast23-devtools":"panel",children:[s.jsxs("div",{style:r.header,children:[s.jsxs("span",{style:r.title,children:["toast-23",s.jsx("span",{style:r.badge,children:E}),o.isPausedGlobally&&s.jsx("span",{style:{...r.badge,background:"#dc2626"},children:"paused"})]}),s.jsxs("span",{style:{display:"inline-flex",gap:4},children:[s.jsx("button",{type:"button",style:r.iconBtn,onClick:()=>S(e=>e==="compact"?"expanded":"compact"),title:m==="compact"?"Expand":"Shrink","aria-label":m==="compact"?"Expand panel":"Shrink panel",children:m==="compact"?"⤢":"⤡"}),s.jsx("button",{type:"button",style:r.iconBtn,onClick:()=>p(!0),title:"Collapse to chip","aria-label":"Collapse to chip",children:"–"})]})]}),s.jsx("div",{style:r.tabs,children:["queue","history","settings"].map(e=>s.jsxs("button",{type:"button",style:g===e?{...r.tab,...r.tabActive}:r.tab,onClick:()=>h(e),children:[e,e==="queue"&&E>0?` (${E})`:"",e==="history"&&x.length>0?` (${x.length})`:""]},e))}),g==="queue"&&F,g==="history"&&H,g==="settings"&&d]})};ft.displayName="Toast23DevTools";function Gt(t){if(t<0)return"now";const n=Math.floor(t/1e3);if(n<5)return"just now";if(n<60)return`${n}s ago`;const o=Math.floor(n/60);if(o<60)return`${o}m ago`;const i=Math.floor(o/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function gt(){const t=a.useContext(V);if(!t)throw new Error("[toast-23] useToast() must be used inside a <Toast23Provider>. Wrap your application root with <Toast23Provider> to fix this.");return a.useMemo(()=>{const n=((o,i)=>t.addToast(o,i));return n.success=(o,i)=>t.addToast(o,{...i,variant:"success"}),n.error=(o,i)=>t.addToast(o,{...i,variant:"error"}),n.warning=(o,i)=>t.addToast(o,{...i,variant:"warning"}),n.info=(o,i)=>t.addToast(o,{...i,variant:"info"}),n.loading=(o,i)=>t.addToast(o,{...i,variant:"loading",duration:i?.duration??0,dismissible:i?.dismissible??!1}),n.custom=(o,i)=>t.addToast(o,{...i,variant:"default",isCustom:!0}),n.dismiss=o=>t.dismissToast(o),n.remove=o=>t.removeToast(o),n.dismissGroup=o=>t.dismissGroup(o),n.removeGroup=o=>t.removeGroup(o),n.pauseAll=()=>t.pauseAll(),n.resumeAll=()=>t.resumeAll(),n.history=()=>t.history(),n.promise=async(o,i,p)=>{const m=t.addToast(i.loading,{...p,variant:"loading",duration:0,dismissible:!1});if(i.progress)try{i.progress(g=>{t.updateToast(m,{progress:Math.max(0,Math.min(1,g))})})}catch{}const S=typeof o=="function"?o():o;try{const g=await S,h=typeof i.success=="function"?i.success(g):i.success;return t.updateToast(m,{message:h,variant:"success",duration:p?.duration??t.config.duration,dismissible:!0,progress:void 0}),g}catch(g){const h=typeof i.error=="function"?i.error(g):i.error;throw t.updateToast(m,{message:h,variant:"error",duration:p?.duration??t.config.duration,dismissible:!0,progress:void 0}),g}},n.confirm=(o,i)=>new Promise(p=>{const m=Q();let S=!1;const g=h=>{S||(S=!0,p(h))};t.addToast(o,{id:m,variant:i?.variant??"warning",title:i?.title,position:i?.position,duration:0,dismissible:!0,action:{label:i?.confirmLabel??"Confirm",onClick:h=>{g(!0),h()},dismissOnClick:!1,className:"toast23-action--confirm"},cancelAction:{label:i?.cancelLabel??"Cancel",onClick:h=>{g(!1),h()},dismissOnClick:!1},onDismiss:()=>g(!1)})}),n},[t.addToast,t.updateToast,t.dismissToast,t.removeToast,t.dismissGroup,t.removeGroup,t.pauseAll,t.resumeAll,t.history,t.config.duration])}function _t(){const t=a.useContext(V);if(!t)throw new Error("[toast-23] useToast23Headless() must be used inside a <Toast23Provider>.");const{headlessStore:n}=t;return{toasts:a.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot),dismiss:t.dismissToast,remove:t.removeToast,dismissGroup:t.dismissGroup,removeGroup:t.removeGroup,pauseAll:t.pauseAll,resumeAll:t.resumeAll,history:t.history,isPausedGlobally:t.isPausedGlobally}}function zt(t){return function(){const o=gt();return X.useEffect(()=>{t(o)},[o]),null}}function Wt(t={}){const{position:n="top-right",maxVisible:o=5,duration:i=5e3,layout:p="default",dir:m="ltr",historySize:S,sound:g,fallbackToNotification:h,swipeEnabled:M,swipeThreshold:D}=t;ct();const w=document.createElement("div");w.setAttribute("data-toast23-standalone",""),w.style.display="contents",document.body.appendChild(w);let A=ht.createRoot(w),b=null;const k=[];let T;const R=new Promise(l=>{T=l}),y=zt(l=>{for(b=l,T(l);k.length>0;){const c=k.shift();try{c.method==="__call__"?l(...c.args):l[c.method](...c.args)}catch{}}});A.render(X.createElement(ot,{position:n,maxVisible:o,duration:i,layout:p,dir:m,...S!==void 0&&{historySize:S},...g!==void 0&&{sound:g},...h!==void 0&&{fallbackToNotification:h},...M!==void 0&&{swipeEnabled:M},...D!==void 0&&{swipeThreshold:D}},X.createElement(y)));const x=(l,...c)=>{if(b)return b[l](...c);k.push({method:l,args:c})},j=(l,c,C)=>{if(b)return b[l](c,C);const E=C?.id??Q();return k.push({method:l,args:[c,{...C,id:E}]}),E},u=((l,c)=>{if(b)return b(l,c);const C=c?.id??Q();return k.push({method:"__call__",args:[l,{...c,id:C}]}),C});return u.success=(l,c)=>j("success",l,c),u.error=(l,c)=>j("error",l,c),u.warning=(l,c)=>j("warning",l,c),u.info=(l,c)=>j("info",l,c),u.loading=(l,c)=>j("loading",l,c),u.custom=(l,c)=>j("custom",l,c),u.dismiss=l=>x("dismiss",l),u.remove=l=>x("remove",l),u.dismissGroup=l=>x("dismissGroup",l),u.removeGroup=l=>x("removeGroup",l),u.pauseAll=()=>x("pauseAll"),u.resumeAll=()=>x("resumeAll"),u.history=()=>b?b.history():[],u.promise=(l,c,C)=>b?b.promise(l,c,C):R.then(E=>E.promise(l,c,C)),u.confirm=(l,c)=>b?b.confirm(l,c):R.then(C=>C.confirm(l,c)),u.destroy=()=>{k.length=0,A&&(A.unmount(),A=null),w.remove(),b=null},u}exports.Toast23DevTools=ft;exports.Toast23Provider=ot;exports.createToast23=Wt;exports.useToast=gt;exports.useToast23Headless=_t;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|