juice-toast 1.4.3 → 1.4.4-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/{LICENSE.md → LICENSE} +5 -4
- package/README.md +0 -1
- package/dist/juice-toast.esm.js +41 -6
- package/dist/juice-toast.umd.js +41 -6
- package/package.json +2 -2
- /package/{EoL.md → Notice.md} +0 -0
package/CHANGELOG.md
CHANGED
package/{LICENSE.md → LICENSE}
RENAMED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
===========================================
|
|
2
|
+
Atrosfer License 1.0
|
|
3
|
+
2026 (C) OpenDN Foundation
|
|
4
|
+
https://atrosfer.opendnf.cloud/1.0
|
|
5
|
+
===========================================
|
|
5
6
|
|
|
6
7
|
1. Grant of License:
|
|
7
8
|
- Permission is hereby granted, free of charge, to any person obtaining a copy
|
package/README.md
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|

|
|
8
8
|

|
|
9
9
|

|
|
10
|
-

|
|
11
10
|

|
|
12
11
|

|
|
13
12
|

|
package/dist/juice-toast.esm.js
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
|
-
var Ct=Object.defineProperty,Lt=Object.defineProperties,St=Object.getOwnPropertyDescriptors,
|
|
1
|
+
var Ct=Object.defineProperty,Lt=Object.defineProperties,St=Object.getOwnPropertyDescriptors,J=Object.getOwnPropertySymbols,ht=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable,yt=(e,a,t)=>a in e?Ct(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,st=(e,a)=>{for(var t in a||(a={}))ht.call(a,t)&&yt(e,t,a[t]);if(J)for(var t of J(a))ft.call(a,t)&&yt(e,t,a[t]);return e},nt=(e,a)=>Lt(e,St(a)),Mt=(e,a)=>{var t={};for(var n in e)ht.call(e,n)&&a.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&J)for(var n of J(e))a.indexOf(n)<0&&ft.call(e,n)&&(t[n]=e[n]);return t};const M=typeof window!="undefined"&&typeof document!="undefined",U=M&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;class W{constructor(){this._heap=[]}get size(){return this._heap.length}_parent(a){return Math.floor((a-1)/2)}_left(a){return 2*a+1}_right(a){return 2*a+2}_swap(a,t){[this._heap[a],this._heap[t]]=[this._heap[t],this._heap[a]]}push(a,t=0){const n={item:a,priority:t,seq:W._seq=(W._seq||0)+1};this._heap.push(n),this._siftUp(this._heap.length-1)}pop(){if(!this._heap.length)return null;this._swap(0,this._heap.length-1);const a=this._heap.pop();return this._siftDown(0),a.item}peek(){return this._heap[0]?this._heap[0].item:null}_siftUp(a){for(;a>0;){const t=this._parent(a);if(this._compare(a,t)<=0)break;this._swap(a,t),a=t}}_siftDown(a){for(;;){const t=this._left(a),n=this._right(a),u=this._heap.length;let o=a;if(t<u&&this._compare(t,o)>0&&(o=t),n<u&&this._compare(n,o)>0&&(o=n),o===a)break;this._swap(a,o),a=o}}_compare(a,t){const n=this._heap[a],u=this._heap[t];return n.priority!==u.priority?n.priority-u.priority:n.seq-u.seq}}let it=!1;const lt=`
|
|
2
2
|
/* JuiceToast base (extended) */
|
|
3
|
-
#juice-toast-root,[id^="juice-toast-root-"]{position:fixed;z-index:9999;display:flex;pointer-events:none;gap:10px}
|
|
3
|
+
#juice-toast-root,[id^="juice-toast-root-"]{position:fixed;z-index:9999;display:flex;pointer-events:none;gap:10px;perspective:800px}
|
|
4
4
|
#juice-toast-root[data-position="bottom-right"],#juice-toast-root-bottom-right{bottom:20px;right:20px;flex-direction:column-reverse;align-items:flex-end}
|
|
5
5
|
#juice-toast-root[data-position="top-right"]{top:20px;right:20px;flex-direction:column;align-items:flex-end}
|
|
6
6
|
#juice-toast-root[data-position="bottom-left"]{bottom:20px;left:20px;flex-direction:column-reverse;align-items:flex-start}
|
|
7
7
|
#juice-toast-root[data-position="top-left"]{top:20px;left:20px;flex-direction:column;align-items:flex-start}
|
|
8
8
|
#juice-toast-root[data-position="top-center"],#juice-toast-root[data-position="bottom-center"]{left:50%;transform:translateX(-50%)}
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
/* store parallax/3d vars */
|
|
11
|
+
.juice-toast {
|
|
12
|
+
pointer-events:auto;
|
|
13
|
+
min-width:220px;
|
|
14
|
+
max-width:420px;
|
|
15
|
+
padding:12px 16px;
|
|
16
|
+
margin:6px 0;
|
|
17
|
+
border-radius:10px;
|
|
18
|
+
background:linear-gradient(180deg,rgba(30,30,30,.95),rgba(20,20,20,.95));
|
|
19
|
+
color:#fff;
|
|
20
|
+
display:flex;
|
|
21
|
+
gap:12px;
|
|
22
|
+
align-items:flex-start;
|
|
23
|
+
box-sizing:border-box;
|
|
24
|
+
transition: transform 0.25s cubic-bezier(0.4,0,0.2,1), opacity 0.28s ease;
|
|
25
|
+
transform:
|
|
26
|
+
translate3d(var(--jt-parallax-x,0), var(--jt-parallax-y,0), var(--jt-parallax-z,0))
|
|
27
|
+
translateX(var(--jt-drag-x,0))
|
|
28
|
+
translateY(var(--jt-drag-y,0))
|
|
29
|
+
rotateX(var(--jt-rot-x,0))
|
|
30
|
+
rotateY(var(--jt-rot-y,0))
|
|
31
|
+
scale(var(--jt-stack-scale,1));
|
|
32
|
+
transform-style:preserve-3d;
|
|
33
|
+
will-change: transform, opacity;
|
|
34
|
+
}
|
|
10
35
|
@keyframes jt-slide-in{0%{opacity:0;transform:translateY(20px) scale(0.98)}100%{opacity:1;transform:translateY(0) scale(1)}}
|
|
11
36
|
@keyframes jt-slide-out{0%{opacity:1;transform:translateY(0) scale(1)}100%{opacity:0;transform:translateY(20px) scale(0.98)}}
|
|
12
37
|
@keyframes jt-bounce{0%{transform:translateY(0)}25%{transform:translateY(-6px)}50%{transform:translateY(0)}75%{transform:translateY(-3px)}100%{transform:translateY(0)}}
|
|
@@ -33,8 +58,18 @@ var Ct=Object.defineProperty,Lt=Object.defineProperties,St=Object.getOwnProperty
|
|
|
33
58
|
position:fixed;inset:0;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(15,23,42,.55);backdrop-filter:blur(6px) saturate(120%);-webkit-backdrop-filter:blur(6px) saturate(120%);opacity:0;transition:opacity .25s ease;z-index:10000;
|
|
34
59
|
}
|
|
35
60
|
.jt-modal-overlay.show{opacity:1}
|
|
36
|
-
.jt-modal{
|
|
37
|
-
|
|
61
|
+
.jt-modal{
|
|
62
|
+
width:100%;
|
|
63
|
+
max-width:520px;
|
|
64
|
+
border-radius:18px;
|
|
65
|
+
padding:24px;
|
|
66
|
+
opacity:0;
|
|
67
|
+
transform:translateY(40px) scale(.96) rotateX(6deg);
|
|
68
|
+
transition:transform .35s cubic-bezier(.16,1,.3,1),opacity .25s ease;
|
|
69
|
+
transform-style:preserve-3d;
|
|
70
|
+
will-change:transform,opacity;
|
|
71
|
+
}
|
|
72
|
+
.jt-modal.show{opacity:1;transform:translateY(0) scale(1) rotateX(0deg)}
|
|
38
73
|
.jt-modal-header{font-size:18px;font-weight:600;letter-spacing:.3px;margin-bottom:10px}
|
|
39
74
|
.jt-modal-body{font-size:14.5px;line-height:1.6;opacity:.85;margin-bottom:22px}
|
|
40
75
|
.jt-modal-actions{display:flex;justify-content:flex-end;gap:12px}
|
|
@@ -42,5 +77,5 @@ var Ct=Object.defineProperty,Lt=Object.defineProperties,St=Object.getOwnProperty
|
|
|
42
77
|
.jt-modal-btn:hover{background:rgba(255,255,255,.08);transform:translateY(-1px)}
|
|
43
78
|
.jt-modal-btn.primary{background:#6366f1;border-color:#6366f1;color:#fff}
|
|
44
79
|
#juice-toast-root[data-parallax="true"] .juice-toast{transition: transform 0.12s cubic-bezier(.2,.8,.2,1), opacity .2s}
|
|
45
|
-
`;function ht(e=tt){if(!E||Z)return;if(document.getElementById("juice-toast-style")){Z=!0;return}const t=document.createElement("style");t.id="juice-toast-style",t.textContent=e,document.head.appendChild(t),Z=!0}const et=(()=>{let e=1;return()=>"jt-"+e++})();function _(){return Date.now()}function I(e,t){return Object.assign({},e||{},t||{})}function at(e,t,a){return Math.max(t,Math.min(a,e))}function $(e){if(!e)return"";const t=document.createElement("template");t.innerHTML=e,t.content.querySelectorAll("script, style, iframe").forEach(r=>r.remove());const a=["b","i","u","strong","em","code","pre","ul","ol","li","br","p","span","img","h1","h2","h3","h4","h5","h6","a"];return(function r(i){Array.from(i.childNodes).forEach(s=>{if(s.nodeType===1){const u=s.tagName.toLowerCase();a.includes(u)?(Array.from(s.attributes||[]).forEach(b=>{const p=b.name.toLowerCase(),m=b.value||"";(p.startsWith("on")||(p==="href"||p==="src"||p==="xlink:href")&&m.trim().toLowerCase().startsWith("javascript:")||u==="img"&&p==="srcset")&&s.removeAttribute(b.name)}),r(s)):s.replaceWith(...Array.from(s.childNodes))}})})(t.content),t.innerHTML}const z={dark:{bg:"linear-gradient(180deg,#1f2937,#111827)",color:"#fff",border:"1px solid rgba(255,255,255,.06)"},light:{bg:"#fff",color:"#111",border:"1px solid #e5e7eb"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.1)"}},ft={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},Mt={success:"jt-bounce",error:"jt-shake",warning:"jt-shake",info:"jt-pulse",loading:"jt-spin"},k={_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,playSound:null,dev:!1,injectCSS:!0,css:null,autoDedupe:!1,maxVisiblePerType:{},parallaxMode:!1,autoFetchFA:!0},_config:{},_theme:"dark",_plugins:[],_queue:new O,_queueDedupe:new Set,_activeMap:new Map,_roots:new Map,_modalStack:[],_faInjected:!1,setup(e={}){const t=e,{duration:a,maxVisible:r}=t,i=Pt(t,["duration","maxVisible"]);typeof a=="number"&&(this._defaults.duration=a),typeof r=="number"&&(this._defaults.maxVisible=r),typeof e.autoDedupe=="boolean"&&(this._defaults.autoDedupe=e.autoDedupe),e.maxVisiblePerType&&(this._defaults.maxVisiblePerType=I(this._defaults.maxVisiblePerType,e.maxVisiblePerType)),typeof e.parallaxMode=="boolean"&&(this._defaults.parallaxMode=e.parallaxMode),typeof e.autoFetchFA=="boolean"&&(this._defaults.autoFetchFA=e.autoFetchFA),this._config=I(this._config,i),this._registerTypes()},use(e){typeof e=="function"&&this._plugins.push(e)},addType(e,t={}){this._config[e]=t,this._registerTypes()},defineTheme(e,t={}){z[e]=I(z[e]||{},t)},setTheme(e){this._theme=e,E&&this._roots.forEach(t=>t.dataset.theme=e)},clear(){this._queue=new O,this._queueDedupe.clear()},destroy(){this.clear(),E&&(this._roots.forEach(e=>{try{e.remove()}catch(t){}}),this._roots.clear())},promise(e,t={}){if(!e||typeof e.then!="function"){this._warn("promise expects a Promise");return}const a={id:et()}.id,r=t.timeout;this._enqueue("loading",G(Q({},Tt(t.loading,"Loading...")),{groupId:a,duration:0}));let i=null;r&&(i=setTimeout(()=>{this._enqueue("error",{message:t.timeoutMessage||"Request timeout",groupId:a}),s()},r));const s=()=>{i&&clearTimeout(i)};return e.then(u=>{s(),this._enqueue("success",G(Q({},yt(t.success,u,"Success")),{groupId:a}))}).catch(u=>{s(),this._enqueue("error",G(Q({},yt(t.error,u,"Error")),{groupId:a}))}),{cancel:()=>{this._enqueue("info",{message:t.cancelMessage||"Cancelled",groupId:a}),i&&clearTimeout(i)}}},modal(e={}){var t;if(!E)return;this._defaults.injectCSS!==!1&&ht(this._defaults.css||tt);const a=I({title:"",message:"",html:null,block:!0,blur:!0,closeOnOverlay:!0,closable:!0,animation:"scale",actions:[],theme:this._theme},e),r=z[a.theme]||z.dark,i=document.createElement("div");i.className="jt-modal-overlay",a.block?i.style.pointerEvents="all":i.style.pointerEvents="none",a.blur||(i.style.backdropFilter="none",i.style.webkitBackdropFilter="none");const s=document.createElement("div");if(s.className=`jt-modal jt-anim-${a.animation}`,s.style.background=r.bg,s.style.color=r.color,s.style.border=r.border||"none",a.title){const m=document.createElement("div");m.className="jt-modal-header",m.textContent=a.title,s.appendChild(m)}const u=document.createElement("div");if(u.className="jt-modal-body",a.html?u.innerHTML=$(a.html):u.textContent=a.message||"",s.appendChild(u),(t=a.actions)!=null&&t.length){const m=document.createElement("div");m.className="jt-modal-actions",a.actions.forEach(f=>{const j=document.createElement("button");j.className="jt-modal-btn"+(f.primary?" primary":""),j.textContent=f.label||"OK",j.onclick=S=>{var P;S.stopPropagation(),(P=f.onClick)==null||P.call(f,S),f.closeOnClick!==!1&&p()},m.appendChild(j)}),s.appendChild(m)}i.appendChild(s),document.body.appendChild(i),this._modalStack.push(i),a.block&&(document.body.style.overflow="hidden"),requestAnimationFrame(()=>{i.classList.add("show"),s.classList.add("show")});const b=m=>{m.key==="Escape"&&p()};a.closable&&(a.closeOnOverlay&&i.addEventListener("click",m=>{m.target===i&&p()}),document.addEventListener("keydown",b));const p=()=>{i.classList.remove("show"),s.classList.remove("show"),setTimeout(()=>{try{i.remove()}catch(f){}a.block&&(document.body.style.overflow=""),document.removeEventListener("keydown",b);const m=this._modalStack.indexOf(i);m>=0&&this._modalStack.splice(m,1)},300)};return{close:p}},_registerTypes(){Object.keys(this._config).forEach(e=>{if(typeof this[e]=="function"&&!this[e].__auto)return;const t=a=>this._enqueue(e,a);t.__auto=!0,this[e]=t})},_enqueue(e,t={}){var a,r;const i=typeof t.priority=="number"?t.priority:(r=(a=this._priorityMap)==null?void 0:a[t.priority])!=null?r:2,s=t.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(e,t):void 0);if(s&&this._queueDedupe.has(s)){this._defaults.dev&&console.log("[JuiceToast] deduped (queue)",s);return}const u={id:et(),type:e,payload:t,priority:i};return s&&this._queueDedupe.add(s),this._queue.push(u,i),this._processQueue(),u.id},_processQueue(){var e;if(!E)return;const t=this._defaults.maxVisible;for(;this._queue.size>0;){const a=this._queue.pop();if(!a)break;const r=((e=a.payload)==null?void 0:e.position)||"bottom-right",i=this._getRoot(r);if(!i)break;if(Array.from(i.children).length>=t){this._queue.push(a,a.priority-.001);break}const s=(this._defaults.maxVisiblePerType||{})[a.type];if(typeof s=="number"&&Array.from(i.children).filter(u=>u.dataset.toastType===a.type).length>=s){this._queue.push(a,a.priority-.001);break}this._showToast(a.type,a.payload,a.id)}},_getRoot(e="bottom-right"){if(!E)return null;if(this._roots.has(e))return this._roots.get(e);const t=document.createElement("div");switch(t.id=`juice-toast-root-${e}`,t.dataset.position=e,t.dataset.theme=this._theme,t.style.pointerEvents="none",t.style.display="flex",t.style.flexDirection="column",this._defaults.parallaxMode&&(t.dataset.parallax="true"),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%)";break;default:t.style.bottom="20px",t.style.right="20px"}if(document.body.appendChild(t),this._defaults.parallaxMode){const a=r=>{const i=t.getBoundingClientRect(),s=i.left+i.width/2,u=i.top+i.height/2,b=r.touches?r.touches[0].clientX:r.clientX,p=r.touches?r.touches[0].clientY:r.clientY;Array.from(t.children).forEach((m,f)=>{const j=(f+1)/Math.max(1,t.children.length),S=at((b-s)/i.width*j*8,-12,12),P=at((p-u)/i.height*j*6,-10,10);m.style.setProperty("--jt-parallax-x",`${S}px`),m.style.setProperty("--jt-parallax-y",`${P}px`)})};t._parallaxHandler=a,t.addEventListener("mousemove",a),t.addEventListener("touchmove",a,{passive:!0}),t.dataset.parallax="true"}return this._roots.set(e,t),t},_warn(e){this._defaults.dev&&typeof console!="undefined"&&console.warn("[JuiceToast]",e)},_ensureFA(){if(!(!E||this._faInjected||!this._defaults.autoFetchFA)){if(document.querySelector('link[href*="fontawesome"], link[href*="font-awesome"], link[href*="cdnjs.cloudflare.com/ajax/libs/font-awesome"]')){this._faInjected=!0;return}try{const e=document.createElement("link");e.rel="stylesheet",e.href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css",e.crossOrigin="anonymous",document.head.appendChild(e),this._faInjected=!0}catch(e){console.error("[JuiceToast]: Fetching icons failed:",e)}}},_playSound(e){if(!E)return;const t=typeof e=="string"&&e?e:this._defaults.playSound;if(t)try{const a=new Audio(t);a.volume=.6,a.play().catch(()=>{})}catch(a){}},_updateStackPositionsFor(e){const t=Array.from(e.children);e.dataset.position&&e.dataset.position.includes("bottom"),t.forEach((a,r)=>{const i=r,s=i*12;a.style.setProperty("--jt-stack-y",`-${s}px`),a.style.setProperty("--jt-stack-scale",1-i*.04),a.style.setProperty("--jt-stack-opacity",1-i*.12),a.style.zIndex=1e3-i})},_runPlugins(e){this._plugins.forEach(t=>{try{t(e)}catch(a){this._warn("Plugin error: "+((a==null?void 0:a.message)||a))}})},_normalizeGlass(e){if(e===!0)return 60;if(!e)return 0;const t=Number(e);return Number.isFinite(t)?at(t,0,100):0},_computeDedupeKey(e,t){try{const a=e||"",r=t.title||"",i=t.message||t.html||"";return`${a}::${String(r).trim().slice(0,200)}::${String(i).trim().slice(0,500)}`}catch(a){return}},_showToast(e,t={},a){var r,i,s,u,b,p,m,f,j,S,P,ot,st,nt,rt;if(!E)return;this._defaults.injectCSS!==!1&&ht(this._defaults.css||tt),this._ensureFA();const gt=this._config[e]||{},bt=typeof t=="object"?t:{message:String(t)},o=I(gt,bt);o.icon=(r=o.icon)!=null?r:o.icon_left_top,o.position=(s=(i=o.position)!=null?i:o.toast)!=null?s:"bottom-right",o.closable=(b=(u=o.closable)!=null?u:o.closeable)!=null?b:!0,o.duration=typeof o.duration=="number"?o.duration:this._defaults.duration;const X=z[o.theme||this._theme]||{},x=a||et(),D=o.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(e,o):void 0);if(D)for(const l of this._roots.values()){const c=Array.from(l.children).find(g=>g.dataset.dedupeKey===D);if(c){let g=c.querySelector(".jt-count");if(g||(g=document.createElement("span"),g.className="jt-count",g.style.marginLeft="6px",(p=c.querySelector(".jt-title"))==null||p.appendChild(g),g.textContent="1"),g.textContent=String(parseInt(g.textContent||"1")+1),o.mergeMessage){const v=c.querySelector(".jt-message");v&&(o.html?v.innerHTML=$(o.html):v.textContent=String(o.message||""))}return c.dataset.toastId}}const n=document.createElement("div");if(n.className="juice-toast",n.dataset.toastId=x,n.dataset.position=o.position,n.dataset.toastType=e,D&&(n.dataset.dedupeKey=D),n.tabIndex=0,n.setAttribute("role","status"),n.style.position="relative",n.style.pointerEvents="auto",n.style.background=o.bg||X.bg,n.style.color=o.color||X.color,n.style.border=o.border||X.border||"none",n.style.minHeight=n.style.minHeight||"",n.style.setProperty("--jt-parallax-x","0px"),n.style.setProperty("--jt-parallax-y","0px"),n.style.setProperty("--jt-drag-x","0px"),n.style.setProperty("--jt-drag-y","0px"),n.style.setProperty("--jt-stack-scale","1"),o.size&&ft[o.size]){const l=ft[o.size];l.width&&(n.style.width=l.width),l.padding&&(n.style.padding=l.padding)}const w=document.createElement("div");if(w.className="jt-content",o.title){const l=document.createElement("div");l.className="jt-title",l.textContent=o.title,w.appendChild(l)}const T=document.createElement("div");if(T.className="jt-message",o.html?T.innerHTML=$(o.html):typeof o.message=="string"?o.message.split(/(`[^`]+`)/g).forEach(l=>{if(l.startsWith("`")&&l.endsWith("`")){const c=document.createElement("code");c.textContent=l.slice(1,-1),T.appendChild(c)}else T.appendChild(document.createTextNode(l))}):o.message&&(T.textContent=String(o.message)),w.appendChild(T),Array.isArray(o.actions)&&o.actions.length){const l=document.createElement("div");l.className="jt-actions",o.actions.forEach(c=>{const g=document.createElement("button");g.className="jt-action",g.textContent=c.label||"Action",g.onclick=v=>{var F;v.stopPropagation(),(F=c.onClick)==null||F.call(c,v),c.closeOnClick&&this.remove(x)},l.appendChild(g)}),w.appendChild(l)}o.bgImage?(n.style.backgroundImage=`url(${o.bgImage})`,n.style.backgroundSize=o.bgSize||"cover",n.style.backgroundPosition=o.bgPosition||"center"):n.style.background=o.bg||X.bg;let y=null;if(o.icon){y=document.createElement("i");const l=o.icon.startsWith("fa")?o.icon:`fa-${o.icon}`;if(y.className=["icon",o.iconPack||"",l].join(" ").trim(),o.iconSize&&(y.style.fontSize=o.iconSize),!N){const c=o.iconAnim||Mt[e];c&&y.classList.add(c)}(o.iconLink||o.iconAnimate)&&(y.classList.add("icon-clickable"),y.addEventListener("click",c=>{c.stopPropagation(),o.iconAnimate&&(y.classList.remove(o.iconAnimate),y.offsetWidth,y.classList.add(o.iconAnimate)),o.iconLink&&window.open(o.iconLink,"_blank","noopener")}))}let h=null;if(o.avatar){h=document.createElement("img");const l=typeof o.avatar=="string"&&o.avatar?o.avatar:o.avatarSrc||"";l&&(h.src=l),h.alt=o.avatarAlt||o.title||"avatar",h.className="jt-avatar",h.loading=o.avatarLazy?"lazy":"eager",h.style.width=h.style.width||"36px",h.style.height=h.style.height||"36px",h.style.borderRadius=h.style.borderRadius||"50%",h.style.objectFit=h.style.objectFit||"cover",h.style.flexShrink="0";const c=o.avatarPosition||"left";c==="left"?h.style.marginRight=(m=o.avatarSpacing)!=null?m:"10px":c==="right"?h.style.marginLeft=(f=o.avatarSpacing)!=null?f:"10px":c==="top"&&(h.style.marginBottom=(j=o.avatarSpacing)!=null?j:"8px")}const V=o.avatarPosition||"left";h&&V==="top"?(n.classList.add("jt-avatar-top"),n.style.flexDirection="column",n.style.alignItems="flex-start",n.appendChild(h),y&&o.iconPosition==="top"?(n.appendChild(y),n.appendChild(w)):y&&o.iconPosition==="right"?(n.appendChild(w),n.appendChild(y)):(y&&n.appendChild(y),n.appendChild(w))):(n.style.flexDirection="row",n.style.alignItems="center",h&&V==="left"&&n.appendChild(h),y&&o.iconPosition==="right"?(n.appendChild(w),n.appendChild(y)):y&&o.iconPosition==="top"?(n.classList.add("jt-icon-top"),n.appendChild(y),n.appendChild(w)):(y&&n.appendChild(y),n.appendChild(w)),h&&V==="right"&&n.appendChild(h));let q=null;if(o.progress&&((S=o.duration)!=null?S:this._defaults.duration)>0&&(q=document.createElement("div"),q.className="jt-progress",o.progressColor&&(q.style.background=o.progressColor),n.appendChild(q)),o.undo){const l=document.createElement("button");l.className="jt-action",l.textContent="Undo",l.onclick=()=>{try{o.undo()}catch(c){}this.remove(x)},w.appendChild(l)}if(o.closable){const l=document.createElement("span");l.className="juice-toast-close",l.tabIndex=0,l.textContent="\xD7",l.style.marginLeft="8px",l.addEventListener("click",c=>{c.stopPropagation(),this.remove(x)}),n.appendChild(l)}const C=this._getRoot(o.position||"bottom-right");if(!C)return;if(o.groupId){const l=Array.from(C.children).find(c=>c.dataset.groupId===o.groupId);if(l){let c=l.querySelector(".jt-count");c||(c=document.createElement("span"),c.className="jt-count",c.style.marginLeft="6px",(P=l.querySelector(".jt-title"))==null||P.appendChild(c),c.textContent="1"),c.textContent=String(parseInt(c.textContent||"1")+1);return}n.dataset.groupId=o.groupId}const it=this._defaults.maxVisible;it&&C.children.length>=it&&C.removeChild(C.firstElementChild),C.appendChild(n);const d={id:x,toast:n,cfg:o,type:e,createdAt:_(),remaining:(ot=o.duration)!=null?ot:this._defaults.duration,raf:null,timer:null,start:_(),paused:!1,_boundMove:null,_boundUp:null,_onPointerDown:null,_onEnter:null,_onLeave:null,dedupeKey:D,hooks:{onShow:o.onShow,onShown:o.onShown,onClose:o.onClose,onRemoved:o.onRemoved}};this._activeMap.set(x,d);try{(nt=(st=d.hooks).onShow)==null||nt.call(st,{id:x,toast:n,cfg:o,type:e})}catch(l){}this._runPlugins({toast:n,cfg:o,type:e,root:C,meta:d}),this._updateStackPositionsFor(C),requestAnimationFrame(()=>{var l,c;N?(n.style.opacity="1",(c=(l=d.hooks).onShown)==null||c.call(l,{id:x,toast:n,cfg:o,type:e})):(n.classList.add("show"),setTimeout(()=>{var g,v;try{(v=(g=d.hooks).onShown)==null||v.call(g,{id:x,toast:n,cfg:o,type:e})}catch(F){}},320))});let lt=0,ct=0,L=0,A=0,K=!1,M=null,R=0;const H=l=>{const c=l.touches?l.touches[0]:l;lt=c.clientX,ct=c.clientY,L=0,A=0,K=!0,M=null,d.paused=!0,d.raf&&(cancelAnimationFrame(d.raf),d.raf=null),n.style.transition="none",d._boundMove=xt,d._boundUp=_t,document.addEventListener("touchmove",d._boundMove,{passive:!0}),document.addEventListener("mousemove",d._boundMove),document.addEventListener("touchend",d._boundUp),document.addEventListener("mouseup",d._boundUp),R=_()},xt=l=>{if(!K)return;const c=l.touches?l.touches[0]:l;L=c.clientX-lt,A=c.clientY-ct,M||(Math.abs(L)>6?M="x":Math.abs(A)>6&&(M="y")),M==="x"?n.style.setProperty("--jt-drag-x",`${L}px`):M==="y"&&n.style.setProperty("--jt-drag-y",`${A}px`),R=_(),c.clientX},_t=l=>{K=!1,d.paused=!1;const c=Math.abs(L),g=Math.abs(A),v=M||(c>g?"x":"y"),F=Math.max(1,_()-R),jt=F?L/F*1e3:0,wt=v==="x"&&(c>(k._defaults.swipeThreshold||60)||Math.abs(jt)>800),kt=v==="y"&&g>(k._defaults.swipeThreshold||80);if(wt||kt){const Et=L>=0?1:-1;v==="x"?n.style.setProperty("--jt-drag-x",`${Et*1e3}px`):n.style.setProperty("--jt-drag-y","1000px"),n.classList.add("swipe-dismissing"),setTimeout(()=>this.remove(x),220)}else n.style.transition="transform 0.22s ease-out, opacity 0.22s ease-out",n.style.setProperty("--jt-drag-x","0px"),n.style.setProperty("--jt-drag-y","0px");L=A=0,d._boundMove&&(document.removeEventListener("touchmove",d._boundMove),document.removeEventListener("mousemove",d._boundMove),d._boundMove=null),d._boundUp&&(document.removeEventListener("touchend",d._boundUp),document.removeEventListener("mouseup",d._boundUp),d._boundUp=null),J()};n._onPointerDown=H,n.addEventListener("touchstart",H,{passive:!0}),n.addEventListener("mousedown",H);const W=()=>{d.paused=!0,d.raf&&(cancelAnimationFrame(d.raf),d.raf=null)},B=()=>{d.paused&&(d.paused=!1,d.start=_(),J())};d._onEnter=W,d._onLeave=B,n.addEventListener("mouseenter",W),n.addEventListener("mouseleave",B),n.addEventListener("focusin",W),n.addEventListener("focusout",B);const Y=(rt=o.duration)!=null?rt:this._defaults.duration;function dt(){if(!k._activeMap.has(x))return;if(d.paused){d.raf=null,d.start=_();return}const l=_()-d.start;if(d.remaining-=l,d.start=_(),q){const c=Math.max(0,d.remaining/Y);q.style.transform=`scaleX(${c})`}if(d.remaining<=0){N||n.classList.remove("show"),setTimeout(()=>k.remove(x),280),d.raf=null;return}d.raf=requestAnimationFrame(dt)}const J=()=>{Y<=0||d.raf||d.paused||(d.start=_(),d.raf=requestAnimationFrame(dt))};Y>0&&(d.start=_(),d.remaining=Y,J());const vt=()=>this.remove(x);return o.undoTimeout&&(d.timer=setTimeout(vt,o.undoTimeout)),(o.playSound||this._defaults.playSound)&&this._playSound(o.playSound||this._defaults.playSound),x},remove(e){var t,a,r,i;const s=this._activeMap.get(e);if(!s)return!1;const{toast:u,cfg:b,type:p}=s;try{(a=(t=s.hooks).onClose)==null||a.call(t,{id:e,toast:u,cfg:b,type:p})}catch(f){}N?u.style.opacity="0":u.classList.add("hide");try{u._onPointerDown&&(u.removeEventListener("touchstart",u._onPointerDown),u.removeEventListener("mousedown",u._onPointerDown))}catch(f){}if(s._boundMove){try{document.removeEventListener("touchmove",s._boundMove),document.removeEventListener("mousemove",s._boundMove)}catch(f){}s._boundMove=null}if(s._boundUp){try{document.removeEventListener("touchend",s._boundUp),document.removeEventListener("mouseup",s._boundUp)}catch(f){}s._boundUp=null}try{s._onEnter&&u.removeEventListener("mouseenter",s._onEnter),s._onLeave&&u.removeEventListener("mouseleave",s._onLeave),s._onEnter&&u.removeEventListener("focusin",s._onEnter),s._onLeave&&u.removeEventListener("focusout",s._onLeave)}catch(f){}s.raf&&(cancelAnimationFrame(s.raf),s.raf=null),s.timer&&(clearTimeout(s.timer),s.timer=null),this._activeMap.delete(e);const m=u.parentNode;if(m&&m.removeChild(u),m&&this._updateStackPositionsFor(m),s.dedupeKey)try{this._queueDedupe.delete(s.dedupeKey)}catch(f){}try{(i=(r=s.hooks).onRemoved)==null||i.call(r,{id:e,cfg:b,type:p})}catch(f){}return!0},update(e,t={}){const a=this._activeMap.get(e);if(!a)return this._warn("update: id not found "+e),!1;const{toast:r}=a;if(a.cfg=I(a.cfg,t),a.cfg.title){const u=r.querySelector(".jt-title");u&&(u.textContent=a.cfg.title)}const i=r.querySelector(".jt-message");i&&(a.cfg.html?i.innerHTML=$(a.cfg.html):i.textContent=String(a.cfg.message||""));const s=z[a.cfg.theme||this._theme]||{};return r.style.background=a.cfg.bg||s.bg,r.style.color=a.cfg.color||s.color,r.style.border=a.cfg.border||s.border||"none",a.cfg.duration!==void 0&&(a.remaining=a.cfg.duration,a.start=_(),!a.paused&&!a.raf&&(a.raf=requestAnimationFrame(function u(){var b;if(!k._activeMap.has(e))return;const p=k._activeMap.get(e);if(!p)return;const m=_()-p.start;p.remaining-=m,p.start=_();const f=p.toast.querySelector(".jt-progress");if(f){const j=Math.max(0,p.remaining/((b=p.cfg.duration)!=null?b:k._defaults.duration));f.style.transform=`scaleX(${j})`}if(p.remaining<=0){N||p.toast.classList.remove("show"),setTimeout(()=>k.remove(e),280);return}p.raf=requestAnimationFrame(u)}))),this._runPlugins({toast:r,cfg:a.cfg,type:a.type,meta:a}),!0},_priorityMap:{low:1,normal:2,high:3,urgent:4}};function Tt(e,t){return e?typeof e=="string"?{message:e}:e:{message:t}}function yt(e,t,a){return e?typeof e=="function"?{message:e(t)}:typeof e=="string"?{message:e}:e:{message:a}}k.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",progress:!0,duration:4e3},warning:{icon:"fa-triangle-exclamation",iconPack:"fas",bg:"#f59e0b",progress:!0,duration:4e3},loading:{icon:"fa-spinner",iconPack:"fas",iconAnim:"jt-spin",duration:0,progress:!0}});export{k as default,k as juiceToast};
|
|
80
|
+
`;function gt(e=lt){if(!M||it)return;if(document.getElementById("juice-toast-style")){it=!0;return}const a=document.createElement("style");a.id="juice-toast-style",a.textContent=e,document.head.appendChild(a),it=!0}const ct=(()=>{let e=1;return()=>"jt-"+e++})();function E(){return Date.now()}function H(e,a){return Object.assign({},e||{},a||{})}function D(e,a,t){return Math.max(a,Math.min(t,e))}function A(e,a,t){return e+(a-e)*t}function G(e){if(!e)return"";const a=document.createElement("template");a.innerHTML=e,a.content.querySelectorAll("script, style, iframe").forEach(n=>n.remove());const t=["b","i","u","strong","em","code","pre","ul","ol","li","br","p","span","img","h1","h2","h3","h4","h5","h6","a"];return(function n(u){Array.from(u.childNodes).forEach(o=>{if(o.nodeType===1){const i=o.tagName.toLowerCase();t.includes(i)?(Array.from(o.attributes||[]).forEach(f=>{const p=f.name.toLowerCase(),y=f.value||"";(p.startsWith("on")||(p==="href"||p==="src"||p==="xlink:href")&&y.trim().toLowerCase().startsWith("javascript:")||i==="img"&&p==="srcset")&&o.removeAttribute(f.name)}),n(o)):o.replaceWith(...Array.from(o.childNodes))}})})(a.content),a.innerHTML}const V={dark:{bg:"linear-gradient(180deg,#1f2937,#111827)",color:"#fff",border:"1px solid rgba(255,255,255,.06)"},light:{bg:"#fff",color:"#111",border:"1px solid #e5e7eb"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.1)"}},xt={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},At={success:"jt-bounce",error:"jt-shake",warning:"jt-shake",info:"jt-pulse",loading:"jt-spin"},L={_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,playSound:null,dev:!1,injectCSS:!0,css:null,autoDedupe:!1,maxVisiblePerType:{},parallaxMode:!1,autoFetchFA:!0,use3d:!1,parallaxSmoothing:.12},_config:{},_theme:"dark",_plugins:[],_queue:new W,_queueDedupe:new Set,_activeMap:new Map,_roots:new Map,_modalStack:[],_faInjected:!1,setup(e={}){const a=e,{duration:t,maxVisible:n}=a,u=Mt(a,["duration","maxVisible"]);typeof t=="number"&&(this._defaults.duration=t),typeof n=="number"&&(this._defaults.maxVisible=n),typeof e.autoDedupe=="boolean"&&(this._defaults.autoDedupe=e.autoDedupe),e.maxVisiblePerType&&(this._defaults.maxVisiblePerType=H(this._defaults.maxVisiblePerType,e.maxVisiblePerType)),typeof e.parallaxMode=="boolean"&&(this._defaults.parallaxMode=e.parallaxMode),typeof e.autoFetchFA=="boolean"&&(this._defaults.autoFetchFA=e.autoFetchFA),typeof e.use3d=="boolean"&&(this._defaults.use3d=e.use3d),typeof e.parallaxSmoothing=="number"&&(this._defaults.parallaxSmoothing=D(e.parallaxSmoothing,0,1)),this._config=H(this._config,u),this._registerTypes()},use(e){typeof e=="function"&&this._plugins.push(e)},addType(e,a={}){this._config[e]=a,this._registerTypes()},defineTheme(e,a={}){V[e]=H(V[e]||{},a)},setTheme(e){this._theme=e,M&&this._roots.forEach(a=>a.dataset.theme=e)},clear(){this._queue=new W,this._queueDedupe.clear()},destroy(){this.clear(),M&&(this._roots.forEach(e=>{try{e._parallaxRAF&&cancelAnimationFrame(e._parallaxRAF),e._parallaxHandler&&(e.removeEventListener("mousemove",e._parallaxHandler),e.removeEventListener("touchmove",e._parallaxHandler)),e.remove()}catch(a){}}),this._roots.clear())},promise(e,a={}){if(!e||typeof e.then!="function"){this._warn("promise expects a Promise");return}const t={id:ct()}.id,n=a.timeout;this._enqueue("loading",nt(st({},Tt(a.loading,"Loading...")),{groupId:t,duration:0}));let u=null;n&&(u=setTimeout(()=>{this._enqueue("error",{message:a.timeoutMessage||"Request timeout",groupId:t}),o()},n));const o=()=>{u&&clearTimeout(u)};return e.then(i=>{o(),this._enqueue("success",nt(st({},_t(a.success,i,"Success")),{groupId:t}))}).catch(i=>{o(),this._enqueue("error",nt(st({},_t(a.error,i,"Error")),{groupId:t}))}),{cancel:()=>{this._enqueue("info",{message:a.cancelMessage||"Cancelled",groupId:t}),u&&clearTimeout(u)}}},modal(e={}){var a;if(!M)return;this._defaults.injectCSS!==!1&>(this._defaults.css||lt);const t=H({title:"",message:"",html:null,block:!0,blur:!0,closeOnOverlay:!0,closable:!0,animation:"scale",actions:[],theme:this._theme,use3d:void 0},e),n=t.use3d===void 0?this._defaults.use3d:!!t.use3d,u=V[t.theme]||V.dark,o=document.createElement("div");o.className="jt-modal-overlay",t.block?o.style.pointerEvents="all":o.style.pointerEvents="none",t.blur||(o.style.backdropFilter="none",o.style.webkitBackdropFilter="none");const i=document.createElement("div");if(i.className=`jt-modal jt-anim-${t.animation}`,i.style.background=u.bg,i.style.color=u.color,i.style.border=u.border||"none",n&&(o.style.perspective=o.style.perspective||"900px",i.style.transform="translateY(40px) scale(.96) rotateX(8deg)"),t.title){const m=document.createElement("div");m.className="jt-modal-header",m.textContent=t.title,i.appendChild(m)}const f=document.createElement("div");if(f.className="jt-modal-body",t.html?f.innerHTML=G(t.html):f.textContent=t.message||"",i.appendChild(f),(a=t.actions)!=null&&a.length){const m=document.createElement("div");m.className="jt-modal-actions",t.actions.forEach(v=>{const x=document.createElement("button");x.className="jt-modal-btn"+(v.primary?" primary":""),x.textContent=v.label||"OK",x.onclick=k=>{var h;k.stopPropagation(),(h=v.onClick)==null||h.call(v,k),v.closeOnClick!==!1&&y()},m.appendChild(x)}),i.appendChild(m)}o.appendChild(i),document.body.appendChild(o),this._modalStack.push(o),t.block&&(document.body.style.overflow="hidden"),requestAnimationFrame(()=>{o.classList.add("show"),i.classList.add("show"),n&&(i.style.transform="translateY(0) scale(1) rotateX(0deg)")});const p=m=>{m.key==="Escape"&&y()};t.closable&&(t.closeOnOverlay&&o.addEventListener("click",m=>{m.target===o&&y()}),document.addEventListener("keydown",p));const y=()=>{o.classList.remove("show"),i.classList.remove("show"),n&&(i.style.transform="translateY(40px) scale(.96) rotateX(8deg)"),setTimeout(()=>{try{o.remove()}catch(v){}t.block&&(document.body.style.overflow=""),document.removeEventListener("keydown",p);const m=this._modalStack.indexOf(o);m>=0&&this._modalStack.splice(m,1)},300)};return{close:y}},_registerTypes(){Object.keys(this._config).forEach(e=>{if(typeof this[e]=="function"&&!this[e].__auto)return;const a=t=>this._enqueue(e,t);a.__auto=!0,this[e]=a})},_enqueue(e,a={}){var t,n;const u=typeof a.priority=="number"?a.priority:(n=(t=this._priorityMap)==null?void 0:t[a.priority])!=null?n:2,o=a.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(e,a):void 0);if(o&&this._queueDedupe.has(o)){this._defaults.dev&&console.log("[JuiceToast] deduped (queue)",o);return}const i={id:ct(),type:e,payload:a,priority:u};return o&&this._queueDedupe.add(o),this._queue.push(i,u),this._processQueue(),i.id},_processQueue(){var e;if(!M)return;const a=this._defaults.maxVisible;for(;this._queue.size>0;){const t=this._queue.pop();if(!t)break;const n=((e=t.payload)==null?void 0:e.position)||"bottom-right",u=this._getRoot(n);if(!u)break;if(Array.from(u.children).length>=a){this._queue.push(t,t.priority-.001);break}const o=(this._defaults.maxVisiblePerType||{})[t.type];if(typeof o=="number"&&Array.from(u.children).filter(i=>i.dataset.toastType===t.type).length>=o){this._queue.push(t,t.priority-.001);break}this._showToast(t.type,t.payload,t.id)}},_getRoot(e="bottom-right"){var a;if(!M)return null;if(this._roots.has(e))return this._roots.get(e);const t=document.createElement("div");switch(t.id=`juice-toast-root-${e}`,t.dataset.position=e,t.dataset.theme=this._theme,t.style.pointerEvents="none",t.style.display="flex",t.style.flexDirection="column",this._defaults.parallaxMode&&(t.dataset.parallax="true"),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%)";break;default:t.style.bottom="20px",t.style.right="20px"}if(document.body.appendChild(t),this._defaults.parallaxMode&&!U){const n=(a=this._defaults.parallaxSmoothing)!=null?a:.12,u=i=>{const f=t.getBoundingClientRect(),p=f.left+f.width/2,y=f.top+f.height/2,m=i.touches?i.touches[0].clientX:i.clientX,v=i.touches?i.touches[0].clientY:i.clientY;if(Array.from(t.children).forEach((x,k)=>{const h=(k+1)/Math.max(1,t.children.length),T=D((m-p)/f.width*h*12,-18,18),w=D((v-y)/f.height*h*8,-14,14),S=D(-h*8,-30,0),X=D((m-p)/f.width*h*-6,-12,12),Y=D((v-y)/f.height*h*4,-8,8);x._jtTarget=x._jtTarget||{},x._jtTarget.tx=T,x._jtTarget.ty=w,x._jtTarget.tz=S,x._jtTarget.rotX=Y,x._jtTarget.rotY=X}),!t._parallaxRAF){const x=()=>{let k=!1;Array.from(t.children).forEach((h,T)=>{h._jtPrev=h._jtPrev||{tx:0,ty:0,tz:0,rotX:0,rotY:0};const w=h._jtTarget||{tx:0,ty:0,tz:0,rotX:0,rotY:0},S=h._jtPrev,X=A(S.tx,w.tx||0,n),Y=A(S.ty,w.ty||0,n),r=A(S.tz,w.tz||0,n),z=A(S.rotX,w.rotX||0,n),j=A(S.rotY,w.rotY||0,n);h.style.setProperty("--jt-parallax-x",`${X}px`),h.style.setProperty("--jt-parallax-y",`${Y}px`),h.style.setProperty("--jt-parallax-z",`${r}px`),h.style.setProperty("--jt-rot-x",`${z}deg`),h.style.setProperty("--jt-rot-y",`${j}deg`),h._jtPrev.tx=X,h._jtPrev.ty=Y,h._jtPrev.tz=r,h._jtPrev.rotX=z,h._jtPrev.rotY=j,(Math.abs(X-(w.tx||0))>.1||Math.abs(Y-(w.ty||0))>.1||Math.abs(r-(w.tz||0))>.5||Math.abs(z-(w.rotX||0))>.1||Math.abs(j-(w.rotY||0))>.1)&&(k=!0)}),k?t._parallaxRAF=requestAnimationFrame(x):t._parallaxRAF=null};t._parallaxRAF=requestAnimationFrame(x)}};t._parallaxHandler=u,t.addEventListener("mousemove",u),t.addEventListener("touchmove",u,{passive:!0});const o=()=>{Array.from(t.children).forEach(i=>{i._jtTarget={tx:0,ty:0,tz:0,rotX:0,rotY:0}}),t._parallaxRAF||(t._parallaxRAF=requestAnimationFrame(function i(){let f=!1;Array.from(t.children).forEach(p=>{p._jtPrev=p._jtPrev||{tx:0,ty:0,tz:0,rotX:0,rotY:0};const y=p._jtPrev,m=p._jtTarget||{tx:0,ty:0,tz:0,rotX:0,rotY:0},v=A(y.tx,m.tx||0,.16),x=A(y.ty,m.ty||0,.16),k=A(y.tz,m.tz||0,.16),h=A(y.rotX,m.rotX||0,.16),T=A(y.rotY,m.rotY||0,.16);p.style.setProperty("--jt-parallax-x",`${v}px`),p.style.setProperty("--jt-parallax-y",`${x}px`),p.style.setProperty("--jt-parallax-z",`${k}px`),p.style.setProperty("--jt-rot-x",`${h}deg`),p.style.setProperty("--jt-rot-y",`${T}deg`),p._jtPrev.tx=v,p._jtPrev.ty=x,p._jtPrev.tz=k,p._jtPrev.rotX=h,p._jtPrev.rotY=T,(Math.abs(v)>.5||Math.abs(x)>.5||Math.abs(k)>.5||Math.abs(h)>.5||Math.abs(T)>.5)&&(f=!0)}),f?t._parallaxRAF=requestAnimationFrame(i):t._parallaxRAF=null}))};t.addEventListener("mouseleave",o),t.addEventListener("touchend",o)}return this._roots.set(e,t),t},_warn(e){this._defaults.dev&&typeof console!="undefined"&&console.warn("[JuiceToast]",e)},_ensureFA(){if(!(!M||this._faInjected||!this._defaults.autoFetchFA)){if(document.querySelector('link[href*="fontawesome"], link[href*="font-awesome"], link[href*="cdnjs.cloudflare.com/ajax/libs/font-awesome"]')){this._faInjected=!0;return}try{const e=document.createElement("link");e.rel="stylesheet",e.href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css",e.crossOrigin="anonymous",document.head.appendChild(e),this._faInjected=!0}catch(e){console.error("[JuiceToast]: Fetching icons failed:",e)}}},_playSound(e){if(!M)return;const a=typeof e=="string"&&e?e:this._defaults.playSound;if(a)try{const t=new Audio(a);t.volume=.6,t.play().catch(()=>{})}catch(t){}},_updateStackPositionsFor(e){const a=Array.from(e.children);e.dataset.position&&e.dataset.position.includes("bottom"),a.forEach((t,n)=>{const u=n,o=u*12;t.style.setProperty("--jt-stack-y",`-${o}px`),t.style.setProperty("--jt-stack-scale",1-u*.04),t.style.setProperty("--jt-stack-opacity",1-u*.12),t.style.zIndex=1e3-u,t.style.setProperty("--jt-parallax-z",`${-u*2}px`)})},_runPlugins(e){this._plugins.forEach(a=>{try{a(e)}catch(t){this._warn("Plugin error: "+((t==null?void 0:t.message)||t))}})},_normalizeGlass(e){if(e===!0)return 60;if(!e)return 0;const a=Number(e);return Number.isFinite(a)?D(a,0,100):0},_computeDedupeKey(e,a){try{const t=e||"",n=a.title||"",u=a.message||a.html||"";return`${t}::${String(n).trim().slice(0,200)}::${String(u).trim().slice(0,500)}`}catch(t){return}},_showToast(e,a={},t){var n,u,o,i,f,p,y,m,v,x,k,h,T,w,S;if(!M)return;this._defaults.injectCSS!==!1&>(this._defaults.css||lt),this._ensureFA();const X=this._config[e]||{},Y=typeof a=="object"?a:{message:String(a)},r=H(X,Y);r.icon=(n=r.icon)!=null?n:r.icon_left_top,r.position=(o=(u=r.position)!=null?u:r.toast)!=null?o:"bottom-right",r.closable=(f=(i=r.closable)!=null?i:r.closeable)!=null?f:!0,r.duration=typeof r.duration=="number"?r.duration:this._defaults.duration;const z=V[r.theme||this._theme]||{},j=t||ct(),K=r.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(e,r):void 0);if(K)for(const l of this._roots.values()){const c=Array.from(l.children).find(b=>b.dataset.dedupeKey===K);if(c){let b=c.querySelector(".jt-count");if(b||(b=document.createElement("span"),b.className="jt-count",b.style.marginLeft="6px",(p=c.querySelector(".jt-title"))==null||p.appendChild(b),b.textContent="1"),b.textContent=String(parseInt(b.textContent||"1")+1),r.mergeMessage){const P=c.querySelector(".jt-message");P&&(r.html?P.innerHTML=G(r.html):P.textContent=String(r.message||""))}return c.dataset.toastId}}const s=document.createElement("div");if(s.className="juice-toast",s.dataset.toastId=j,s.dataset.position=r.position,s.dataset.toastType=e,K&&(s.dataset.dedupeKey=K),s.tabIndex=0,s.setAttribute("role","status"),s.style.position="relative",s.style.pointerEvents="auto",s.style.background=r.bg||z.bg,s.style.color=r.color||z.color,s.style.border=r.border||z.border||"none",s.style.minHeight=s.style.minHeight||"",s.style.setProperty("--jt-parallax-x","0px"),s.style.setProperty("--jt-parallax-y","0px"),s.style.setProperty("--jt-parallax-z","0px"),s.style.setProperty("--jt-drag-x","0px"),s.style.setProperty("--jt-drag-y","0px"),s.style.setProperty("--jt-rot-x","0deg"),s.style.setProperty("--jt-rot-y","0deg"),s.style.setProperty("--jt-stack-scale","1"),r.size&&xt[r.size]){const l=xt[r.size];l.width&&(s.style.width=l.width),l.padding&&(s.style.padding=l.padding)}const C=document.createElement("div");if(C.className="jt-content",r.title){const l=document.createElement("div");l.className="jt-title",l.textContent=r.title,C.appendChild(l)}const N=document.createElement("div");if(N.className="jt-message",r.html?N.innerHTML=G(r.html):typeof r.message=="string"?r.message.split(/(`[^`]+`)/g).forEach(l=>{if(l.startsWith("`")&&l.endsWith("`")){const c=document.createElement("code");c.textContent=l.slice(1,-1),N.appendChild(c)}else N.appendChild(document.createTextNode(l))}):r.message&&(N.textContent=String(r.message)),C.appendChild(N),Array.isArray(r.actions)&&r.actions.length){const l=document.createElement("div");l.className="jt-actions",r.actions.forEach(c=>{const b=document.createElement("button");b.className="jt-action",b.textContent=c.label||"Action",b.onclick=P=>{var R;P.stopPropagation(),(R=c.onClick)==null||R.call(c,P),c.closeOnClick&&this.remove(j)},l.appendChild(b)}),C.appendChild(l)}r.bgImage?(s.style.backgroundImage=`url(${r.bgImage})`,s.style.backgroundSize=r.bgSize||"cover",s.style.backgroundPosition=r.bgPosition||"center"):s.style.background=r.bg||z.bg;let _=null;if(r.icon){_=document.createElement("i");const l=r.icon.startsWith("fa")?r.icon:`fa-${r.icon}`;if(_.className=["icon",r.iconPack||"",l].join(" ").trim(),r.iconSize&&(_.style.fontSize=r.iconSize),!U){const c=r.iconAnim||At[e];c&&_.classList.add(c)}(r.iconLink||r.iconAnimate)&&(_.classList.add("icon-clickable"),_.addEventListener("click",c=>{c.stopPropagation(),r.iconAnimate&&(_.classList.remove(r.iconAnimate),_.offsetWidth,_.classList.add(r.iconAnimate)),r.iconLink&&window.open(r.iconLink,"_blank","noopener")}))}let g=null;if(r.avatar){g=document.createElement("img");const l=typeof r.avatar=="string"&&r.avatar?r.avatar:r.avatarSrc||"";l&&(g.src=l),g.alt=r.avatarAlt||r.title||"avatar",g.className="jt-avatar",g.loading=r.avatarLazy?"lazy":"eager",g.style.width=g.style.width||"36px",g.style.height=g.style.height||"36px",g.style.borderRadius=g.style.borderRadius||"50%",g.style.objectFit=g.style.objectFit||"cover",g.style.flexShrink="0";const c=r.avatarPosition||"left";c==="left"?g.style.marginRight=(y=r.avatarSpacing)!=null?y:"10px":c==="right"?g.style.marginLeft=(m=r.avatarSpacing)!=null?m:"10px":c==="top"&&(g.style.marginBottom=(v=r.avatarSpacing)!=null?v:"8px")}const Q=r.avatarPosition||"left";g&&Q==="top"?(s.classList.add("jt-avatar-top"),s.style.flexDirection="column",s.style.alignItems="flex-start",s.appendChild(g),_&&r.iconPosition==="top"?(s.appendChild(_),s.appendChild(C)):_&&r.iconPosition==="right"?(s.appendChild(C),s.appendChild(_)):(_&&s.appendChild(_),s.appendChild(C))):(s.style.flexDirection="row",s.style.alignItems="center",g&&Q==="left"&&s.appendChild(g),_&&r.iconPosition==="right"?(s.appendChild(C),s.appendChild(_)):_&&r.iconPosition==="top"?(s.classList.add("jt-icon-top"),s.appendChild(_),s.appendChild(C)):(_&&s.appendChild(_),s.appendChild(C)),g&&Q==="right"&&s.appendChild(g));let $=null;if(r.progress&&((x=r.duration)!=null?x:this._defaults.duration)>0&&($=document.createElement("div"),$.className="jt-progress",r.progressColor&&($.style.background=r.progressColor),s.appendChild($)),r.undo){const l=document.createElement("button");l.className="jt-action",l.textContent="Undo",l.onclick=()=>{try{r.undo()}catch(c){}this.remove(j)},C.appendChild(l)}if(r.closable){const l=document.createElement("span");l.className="juice-toast-close",l.tabIndex=0,l.textContent="\xD7",l.style.marginLeft="8px",l.addEventListener("click",c=>{c.stopPropagation(),this.remove(j)}),s.appendChild(l)}const q=this._getRoot(r.position||"bottom-right");if(!q)return;if(r.groupId){const l=Array.from(q.children).find(c=>c.dataset.groupId===r.groupId);if(l){let c=l.querySelector(".jt-count");c||(c=document.createElement("span"),c.className="jt-count",c.style.marginLeft="6px",(k=l.querySelector(".jt-title"))==null||k.appendChild(c),c.textContent="1"),c.textContent=String(parseInt(c.textContent||"1")+1);return}s.dataset.groupId=r.groupId}const dt=this._defaults.maxVisible;dt&&q.children.length>=dt&&q.removeChild(q.firstElementChild),q.appendChild(s);const d={id:j,toast:s,cfg:r,type:e,createdAt:E(),remaining:(h=r.duration)!=null?h:this._defaults.duration,raf:null,timer:null,start:E(),paused:!1,_boundMove:null,_boundUp:null,_onPointerDown:null,_onEnter:null,_onLeave:null,dedupeKey:K,hooks:{onShow:r.onShow,onShown:r.onShown,onClose:r.onClose,onRemoved:r.onRemoved}};this._activeMap.set(j,d);try{(w=(T=d.hooks).onShow)==null||w.call(T,{id:j,toast:s,cfg:r,type:e})}catch(l){}this._runPlugins({toast:s,cfg:r,type:e,root:q,meta:d}),this._updateStackPositionsFor(q),requestAnimationFrame(()=>{var l,c;U?(s.style.opacity="1",(c=(l=d.hooks).onShown)==null||c.call(l,{id:j,toast:s,cfg:r,type:e})):(s.classList.add("show"),setTimeout(()=>{var b,P;try{(P=(b=d.hooks).onShown)==null||P.call(b,{id:j,toast:s,cfg:r,type:e})}catch(R){}},320))});let ut=0,pt=0,F=0,O=0,Z=!1,I=null,tt=0;const et=l=>{const c=l.touches?l.touches[0]:l;ut=c.clientX,pt=c.clientY,F=0,O=0,Z=!0,I=null,d.paused=!0,d.raf&&(cancelAnimationFrame(d.raf),d.raf=null),s.style.transition="none",d._boundMove=bt,d._boundUp=vt,document.addEventListener("touchmove",d._boundMove,{passive:!0}),document.addEventListener("mousemove",d._boundMove),document.addEventListener("touchend",d._boundUp),document.addEventListener("mouseup",d._boundUp),tt=E()},bt=l=>{if(!Z)return;const c=l.touches?l.touches[0]:l;F=c.clientX-ut,O=c.clientY-pt,I||(Math.abs(F)>6?I="x":Math.abs(O)>6&&(I="y")),I==="x"?s.style.setProperty("--jt-drag-x",`${F}px`):I==="y"&&s.style.setProperty("--jt-drag-y",`${O}px`),tt=E(),c.clientX},vt=l=>{Z=!1,d.paused=!1;const c=Math.abs(F),b=Math.abs(O),P=I||(c>b?"x":"y"),R=Math.max(1,E()-tt),wt=R?F/R*1e3:0,kt=P==="x"&&(c>(L._defaults.swipeThreshold||60)||Math.abs(wt)>800),Et=P==="y"&&b>(L._defaults.swipeThreshold||80);if(kt||Et){const Pt=F>=0?1:-1;P==="x"?s.style.setProperty("--jt-drag-x",`${Pt*1e3}px`):s.style.setProperty("--jt-drag-y","1000px"),s.classList.add("swipe-dismissing"),setTimeout(()=>this.remove(j),220)}else s.style.transition="transform 0.22s ease-out, opacity 0.22s ease-out",s.style.setProperty("--jt-drag-x","0px"),s.style.setProperty("--jt-drag-y","0px");F=O=0,d._boundMove&&(document.removeEventListener("touchmove",d._boundMove),document.removeEventListener("mousemove",d._boundMove),d._boundMove=null),d._boundUp&&(document.removeEventListener("touchend",d._boundUp),document.removeEventListener("mouseup",d._boundUp),d._boundUp=null),ot()};s._onPointerDown=et,s.addEventListener("touchstart",et,{passive:!0}),s.addEventListener("mousedown",et);const at=()=>{d.paused=!0,d.raf&&(cancelAnimationFrame(d.raf),d.raf=null)},rt=()=>{d.paused&&(d.paused=!1,d.start=E(),ot())};d._onEnter=at,d._onLeave=rt,s.addEventListener("mouseenter",at),s.addEventListener("mouseleave",rt),s.addEventListener("focusin",at),s.addEventListener("focusout",rt);const B=(S=r.duration)!=null?S:this._defaults.duration;function mt(){if(!L._activeMap.has(j))return;if(d.paused){d.raf=null,d.start=E();return}const l=E()-d.start;if(d.remaining-=l,d.start=E(),$){const c=Math.max(0,d.remaining/B);$.style.transform=`scaleX(${c})`}if(d.remaining<=0){U||s.classList.remove("show"),setTimeout(()=>L.remove(j),280),d.raf=null;return}d.raf=requestAnimationFrame(mt)}const ot=()=>{B<=0||d.raf||d.paused||(d.start=E(),d.raf=requestAnimationFrame(mt))};B>0&&(d.start=E(),d.remaining=B,ot());const jt=()=>this.remove(j);return r.undoTimeout&&(d.timer=setTimeout(jt,r.undoTimeout)),(r.playSound||this._defaults.playSound)&&this._playSound(r.playSound||this._defaults.playSound),j},remove(e){var a,t,n,u;const o=this._activeMap.get(e);if(!o)return!1;const{toast:i,cfg:f,type:p}=o;try{(t=(a=o.hooks).onClose)==null||t.call(a,{id:e,toast:i,cfg:f,type:p})}catch(m){}U?i.style.opacity="0":i.classList.add("hide");try{i._onPointerDown&&(i.removeEventListener("touchstart",i._onPointerDown),i.removeEventListener("mousedown",i._onPointerDown))}catch(m){}if(o._boundMove){try{document.removeEventListener("touchmove",o._boundMove),document.removeEventListener("mousemove",o._boundMove)}catch(m){}o._boundMove=null}if(o._boundUp){try{document.removeEventListener("touchend",o._boundUp),document.removeEventListener("mouseup",o._boundUp)}catch(m){}o._boundUp=null}try{o._onEnter&&i.removeEventListener("mouseenter",o._onEnter),o._onLeave&&i.removeEventListener("mouseleave",o._onLeave),o._onEnter&&i.removeEventListener("focusin",o._onEnter),o._onLeave&&i.removeEventListener("focusout",o._onLeave)}catch(m){}o.raf&&(cancelAnimationFrame(o.raf),o.raf=null),o.timer&&(clearTimeout(o.timer),o.timer=null),this._activeMap.delete(e);const y=i.parentNode;if(y&&y.removeChild(i),y&&this._updateStackPositionsFor(y),o.dedupeKey)try{this._queueDedupe.delete(o.dedupeKey)}catch(m){}try{(u=(n=o.hooks).onRemoved)==null||u.call(n,{id:e,cfg:f,type:p})}catch(m){}return!0},update(e,a={}){const t=this._activeMap.get(e);if(!t)return this._warn("update: id not found "+e),!1;const{toast:n}=t;if(t.cfg=H(t.cfg,a),t.cfg.title){const i=n.querySelector(".jt-title");i&&(i.textContent=t.cfg.title)}const u=n.querySelector(".jt-message");u&&(t.cfg.html?u.innerHTML=G(t.cfg.html):u.textContent=String(t.cfg.message||""));const o=V[t.cfg.theme||this._theme]||{};return n.style.background=t.cfg.bg||o.bg,n.style.color=t.cfg.color||o.color,n.style.border=t.cfg.border||o.border||"none",t.cfg.duration!==void 0&&(t.remaining=t.cfg.duration,t.start=E(),!t.paused&&!t.raf&&(t.raf=requestAnimationFrame(function i(){var f;if(!L._activeMap.has(e))return;const p=L._activeMap.get(e);if(!p)return;const y=E()-p.start;p.remaining-=y,p.start=E();const m=p.toast.querySelector(".jt-progress");if(m){const v=Math.max(0,p.remaining/((f=p.cfg.duration)!=null?f:L._defaults.duration));m.style.transform=`scaleX(${v})`}if(p.remaining<=0){U||p.toast.classList.remove("show"),setTimeout(()=>L.remove(e),280);return}p.raf=requestAnimationFrame(i)}))),this._runPlugins({toast:n,cfg:t.cfg,type:t.type,meta:t}),!0},_priorityMap:{low:1,normal:2,high:3,urgent:4}};function Tt(e,a){return e?typeof e=="string"?{message:e}:e:{message:a}}function _t(e,a,t){return e?typeof e=="function"?{message:e(a)}:typeof e=="string"?{message:e}:e:{message:t}}L.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",progress:!0,duration:4e3},warning:{icon:"fa-triangle-exclamation",iconPack:"fas",bg:"#f59e0b",progress:!0,duration:4e3},loading:{icon:"fa-spinner",iconPack:"fas",iconAnim:"jt-spin",duration:0,progress:!0}});export{L as default,L as juiceToast};
|
|
46
81
|
//# sourceMappingURL=juice-toast.esm.js.map
|
package/dist/juice-toast.umd.js
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(X,W){typeof exports=="object"&&typeof module!="undefined"?W(exports):typeof define=="function"&&define.amd?define(["exports"],W):(X=typeof globalThis!="undefined"?globalThis:X||self,W(X.juiceToast={}))})(this,(function(X){"use strict";var W=Object.defineProperty,jt=Object.defineProperties,wt=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,pt=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable,ht=(e,a,t)=>a in e?W(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,tt=(e,a)=>{for(var t in a||(a={}))pt.call(a,t)&&ht(e,t,a[t]);if(G)for(var t of G(a))mt.call(a,t)&&ht(e,t,a[t]);return e},et=(e,a)=>jt(e,wt(a)),kt=(e,a)=>{var t={};for(var n in e)pt.call(e,n)&&a.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&G)for(var n of G(e))a.indexOf(n)<0&&mt.call(e,n)&&(t[n]=e[n]);return t};const M=typeof window!="undefined"&&typeof document!="undefined",$=M&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;class B{constructor(){this._heap=[]}get size(){return this._heap.length}_parent(a){return Math.floor((a-1)/2)}_left(a){return 2*a+1}_right(a){return 2*a+2}_swap(a,t){[this._heap[a],this._heap[t]]=[this._heap[t],this._heap[a]]}push(a,t=0){const n={item:a,priority:t,seq:B._seq=(B._seq||0)+1};this._heap.push(n),this._siftUp(this._heap.length-1)}pop(){if(!this._heap.length)return null;this._swap(0,this._heap.length-1);const a=this._heap.pop();return this._siftDown(0),a.item}peek(){return this._heap[0]?this._heap[0].item:null}_siftUp(a){for(;a>0;){const t=this._parent(a);if(this._compare(a,t)<=0)break;this._swap(a,t),a=t}}_siftDown(a){for(;;){const t=this._left(a),n=this._right(a),u=this._heap.length;let o=a;if(t<u&&this._compare(t,o)>0&&(o=t),n<u&&this._compare(n,o)>0&&(o=n),o===a)break;this._swap(a,o),a=o}}_compare(a,t){const n=this._heap[a],u=this._heap[t];return n.priority!==u.priority?n.priority-u.priority:n.seq-u.seq}}let at=!1;const rt=`
|
|
2
2
|
/* JuiceToast base (extended) */
|
|
3
|
-
#juice-toast-root,[id^="juice-toast-root-"]{position:fixed;z-index:9999;display:flex;pointer-events:none;gap:10px}
|
|
3
|
+
#juice-toast-root,[id^="juice-toast-root-"]{position:fixed;z-index:9999;display:flex;pointer-events:none;gap:10px;perspective:800px}
|
|
4
4
|
#juice-toast-root[data-position="bottom-right"],#juice-toast-root-bottom-right{bottom:20px;right:20px;flex-direction:column-reverse;align-items:flex-end}
|
|
5
5
|
#juice-toast-root[data-position="top-right"]{top:20px;right:20px;flex-direction:column;align-items:flex-end}
|
|
6
6
|
#juice-toast-root[data-position="bottom-left"]{bottom:20px;left:20px;flex-direction:column-reverse;align-items:flex-start}
|
|
7
7
|
#juice-toast-root[data-position="top-left"]{top:20px;left:20px;flex-direction:column;align-items:flex-start}
|
|
8
8
|
#juice-toast-root[data-position="top-center"],#juice-toast-root[data-position="bottom-center"]{left:50%;transform:translateX(-50%)}
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
/* store parallax/3d vars */
|
|
11
|
+
.juice-toast {
|
|
12
|
+
pointer-events:auto;
|
|
13
|
+
min-width:220px;
|
|
14
|
+
max-width:420px;
|
|
15
|
+
padding:12px 16px;
|
|
16
|
+
margin:6px 0;
|
|
17
|
+
border-radius:10px;
|
|
18
|
+
background:linear-gradient(180deg,rgba(30,30,30,.95),rgba(20,20,20,.95));
|
|
19
|
+
color:#fff;
|
|
20
|
+
display:flex;
|
|
21
|
+
gap:12px;
|
|
22
|
+
align-items:flex-start;
|
|
23
|
+
box-sizing:border-box;
|
|
24
|
+
transition: transform 0.25s cubic-bezier(0.4,0,0.2,1), opacity 0.28s ease;
|
|
25
|
+
transform:
|
|
26
|
+
translate3d(var(--jt-parallax-x,0), var(--jt-parallax-y,0), var(--jt-parallax-z,0))
|
|
27
|
+
translateX(var(--jt-drag-x,0))
|
|
28
|
+
translateY(var(--jt-drag-y,0))
|
|
29
|
+
rotateX(var(--jt-rot-x,0))
|
|
30
|
+
rotateY(var(--jt-rot-y,0))
|
|
31
|
+
scale(var(--jt-stack-scale,1));
|
|
32
|
+
transform-style:preserve-3d;
|
|
33
|
+
will-change: transform, opacity;
|
|
34
|
+
}
|
|
10
35
|
@keyframes jt-slide-in{0%{opacity:0;transform:translateY(20px) scale(0.98)}100%{opacity:1;transform:translateY(0) scale(1)}}
|
|
11
36
|
@keyframes jt-slide-out{0%{opacity:1;transform:translateY(0) scale(1)}100%{opacity:0;transform:translateY(20px) scale(0.98)}}
|
|
12
37
|
@keyframes jt-bounce{0%{transform:translateY(0)}25%{transform:translateY(-6px)}50%{transform:translateY(0)}75%{transform:translateY(-3px)}100%{transform:translateY(0)}}
|
|
@@ -33,8 +58,18 @@
|
|
|
33
58
|
position:fixed;inset:0;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(15,23,42,.55);backdrop-filter:blur(6px) saturate(120%);-webkit-backdrop-filter:blur(6px) saturate(120%);opacity:0;transition:opacity .25s ease;z-index:10000;
|
|
34
59
|
}
|
|
35
60
|
.jt-modal-overlay.show{opacity:1}
|
|
36
|
-
.jt-modal{
|
|
37
|
-
|
|
61
|
+
.jt-modal{
|
|
62
|
+
width:100%;
|
|
63
|
+
max-width:520px;
|
|
64
|
+
border-radius:18px;
|
|
65
|
+
padding:24px;
|
|
66
|
+
opacity:0;
|
|
67
|
+
transform:translateY(40px) scale(.96) rotateX(6deg);
|
|
68
|
+
transition:transform .35s cubic-bezier(.16,1,.3,1),opacity .25s ease;
|
|
69
|
+
transform-style:preserve-3d;
|
|
70
|
+
will-change:transform,opacity;
|
|
71
|
+
}
|
|
72
|
+
.jt-modal.show{opacity:1;transform:translateY(0) scale(1) rotateX(0deg)}
|
|
38
73
|
.jt-modal-header{font-size:18px;font-weight:600;letter-spacing:.3px;margin-bottom:10px}
|
|
39
74
|
.jt-modal-body{font-size:14.5px;line-height:1.6;opacity:.85;margin-bottom:22px}
|
|
40
75
|
.jt-modal-actions{display:flex;justify-content:flex-end;gap:12px}
|
|
@@ -42,5 +77,5 @@
|
|
|
42
77
|
.jt-modal-btn:hover{background:rgba(255,255,255,.08);transform:translateY(-1px)}
|
|
43
78
|
.jt-modal-btn.primary{background:#6366f1;border-color:#6366f1;color:#fff}
|
|
44
79
|
#juice-toast-root[data-parallax="true"] .juice-toast{transition: transform 0.12s cubic-bezier(.2,.8,.2,1), opacity .2s}
|
|
45
|
-
`;function le(t=B){if(!E||W)return;if(document.getElementById("juice-toast-style")){W=!0;return}const e=document.createElement("style");e.id="juice-toast-style",e.textContent=t,document.head.appendChild(e),W=!0}const J=(()=>{let t=1;return()=>"jt-"+t++})();function x(){return Date.now()}function q(t,e){return Object.assign({},t||{},e||{})}function Q(t,e,o){return Math.max(e,Math.min(o,t))}function $(t){if(!t)return"";const e=document.createElement("template");e.innerHTML=t,e.content.querySelectorAll("script, style, iframe").forEach(r=>r.remove());const o=["b","i","u","strong","em","code","pre","ul","ol","li","br","p","span","img","h1","h2","h3","h4","h5","h6","a"];return(function r(i){Array.from(i.childNodes).forEach(n=>{if(n.nodeType===1){const u=n.tagName.toLowerCase();o.includes(u)?(Array.from(n.attributes||[]).forEach(b=>{const p=b.name.toLowerCase(),m=b.value||"";(p.startsWith("on")||(p==="href"||p==="src"||p==="xlink:href")&&m.trim().toLowerCase().startsWith("javascript:")||u==="img"&&p==="srcset")&&n.removeAttribute(b.name)}),r(n)):n.replaceWith(...Array.from(n.childNodes))}})})(e.content),e.innerHTML}const A={dark:{bg:"linear-gradient(180deg,#1f2937,#111827)",color:"#fff",border:"1px solid rgba(255,255,255,.06)"},light:{bg:"#fff",color:"#111",border:"1px solid #e5e7eb"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.1)"}},ce={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},je={success:"jt-bounce",error:"jt-shake",warning:"jt-shake",info:"jt-pulse",loading:"jt-spin"},w={_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,playSound:null,dev:!1,injectCSS:!0,css:null,autoDedupe:!1,maxVisiblePerType:{},parallaxMode:!1,autoFetchFA:!0},_config:{},_theme:"dark",_plugins:[],_queue:new X,_queueDedupe:new Set,_activeMap:new Map,_roots:new Map,_modalStack:[],_faInjected:!1,setup(t={}){const e=t,{duration:o,maxVisible:r}=e,i=ve(e,["duration","maxVisible"]);typeof o=="number"&&(this._defaults.duration=o),typeof r=="number"&&(this._defaults.maxVisible=r),typeof t.autoDedupe=="boolean"&&(this._defaults.autoDedupe=t.autoDedupe),t.maxVisiblePerType&&(this._defaults.maxVisiblePerType=q(this._defaults.maxVisiblePerType,t.maxVisiblePerType)),typeof t.parallaxMode=="boolean"&&(this._defaults.parallaxMode=t.parallaxMode),typeof t.autoFetchFA=="boolean"&&(this._defaults.autoFetchFA=t.autoFetchFA),this._config=q(this._config,i),this._registerTypes()},use(t){typeof t=="function"&&this._plugins.push(t)},addType(t,e={}){this._config[t]=e,this._registerTypes()},defineTheme(t,e={}){A[t]=q(A[t]||{},e)},setTheme(t){this._theme=t,E&&this._roots.forEach(e=>e.dataset.theme=t)},clear(){this._queue=new X,this._queueDedupe.clear()},destroy(){this.clear(),E&&(this._roots.forEach(t=>{try{t.remove()}catch(e){}}),this._roots.clear())},promise(t,e={}){if(!t||typeof t.then!="function"){this._warn("promise expects a Promise");return}const o={id:J()}.id,r=e.timeout;this._enqueue("loading",H(R({},we(e.loading,"Loading...")),{groupId:o,duration:0}));let i=null;r&&(i=setTimeout(()=>{this._enqueue("error",{message:e.timeoutMessage||"Request timeout",groupId:o}),n()},r));const n=()=>{i&&clearTimeout(i)};return t.then(u=>{n(),this._enqueue("success",H(R({},de(e.success,u,"Success")),{groupId:o}))}).catch(u=>{n(),this._enqueue("error",H(R({},de(e.error,u,"Error")),{groupId:o}))}),{cancel:()=>{this._enqueue("info",{message:e.cancelMessage||"Cancelled",groupId:o}),i&&clearTimeout(i)}}},modal(t={}){var e;if(!E)return;this._defaults.injectCSS!==!1&&le(this._defaults.css||B);const o=q({title:"",message:"",html:null,block:!0,blur:!0,closeOnOverlay:!0,closable:!0,animation:"scale",actions:[],theme:this._theme},t),r=A[o.theme]||A.dark,i=document.createElement("div");i.className="jt-modal-overlay",o.block?i.style.pointerEvents="all":i.style.pointerEvents="none",o.blur||(i.style.backdropFilter="none",i.style.webkitBackdropFilter="none");const n=document.createElement("div");if(n.className=`jt-modal jt-anim-${o.animation}`,n.style.background=r.bg,n.style.color=r.color,n.style.border=r.border||"none",o.title){const m=document.createElement("div");m.className="jt-modal-header",m.textContent=o.title,n.appendChild(m)}const u=document.createElement("div");if(u.className="jt-modal-body",o.html?u.innerHTML=$(o.html):u.textContent=o.message||"",n.appendChild(u),(e=o.actions)!=null&&e.length){const m=document.createElement("div");m.className="jt-modal-actions",o.actions.forEach(f=>{const j=document.createElement("button");j.className="jt-modal-btn"+(f.primary?" primary":""),j.textContent=f.label||"OK",j.onclick=S=>{var M;S.stopPropagation(),(M=f.onClick)==null||M.call(f,S),f.closeOnClick!==!1&&p()},m.appendChild(j)}),n.appendChild(m)}i.appendChild(n),document.body.appendChild(i),this._modalStack.push(i),o.block&&(document.body.style.overflow="hidden"),requestAnimationFrame(()=>{i.classList.add("show"),n.classList.add("show")});const b=m=>{m.key==="Escape"&&p()};o.closable&&(o.closeOnOverlay&&i.addEventListener("click",m=>{m.target===i&&p()}),document.addEventListener("keydown",b));const p=()=>{i.classList.remove("show"),n.classList.remove("show"),setTimeout(()=>{try{i.remove()}catch(f){}o.block&&(document.body.style.overflow=""),document.removeEventListener("keydown",b);const m=this._modalStack.indexOf(i);m>=0&&this._modalStack.splice(m,1)},300)};return{close:p}},_registerTypes(){Object.keys(this._config).forEach(t=>{if(typeof this[t]=="function"&&!this[t].__auto)return;const e=o=>this._enqueue(t,o);e.__auto=!0,this[t]=e})},_enqueue(t,e={}){var o,r;const i=typeof e.priority=="number"?e.priority:(r=(o=this._priorityMap)==null?void 0:o[e.priority])!=null?r:2,n=e.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(t,e):void 0);if(n&&this._queueDedupe.has(n)){this._defaults.dev&&console.log("[JuiceToast] deduped (queue)",n);return}const u={id:J(),type:t,payload:e,priority:i};return n&&this._queueDedupe.add(n),this._queue.push(u,i),this._processQueue(),u.id},_processQueue(){var t;if(!E)return;const e=this._defaults.maxVisible;for(;this._queue.size>0;){const o=this._queue.pop();if(!o)break;const r=((t=o.payload)==null?void 0:t.position)||"bottom-right",i=this._getRoot(r);if(!i)break;if(Array.from(i.children).length>=e){this._queue.push(o,o.priority-.001);break}const n=(this._defaults.maxVisiblePerType||{})[o.type];if(typeof n=="number"&&Array.from(i.children).filter(u=>u.dataset.toastType===o.type).length>=n){this._queue.push(o,o.priority-.001);break}this._showToast(o.type,o.payload,o.id)}},_getRoot(t="bottom-right"){if(!E)return null;if(this._roots.has(t))return this._roots.get(t);const e=document.createElement("div");switch(e.id=`juice-toast-root-${t}`,e.dataset.position=t,e.dataset.theme=this._theme,e.style.pointerEvents="none",e.style.display="flex",e.style.flexDirection="column",this._defaults.parallaxMode&&(e.dataset.parallax="true"),t){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%)";break;default:e.style.bottom="20px",e.style.right="20px"}if(document.body.appendChild(e),this._defaults.parallaxMode){const o=r=>{const i=e.getBoundingClientRect(),n=i.left+i.width/2,u=i.top+i.height/2,b=r.touches?r.touches[0].clientX:r.clientX,p=r.touches?r.touches[0].clientY:r.clientY;Array.from(e.children).forEach((m,f)=>{const j=(f+1)/Math.max(1,e.children.length),S=Q((b-n)/i.width*j*8,-12,12),M=Q((p-u)/i.height*j*6,-10,10);m.style.setProperty("--jt-parallax-x",`${S}px`),m.style.setProperty("--jt-parallax-y",`${M}px`)})};e._parallaxHandler=o,e.addEventListener("mousemove",o),e.addEventListener("touchmove",o,{passive:!0}),e.dataset.parallax="true"}return this._roots.set(t,e),e},_warn(t){this._defaults.dev&&typeof console!="undefined"&&console.warn("[JuiceToast]",t)},_ensureFA(){if(!(!E||this._faInjected||!this._defaults.autoFetchFA)){if(document.querySelector('link[href*="fontawesome"], link[href*="font-awesome"], link[href*="cdnjs.cloudflare.com/ajax/libs/font-awesome"]')){this._faInjected=!0;return}try{const t=document.createElement("link");t.rel="stylesheet",t.href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css",t.crossOrigin="anonymous",document.head.appendChild(t),this._faInjected=!0}catch(t){console.error("[JuiceToast]: Fetching icons failed:",t)}}},_playSound(t){if(!E)return;const e=typeof t=="string"&&t?t:this._defaults.playSound;if(e)try{const o=new Audio(e);o.volume=.6,o.play().catch(()=>{})}catch(o){}},_updateStackPositionsFor(t){const e=Array.from(t.children);t.dataset.position&&t.dataset.position.includes("bottom"),e.forEach((o,r)=>{const i=r,n=i*12;o.style.setProperty("--jt-stack-y",`-${n}px`),o.style.setProperty("--jt-stack-scale",1-i*.04),o.style.setProperty("--jt-stack-opacity",1-i*.12),o.style.zIndex=1e3-i})},_runPlugins(t){this._plugins.forEach(e=>{try{e(t)}catch(o){this._warn("Plugin error: "+((o==null?void 0:o.message)||o))}})},_normalizeGlass(t){if(t===!0)return 60;if(!t)return 0;const e=Number(t);return Number.isFinite(e)?Q(e,0,100):0},_computeDedupeKey(t,e){try{const o=t||"",r=e.title||"",i=e.message||e.html||"";return`${o}::${String(r).trim().slice(0,200)}::${String(i).trim().slice(0,500)}`}catch(o){return}},_showToast(t,e={},o){var r,i,n,u,b,p,m,f,j,S,M,ue,pe,me,he;if(!E)return;this._defaults.injectCSS!==!1&&le(this._defaults.css||B),this._ensureFA();const ke=this._config[t]||{},Ee=typeof e=="object"?e:{message:String(e)},a=q(ke,Ee);a.icon=(r=a.icon)!=null?r:a.icon_left_top,a.position=(n=(i=a.position)!=null?i:a.toast)!=null?n:"bottom-right",a.closable=(b=(u=a.closable)!=null?u:a.closeable)!=null?b:!0,a.duration=typeof a.duration=="number"?a.duration:this._defaults.duration;const V=A[a.theme||this._theme]||{},_=o||J(),Y=a.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(t,a):void 0);if(Y)for(const l of this._roots.values()){const c=Array.from(l.children).find(g=>g.dataset.dedupeKey===Y);if(c){let g=c.querySelector(".jt-count");if(g||(g=document.createElement("span"),g.className="jt-count",g.style.marginLeft="6px",(p=c.querySelector(".jt-title"))==null||p.appendChild(g),g.textContent="1"),g.textContent=String(parseInt(g.textContent||"1")+1),a.mergeMessage){const v=c.querySelector(".jt-message");v&&(a.html?v.innerHTML=$(a.html):v.textContent=String(a.message||""))}return c.dataset.toastId}}const s=document.createElement("div");if(s.className="juice-toast",s.dataset.toastId=_,s.dataset.position=a.position,s.dataset.toastType=t,Y&&(s.dataset.dedupeKey=Y),s.tabIndex=0,s.setAttribute("role","status"),s.style.position="relative",s.style.pointerEvents="auto",s.style.background=a.bg||V.bg,s.style.color=a.color||V.color,s.style.border=a.border||V.border||"none",s.style.minHeight=s.style.minHeight||"",s.style.setProperty("--jt-parallax-x","0px"),s.style.setProperty("--jt-parallax-y","0px"),s.style.setProperty("--jt-drag-x","0px"),s.style.setProperty("--jt-drag-y","0px"),s.style.setProperty("--jt-stack-scale","1"),a.size&&ce[a.size]){const l=ce[a.size];l.width&&(s.style.width=l.width),l.padding&&(s.style.padding=l.padding)}const k=document.createElement("div");if(k.className="jt-content",a.title){const l=document.createElement("div");l.className="jt-title",l.textContent=a.title,k.appendChild(l)}const F=document.createElement("div");if(F.className="jt-message",a.html?F.innerHTML=$(a.html):typeof a.message=="string"?a.message.split(/(`[^`]+`)/g).forEach(l=>{if(l.startsWith("`")&&l.endsWith("`")){const c=document.createElement("code");c.textContent=l.slice(1,-1),F.appendChild(c)}else F.appendChild(document.createTextNode(l))}):a.message&&(F.textContent=String(a.message)),k.appendChild(F),Array.isArray(a.actions)&&a.actions.length){const l=document.createElement("div");l.className="jt-actions",a.actions.forEach(c=>{const g=document.createElement("button");g.className="jt-action",g.textContent=c.label||"Action",g.onclick=v=>{var D;v.stopPropagation(),(D=c.onClick)==null||D.call(c,v),c.closeOnClick&&this.remove(_)},l.appendChild(g)}),k.appendChild(l)}a.bgImage?(s.style.backgroundImage=`url(${a.bgImage})`,s.style.backgroundSize=a.bgSize||"cover",s.style.backgroundPosition=a.bgPosition||"center"):s.style.background=a.bg||V.bg;let y=null;if(a.icon){y=document.createElement("i");const l=a.icon.startsWith("fa")?a.icon:`fa-${a.icon}`;if(y.className=["icon",a.iconPack||"",l].join(" ").trim(),a.iconSize&&(y.style.fontSize=a.iconSize),!O){const c=a.iconAnim||je[t];c&&y.classList.add(c)}(a.iconLink||a.iconAnimate)&&(y.classList.add("icon-clickable"),y.addEventListener("click",c=>{c.stopPropagation(),a.iconAnimate&&(y.classList.remove(a.iconAnimate),y.offsetWidth,y.classList.add(a.iconAnimate)),a.iconLink&&window.open(a.iconLink,"_blank","noopener")}))}let h=null;if(a.avatar){h=document.createElement("img");const l=typeof a.avatar=="string"&&a.avatar?a.avatar:a.avatarSrc||"";l&&(h.src=l),h.alt=a.avatarAlt||a.title||"avatar",h.className="jt-avatar",h.loading=a.avatarLazy?"lazy":"eager",h.style.width=h.style.width||"36px",h.style.height=h.style.height||"36px",h.style.borderRadius=h.style.borderRadius||"50%",h.style.objectFit=h.style.objectFit||"cover",h.style.flexShrink="0";const c=a.avatarPosition||"left";c==="left"?h.style.marginRight=(m=a.avatarSpacing)!=null?m:"10px":c==="right"?h.style.marginLeft=(f=a.avatarSpacing)!=null?f:"10px":c==="top"&&(h.style.marginBottom=(j=a.avatarSpacing)!=null?j:"8px")}const G=a.avatarPosition||"left";h&&G==="top"?(s.classList.add("jt-avatar-top"),s.style.flexDirection="column",s.style.alignItems="flex-start",s.appendChild(h),y&&a.iconPosition==="top"?(s.appendChild(y),s.appendChild(k)):y&&a.iconPosition==="right"?(s.appendChild(k),s.appendChild(y)):(y&&s.appendChild(y),s.appendChild(k))):(s.style.flexDirection="row",s.style.alignItems="center",h&&G==="left"&&s.appendChild(h),y&&a.iconPosition==="right"?(s.appendChild(k),s.appendChild(y)):y&&a.iconPosition==="top"?(s.classList.add("jt-icon-top"),s.appendChild(y),s.appendChild(k)):(y&&s.appendChild(y),s.appendChild(k)),h&&G==="right"&&s.appendChild(h));let I=null;if(a.progress&&((S=a.duration)!=null?S:this._defaults.duration)>0&&(I=document.createElement("div"),I.className="jt-progress",a.progressColor&&(I.style.background=a.progressColor),s.appendChild(I)),a.undo){const l=document.createElement("button");l.className="jt-action",l.textContent="Undo",l.onclick=()=>{try{a.undo()}catch(c){}this.remove(_)},k.appendChild(l)}if(a.closable){const l=document.createElement("span");l.className="juice-toast-close",l.tabIndex=0,l.textContent="\xD7",l.style.marginLeft="8px",l.addEventListener("click",c=>{c.stopPropagation(),this.remove(_)}),s.appendChild(l)}const C=this._getRoot(a.position||"bottom-right");if(!C)return;if(a.groupId){const l=Array.from(C.children).find(c=>c.dataset.groupId===a.groupId);if(l){let c=l.querySelector(".jt-count");c||(c=document.createElement("span"),c.className="jt-count",c.style.marginLeft="6px",(M=l.querySelector(".jt-title"))==null||M.appendChild(c),c.textContent="1"),c.textContent=String(parseInt(c.textContent||"1")+1);return}s.dataset.groupId=a.groupId}const fe=this._defaults.maxVisible;fe&&C.children.length>=fe&&C.removeChild(C.firstElementChild),C.appendChild(s);const d={id:_,toast:s,cfg:a,type:t,createdAt:x(),remaining:(ue=a.duration)!=null?ue:this._defaults.duration,raf:null,timer:null,start:x(),paused:!1,_boundMove:null,_boundUp:null,_onPointerDown:null,_onEnter:null,_onLeave:null,dedupeKey:Y,hooks:{onShow:a.onShow,onShown:a.onShown,onClose:a.onClose,onRemoved:a.onRemoved}};this._activeMap.set(_,d);try{(me=(pe=d.hooks).onShow)==null||me.call(pe,{id:_,toast:s,cfg:a,type:t})}catch(l){}this._runPlugins({toast:s,cfg:a,type:t,root:C,meta:d}),this._updateStackPositionsFor(C),requestAnimationFrame(()=>{var l,c;O?(s.style.opacity="1",(c=(l=d.hooks).onShown)==null||c.call(l,{id:_,toast:s,cfg:a,type:t})):(s.classList.add("show"),setTimeout(()=>{var g,v;try{(v=(g=d.hooks).onShown)==null||v.call(g,{id:_,toast:s,cfg:a,type:t})}catch(D){}},320))});let ye=0,ge=0,L=0,z=0,Z=!1,T=null,ee=0;const te=l=>{const c=l.touches?l.touches[0]:l;ye=c.clientX,ge=c.clientY,L=0,z=0,Z=!0,T=null,d.paused=!0,d.raf&&(cancelAnimationFrame(d.raf),d.raf=null),s.style.transition="none",d._boundMove=Ce,d._boundUp=Le,document.addEventListener("touchmove",d._boundMove,{passive:!0}),document.addEventListener("mousemove",d._boundMove),document.addEventListener("touchend",d._boundUp),document.addEventListener("mouseup",d._boundUp),ee=x()},Ce=l=>{if(!Z)return;const c=l.touches?l.touches[0]:l;L=c.clientX-ye,z=c.clientY-ge,T||(Math.abs(L)>6?T="x":Math.abs(z)>6&&(T="y")),T==="x"?s.style.setProperty("--jt-drag-x",`${L}px`):T==="y"&&s.style.setProperty("--jt-drag-y",`${z}px`),ee=x(),c.clientX},Le=l=>{Z=!1,d.paused=!1;const c=Math.abs(L),g=Math.abs(z),v=T||(c>g?"x":"y"),D=Math.max(1,x()-ee),Se=D?L/D*1e3:0,Me=v==="x"&&(c>(w._defaults.swipeThreshold||60)||Math.abs(Se)>800),Te=v==="y"&&g>(w._defaults.swipeThreshold||80);if(Me||Te){const qe=L>=0?1:-1;v==="x"?s.style.setProperty("--jt-drag-x",`${qe*1e3}px`):s.style.setProperty("--jt-drag-y","1000px"),s.classList.add("swipe-dismissing"),setTimeout(()=>this.remove(_),220)}else s.style.transition="transform 0.22s ease-out, opacity 0.22s ease-out",s.style.setProperty("--jt-drag-x","0px"),s.style.setProperty("--jt-drag-y","0px");L=z=0,d._boundMove&&(document.removeEventListener("touchmove",d._boundMove),document.removeEventListener("mousemove",d._boundMove),d._boundMove=null),d._boundUp&&(document.removeEventListener("touchend",d._boundUp),document.removeEventListener("mouseup",d._boundUp),d._boundUp=null),ne()};s._onPointerDown=te,s.addEventListener("touchstart",te,{passive:!0}),s.addEventListener("mousedown",te);const oe=()=>{d.paused=!0,d.raf&&(cancelAnimationFrame(d.raf),d.raf=null)},ae=()=>{d.paused&&(d.paused=!1,d.start=x(),ne())};d._onEnter=oe,d._onLeave=ae,s.addEventListener("mouseenter",oe),s.addEventListener("mouseleave",ae),s.addEventListener("focusin",oe),s.addEventListener("focusout",ae);const K=(he=a.duration)!=null?he:this._defaults.duration;function be(){if(!w._activeMap.has(_))return;if(d.paused){d.raf=null,d.start=x();return}const l=x()-d.start;if(d.remaining-=l,d.start=x(),I){const c=Math.max(0,d.remaining/K);I.style.transform=`scaleX(${c})`}if(d.remaining<=0){O||s.classList.remove("show"),setTimeout(()=>w.remove(_),280),d.raf=null;return}d.raf=requestAnimationFrame(be)}const ne=()=>{K<=0||d.raf||d.paused||(d.start=x(),d.raf=requestAnimationFrame(be))};K>0&&(d.start=x(),d.remaining=K,ne());const Pe=()=>this.remove(_);return a.undoTimeout&&(d.timer=setTimeout(Pe,a.undoTimeout)),(a.playSound||this._defaults.playSound)&&this._playSound(a.playSound||this._defaults.playSound),_},remove(t){var e,o,r,i;const n=this._activeMap.get(t);if(!n)return!1;const{toast:u,cfg:b,type:p}=n;try{(o=(e=n.hooks).onClose)==null||o.call(e,{id:t,toast:u,cfg:b,type:p})}catch(f){}O?u.style.opacity="0":u.classList.add("hide");try{u._onPointerDown&&(u.removeEventListener("touchstart",u._onPointerDown),u.removeEventListener("mousedown",u._onPointerDown))}catch(f){}if(n._boundMove){try{document.removeEventListener("touchmove",n._boundMove),document.removeEventListener("mousemove",n._boundMove)}catch(f){}n._boundMove=null}if(n._boundUp){try{document.removeEventListener("touchend",n._boundUp),document.removeEventListener("mouseup",n._boundUp)}catch(f){}n._boundUp=null}try{n._onEnter&&u.removeEventListener("mouseenter",n._onEnter),n._onLeave&&u.removeEventListener("mouseleave",n._onLeave),n._onEnter&&u.removeEventListener("focusin",n._onEnter),n._onLeave&&u.removeEventListener("focusout",n._onLeave)}catch(f){}n.raf&&(cancelAnimationFrame(n.raf),n.raf=null),n.timer&&(clearTimeout(n.timer),n.timer=null),this._activeMap.delete(t);const m=u.parentNode;if(m&&m.removeChild(u),m&&this._updateStackPositionsFor(m),n.dedupeKey)try{this._queueDedupe.delete(n.dedupeKey)}catch(f){}try{(i=(r=n.hooks).onRemoved)==null||i.call(r,{id:t,cfg:b,type:p})}catch(f){}return!0},update(t,e={}){const o=this._activeMap.get(t);if(!o)return this._warn("update: id not found "+t),!1;const{toast:r}=o;if(o.cfg=q(o.cfg,e),o.cfg.title){const u=r.querySelector(".jt-title");u&&(u.textContent=o.cfg.title)}const i=r.querySelector(".jt-message");i&&(o.cfg.html?i.innerHTML=$(o.cfg.html):i.textContent=String(o.cfg.message||""));const n=A[o.cfg.theme||this._theme]||{};return r.style.background=o.cfg.bg||n.bg,r.style.color=o.cfg.color||n.color,r.style.border=o.cfg.border||n.border||"none",o.cfg.duration!==void 0&&(o.remaining=o.cfg.duration,o.start=x(),!o.paused&&!o.raf&&(o.raf=requestAnimationFrame(function u(){var b;if(!w._activeMap.has(t))return;const p=w._activeMap.get(t);if(!p)return;const m=x()-p.start;p.remaining-=m,p.start=x();const f=p.toast.querySelector(".jt-progress");if(f){const j=Math.max(0,p.remaining/((b=p.cfg.duration)!=null?b:w._defaults.duration));f.style.transform=`scaleX(${j})`}if(p.remaining<=0){O||p.toast.classList.remove("show"),setTimeout(()=>w.remove(t),280);return}p.raf=requestAnimationFrame(u)}))),this._runPlugins({toast:r,cfg:o.cfg,type:o.type,meta:o}),!0},_priorityMap:{low:1,normal:2,high:3,urgent:4}};function we(t,e){return t?typeof t=="string"?{message:t}:t:{message:e}}function de(t,e,o){return t?typeof t=="function"?{message:t(e)}:typeof t=="string"?{message:t}:t:{message:o}}w.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",progress:!0,duration:4e3},warning:{icon:"fa-triangle-exclamation",iconPack:"fas",bg:"#f59e0b",progress:!0,duration:4e3},loading:{icon:"fa-spinner",iconPack:"fas",iconAnim:"jt-spin",duration:0,progress:!0}}),P.default=w,P.juiceToast=w,Object.defineProperty(P,"__esModule",{value:!0})}));
|
|
80
|
+
`;function ft(e=rt){if(!M||at)return;if(document.getElementById("juice-toast-style")){at=!0;return}const a=document.createElement("style");a.id="juice-toast-style",a.textContent=e,document.head.appendChild(a),at=!0}const ot=(()=>{let e=1;return()=>"jt-"+e++})();function k(){return Date.now()}function O(e,a){return Object.assign({},e||{},a||{})}function Y(e,a,t){return Math.max(a,Math.min(t,e))}function S(e,a,t){return e+(a-e)*t}function Q(e){if(!e)return"";const a=document.createElement("template");a.innerHTML=e,a.content.querySelectorAll("script, style, iframe").forEach(n=>n.remove());const t=["b","i","u","strong","em","code","pre","ul","ol","li","br","p","span","img","h1","h2","h3","h4","h5","h6","a"];return(function n(u){Array.from(u.childNodes).forEach(o=>{if(o.nodeType===1){const i=o.tagName.toLowerCase();t.includes(i)?(Array.from(o.attributes||[]).forEach(f=>{const p=f.name.toLowerCase(),y=f.value||"";(p.startsWith("on")||(p==="href"||p==="src"||p==="xlink:href")&&y.trim().toLowerCase().startsWith("javascript:")||i==="img"&&p==="srcset")&&o.removeAttribute(f.name)}),n(o)):o.replaceWith(...Array.from(o.childNodes))}})})(a.content),a.innerHTML}const R={dark:{bg:"linear-gradient(180deg,#1f2937,#111827)",color:"#fff",border:"1px solid rgba(255,255,255,.06)"},light:{bg:"#fff",color:"#111",border:"1px solid #e5e7eb"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.1)"}},yt={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},Et={success:"jt-bounce",error:"jt-shake",warning:"jt-shake",info:"jt-pulse",loading:"jt-spin"},C={_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,playSound:null,dev:!1,injectCSS:!0,css:null,autoDedupe:!1,maxVisiblePerType:{},parallaxMode:!1,autoFetchFA:!0,use3d:!1,parallaxSmoothing:.12},_config:{},_theme:"dark",_plugins:[],_queue:new B,_queueDedupe:new Set,_activeMap:new Map,_roots:new Map,_modalStack:[],_faInjected:!1,setup(e={}){const a=e,{duration:t,maxVisible:n}=a,u=kt(a,["duration","maxVisible"]);typeof t=="number"&&(this._defaults.duration=t),typeof n=="number"&&(this._defaults.maxVisible=n),typeof e.autoDedupe=="boolean"&&(this._defaults.autoDedupe=e.autoDedupe),e.maxVisiblePerType&&(this._defaults.maxVisiblePerType=O(this._defaults.maxVisiblePerType,e.maxVisiblePerType)),typeof e.parallaxMode=="boolean"&&(this._defaults.parallaxMode=e.parallaxMode),typeof e.autoFetchFA=="boolean"&&(this._defaults.autoFetchFA=e.autoFetchFA),typeof e.use3d=="boolean"&&(this._defaults.use3d=e.use3d),typeof e.parallaxSmoothing=="number"&&(this._defaults.parallaxSmoothing=Y(e.parallaxSmoothing,0,1)),this._config=O(this._config,u),this._registerTypes()},use(e){typeof e=="function"&&this._plugins.push(e)},addType(e,a={}){this._config[e]=a,this._registerTypes()},defineTheme(e,a={}){R[e]=O(R[e]||{},a)},setTheme(e){this._theme=e,M&&this._roots.forEach(a=>a.dataset.theme=e)},clear(){this._queue=new B,this._queueDedupe.clear()},destroy(){this.clear(),M&&(this._roots.forEach(e=>{try{e._parallaxRAF&&cancelAnimationFrame(e._parallaxRAF),e._parallaxHandler&&(e.removeEventListener("mousemove",e._parallaxHandler),e.removeEventListener("touchmove",e._parallaxHandler)),e.remove()}catch(a){}}),this._roots.clear())},promise(e,a={}){if(!e||typeof e.then!="function"){this._warn("promise expects a Promise");return}const t={id:ot()}.id,n=a.timeout;this._enqueue("loading",et(tt({},Pt(a.loading,"Loading...")),{groupId:t,duration:0}));let u=null;n&&(u=setTimeout(()=>{this._enqueue("error",{message:a.timeoutMessage||"Request timeout",groupId:t}),o()},n));const o=()=>{u&&clearTimeout(u)};return e.then(i=>{o(),this._enqueue("success",et(tt({},gt(a.success,i,"Success")),{groupId:t}))}).catch(i=>{o(),this._enqueue("error",et(tt({},gt(a.error,i,"Error")),{groupId:t}))}),{cancel:()=>{this._enqueue("info",{message:a.cancelMessage||"Cancelled",groupId:t}),u&&clearTimeout(u)}}},modal(e={}){var a;if(!M)return;this._defaults.injectCSS!==!1&&ft(this._defaults.css||rt);const t=O({title:"",message:"",html:null,block:!0,blur:!0,closeOnOverlay:!0,closable:!0,animation:"scale",actions:[],theme:this._theme,use3d:void 0},e),n=t.use3d===void 0?this._defaults.use3d:!!t.use3d,u=R[t.theme]||R.dark,o=document.createElement("div");o.className="jt-modal-overlay",t.block?o.style.pointerEvents="all":o.style.pointerEvents="none",t.blur||(o.style.backdropFilter="none",o.style.webkitBackdropFilter="none");const i=document.createElement("div");if(i.className=`jt-modal jt-anim-${t.animation}`,i.style.background=u.bg,i.style.color=u.color,i.style.border=u.border||"none",n&&(o.style.perspective=o.style.perspective||"900px",i.style.transform="translateY(40px) scale(.96) rotateX(8deg)"),t.title){const m=document.createElement("div");m.className="jt-modal-header",m.textContent=t.title,i.appendChild(m)}const f=document.createElement("div");if(f.className="jt-modal-body",t.html?f.innerHTML=Q(t.html):f.textContent=t.message||"",i.appendChild(f),(a=t.actions)!=null&&a.length){const m=document.createElement("div");m.className="jt-modal-actions",t.actions.forEach(v=>{const x=document.createElement("button");x.className="jt-modal-btn"+(v.primary?" primary":""),x.textContent=v.label||"OK",x.onclick=E=>{var h;E.stopPropagation(),(h=v.onClick)==null||h.call(v,E),v.closeOnClick!==!1&&y()},m.appendChild(x)}),i.appendChild(m)}o.appendChild(i),document.body.appendChild(o),this._modalStack.push(o),t.block&&(document.body.style.overflow="hidden"),requestAnimationFrame(()=>{o.classList.add("show"),i.classList.add("show"),n&&(i.style.transform="translateY(0) scale(1) rotateX(0deg)")});const p=m=>{m.key==="Escape"&&y()};t.closable&&(t.closeOnOverlay&&o.addEventListener("click",m=>{m.target===o&&y()}),document.addEventListener("keydown",p));const y=()=>{o.classList.remove("show"),i.classList.remove("show"),n&&(i.style.transform="translateY(40px) scale(.96) rotateX(8deg)"),setTimeout(()=>{try{o.remove()}catch(v){}t.block&&(document.body.style.overflow=""),document.removeEventListener("keydown",p);const m=this._modalStack.indexOf(o);m>=0&&this._modalStack.splice(m,1)},300)};return{close:y}},_registerTypes(){Object.keys(this._config).forEach(e=>{if(typeof this[e]=="function"&&!this[e].__auto)return;const a=t=>this._enqueue(e,t);a.__auto=!0,this[e]=a})},_enqueue(e,a={}){var t,n;const u=typeof a.priority=="number"?a.priority:(n=(t=this._priorityMap)==null?void 0:t[a.priority])!=null?n:2,o=a.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(e,a):void 0);if(o&&this._queueDedupe.has(o)){this._defaults.dev&&console.log("[JuiceToast] deduped (queue)",o);return}const i={id:ot(),type:e,payload:a,priority:u};return o&&this._queueDedupe.add(o),this._queue.push(i,u),this._processQueue(),i.id},_processQueue(){var e;if(!M)return;const a=this._defaults.maxVisible;for(;this._queue.size>0;){const t=this._queue.pop();if(!t)break;const n=((e=t.payload)==null?void 0:e.position)||"bottom-right",u=this._getRoot(n);if(!u)break;if(Array.from(u.children).length>=a){this._queue.push(t,t.priority-.001);break}const o=(this._defaults.maxVisiblePerType||{})[t.type];if(typeof o=="number"&&Array.from(u.children).filter(i=>i.dataset.toastType===t.type).length>=o){this._queue.push(t,t.priority-.001);break}this._showToast(t.type,t.payload,t.id)}},_getRoot(e="bottom-right"){var a;if(!M)return null;if(this._roots.has(e))return this._roots.get(e);const t=document.createElement("div");switch(t.id=`juice-toast-root-${e}`,t.dataset.position=e,t.dataset.theme=this._theme,t.style.pointerEvents="none",t.style.display="flex",t.style.flexDirection="column",this._defaults.parallaxMode&&(t.dataset.parallax="true"),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%)";break;default:t.style.bottom="20px",t.style.right="20px"}if(document.body.appendChild(t),this._defaults.parallaxMode&&!$){const n=(a=this._defaults.parallaxSmoothing)!=null?a:.12,u=i=>{const f=t.getBoundingClientRect(),p=f.left+f.width/2,y=f.top+f.height/2,m=i.touches?i.touches[0].clientX:i.clientX,v=i.touches?i.touches[0].clientY:i.clientY;if(Array.from(t.children).forEach((x,E)=>{const h=(E+1)/Math.max(1,t.children.length),T=Y((m-p)/f.width*h*12,-18,18),w=Y((v-y)/f.height*h*8,-14,14),A=Y(-h*8,-30,0),I=Y((m-p)/f.width*h*-6,-12,12),D=Y((v-y)/f.height*h*4,-8,8);x._jtTarget=x._jtTarget||{},x._jtTarget.tx=T,x._jtTarget.ty=w,x._jtTarget.tz=A,x._jtTarget.rotX=D,x._jtTarget.rotY=I}),!t._parallaxRAF){const x=()=>{let E=!1;Array.from(t.children).forEach((h,T)=>{h._jtPrev=h._jtPrev||{tx:0,ty:0,tz:0,rotX:0,rotY:0};const w=h._jtTarget||{tx:0,ty:0,tz:0,rotX:0,rotY:0},A=h._jtPrev,I=S(A.tx,w.tx||0,n),D=S(A.ty,w.ty||0,n),r=S(A.tz,w.tz||0,n),z=S(A.rotX,w.rotX||0,n),j=S(A.rotY,w.rotY||0,n);h.style.setProperty("--jt-parallax-x",`${I}px`),h.style.setProperty("--jt-parallax-y",`${D}px`),h.style.setProperty("--jt-parallax-z",`${r}px`),h.style.setProperty("--jt-rot-x",`${z}deg`),h.style.setProperty("--jt-rot-y",`${j}deg`),h._jtPrev.tx=I,h._jtPrev.ty=D,h._jtPrev.tz=r,h._jtPrev.rotX=z,h._jtPrev.rotY=j,(Math.abs(I-(w.tx||0))>.1||Math.abs(D-(w.ty||0))>.1||Math.abs(r-(w.tz||0))>.5||Math.abs(z-(w.rotX||0))>.1||Math.abs(j-(w.rotY||0))>.1)&&(E=!0)}),E?t._parallaxRAF=requestAnimationFrame(x):t._parallaxRAF=null};t._parallaxRAF=requestAnimationFrame(x)}};t._parallaxHandler=u,t.addEventListener("mousemove",u),t.addEventListener("touchmove",u,{passive:!0});const o=()=>{Array.from(t.children).forEach(i=>{i._jtTarget={tx:0,ty:0,tz:0,rotX:0,rotY:0}}),t._parallaxRAF||(t._parallaxRAF=requestAnimationFrame(function i(){let f=!1;Array.from(t.children).forEach(p=>{p._jtPrev=p._jtPrev||{tx:0,ty:0,tz:0,rotX:0,rotY:0};const y=p._jtPrev,m=p._jtTarget||{tx:0,ty:0,tz:0,rotX:0,rotY:0},v=S(y.tx,m.tx||0,.16),x=S(y.ty,m.ty||0,.16),E=S(y.tz,m.tz||0,.16),h=S(y.rotX,m.rotX||0,.16),T=S(y.rotY,m.rotY||0,.16);p.style.setProperty("--jt-parallax-x",`${v}px`),p.style.setProperty("--jt-parallax-y",`${x}px`),p.style.setProperty("--jt-parallax-z",`${E}px`),p.style.setProperty("--jt-rot-x",`${h}deg`),p.style.setProperty("--jt-rot-y",`${T}deg`),p._jtPrev.tx=v,p._jtPrev.ty=x,p._jtPrev.tz=E,p._jtPrev.rotX=h,p._jtPrev.rotY=T,(Math.abs(v)>.5||Math.abs(x)>.5||Math.abs(E)>.5||Math.abs(h)>.5||Math.abs(T)>.5)&&(f=!0)}),f?t._parallaxRAF=requestAnimationFrame(i):t._parallaxRAF=null}))};t.addEventListener("mouseleave",o),t.addEventListener("touchend",o)}return this._roots.set(e,t),t},_warn(e){this._defaults.dev&&typeof console!="undefined"&&console.warn("[JuiceToast]",e)},_ensureFA(){if(!(!M||this._faInjected||!this._defaults.autoFetchFA)){if(document.querySelector('link[href*="fontawesome"], link[href*="font-awesome"], link[href*="cdnjs.cloudflare.com/ajax/libs/font-awesome"]')){this._faInjected=!0;return}try{const e=document.createElement("link");e.rel="stylesheet",e.href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css",e.crossOrigin="anonymous",document.head.appendChild(e),this._faInjected=!0}catch(e){console.error("[JuiceToast]: Fetching icons failed:",e)}}},_playSound(e){if(!M)return;const a=typeof e=="string"&&e?e:this._defaults.playSound;if(a)try{const t=new Audio(a);t.volume=.6,t.play().catch(()=>{})}catch(t){}},_updateStackPositionsFor(e){const a=Array.from(e.children);e.dataset.position&&e.dataset.position.includes("bottom"),a.forEach((t,n)=>{const u=n,o=u*12;t.style.setProperty("--jt-stack-y",`-${o}px`),t.style.setProperty("--jt-stack-scale",1-u*.04),t.style.setProperty("--jt-stack-opacity",1-u*.12),t.style.zIndex=1e3-u,t.style.setProperty("--jt-parallax-z",`${-u*2}px`)})},_runPlugins(e){this._plugins.forEach(a=>{try{a(e)}catch(t){this._warn("Plugin error: "+((t==null?void 0:t.message)||t))}})},_normalizeGlass(e){if(e===!0)return 60;if(!e)return 0;const a=Number(e);return Number.isFinite(a)?Y(a,0,100):0},_computeDedupeKey(e,a){try{const t=e||"",n=a.title||"",u=a.message||a.html||"";return`${t}::${String(n).trim().slice(0,200)}::${String(u).trim().slice(0,500)}`}catch(t){return}},_showToast(e,a={},t){var n,u,o,i,f,p,y,m,v,x,E,h,T,w,A;if(!M)return;this._defaults.injectCSS!==!1&&ft(this._defaults.css||rt),this._ensureFA();const I=this._config[e]||{},D=typeof a=="object"?a:{message:String(a)},r=O(I,D);r.icon=(n=r.icon)!=null?n:r.icon_left_top,r.position=(o=(u=r.position)!=null?u:r.toast)!=null?o:"bottom-right",r.closable=(f=(i=r.closable)!=null?i:r.closeable)!=null?f:!0,r.duration=typeof r.duration=="number"?r.duration:this._defaults.duration;const z=R[r.theme||this._theme]||{},j=t||ot(),J=r.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(e,r):void 0);if(J)for(const l of this._roots.values()){const c=Array.from(l.children).find(b=>b.dataset.dedupeKey===J);if(c){let b=c.querySelector(".jt-count");if(b||(b=document.createElement("span"),b.className="jt-count",b.style.marginLeft="6px",(p=c.querySelector(".jt-title"))==null||p.appendChild(b),b.textContent="1"),b.textContent=String(parseInt(b.textContent||"1")+1),r.mergeMessage){const P=c.querySelector(".jt-message");P&&(r.html?P.innerHTML=Q(r.html):P.textContent=String(r.message||""))}return c.dataset.toastId}}const s=document.createElement("div");if(s.className="juice-toast",s.dataset.toastId=j,s.dataset.position=r.position,s.dataset.toastType=e,J&&(s.dataset.dedupeKey=J),s.tabIndex=0,s.setAttribute("role","status"),s.style.position="relative",s.style.pointerEvents="auto",s.style.background=r.bg||z.bg,s.style.color=r.color||z.color,s.style.border=r.border||z.border||"none",s.style.minHeight=s.style.minHeight||"",s.style.setProperty("--jt-parallax-x","0px"),s.style.setProperty("--jt-parallax-y","0px"),s.style.setProperty("--jt-parallax-z","0px"),s.style.setProperty("--jt-drag-x","0px"),s.style.setProperty("--jt-drag-y","0px"),s.style.setProperty("--jt-rot-x","0deg"),s.style.setProperty("--jt-rot-y","0deg"),s.style.setProperty("--jt-stack-scale","1"),r.size&&yt[r.size]){const l=yt[r.size];l.width&&(s.style.width=l.width),l.padding&&(s.style.padding=l.padding)}const L=document.createElement("div");if(L.className="jt-content",r.title){const l=document.createElement("div");l.className="jt-title",l.textContent=r.title,L.appendChild(l)}const U=document.createElement("div");if(U.className="jt-message",r.html?U.innerHTML=Q(r.html):typeof r.message=="string"?r.message.split(/(`[^`]+`)/g).forEach(l=>{if(l.startsWith("`")&&l.endsWith("`")){const c=document.createElement("code");c.textContent=l.slice(1,-1),U.appendChild(c)}else U.appendChild(document.createTextNode(l))}):r.message&&(U.textContent=String(r.message)),L.appendChild(U),Array.isArray(r.actions)&&r.actions.length){const l=document.createElement("div");l.className="jt-actions",r.actions.forEach(c=>{const b=document.createElement("button");b.className="jt-action",b.textContent=c.label||"Action",b.onclick=P=>{var K;P.stopPropagation(),(K=c.onClick)==null||K.call(c,P),c.closeOnClick&&this.remove(j)},l.appendChild(b)}),L.appendChild(l)}r.bgImage?(s.style.backgroundImage=`url(${r.bgImage})`,s.style.backgroundSize=r.bgSize||"cover",s.style.backgroundPosition=r.bgPosition||"center"):s.style.background=r.bg||z.bg;let _=null;if(r.icon){_=document.createElement("i");const l=r.icon.startsWith("fa")?r.icon:`fa-${r.icon}`;if(_.className=["icon",r.iconPack||"",l].join(" ").trim(),r.iconSize&&(_.style.fontSize=r.iconSize),!$){const c=r.iconAnim||Et[e];c&&_.classList.add(c)}(r.iconLink||r.iconAnimate)&&(_.classList.add("icon-clickable"),_.addEventListener("click",c=>{c.stopPropagation(),r.iconAnimate&&(_.classList.remove(r.iconAnimate),_.offsetWidth,_.classList.add(r.iconAnimate)),r.iconLink&&window.open(r.iconLink,"_blank","noopener")}))}let g=null;if(r.avatar){g=document.createElement("img");const l=typeof r.avatar=="string"&&r.avatar?r.avatar:r.avatarSrc||"";l&&(g.src=l),g.alt=r.avatarAlt||r.title||"avatar",g.className="jt-avatar",g.loading=r.avatarLazy?"lazy":"eager",g.style.width=g.style.width||"36px",g.style.height=g.style.height||"36px",g.style.borderRadius=g.style.borderRadius||"50%",g.style.objectFit=g.style.objectFit||"cover",g.style.flexShrink="0";const c=r.avatarPosition||"left";c==="left"?g.style.marginRight=(y=r.avatarSpacing)!=null?y:"10px":c==="right"?g.style.marginLeft=(m=r.avatarSpacing)!=null?m:"10px":c==="top"&&(g.style.marginBottom=(v=r.avatarSpacing)!=null?v:"8px")}const st=r.avatarPosition||"left";g&&st==="top"?(s.classList.add("jt-avatar-top"),s.style.flexDirection="column",s.style.alignItems="flex-start",s.appendChild(g),_&&r.iconPosition==="top"?(s.appendChild(_),s.appendChild(L)):_&&r.iconPosition==="right"?(s.appendChild(L),s.appendChild(_)):(_&&s.appendChild(_),s.appendChild(L))):(s.style.flexDirection="row",s.style.alignItems="center",g&&st==="left"&&s.appendChild(g),_&&r.iconPosition==="right"?(s.appendChild(L),s.appendChild(_)):_&&r.iconPosition==="top"?(s.classList.add("jt-icon-top"),s.appendChild(_),s.appendChild(L)):(_&&s.appendChild(_),s.appendChild(L)),g&&st==="right"&&s.appendChild(g));let H=null;if(r.progress&&((x=r.duration)!=null?x:this._defaults.duration)>0&&(H=document.createElement("div"),H.className="jt-progress",r.progressColor&&(H.style.background=r.progressColor),s.appendChild(H)),r.undo){const l=document.createElement("button");l.className="jt-action",l.textContent="Undo",l.onclick=()=>{try{r.undo()}catch(c){}this.remove(j)},L.appendChild(l)}if(r.closable){const l=document.createElement("span");l.className="juice-toast-close",l.tabIndex=0,l.textContent="\xD7",l.style.marginLeft="8px",l.addEventListener("click",c=>{c.stopPropagation(),this.remove(j)}),s.appendChild(l)}const q=this._getRoot(r.position||"bottom-right");if(!q)return;if(r.groupId){const l=Array.from(q.children).find(c=>c.dataset.groupId===r.groupId);if(l){let c=l.querySelector(".jt-count");c||(c=document.createElement("span"),c.className="jt-count",c.style.marginLeft="6px",(E=l.querySelector(".jt-title"))==null||E.appendChild(c),c.textContent="1"),c.textContent=String(parseInt(c.textContent||"1")+1);return}s.dataset.groupId=r.groupId}const xt=this._defaults.maxVisible;xt&&q.children.length>=xt&&q.removeChild(q.firstElementChild),q.appendChild(s);const d={id:j,toast:s,cfg:r,type:e,createdAt:k(),remaining:(h=r.duration)!=null?h:this._defaults.duration,raf:null,timer:null,start:k(),paused:!1,_boundMove:null,_boundUp:null,_onPointerDown:null,_onEnter:null,_onLeave:null,dedupeKey:J,hooks:{onShow:r.onShow,onShown:r.onShown,onClose:r.onClose,onRemoved:r.onRemoved}};this._activeMap.set(j,d);try{(w=(T=d.hooks).onShow)==null||w.call(T,{id:j,toast:s,cfg:r,type:e})}catch(l){}this._runPlugins({toast:s,cfg:r,type:e,root:q,meta:d}),this._updateStackPositionsFor(q),requestAnimationFrame(()=>{var l,c;$?(s.style.opacity="1",(c=(l=d.hooks).onShown)==null||c.call(l,{id:j,toast:s,cfg:r,type:e})):(s.classList.add("show"),setTimeout(()=>{var b,P;try{(P=(b=d.hooks).onShown)==null||P.call(b,{id:j,toast:s,cfg:r,type:e})}catch(K){}},320))});let _t=0,bt=0,F=0,V=0,nt=!1,N=null,it=0;const lt=l=>{const c=l.touches?l.touches[0]:l;_t=c.clientX,bt=c.clientY,F=0,V=0,nt=!0,N=null,d.paused=!0,d.raf&&(cancelAnimationFrame(d.raf),d.raf=null),s.style.transition="none",d._boundMove=Ct,d._boundUp=Lt,document.addEventListener("touchmove",d._boundMove,{passive:!0}),document.addEventListener("mousemove",d._boundMove),document.addEventListener("touchend",d._boundUp),document.addEventListener("mouseup",d._boundUp),it=k()},Ct=l=>{if(!nt)return;const c=l.touches?l.touches[0]:l;F=c.clientX-_t,V=c.clientY-bt,N||(Math.abs(F)>6?N="x":Math.abs(V)>6&&(N="y")),N==="x"?s.style.setProperty("--jt-drag-x",`${F}px`):N==="y"&&s.style.setProperty("--jt-drag-y",`${V}px`),it=k(),c.clientX},Lt=l=>{nt=!1,d.paused=!1;const c=Math.abs(F),b=Math.abs(V),P=N||(c>b?"x":"y"),K=Math.max(1,k()-it),St=K?F/K*1e3:0,At=P==="x"&&(c>(C._defaults.swipeThreshold||60)||Math.abs(St)>800),Tt=P==="y"&&b>(C._defaults.swipeThreshold||80);if(At||Tt){const zt=F>=0?1:-1;P==="x"?s.style.setProperty("--jt-drag-x",`${zt*1e3}px`):s.style.setProperty("--jt-drag-y","1000px"),s.classList.add("swipe-dismissing"),setTimeout(()=>this.remove(j),220)}else s.style.transition="transform 0.22s ease-out, opacity 0.22s ease-out",s.style.setProperty("--jt-drag-x","0px"),s.style.setProperty("--jt-drag-y","0px");F=V=0,d._boundMove&&(document.removeEventListener("touchmove",d._boundMove),document.removeEventListener("mousemove",d._boundMove),d._boundMove=null),d._boundUp&&(document.removeEventListener("touchend",d._boundUp),document.removeEventListener("mouseup",d._boundUp),d._boundUp=null),ut()};s._onPointerDown=lt,s.addEventListener("touchstart",lt,{passive:!0}),s.addEventListener("mousedown",lt);const ct=()=>{d.paused=!0,d.raf&&(cancelAnimationFrame(d.raf),d.raf=null)},dt=()=>{d.paused&&(d.paused=!1,d.start=k(),ut())};d._onEnter=ct,d._onLeave=dt,s.addEventListener("mouseenter",ct),s.addEventListener("mouseleave",dt),s.addEventListener("focusin",ct),s.addEventListener("focusout",dt);const Z=(A=r.duration)!=null?A:this._defaults.duration;function vt(){if(!C._activeMap.has(j))return;if(d.paused){d.raf=null,d.start=k();return}const l=k()-d.start;if(d.remaining-=l,d.start=k(),H){const c=Math.max(0,d.remaining/Z);H.style.transform=`scaleX(${c})`}if(d.remaining<=0){$||s.classList.remove("show"),setTimeout(()=>C.remove(j),280),d.raf=null;return}d.raf=requestAnimationFrame(vt)}const ut=()=>{Z<=0||d.raf||d.paused||(d.start=k(),d.raf=requestAnimationFrame(vt))};Z>0&&(d.start=k(),d.remaining=Z,ut());const Mt=()=>this.remove(j);return r.undoTimeout&&(d.timer=setTimeout(Mt,r.undoTimeout)),(r.playSound||this._defaults.playSound)&&this._playSound(r.playSound||this._defaults.playSound),j},remove(e){var a,t,n,u;const o=this._activeMap.get(e);if(!o)return!1;const{toast:i,cfg:f,type:p}=o;try{(t=(a=o.hooks).onClose)==null||t.call(a,{id:e,toast:i,cfg:f,type:p})}catch(m){}$?i.style.opacity="0":i.classList.add("hide");try{i._onPointerDown&&(i.removeEventListener("touchstart",i._onPointerDown),i.removeEventListener("mousedown",i._onPointerDown))}catch(m){}if(o._boundMove){try{document.removeEventListener("touchmove",o._boundMove),document.removeEventListener("mousemove",o._boundMove)}catch(m){}o._boundMove=null}if(o._boundUp){try{document.removeEventListener("touchend",o._boundUp),document.removeEventListener("mouseup",o._boundUp)}catch(m){}o._boundUp=null}try{o._onEnter&&i.removeEventListener("mouseenter",o._onEnter),o._onLeave&&i.removeEventListener("mouseleave",o._onLeave),o._onEnter&&i.removeEventListener("focusin",o._onEnter),o._onLeave&&i.removeEventListener("focusout",o._onLeave)}catch(m){}o.raf&&(cancelAnimationFrame(o.raf),o.raf=null),o.timer&&(clearTimeout(o.timer),o.timer=null),this._activeMap.delete(e);const y=i.parentNode;if(y&&y.removeChild(i),y&&this._updateStackPositionsFor(y),o.dedupeKey)try{this._queueDedupe.delete(o.dedupeKey)}catch(m){}try{(u=(n=o.hooks).onRemoved)==null||u.call(n,{id:e,cfg:f,type:p})}catch(m){}return!0},update(e,a={}){const t=this._activeMap.get(e);if(!t)return this._warn("update: id not found "+e),!1;const{toast:n}=t;if(t.cfg=O(t.cfg,a),t.cfg.title){const i=n.querySelector(".jt-title");i&&(i.textContent=t.cfg.title)}const u=n.querySelector(".jt-message");u&&(t.cfg.html?u.innerHTML=Q(t.cfg.html):u.textContent=String(t.cfg.message||""));const o=R[t.cfg.theme||this._theme]||{};return n.style.background=t.cfg.bg||o.bg,n.style.color=t.cfg.color||o.color,n.style.border=t.cfg.border||o.border||"none",t.cfg.duration!==void 0&&(t.remaining=t.cfg.duration,t.start=k(),!t.paused&&!t.raf&&(t.raf=requestAnimationFrame(function i(){var f;if(!C._activeMap.has(e))return;const p=C._activeMap.get(e);if(!p)return;const y=k()-p.start;p.remaining-=y,p.start=k();const m=p.toast.querySelector(".jt-progress");if(m){const v=Math.max(0,p.remaining/((f=p.cfg.duration)!=null?f:C._defaults.duration));m.style.transform=`scaleX(${v})`}if(p.remaining<=0){$||p.toast.classList.remove("show"),setTimeout(()=>C.remove(e),280);return}p.raf=requestAnimationFrame(i)}))),this._runPlugins({toast:n,cfg:t.cfg,type:t.type,meta:t}),!0},_priorityMap:{low:1,normal:2,high:3,urgent:4}};function Pt(e,a){return e?typeof e=="string"?{message:e}:e:{message:a}}function gt(e,a,t){return e?typeof e=="function"?{message:e(a)}:typeof e=="string"?{message:e}:e:{message:t}}C.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",progress:!0,duration:4e3},warning:{icon:"fa-triangle-exclamation",iconPack:"fas",bg:"#f59e0b",progress:!0,duration:4e3},loading:{icon:"fa-spinner",iconPack:"fas",iconAnim:"jt-spin",duration:0,progress:!0}}),X.default=C,X.juiceToast=C,Object.defineProperty(X,"__esModule",{value:!0})}));
|
|
46
81
|
//# sourceMappingURL=juice-toast.umd.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "juice-toast",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4-beta.1",
|
|
4
4
|
"description": "Zero dependency JavaScript toast notification library with animations, dark mode, auto CSS injection, and mobile support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"toast",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"README.md",
|
|
53
53
|
"CONTRIBUTING.md",
|
|
54
54
|
"WARNER_NEXT_VERSION.md",
|
|
55
|
-
"
|
|
55
|
+
"Notice.md",
|
|
56
56
|
"NEW_FUNCTION.md",
|
|
57
57
|
"API.md"
|
|
58
58
|
],
|
/package/{EoL.md → Notice.md}
RENAMED
|
File without changes
|