juice-toast 1.3.2 → 1.3.3

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,6 +1,9 @@
1
- ## v1.3.2
1
+ ## v1.3.3
2
+ - Bug Fixes on Closeable Toast & Logic
3
+
4
+ v1.3.2
2
5
  - Improved A11Y
3
- - Adding **Background Image**
6
+ - Adding Background Image
4
7
  - Adding more Theme
5
8
  - Adding default toast (juiceToast.success|error|info|warning|loading)
6
9
 
@@ -1,6 +1,331 @@
1
1
  /**
2
2
  * 2026 (C) OpenDN Foundation
3
- * v1.3.2 (STABLE)
3
+ * v1.3.3 (STABLE & BUG FIX)
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
+ 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
+ /* ================= COMPACT ================= */
188
+
189
+ .jt-compact {
190
+ padding: 6px 8px;
191
+ font-size: 0.85em;
192
+ gap: 6px;
193
+ max-width: 280px;
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: linear-gradient(to right, #FFFFFF, #FAFAFA);
237
+ height: 4px;
238
+ transform-origin: left;
239
+ transition: transform linear;
240
+ border-radius: 2px;
241
+ transform: scaleX(1);
242
+ opacity: .85;
243
+ }
244
+
245
+ /* ================= BACKGROUND IMAGE ================= */
246
+
247
+ .juice-toast.bg-image {
248
+ background-size: cover;
249
+ background-position: center;
250
+ background-repeat: no-repeat;
251
+ color: #fff;
252
+ text-shadow: 0 1px 2px rgba(0,0,0,0.6);
253
+ }
254
+
255
+ /* ================= ANIMATIONS ================= */
256
+
257
+ @keyframes jt-spin {
258
+ to { transform: rotate(360deg); }
259
+ }
260
+
261
+ @keyframes jt-pulse {
262
+ 50% { transform: scale(1.15); }
263
+ }
264
+
265
+ @keyframes jt-shake {
266
+ 25% { transform: translateX(-3px); }
267
+ 50% { transform: translateX(3px); }
268
+ 75% { transform: translateX(-3px); }
269
+ }
270
+
271
+ @keyframes jt-bounce {
272
+ 0% { transform: scale(1); }
273
+ 30% { transform: scale(1.25); }
274
+ 60% { transform: scale(.95); }
275
+ 100% { transform: scale(1); }
276
+ }
277
+
278
+ @keyframes jt-wiggle {
279
+ 0% { transform: rotate(0); }
280
+ 25% { transform: rotate(-10deg); }
281
+ 50% { transform: rotate(10deg); }
282
+ 75% { transform: rotate(-6deg); }
283
+ 100% { transform: rotate(0); }
284
+ }
285
+
286
+ @keyframes jt-pop {
287
+ 0% { transform: scale(.7); opacity: 0; }
288
+ 70% { transform: scale(1.05); opacity: 1; }
289
+ 100% { transform: scale(1); }
290
+ }
291
+
292
+ @keyframes jt-slide {
293
+ from { transform: translateY(20 px);opacity: 0; }
294
+ to { transform: translateY(0);opacity: 1; }
295
+ }
296
+
297
+ /* ================= CLASSES ================= */
298
+
299
+ .spin { animation: jt-spin .6s linear; }
300
+ .pulse { animation: jt-pulse .4s ease; }
301
+ .shake { animation: jt-shake .4s ease; }
302
+ .bounce { animation: jt-bounce .45s ease; }
303
+ .wiggle { animation: jt-wiggle .5s ease; }
304
+ .pop { animation: jt-pop .35s ease-out; }
305
+ .slide-in { animation: jt-slide .55s ease; }
306
+
307
+ /* ================= ICON INTERACTION ================= */
308
+
309
+ .icon-clickable {
310
+ cursor: pointer;
311
+ transition: transform .15s ease, opacity .15s ease;
312
+ }
313
+
314
+ .icon-clickable:hover {
315
+ transform: scale(1.1);
316
+ opacity: .85;
317
+ }
318
+
319
+ /* ================= ACCESSIBILITY ================= */
320
+
321
+ @media (prefers-reduced-motion: reduce) {
322
+ .spin,
323
+ .pulse,
324
+ .shake,
325
+ .bounce,
326
+ .wiggle,
327
+ .pop {
328
+ animation: none !important;
329
+ }
330
+ }
331
+ `;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=a,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]||{},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.tabIndex=0,l.className="juice-toast-close",l.textContent="\xd7",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;if(i.progress&&(i.duration??this._defaults.duration)>0&&((d=document.createElement("div")).className="jt-progress",i.progressColor&&(d.style.background=i.progressColor||"rgba(255,255,255,.7)"),n.appendChild(d)),i.tts&&"speechSynthesis"in window)try{let p=new SpeechSynthesisUtterance(i.message||i.title||"");p.lang=i.ttsLang||"en-US",p.rate=i.ttsRate??1,window.speechSynthesis.speak(p)}catch(f){this._warn("TTS failed: "+f.message)}let g=this._normalizeGlass(i.glassUI??this._defaults.glassUI);g>0&&(n.style.setProperty("--jt-glass",i.glassUI??50),n.classList.add("jt-glass")),g||(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 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,$=0;n.addEventListener("touchstart",e=>{h=e.touches[0].clientX}),n.addEventListener("touchmove",e=>{$=e.touches[0].clientX-h,n.style.transform=`translateX(${$}px)`}),n.addEventListener("touchend",()=>{Math.abs($)>this._defaults.swipeThreshold?(n.style.transform=`translateX(${$>0?1e3:-1e3}px)`,setTimeout(()=>{n.remove(),this._next()},200)):n.style.transform="",h=$=0});let x=document.createElement("div");x.className="jt-content";let b=i.enterAnimation??"pop";if(b&&!reduceMotion&&n.classList.add(b),i.title){let y=document.createElement("div");y.className="jt-title",y.textContent=i.title,x.appendChild(y)}let _=document.createElement("div");if(_.className="jt-message",_.textContent=i.message||"",x.appendChild(_),u&&"top"===i.iconPosition?(n.classList.add("jt-icon-top"),n.appendChild(u),n.appendChild(x)):u&&"right"===i.iconPosition?(n.appendChild(x),n.appendChild(u)):(u&&n.appendChild(u),n.appendChild(x)),Array.isArray(i.actions)&&i.actions.length){let j=document.createElement("div");j.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())},j.appendChild(t)}),x.appendChild(j)}if(i.closable){let k=document.createElement("span");k.className="juice-toast-close",k.textContent="\xd7",k.onclick=()=>{n.remove(),this._next()},n.appendChild(k)}let w=this._getRoot(i.position),v=this._defaults.maxVisible;v&&w.children.length>=v&&w.firstChild.remove(),w.appendChild(n),this._runPlugins({toast:n,cfg:i,type:e,root:w}),requestAnimationFrame(()=>n.classList.add("show"));let C=i.duration??this._defaults.duration;if(0===C)return;let E=Date.now(),S=i.duration??this._defaults.duration,A,I=()=>{if(n.__paused)E=Date.now();else{let e=Date.now();S-=e-E,E=e}S<=0?(n.classList.remove("show"),setTimeout(()=>{n.remove(),this._next()},300)):A=requestAnimationFrame(I),d&&(d.style.transform=`scaleX(${Math.max(0,S/C)})`)};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(I)}};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};
@@ -1,6 +1,328 @@
1
1
  /**
2
2
  * OpenDN Foundation (C) 2026
3
- * Source Of Juice Toast v1.3.1 (iOS user)
3
+ * Source Of Juice Toast v1.3.3 (iOS user)
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
+ 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
+ /* ================= CONTENT ================= */
126
+
127
+ .juice-toast .jt-content {
128
+ display: flex;
129
+ flex-direction: column;
130
+ gap: 4px;
131
+ flex: 1 1 auto;
132
+ }
133
+
134
+ /* title */
135
+ .juice-toast .jt-title {
136
+ font-weight: 700;
137
+ font-size: 13px;
138
+ line-height: 1.1;
139
+ }
140
+
141
+ /* message */
142
+ .juice-toast .jt-message {
143
+ font-size: 13px;
144
+ line-height: 1.3;
145
+ opacity: 0.95;
146
+ }
147
+
148
+ /* ================= ICON POSITION ================= */
149
+
150
+ .jt-icon-top {
151
+ flex-direction: column;
152
+ align-items: flex-start;
153
+ }
154
+
155
+ .jt-icon-top .icon {
156
+ align-self: center;
157
+ margin-bottom: 6px;
158
+ }
159
+
160
+ /* ================= CLOSE ================= */
161
+
162
+ .juice-toast-close {
163
+ position: absolute;
164
+ top: 6px;
165
+ right: 8px;
166
+ cursor: pointer;
167
+ font-size: 16px;
168
+ opacity: 0.75;
169
+ padding: 4px;
170
+ border-radius: 4px;
171
+ }
172
+
173
+ .juice-toast-close:hover {
174
+ opacity: 1;
175
+ background: rgba(255,255,255,0.06);
176
+ }
177
+
178
+ /* ================= ACTIONS ================= */
179
+
180
+ .jt-actions {
181
+ display: flex;
182
+ gap: 8px;
183
+ margin-top: 10px;
184
+ }
185
+
186
+ .jt-action {
187
+ background: transparent;
188
+ border: 1px solid currentColor;
189
+ padding: 4px 10px;
190
+ border-radius: 6px;
191
+ cursor: pointer;
192
+ font-size: 12px;
193
+ }
194
+
195
+ /* ================= COMPACT ================= */
196
+
197
+ .jt-compact {
198
+ padding: 8px 10px;
199
+ gap: 8px;
200
+ font-size: 0.9em;
201
+ }
202
+
203
+ /* ================= GLASS UI ================= */
204
+
205
+ .jt-glass {
206
+ --g: calc(var(--jt-glass, 60) / 100);
207
+
208
+ background: rgba(30, 30, 30, calc(0.2 + var(--g)));
209
+ backdrop-filter: blur(calc(6px + (14px * var(--g))))
210
+ saturate(calc(1 + (0.4 * var(--g))));
211
+ -webkit-backdrop-filter: blur(calc(6px + (14px * var(--g))))
212
+ saturate(calc(1 + (0.4 * var(--g))));
213
+ }
214
+
215
+ /* light theme support */
216
+ [data-theme="light"] .jt-glass {
217
+ background:
218
+ linear-gradient(
219
+ rgba(255,255,255, calc(0.6 * var(--g))),
220
+ rgba(255,255,255, calc(0.35 * var(--g)))
221
+ ),
222
+ rgba(255,255,255, calc(0.55 - (0.25 * var(--g))));
223
+
224
+ color: #111;
225
+
226
+ border:
227
+ 1px solid rgba(0,0,0, calc(0.05 + 0.12 * var(--g)));
228
+
229
+ box-shadow:
230
+ 0 10px 30px rgba(0,0,0, calc(0.08 + 0.18 * var(--g))),
231
+ inset 0 1px 0 rgba(255,255,255, calc(0.4 * var(--g)));
232
+ }
233
+
234
+ /* ================= PROGRESS BAR ================= */
235
+ .jt-progress {
236
+ position: absolute;
237
+ left: 0;
238
+ bottom: 0;
239
+
240
+ height: 3px;
241
+ width: 100%;
242
+
243
+ background: linear-gradient(to right, #FFFFFF, #FAFAFA);
244
+ height: 4px;
245
+ transform-origin: left;
246
+ transition: transform linear;
247
+ border-radius: 2px;
248
+ transform: scaleX(1);
249
+ opacity: .85;
250
+ }
251
+
252
+ .juice-toast.bg-image {
253
+ background-size: cover;
254
+ background-position: center;
255
+ background-repeat: no-repeat;
256
+ color: #fff;
257
+ text-shadow: 0 1px 2px rgba(0,0,0,0.6);
258
+ }
259
+
260
+ /* ================= ANIMATIONS ================= */
261
+
262
+ @keyframes jt-spin {
263
+ to { transform: rotate(360deg); }
264
+ }
265
+
266
+ @keyframes jt-pulse {
267
+ 50% { transform: scale(1.15); }
268
+ }
269
+
270
+ @keyframes jt-shake {
271
+ 25% { transform: translateX(-3px); }
272
+ 50% { transform: translateX(3px); }
273
+ 75% { transform: translateX(-3px); }
274
+ }
275
+
276
+ @keyframes jt-bounce {
277
+ 0% { transform: scale(1); }
278
+ 30% { transform: scale(1.25); }
279
+ 60% { transform: scale(.95); }
280
+ 100% { transform: scale(1); }
281
+ }
282
+
283
+ @keyframes jt-wiggle {
284
+ 0% { transform: rotate(0); }
285
+ 25% { transform: rotate(-10deg); }
286
+ 50% { transform: rotate(10deg); }
287
+ 75% { transform: rotate(-6deg); }
288
+ 100% { transform: rotate(0); }
289
+ }
290
+
291
+ @keyframes jt-pop {
292
+ 0% { transform: scale(.7); opacity: 0; }
293
+ 70% { transform: scale(1.05); opacity: 1; }
294
+ 100% { transform: scale(1); }
295
+ }
296
+
297
+ /* ================= CLASSES ================= */
298
+
299
+ .spin { animation: jt-spin .6s linear; }
300
+ .pulse { animation: jt-pulse .4s ease; }
301
+ .shake { animation: jt-shake .4s ease; }
302
+ .bounce { animation: jt-bounce .45s ease; }
303
+ .wiggle { animation: jt-wiggle .5s ease; }
304
+ .pop { animation: jt-pop .35s ease-out; }
305
+
306
+ .icon-clickable {
307
+ cursor: pointer;
308
+ transition: transform .15s ease, opacity .15s ease;
309
+ }
310
+
311
+ .icon-clickable:hover {
312
+ transform: scale(1.1);
313
+ opacity: .85;
314
+ }
315
+
316
+ /* ================= ACCESSIBILITY ================= */
317
+
318
+ @media (prefers-reduced-motion: reduce) {
319
+ .spin,
320
+ .pulse,
321
+ .shake,
322
+ .bounce,
323
+ .wiggle,
324
+ .pop {
325
+ animation: none !important;
326
+ }
327
+ }
328
+ `;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=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,p=i.duration??this._defaults.duration;i.progress&&p>0&&((d=document.createElement("div")).className="jt-progress",i.progressColor&&(d.style.background=i.progressColor||"rgba(255,255,255,.7)"),n.appendChild(d)),i.tts&&i.message&&speakTTS(i.message,i.ttsLang??"en-US",i.ttsRate??1);let u=this._normalizeGlass(i.glassUI??this._defaults.glassUI);u>0&&(n.style.setProperty("--jt-glass",i.glassUI??50),n.classList.add("jt-glass")),u||(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 f=null;if(i.icon){(f=document.createElement("i")).className=["icon",i.iconPack||"",i.icon].join(" ").trim(),i.iconSize&&(f.style.fontSize=i.iconSize),(i.iconLink||i.iconAnimate)&&(f.classList.add("icon-clickable"),f.onclick=e=>{e.stopPropagation(),i.iconAnimate&&(f.classList.remove(i.iconAnimate),f.offsetWidth,f.classList.add(i.iconAnimate)),i.iconLink&&window.open(i.iconLink,"_blank","noopener")});let m=i.iconAnimate??TYPE_ANIMATION[e];m&&(f.classList.add(m),f.addEventListener("click",()=>{f.classList.remove(m),f.offsetWidth,f.classList.add(m)}))}reduceMotion&&(n.classList.remove("pop","bounce","shake","wiggle","pulse","spin"),f?.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,g=0,$=!1,b=e=>{let t=e.touches?e.touches[0]:e;h=t.clientX,g=0,$=!0,n.__paused=!0},x=e=>{if(!$)return;let t=e.touches?e.touches[0]:e;g=t.clientX-h,n.style.transform=`translate3d(${g}px, 0, 0)`},y=()=>{$&&($=!1,Math.abs(g)>(this._defaults.swipeThreshold||60)?(n.style.transition="transform .25s ease, opacity .2s ease",n.style.transform=`translate3d(${g>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),h=g=0)};isTouch?(n.addEventListener("touchstart",b,{passive:!0}),n.addEventListener("touchmove",x,{passive:!0}),n.addEventListener("touchend",y),n.addEventListener("touchcancel",y)):n.addEventListener("mousedown",e=>{h=e.clientX,g=0,$=!0,n.__paused=!0;let t=e=>{g=e.clientX-h,n.style.transform=`translate3d(${g}px, 0, 0)`},s=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",s),y()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",s)});let _=document.createElement("div");_.className="jt-content";let v=i.enterAnimation??"pop";if(v&&!reduceMotion&&n.classList.add(v),i.title){let k=document.createElement("div");k.className="jt-title",k.textContent=i.title,_.appendChild(k)}let w=document.createElement("div");if(w.className="jt-message",w.textContent=i.message||"",_.appendChild(w),f&&"top"===i.iconPosition?(n.classList.add("jt-icon-top"),n.appendChild(f),n.appendChild(_)):f&&"right"===i.iconPosition?(n.appendChild(_),n.appendChild(f)):(f&&n.appendChild(f),n.appendChild(_)),Array.isArray(i.actions)&&i.actions.length){let j=document.createElement("div");j.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())},j.appendChild(t)}),_.appendChild(j)}if(i.closable){let S=document.createElement("span");S.className="juice-toast-close",S.textContent="\xd7",S.onclick=()=>{n.replaceWith(),n.onclick=null,n.onmousedown=null,n.remove(),this._next()},n.appendChild(S)}isIOSStandalone&&(n.style.borderRadius=n.style.borderRadius||"14px");let E=this._getRoot(i.position),L=this._defaults.maxVisible;if(L&&E.children.length>=L&&E.firstChild.remove(),E.appendChild(n),this._runPlugins({toast:n,cfg:i,type:e,root:E}),requestAnimationFrame(()=>{n.classList.add("show")}),0===p)return;let C=Date.now(),I=p,T=()=>{if(n.__paused)C=Date.now();else{let e=Date.now();I-=e-C,C=e}if(I<=0?(n.classList.remove("show"),setTimeout(()=>{n.replaceWith(),n.onclick=null,n.onmousedown=null,n.remove(),this._next()},300)):raf(T),d){let t=Math.max(0,Math.min(1,I/p));d.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(),raf(T),(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.3",
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/"