juice-toast 1.3.0 → 1.3.1
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/CHANGELOG.md +8 -0
- package/CODE_OF_CONDUCT.md +2 -2
- package/EoL.md +0 -1
- package/README.md +6 -22
- package/dist/juice-toast-ios.d.ts +141 -0
- package/dist/juice-toast.d.ts +129 -186
- package/dist/juice-toast.esm.js +308 -2
- package/dist/juice-toast.ios.js +316 -0
- package/package.json +6 -2
- package/NEW_FUNCTION.md +0 -41
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
## v1.3.1
|
|
3
|
+
- Improved iOS / Safari (WebKit) compatibility
|
|
4
|
+
- Smoother swipe-to-dismiss on mobile
|
|
5
|
+
- Better pause-on-touch behavior
|
|
6
|
+
- Progress bar sync fixes
|
|
7
|
+
- Accessibility & stability improvements
|
|
8
|
+
|
|
1
9
|
v1.3.0
|
|
2
10
|
- Add CSS Injection System (no external `style.css` needed)
|
|
3
11
|
- Add Reduced Motion Support (prefers-reduced-motion)
|
package/CODE_OF_CONDUCT.md
CHANGED
|
@@ -49,7 +49,7 @@ Here are some ways you can help make Juice Toast a positive community:
|
|
|
49
49
|
If you see or experience something that breaks this Code of Conduct:
|
|
50
50
|
|
|
51
51
|
1. **Stay calm** and don’t respond aggressively.
|
|
52
|
-
2. **Report it** to the maintainers at **[
|
|
52
|
+
2. **Report it** to the maintainers at **[musickhairy@gmail.com]**.
|
|
53
53
|
3. Maintainers will **review and respond quickly and fairly**, keeping the reporter anonymous if requested.
|
|
54
54
|
4. Actions can include **warnings, temporary restrictions, or banning**, depending on severity.
|
|
55
55
|
|
|
@@ -84,4 +84,4 @@ Juice Toast isn’t just code — it’s a **community of developers who care**.
|
|
|
84
84
|
Great ideas come from collaboration, experimentation, and mutual respect.
|
|
85
85
|
By following this Code of Conduct, you’re helping make Juice Toast a **place where developers of all skill levels can grow, learn, and have fun**.
|
|
86
86
|
|
|
87
|
-
Let’s build something amazing together! 🚀
|
|
87
|
+
Let’s build something amazing together! 🚀
|
package/EoL.md
CHANGED
|
@@ -6,5 +6,4 @@ The following versions and distributions have reached End of Life (EoL) and are
|
|
|
6
6
|
|--------------------|-----------------|--------|
|
|
7
7
|
| 1.2.0-rc.2026 | UMD build | UMD distribution has been removed to simplify maintenance and reduce build complexity |
|
|
8
8
|
| 0.0.0-next.1202026 | Pre-release tag | Versioning structure became inconsistent and difficult to maintain |
|
|
9
|
-
| 1.0.0 | 1.0.0 | Stable release | Deprecated due to outdated internal architecture and styling standards |
|
|
10
9
|
| 1.0.0 | Stable release | Deprecated due to outdated internal architecture and styling standards |
|
package/README.md
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
**JuiceToast** is a lightweight, flexible, and dependency-free toast notification library for modern web applications.
|
|
4
4
|
Designed with a **clean API**, **extensive customization**, and **strong backward compatibility**, JuiceToast fits both small projects and enterprise-scale systems.
|
|
5
5
|
|
|
6
|
-
It supports **ESM
|
|
6
|
+
It supports **ESM**, **dynamic toast types**, **theme management**, **queue handling**, and **legacy API compatibility** out of the box.
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
## ✨ Key Features
|
|
11
11
|
|
|
12
12
|
- 🚀 Zero dependencies
|
|
13
|
-
- 📦 Supports **ESM**
|
|
13
|
+
- 📦 Supports **ESM**
|
|
14
14
|
- 🔁 Built-in queue system (one toast displayed at a time)
|
|
15
15
|
- 🎨 Theme system (light, dark, and custom themes)
|
|
16
16
|
- 🧩 Dynamic toast types (`success`, `error`, etc.)
|
|
@@ -26,26 +26,7 @@ It supports **ESM and UMD**, **dynamic toast types**, **theme management**, **qu
|
|
|
26
26
|
|
|
27
27
|
### ESM
|
|
28
28
|
```js
|
|
29
|
-
import juiceToast from "https://
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### UMD (Browser)
|
|
33
|
-
```html
|
|
34
|
-
<link
|
|
35
|
-
rel="stylesheet"
|
|
36
|
-
href="https://cdn.kyrt.my.id/libs/css/fontic/2.0.0/juice-toast/style.min.css"
|
|
37
|
-
/>
|
|
38
|
-
<script src="https://cdn.kyrt.my.id/libs/js/juice-toast/1.1.0/juice-toast.umd.min.js"></script>
|
|
39
|
-
|
|
40
|
-
<script>
|
|
41
|
-
juiceToast.setup({
|
|
42
|
-
success: {
|
|
43
|
-
bg: "#01AA38"
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
juiceToast.success("Hello world!");
|
|
48
|
-
</script>
|
|
29
|
+
import juiceToast from "https://npdn.kyrt.my.id/npm/juice-toast@1.3.0/dist/juice-toast.esm.js";
|
|
49
30
|
```
|
|
50
31
|
|
|
51
32
|
---
|
|
@@ -241,6 +222,9 @@ dark: {
|
|
|
241
222
|
- Browser-only (DOM required)
|
|
242
223
|
- Root element is automatically created: `#juice-toast-root`
|
|
243
224
|
- Suitable for frameworks, custom runtimes, etc.
|
|
225
|
+
- For JuiceToast ^v1.3.0, You don't need import `style.css` manually.
|
|
226
|
+
- UMD Are deprecated for maintain reason
|
|
227
|
+
- Need Improvment for Handphone user or WebKit user
|
|
244
228
|
|
|
245
229
|
---
|
|
246
230
|
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/* JuiceToast v1.3.1 (iOS Enhanced)
|
|
2
|
+
* (C) 2026 OpenDN Foundation
|
|
3
|
+
* Type Definitions
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type ToastType =
|
|
7
|
+
| "success"
|
|
8
|
+
| "error"
|
|
9
|
+
| "warning"
|
|
10
|
+
| "info"
|
|
11
|
+
| "loading"
|
|
12
|
+
| string
|
|
13
|
+
|
|
14
|
+
export type ToastPosition =
|
|
15
|
+
| "top-left"
|
|
16
|
+
| "top-right"
|
|
17
|
+
| "bottom-left"
|
|
18
|
+
| "bottom-right"
|
|
19
|
+
| "top-center"
|
|
20
|
+
| "bottom-center"
|
|
21
|
+
|
|
22
|
+
export type ToastSize = "sm" | "md" | "lg"
|
|
23
|
+
|
|
24
|
+
export type AnimationType =
|
|
25
|
+
| "spin"
|
|
26
|
+
| "pulse"
|
|
27
|
+
| "shake"
|
|
28
|
+
| "bounce"
|
|
29
|
+
| "wiggle"
|
|
30
|
+
| "pop"
|
|
31
|
+
| string
|
|
32
|
+
|
|
33
|
+
export interface ToastAction {
|
|
34
|
+
label: string
|
|
35
|
+
onClick?: (event: MouseEvent) => void
|
|
36
|
+
closeOnClick?: boolean
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ToastOptions {
|
|
40
|
+
/* content */
|
|
41
|
+
title?: string
|
|
42
|
+
message?: string
|
|
43
|
+
|
|
44
|
+
/* icon */
|
|
45
|
+
icon?: string
|
|
46
|
+
iconPack?: string
|
|
47
|
+
iconSize?: string | number
|
|
48
|
+
iconPosition?: "left" | "right" | "top"
|
|
49
|
+
iconLink?: string
|
|
50
|
+
iconAnimate?: AnimationType
|
|
51
|
+
|
|
52
|
+
/* layout */
|
|
53
|
+
position?: ToastPosition
|
|
54
|
+
size?: ToastSize
|
|
55
|
+
width?: string
|
|
56
|
+
height?: string
|
|
57
|
+
compact?: boolean
|
|
58
|
+
|
|
59
|
+
/* behavior */
|
|
60
|
+
duration?: number
|
|
61
|
+
closable?: boolean
|
|
62
|
+
progress?: boolean
|
|
63
|
+
progressColor?: string
|
|
64
|
+
swipeThreshold?: number
|
|
65
|
+
|
|
66
|
+
/* style */
|
|
67
|
+
theme?: string
|
|
68
|
+
bg?: string
|
|
69
|
+
color?: string
|
|
70
|
+
border?: string
|
|
71
|
+
glassUI?: boolean | number
|
|
72
|
+
|
|
73
|
+
/* animation */
|
|
74
|
+
animation?: AnimationType
|
|
75
|
+
enterAnimation?: AnimationType
|
|
76
|
+
|
|
77
|
+
/* actions */
|
|
78
|
+
actions?: ToastAction[]
|
|
79
|
+
|
|
80
|
+
/* sound */
|
|
81
|
+
playSound?: string | null
|
|
82
|
+
|
|
83
|
+
/* legacy / alias (still supported internally) */
|
|
84
|
+
toast?: ToastPosition
|
|
85
|
+
closeable?: boolean
|
|
86
|
+
icon_left_top?: string
|
|
87
|
+
icon_config?: string
|
|
88
|
+
icon_onClick_url?: string
|
|
89
|
+
icon_onClick_animate?: AnimationType
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface JuiceToastConfig {
|
|
93
|
+
duration?: number
|
|
94
|
+
maxVisible?: number
|
|
95
|
+
swipeThreshold?: number
|
|
96
|
+
glassUI?: number | boolean
|
|
97
|
+
playSound?: string | null
|
|
98
|
+
dev?: boolean
|
|
99
|
+
injectCSS?: boolean
|
|
100
|
+
css?: string
|
|
101
|
+
|
|
102
|
+
/* custom toast type defaults */
|
|
103
|
+
[type: string]: any
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface ToastPluginContext {
|
|
107
|
+
toast: HTMLElement
|
|
108
|
+
cfg: ToastOptions
|
|
109
|
+
type: ToastType
|
|
110
|
+
root: HTMLElement
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type JuiceToastPlugin = (ctx: ToastPluginContext) => void
|
|
114
|
+
|
|
115
|
+
export interface JuiceToast {
|
|
116
|
+
/* lifecycle */
|
|
117
|
+
setup(config?: JuiceToastConfig): void
|
|
118
|
+
clear(): void
|
|
119
|
+
destroy(): void
|
|
120
|
+
|
|
121
|
+
/* extension */
|
|
122
|
+
use(plugin: JuiceToastPlugin): void
|
|
123
|
+
addType(type: ToastType, defaults?: Partial<ToastOptions>): void
|
|
124
|
+
defineTheme(
|
|
125
|
+
name: string,
|
|
126
|
+
theme: {
|
|
127
|
+
bg?: string
|
|
128
|
+
color?: string
|
|
129
|
+
border?: string
|
|
130
|
+
}
|
|
131
|
+
): void
|
|
132
|
+
setTheme(name: string): void
|
|
133
|
+
|
|
134
|
+
/* dynamic toast functions (success, error, custom, dll) */
|
|
135
|
+
[key: string]: any
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
declare const juiceToast: JuiceToast
|
|
139
|
+
|
|
140
|
+
export default juiceToast
|
|
141
|
+
export { juiceToast }
|
package/dist/juice-toast.d.ts
CHANGED
|
@@ -1,186 +1,129 @@
|
|
|
1
|
-
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
/* ================= PLUGIN ================= */
|
|
132
|
-
|
|
133
|
-
export interface JuiceToastPluginContext {
|
|
134
|
-
toast: HTMLElement;
|
|
135
|
-
cfg: Readonly<ToastPayload>;
|
|
136
|
-
type: string;
|
|
137
|
-
root: HTMLElement;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export type JuiceToastPlugin = (
|
|
141
|
-
ctx: JuiceToastPluginContext
|
|
142
|
-
) => void;
|
|
143
|
-
|
|
144
|
-
/* ================= MAIN API ================= */
|
|
145
|
-
|
|
146
|
-
export interface JuiceToast {
|
|
147
|
-
/* core */
|
|
148
|
-
setup(cfg?: JuiceToastSetup): void;
|
|
149
|
-
clear(): void;
|
|
150
|
-
destroy(): void;
|
|
151
|
-
|
|
152
|
-
/* theme */
|
|
153
|
-
defineTheme(
|
|
154
|
-
name: string,
|
|
155
|
-
styles: Readonly<{
|
|
156
|
-
bg?: string;
|
|
157
|
-
color?: string;
|
|
158
|
-
border?: string;
|
|
159
|
-
}>
|
|
160
|
-
): void;
|
|
161
|
-
|
|
162
|
-
setTheme(name: string): void;
|
|
163
|
-
|
|
164
|
-
/* types */
|
|
165
|
-
addType(
|
|
166
|
-
name: string,
|
|
167
|
-
cfg?: Readonly<ToastPayload>
|
|
168
|
-
): void;
|
|
169
|
-
|
|
170
|
-
/* plugin */
|
|
171
|
-
use(plugin: JuiceToastPlugin): void;
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Dynamic toast methods
|
|
175
|
-
* success(), error(), warning(), info(), loading(), custom...
|
|
176
|
-
*/
|
|
177
|
-
readonly [type: string]:
|
|
178
|
-
| ((payload?: Readonly<ToastPayload> | string) => void)
|
|
179
|
-
| unknown;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const juiceToast: JuiceToast;
|
|
183
|
-
|
|
184
|
-
export default juiceToast;
|
|
185
|
-
export { juiceToast };
|
|
186
|
-
}
|
|
1
|
+
/* JuiceToast v1.3.1
|
|
2
|
+
* (C) 2026 OpenDN Foundation
|
|
3
|
+
* Type Definitions
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type ToastType =
|
|
7
|
+
| "success"
|
|
8
|
+
| "error"
|
|
9
|
+
| "warning"
|
|
10
|
+
| "info"
|
|
11
|
+
| "loading"
|
|
12
|
+
| string
|
|
13
|
+
|
|
14
|
+
export type ToastPosition =
|
|
15
|
+
| "top-left"
|
|
16
|
+
| "top-right"
|
|
17
|
+
| "bottom-left"
|
|
18
|
+
| "bottom-right"
|
|
19
|
+
| "top-center"
|
|
20
|
+
| "bottom-center"
|
|
21
|
+
|
|
22
|
+
export type ToastSize = "sm" | "md" | "lg"
|
|
23
|
+
|
|
24
|
+
export type AnimationType =
|
|
25
|
+
| "spin"
|
|
26
|
+
| "pulse"
|
|
27
|
+
| "shake"
|
|
28
|
+
| "bounce"
|
|
29
|
+
| "wiggle"
|
|
30
|
+
| "pop"
|
|
31
|
+
| string
|
|
32
|
+
|
|
33
|
+
export interface ToastAction {
|
|
34
|
+
label: string
|
|
35
|
+
onClick?: (event: MouseEvent) => void
|
|
36
|
+
closeOnClick?: boolean
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ToastOptions {
|
|
40
|
+
/* content */
|
|
41
|
+
title?: string
|
|
42
|
+
message?: string
|
|
43
|
+
|
|
44
|
+
/* icon */
|
|
45
|
+
icon?: string
|
|
46
|
+
iconPack?: string
|
|
47
|
+
iconSize?: string | number
|
|
48
|
+
iconPosition?: "left" | "right" | "top"
|
|
49
|
+
iconLink?: string
|
|
50
|
+
iconAnimate?: AnimationType
|
|
51
|
+
|
|
52
|
+
/* layout */
|
|
53
|
+
position?: ToastPosition
|
|
54
|
+
size?: ToastSize
|
|
55
|
+
width?: string
|
|
56
|
+
height?: string
|
|
57
|
+
compact?: boolean
|
|
58
|
+
|
|
59
|
+
/* behavior */
|
|
60
|
+
duration?: number
|
|
61
|
+
closable?: boolean
|
|
62
|
+
progress?: boolean
|
|
63
|
+
progressColor?: string
|
|
64
|
+
swipeThreshold?: number
|
|
65
|
+
|
|
66
|
+
/* style */
|
|
67
|
+
theme?: string
|
|
68
|
+
bg?: string
|
|
69
|
+
color?: string
|
|
70
|
+
border?: string
|
|
71
|
+
glassUI?: boolean | number
|
|
72
|
+
|
|
73
|
+
/* animation */
|
|
74
|
+
animation?: AnimationType
|
|
75
|
+
enterAnimation?: AnimationType
|
|
76
|
+
|
|
77
|
+
/* actions */
|
|
78
|
+
actions?: ToastAction[]
|
|
79
|
+
|
|
80
|
+
/* sound */
|
|
81
|
+
playSound?: string | null
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface JuiceToastConfig {
|
|
85
|
+
duration?: number
|
|
86
|
+
maxVisible?: number
|
|
87
|
+
swipeThreshold?: number
|
|
88
|
+
glassUI?: number | boolean
|
|
89
|
+
playSound?: string | null
|
|
90
|
+
dev?: boolean
|
|
91
|
+
injectCSS?: boolean
|
|
92
|
+
css?: string
|
|
93
|
+
|
|
94
|
+
[type: string]: any
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface ToastPluginContext {
|
|
98
|
+
toast: HTMLElement
|
|
99
|
+
cfg: ToastOptions
|
|
100
|
+
type: ToastType
|
|
101
|
+
root: HTMLElement
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export type JuiceToastPlugin = (ctx: ToastPluginContext) => void
|
|
105
|
+
|
|
106
|
+
export interface JuiceToast {
|
|
107
|
+
/* core */
|
|
108
|
+
setup(config?: JuiceToastConfig): void
|
|
109
|
+
clear(): void
|
|
110
|
+
destroy(): void
|
|
111
|
+
|
|
112
|
+
/* toast types */
|
|
113
|
+
[key: string]: any
|
|
114
|
+
|
|
115
|
+
/* extension */
|
|
116
|
+
use(plugin: JuiceToastPlugin): void
|
|
117
|
+
addType(type: ToastType, defaults?: Partial<ToastOptions>): void
|
|
118
|
+
defineTheme(name: string, theme: {
|
|
119
|
+
bg?: string
|
|
120
|
+
color?: string
|
|
121
|
+
border?: string
|
|
122
|
+
}): void
|
|
123
|
+
setTheme(name: string): void
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare const juiceToast: JuiceToast
|
|
127
|
+
|
|
128
|
+
export default juiceToast
|
|
129
|
+
export { juiceToast }
|
package/dist/juice-toast.esm.js
CHANGED
|
@@ -1,6 +1,312 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 2026 (C) OpenDN Foundation
|
|
3
|
-
* v1.3.
|
|
3
|
+
* v1.3.1 (STABLE)
|
|
4
4
|
* ESM (ECMAScript Module)
|
|
5
5
|
*/
|
|
6
|
-
const isBrowser="undefined"!=typeof window&&"undefined"!=typeof document,reduceMotion=isBrowser&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,TYPE_ANIMATION={success:"bounce",error:"shake",warning:"wiggle",info:"pulse",loading:"spin"};let __cssInjected=!1;const BASE_CSS='\n#juice-toast-root {\n position: fixed;\n z-index: 9999;\n display: flex;\n gap: 10px;\n pointer-events: none;\n}\n\n/* bottom (default) */\n#juice-toast-root[data-position="bottom"] {\n bottom: 20px;\n left: 50%;\n transform: translateX(-50%);\n flex-direction: column;\n align-items: center;\n}\n\n/* top */\n#juice-toast-root[data-position="top"] {\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n flex-direction: column;\n align-items: center;\n}\n\n/* center */\n#juice-toast-root[data-position="center"] {\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n flex-direction: column;\n align-items: center;\n}\n\n[id^="juice-toast-root-"] {\n position: fixed;\n z-index: 9999;\n display: flex;\n gap: 10px;\n pointer-events: none;\n}\n\n\n/* ================= TOAST ================= */\n\n.juice-toast {\n /* animation vars (safe for swipe) */\n --jt-x: 0px;\n --jt-y: 12px;\n\n pointer-events: auto;\n display: flex;\n gap: 12px;\n align-items: flex-start;\n\n min-width: 220px;\n max-width: 420px;\n padding: 12px 16px;\n margin: 6px 0;\n\n border-radius: 8px;\n background: #333;\n color: #fff;\n\n font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial;\n font-size: 14px;\n\n opacity: 0;\n transform: translate(var(--jt-x), var(--jt-y));\n transition:\n opacity .25s ease,\n transform .25s ease,\n background .25s ease,\n color .25s ease,\n box-shadow .25s ease;\n\n position: relative;\n box-sizing: border-box;\n overflow: hidden;\n}\n\n/* visible */\n.juice-toast.show {\n opacity: 1;\n --jt-y: 0px;\n}\n\n/* ================= ICON ================= */\n\n.juice-toast .icon {\n width: 28px;\n height: 28px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 16px;\n line-height: 1;\n flex: 0 0 28px;\n}\n\n/* clickable icon */\n.icon-clickable {\n opacity: 0.85;\n cursor: pointer;\n}\n\n.icon-clickable:hover {\n opacity: 1;\n}\n\n/* ================= CONTENT ================= */\n\n.juice-toast .jt-content {\n display: flex;\n flex-direction: column;\n gap: 4px;\n flex: 1 1 auto;\n}\n\n/* title */\n.juice-toast .jt-title {\n font-weight: 700;\n font-size: 13px;\n line-height: 1.1;\n}\n\n/* message */\n.juice-toast .jt-message {\n font-size: 13px;\n line-height: 1.3;\n opacity: 0.95;\n}\n\n/* ================= ICON POSITION ================= */\n\n.jt-icon-top {\n flex-direction: column;\n align-items: flex-start;\n}\n\n.jt-icon-top .icon {\n align-self: center;\n margin-bottom: 6px;\n}\n\n/* ================= CLOSE ================= */\n\n.juice-toast-close {\n position: absolute;\n top: 6px;\n right: 8px;\n cursor: pointer;\n font-size: 16px;\n opacity: 0.75;\n padding: 4px;\n border-radius: 4px;\n}\n\n.juice-toast-close:hover {\n opacity: 1;\n background: rgba(255,255,255,0.06);\n}\n\n/* ================= ACTIONS ================= */\n\n.jt-actions {\n display: flex;\n gap: 8px;\n margin-top: 10px;\n}\n\n.jt-action {\n background: transparent;\n border: 1px solid currentColor;\n padding: 4px 10px;\n border-radius: 6px;\n cursor: pointer;\n font-size: 12px;\n}\n\n/* ================= COMPACT ================= */\n\n.jt-compact {\n padding: 8px 10px;\n gap: 8px;\n font-size: 0.9em;\n}\n\n/* ================= GLASS UI ================= */\n\n.jt-glass {\n --g: calc(var(--jt-glass, 60) / 100);\n\n background: rgba(30, 30, 30, calc(0.2 + var(--g)));\n backdrop-filter: blur(calc(6px + (14px * var(--g))))\n saturate(calc(1 + (0.4 * var(--g))));\n -webkit-backdrop-filter: blur(calc(6px + (14px * var(--g))))\n saturate(calc(1 + (0.4 * var(--g))));\n}\n\n/* light theme support */\n[data-theme="light"] .jt-glass {\n background:\n linear-gradient(\n rgba(255,255,255, calc(0.6 * var(--g))),\n rgba(255,255,255, calc(0.35 * var(--g)))\n ),\n rgba(255,255,255, calc(0.55 - (0.25 * var(--g))));\n\n color: #111;\n\n border:\n 1px solid rgba(0,0,0, calc(0.05 + 0.12 * var(--g)));\n\n box-shadow:\n 0 10px 30px rgba(0,0,0, calc(0.08 + 0.18 * var(--g))),\n inset 0 1px 0 rgba(255,255,255, calc(0.4 * var(--g)));\n}\n\n/* ================= PROGRESS BAR ================= */\n.jt-progress {\n position: absolute;\n left: 0;\n bottom: 0;\n\n height: 3px;\n width: 100%;\n\n background: rgba(255,255,255,.7);\n transform-origin: left;\n transform: scaleX(1);\n opacity: .85;\n}\n\n/* ================= ANIMATIONS ================= */\n\n@keyframes jt-spin {\n to { transform: rotate(360deg); }\n}\n\n@keyframes jt-pulse {\n 50% { transform: scale(1.15); }\n}\n\n@keyframes jt-shake {\n 25% { transform: translateX(-3px); }\n 50% { transform: translateX(3px); }\n 75% { transform: translateX(-3px); }\n}\n\n@keyframes jt-bounce {\n 0% { transform: scale(1); }\n 30% { transform: scale(1.25); }\n 60% { transform: scale(.95); }\n 100% { transform: scale(1); }\n}\n\n@keyframes jt-wiggle {\n 0% { transform: rotate(0); }\n 25% { transform: rotate(-10deg); }\n 50% { transform: rotate(10deg); }\n 75% { transform: rotate(-6deg); }\n 100% { transform: rotate(0); }\n}\n\n@keyframes jt-pop {\n 0% { transform: scale(.7); opacity: 0; }\n 70% { transform: scale(1.05); opacity: 1; }\n 100% { transform: scale(1); }\n}\n\n/* ================= CLASSES ================= */\n\n.spin { animation: jt-spin .6s linear; }\n.pulse { animation: jt-pulse .4s ease; }\n.shake { animation: jt-shake .4s ease; }\n.bounce { animation: jt-bounce .45s ease; }\n.wiggle { animation: jt-wiggle .5s ease; }\n.pop { animation: jt-pop .35s ease-out; }\n\n/* ================= ICON INTERACTION ================= */\n\n.icon-clickable {\n cursor: pointer;\n transition: transform .15s ease, opacity .15s ease;\n}\n\n.icon-clickable:hover {\n transform: scale(1.1);\n opacity: .85;\n}\n\n/* ================= ACCESSIBILITY ================= */\n\n@media (prefers-reduced-motion: reduce) {\n .spin,\n .pulse,\n .shake,\n .bounce,\n .wiggle,\n .pop {\n animation: none !important;\n }\n}\n';function injectCSS(n){if(!isBrowser||__cssInjected)return;const t=document.createElement("style");t.id="juice-toast-style",t.textContent=n,document.head.appendChild(t),__cssInjected=!0}const themes={light:{bg:"#ffffff",color:"#111",border:"1px solid #e5e7eb"},dark:{bg:"#1f2937",color:"#fff",border:"1px solid rgba(255,255,255,.08)"}},sizePreset={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},juiceToast={_config:{},_queue:[],_showing:!1,_theme:"dark",_plugins:[],setup(n={}){this._config=n,this._defaults={...this._defaults,...n},this._registerTypes()},use(n){"function"==typeof n&&this._plugins.push(n)},addType(n,t={}){this._config[n]=t,this._registerTypes()},defineTheme(n,t={}){themes[n]={...themes[n]||{},...t}},setTheme(n){if(this._theme=n,!isBrowser)return;const t=document.getElementById("juice-toast-root");t&&(t.dataset.theme=n)},clear(){this._queue.length=0},destroy(){this.clear(),isBrowser&&document.getElementById("juice-toast-root")?.remove()},_registerTypes(){Object.keys(this._config).forEach((n=>{if("function"==typeof this[n]&&!this[n].__auto)return;const t=t=>this._enqueue(n,t);t.__auto=!0,this[n]=t}))},_enqueue(n,t){this._queue.push({type:n,payload:t}),this._showing||this._next()},_next(){if(!this._queue.length)return void(this._showing=!1);this._showing=!0;const n=this._queue.shift();this._showToast(n.type,n.payload)},_runPlugins(n){this._plugins.forEach((t=>{try{t(n)}catch(n){this._warn("Plugin error: "+n.message)}}))},_normalizeGlass(n){if(!0===n)return 60;if(!1===n||null==n)return 0;const t=Number(n);return Number.isFinite(t)?Math.max(0,Math.min(100,t)):0},_getRoot(n="bottom-right"){if(!isBrowser)return null;let t=document.getElementById(`juice-toast-root-${n}`);if(!t){switch(t=document.createElement("div"),t.id=`juice-toast-root-${n}`,t.dataset.position=n,t.dataset.theme=this._theme,t.style.position="fixed",t.style.zIndex=9999,n){case"top-left":t.style.top="20px",t.style.left="20px";break;case"top-right":t.style.top="20px",t.style.right="20px";break;case"bottom-left":t.style.bottom="20px",t.style.left="20px";break;case"bottom-right":t.style.bottom="20px",t.style.right="20px";break;case"top-center":t.style.top="20px",t.style.left="50%",t.style.transform="translateX(-50%)";break;case"bottom-center":t.style.bottom="20px",t.style.left="50%",t.style.transform="translateX(-50%)"}document.body.appendChild(t)}return t},_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,playSound:null,dev:!1,injectCSS:!0,css:null},_warn(n){this._defaults.dev&&"undefined"!=typeof console&&console.warn("[JuiceToast]",n)},_playSound(n){if(!isBrowser)return;const t="string"==typeof n&&n?n:this._defaults.playSound;if(t)try{const n=new Audio(t);n.volume=.6,n.play().catch((()=>{}))}catch{}},_showToast(n,t){if(!isBrowser)return;!1!==this._defaults.injectCSS&&injectCSS(this._defaults.css||BASE_CSS);const e={...this._config[n]||{},..."object"==typeof t?t:{message:String(t)}};e.icon=e.icon??e.icon_left_top,e.iconPack=e.iconPack??e.icon_config,e.iconLink=e.iconLink??e.icon_onClick_url,e.iconAnimate=e.iconAnimate??e.icon_onClick_animate,e.position=e.position??e.toast,e.closable=e.closable??e.closeable,e.iconPosition=e.iconPosition||"left",e.compact=!!e.compact;const s=themes[e.theme||this._theme]||{},o=document.createElement("div");o.className="juice-toast";const i=e.animation||"slide-in";if(e.enterAnimation||(o.style.animation=`${i} 0.4s ease forwards`),o.setAttribute("role","alert"),o.setAttribute("aria-live","polite"),o.tabIndex=0,e.size&&sizePreset[e.size]){const n=sizePreset[e.size];n.width&&(o.style.width=n.width),n.padding&&(o.style.padding=n.padding)}let a=null;e.progress&&(e.duration??this._defaults.duration)>0&&(a=document.createElement("div"),a.className="jt-progress",e.progressColor&&(a.style.background=e.progressColor||"rgba(255,255,255,.7)"),o.appendChild(a));const r=this._normalizeGlass(e.glassUI??this._defaults.glassUI);r>0&&(o.classList.add("jt-glass"),o.style.setProperty("--jt-glass",r)),r||(o.style.background=e.bg||s.bg),o.style.color=e.color||s.color,o.style.border=e.border||s.border,e.compact&&o.classList.add("jt-compact"),(e.glassUI??this._defaults.glassUI)&&o.classList.add("jt-glass"),e.width&&(o.style.width=e.width),e.height&&(o.style.height=e.height);let c=null;if(e.icon){c=document.createElement("i"),c.className=["icon",e.iconPack||"",e.icon].join(" ").trim(),e.iconSize&&(c.style.fontSize=e.iconSize),(e.iconLink||e.iconAnimate)&&(c.classList.add("icon-clickable"),c.onclick=n=>{n.stopPropagation(),e.iconAnimate&&(c.classList.remove(e.iconAnimate),c.offsetWidth,c.classList.add(e.iconAnimate)),e.iconLink&&window.open(e.iconLink,"_blank","noopener")});const t=e.iconAnimate??TYPE_ANIMATION[n];t&&(c.classList.add(t),c.addEventListener("click",(()=>{c.classList.remove(t),c.offsetWidth,c.classList.add(t)})))}reduceMotion&&(o.classList.remove("pop","bounce","shake","wiggle","pulse","spin"),c?.classList.remove("bounce","shake","wiggle","pulse","spin")),e.message||e.title||this._warn("Toast created without message or title"),e.icon&&!e.iconPack&&this._warn("icon provided without iconPack"),e.duration<0&&this._warn("duration cannot be negative");let l=0,d=0;o.addEventListener("touchstart",(n=>{l=n.touches[0].clientX})),o.addEventListener("touchmove",(n=>{d=n.touches[0].clientX-l,o.style.transform=`translateX(${d}px)`})),o.addEventListener("touchend",(()=>{Math.abs(d)>this._defaults.swipeThreshold?(o.style.transform=`translateX(${d>0?1e3:-1e3}px)`,setTimeout((()=>{o.remove(),this._next()}),200)):o.style.transform="",l=d=0}));const p=document.createElement("div");p.className="jt-content";const u=e.enterAnimation??"pop";if(u&&!reduceMotion&&o.classList.add(u),e.title){const n=document.createElement("div");n.className="jt-title",n.textContent=e.title,p.appendChild(n)}const m=document.createElement("div");if(m.className="jt-message",m.textContent=e.message||"",p.appendChild(m),c&&"top"===e.iconPosition?(o.classList.add("jt-icon-top"),o.appendChild(c),o.appendChild(p)):c&&"right"===e.iconPosition?(o.appendChild(p),o.appendChild(c)):(c&&o.appendChild(c),o.appendChild(p)),Array.isArray(e.actions)&&e.actions.length){const n=document.createElement("div");n.className="jt-actions",e.actions.forEach((t=>{const e=document.createElement("button");e.className="jt-action",e.textContent=t.label,e.onclick=n=>{n.stopPropagation(),t.onClick?.(n),t.closeOnClick&&(o.remove(),this._next())},n.appendChild(e)})),p.appendChild(n)}if(e.closable){const n=document.createElement("span");n.className="juice-toast-close",n.innerHTML="×",n.onclick=()=>{o.remove(),this._next()},o.appendChild(n)}const h=this._getRoot(e.position),f=this._defaults.maxVisible;f&&h.children.length>=f&&h.firstChild.remove(),h.appendChild(o),this._runPlugins({toast:o,cfg:e,type:n,root:h}),requestAnimationFrame((()=>o.classList.add("show")));const g=e.duration??2500;if(0===g)return;let x,b=Date.now(),y=e.duration??this._defaults.duration;const _=()=>{if(o.__paused)b=Date.now();else{const n=Date.now();y-=n-b,b=n}y<=0?(o.classList.remove("show"),setTimeout((()=>{o.remove(),this._next()}),300)):x=requestAnimationFrame(_),a&&(a.style.transform=`scaleX(${Math.max(0,y/g)})`)};o.addEventListener("mouseenter",(()=>o.__paused=!0)),o.addEventListener("mouseleave",(()=>o.__paused=!1)),o.addEventListener("touchstart",(()=>o.__paused=!0)),o.addEventListener("touchend",(()=>o.__paused=!1)),requestAnimationFrame(_)}};export default juiceToast;export{juiceToast};
|
|
6
|
+
let isBrowser="undefined"!=typeof window&&"undefined"!=typeof document,reduceMotion=isBrowser&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,TYPE_ANIMATION={success:"bounce",error:"shake",warning:"wiggle",info:"pulse",loading:"spin"},__cssInjected=!1,BASE_CSS=`
|
|
7
|
+
#juice-toast-root {
|
|
8
|
+
position: fixed;
|
|
9
|
+
z-index: 9999;
|
|
10
|
+
display: flex;
|
|
11
|
+
gap: 10px;
|
|
12
|
+
pointer-events: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* bottom (default) */
|
|
16
|
+
#juice-toast-root[data-position="bottom"] {
|
|
17
|
+
bottom: 20px;
|
|
18
|
+
left: 50%;
|
|
19
|
+
transform: translateX(-50%);
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
align-items: center;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* top */
|
|
25
|
+
#juice-toast-root[data-position="top"] {
|
|
26
|
+
top: 20px;
|
|
27
|
+
left: 50%;
|
|
28
|
+
transform: translateX(-50%);
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
align-items: center;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* center */
|
|
34
|
+
#juice-toast-root[data-position="center"] {
|
|
35
|
+
top: 50%;
|
|
36
|
+
left: 50%;
|
|
37
|
+
transform: translate(-50%, -50%);
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
align-items: center;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
[id^="juice-toast-root-"] {
|
|
43
|
+
position: fixed;
|
|
44
|
+
z-index: 9999;
|
|
45
|
+
display: flex;
|
|
46
|
+
gap: 10px;
|
|
47
|
+
pointer-events: none;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
/* ================= TOAST ================= */
|
|
52
|
+
|
|
53
|
+
.juice-toast {
|
|
54
|
+
/* animation vars (safe for swipe) */
|
|
55
|
+
--jt-x: 0px;
|
|
56
|
+
--jt-y: 12px;
|
|
57
|
+
|
|
58
|
+
pointer-events: auto;
|
|
59
|
+
display: flex;
|
|
60
|
+
gap: 12px;
|
|
61
|
+
align-items: flex-start;
|
|
62
|
+
|
|
63
|
+
min-width: 220px;
|
|
64
|
+
max-width: 420px;
|
|
65
|
+
padding: 12px 16px;
|
|
66
|
+
margin: 6px 0;
|
|
67
|
+
|
|
68
|
+
border-radius: 8px;
|
|
69
|
+
background: #333;
|
|
70
|
+
color: #fff;
|
|
71
|
+
|
|
72
|
+
font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial;
|
|
73
|
+
font-size: 14px;
|
|
74
|
+
|
|
75
|
+
opacity: 0;
|
|
76
|
+
transform: translate(var(--jt-x), var(--jt-y));
|
|
77
|
+
transition:
|
|
78
|
+
opacity .25s ease,
|
|
79
|
+
transform .25s ease,
|
|
80
|
+
background .25s ease,
|
|
81
|
+
color .25s ease,
|
|
82
|
+
box-shadow .25s ease;
|
|
83
|
+
|
|
84
|
+
position: relative;
|
|
85
|
+
box-sizing: border-box;
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* visible */
|
|
90
|
+
.juice-toast.show {
|
|
91
|
+
opacity: 1;
|
|
92
|
+
--jt-y: 0px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* ================= ICON ================= */
|
|
96
|
+
|
|
97
|
+
.juice-toast .icon {
|
|
98
|
+
width: 28px;
|
|
99
|
+
height: 28px;
|
|
100
|
+
display: inline-flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
justify-content: center;
|
|
103
|
+
font-size: 16px;
|
|
104
|
+
line-height: 1;
|
|
105
|
+
flex: 0 0 28px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* clickable icon */
|
|
109
|
+
.icon-clickable {
|
|
110
|
+
opacity: 0.85;
|
|
111
|
+
cursor: pointer;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.icon-clickable:hover {
|
|
115
|
+
opacity: 1;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* ================= CONTENT ================= */
|
|
119
|
+
|
|
120
|
+
.juice-toast .jt-content {
|
|
121
|
+
display: flex;
|
|
122
|
+
flex-direction: column;
|
|
123
|
+
gap: 4px;
|
|
124
|
+
flex: 1 1 auto;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* title */
|
|
128
|
+
.juice-toast .jt-title {
|
|
129
|
+
font-weight: 700;
|
|
130
|
+
font-size: 13px;
|
|
131
|
+
line-height: 1.1;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* message */
|
|
135
|
+
.juice-toast .jt-message {
|
|
136
|
+
font-size: 13px;
|
|
137
|
+
line-height: 1.3;
|
|
138
|
+
opacity: 0.95;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* ================= ICON POSITION ================= */
|
|
142
|
+
|
|
143
|
+
.jt-icon-top {
|
|
144
|
+
flex-direction: column;
|
|
145
|
+
align-items: flex-start;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.jt-icon-top .icon {
|
|
149
|
+
align-self: center;
|
|
150
|
+
margin-bottom: 6px;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* ================= CLOSE ================= */
|
|
154
|
+
|
|
155
|
+
.juice-toast-close {
|
|
156
|
+
position: absolute;
|
|
157
|
+
top: 6px;
|
|
158
|
+
right: 8px;
|
|
159
|
+
cursor: pointer;
|
|
160
|
+
font-size: 16px;
|
|
161
|
+
opacity: 0.75;
|
|
162
|
+
padding: 4px;
|
|
163
|
+
border-radius: 4px;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.juice-toast-close:hover {
|
|
167
|
+
opacity: 1;
|
|
168
|
+
background: rgba(255,255,255,0.06);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* ================= ACTIONS ================= */
|
|
172
|
+
|
|
173
|
+
.jt-actions {
|
|
174
|
+
display: flex;
|
|
175
|
+
gap: 8px;
|
|
176
|
+
margin-top: 10px;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.jt-action {
|
|
180
|
+
background: transparent;
|
|
181
|
+
border: 1px solid currentColor;
|
|
182
|
+
padding: 4px 10px;
|
|
183
|
+
border-radius: 6px;
|
|
184
|
+
cursor: pointer;
|
|
185
|
+
font-size: 12px;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* ================= COMPACT ================= */
|
|
189
|
+
|
|
190
|
+
.jt-compact {
|
|
191
|
+
padding: 8px 10px;
|
|
192
|
+
gap: 8px;
|
|
193
|
+
font-size: 0.9em;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* ================= GLASS UI ================= */
|
|
197
|
+
|
|
198
|
+
.jt-glass {
|
|
199
|
+
--g: calc(var(--jt-glass, 60) / 100);
|
|
200
|
+
|
|
201
|
+
background: rgba(30, 30, 30, calc(0.2 + var(--g)));
|
|
202
|
+
backdrop-filter: blur(calc(6px + (14px * var(--g))))
|
|
203
|
+
saturate(calc(1 + (0.4 * var(--g))));
|
|
204
|
+
-webkit-backdrop-filter: blur(calc(6px + (14px * var(--g))))
|
|
205
|
+
saturate(calc(1 + (0.4 * var(--g))));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* light theme support */
|
|
209
|
+
[data-theme="light"] .jt-glass {
|
|
210
|
+
background:
|
|
211
|
+
linear-gradient(
|
|
212
|
+
rgba(255,255,255, calc(0.6 * var(--g))),
|
|
213
|
+
rgba(255,255,255, calc(0.35 * var(--g)))
|
|
214
|
+
),
|
|
215
|
+
rgba(255,255,255, calc(0.55 - (0.25 * var(--g))));
|
|
216
|
+
|
|
217
|
+
color: #111;
|
|
218
|
+
|
|
219
|
+
border:
|
|
220
|
+
1px solid rgba(0,0,0, calc(0.05 + 0.12 * var(--g)));
|
|
221
|
+
|
|
222
|
+
box-shadow:
|
|
223
|
+
0 10px 30px rgba(0,0,0, calc(0.08 + 0.18 * var(--g))),
|
|
224
|
+
inset 0 1px 0 rgba(255,255,255, calc(0.4 * var(--g)));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/* ================= PROGRESS BAR ================= */
|
|
228
|
+
.jt-progress {
|
|
229
|
+
position: absolute;
|
|
230
|
+
left: 0;
|
|
231
|
+
bottom: 0;
|
|
232
|
+
|
|
233
|
+
height: 3px;
|
|
234
|
+
width: 100%;
|
|
235
|
+
|
|
236
|
+
background: rgba(255,255,255,.7);
|
|
237
|
+
transform-origin: left;
|
|
238
|
+
transform: scaleX(1);
|
|
239
|
+
opacity: .85;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* ================= ANIMATIONS ================= */
|
|
243
|
+
|
|
244
|
+
@keyframes jt-spin {
|
|
245
|
+
to { transform: rotate(360deg); }
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
@keyframes jt-pulse {
|
|
249
|
+
50% { transform: scale(1.15); }
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
@keyframes jt-shake {
|
|
253
|
+
25% { transform: translateX(-3px); }
|
|
254
|
+
50% { transform: translateX(3px); }
|
|
255
|
+
75% { transform: translateX(-3px); }
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
@keyframes jt-bounce {
|
|
259
|
+
0% { transform: scale(1); }
|
|
260
|
+
30% { transform: scale(1.25); }
|
|
261
|
+
60% { transform: scale(.95); }
|
|
262
|
+
100% { transform: scale(1); }
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
@keyframes jt-wiggle {
|
|
266
|
+
0% { transform: rotate(0); }
|
|
267
|
+
25% { transform: rotate(-10deg); }
|
|
268
|
+
50% { transform: rotate(10deg); }
|
|
269
|
+
75% { transform: rotate(-6deg); }
|
|
270
|
+
100% { transform: rotate(0); }
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
@keyframes jt-pop {
|
|
274
|
+
0% { transform: scale(.7); opacity: 0; }
|
|
275
|
+
70% { transform: scale(1.05); opacity: 1; }
|
|
276
|
+
100% { transform: scale(1); }
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* ================= CLASSES ================= */
|
|
280
|
+
|
|
281
|
+
.spin { animation: jt-spin .6s linear; }
|
|
282
|
+
.pulse { animation: jt-pulse .4s ease; }
|
|
283
|
+
.shake { animation: jt-shake .4s ease; }
|
|
284
|
+
.bounce { animation: jt-bounce .45s ease; }
|
|
285
|
+
.wiggle { animation: jt-wiggle .5s ease; }
|
|
286
|
+
.pop { animation: jt-pop .35s ease-out; }
|
|
287
|
+
|
|
288
|
+
/* ================= ICON INTERACTION ================= */
|
|
289
|
+
|
|
290
|
+
.icon-clickable {
|
|
291
|
+
cursor: pointer;
|
|
292
|
+
transition: transform .15s ease, opacity .15s ease;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.icon-clickable:hover {
|
|
296
|
+
transform: scale(1.1);
|
|
297
|
+
opacity: .85;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/* ================= ACCESSIBILITY ================= */
|
|
301
|
+
|
|
302
|
+
@media (prefers-reduced-motion: reduce) {
|
|
303
|
+
.spin,
|
|
304
|
+
.pulse,
|
|
305
|
+
.shake,
|
|
306
|
+
.bounce,
|
|
307
|
+
.wiggle,
|
|
308
|
+
.pop {
|
|
309
|
+
animation: none !important;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
`;function injectCSS(e){if(!isBrowser||__cssInjected)return;let t=document.createElement("style");t.id="juice-toast-style",t.textContent=e,document.head.appendChild(t),__cssInjected=!0}let themes={light:{bg:"#ffffff",color:"#111",border:"1px solid #e5e7eb"},dark:{bg:"#1f2937",color:"#fff",border:"1px solid rgba(255,255,255,.08)"}},sizePreset={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},juiceToast={_config:{},_queue:[],_showing:!1,_theme:"dark",_plugins:[],setup(e={}){this._config=e,this._defaults={...this._defaults,...e},this._registerTypes()},use(e){"function"==typeof e&&this._plugins.push(e)},addType(e,t={}){this._config[e]=t,this._registerTypes()},defineTheme(e,t={}){themes[e]={...themes[e]||{},...t}},setTheme(e){if(this._theme=e,!isBrowser)return;let t=document.getElementById("juice-toast-root");t&&(t.dataset.theme=e)},clear(){this._queue.length=0},destroy(){this.clear(),isBrowser&&document.getElementById("juice-toast-root")?.remove()},_registerTypes(){Object.keys(this._config).forEach(e=>{if("function"==typeof this[e]&&!this[e].__auto)return;let t=t=>this._enqueue(e,t);t.__auto=!0,this[e]=t})},_enqueue(e,t){this._queue.push({type:e,payload:t}),this._showing||this._next()},_next(){if(!this._queue.length){this._showing=!1;return}this._showing=!0;let e=this._queue.shift();this._showToast(e.type,e.payload)},_runPlugins(e){this._plugins.forEach(t=>{try{t(e)}catch(s){this._warn("Plugin error: "+s.message)}})},_normalizeGlass(e){if(!0===e)return 60;if(!1===e||null==e)return 0;let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(100,t)):0},_getRoot(e="bottom-right"){if(!isBrowser)return null;let t=document.getElementById(`juice-toast-root-${e}`);if(!t){switch((t=document.createElement("div")).id=`juice-toast-root-${e}`,t.dataset.position=e,t.dataset.theme=this._theme,t.style.position="fixed",t.style.zIndex=9999,e){case"top-left":t.style.top="20px",t.style.left="20px";break;case"top-right":t.style.top="20px",t.style.right="20px";break;case"bottom-left":t.style.bottom="20px",t.style.left="20px";break;case"bottom-right":t.style.bottom="20px",t.style.right="20px";break;case"top-center":t.style.top="20px",t.style.left="50%",t.style.transform="translateX(-50%)";break;case"bottom-center":t.style.bottom="20px",t.style.left="50%",t.style.transform="translateX(-50%)"}document.body.appendChild(t)}return t},_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,playSound:null,dev:!1,injectCSS:!0,css:null},_warn(e){this._defaults.dev&&"undefined"!=typeof console&&console.warn("[JuiceToast]",e)},_playSound(e){if(!isBrowser)return;let t="string"==typeof e&&e?e:this._defaults.playSound;if(t)try{let s=new Audio(t);s.volume=.6,s.play().catch(()=>{})}catch{}},_showToast(e,t){if(!isBrowser)return;!1!==this._defaults.injectCSS&&injectCSS(this._defaults.css||BASE_CSS);let s=this._config[e]||{},i="object"==typeof t?t:{message:String(t)},a={...s,...i};a.icon=a.icon??a.icon_left_top,a.iconPack=a.iconPack??a.icon_config,a.iconLink=a.iconLink??a.icon_onClick_url,a.iconAnimate=a.iconAnimate??a.icon_onClick_animate,a.position=a.position??a.toast,a.closable=a.closable??a.closeable,a.iconPosition=a.iconPosition||"left",a.compact=!!a.compact;let o=themes[a.theme||this._theme]||{},n=document.createElement("div");n.className="juice-toast";let r=a.animation||"slide-in";if(a.enterAnimation||(n.style.animation=`${r} 0.4s ease forwards`),n.setAttribute("role","alert"),n.setAttribute("aria-live","polite"),n.tabIndex=0,a.size&&sizePreset[a.size]){let l=sizePreset[a.size];l.width&&(n.style.width=l.width),l.padding&&(n.style.padding=l.padding)}let c=null;a.progress&&(a.duration??this._defaults.duration)>0&&((c=document.createElement("div")).className="jt-progress",a.progressColor&&(c.style.background=a.progressColor||"rgba(255,255,255,.7)"),n.appendChild(c));let p=this._normalizeGlass(a.glassUI??this._defaults.glassUI);p>0&&(n.classList.add("jt-glass"),n.style.setProperty("--jt-glass",p)),p||(n.style.background=a.bg||o.bg),n.style.color=a.color||o.color,n.style.border=a.border||o.border,a.compact&&n.classList.add("jt-compact"),(a.glassUI??this._defaults.glassUI)&&n.classList.add("jt-glass"),a.width&&(n.style.width=a.width),a.height&&(n.style.height=a.height);let d=null;if(a.icon){(d=document.createElement("i")).className=["icon",a.iconPack||"",a.icon].join(" ").trim(),a.iconSize&&(d.style.fontSize=a.iconSize),(a.iconLink||a.iconAnimate)&&(d.classList.add("icon-clickable"),d.onclick=e=>{e.stopPropagation(),a.iconAnimate&&(d.classList.remove(a.iconAnimate),d.offsetWidth,d.classList.add(a.iconAnimate)),a.iconLink&&window.open(a.iconLink,"_blank","noopener")});let u=a.iconAnimate??TYPE_ANIMATION[e];u&&(d.classList.add(u),d.addEventListener("click",()=>{d.classList.remove(u),d.offsetWidth,d.classList.add(u)}))}reduceMotion&&(n.classList.remove("pop","bounce","shake","wiggle","pulse","spin"),d?.classList.remove("bounce","shake","wiggle","pulse","spin")),a.message||a.title||this._warn("Toast created without message or title"),a.icon&&!a.iconPack&&this._warn("icon provided without iconPack"),a.duration<0&&this._warn("duration cannot be negative");let h=0,m=0;n.addEventListener("touchstart",e=>{h=e.touches[0].clientX}),n.addEventListener("touchmove",e=>{m=e.touches[0].clientX-h,n.style.transform=`translateX(${m}px)`}),n.addEventListener("touchend",()=>{Math.abs(m)>this._defaults.swipeThreshold?(n.style.transform=`translateX(${m>0?1e3:-1e3}px)`,setTimeout(()=>{n.remove(),this._next()},200)):n.style.transform="",h=m=0});let f=document.createElement("div");f.className="jt-content";let g=a.enterAnimation??"pop";if(g&&!reduceMotion&&n.classList.add(g),a.title){let $=document.createElement("div");$.className="jt-title",$.textContent=a.title,f.appendChild($)}let x=document.createElement("div");if(x.className="jt-message",x.textContent=a.message||"",f.appendChild(x),d&&"top"===a.iconPosition?(n.classList.add("jt-icon-top"),n.appendChild(d),n.appendChild(f)):d&&"right"===a.iconPosition?(n.appendChild(f),n.appendChild(d)):(d&&n.appendChild(d),n.appendChild(f)),Array.isArray(a.actions)&&a.actions.length){let b=document.createElement("div");b.className="jt-actions",a.actions.forEach(e=>{let t=document.createElement("button");t.className="jt-action",t.textContent=e.label,t.onclick=t=>{t.stopPropagation(),e.onClick?.(t),e.closeOnClick&&(n.remove(),this._next())},b.appendChild(t)}),f.appendChild(b)}if(a.closable){let y=document.createElement("span");y.className="juice-toast-close",y.innerHTML="\xd7",y.onclick=()=>{n.remove(),this._next()},n.appendChild(y)}let _=this._getRoot(a.position),j=this._defaults.maxVisible;j&&_.children.length>=j&&_.firstChild.remove(),_.appendChild(n),this._runPlugins({toast:n,cfg:a,type:e,root:_}),requestAnimationFrame(()=>n.classList.add("show"));let w=a.duration??2500;if(0===w)return;let k=Date.now(),v=a.duration??this._defaults.duration,C,E=()=>{if(n.__paused)k=Date.now();else{let e=Date.now();v-=e-k,k=e}v<=0?(n.classList.remove("show"),setTimeout(()=>{n.remove(),this._next()},300)):C=requestAnimationFrame(E),c&&(c.style.transform=`scaleX(${Math.max(0,v/w)})`)};n.addEventListener("mouseenter",()=>n.__paused=!0),n.addEventListener("mouseleave",()=>n.__paused=!1),n.addEventListener("touchstart",()=>n.__paused=!0),n.addEventListener("touchend",()=>n.__paused=!1),requestAnimationFrame(E)}};export default juiceToast;export{juiceToast};
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenDN Foundation (C) 2026
|
|
3
|
+
* Source Of Juice Toast v1.3.1 (NEW: For iOS user)
|
|
4
|
+
* Read CONTRIBUTE.md To Contribute
|
|
5
|
+
*/
|
|
6
|
+
let isBrowser="undefined"!=typeof window&&"undefined"!=typeof document,reduceMotion=isBrowser&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,isTouch=isBrowser&&("ontouchstart"in window||navigator&&navigator.maxTouchPoints>0),isIOS=isBrowser&&/iPad|iPhone|iPod/.test(navigator.userAgent||""),isIOSStandalone=isBrowser&&(!0===window.navigator.standalone||window.matchMedia&&window.matchMedia("(display-mode: standalone)").matches),TYPE_ANIMATION={success:"bounce",error:"shake",warning:"wiggle",info:"pulse",loading:"spin"},__cssInjected=!1,BASE_CSS=`
|
|
7
|
+
:root {
|
|
8
|
+
--jt-safe-top: env(safe-area-inset-top, 0px);
|
|
9
|
+
--jt-safe-bottom: env(safe-area-inset-bottom, 0px);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
#juice-toast-root {
|
|
13
|
+
position: fixed;
|
|
14
|
+
z-index: 9999;
|
|
15
|
+
display: flex;
|
|
16
|
+
gap: 10px;
|
|
17
|
+
pointer-events: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* bottom (default) */
|
|
21
|
+
#juice-toast-root[data-position="bottom"] {
|
|
22
|
+
bottom: 20px;
|
|
23
|
+
left: 50%;
|
|
24
|
+
transform: translateX(-50%);
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
align-items: center;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* top */
|
|
30
|
+
#juice-toast-root[data-position="top"] {
|
|
31
|
+
top: 20px;
|
|
32
|
+
left: 50%;
|
|
33
|
+
transform: translateX(-50%);
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
align-items: center;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* center */
|
|
39
|
+
#juice-toast-root[data-position="center"] {
|
|
40
|
+
top: 50%;
|
|
41
|
+
left: 50%;
|
|
42
|
+
transform: translate(-50%, -50%);
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
align-items: center;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[id^="juice-toast-root-"] {
|
|
48
|
+
position: fixed;
|
|
49
|
+
z-index: 9999;
|
|
50
|
+
display: flex;
|
|
51
|
+
gap: 10px;
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
padding-top: var(--jt-safe-top);
|
|
54
|
+
padding-bottom: var(--jt-safe-bottom);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
/* ================= TOAST ================= */
|
|
59
|
+
|
|
60
|
+
.juice-toast {
|
|
61
|
+
--jt-x: 0px;
|
|
62
|
+
--jt-y: 12px;
|
|
63
|
+
|
|
64
|
+
pointer-events: auto;
|
|
65
|
+
display: flex;
|
|
66
|
+
gap: 12px;
|
|
67
|
+
align-items: flex-start;
|
|
68
|
+
|
|
69
|
+
min-width: 220px;
|
|
70
|
+
max-width: 420px;
|
|
71
|
+
padding: 12px 16px;
|
|
72
|
+
margin: 6px 0;
|
|
73
|
+
|
|
74
|
+
border-radius: 8px;
|
|
75
|
+
background: #333;
|
|
76
|
+
color: #fff;
|
|
77
|
+
|
|
78
|
+
font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial;
|
|
79
|
+
font-size: 14px;
|
|
80
|
+
|
|
81
|
+
opacity: 0;
|
|
82
|
+
transform: translate(var(--jt-x), var(--jt-y));
|
|
83
|
+
transition:
|
|
84
|
+
opacity .25s ease,
|
|
85
|
+
transform .25s ease,
|
|
86
|
+
background .25s ease,
|
|
87
|
+
color .25s ease,
|
|
88
|
+
box-shadow .25s ease;
|
|
89
|
+
|
|
90
|
+
position: relative;
|
|
91
|
+
box-sizing: border-box;
|
|
92
|
+
overflow: hidden;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* visible */
|
|
96
|
+
.juice-toast.show {
|
|
97
|
+
opacity: 1;
|
|
98
|
+
--jt-y: 0px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* ================= ICON ================= */
|
|
102
|
+
|
|
103
|
+
.juice-toast .icon {
|
|
104
|
+
width: 28px;
|
|
105
|
+
height: 28px;
|
|
106
|
+
display: inline-flex;
|
|
107
|
+
align-items: center;
|
|
108
|
+
justify-content: center;
|
|
109
|
+
font-size: 16px;
|
|
110
|
+
line-height: 1;
|
|
111
|
+
flex: 0 0 28px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* clickable icon */
|
|
115
|
+
.icon-clickable {
|
|
116
|
+
opacity: 0.85;
|
|
117
|
+
cursor: pointer;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.icon-clickable:hover {
|
|
121
|
+
opacity: 1;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* ================= CONTENT ================= */
|
|
125
|
+
|
|
126
|
+
.juice-toast .jt-content {
|
|
127
|
+
display: flex;
|
|
128
|
+
flex-direction: column;
|
|
129
|
+
gap: 4px;
|
|
130
|
+
flex: 1 1 auto;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* title */
|
|
134
|
+
.juice-toast .jt-title {
|
|
135
|
+
font-weight: 700;
|
|
136
|
+
font-size: 13px;
|
|
137
|
+
line-height: 1.1;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* message */
|
|
141
|
+
.juice-toast .jt-message {
|
|
142
|
+
font-size: 13px;
|
|
143
|
+
line-height: 1.3;
|
|
144
|
+
opacity: 0.95;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* ================= ICON POSITION ================= */
|
|
148
|
+
|
|
149
|
+
.jt-icon-top {
|
|
150
|
+
flex-direction: column;
|
|
151
|
+
align-items: flex-start;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.jt-icon-top .icon {
|
|
155
|
+
align-self: center;
|
|
156
|
+
margin-bottom: 6px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* ================= CLOSE ================= */
|
|
160
|
+
|
|
161
|
+
.juice-toast-close {
|
|
162
|
+
position: absolute;
|
|
163
|
+
top: 6px;
|
|
164
|
+
right: 8px;
|
|
165
|
+
cursor: pointer;
|
|
166
|
+
font-size: 16px;
|
|
167
|
+
opacity: 0.75;
|
|
168
|
+
padding: 4px;
|
|
169
|
+
border-radius: 4px;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.juice-toast-close:hover {
|
|
173
|
+
opacity: 1;
|
|
174
|
+
background: rgba(255,255,255,0.06);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/* ================= ACTIONS ================= */
|
|
178
|
+
|
|
179
|
+
.jt-actions {
|
|
180
|
+
display: flex;
|
|
181
|
+
gap: 8px;
|
|
182
|
+
margin-top: 10px;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.jt-action {
|
|
186
|
+
background: transparent;
|
|
187
|
+
border: 1px solid currentColor;
|
|
188
|
+
padding: 4px 10px;
|
|
189
|
+
border-radius: 6px;
|
|
190
|
+
cursor: pointer;
|
|
191
|
+
font-size: 12px;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* ================= COMPACT ================= */
|
|
195
|
+
|
|
196
|
+
.jt-compact {
|
|
197
|
+
padding: 8px 10px;
|
|
198
|
+
gap: 8px;
|
|
199
|
+
font-size: 0.9em;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/* ================= GLASS UI ================= */
|
|
203
|
+
|
|
204
|
+
.jt-glass {
|
|
205
|
+
--g: calc(var(--jt-glass, 60) / 100);
|
|
206
|
+
|
|
207
|
+
background: rgba(30, 30, 30, calc(0.2 + var(--g)));
|
|
208
|
+
backdrop-filter: blur(calc(6px + (14px * var(--g))))
|
|
209
|
+
saturate(calc(1 + (0.4 * var(--g))));
|
|
210
|
+
-webkit-backdrop-filter: blur(calc(6px + (14px * var(--g))))
|
|
211
|
+
saturate(calc(1 + (0.4 * var(--g))));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/* light theme support */
|
|
215
|
+
[data-theme="light"] .jt-glass {
|
|
216
|
+
background:
|
|
217
|
+
linear-gradient(
|
|
218
|
+
rgba(255,255,255, calc(0.6 * var(--g))),
|
|
219
|
+
rgba(255,255,255, calc(0.35 * var(--g)))
|
|
220
|
+
),
|
|
221
|
+
rgba(255,255,255, calc(0.55 - (0.25 * var(--g))));
|
|
222
|
+
|
|
223
|
+
color: #111;
|
|
224
|
+
|
|
225
|
+
border:
|
|
226
|
+
1px solid rgba(0,0,0, calc(0.05 + 0.12 * var(--g)));
|
|
227
|
+
|
|
228
|
+
box-shadow:
|
|
229
|
+
0 10px 30px rgba(0,0,0, calc(0.08 + 0.18 * var(--g))),
|
|
230
|
+
inset 0 1px 0 rgba(255,255,255, calc(0.4 * var(--g)));
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* ================= PROGRESS BAR ================= */
|
|
234
|
+
.jt-progress {
|
|
235
|
+
position: absolute;
|
|
236
|
+
left: 0;
|
|
237
|
+
bottom: 0;
|
|
238
|
+
|
|
239
|
+
height: 3px;
|
|
240
|
+
width: 100%;
|
|
241
|
+
|
|
242
|
+
background: rgba(255,255,255,.7);
|
|
243
|
+
transform-origin: left;
|
|
244
|
+
transform: scaleX(1);
|
|
245
|
+
opacity: .85;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* ================= ANIMATIONS ================= */
|
|
249
|
+
|
|
250
|
+
@keyframes jt-spin {
|
|
251
|
+
to { transform: rotate(360deg); }
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
@keyframes jt-pulse {
|
|
255
|
+
50% { transform: scale(1.15); }
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
@keyframes jt-shake {
|
|
259
|
+
25% { transform: translateX(-3px); }
|
|
260
|
+
50% { transform: translateX(3px); }
|
|
261
|
+
75% { transform: translateX(-3px); }
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
@keyframes jt-bounce {
|
|
265
|
+
0% { transform: scale(1); }
|
|
266
|
+
30% { transform: scale(1.25); }
|
|
267
|
+
60% { transform: scale(.95); }
|
|
268
|
+
100% { transform: scale(1); }
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
@keyframes jt-wiggle {
|
|
272
|
+
0% { transform: rotate(0); }
|
|
273
|
+
25% { transform: rotate(-10deg); }
|
|
274
|
+
50% { transform: rotate(10deg); }
|
|
275
|
+
75% { transform: rotate(-6deg); }
|
|
276
|
+
100% { transform: rotate(0); }
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
@keyframes jt-pop {
|
|
280
|
+
0% { transform: scale(.7); opacity: 0; }
|
|
281
|
+
70% { transform: scale(1.05); opacity: 1; }
|
|
282
|
+
100% { transform: scale(1); }
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/* ================= CLASSES ================= */
|
|
286
|
+
|
|
287
|
+
.spin { animation: jt-spin .6s linear; }
|
|
288
|
+
.pulse { animation: jt-pulse .4s ease; }
|
|
289
|
+
.shake { animation: jt-shake .4s ease; }
|
|
290
|
+
.bounce { animation: jt-bounce .45s ease; }
|
|
291
|
+
.wiggle { animation: jt-wiggle .5s ease; }
|
|
292
|
+
.pop { animation: jt-pop .35s ease-out; }
|
|
293
|
+
|
|
294
|
+
.icon-clickable {
|
|
295
|
+
cursor: pointer;
|
|
296
|
+
transition: transform .15s ease, opacity .15s ease;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.icon-clickable:hover {
|
|
300
|
+
transform: scale(1.1);
|
|
301
|
+
opacity: .85;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/* ================= ACCESSIBILITY ================= */
|
|
305
|
+
|
|
306
|
+
@media (prefers-reduced-motion: reduce) {
|
|
307
|
+
.spin,
|
|
308
|
+
.pulse,
|
|
309
|
+
.shake,
|
|
310
|
+
.bounce,
|
|
311
|
+
.wiggle,
|
|
312
|
+
.pop {
|
|
313
|
+
animation: none !important;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
`;function injectCSS(e){if(!isBrowser||__cssInjected)return;let t=document.createElement("style");t.id="juice-toast-style",t.textContent=e,document.head.appendChild(t),__cssInjected=!0}let themes={light:{bg:"#ffffff",color:"#111",border:"1px solid #e5e7eb"},dark:{bg:"#1f2937",color:"#fff",border:"1px solid rgba(255,255,255,.08)"}},sizePreset={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},juiceToast={_config:{},_queue:[],_showing:!1,_theme:"dark",_plugins:[],setup(e={}){this._config=e,this._defaults={...this._defaults,...e},isIOS&&(this._defaults.swipeThreshold=Math.min(this._defaults.swipeThreshold||60,50),this._defaults.glassUI=this._defaults.glassUI||60,this._defaults.duration=this._defaults.duration??2200),this._registerTypes()},use(e){"function"==typeof e&&this._plugins.push(e)},addType(e,t={}){this._config[e]=t,this._registerTypes()},defineTheme(e,t={}){themes[e]={...themes[e]||{},...t}},setTheme(e){if(this._theme=e,!isBrowser)return;let t=document.querySelector('[id^="juice-toast-root-"]');t&&(t.dataset.theme=e)},clear(){this._queue.length=0},destroy(){if(this.clear(),!isBrowser)return;let e=document.querySelectorAll('[id^="juice-toast-root-"]');e.forEach(e=>e.remove())},_registerTypes(){Object.keys(this._config).forEach(e=>{if("function"==typeof this[e]&&!this[e].__auto)return;let t=t=>this._enqueue(e,t);t.__auto=!0,this[e]=t})},_enqueue(e,t){this._queue.push({type:e,payload:t}),this._showing||this._next()},_next(){if(!this._queue.length){this._showing=!1;return}this._showing=!0;let e=this._queue.shift();this._showToast(e.type,e.payload)},_runPlugins(e){this._plugins.forEach(t=>{try{t(e)}catch(s){this._warn("Plugin error: "+(s&&s.message?s.message:String(s)))}})},_normalizeGlass(e){if(!0===e)return 60;if(!1===e||null==e)return 0;let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(100,t)):0},_getRoot(e="bottom-right"){if(!isBrowser)return null;let t=document.getElementById(`juice-toast-root-${e}`);if(!t){switch((t=document.createElement("div")).id=`juice-toast-root-${e}`,t.dataset.position=e,t.dataset.theme=this._theme,t.style.position="fixed",t.style.zIndex=9999,t.style.display="flex",t.style.flexDirection="column",t.style.gap="8px",t.style.pointerEvents="none",e){case"top-left":t.style.top="calc(20px + env(safe-area-inset-top))",t.style.left="20px",t.style.alignItems="flex-start";break;case"top-right":t.style.top="calc(20px + env(safe-area-inset-top))",t.style.right="20px",t.style.alignItems="flex-end";break;case"bottom-left":t.style.bottom="calc(20px + env(safe-area-inset-bottom))",t.style.left="20px",t.style.alignItems="flex-start";break;case"bottom-right":t.style.bottom="calc(20px + env(safe-area-inset-bottom))",t.style.right="20px",t.style.alignItems="flex-end";break;case"top-center":t.style.top="calc(20px + env(safe-area-inset-top))",t.style.left="50%",t.style.transform="translateX(-50%)",t.style.alignItems="center";break;case"bottom-center":t.style.bottom="calc(20px + env(safe-area-inset-bottom))",t.style.left="50%",t.style.transform="translateX(-50%)",t.style.alignItems="center";break;default:t.style.bottom="calc(20px + env(safe-area-inset-bottom))",t.style.right="20px"}document.body.appendChild(t)}return t},_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,playSound:null,dev:!1,injectCSS:!0,css:null},_warn(e){this._defaults.dev&&"undefined"!=typeof console&&console.warn("[JuiceToast]",e)},_playSound(e){if(!isBrowser)return;let t="string"==typeof e&&e?e:this._defaults.playSound;if(t)try{let s=new Audio(t);s.volume=.6;let a=()=>{s.play().catch(()=>{}),window.removeEventListener("touchstart",a),window.removeEventListener("click",a)};s.play().catch(()=>{window.addEventListener("touchstart",a,{once:!0}),window.addEventListener("click",a,{once:!0})})}catch(i){}},_showToast(e,t){if(!isBrowser)return;!1!==this._defaults.injectCSS&&injectCSS(this._defaults.css||BASE_CSS);let s=this._config[e]||{},a="object"==typeof t?t:{message:String(t)},i={...s,...a};i.icon=i.icon??i.icon_left_top,i.iconPack=i.iconPack??i.icon_config,i.iconLink=i.iconLink??i.icon_onClick_url,i.iconAnimate=i.iconAnimate??i.icon_onClick_animate,i.position=i.position??i.toast,i.closable=i.closable??i.closeable,i.iconPosition=i.iconPosition||"left",i.compact=!!i.compact;let o=themes[i.theme||this._theme]||{},n=document.createElement("div");n.className="juice-toast";let r=i.animation||"slide-in";if(i.enterAnimation||(n.style.animation=`${r} 0.4s ease forwards`),n.setAttribute("role","alert"),n.setAttribute("aria-live","polite"),n.tabIndex=0,i.size&&sizePreset[i.size]){let l=sizePreset[i.size];l.width&&(n.style.width=l.width),l.padding&&(n.style.padding=l.padding)}let c=null,d=i.duration??this._defaults.duration;i.progress&&d>0&&((c=document.createElement("div")).className="jt-progress",i.progressColor&&(c.style.background=i.progressColor||"rgba(255,255,255,.7)"),n.appendChild(c));let p=this._normalizeGlass(i.glassUI??this._defaults.glassUI);p>0&&(n.classList.add("jt-glass"),n.style.setProperty("--jt-glass",p)),p||(n.style.background=i.bg||o.bg),n.style.color=i.color||o.color,n.style.border=i.border||o.border,i.compact&&n.classList.add("jt-compact"),(i.glassUI??this._defaults.glassUI)&&n.classList.add("jt-glass"),i.width&&(n.style.width=i.width),i.height&&(n.style.height=i.height);let u=null;if(i.icon){(u=document.createElement("i")).className=["icon",i.iconPack||"",i.icon].join(" ").trim(),i.iconSize&&(u.style.fontSize=i.iconSize),(i.iconLink||i.iconAnimate)&&(u.classList.add("icon-clickable"),u.onclick=e=>{e.stopPropagation(),i.iconAnimate&&(u.classList.remove(i.iconAnimate),u.offsetWidth,u.classList.add(i.iconAnimate)),i.iconLink&&window.open(i.iconLink,"_blank","noopener")});let m=i.iconAnimate??TYPE_ANIMATION[e];m&&(u.classList.add(m),u.addEventListener("click",()=>{u.classList.remove(m),u.offsetWidth,u.classList.add(m)}))}reduceMotion&&(n.classList.remove("pop","bounce","shake","wiggle","pulse","spin"),u?.classList.remove("bounce","shake","wiggle","pulse","spin")),i.message||i.title||this._warn("Toast created without message or title"),i.icon&&!i.iconPack&&this._warn("icon provided without iconPack"),i.duration<0&&this._warn("duration cannot be negative");let h=0,f=0,$=!1,g=e=>{let t=e.touches?e.touches[0]:e;h=t.clientX,f=0,$=!0,n.__paused=!0},x=e=>{if(!$)return;let t=e.touches?e.touches[0]:e;f=t.clientX-h,n.style.transform=`translate3d(${f}px, 0, 0)`},y=()=>{$&&($=!1,Math.abs(f)>(this._defaults.swipeThreshold||60)?(n.style.transition="transform .25s ease, opacity .2s ease",n.style.transform=`translate3d(${f>0?1e3:-1e3}px, 0, 0)`,setTimeout(()=>{n.remove(),this._next()},220)):(n.style.transition="transform .2s ease",n.style.transform=""),setTimeout(()=>{n.__paused=!1},60),h=f=0)};isTouch?(n.addEventListener("touchstart",g,{passive:!0}),n.addEventListener("touchmove",x,{passive:!0}),n.addEventListener("touchend",y),n.addEventListener("touchcancel",y)):n.addEventListener("mousedown",e=>{h=e.clientX,f=0,$=!0,n.__paused=!0;let t=e=>{f=e.clientX-h,n.style.transform=`translate3d(${f}px, 0, 0)`},s=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",s),y()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",s)});let b=document.createElement("div");b.className="jt-content";let v=i.enterAnimation??"pop";if(v&&!reduceMotion&&n.classList.add(v),i.title){let _=document.createElement("div");_.className="jt-title",_.textContent=i.title,b.appendChild(_)}let j=document.createElement("div");if(j.className="jt-message",j.textContent=i.message||"",b.appendChild(j),u&&"top"===i.iconPosition?(n.classList.add("jt-icon-top"),n.appendChild(u),n.appendChild(b)):u&&"right"===i.iconPosition?(n.appendChild(b),n.appendChild(u)):(u&&n.appendChild(u),n.appendChild(b)),Array.isArray(i.actions)&&i.actions.length){let w=document.createElement("div");w.className="jt-actions",i.actions.forEach(e=>{let t=document.createElement("button");t.className="jt-action",t.textContent=e.label,t.onclick=t=>{t.stopPropagation(),e.onClick?.(t),e.closeOnClick&&(n.remove(),this._next())},w.appendChild(t)}),b.appendChild(w)}if(i.closable){let k=document.createElement("span");k.className="juice-toast-close",k.innerHTML="\xd7",k.onclick=()=>{n.remove(),this._next()},n.appendChild(k)}isIOSStandalone&&(n.style.borderRadius=n.style.borderRadius||"14px");let S=this._getRoot(i.position),E=this._defaults.maxVisible;if(E&&S.children.length>=E&&S.firstChild.remove(),S.appendChild(n),this._runPlugins({toast:n,cfg:i,type:e,root:S}),requestAnimationFrame(()=>{n.classList.add("show")}),0===d)return;let C=Date.now(),L=d,I,T=()=>{if(n.__paused)C=Date.now();else{let e=Date.now();L-=e-C,C=e}if(L<=0?(n.classList.remove("show"),setTimeout(()=>{n.remove(),this._next()},300)):I=requestAnimationFrame(T),c){let t=Math.max(0,Math.min(1,L/d));c.style.transform=`scaleX(${t})`}};isTouch||(n.addEventListener("mouseenter",()=>n.__paused=!0),n.addEventListener("mouseleave",()=>n.__paused=!1)),n.addEventListener("touchstart",()=>{n.__paused=!0},{passive:!0}),n.addEventListener("touchend",()=>{n.__paused=!1}),C=Date.now(),I=requestAnimationFrame(T),(i.playSound||this._defaults.playSound)&&this._playSound(i.playSound)}};export default juiceToast;export{juiceToast};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "juice-toast",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Lightweight, dependency-free toast notification library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"toast",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"funding": "https://patreon.com/Khairy47",
|
|
25
25
|
"engines": {
|
|
26
|
-
"node": ">=
|
|
26
|
+
"node": ">=18"
|
|
27
27
|
},
|
|
28
28
|
"module": "dist/juice-toast.esm.js",
|
|
29
29
|
"types": "dist/juice-toast.d.ts",
|
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
".": {
|
|
32
32
|
"import": "./dist/juice-toast.esm.js",
|
|
33
33
|
"types": "./dist/juice-toast.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./ios": {
|
|
36
|
+
"import": "./dist/juice-toast.ios.js",
|
|
37
|
+
"types": "./dist/juice-toast-ios.d.ts"
|
|
34
38
|
}
|
|
35
39
|
},
|
|
36
40
|
"files": [
|
package/NEW_FUNCTION.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# Juice Toast Release Candidate 2026 for v1.2.0/v1.2.1
|
|
2
|
-
|
|
3
|
-
```js
|
|
4
|
-
animation: "slide-in" | "fade-in" | "bounce-in";
|
|
5
|
-
glassUI: true | false | number
|
|
6
|
-
playSound: "soundName.mp3" // You can play `.wav`, `.aiff/.aif`, `.ogg`, `.wma`, `.opus`, etc.
|
|
7
|
-
swipeThreshold: number; // default 60
|
|
8
|
-
pauseOnHover: true; // implicit via mouseenter
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
# Juice Toast Release v1.3.0
|
|
12
|
-
```js
|
|
13
|
-
animation: "slide-in" | "fade-in" | "bounce-in"; // legacy / css animation
|
|
14
|
-
enterAnimation: "pop" | "bounce" | "shake" | "wiggle" | "pulse" | "spin"; // class-based
|
|
15
|
-
progress: true;
|
|
16
|
-
progressColor: "rgba(255,255,255,.7)";
|
|
17
|
-
juiceToast.use(ctx => {
|
|
18
|
-
// ctx.toast
|
|
19
|
-
// ctx.cfg
|
|
20
|
-
// ctx.type
|
|
21
|
-
// ctx.root
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// Global Setup
|
|
25
|
-
juiceToast.setup({
|
|
26
|
-
duration: 2500,
|
|
27
|
-
maxVisible: 3,
|
|
28
|
-
playSound: "ding.mp3",
|
|
29
|
-
glassUI: 40,
|
|
30
|
-
injectCSS: true,
|
|
31
|
-
css: "custom css",
|
|
32
|
-
dev: true
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
```A11Y
|
|
38
|
-
role="alert"
|
|
39
|
-
aria-live="polite"
|
|
40
|
-
prefers-reduced-motion supported
|
|
41
|
-
```
|