juice-toast 1.3.2 → 1.3.4

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/API.md CHANGED
@@ -251,10 +251,10 @@ juiceToast.custom("Hello World");
251
251
  ## Background image
252
252
  ```js
253
253
  juiceToast.setup({
254
- bgImage: { "bgImage": "https://cdn.kyrt.my.id/image/ts-logo-128.svg" }
254
+ image: { bgImage: "https://cdn.kyrt.my.id/image/ts-logo-128.svg" }
255
255
  });
256
256
 
257
- juiceToast.bgImage("Hi");
257
+ juiceToast.image("Hi");
258
258
  ```
259
259
 
260
260
  ---
package/CHANGELOG.md CHANGED
@@ -1,8 +1,16 @@
1
- ## v1.3.2
1
+ ## v1.3.4
2
+ - Bug Fixes
3
+ - Add profile image
4
+ - Add Hook's Plugins
5
+
6
+ v1.3.3
7
+ - Bug Fixes on Closeable Toast & Logic
8
+
9
+ v1.3.2
2
10
  - Improved A11Y
3
- - Adding **Background Image**
11
+ - Adding Background Image
4
12
  - Adding more Theme
5
- - Adding default toast (juiceToast.success|error|info|warning|loading)
13
+ - Adding default toast (juiceToast.success|error|info|warning)
6
14
 
7
15
  v1.3.1
8
16
  - Improved iOS / Safari (WebKit) compatibility
@@ -36,6 +44,7 @@ NEXT 120/2026
36
44
  - Add Promise-based Toast API
37
45
  - Add Stack Grouping
38
46
  - Improve TypeScript Definitions
47
+ - !Remove UMD due to maintance reason!
39
48
 
40
49
  v1.1.0
41
50
  - Add Size Preset
package/EoL.md CHANGED
@@ -4,6 +4,9 @@ The following versions and distributions have reached End of Life (EoL) and are
4
4
 
5
5
  | EoL Version | Affected Target | Reason |
6
6
  |--------------------|-----------------|--------|
7
+ | 1.2.1 | None | This version is End of Support, update to ^1.3.0 |
7
8
  | 1.2.0-rc.2026 | UMD build | UMD distribution has been removed to simplify maintenance and reduce build complexity |
9
+ | 0.0.1-next.1202026 | None | This next version are ended, use Release Candidate version |
8
10
  | 0.0.0-next.1202026 | Pre-release tag | Versioning structure became inconsistent and difficult to maintain |
9
- | 1.0.0 | Stable release | Deprecated due to outdated internal architecture and styling standards |
11
+ | 1.1.0 | None | This version is End of Support, update to ^1.2.0 |
12
+ | 1.0.0 | Unstable release | Deprecated due to outdated internal architecture and styling standards |
@@ -1,160 +1,34 @@
1
- /* JuiceToast v1.3.2 (iOS User)
2
- * (C) 2026 OpenDN Foundation
3
- * Type Definitions
4
- */
5
-
6
- /* ================= CORE ================= */
7
-
8
- export type ToastPosition =
9
- | "top-left"
10
- | "top-right"
11
- | "bottom-left"
12
- | "bottom-right"
13
- | "top-center"
14
- | "bottom-center"
15
- | string;
16
-
17
- export type ToastSize = "sm" | "md" | "lg";
18
-
19
- export type ToastAnimation =
20
- | "spin"
21
- | "pulse"
22
- | "shake"
23
- | "bounce"
24
- | "wiggle"
25
- | "pop"
26
- | string;
27
-
28
- /* ================= ACTIONS ================= */
29
-
30
- export interface ToastAction {
31
- label: string;
32
- onClick?: (ev: MouseEvent) => void;
33
- closeOnClick?: boolean;
34
- }
35
-
36
- /* ================= OPTIONS ================= */
37
-
38
- export interface ToastOptions {
39
- title?: string;
40
- message?: string;
41
-
42
- theme?: string;
43
- position?: ToastPosition;
44
-
45
- duration?: number;
46
- progress?: boolean;
47
- progressColor?: string;
48
-
49
- icon?: string;
50
- iconPack?: string;
51
- iconSize?: string;
52
- iconPosition?: "left" | "right" | "top";
53
-
54
- iconLink?: string;
55
- iconAnimate?: ToastAnimation;
56
-
57
- closable?: boolean;
58
-
59
- bg?: string;
60
- color?: string;
61
- border?: string;
62
-
63
- width?: string;
64
- height?: string;
65
-
66
- size?: ToastSize;
67
- compact?: boolean;
68
-
69
- glassUI?: number | boolean;
70
-
71
- bgImage?: string;
72
-
73
- enterAnimation?: ToastAnimation;
74
- animation?: string;
75
-
76
- actions?: ToastAction[];
77
-
78
- /* AUDIO */
79
- playSound?: string;
80
-
81
- /* TTS */
82
- tts?: boolean;
83
- ttsLang?: string;
84
- ttsRate?: number;
85
- }
86
-
87
- /* ================= INTERNAL DEFAULTS ================= */
88
-
89
- export interface JuiceToastDefaults {
90
- duration: number;
91
- maxVisible: number;
92
- swipeThreshold: number;
93
- glassUI: number;
94
- playSound: string | null;
95
- dev: boolean;
96
- injectCSS: boolean;
97
- css: string | null;
98
- }
99
-
100
- /* ================= PLUGIN ================= */
101
-
102
- export interface JuiceToastPluginContext<T extends string = string> {
103
- toast: HTMLElement;
104
- cfg: ToastOptions;
105
- type: T;
106
- root: HTMLElement;
107
- }
108
-
109
- export type JuiceToastPlugin<T extends string = string> = (
110
- ctx: JuiceToastPluginContext<T>
111
- ) => void;
112
-
113
- /* ================= CONFIG ================= */
114
-
115
- export type ToastTypeConfig = Record<string, Partial<ToastOptions>>;
116
-
117
- /* ================= DYNAMIC METHODS ================= */
118
-
119
- type DynamicToastMethods<T extends string> = {
120
- [K in T]: (payload?: string | ToastOptions) => void;
121
- };
122
-
123
- /* ================= CORE INSTANCE ================= */
124
-
125
- export interface JuiceToastBase<T extends string = string> {
126
- _config: ToastTypeConfig;
127
- _queue: any[];
128
- _showing: boolean;
129
- _theme: string;
130
- _plugins: JuiceToastPlugin<T>[];
131
- _defaults: JuiceToastDefaults;
132
-
133
- /* ===== PUBLIC API ===== */
134
-
135
- setup<C extends ToastTypeConfig>(
136
- config: C
137
- ): JuiceToastBase<keyof C & string> &
138
- DynamicToastMethods<keyof C & string>;
139
-
140
- use(plugin: JuiceToastPlugin<T>): void;
141
-
142
- addType(name: string, cfg?: Partial<ToastOptions>): void;
143
-
144
- defineTheme(name: string, styles: Record<string, string>): void;
145
-
146
- setTheme(name: string): void;
147
-
148
- clear(): void;
149
- destroy(): void;
150
- }
151
-
152
- /* ================= FINAL TYPE ================= */
153
-
154
- export type JuiceToast<T extends string = string> =
155
- JuiceToastBase<T> & DynamicToastMethods<T>;
156
-
157
- declare const juiceToast: JuiceToast;
158
-
159
1
  export default juiceToast;
160
- export { juiceToast };
2
+ export namespace juiceToast {
3
+ let _config: {};
4
+ let _queue: any[];
5
+ let _showing: boolean;
6
+ let _theme: string;
7
+ let _plugins: any[];
8
+ function setup(e?: {}): void;
9
+ function use(e: any): void;
10
+ function addType(e: any, t?: {}): void;
11
+ function defineTheme(e: any, t?: {}): void;
12
+ function setTheme(e: any): void;
13
+ function clear(): void;
14
+ function destroy(): void;
15
+ function _registerTypes(): void;
16
+ function _enqueue(e: any, t: any): void;
17
+ function _next(): void;
18
+ function _runPlugins(e: any): void;
19
+ function _normalizeGlass(e: any): number;
20
+ function _getRoot(e?: string): HTMLElement;
21
+ namespace _defaults {
22
+ let duration: number;
23
+ let maxVisible: number;
24
+ let swipeThreshold: number;
25
+ let glassUI: number;
26
+ let playSound: any;
27
+ let dev: boolean;
28
+ let injectCSS: boolean;
29
+ let css: any;
30
+ }
31
+ function _warn(e: any): void;
32
+ function _playSound(e: any): void;
33
+ function _showToast(e: any, t: any): void;
34
+ }
@@ -1,120 +1,34 @@
1
- /* JuiceToast v1.3.2
2
- * (C) 2026 OpenDN Foundation
3
- * Type Definitions
4
- */
5
- /* ================= CORE TYPES ================= */
6
-
7
- export type ToastPosition =
8
- | "top-left"
9
- | "top-right"
10
- | "bottom-left"
11
- | "bottom-right"
12
- | "top-center"
13
- | "bottom-center";
14
-
15
- export type ToastSize = "sm" | "md" | "lg";
16
-
17
- export interface ToastAction {
18
- label: string;
19
- onClick?: (ev: MouseEvent) => void;
20
- closeOnClick?: boolean;
21
- }
22
-
23
- export interface ToastOptions {
24
- title?: string;
25
- message?: string;
26
-
27
- theme?: string;
28
- position?: ToastPosition;
29
-
30
- duration?: number;
31
- progress?: boolean;
32
- progressColor?: string;
33
-
34
- icon?: string;
35
- iconPack?: string;
36
- iconSize?: string;
37
- iconPosition?: "left" | "right" | "top";
38
-
39
- iconLink?: string;
40
- iconAnimate?: string;
41
-
42
- closable?: boolean;
43
-
44
- bg?: string;
45
- color?: string;
46
- border?: string;
47
-
48
- width?: string;
49
- height?: string;
50
-
51
- size?: ToastSize;
52
- compact?: boolean;
53
-
54
- glassUI?: number | boolean;
55
-
56
- bgImage?: string;
57
-
58
- enterAnimation?: string;
59
- animation?: string;
60
-
61
- actions?: ToastAction[];
62
-
63
- /* TTS */
64
- tts?: boolean;
65
- ttsLang?: string;
66
- ttsRate?: number;
67
- }
68
-
69
- /* ================= CONFIG TYPES ================= */
70
-
71
- export type ToastTypeConfig = Record<string, Partial<ToastOptions>>;
72
-
73
- /* ================= PLUGIN ================= */
74
-
75
- export interface JuiceToastPluginContext<T extends string = string> {
76
- toast: HTMLElement;
77
- cfg: ToastOptions;
78
- type: T;
79
- root: HTMLElement;
80
- }
81
-
82
- export type JuiceToastPlugin<T extends string = string> = (
83
- ctx: JuiceToastPluginContext<T>
84
- ) => void;
85
-
86
- /* ================= MAIN INTERFACE ================= */
87
-
88
- type DynamicToastMethods<T extends string> = {
89
- [K in T]: (payload?: string | ToastOptions) => void;
90
- };
91
-
92
- export interface JuiceToastBase<T extends string = string> {
93
- /* ===== PUBLIC API ===== */
94
-
95
- setup<C extends Record<string, Partial<ToastOptions>>>(
96
- config: C
97
- ): JuiceToastBase<keyof C & string> &
98
- DynamicToastMethods<keyof C & string>;
99
-
100
- use(plugin: JuiceToastPlugin<T>): void;
101
-
102
- addType(name: string, cfg?: Partial<ToastOptions>): void;
103
-
104
- defineTheme(name: string, styles: Record<string, string>): void;
105
-
106
- setTheme(name: string): void;
107
-
108
- clear(): void;
109
- destroy(): void;
110
- }
111
-
112
- /* ================= FINAL TYPE ================= */
113
-
114
- export type JuiceToast<T extends string = string> =
115
- JuiceToastBase<T> & DynamicToastMethods<T>;
116
-
117
- declare const juiceToast: JuiceToast;
118
-
119
1
  export default juiceToast;
120
- export { juiceToast };
2
+ export namespace juiceToast {
3
+ let _config: {};
4
+ let _queue: any[];
5
+ let _showing: boolean;
6
+ let _theme: string;
7
+ let _plugins: any[];
8
+ function setup(e?: {}): void;
9
+ function use(e: any): void;
10
+ function addType(e: any, t?: {}): void;
11
+ function defineTheme(e: any, t?: {}): void;
12
+ function setTheme(e: any): void;
13
+ function clear(): void;
14
+ function destroy(): void;
15
+ function _registerTypes(): void;
16
+ function _enqueue(e: any, t: any): void;
17
+ function _next(): void;
18
+ function _runPlugins(e: any): void;
19
+ function _normalizeGlass(e: any): number;
20
+ function _getRoot(e?: string): HTMLElement;
21
+ namespace _defaults {
22
+ let duration: number;
23
+ let maxVisible: number;
24
+ let swipeThreshold: number;
25
+ let glassUI: number;
26
+ let playSound: any;
27
+ let dev: boolean;
28
+ let injectCSS: boolean;
29
+ let css: any;
30
+ }
31
+ function _warn(e: any): void;
32
+ function _playSound(e: any): void;
33
+ function _showToast(e: any, t: any): void;
34
+ }
@@ -1,6 +1,369 @@
1
1
  /**
2
2
  * 2026 (C) OpenDN Foundation
3
- * v1.3.2 (STABLE)
3
+ * v1.3.4 (Nearing End of Support notifier)
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 transform: translate(var(--jt-x), 0px) scale(1);\n transition: transform 0.35s ease, opacity 0.35s ease;\n}\n\n/* hide */\n.juice-toast.hide {\n opacity: 0;\n transform: translate(var(--jt-x), 12px) scale(0.95);\n}\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: 6px 8px;\n font-size: 0.85em;\n gap: 6px;\n max-width: 280px;\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: linear-gradient(to right, #FFFFFF, #FAFAFA);\n height: 4px;\n transform-origin: left;\n transition: transform linear;\n border-radius: 2px;\n transform: scaleX(1);\n opacity: .85;\n}\n\n/* ================= BACKGROUND IMAGE ================= */\n\n.juice-toast.bg-image {\n background-size: cover;\n background-position: center;\n background-repeat: no-repeat;\n color: #fff;\n text-shadow: 0 1px 2px rgba(0,0,0,0.6);\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 e=document.createElement("style");e.id="juice-toast-style",e.textContent=n,document.head.appendChild(e),__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)"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.15)"},midnight:{bg:"#0f172a",color:"#e5e7eb",border:"1px solid rgba(255,255,255,.06)"},soft:{bg:"#f8fafc",color:"#0f172a",border:"1px solid #e2e8f0"},neutral:{bg:"#ffffff",color:"#374151",border:"1px solid #d1d5db"},brand:{bg:"#6366f1",color:"#fff",border:"none"},gradient:{bg:"linear-gradient(135deg,#6366f1,#ec4899)",color:"#fff",border:"none"},outline:{bg:"transparent",color:"#111",border:"2px solid currentColor"}},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,e={}){this._config[n]=e,this._registerTypes()},defineTheme(n,e={}){themes[n]={...themes[n]||{},...e}},setTheme(n){if(this._theme=n,!isBrowser)return;const e=document.getElementById("juice-toast-root");e&&(e.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 e=e=>this._enqueue(n,e);e.__auto=!0,this[n]=e}))},_enqueue(n,e){this._queue.push({type:n,payload:e}),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((e=>{try{e(n)}catch(n){this._warn("Plugin error: "+n.message)}}))},_normalizeGlass(n){if(!0===n)return 60;if(!1===n||null==n)return 0;const e=Number(n);return Number.isFinite(e)?Math.max(0,Math.min(100,e)):0},_getRoot(n="bottom-right"){if(!isBrowser)return null;let e=document.getElementById(`juice-toast-root-${n}`);if(!e){switch(e=document.createElement("div"),e.id=`juice-toast-root-${n}`,e.dataset.position=n,e.dataset.theme=this._theme,e.style.position="fixed",e.style.zIndex=9999,n){case"top-left":e.style.top="20px",e.style.left="20px";break;case"top-right":e.style.top="20px",e.style.right="20px";break;case"bottom-left":e.style.bottom="20px",e.style.left="20px";break;case"bottom-right":e.style.bottom="20px",e.style.right="20px";break;case"top-center":e.style.top="20px",e.style.left="50%",e.style.transform="translateX(-50%)";break;case"bottom-center":e.style.bottom="20px",e.style.left="50%",e.style.transform="translateX(-50%)"}document.body.appendChild(e)}return e},_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 e="string"==typeof n&&n?n:this._defaults.playSound;if(e)try{const n=new Audio(e);n.volume=.6,n.play().catch((()=>{}))}catch{}},_showToast(n,e){if(!isBrowser)return;!1!==this._defaults.injectCSS&&injectCSS(this._defaults.css||BASE_CSS);const t={...this._config[n]||{},..."object"==typeof e?e:{message:String(e)}};t.icon=t.icon??t.icon_left_top,t.iconPack=t.iconPack??t.icon_config,t.iconLink=t.iconLink??t.icon_onClick_url,t.iconAnimate=t.iconAnimate??t.icon_onClick_animate,t.position=t.position??t.toast,t.closable=t.closable??t.closeable,t.iconPosition=t.iconPosition||"left",t.compact=!!t.compact;const s=themes[t.theme||this._theme]||{},o=document.createElement("div");o.className="juice-toast";const i=t.animation||"slide-in";if(t.enterAnimation||(o.style.animation=`${i} 0.4s ease forwards`),o.setAttribute("role","alert"),o.setAttribute("aria-live","error"===n?"assertive":"polite"),o.setAttribute("aria-atomic","true"),o.tabIndex=0,t.closable&&(close.tabIndex=0,close.addEventListener("keydown",(n=>{"Enter"!==n.key&&" "!==n.key||(o.remove(),this._next())}))),t.size&&sizePreset[t.size]){const n=sizePreset[t.size];n.width&&(o.style.width=n.width),n.padding&&(o.style.padding=n.padding)}let a=null;if(t.progress&&(t.duration??this._defaults.duration)>0&&(a=document.createElement("div"),a.className="jt-progress",t.progressColor&&(a.style.background=t.progressColor||"rgba(255,255,255,.7)"),o.appendChild(a)),t.tts&&"speechSynthesis"in window)try{const n=new SpeechSynthesisUtterance(t.message||t.title||"");n.lang=t.ttsLang||"en-US",n.rate=t.ttsRate??1,window.speechSynthesis.speak(n)}catch(n){this._warn("TTS failed: "+n.message)}const r=this._normalizeGlass(t.glassUI??this._defaults.glassUI);r>0&&(o.style.setProperty("--jt-glass",t.glassUI??50),o.classList.add("jt-glass")),r||(o.style.background=t.bg||s.bg),o.style.color=t.color||s.color,o.style.border=t.border||s.border,t.compact&&o.classList.add("jt-compact"),(t.glassUI??this._defaults.glassUI)&&o.classList.add("jt-glass"),t.width&&(o.style.width=t.width),t.height&&(o.style.height=t.height),t.bgImage&&(o.style.backgroundImage=`url(${t.bgImage})`,o.classList.add("bg-image"));let c=null;if(t.icon){c=document.createElement("i"),c.className=["icon",t.iconPack||"",t.icon].join(" ").trim(),t.iconSize&&(c.style.fontSize=t.iconSize),(t.iconLink||t.iconAnimate)&&(c.classList.add("icon-clickable"),c.onclick=n=>{n.stopPropagation(),t.iconAnimate&&(c.classList.remove(t.iconAnimate),c.offsetWidth,c.classList.add(t.iconAnimate)),t.iconLink&&window.open(t.iconLink,"_blank","noopener")});const e=t.iconAnimate??TYPE_ANIMATION[n];e&&(c.classList.add(e),c.addEventListener("click",(()=>{c.classList.remove(e),c.offsetWidth,c.classList.add(e)})))}reduceMotion&&(o.classList.remove("pop","bounce","shake","wiggle","pulse","spin"),c?.classList.remove("bounce","shake","wiggle","pulse","spin")),t.message||t.title||this._warn("Toast created without message or title"),t.icon&&!t.iconPack&&this._warn("icon provided without iconPack"),t.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=t.enterAnimation??"pop";if(u&&!reduceMotion&&o.classList.add(u),t.title){const n=document.createElement("div");n.className="jt-title",n.textContent=t.title,p.appendChild(n)}const m=document.createElement("div");if(m.className="jt-message",m.textContent=t.message||"",p.appendChild(m),c&&"top"===t.iconPosition?(o.classList.add("jt-icon-top"),o.appendChild(c),o.appendChild(p)):c&&"right"===t.iconPosition?(o.appendChild(p),o.appendChild(c)):(c&&o.appendChild(c),o.appendChild(p)),Array.isArray(t.actions)&&t.actions.length){const n=document.createElement("div");n.className="jt-actions",t.actions.forEach((e=>{const t=document.createElement("button");t.className="jt-action",t.textContent=e.label,t.onclick=n=>{n.stopPropagation(),e.onClick?.(n),e.closeOnClick&&(o.remove(),this._next())},n.appendChild(t)})),p.appendChild(n)}if(t.closable){const n=document.createElement("span");n.className="juice-toast-close",n.innerHTML="×",n.onclick=()=>{o.remove(),this._next()},o.appendChild(n)}const f=this._getRoot(t.position),g=this._defaults.maxVisible;g&&f.children.length>=g&&f.firstChild.remove(),f.appendChild(o),this._runPlugins({toast:o,cfg:t,type:n,root:f}),requestAnimationFrame((()=>o.classList.add("show")));const h=t.duration??2500;if(0===h)return;let b,x=Date.now(),y=t.duration??this._defaults.duration;const _=()=>{if(o.__paused)x=Date.now();else{const n=Date.now();y-=n-x,x=n}y<=0?(o.classList.remove("show"),setTimeout((()=>{o.remove(),this._next()}),300)):b=requestAnimationFrame(_),a&&(a.style.transform=`scaleX(${Math.max(0,y/h)})`)};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(_)}};juiceToast.setup({success:{icon:"fa-check",iconPack:"fas",bg:"#16a34a",progress:!0,duration:3e3},error:{icon:"fa-xmark",iconPack:"fas",bg:"#dc2626",progress:!0,duration:4e3},info:{icon:"fa-circle-info",iconPack:"fas",bg:"#2563eb",progress:!0},warning:{icon:"fa-triangle-exclamation",iconPack:"fas",bg:"#f59e0b",progress:!0},loading:{icon:"fa-spinner",iconPack:"fas",iconAnimate:"spin",duration:0,progress:!1,closable:!1}});export default juiceToast;export{juiceToast};
6
+ console.warn("%cJuiceToast v1.3.x%c — This version is approaching End of Support on Feb 28th 2026. Use %c^v1.4.x (Gold)%c to remove this message.","background: #f59e0b; color: #000; font-weight: bold; padding: 2px 6px; border-radius: 4px;","color: #555; font-weight: normal;","background: #38bdf8; color: #000; font-weight: bold; padding: 2px 4px; border-radius: 3px;","color: #555; font-weight: normal;");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
+ /* top */
16
+ #juice-toast-root[data-position="top"] {
17
+ top: 20px;
18
+ left: 50%;
19
+ transform: translateX(-50%);
20
+ flex-direction: column;
21
+ align-items: center;
22
+ }
23
+
24
+ /* center */
25
+ #juice-toast-root[data-position="center"] {
26
+ top: 50%;
27
+ left: 50%;
28
+ transform: translate(-50%, -50%);
29
+ flex-direction: column;
30
+ align-items: center;
31
+ }
32
+
33
+ [id^="juice-toast-root-"] {
34
+ position: fixed;
35
+ z-index: 9999;
36
+ display: flex;
37
+ gap: 10px;
38
+ pointer-events: none;
39
+ }
40
+
41
+
42
+ /* ================= TOAST ================= */
43
+
44
+ .juice-toast {
45
+ /* animation vars (safe for swipe) */
46
+ --jt-x: 0px;
47
+ --jt-y: 12px;
48
+
49
+ pointer-events: auto;
50
+ display: flex;
51
+ gap: 12px;
52
+ align-items: flex-start;
53
+
54
+ min-width: 220px;
55
+ max-width: 420px;
56
+ padding: 12px 16px;
57
+ margin: 6px 0;
58
+
59
+ border-radius: 8px;
60
+ background: #333;
61
+ color: #fff;
62
+
63
+ font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial;
64
+ font-size: 14px;
65
+
66
+ opacity: 0;
67
+ transform: translate(var(--jt-x), var(--jt-y));
68
+ transition:
69
+ opacity .25s ease,
70
+ transform .25s ease,
71
+ background .25s ease,
72
+ color .25s ease,
73
+ box-shadow .25s ease;
74
+
75
+ position: relative;
76
+ box-sizing: border-box;
77
+ overflow: hidden;
78
+ }
79
+
80
+ /* visible */
81
+ .juice-toast.show {
82
+ opacity: 1;
83
+ transform: translate(var(--jt-x), 0px) scale(1);
84
+ transition: transform 0.35s ease, opacity 0.35s ease;
85
+ }
86
+
87
+ /* hide */
88
+ .juice-toast.hide {
89
+ opacity: 0;
90
+ transform: translate(var(--jt-x), 12px) scale(0.95);
91
+ }
92
+
93
+
94
+ /* ================= ICON ================= */
95
+
96
+ .juice-toast .icon {
97
+ width: 28px;
98
+ height: 28px;
99
+ display: inline-flex;
100
+ align-items: center;
101
+ justify-content: center;
102
+ font-size: 16px;
103
+ line-height: 1;
104
+ flex: 0 0 28px;
105
+ }
106
+
107
+ /* clickable icon */
108
+ .icon-clickable {
109
+ opacity: 0.85;
110
+ cursor: pointer;
111
+ }
112
+
113
+ .icon-clickable:hover {
114
+ opacity: 1;
115
+ }
116
+
117
+ /* ================= CONTENT ================= */
118
+
119
+ .juice-toast .jt-content {
120
+ display: flex;
121
+ flex-direction: column;
122
+ gap: 4px;
123
+ flex: 1 1 auto;
124
+ }
125
+
126
+ /* title */
127
+ .juice-toast .jt-title {
128
+ font-weight: 700;
129
+ font-size: 13px;
130
+ line-height: 1.1;
131
+ }
132
+
133
+ /* message */
134
+ .juice-toast .jt-message {
135
+ font-size: 13px;
136
+ line-height: 1.3;
137
+ opacity: 0.95;
138
+ }
139
+
140
+ /* ================= ICON POSITION ================= */
141
+
142
+ .jt-icon-top {
143
+ flex-direction: column;
144
+ align-items: flex-start;
145
+ }
146
+
147
+ .jt-icon-top .icon {
148
+ align-self: center;
149
+ margin-bottom: 6px;
150
+ }
151
+
152
+ /* ================= CLOSE ================= */
153
+
154
+ .juice-toast-close {
155
+ position: absolute;
156
+ top: 6px;
157
+ right: 8px;
158
+ cursor: pointer;
159
+ font-size: 16px;
160
+ opacity: 0.75;
161
+ padding: 4px;
162
+ border-radius: 4px;
163
+ }
164
+
165
+ .juice-toast-close:hover {
166
+ opacity: 1;
167
+ background: rgba(255,255,255,0.06);
168
+ }
169
+
170
+ /* ================= ACTIONS ================= */
171
+
172
+ .jt-actions {
173
+ display: flex;
174
+ gap: 8px;
175
+ margin-top: 10px;
176
+ }
177
+
178
+ .jt-action {
179
+ background: transparent;
180
+ border: 1px solid currentColor;
181
+ padding: 4px 10px;
182
+ border-radius: 6px;
183
+ cursor: pointer;
184
+ font-size: 12px;
185
+ }
186
+
187
+ .jt-message code {
188
+ background: rgba(255,255,255,0.1);
189
+ color: #facc15; /* kuning */
190
+ padding: 2px 4px;
191
+ border-radius: 4px;
192
+ font-family: monospace;
193
+ font-size: 0.9em;
194
+ }
195
+
196
+ /* ================= COMPACT ================= */
197
+
198
+ .jt-compact {
199
+ padding: 6px 8px;
200
+ font-size: 0.85em;
201
+ gap: 6px;
202
+ max-width: 280px;
203
+ }
204
+
205
+ /* ================= GLASS UI ================= */
206
+
207
+ .jt-glass {
208
+ --g: calc(var(--jt-glass, 60) / 100);
209
+
210
+ background: rgba(30, 30, 30, calc(0.2 + var(--g)));
211
+ backdrop-filter: blur(calc(6px + (14px * var(--g))))
212
+ saturate(calc(1 + (0.4 * var(--g))));
213
+ -webkit-backdrop-filter: blur(calc(6px + (14px * var(--g))))
214
+ saturate(calc(1 + (0.4 * var(--g))));
215
+ }
216
+
217
+ /* light theme support */
218
+ [data-theme="light"] .jt-glass {
219
+ background:
220
+ linear-gradient(
221
+ rgba(255,255,255, calc(0.6 * var(--g))),
222
+ rgba(255,255,255, calc(0.35 * var(--g)))
223
+ ),
224
+ rgba(255,255,255, calc(0.55 - (0.25 * var(--g))));
225
+
226
+ color: #111;
227
+
228
+ border:
229
+ 1px solid rgba(0,0,0, calc(0.05 + 0.12 * var(--g)));
230
+
231
+ box-shadow:
232
+ 0 10px 30px rgba(0,0,0, calc(0.08 + 0.18 * var(--g))),
233
+ inset 0 1px 0 rgba(255,255,255, calc(0.4 * var(--g)));
234
+ }
235
+
236
+ /* ================= PROGRESS BAR ================= */
237
+ .jt-progress {
238
+ position: absolute;
239
+ left: 0;
240
+ bottom: 0;
241
+
242
+ height: 3px;
243
+ width: 100%;
244
+
245
+ background: linear-gradient(to right, #FFFFFF, #FAFAFA);
246
+ height: 4px;
247
+ transform-origin: left;
248
+ transition: transform linear;
249
+ border-radius: 2px;
250
+ transform: scaleX(1);
251
+ opacity: .85;
252
+ }
253
+
254
+ /* ================= BACKGROUND IMAGE ================= */
255
+
256
+ .juice-toast.bg-image {
257
+ background-size: cover;
258
+ background-position: center;
259
+ background-repeat: no-repeat;
260
+ color: #fff;
261
+ text-shadow: 0 1px 2px rgba(0,0,0,0.6);
262
+ }
263
+
264
+ /* ================= ANIMATIONS ================= */
265
+
266
+ @keyframes jt-spin {
267
+ to { transform: rotate(360deg); }
268
+ }
269
+
270
+ @keyframes jt-pulse {
271
+ 50% { transform: scale(1.15); }
272
+ }
273
+
274
+ @keyframes jt-shake {
275
+ 25% { transform: translateX(-3px); }
276
+ 50% { transform: translateX(3px); }
277
+ 75% { transform: translateX(-3px); }
278
+ }
279
+
280
+ @keyframes jt-bounce {
281
+ 0% { transform: scale(1); }
282
+ 30% { transform: scale(1.25); }
283
+ 60% { transform: scale(.95); }
284
+ 100% { transform: scale(1); }
285
+ }
286
+
287
+ @keyframes jt-wiggle {
288
+ 0% { transform: rotate(0); }
289
+ 25% { transform: rotate(-10deg); }
290
+ 50% { transform: rotate(10deg); }
291
+ 75% { transform: rotate(-6deg); }
292
+ 100% { transform: rotate(0); }
293
+ }
294
+
295
+ @keyframes jt-pop {
296
+ 0% { transform: scale(.7); opacity: 0; }
297
+ 70% { transform: scale(1.05); opacity: 1; }
298
+ 100% { transform: scale(1); }
299
+ }
300
+
301
+ @keyframes jt-slide {
302
+ from {
303
+ transform: translateY(20px);
304
+ opacity: 0;
305
+ }
306
+ to {
307
+ transform: translateY(0);
308
+ opacity: 1;
309
+ }
310
+ }
311
+
312
+ /* ================= CLASSES ================= */
313
+
314
+ .spin { animation: jt-spin .6s linear; }
315
+ .pulse { animation: jt-pulse .4s ease; }
316
+ .shake { animation: jt-shake .4s ease; }
317
+ .bounce { animation: jt-bounce .45s ease; }
318
+ .wiggle { animation: jt-wiggle .5s ease; }
319
+ .pop { animation: jt-pop .35s ease-out; }
320
+ .slide-in { animation: jt-slide .55s ease; }
321
+
322
+ /* ================= ICON INTERACTION ================= */
323
+
324
+ .icon-clickable {
325
+ cursor: pointer;
326
+ transition: transform .15s ease, opacity .15s ease;
327
+ }
328
+
329
+ .icon-clickable:hover {
330
+ transform: scale(1.1);
331
+ opacity: .85;
332
+ }
333
+
334
+ /* ================= ACCESSIBILITY ================= */
335
+
336
+ @media (prefers-reduced-motion: reduce) {
337
+ .spin,
338
+ .pulse,
339
+ .shake,
340
+ .bounce,
341
+ .wiggle,
342
+ .pop {
343
+ animation: none !important;
344
+ }
345
+ }
346
+
347
+ .jt-profile {
348
+ width: 40px;
349
+ height: 40px;
350
+ border-radius: 50%;
351
+ object-fit: cover;
352
+ flex-shrink: 0;
353
+ }
354
+
355
+ .jt-profile.square {
356
+ border-radius: 6px;
357
+ object-fit: cover;
358
+ margin-right: auto;
359
+ flex-shrink: 0;
360
+ width: 40px;
361
+ height: 40px;
362
+ }
363
+
364
+ .juice-toast {
365
+ display: flex;
366
+ align-items: center;
367
+ gap: 10px;
368
+ }
369
+ `;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)"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.15)"},midnight:{bg:"#0f172a",color:"#e5e7eb",border:"1px solid rgba(255,255,255,.06)"},soft:{bg:"#f8fafc",color:"#0f172a",border:"1px solid #e2e8f0"},neutral:{bg:"#ffffff",color:"#374151",border:"1px solid #d1d5db"},brand:{bg:"#6366f1",color:"#fff",border:"none"},gradient:{bg:"linear-gradient(135deg,#6366f1,#ec4899)",color:"#fff",border:"none"},outline:{bg:"transparent",color:"#111",border:"2px solid currentColor"}},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={}){let{duration:t,maxVisible:s,...i}=e;this._defaults={...this._defaults,duration:t,maxVisible:s},this._config={...this._config,...i},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","error"===e?"assertive":"polite"),n.setAttribute("aria-atomic","true"),n.tabIndex=0,a.closable){let l=document.createElement("span");l.tabIndex=0,l.className="juice-toast-close",l.textContent="\xd7",l.addEventListener("keydown",e=>{("Enter"===e.key||" "===e.key)&&(n.remove(),this._next())})}let c=null;if(a.profile&&((c=document.createElement("img")).src=a.profile,c.className="jt-profile","square"===a.profileShape&&c.classList.add("square"),n.appendChild(c)),a.size&&sizePreset[a.size]){let d=sizePreset[a.size];d.width&&(n.style.width=d.width),d.padding&&(n.style.padding=d.padding)}let p=null;if(a.progress&&(a.duration??this._defaults.duration)>0&&((p=document.createElement("div")).className="jt-progress",a.progressColor&&(p.style.background=a.progressColor||"rgba(255,255,255,.7)"),n.appendChild(p)),a.tts&&"speechSynthesis"in window)try{let f=new SpeechSynthesisUtterance(a.message||a.title||"");f.lang=a.ttsLang||"en-US",f.rate=a.ttsRate??1,window.speechSynthesis.speak(f)}catch(g){this._warn("TTS failed: "+g.message)}let h=this._normalizeGlass(a.glassUI??this._defaults.glassUI);h>0&&(n.style.setProperty("--jt-glass",a.glassUI??50),n.classList.add("jt-glass")),h||(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.width&&(n.style.width=a.width),a.height&&(n.style.height=a.height),a.bgImage&&(n.style.backgroundImage=`url(${a.bgImage})`,n.classList.add("bg-image"));let u=null;if(a.icon){(u=document.createElement("i")).className=["icon",a.iconPack||"",a.icon].join(" ").trim(),a.iconSize&&(u.style.fontSize=a.iconSize),(a.iconLink||a.iconAnimate)&&(u.classList.add("icon-clickable"),u.onclick=e=>{e.stopPropagation(),a.iconAnimate&&(u.classList.remove(a.iconAnimate),u.offsetWidth,u.classList.add(a.iconAnimate)),a.iconLink&&window.open(a.iconLink,"_blank","noopener")});let m=a.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")),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 $=0,x=0;n.addEventListener("touchstart",e=>{$=e.touches[0].clientX}),n.addEventListener("touchmove",e=>{x=e.touches[0].clientX-$,n.style.transform=`translateX(${x}px)`}),n.addEventListener("touchend",()=>{Math.abs(x)>this._defaults.swipeThreshold?(n.style.transform=`translateX(${x>0?1e3:-1e3}px)`,setTimeout(()=>{n.remove(),this._next()},200)):n.style.transform="",$=x=0});let b=document.createElement("div");b.className="jt-content";let y=a.enterAnimation??"pop";if(y&&!reduceMotion&&n.classList.add(y),a.title){let _=document.createElement("div");_.className="jt-title",_.textContent=a.title,b.appendChild(_)}let j=document.createElement("div");if(j.className="jt-message","string"==typeof a.message){let k=a.message.split(/(`[^`]+`)/g);k.forEach(e=>{if(e.startsWith("`")&&e.endsWith("`")){let t=document.createElement("code");t.textContent=e.slice(1,-1),j.appendChild(t)}else j.appendChild(document.createTextNode(e))})}if(b.appendChild(j),u&&"top"===a.iconPosition?(n.classList.add("jt-icon-top"),n.appendChild(u),n.appendChild(b)):u&&"right"===a.iconPosition?(n.appendChild(b),n.appendChild(u)):(u&&n.appendChild(u),n.appendChild(b)),Array.isArray(a.actions)&&a.actions.length){let w=document.createElement("div");w.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())},w.appendChild(t)}),b.appendChild(w)}if(a.closable){let v=document.createElement("span");v.className="juice-toast-close",v.textContent="\xd7",v.onclick=()=>{n.remove(),this._next()},n.appendChild(v)}let C=this._getRoot(a.position),E=this._defaults.maxVisible;E&&C.children.length>=E&&C.firstChild.remove(),C.appendChild(n),this._runPlugins({toast:n,cfg:a,type:e,root:C}),requestAnimationFrame(()=>n.classList.add("show"));let S=a.duration??this._defaults.duration;if(0===S)return;let I=Date.now(),T=a.duration??this._defaults.duration,A,L=()=>{if(n.__paused)I=Date.now();else{let e=Date.now();T-=e-I,I=e}T<=0?(n.classList.remove("show"),setTimeout(()=>{n.remove(),this._next()},300)):A=requestAnimationFrame(L),p&&(p.style.transform=`scaleX(${Math.max(0,T/S)})`)};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(L)}};juiceToast.setup({success:{icon:"fa-check",iconPack:"fas",bg:"#16a34a",progress:!0,duration:4e3},error:{icon:"fa-xmark",iconPack:"fas",bg:"#dc2626",progress:!0,duration:4e3},info:{icon:"fa-circle-info",iconPack:"fas",bg:"#2563eb",duration:4e3,progress:!0},warning:{icon:"fa-triangle-exclamation",iconPack:"fas",bg:"#f59e0b",duration:4e3,progress:!0}});export default juiceToast;export{juiceToast};
@@ -1,6 +1,355 @@
1
1
  /**
2
2
  * OpenDN Foundation (C) 2026
3
- * Source Of Juice Toast v1.3.1 (iOS user)
3
+ * Juice Toast v1.3.4 (iOS user | Nearing End of Support notifier)
4
4
  * Read CONTRIBUTE.md To Contribute
5
5
  */
6
- const 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);function speakTTS(e,n="en-US",t=1){if(!("speechSynthesis"in window))return;const s=new SpeechSynthesisUtterance(e);s.lang=n,s.rate=t;const o=()=>{window.speechSynthesis.speak(s),document.body.removeEventListener("touchstart",o),document.body.removeEventListener("click",o)};/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream&&!1===window.speechSynthesis.speaking?(document.body.addEventListener("touchstart",o,{once:!0}),document.body.addEventListener("click",o,{once:!0})):o()}const raf=window.requestAnimationFrame||window.webkitRequestAnimationFrame||(e=>setTimeout(e,16)),TYPE_ANIMATION={success:"bounce",error:"shake",warning:"wiggle",info:"pulse",loading:"spin"};let __cssInjected=!1;const BASE_CSS='\n:root {\n --jt-safe-top: env(safe-area-inset-top, 0px);\n --jt-safe-bottom: env(safe-area-inset-bottom, 0px);\n}\n\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 padding-top: var(--jt-safe-top);\n padding-bottom: var(--jt-safe-bottom);\n}\n\n\n/* ================= TOAST ================= */\n\n.juice-toast {\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 scroll-behavior: contains;\n -webkit-overflow-scrolling: touch;\n\n will-change: transform, opacity;\n backface-visibility: hidden;\n -webkit-backface-visibility: hidden;\n\n touch-action: pan-y;\n\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: linear-gradient(to right, #FFFFFF, #FAFAFA);\n height: 4px;\n transform-origin: left;\n transition: transform linear;\n border-radius: 2px;\n transform: scaleX(1);\n opacity: .85;\n}\n\n.juice-toast.bg-image {\n background-size: cover;\n background-position: center;\n background-repeat: no-repeat;\n color: #fff;\n text-shadow: 0 1px 2px rgba(0,0,0,0.6);\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-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(e){if(!isBrowser||__cssInjected)return;const n=document.createElement("style");n.id="juice-toast-style",n.textContent=e,document.head.appendChild(n),__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)"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.15)"},midnight:{bg:"#0f172a",color:"#e5e7eb",border:"1px solid rgba(255,255,255,.06)"},soft:{bg:"#f8fafc",color:"#0f172a",border:"1px solid #e2e8f0"},neutral:{bg:"#ffffff",color:"#374151",border:"1px solid #d1d5db"},brand:{bg:"#6366f1",color:"#fff",border:"none"},gradient:{bg:"linear-gradient(135deg,#6366f1,#ec4899)",color:"#fff",border:"none"},outline:{bg:"transparent",color:"#111",border:"2px solid currentColor"}},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,n={}){this._config[e]=n,this._registerTypes()},defineTheme(e,n={}){themes[e]={...themes[e]||{},...n}},setTheme(e){if(this._theme=e,!isBrowser)return;const n=document.querySelector('[id^="juice-toast-root-"]');n&&(n.dataset.theme=e)},clear(){this._queue.length=0},destroy(){if(this.clear(),!isBrowser)return;document.querySelectorAll('[id^="juice-toast-root-"]').forEach((e=>e.remove()))},_registerTypes(){Object.keys(this._config).forEach((e=>{if("function"==typeof this[e]&&!this[e].__auto)return;const n=n=>this._enqueue(e,n);n.__auto=!0,this[e]=n}))},_enqueue(e,n){this._queue.push({type:e,payload:n}),this._showing||this._next()},_next(){if(!this._queue.length)return void(this._showing=!1);this._showing=!0;const e=this._queue.shift();this._showToast(e.type,e.payload)},_runPlugins(e){this._plugins.forEach((n=>{try{n(e)}catch(e){this._warn("Plugin error: "+(e&&e.message?e.message:String(e)))}}))},_normalizeGlass(e){if(!0===e)return 60;if(!1===e||null==e)return 0;const n=Number(e);return Number.isFinite(n)?Math.max(0,Math.min(100,n)):0},_getRoot(e="bottom-right"){if(!isBrowser)return null;let n=document.getElementById(`juice-toast-root-${e}`);if(!n){switch(n=document.createElement("div"),n.id=`juice-toast-root-${e}`,n.dataset.position=e,n.dataset.theme=this._theme,n.style.position="fixed",n.style.zIndex=9999,n.style.display="flex",n.style.flexDirection="column",n.style.gap="8px",n.style.pointerEvents="none",e){case"top-left":n.style.top="calc(20px + env(safe-area-inset-top))",n.style.left="20px",n.style.alignItems="flex-start";break;case"top-right":n.style.top="calc(20px + env(safe-area-inset-top))",n.style.right="20px",n.style.alignItems="flex-end";break;case"bottom-left":n.style.bottom="calc(20px + env(safe-area-inset-bottom))",n.style.left="20px",n.style.alignItems="flex-start";break;case"bottom-right":n.style.bottom="calc(20px + env(safe-area-inset-bottom))",n.style.right="20px",n.style.alignItems="flex-end";break;case"top-center":n.style.top="calc(20px + env(safe-area-inset-top))",n.style.left="50%",n.style.transform="translateX(-50%)",n.style.alignItems="center";break;case"bottom-center":n.style.bottom="calc(20px + env(safe-area-inset-bottom))",n.style.left="50%",n.style.transform="translateX(-50%)",n.style.alignItems="center";break;default:n.style.bottom="calc(20px + env(safe-area-inset-bottom))",n.style.right="20px"}document.body.appendChild(n)}return n},_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;const n="string"==typeof e&&e?e:this._defaults.playSound;if(n)try{const e=new Audio(n);e.volume=.6;const t=()=>{e.play().catch((()=>{})),window.removeEventListener("touchstart",t),window.removeEventListener("click",t)};e.play().catch((()=>{window.addEventListener("touchstart",t,{once:!0}),window.addEventListener("click",t,{once:!0})}))}catch(e){}},_showToast(e,n){if(!isBrowser)return;!1!==this._defaults.injectCSS&&injectCSS(this._defaults.css||BASE_CSS);const t={...this._config[e]||{},..."object"==typeof n?n:{message:String(n)}};t.icon=t.icon??t.icon_left_top,t.iconPack=t.iconPack??t.icon_config,t.iconLink=t.iconLink??t.icon_onClick_url,t.iconAnimate=t.iconAnimate??t.icon_onClick_animate,t.position=t.position??t.toast,t.closable=t.closable??t.closeable,t.iconPosition=t.iconPosition||"left",t.compact=!!t.compact;const s=themes[t.theme||this._theme]||{},o=document.createElement("div");o.className="juice-toast";const i=t.animation||"slide-in";if(t.enterAnimation||(o.style.animation=`${i} 0.4s ease forwards`),o.setAttribute("role","alert"),o.setAttribute("aria-live","error"===e?"assertive":"polite"),o.setAttribute("aria-atomic","true"),o.tabIndex=0,t.closable&&(close.tabIndex=0,close.addEventListener("keydown",(e=>{"Enter"!==e.key&&" "!==e.key||(o.remove(),this._next())}))),t.size&&sizePreset[t.size]){const e=sizePreset[t.size];e.width&&(o.style.width=e.width),e.padding&&(o.style.padding=e.padding)}let a=null;const r=t.duration??this._defaults.duration;t.progress&&r>0&&(a=document.createElement("div"),a.className="jt-progress",t.progressColor&&(a.style.background=t.progressColor||"rgba(255,255,255,.7)"),o.appendChild(a)),t.tts&&t.message&&speakTTS(t.message,t.ttsLang??"en-US",t.ttsRate??1);const c=this._normalizeGlass(t.glassUI??this._defaults.glassUI);c>0&&(o.style.setProperty("--jt-glass",t.glassUI??50),o.classList.add("jt-glass")),c||(o.style.background=t.bg||s.bg),o.style.color=t.color||s.color,o.style.border=t.border||s.border,t.compact&&o.classList.add("jt-compact"),(t.glassUI??this._defaults.glassUI)&&o.classList.add("jt-glass"),t.width&&(o.style.width=t.width),t.height&&(o.style.height=t.height),t.bgImage&&(o.style.backgroundImage=`url(${t.bgImage})`,o.classList.add("bg-image"));let l=null;if(t.icon){l=document.createElement("i"),l.className=["icon",t.iconPack||"",t.icon].join(" ").trim(),t.iconSize&&(l.style.fontSize=t.iconSize),(t.iconLink||t.iconAnimate)&&(l.classList.add("icon-clickable"),l.onclick=e=>{e.stopPropagation(),t.iconAnimate&&(l.classList.remove(t.iconAnimate),l.offsetWidth,l.classList.add(t.iconAnimate)),t.iconLink&&window.open(t.iconLink,"_blank","noopener")});const n=t.iconAnimate??TYPE_ANIMATION[e];n&&(l.classList.add(n),l.addEventListener("click",(()=>{l.classList.remove(n),l.offsetWidth,l.classList.add(n)})))}reduceMotion&&(o.classList.remove("pop","bounce","shake","wiggle","pulse","spin"),l?.classList.remove("bounce","shake","wiggle","pulse","spin")),t.message||t.title||this._warn("Toast created without message or title"),t.icon&&!t.iconPack&&this._warn("icon provided without iconPack"),t.duration<0&&this._warn("duration cannot be negative");let d=0,p=0,u=!1;const m=e=>{const n=e.touches?e.touches[0]:e;d=n.clientX,p=0,u=!0,o.__paused=!0},f=e=>{if(!u)return;const n=e.touches?e.touches[0]:e;p=n.clientX-d,o.style.transform=`translate3d(${p}px, 0, 0)`},h=()=>{u&&(u=!1,Math.abs(p)>(this._defaults.swipeThreshold||60)?(o.style.transition="transform .25s ease, opacity .2s ease",o.style.transform=`translate3d(${p>0?1e3:-1e3}px, 0, 0)`,setTimeout((()=>{o.replaceWith(),o.onclick=null,o.onmousedown=null,o.remove(),this._next()}),220)):(o.style.transition="transform .2s ease",o.style.transform=""),setTimeout((()=>{o.__paused=!1}),60),d=p=0)};isTouch?(o.addEventListener("touchstart",m,{passive:!0}),o.addEventListener("touchmove",f,{passive:!0}),o.addEventListener("touchend",h),o.addEventListener("touchcancel",h)):o.addEventListener("mousedown",(e=>{d=e.clientX,p=0,u=!0,o.__paused=!0;const n=e=>{p=e.clientX-d,o.style.transform=`translate3d(${p}px, 0, 0)`},t=()=>{document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",t),h()};document.addEventListener("mousemove",n),document.addEventListener("mouseup",t)}));const g=document.createElement("div");g.className="jt-content";const b=t.enterAnimation??"pop";if(b&&!reduceMotion&&o.classList.add(b),t.title){const e=document.createElement("div");e.className="jt-title",e.textContent=t.title,g.appendChild(e)}const x=document.createElement("div");if(x.className="jt-message",x.textContent=t.message||"",g.appendChild(x),l&&"top"===t.iconPosition?(o.classList.add("jt-icon-top"),o.appendChild(l),o.appendChild(g)):l&&"right"===t.iconPosition?(o.appendChild(g),o.appendChild(l)):(l&&o.appendChild(l),o.appendChild(g)),Array.isArray(t.actions)&&t.actions.length){const e=document.createElement("div");e.className="jt-actions",t.actions.forEach((n=>{const t=document.createElement("button");t.className="jt-action",t.textContent=n.label,t.onclick=e=>{e.stopPropagation(),n.onClick?.(e),n.closeOnClick&&(o.replaceWith(),o.onclick=null,o.onmousedown=null,o.remove(),this._next())},e.appendChild(t)})),g.appendChild(e)}if(t.closable){const e=document.createElement("span");e.className="juice-toast-close",e.innerHTML="×",e.onclick=()=>{o.replaceWith(),o.onclick=null,o.onmousedown=null,o.remove(),this._next()},o.appendChild(e)}isIOSStandalone&&(o.style.borderRadius=o.style.borderRadius||"14px");const y=this._getRoot(t.position),w=this._defaults.maxVisible;if(w&&y.children.length>=w&&y.firstChild.remove(),y.appendChild(o),this._runPlugins({toast:o,cfg:t,type:e,root:y}),requestAnimationFrame((()=>{o.classList.add("show")})),0===r)return;let v=Date.now(),_=r;const k=()=>{if(o.__paused)v=Date.now();else{const e=Date.now();_-=e-v,v=e}if(_<=0?(o.classList.remove("show"),setTimeout((()=>{o.replaceWith(),o.onclick=null,o.onmousedown=null,o.remove(),this._next()}),300)):raf(k),a){const e=Math.max(0,Math.min(1,_/r));a.style.transform=`scaleX(${e})`}};isTouch||(o.addEventListener("mouseenter",(()=>o.__paused=!0)),o.addEventListener("mouseleave",(()=>o.__paused=!1))),o.addEventListener("touchstart",(()=>{o.__paused=!0}),{passive:!0}),o.addEventListener("touchend",(()=>{o.__paused=!1})),v=Date.now(),raf(k),(t.playSound||this._defaults.playSound)&&this._playSound(t.playSound)}};juiceToast.setup({success:{icon:"fa-check",iconPack:"fa-solid",bg:"#16a34a",progress:!0,duration:3e3},error:{icon:"fa-xmark",iconPack:"fa-solid",bg:"#dc2626",progress:!0,duration:4e3},info:{icon:"fa-circle-info",iconPack:"fa-solid",bg:"#2563eb",progress:!0},warning:{icon:"fa-triangle-exclamation",iconPack:"fa-solid",bg:"#f59e0b",progress:!0},loading:{icon:"fa-spinner",iconPack:"fa-solid",iconAnimate:"spin",duration:0,progress:!1,closable:!1}});export default juiceToast;export{juiceToast};
6
+ console.warn("%cJuiceToast v1.3.x%c — This version is approaching End of Support on Feb 28th 2026. Use %c^v1.4.x (Gold)%c to remove this message.","background: #f59e0b; color: #000; font-weight: bold; padding: 2px 6px; border-radius: 4px;","color: #555; font-weight: normal;","background: #38bdf8; color: #000; font-weight: bold; padding: 2px 4px; border-radius: 3px;","color: #555; font-weight: normal;");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);function speakTTS(e,t="en-US",s=1){if(!("speechSynthesis"in window))return;let a=new SpeechSynthesisUtterance(e);a.lang=t,a.rate=s;let i=()=>{window.speechSynthesis.speak(a),document.body.removeEventListener("touchstart",i),document.body.removeEventListener("click",i)},o=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;o&&!1===window.speechSynthesis.speaking?(document.body.addEventListener("touchstart",i,{once:!0}),document.body.addEventListener("click",i,{once:!0})):i()}let raf=window.requestAnimationFrame||window.webkitRequestAnimationFrame||(e=>setTimeout(e,16)),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
+ /* top */
21
+ #juice-toast-root[data-position="top"] {
22
+ top: 20px;
23
+ left: 50%;
24
+ transform: translateX(-50%);
25
+ flex-direction: column;
26
+ align-items: center;
27
+ }
28
+
29
+ /* center */
30
+ #juice-toast-root[data-position="center"] {
31
+ top: 50%;
32
+ left: 50%;
33
+ transform: translate(-50%, -50%);
34
+ flex-direction: column;
35
+ align-items: center;
36
+ }
37
+
38
+ [id^="juice-toast-root-"] {
39
+ position: fixed;
40
+ z-index: 9999;
41
+ display: flex;
42
+ gap: 10px;
43
+ pointer-events: none;
44
+ padding-top: var(--jt-safe-top);
45
+ padding-bottom: var(--jt-safe-bottom);
46
+ }
47
+
48
+
49
+ /* ================= TOAST ================= */
50
+
51
+ .juice-toast {
52
+ --jt-x: 0px;
53
+ --jt-y: 12px;
54
+
55
+ pointer-events: auto;
56
+ display: flex;
57
+ gap: 12px;
58
+ align-items: flex-start;
59
+
60
+ min-width: 220px;
61
+ max-width: 420px;
62
+ padding: 12px 16px;
63
+ margin: 6px 0;
64
+
65
+ border-radius: 8px;
66
+ background: #333;
67
+ color: #fff;
68
+
69
+ font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial;
70
+ font-size: 14px;
71
+
72
+ opacity: 0;
73
+ transform: translate(var(--jt-x), var(--jt-y));
74
+ transition:
75
+ opacity .25s ease,
76
+ transform .25s ease,
77
+ background .25s ease,
78
+ color .25s ease,
79
+ box-shadow .25s ease;
80
+
81
+ position: relative;
82
+ box-sizing: border-box;
83
+ overflow: hidden;
84
+
85
+ scroll-behavior: contains;
86
+ -webkit-overflow-scrolling: touch;
87
+
88
+ will-change: transform, opacity;
89
+ backface-visibility: hidden;
90
+ -webkit-backface-visibility: hidden;
91
+
92
+ touch-action: pan-y;
93
+
94
+ }
95
+
96
+ /* visible */
97
+ .juice-toast.show {
98
+ opacity: 1;
99
+ --jt-y: 0px;
100
+ }
101
+
102
+ /* ================= ICON ================= */
103
+
104
+ .juice-toast .icon {
105
+ width: 28px;
106
+ height: 28px;
107
+ display: inline-flex;
108
+ align-items: center;
109
+ justify-content: center;
110
+ font-size: 16px;
111
+ line-height: 1;
112
+ flex: 0 0 28px;
113
+ }
114
+
115
+ /* clickable icon */
116
+ .icon-clickable {
117
+ opacity: 0.85;
118
+ cursor: pointer;
119
+ }
120
+
121
+ .icon-clickable:hover {
122
+ opacity: 1;
123
+ }
124
+
125
+ .jt-message code {
126
+ background: rgba(255,255,255,0.1);
127
+ color: #facc15; /* kuning */
128
+ padding: 2px 4px;
129
+ border-radius: 4px;
130
+ font-family: monospace;
131
+ font-size: 0.9em;
132
+ }
133
+
134
+ /* ================= CONTENT ================= */
135
+
136
+ .juice-toast .jt-content {
137
+ display: flex;
138
+ flex-direction: column;
139
+ gap: 4px;
140
+ flex: 1 1 auto;
141
+ }
142
+
143
+ /* title */
144
+ .juice-toast .jt-title {
145
+ font-weight: 700;
146
+ font-size: 13px;
147
+ line-height: 1.1;
148
+ }
149
+
150
+ /* message */
151
+ .juice-toast .jt-message {
152
+ font-size: 13px;
153
+ line-height: 1.3;
154
+ opacity: 0.95;
155
+ }
156
+
157
+ /* ================= ICON POSITION ================= */
158
+
159
+ .jt-icon-top {
160
+ flex-direction: column;
161
+ align-items: flex-start;
162
+ }
163
+
164
+ .jt-icon-top .icon {
165
+ align-self: center;
166
+ margin-bottom: 6px;
167
+ }
168
+
169
+ /* ================= CLOSE ================= */
170
+
171
+ .juice-toast-close {
172
+ position: absolute;
173
+ top: 6px;
174
+ right: 8px;
175
+ cursor: pointer;
176
+ font-size: 16px;
177
+ opacity: 0.75;
178
+ padding: 4px;
179
+ border-radius: 4px;
180
+ }
181
+
182
+ .juice-toast-close:hover {
183
+ opacity: 1;
184
+ background: rgba(255,255,255,0.06);
185
+ }
186
+
187
+ /* ================= ACTIONS ================= */
188
+
189
+ .jt-actions {
190
+ display: flex;
191
+ gap: 8px;
192
+ margin-top: 10px;
193
+ }
194
+
195
+ .jt-action {
196
+ background: transparent;
197
+ border: 1px solid currentColor;
198
+ padding: 4px 10px;
199
+ border-radius: 6px;
200
+ cursor: pointer;
201
+ font-size: 12px;
202
+ }
203
+
204
+ /* ================= COMPACT ================= */
205
+
206
+ .jt-compact {
207
+ padding: 8px 10px;
208
+ gap: 8px;
209
+ font-size: 0.9em;
210
+ }
211
+
212
+ /* ================= GLASS UI ================= */
213
+
214
+ .jt-glass {
215
+ --g: calc(var(--jt-glass, 60) / 100);
216
+
217
+ background: rgba(30, 30, 30, calc(0.2 + var(--g)));
218
+ backdrop-filter: blur(calc(6px + (14px * var(--g))))
219
+ saturate(calc(1 + (0.4 * var(--g))));
220
+ -webkit-backdrop-filter: blur(calc(6px + (14px * var(--g))))
221
+ saturate(calc(1 + (0.4 * var(--g))));
222
+ }
223
+
224
+ /* light theme support */
225
+ [data-theme="light"] .jt-glass {
226
+ background:
227
+ linear-gradient(
228
+ rgba(255,255,255, calc(0.6 * var(--g))),
229
+ rgba(255,255,255, calc(0.35 * var(--g)))
230
+ ),
231
+ rgba(255,255,255, calc(0.55 - (0.25 * var(--g))));
232
+
233
+ color: #111;
234
+
235
+ border:
236
+ 1px solid rgba(0,0,0, calc(0.05 + 0.12 * var(--g)));
237
+
238
+ box-shadow:
239
+ 0 10px 30px rgba(0,0,0, calc(0.08 + 0.18 * var(--g))),
240
+ inset 0 1px 0 rgba(255,255,255, calc(0.4 * var(--g)));
241
+ }
242
+
243
+ /* ================= PROGRESS BAR ================= */
244
+ .jt-progress {
245
+ position: absolute;
246
+ left: 0;
247
+ bottom: 0;
248
+
249
+ height: 3px;
250
+ width: 100%;
251
+
252
+ background: linear-gradient(to right, #FFFFFF, #FAFAFA);
253
+ height: 4px;
254
+ transform-origin: left;
255
+ transition: transform linear;
256
+ border-radius: 2px;
257
+ transform: scaleX(1);
258
+ opacity: .85;
259
+ }
260
+
261
+ .juice-toast.bg-image {
262
+ background-size: cover;
263
+ background-position: center;
264
+ background-repeat: no-repeat;
265
+ color: #fff;
266
+ text-shadow: 0 1px 2px rgba(0,0,0,0.6);
267
+ }
268
+
269
+ /* ================= ANIMATIONS ================= */
270
+
271
+ @keyframes jt-spin {
272
+ to { transform: rotate(360deg); }
273
+ }
274
+
275
+ @keyframes jt-pulse {
276
+ 50% { transform: scale(1.15); }
277
+ }
278
+
279
+ @keyframes jt-shake {
280
+ 25% { transform: translateX(-3px); }
281
+ 50% { transform: translateX(3px); }
282
+ 75% { transform: translateX(-3px); }
283
+ }
284
+
285
+ @keyframes jt-bounce {
286
+ 0% { transform: scale(1); }
287
+ 30% { transform: scale(1.25); }
288
+ 60% { transform: scale(.95); }
289
+ 100% { transform: scale(1); }
290
+ }
291
+
292
+ @keyframes jt-wiggle {
293
+ 0% { transform: rotate(0); }
294
+ 25% { transform: rotate(-10deg); }
295
+ 50% { transform: rotate(10deg); }
296
+ 75% { transform: rotate(-6deg); }
297
+ 100% { transform: rotate(0); }
298
+ }
299
+
300
+ @keyframes jt-pop {
301
+ 0% { transform: scale(.7); opacity: 0; }
302
+ 70% { transform: scale(1.05); opacity: 1; }
303
+ 100% { transform: scale(1); }
304
+ }
305
+
306
+ /* ================= CLASSES ================= */
307
+
308
+ .spin { animation: jt-spin .6s linear; }
309
+ .pulse { animation: jt-pulse .4s ease; }
310
+ .shake { animation: jt-shake .4s ease; }
311
+ .bounce { animation: jt-bounce .45s ease; }
312
+ .wiggle { animation: jt-wiggle .5s ease; }
313
+ .pop { animation: jt-pop .35s ease-out; }
314
+
315
+ .icon-clickable {
316
+ cursor: pointer;
317
+ transition: transform .15s ease, opacity .15s ease;
318
+ }
319
+
320
+ .icon-clickable:hover {
321
+ transform: scale(1.1);
322
+ opacity: .85;
323
+ }
324
+
325
+ /* ================= ACCESSIBILITY ================= */
326
+
327
+ @media (prefers-reduced-motion: reduce) {
328
+ .spin,
329
+ .pulse,
330
+ .shake,
331
+ .bounce,
332
+ .wiggle,
333
+ .pop {
334
+ animation: none !important;
335
+ }
336
+ }
337
+
338
+ .jt-profile {
339
+ width: 40px;
340
+ height: 40px;
341
+ border-radius: 50%;
342
+ object-fit: cover;
343
+ flex-shrink: 0;
344
+ }
345
+
346
+ .jt-profile.square {
347
+ border-radius: 8px;
348
+ }
349
+
350
+ .juice-toast {
351
+ display: flex;
352
+ align-items: center;
353
+ gap: 10px;
354
+ }
355
+ `;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)"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.15)"},midnight:{bg:"#0f172a",color:"#e5e7eb",border:"1px solid rgba(255,255,255,.06)"},soft:{bg:"#f8fafc",color:"#0f172a",border:"1px solid #e2e8f0"},neutral:{bg:"#ffffff",color:"#374151",border:"1px solid #d1d5db"},brand:{bg:"#6366f1",color:"#fff",border:"none"},gradient:{bg:"linear-gradient(135deg,#6366f1,#ec4899)",color:"#fff",border:"none"},outline:{bg:"transparent",color:"#111",border:"2px solid currentColor"}},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={}){let{duration:t,maxVisible:s,...a}=e;this._defaults={...this._defaults,duration:t,maxVisible:s},this._config={...this._config,...a},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","error"===e?"assertive":"polite"),n.setAttribute("aria-atomic","true"),n.tabIndex=0,i.closable){let l=document.createElement("span");l.className="juice-toast-close",l.textContent="\xd7",l.tabIndex=0,l.addEventListener("keydown",e=>{("Enter"===e.key||" "===e.key)&&(n.remove(),this._next())})}if(i.size&&sizePreset[i.size]){let c=sizePreset[i.size];c.width&&(n.style.width=c.width),c.padding&&(n.style.padding=c.padding)}let d=null;i.profile&&((d=document.createElement("img")).src=i.profile,d.className="jt-profile","square"===i.profileShape&&d.classList.add("square"),n.appendChild(d));let p=null,u=i.duration??this._defaults.duration;i.progress&&u>0&&((p=document.createElement("div")).className="jt-progress",i.progressColor&&(p.style.background=i.progressColor||"rgba(255,255,255,.7)"),n.appendChild(p)),i.tts&&i.message&&speakTTS(i.message,i.ttsLang??"en-US",i.ttsRate??1);let f=this._normalizeGlass(i.glassUI??this._defaults.glassUI);f>0&&(n.style.setProperty("--jt-glass",i.glassUI??50),n.classList.add("jt-glass")),f||(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.width&&(n.style.width=i.width),i.height&&(n.style.height=i.height),i.bgImage&&(n.style.backgroundImage=`url(${i.bgImage})`,n.classList.add("bg-image"));let h=null;if(i.icon){(h=document.createElement("i")).className=["icon",i.iconPack||"",i.icon].join(" ").trim(),i.iconSize&&(h.style.fontSize=i.iconSize),(i.iconLink||i.iconAnimate)&&(h.classList.add("icon-clickable"),h.onclick=e=>{e.stopPropagation(),i.iconAnimate&&(h.classList.remove(i.iconAnimate),h.offsetWidth,h.classList.add(i.iconAnimate)),i.iconLink&&window.open(i.iconLink,"_blank","noopener")});let g=i.iconAnimate??TYPE_ANIMATION[e];g&&(h.classList.add(g),h.addEventListener("click",()=>{h.classList.remove(g),h.offsetWidth,h.classList.add(g)}))}reduceMotion&&(n.classList.remove("pop","bounce","shake","wiggle","pulse","spin"),h?.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 m=0,$=0,b=!1,x=e=>{let t=e.touches?e.touches[0]:e;m=t.clientX,$=0,b=!0,n.__paused=!0},y=e=>{if(!b)return;let t=e.touches?e.touches[0]:e;$=t.clientX-m,n.style.transform=`translate3d(${$}px, 0, 0)`},_=()=>{b&&(b=!1,Math.abs($)>(this._defaults.swipeThreshold||60)?(n.style.transition="transform .25s ease, opacity .2s ease",n.style.transform=`translate3d(${$>0?1e3:-1e3}px, 0, 0)`,setTimeout(()=>{n.replaceWith(),n.onclick=null,n.onmousedown=null,n.remove(),this._next()},220)):(n.style.transition="transform .2s ease",n.style.transform=""),setTimeout(()=>{n.__paused=!1},60),m=$=0)};isTouch?(n.addEventListener("touchstart",x,{passive:!0}),n.addEventListener("touchmove",y,{passive:!0}),n.addEventListener("touchend",_),n.addEventListener("touchcancel",_)):n.addEventListener("mousedown",e=>{m=e.clientX,$=0,b=!0,n.__paused=!0;let t=e=>{$=e.clientX-m,n.style.transform=`translate3d(${$}px, 0, 0)`},s=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",s),_()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",s)});let v=document.createElement("div");v.className="jt-content";let k=i.enterAnimation??"pop";if(k&&!reduceMotion&&n.classList.add(k),i.title){let w=document.createElement("div");w.className="jt-title",w.textContent=i.title,v.appendChild(w)}let j=document.createElement("div");if(j.className="jt-message","string"==typeof i.message){let S=i.message.split(/(`[^`]+`)/g);S.forEach(e=>{if(e.startsWith("`")&&e.endsWith("`")){let t=document.createElement("code");t.textContent=e.slice(1,-1),j.appendChild(t)}else j.appendChild(document.createTextNode(e))})}if(v.appendChild(j),h&&"top"===i.iconPosition?(n.classList.add("jt-icon-top"),n.appendChild(h),n.appendChild(v)):h&&"right"===i.iconPosition?(n.appendChild(v),n.appendChild(h)):(h&&n.appendChild(h),n.appendChild(v)),Array.isArray(i.actions)&&i.actions.length){let E=document.createElement("div");E.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.replaceWith(),n.onclick=null,n.onmousedown=null,n.remove(),this._next())},E.appendChild(t)}),v.appendChild(E)}if(i.closable){let C=document.createElement("span");C.className="juice-toast-close",C.textContent="\xd7",C.onclick=()=>{n.replaceWith(),n.onclick=null,n.onmousedown=null,n.remove(),this._next()},n.appendChild(C)}isIOSStandalone&&(n.style.borderRadius=n.style.borderRadius||"14px");let L=this._getRoot(i.position),I=this._defaults.maxVisible;if(I&&L.children.length>=I&&L.firstChild.remove(),L.appendChild(n),this._runPlugins({toast:n,cfg:i,type:e,root:L}),requestAnimationFrame(()=>{n.classList.add("show")}),0===u)return;let T=Date.now(),A=u,P=()=>{if(n.__paused)T=Date.now();else{let e=Date.now();A-=e-T,T=e}if(A<=0?(n.classList.remove("show"),setTimeout(()=>{n.replaceWith(),n.onclick=null,n.onmousedown=null,n.remove(),this._next()},300)):raf(P),p){let t=Math.max(0,Math.min(1,A/u));p.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}),T=Date.now(),raf(P),(i.playSound||this._defaults.playSound)&&this._playSound(i.playSound)}};juiceToast.setup({success:{icon:"fa-check",iconPack:"fa-solid",bg:"#16a34a",progress:!0,duration:3e3},error:{icon:"fa-xmark",iconPack:"fa-solid",bg:"#dc2626",progress:!0,duration:4e3},info:{icon:"fa-circle-info",iconPack:"fa-solid",bg:"#2563eb",progress:!0},warning:{icon:"fa-triangle-exclamation",iconPack:"fa-solid",bg:"#f59e0b",progress:!0},loading:{icon:"fa-spinner",iconPack:"fa-solid",iconAnimate:"spin",duration:0,progress:!1,closable:!1}});export default juiceToast;export{juiceToast};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juice-toast",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
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": ">=18"
26
+ "node": ">=19"
27
27
  },
28
28
  "scripts": {
29
29
  "format": "npx prettier --write src/"
@@ -60,5 +60,9 @@
60
60
  "jsdelivr": "dist/juice-toast.esm.js",
61
61
  "devDependencies": {
62
62
  "prettier": "^3.8.1"
63
+ },
64
+ "dependencies": {
65
+ "react": "^19.2.4",
66
+ "react-dom": "^19.2.4"
63
67
  }
64
68
  }