juice-toast 1.4.2 → 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/API.md +8 -1
- package/CHANGELOG.md +11 -1
- package/CONTRIBUTING.md +1 -1
- package/LICENSE +73 -0
- package/README.md +1 -2
- package/dist/juice-toast.esm.js +60 -92
- package/dist/juice-toast.umd.js +60 -92
- package/package.json +3 -3
- package/LICENSE.md +0 -54
- /package/{EoL.md → Notice.md} +0 -0
package/API.md
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
## v1.4.
|
|
1
|
+
## v1.4.4 Pack 0 (Beta 1)
|
|
2
|
+
- Fix Parallax Mode
|
|
3
|
+
- Experimental **3D Mode** (unstable)
|
|
4
|
+
|
|
5
|
+
v1.4.3
|
|
6
|
+
- Add Parallax Mode
|
|
7
|
+
- Fixes Animation
|
|
8
|
+
- Auto-fecth **Font Awesome** Icons
|
|
9
|
+
- Smart Dedup
|
|
10
|
+
|
|
11
|
+
v1.4.2
|
|
2
12
|
- Add modal
|
|
3
13
|
- Bug fixes
|
|
4
14
|
- improve documentation
|
package/CONTRIBUTING.md
CHANGED
|
@@ -62,4 +62,4 @@ git push origin feature/your-feature-name
|
|
|
62
62
|
## Code of Conduct
|
|
63
63
|
Read the [Code Of Conduct](https://github.com/KhairyK/juiceToast/blob/main/CODE_OF_CONDUCT.md)
|
|
64
64
|
|
|
65
|
-
2026 (C) OpenDN Foundation / Released under
|
|
65
|
+
2026 (C) OpenDN Foundation / Released under Atrosfer 1.0LICENSE
|
package/LICENSE
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
===========================================
|
|
2
|
+
Atrosfer License 1.0
|
|
3
|
+
2026 (C) OpenDN Foundation
|
|
4
|
+
https://atrosfer.opendnf.cloud/1.0
|
|
5
|
+
===========================================
|
|
6
|
+
|
|
7
|
+
1. Grant of License:
|
|
8
|
+
- Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, subject to the conditions stated herein.
|
|
13
|
+
|
|
14
|
+
2. Conditions:
|
|
15
|
+
a. License Notice:
|
|
16
|
+
- The above copyright notice and this permission notice shall be included
|
|
17
|
+
in all copies or substantial portions of the Software.
|
|
18
|
+
b. Attribution:
|
|
19
|
+
- When distributing the Software in any form, credit must be given to the
|
|
20
|
+
original author, Sholehuddin Khairy, including a link to the official
|
|
21
|
+
repository or project page, if applicable.
|
|
22
|
+
c. Modifications:
|
|
23
|
+
- Any modified versions of the Software must clearly state the changes made
|
|
24
|
+
and retain this license in its entirety.
|
|
25
|
+
|
|
26
|
+
3. Source Code Distribution:
|
|
27
|
+
- The Software may be distributed in source code or compiled/binary form.
|
|
28
|
+
- Redistribution must include this license and the original copyright notice.
|
|
29
|
+
|
|
30
|
+
4. Commercial Use:
|
|
31
|
+
- The Software may be used for commercial purposes.
|
|
32
|
+
- Distribution or sale of modified versions for profit requires compliance
|
|
33
|
+
with all terms of this license, including proper attribution.
|
|
34
|
+
|
|
35
|
+
5. Contributions:
|
|
36
|
+
- Contributions to the Software are encouraged.
|
|
37
|
+
- By submitting contributions, contributors grant the right to use, modify,
|
|
38
|
+
and distribute them under the terms of this license.
|
|
39
|
+
|
|
40
|
+
6. Patent Clause:
|
|
41
|
+
- The license grants no rights to any patents owned by the copyright holder
|
|
42
|
+
or contributors. Use of the Software does not grant any patent license.
|
|
43
|
+
|
|
44
|
+
7. Trademarks:
|
|
45
|
+
- This license does not grant any rights to use the trademarks, service marks,
|
|
46
|
+
or trade names of the copyright holder, except as required for reasonable
|
|
47
|
+
attribution of the Software.
|
|
48
|
+
|
|
49
|
+
8. Warranty Disclaimer:
|
|
50
|
+
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
51
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
52
|
+
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
|
53
|
+
- THE COPYRIGHT HOLDER SHALL NOT BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
|
|
54
|
+
LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR
|
|
55
|
+
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
56
|
+
|
|
57
|
+
9. Indemnity:
|
|
58
|
+
- Users agree to indemnify, defend, and hold harmless the copyright holder
|
|
59
|
+
from and against any claims, damages, or liabilities arising from their
|
|
60
|
+
use, modification, or distribution of the Software.
|
|
61
|
+
|
|
62
|
+
10. International Use:
|
|
63
|
+
- This license is governed by international copyright law.
|
|
64
|
+
- Use of the Software constitutes acceptance of the terms in any jurisdiction.
|
|
65
|
+
|
|
66
|
+
11. Termination:
|
|
67
|
+
- Any violation of the terms of this license will result in automatic
|
|
68
|
+
termination of rights granted herein.
|
|
69
|
+
- Termination does not affect rights accrued prior to the violation.
|
|
70
|
+
|
|
71
|
+
12. Acceptance:
|
|
72
|
+
- By using, copying, modifying, or distributing this Software, you acknowledge
|
|
73
|
+
that you have read, understood, and agree to be bound by the terms of this license.
|
package/README.md
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|

|
|
8
8
|

|
|
9
9
|

|
|
10
|
-

|
|
11
10
|

|
|
12
11
|

|
|
13
12
|

|
|
@@ -395,7 +394,7 @@ JuiceToast provides more advanced architecture while staying dependency-free.
|
|
|
395
394
|
|
|
396
395
|
# 📄 License
|
|
397
396
|
|
|
398
|
-
|
|
397
|
+
Atrosfer 1.0 License (C) 2026 OpenDN Foundation
|
|
399
398
|
|
|
400
399
|
---
|
|
401
400
|
|
package/dist/juice-toast.esm.js
CHANGED
|
@@ -1,113 +1,81 @@
|
|
|
1
|
-
var
|
|
2
|
-
/* JuiceToast base (
|
|
3
|
-
#juice-toast-root,[id^="juice-toast-root-"]{position:fixed;z-index:9999;display:flex;pointer-events:none;gap:10px}
|
|
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
|
+
/* JuiceToast base (extended) */
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
}
|
|
35
|
+
@keyframes jt-slide-in{0%{opacity:0;transform:translateY(20px) scale(0.98)}100%{opacity:1;transform:translateY(0) scale(1)}}
|
|
36
|
+
@keyframes jt-slide-out{0%{opacity:1;transform:translateY(0) scale(1)}100%{opacity:0;transform:translateY(20px) scale(0.98)}}
|
|
37
|
+
@keyframes jt-bounce{0%{transform:translateY(0)}25%{transform:translateY(-6px)}50%{transform:translateY(0)}75%{transform:translateY(-3px)}100%{transform:translateY(0)}}
|
|
38
|
+
@keyframes jt-shake{0%{transform:translateX(0)}20%{transform:translateX(-6px)}40%{transform:translateX(6px)}60%{transform:translateX(-4px)}80%{transform:translateX(2px)}100%{transform:translateX(0)}}
|
|
39
|
+
@keyframes jt-pulse{0%{transform:scale(1)}50%{transform:scale(1.02)}100%{transform:scale(1)}}
|
|
40
|
+
@keyframes jt-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}
|
|
41
|
+
.juice-toast.show{animation:jt-slide-in .32s cubic-bezier(0.4,0,0.2,1) forwards;opacity:1}
|
|
42
|
+
.juice-toast.hide{animation:jt-slide-out .28s cubic-bezier(0.4,0,0.2,1) forwards;opacity:0;pointer-events:none}
|
|
14
43
|
.juice-toast .icon{width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center;border-radius:8px;background:rgba(255,255,255,.06)}
|
|
15
|
-
.jt-content{display:flex;flex-direction:column;gap:4px;flex:1}
|
|
16
|
-
.jt-title{font-weight:700;font-size:13px}
|
|
17
|
-
.jt-message{font-size:13px;opacity:.95}
|
|
44
|
+
.jt-content{display:flex;flex-direction:column;gap:4px;flex:1;min-width:0}
|
|
45
|
+
.jt-title{font-weight:700;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
46
|
+
.jt-message{font-size:13px;opacity:.95;word-break:break-word}
|
|
18
47
|
.jt-actions{display:flex;gap:8px;margin-top:10px}
|
|
19
48
|
.jt-action{border:1px solid currentColor;padding:4px 10px;border-radius:6px;font-size:12px;cursor:pointer;background:transparent}
|
|
20
49
|
.jt-progress{position:absolute;left:0;bottom:0;height:4px;width:100%;border-radius:2px;background:linear-gradient(90deg,#4ade80,#22c55e);transform-origin:left;transform:scaleX(1);transition:transform linear}
|
|
21
|
-
|
|
22
|
-
/* avatar specific */
|
|
50
|
+
.juice-toast.swipe-dismissing {opacity: 0; transition: transform 0.22s ease-out, opacity 0.22s ease-out;}
|
|
23
51
|
.jt-avatar{width:36px;height:36px;border-radius:50%;object-fit:cover;flex-shrink:0}
|
|
24
52
|
|
|
25
|
-
/*
|
|
26
|
-
|
|
53
|
+
/* avatar top variant */
|
|
54
|
+
.juice-toast.jt-avatar-top{flex-direction:column;align-items:flex-start}
|
|
55
|
+
|
|
56
|
+
/* modal */
|
|
27
57
|
.jt-modal-overlay{
|
|
28
|
-
position:fixed;
|
|
29
|
-
inset:0;
|
|
30
|
-
display:flex;
|
|
31
|
-
align-items:center;
|
|
32
|
-
justify-content:center;
|
|
33
|
-
padding:20px;
|
|
34
|
-
background:rgba(15,23,42,.55);
|
|
35
|
-
backdrop-filter:blur(6px) saturate(120%);
|
|
36
|
-
-webkit-backdrop-filter:blur(6px) saturate(120%);
|
|
37
|
-
opacity:0;
|
|
38
|
-
transition:opacity .25s ease;
|
|
39
|
-
z-index:10000;
|
|
40
|
-
}
|
|
41
|
-
.jt-modal-overlay.show{
|
|
42
|
-
opacity:1;
|
|
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;
|
|
43
59
|
}
|
|
44
|
-
|
|
45
|
-
/* Base modal */
|
|
60
|
+
.jt-modal-overlay.show{opacity:1}
|
|
46
61
|
.jt-modal{
|
|
47
62
|
width:100%;
|
|
48
63
|
max-width:520px;
|
|
49
64
|
border-radius:18px;
|
|
50
65
|
padding:24px;
|
|
51
|
-
|
|
52
66
|
opacity:0;
|
|
53
|
-
transform:translateY(40px) scale(.96);
|
|
54
|
-
transition:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.jt-modal.show{
|
|
60
|
-
opacity:1;
|
|
61
|
-
transform:translateY(0) scale(1);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.jt-modal-header{
|
|
65
|
-
font-size:18px;
|
|
66
|
-
font-weight:600;
|
|
67
|
-
letter-spacing:.3px;
|
|
68
|
-
margin-bottom:10px;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.jt-modal-body{
|
|
72
|
-
font-size:14.5px;
|
|
73
|
-
line-height:1.6;
|
|
74
|
-
opacity:.85;
|
|
75
|
-
margin-bottom:22px;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.jt-modal-actions{
|
|
79
|
-
display:flex;
|
|
80
|
-
justify-content:flex-end;
|
|
81
|
-
gap:12px;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.jt-modal-btn{
|
|
85
|
-
min-width:88px;
|
|
86
|
-
padding:8px 16px;
|
|
87
|
-
border-radius:12px;
|
|
88
|
-
font-size:13.5px;
|
|
89
|
-
font-weight:500;
|
|
90
|
-
cursor:pointer;
|
|
91
|
-
transition:all .2s ease;
|
|
92
|
-
border:1px solid rgba(255,255,255,.08);
|
|
93
|
-
background:rgba(255,255,255,.04);
|
|
94
|
-
color:inherit;
|
|
95
|
-
}
|
|
96
|
-
.jt-modal-btn:hover{
|
|
97
|
-
background:rgba(255,255,255,.08);
|
|
98
|
-
transform:translateY(-1px);
|
|
99
|
-
}
|
|
100
|
-
.jt-modal-btn:active{
|
|
101
|
-
transform:translateY(0);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.jt-modal-btn.primary{
|
|
105
|
-
background:#6366f1;
|
|
106
|
-
border-color:#6366f1;
|
|
107
|
-
color:#fff;
|
|
108
|
-
}
|
|
109
|
-
.jt-modal-btn.primary:hover{
|
|
110
|
-
background:#5458ee;
|
|
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;
|
|
111
71
|
}
|
|
112
|
-
`;function rt(e=J){if(!y||H)return;if(document.getElementById("juice-toast-style")){H=!0;return}const t=document.createElement("style");t.id="juice-toast-style",t.textContent=e,document.head.appendChild(t),H=!0}const K=(()=>{let e=1;return()=>"jt-"+e++})();function _(){return Date.now()}function F(e,t){return Object.assign({},e||{},t||{})}function xt(e,t,o){return Math.max(t,Math.min(o,e))}function lt(e){if(!e)return"";const t=document.createElement("template");t.innerHTML=e,t.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(l){Array.from(l.childNodes).forEach(c=>{if(c.nodeType===1){const h=c.tagName.toLowerCase();o.includes(h)?(Array.from(c.attributes||[]).forEach(g=>{const m=g.name.toLowerCase(),f=g.value||"";(m.startsWith("on")||(m==="href"||m==="src"||m==="xlink:href")&&f.trim().toLowerCase().startsWith("javascript:")||h==="img"&&m==="srcset")&&c.removeAttribute(g.name)}),r(c)):c.replaceWith(...Array.from(c.childNodes))}})})(t.content),t.innerHTML}const P={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)"}},ct={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},_t={success:"jt-bounce",error:"jt-shake",warning:"jt-shake",info:"jt-pulse",loading:"jt-spin"},j={_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,playSound:null,dev:!1,injectCSS:!0,css:null},_config:{},_theme:"dark",_plugins:[],_queue:new q,_queueDedupe:new Set,_activeMap:new Map,_roots:new Map,_modalStack:[],setup(e={}){const t=e,{duration:o,maxVisible:r}=t,l=yt(t,["duration","maxVisible"]);o&&(this._defaults.duration=o),r&&(this._defaults.maxVisible=r),this._config=F(this._config,l),this._registerTypes()},use(e){typeof e=="function"&&this._plugins.push(e)},addType(e,t={}){this._config[e]=t,this._registerTypes()},defineTheme(e,t={}){P[e]=F(P[e]||{},t)},setTheme(e){this._theme=e,y&&this._roots.forEach(t=>t.dataset.theme=e)},clear(){this._queue=new q,this._queueDedupe.clear()},destroy(){this.clear(),y&&(this._roots.forEach(e=>e.remove()),this._roots.clear())},promise(e,t={}){if(!e||typeof e.then!="function"){this._warn("promise expects a Promise");return}const o={id:K()}.id,r=t.timeout;this._enqueue("loading",B(W({},jt(t.loading,"Loading...")),{groupId:o,duration:0}));let l=null;r&&(l=setTimeout(()=>{this._enqueue("error",{message:t.timeoutMessage||"Request timeout",groupId:o}),c()},r));const c=()=>{l&&clearTimeout(l)};return e.then(h=>{c(),this._enqueue("success",B(W({},dt(t.success,h,"Success")),{groupId:o}))}).catch(h=>{c(),this._enqueue("error",B(W({},dt(t.error,h,"Error")),{groupId:o}))}),{cancel:()=>{this._enqueue("info",{message:t.cancelMessage||"Cancelled",groupId:o}),l&&clearTimeout(l)}}},modal(e={}){var t;if(!y)return;this._defaults.injectCSS!==!1&&rt(this._defaults.css||J);const o=F({title:"",message:"",html:null,block:!0,blur:!0,closeOnOverlay:!0,closable:!0,animation:"scale",actions:[],theme:this._theme},e),r=P[o.theme]||P.dark,l=document.createElement("div");l.className="jt-modal-overlay",o.block?l.style.pointerEvents="all":l.style.pointerEvents="none",o.blur||(l.style.backdropFilter="none",l.style.webkitBackdropFilter="none");const c=document.createElement("div");if(c.className=`jt-modal jt-anim-${o.animation}`,c.style.background=r.bg,c.style.color=r.color,c.style.border=r.border||"none",o.title){const m=document.createElement("div");m.className="jt-modal-header",m.textContent=o.title,c.appendChild(m)}const h=document.createElement("div");if(h.className="jt-modal-body",o.html?h.innerHTML=lt(o.html):h.textContent=o.message||"",c.appendChild(h),(t=o.actions)!=null&&t.length){const m=document.createElement("div");m.className="jt-modal-actions",o.actions.forEach(f=>{const w=document.createElement("button");w.className="jt-modal-btn"+(f.primary?" primary":""),w.textContent=f.label||"OK",w.onclick=M=>{var S;M.stopPropagation(),(S=f.onClick)==null||S.call(f,M),f.closeOnClick!==!1&&g()},m.appendChild(w)}),c.appendChild(m)}l.appendChild(c),document.body.appendChild(l),o.block&&(document.body.style.overflow="hidden"),requestAnimationFrame(()=>{l.classList.add("show"),c.classList.add("show")});const g=()=>{l.classList.remove("show"),c.classList.remove("show"),setTimeout(()=>{l.remove(),o.block&&(document.body.style.overflow="")},300)};if(o.closable){o.closeOnOverlay&&l.addEventListener("click",f=>{f.target===l&&g()});const m=f=>{f.key==="Escape"&&(g(),document.removeEventListener("keydown",m))};document.addEventListener("keydown",m)}return{close:g}},_registerTypes(){Object.keys(this._config).forEach(e=>{if(typeof this[e]=="function"&&!this[e].__auto)return;const t=o=>this._enqueue(e,o);t.__auto=!0,this[e]=t})},_enqueue(e,t={}){var o,r;const l=(r=(o=this._priorityMap)==null?void 0:o[t.priority])!=null?r:2,c=t.dedupeKey;if(c&&this._queueDedupe.has(c)){this._defaults.dev&&console.log("[JuiceToast] deduped",c);return}const h={id:K(),type:e,payload:t,priority:l};c&&this._queueDedupe.add(c),this._queue.push(h,l),this._processQueue()},_processQueue(){var e;if(!y)return;const t=this._defaults.maxVisible;for(;this._queue.size>0;){const o=this._queue.pop();if(!o)break;const r=((e=o.payload)==null?void 0:e.position)||"bottom-right",l=this._getRoot(r);if(Array.from(l.children).length>=t){this._queue.push(o,o.priority-.001);break}this._showToast(o.type,o.payload,o.id)}},_getRoot(e="bottom-right"){if(!y)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",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"}return document.body.appendChild(t),this._roots.set(e,t),t},_warn(e){this._defaults.dev&&typeof console!="undefined"&&console.warn("[JuiceToast]",e)},_playSound(e){if(!y)return;const t=typeof e=="string"&&e?e:this._defaults.playSound;if(t)try{const o=new Audio(t);o.volume=.6,o.play().catch(()=>{})}catch(o){}},_updateStackPositionsFor(e){const t=Array.from(e.children);e.dataset.position&&e.dataset.position.includes("bottom"),t.forEach((o,r)=>{const l=r,c=l*12;o.style.setProperty("--jt-stack-y",`-${c}px`),o.style.setProperty("--jt-stack-scale",1-l*.04),o.style.setProperty("--jt-stack-opacity",1-l*.12),o.style.zIndex=1e3-l})},_runPlugins(e){this._plugins.forEach(t=>{try{t(e)}catch(o){this._warn("Plugin error: "+o.message)}})},_normalizeGlass(e){if(e===!0)return 60;if(!e)return 0;const t=Number(e);return Number.isFinite(t)?xt(t,0,100):0},_showToast(e,t={},o){var r,l,c,h,g,m,f,w,M,S,Q,G,Z;if(!y)return;this._defaults.injectCSS!==!1&&rt(this._defaults.css||J);const ut=this._config[e]||{},pt=typeof t=="object"?t:{message:String(t)},n=F(ut,pt);n.icon=(r=n.icon)!=null?r:n.icon_left_top,n.position=(c=(l=n.position)!=null?l:n.toast)!=null?c:"bottom-right",n.closable=(g=(h=n.closable)!=null?h:n.closeable)!=null?g:!0,n.duration=(m=n.duration)!=null?m:this._defaults.duration;const Y=P[n.theme||this._theme]||{},v=o||K(),a=document.createElement("div");if(a.className="juice-toast",a.dataset.toastId=v,a.dataset.position=n.position,a.tabIndex=0,a.setAttribute("role","status"),a.style.position="relative",a.style.pointerEvents="auto",a.style.background=n.bg||Y.bg,a.style.color=n.color||Y.color,a.style.border=n.border||Y.border||"none",n.size&&ct[n.size]){const s=ct[n.size];s.width&&(a.style.width=s.width),s.padding&&(a.style.padding=s.padding)}const b=document.createElement("div");if(b.className="jt-content",n.title){const s=document.createElement("div");s.className="jt-title",s.textContent=n.title,b.appendChild(s)}const k=document.createElement("div");if(k.className="jt-message",n.html?k.innerHTML=lt(n.html):typeof n.message=="string"?n.message.split(/(`[^`]+`)/g).forEach(s=>{if(s.startsWith("`")&&s.endsWith("`")){const d=document.createElement("code");d.textContent=s.slice(1,-1),k.appendChild(d)}else k.appendChild(document.createTextNode(s))}):n.message&&(k.textContent=String(n.message)),b.appendChild(k),Array.isArray(n.actions)&&n.actions.length){const s=document.createElement("div");s.className="jt-actions",n.actions.forEach(d=>{const I=document.createElement("button");I.className="jt-action",I.textContent=d.label||"Action",I.onclick=ot=>{var nt;ot.stopPropagation(),(nt=d.onClick)==null||nt.call(d,ot),d.closeOnClick&&L()},s.appendChild(I)}),b.appendChild(s)}let p=null;if(n.icon){if(p=document.createElement("i"),p.className=["icon",n.iconPack||"",n.icon].join(" ").trim(),n.iconSize&&(p.style.fontSize=n.iconSize),!vt){const s=n.iconAnim||_t[e];s&&p.classList.add(s)}(n.iconLink||n.iconAnimate)&&(p.classList.add("icon-clickable"),p.addEventListener("click",s=>{s.stopPropagation(),n.iconAnimate&&(p.classList.remove(n.iconAnimate),p.offsetWidth,p.classList.add(n.iconAnimate)),n.iconLink&&window.open(n.iconLink,"_blank","noopener")}))}let u=null;if(n.avatar){u=document.createElement("img");const s=typeof n.avatar=="string"&&n.avatar?n.avatar:n.avatarSrc||"";s&&(u.src=s),u.alt=n.avatarAlt||n.title||"avatar",u.className="jt-avatar",u.loading=n.avatarLazy?"lazy":"eager",u.style.width=u.style.width||"36px",u.style.height=u.style.height||"36px",u.style.borderRadius=u.style.borderRadius||"50%",u.style.objectFit=u.style.objectFit||"cover",u.style.flexShrink="0";const d=n.avatarPosition||"left";d==="left"?u.style.marginRight=(f=n.avatarSpacing)!=null?f:"10px":d==="right"?u.style.marginLeft=(w=n.avatarSpacing)!=null?w:"10px":d==="top"&&(u.style.marginBottom=(M=n.avatarSpacing)!=null?M:"8px")}const D=n.avatarPosition||"left";u&&D==="top"?(a.classList.add("jt-avatar-top"),a.style.flexDirection="column",a.style.alignItems="flex-start",a.appendChild(u),p&&n.iconPosition==="top"?(a.appendChild(p),a.appendChild(b)):p&&n.iconPosition==="right"?(a.appendChild(b),a.appendChild(p)):(p&&a.appendChild(p),a.appendChild(b))):(a.style.flexDirection="row",a.style.alignItems="center",u&&D==="left"&&a.appendChild(u),p&&n.iconPosition==="right"?(a.appendChild(b),a.appendChild(p)):p&&n.iconPosition==="top"?(a.classList.add("jt-icon-top"),a.appendChild(p),a.appendChild(b)):(p&&a.appendChild(p),a.appendChild(b)),u&&D==="right"&&a.appendChild(u));let E=null;if(n.progress&&((S=n.duration)!=null?S:this._defaults.duration)>0&&(E=document.createElement("div"),E.className="jt-progress",n.progressColor&&(E.style.background=n.progressColor),a.appendChild(E)),n.undo){const s=document.createElement("button");s.className="jt-action",s.textContent="Undo",s.onclick=()=>{try{n.undo()}catch(d){}L()},b.appendChild(s)}if(n.closable){const s=document.createElement("span");s.className="juice-toast-close",s.tabIndex=0,s.textContent="\xD7",s.addEventListener("click",d=>{d.stopPropagation(),L()}),a.appendChild(s)}const x=this._getRoot(n.position||"bottom-right");if(!x)return;if(n.groupId){const s=Array.from(x.children).find(d=>d.dataset.groupId===n.groupId);if(s){let d=s.querySelector(".jt-count");d||(d=document.createElement("span"),d.className="jt-count",d.style.marginLeft="6px",(Q=s.querySelector(".jt-title"))==null||Q.appendChild(d),d.textContent="1"),d.textContent=String(parseInt(d.textContent||"1")+1);return}a.dataset.groupId=n.groupId}const tt=this._defaults.maxVisible;tt&&x.children.length>=tt&&x.removeChild(x.firstElementChild),x.appendChild(a);const i={id:v,toast:a,cfg:n,createdAt:_(),remaining:(G=n.duration)!=null?G:this._defaults.duration,raf:null,timer:null,start:_(),paused:!1,_boundMove:null,_boundUp:null};this._activeMap.set(v,i),this._runPlugins({toast:a,cfg:n,type:e,root:x}),this._updateStackPositionsFor(x),requestAnimationFrame(()=>a.classList.add("show"));let X=0,R=0,C=0,T=0,$=!1;const A=s=>{const d=s.touches?s.touches[0]:s;X=d.clientX,R=d.clientY,$=!0,i.paused=!0,i.raf&&(cancelAnimationFrame(i.raf),i.raf=null),a.style.transition="none",i._boundMove=mt,i._boundUp=ht,document.addEventListener("touchmove",i._boundMove,{passive:!0}),document.addEventListener("mousemove",i._boundMove),document.addEventListener("touchend",i._boundUp),document.addEventListener("mouseup",i._boundUp)},mt=s=>{if(!$)return;const d=s.touches?s.touches[0]:s;C=d.clientX-X,T=d.clientY-R,Math.abs(C)>Math.abs(T)?a.style.transform=`translateX(${C}px)`:a.style.transform=`translateY(${T}px)`},ht=()=>{$=!1,i.paused=!1,a.style.transition="",Math.abs(C)>(this._defaults.swipeThreshold||60)?(a.style.transform=`translateX(${C>0?1e3:-1e3}px)`,setTimeout(L,220)):a.style.transform="",X=R=C=T=0,i._boundMove&&(document.removeEventListener("touchmove",i._boundMove,{passive:!0}),document.removeEventListener("mousemove",i._boundMove),i._boundMove=null),i._boundUp&&(document.removeEventListener("touchend",i._boundUp),document.removeEventListener("mouseup",i._boundUp),i._boundUp=null),V()};a.addEventListener("touchstart",A,{passive:!0}),a.addEventListener("mousedown",A);const N=()=>{i.paused=!0,i.raf&&(cancelAnimationFrame(i.raf),i.raf=null)},z=()=>{i.paused&&(i.paused=!1,i.start=_(),V())};a.addEventListener("mouseenter",N),a.addEventListener("mouseleave",z),a.addEventListener("focusin",N),a.addEventListener("focusout",z);const O=(Z=n.duration)!=null?Z:this._defaults.duration;function et(){if(!j._activeMap.has(v))return;if(i.paused){i.raf=null,i.start=_();return}const s=_()-i.start;if(i.remaining-=s,i.start=_(),E){const d=Math.max(0,i.remaining/O);E.style.transform=`scaleX(${d})`}if(i.remaining<=0){a.classList.remove("show"),setTimeout(L,280),i.raf=null;return}i.raf=requestAnimationFrame(et)}function V(){O<=0||i.raf||i.paused||(i.start=_(),i.raf=requestAnimationFrame(et))}O>0&&(i.start=_(),i.remaining=O,V());function L(){if(!j._activeMap.has(v))return;a.classList.add("hide"),a.removeEventListener("touchstart",A),a.removeEventListener("mousedown",A),i._boundMove&&(document.removeEventListener("touchmove",i._boundMove,{passive:!0}),document.removeEventListener("mousemove",i._boundMove),i._boundMove=null),i._boundUp&&(document.removeEventListener("touchend",i._boundUp),document.removeEventListener("mouseup",i._boundUp),i._boundUp=null),a.removeEventListener("mouseenter",N),a.removeEventListener("mouseleave",z),a.removeEventListener("focusin",N),a.removeEventListener("focusout",z);const s=j._activeMap.get(v);s!=null&&s.raf&&(cancelAnimationFrame(s.raf),s.raf=null),s!=null&&s.timer&&(clearTimeout(s.timer),s.timer=null),j._activeMap.delete(v);const d=a.parentNode;d&&d.removeChild(a),d&&j._updateStackPositionsFor(d)}return n.undoTimeout&&(i.timer=setTimeout(L,n.undoTimeout)),(n.playSound||this._defaults.playSound)&&this._playSound(n.playSound||this._defaults.playSound),v},_priorityMap:{low:1,normal:2,high:3,urgent:4}};function jt(e,t){return e?typeof e=="string"?{message:t}:e:{message:t}}function dt(e,t,o){return e?typeof e=="function"?{message:e(t)}:typeof e=="string"?{message:e}:e:{message:o}}j.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:"spinner",iconPack:"fas",iconAnim:"jt-spin",duration:0,progress:!0}});export{j as default,j as juiceToast};
|
|
72
|
+
.jt-modal.show{opacity:1;transform:translateY(0) scale(1) rotateX(0deg)}
|
|
73
|
+
.jt-modal-header{font-size:18px;font-weight:600;letter-spacing:.3px;margin-bottom:10px}
|
|
74
|
+
.jt-modal-body{font-size:14.5px;line-height:1.6;opacity:.85;margin-bottom:22px}
|
|
75
|
+
.jt-modal-actions{display:flex;justify-content:flex-end;gap:12px}
|
|
76
|
+
.jt-modal-btn{min-width:88px;padding:8px 16px;border-radius:12px;font-size:13.5px;font-weight:500;cursor:pointer;transition:all .2s ease;border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.04);color:inherit}
|
|
77
|
+
.jt-modal-btn:hover{background:rgba(255,255,255,.08);transform:translateY(-1px)}
|
|
78
|
+
.jt-modal-btn.primary{background:#6366f1;border-color:#6366f1;color:#fff}
|
|
79
|
+
#juice-toast-root[data-parallax="true"] .juice-toast{transition: transform 0.12s cubic-bezier(.2,.8,.2,1), opacity .2s}
|
|
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};
|
|
113
81
|
//# sourceMappingURL=juice-toast.esm.js.map
|
package/dist/juice-toast.umd.js
CHANGED
|
@@ -1,113 +1,81 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
/* JuiceToast base (
|
|
3
|
-
#juice-toast-root,[id^="juice-toast-root-"]{position:fixed;z-index:9999;display:flex;pointer-events:none;gap:10px}
|
|
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
|
+
/* JuiceToast base (extended) */
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
}
|
|
35
|
+
@keyframes jt-slide-in{0%{opacity:0;transform:translateY(20px) scale(0.98)}100%{opacity:1;transform:translateY(0) scale(1)}}
|
|
36
|
+
@keyframes jt-slide-out{0%{opacity:1;transform:translateY(0) scale(1)}100%{opacity:0;transform:translateY(20px) scale(0.98)}}
|
|
37
|
+
@keyframes jt-bounce{0%{transform:translateY(0)}25%{transform:translateY(-6px)}50%{transform:translateY(0)}75%{transform:translateY(-3px)}100%{transform:translateY(0)}}
|
|
38
|
+
@keyframes jt-shake{0%{transform:translateX(0)}20%{transform:translateX(-6px)}40%{transform:translateX(6px)}60%{transform:translateX(-4px)}80%{transform:translateX(2px)}100%{transform:translateX(0)}}
|
|
39
|
+
@keyframes jt-pulse{0%{transform:scale(1)}50%{transform:scale(1.02)}100%{transform:scale(1)}}
|
|
40
|
+
@keyframes jt-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}
|
|
41
|
+
.juice-toast.show{animation:jt-slide-in .32s cubic-bezier(0.4,0,0.2,1) forwards;opacity:1}
|
|
42
|
+
.juice-toast.hide{animation:jt-slide-out .28s cubic-bezier(0.4,0,0.2,1) forwards;opacity:0;pointer-events:none}
|
|
14
43
|
.juice-toast .icon{width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center;border-radius:8px;background:rgba(255,255,255,.06)}
|
|
15
|
-
.jt-content{display:flex;flex-direction:column;gap:4px;flex:1}
|
|
16
|
-
.jt-title{font-weight:700;font-size:13px}
|
|
17
|
-
.jt-message{font-size:13px;opacity:.95}
|
|
44
|
+
.jt-content{display:flex;flex-direction:column;gap:4px;flex:1;min-width:0}
|
|
45
|
+
.jt-title{font-weight:700;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
46
|
+
.jt-message{font-size:13px;opacity:.95;word-break:break-word}
|
|
18
47
|
.jt-actions{display:flex;gap:8px;margin-top:10px}
|
|
19
48
|
.jt-action{border:1px solid currentColor;padding:4px 10px;border-radius:6px;font-size:12px;cursor:pointer;background:transparent}
|
|
20
49
|
.jt-progress{position:absolute;left:0;bottom:0;height:4px;width:100%;border-radius:2px;background:linear-gradient(90deg,#4ade80,#22c55e);transform-origin:left;transform:scaleX(1);transition:transform linear}
|
|
21
|
-
|
|
22
|
-
/* avatar specific */
|
|
50
|
+
.juice-toast.swipe-dismissing {opacity: 0; transition: transform 0.22s ease-out, opacity 0.22s ease-out;}
|
|
23
51
|
.jt-avatar{width:36px;height:36px;border-radius:50%;object-fit:cover;flex-shrink:0}
|
|
24
52
|
|
|
25
|
-
/*
|
|
26
|
-
|
|
53
|
+
/* avatar top variant */
|
|
54
|
+
.juice-toast.jt-avatar-top{flex-direction:column;align-items:flex-start}
|
|
55
|
+
|
|
56
|
+
/* modal */
|
|
27
57
|
.jt-modal-overlay{
|
|
28
|
-
position:fixed;
|
|
29
|
-
inset:0;
|
|
30
|
-
display:flex;
|
|
31
|
-
align-items:center;
|
|
32
|
-
justify-content:center;
|
|
33
|
-
padding:20px;
|
|
34
|
-
background:rgba(15,23,42,.55);
|
|
35
|
-
backdrop-filter:blur(6px) saturate(120%);
|
|
36
|
-
-webkit-backdrop-filter:blur(6px) saturate(120%);
|
|
37
|
-
opacity:0;
|
|
38
|
-
transition:opacity .25s ease;
|
|
39
|
-
z-index:10000;
|
|
40
|
-
}
|
|
41
|
-
.jt-modal-overlay.show{
|
|
42
|
-
opacity:1;
|
|
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;
|
|
43
59
|
}
|
|
44
|
-
|
|
45
|
-
/* Base modal */
|
|
60
|
+
.jt-modal-overlay.show{opacity:1}
|
|
46
61
|
.jt-modal{
|
|
47
62
|
width:100%;
|
|
48
63
|
max-width:520px;
|
|
49
64
|
border-radius:18px;
|
|
50
65
|
padding:24px;
|
|
51
|
-
|
|
52
66
|
opacity:0;
|
|
53
|
-
transform:translateY(40px) scale(.96);
|
|
54
|
-
transition:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.jt-modal.show{
|
|
60
|
-
opacity:1;
|
|
61
|
-
transform:translateY(0) scale(1);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.jt-modal-header{
|
|
65
|
-
font-size:18px;
|
|
66
|
-
font-weight:600;
|
|
67
|
-
letter-spacing:.3px;
|
|
68
|
-
margin-bottom:10px;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.jt-modal-body{
|
|
72
|
-
font-size:14.5px;
|
|
73
|
-
line-height:1.6;
|
|
74
|
-
opacity:.85;
|
|
75
|
-
margin-bottom:22px;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.jt-modal-actions{
|
|
79
|
-
display:flex;
|
|
80
|
-
justify-content:flex-end;
|
|
81
|
-
gap:12px;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.jt-modal-btn{
|
|
85
|
-
min-width:88px;
|
|
86
|
-
padding:8px 16px;
|
|
87
|
-
border-radius:12px;
|
|
88
|
-
font-size:13.5px;
|
|
89
|
-
font-weight:500;
|
|
90
|
-
cursor:pointer;
|
|
91
|
-
transition:all .2s ease;
|
|
92
|
-
border:1px solid rgba(255,255,255,.08);
|
|
93
|
-
background:rgba(255,255,255,.04);
|
|
94
|
-
color:inherit;
|
|
95
|
-
}
|
|
96
|
-
.jt-modal-btn:hover{
|
|
97
|
-
background:rgba(255,255,255,.08);
|
|
98
|
-
transform:translateY(-1px);
|
|
99
|
-
}
|
|
100
|
-
.jt-modal-btn:active{
|
|
101
|
-
transform:translateY(0);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.jt-modal-btn.primary{
|
|
105
|
-
background:#6366f1;
|
|
106
|
-
border-color:#6366f1;
|
|
107
|
-
color:#fff;
|
|
108
|
-
}
|
|
109
|
-
.jt-modal-btn.primary:hover{
|
|
110
|
-
background:#5458ee;
|
|
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;
|
|
111
71
|
}
|
|
112
|
-
`;function ne(t=V){if(!y||$)return;if(document.getElementById("juice-toast-style")){$=!0;return}const e=document.createElement("style");e.id="juice-toast-style",e.textContent=t,document.head.appendChild(e),$=!0}const W=(()=>{let t=1;return()=>"jt-"+t++})();function v(){return Date.now()}function z(t,e){return Object.assign({},t||{},e||{})}function be(t,e,n){return Math.max(e,Math.min(n,t))}function oe(t){if(!t)return"";const e=document.createElement("template");e.innerHTML=t,e.content.querySelectorAll("script, style, iframe").forEach(r=>r.remove());const n=["b","i","u","strong","em","code","pre","ul","ol","li","br","p","span","img","h1","h2","h3","h4","h5","h6","a"];return(function r(l){Array.from(l.childNodes).forEach(c=>{if(c.nodeType===1){const h=c.tagName.toLowerCase();n.includes(h)?(Array.from(c.attributes||[]).forEach(g=>{const m=g.name.toLowerCase(),f=g.value||"";(m.startsWith("on")||(m==="href"||m==="src"||m==="xlink:href")&&f.trim().toLowerCase().startsWith("javascript:")||h==="img"&&m==="srcset")&&c.removeAttribute(g.name)}),r(c)):c.replaceWith(...Array.from(c.childNodes))}})})(e.content),e.innerHTML}const P={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)"}},se={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},ye={success:"jt-bounce",error:"jt-shake",warning:"jt-shake",info:"jt-pulse",loading:"jt-spin"},x={_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,playSound:null,dev:!1,injectCSS:!0,css:null},_config:{},_theme:"dark",_plugins:[],_queue:new T,_queueDedupe:new Set,_activeMap:new Map,_roots:new Map,_modalStack:[],setup(t={}){const e=t,{duration:n,maxVisible:r}=e,l=fe(e,["duration","maxVisible"]);n&&(this._defaults.duration=n),r&&(this._defaults.maxVisible=r),this._config=z(this._config,l),this._registerTypes()},use(t){typeof t=="function"&&this._plugins.push(t)},addType(t,e={}){this._config[t]=e,this._registerTypes()},defineTheme(t,e={}){P[t]=z(P[t]||{},e)},setTheme(t){this._theme=t,y&&this._roots.forEach(e=>e.dataset.theme=t)},clear(){this._queue=new T,this._queueDedupe.clear()},destroy(){this.clear(),y&&(this._roots.forEach(t=>t.remove()),this._roots.clear())},promise(t,e={}){if(!t||typeof t.then!="function"){this._warn("promise expects a Promise");return}const n={id:W()}.id,r=e.timeout;this._enqueue("loading",R(X({},ve(e.loading,"Loading...")),{groupId:n,duration:0}));let l=null;r&&(l=setTimeout(()=>{this._enqueue("error",{message:e.timeoutMessage||"Request timeout",groupId:n}),c()},r));const c=()=>{l&&clearTimeout(l)};return t.then(h=>{c(),this._enqueue("success",R(X({},ae(e.success,h,"Success")),{groupId:n}))}).catch(h=>{c(),this._enqueue("error",R(X({},ae(e.error,h,"Error")),{groupId:n}))}),{cancel:()=>{this._enqueue("info",{message:e.cancelMessage||"Cancelled",groupId:n}),l&&clearTimeout(l)}}},modal(t={}){var e;if(!y)return;this._defaults.injectCSS!==!1&&ne(this._defaults.css||V);const n=z({title:"",message:"",html:null,block:!0,blur:!0,closeOnOverlay:!0,closable:!0,animation:"scale",actions:[],theme:this._theme},t),r=P[n.theme]||P.dark,l=document.createElement("div");l.className="jt-modal-overlay",n.block?l.style.pointerEvents="all":l.style.pointerEvents="none",n.blur||(l.style.backdropFilter="none",l.style.webkitBackdropFilter="none");const c=document.createElement("div");if(c.className=`jt-modal jt-anim-${n.animation}`,c.style.background=r.bg,c.style.color=r.color,c.style.border=r.border||"none",n.title){const m=document.createElement("div");m.className="jt-modal-header",m.textContent=n.title,c.appendChild(m)}const h=document.createElement("div");if(h.className="jt-modal-body",n.html?h.innerHTML=oe(n.html):h.textContent=n.message||"",c.appendChild(h),(e=n.actions)!=null&&e.length){const m=document.createElement("div");m.className="jt-modal-actions",n.actions.forEach(f=>{const k=document.createElement("button");k.className="jt-modal-btn"+(f.primary?" primary":""),k.textContent=f.label||"OK",k.onclick=q=>{var A;q.stopPropagation(),(A=f.onClick)==null||A.call(f,q),f.closeOnClick!==!1&&g()},m.appendChild(k)}),c.appendChild(m)}l.appendChild(c),document.body.appendChild(l),n.block&&(document.body.style.overflow="hidden"),requestAnimationFrame(()=>{l.classList.add("show"),c.classList.add("show")});const g=()=>{l.classList.remove("show"),c.classList.remove("show"),setTimeout(()=>{l.remove(),n.block&&(document.body.style.overflow="")},300)};if(n.closable){n.closeOnOverlay&&l.addEventListener("click",f=>{f.target===l&&g()});const m=f=>{f.key==="Escape"&&(g(),document.removeEventListener("keydown",m))};document.addEventListener("keydown",m)}return{close:g}},_registerTypes(){Object.keys(this._config).forEach(t=>{if(typeof this[t]=="function"&&!this[t].__auto)return;const e=n=>this._enqueue(t,n);e.__auto=!0,this[t]=e})},_enqueue(t,e={}){var n,r;const l=(r=(n=this._priorityMap)==null?void 0:n[e.priority])!=null?r:2,c=e.dedupeKey;if(c&&this._queueDedupe.has(c)){this._defaults.dev&&console.log("[JuiceToast] deduped",c);return}const h={id:W(),type:t,payload:e,priority:l};c&&this._queueDedupe.add(c),this._queue.push(h,l),this._processQueue()},_processQueue(){var t;if(!y)return;const e=this._defaults.maxVisible;for(;this._queue.size>0;){const n=this._queue.pop();if(!n)break;const r=((t=n.payload)==null?void 0:t.position)||"bottom-right",l=this._getRoot(r);if(Array.from(l.children).length>=e){this._queue.push(n,n.priority-.001);break}this._showToast(n.type,n.payload,n.id)}},_getRoot(t="bottom-right"){if(!y)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",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"}return document.body.appendChild(e),this._roots.set(t,e),e},_warn(t){this._defaults.dev&&typeof console!="undefined"&&console.warn("[JuiceToast]",t)},_playSound(t){if(!y)return;const e=typeof t=="string"&&t?t:this._defaults.playSound;if(e)try{const n=new Audio(e);n.volume=.6,n.play().catch(()=>{})}catch(n){}},_updateStackPositionsFor(t){const e=Array.from(t.children);t.dataset.position&&t.dataset.position.includes("bottom"),e.forEach((n,r)=>{const l=r,c=l*12;n.style.setProperty("--jt-stack-y",`-${c}px`),n.style.setProperty("--jt-stack-scale",1-l*.04),n.style.setProperty("--jt-stack-opacity",1-l*.12),n.style.zIndex=1e3-l})},_runPlugins(t){this._plugins.forEach(e=>{try{e(t)}catch(n){this._warn("Plugin error: "+n.message)}})},_normalizeGlass(t){if(t===!0)return 60;if(!t)return 0;const e=Number(t);return Number.isFinite(e)?be(e,0,100):0},_showToast(t,e={},n){var r,l,c,h,g,m,f,k,q,A,ie,re,le;if(!y)return;this._defaults.injectCSS!==!1&&ne(this._defaults.css||V);const xe=this._config[t]||{},_e=typeof e=="object"?e:{message:String(e)},o=z(xe,_e);o.icon=(r=o.icon)!=null?r:o.icon_left_top,o.position=(c=(l=o.position)!=null?l:o.toast)!=null?c:"bottom-right",o.closable=(g=(h=o.closable)!=null?h:o.closeable)!=null?g:!0,o.duration=(m=o.duration)!=null?m:this._defaults.duration;const B=P[o.theme||this._theme]||{},_=n||W(),s=document.createElement("div");if(s.className="juice-toast",s.dataset.toastId=_,s.dataset.position=o.position,s.tabIndex=0,s.setAttribute("role","status"),s.style.position="relative",s.style.pointerEvents="auto",s.style.background=o.bg||B.bg,s.style.color=o.color||B.color,s.style.border=o.border||B.border||"none",o.size&&se[o.size]){const a=se[o.size];a.width&&(s.style.width=a.width),a.padding&&(s.style.padding=a.padding)}const b=document.createElement("div");if(b.className="jt-content",o.title){const a=document.createElement("div");a.className="jt-title",a.textContent=o.title,b.appendChild(a)}const E=document.createElement("div");if(E.className="jt-message",o.html?E.innerHTML=oe(o.html):typeof o.message=="string"?o.message.split(/(`[^`]+`)/g).forEach(a=>{if(a.startsWith("`")&&a.endsWith("`")){const d=document.createElement("code");d.textContent=a.slice(1,-1),E.appendChild(d)}else E.appendChild(document.createTextNode(a))}):o.message&&(E.textContent=String(o.message)),b.appendChild(E),Array.isArray(o.actions)&&o.actions.length){const a=document.createElement("div");a.className="jt-actions",o.actions.forEach(d=>{const D=document.createElement("button");D.className="jt-action",D.textContent=d.label||"Action",D.onclick=ue=>{var pe;ue.stopPropagation(),(pe=d.onClick)==null||pe.call(d,ue),d.closeOnClick&&M()},a.appendChild(D)}),b.appendChild(a)}let p=null;if(o.icon){if(p=document.createElement("i"),p.className=["icon",o.iconPack||"",o.icon].join(" ").trim(),o.iconSize&&(p.style.fontSize=o.iconSize),!ge){const a=o.iconAnim||ye[t];a&&p.classList.add(a)}(o.iconLink||o.iconAnimate)&&(p.classList.add("icon-clickable"),p.addEventListener("click",a=>{a.stopPropagation(),o.iconAnimate&&(p.classList.remove(o.iconAnimate),p.offsetWidth,p.classList.add(o.iconAnimate)),o.iconLink&&window.open(o.iconLink,"_blank","noopener")}))}let u=null;if(o.avatar){u=document.createElement("img");const a=typeof o.avatar=="string"&&o.avatar?o.avatar:o.avatarSrc||"";a&&(u.src=a),u.alt=o.avatarAlt||o.title||"avatar",u.className="jt-avatar",u.loading=o.avatarLazy?"lazy":"eager",u.style.width=u.style.width||"36px",u.style.height=u.style.height||"36px",u.style.borderRadius=u.style.borderRadius||"50%",u.style.objectFit=u.style.objectFit||"cover",u.style.flexShrink="0";const d=o.avatarPosition||"left";d==="left"?u.style.marginRight=(f=o.avatarSpacing)!=null?f:"10px":d==="right"?u.style.marginLeft=(k=o.avatarSpacing)!=null?k:"10px":d==="top"&&(u.style.marginBottom=(q=o.avatarSpacing)!=null?q:"8px")}const H=o.avatarPosition||"left";u&&H==="top"?(s.classList.add("jt-avatar-top"),s.style.flexDirection="column",s.style.alignItems="flex-start",s.appendChild(u),p&&o.iconPosition==="top"?(s.appendChild(p),s.appendChild(b)):p&&o.iconPosition==="right"?(s.appendChild(b),s.appendChild(p)):(p&&s.appendChild(p),s.appendChild(b))):(s.style.flexDirection="row",s.style.alignItems="center",u&&H==="left"&&s.appendChild(u),p&&o.iconPosition==="right"?(s.appendChild(b),s.appendChild(p)):p&&o.iconPosition==="top"?(s.classList.add("jt-icon-top"),s.appendChild(p),s.appendChild(b)):(p&&s.appendChild(p),s.appendChild(b)),u&&H==="right"&&s.appendChild(u));let C=null;if(o.progress&&((A=o.duration)!=null?A:this._defaults.duration)>0&&(C=document.createElement("div"),C.className="jt-progress",o.progressColor&&(C.style.background=o.progressColor),s.appendChild(C)),o.undo){const a=document.createElement("button");a.className="jt-action",a.textContent="Undo",a.onclick=()=>{try{o.undo()}catch(d){}M()},b.appendChild(a)}if(o.closable){const a=document.createElement("span");a.className="juice-toast-close",a.tabIndex=0,a.textContent="\xD7",a.addEventListener("click",d=>{d.stopPropagation(),M()}),s.appendChild(a)}const j=this._getRoot(o.position||"bottom-right");if(!j)return;if(o.groupId){const a=Array.from(j.children).find(d=>d.dataset.groupId===o.groupId);if(a){let d=a.querySelector(".jt-count");d||(d=document.createElement("span"),d.className="jt-count",d.style.marginLeft="6px",(ie=a.querySelector(".jt-title"))==null||ie.appendChild(d),d.textContent="1"),d.textContent=String(parseInt(d.textContent||"1")+1);return}s.dataset.groupId=o.groupId}const ce=this._defaults.maxVisible;ce&&j.children.length>=ce&&j.removeChild(j.firstElementChild),j.appendChild(s);const i={id:_,toast:s,cfg:o,createdAt:v(),remaining:(re=o.duration)!=null?re:this._defaults.duration,raf:null,timer:null,start:v(),paused:!1,_boundMove:null,_boundUp:null};this._activeMap.set(_,i),this._runPlugins({toast:s,cfg:o,type:t,root:j}),this._updateStackPositionsFor(j),requestAnimationFrame(()=>s.classList.add("show"));let J=0,K=0,L=0,O=0,Q=!1;const I=a=>{const d=a.touches?a.touches[0]:a;J=d.clientX,K=d.clientY,Q=!0,i.paused=!0,i.raf&&(cancelAnimationFrame(i.raf),i.raf=null),s.style.transition="none",i._boundMove=je,i._boundUp=we,document.addEventListener("touchmove",i._boundMove,{passive:!0}),document.addEventListener("mousemove",i._boundMove),document.addEventListener("touchend",i._boundUp),document.addEventListener("mouseup",i._boundUp)},je=a=>{if(!Q)return;const d=a.touches?a.touches[0]:a;L=d.clientX-J,O=d.clientY-K,Math.abs(L)>Math.abs(O)?s.style.transform=`translateX(${L}px)`:s.style.transform=`translateY(${O}px)`},we=()=>{Q=!1,i.paused=!1,s.style.transition="",Math.abs(L)>(this._defaults.swipeThreshold||60)?(s.style.transform=`translateX(${L>0?1e3:-1e3}px)`,setTimeout(M,220)):s.style.transform="",J=K=L=O=0,i._boundMove&&(document.removeEventListener("touchmove",i._boundMove,{passive:!0}),document.removeEventListener("mousemove",i._boundMove),i._boundMove=null),i._boundUp&&(document.removeEventListener("touchend",i._boundUp),document.removeEventListener("mouseup",i._boundUp),i._boundUp=null),G()};s.addEventListener("touchstart",I,{passive:!0}),s.addEventListener("mousedown",I);const U=()=>{i.paused=!0,i.raf&&(cancelAnimationFrame(i.raf),i.raf=null)},F=()=>{i.paused&&(i.paused=!1,i.start=v(),G())};s.addEventListener("mouseenter",U),s.addEventListener("mouseleave",F),s.addEventListener("focusin",U),s.addEventListener("focusout",F);const Y=(le=o.duration)!=null?le:this._defaults.duration;function de(){if(!x._activeMap.has(_))return;if(i.paused){i.raf=null,i.start=v();return}const a=v()-i.start;if(i.remaining-=a,i.start=v(),C){const d=Math.max(0,i.remaining/Y);C.style.transform=`scaleX(${d})`}if(i.remaining<=0){s.classList.remove("show"),setTimeout(M,280),i.raf=null;return}i.raf=requestAnimationFrame(de)}function G(){Y<=0||i.raf||i.paused||(i.start=v(),i.raf=requestAnimationFrame(de))}Y>0&&(i.start=v(),i.remaining=Y,G());function M(){if(!x._activeMap.has(_))return;s.classList.add("hide"),s.removeEventListener("touchstart",I),s.removeEventListener("mousedown",I),i._boundMove&&(document.removeEventListener("touchmove",i._boundMove,{passive:!0}),document.removeEventListener("mousemove",i._boundMove),i._boundMove=null),i._boundUp&&(document.removeEventListener("touchend",i._boundUp),document.removeEventListener("mouseup",i._boundUp),i._boundUp=null),s.removeEventListener("mouseenter",U),s.removeEventListener("mouseleave",F),s.removeEventListener("focusin",U),s.removeEventListener("focusout",F);const a=x._activeMap.get(_);a!=null&&a.raf&&(cancelAnimationFrame(a.raf),a.raf=null),a!=null&&a.timer&&(clearTimeout(a.timer),a.timer=null),x._activeMap.delete(_);const d=s.parentNode;d&&d.removeChild(s),d&&x._updateStackPositionsFor(d)}return o.undoTimeout&&(i.timer=setTimeout(M,o.undoTimeout)),(o.playSound||this._defaults.playSound)&&this._playSound(o.playSound||this._defaults.playSound),_},_priorityMap:{low:1,normal:2,high:3,urgent:4}};function ve(t,e){return t?typeof t=="string"?{message:e}:t:{message:e}}function ae(t,e,n){return t?typeof t=="function"?{message:t(e)}:typeof t=="string"?{message:t}:t:{message:n}}x.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:"spinner",iconPack:"fas",iconAnim:"jt-spin",duration:0,progress:!0}}),w.default=x,w.juiceToast=x,Object.defineProperty(w,"__esModule",{value:!0})}));
|
|
72
|
+
.jt-modal.show{opacity:1;transform:translateY(0) scale(1) rotateX(0deg)}
|
|
73
|
+
.jt-modal-header{font-size:18px;font-weight:600;letter-spacing:.3px;margin-bottom:10px}
|
|
74
|
+
.jt-modal-body{font-size:14.5px;line-height:1.6;opacity:.85;margin-bottom:22px}
|
|
75
|
+
.jt-modal-actions{display:flex;justify-content:flex-end;gap:12px}
|
|
76
|
+
.jt-modal-btn{min-width:88px;padding:8px 16px;border-radius:12px;font-size:13.5px;font-weight:500;cursor:pointer;transition:all .2s ease;border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.04);color:inherit}
|
|
77
|
+
.jt-modal-btn:hover{background:rgba(255,255,255,.08);transform:translateY(-1px)}
|
|
78
|
+
.jt-modal-btn.primary{background:#6366f1;border-color:#6366f1;color:#fff}
|
|
79
|
+
#juice-toast-root[data-parallax="true"] .juice-toast{transition: transform 0.12s cubic-bezier(.2,.8,.2,1), opacity .2s}
|
|
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})}));
|
|
113
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",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"frontend-ui",
|
|
18
18
|
"browser-notification"
|
|
19
19
|
],
|
|
20
|
-
"license": "
|
|
20
|
+
"license": "Atrsofer-1.0",
|
|
21
21
|
"author": "KhairyK",
|
|
22
22
|
"homepage": "https://github.com/KhairyK/juiceToast",
|
|
23
23
|
"bugs": {
|
|
@@ -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/LICENSE.md
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# MIT License
|
|
2
|
-
|
|
3
|
-
**Project:** JuiceToast
|
|
4
|
-
**Copyright (c) 2026 OpenDN Foundation (Sholehuddin Khairy / KhairyK)**
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Permission
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
of this software and associated documentation files (the “Software”), to deal
|
|
12
|
-
in the Software **without restriction**, including without limitation the rights to:
|
|
13
|
-
|
|
14
|
-
- use
|
|
15
|
-
- copy
|
|
16
|
-
- modify
|
|
17
|
-
- merge
|
|
18
|
-
- publish
|
|
19
|
-
- distribute
|
|
20
|
-
- sublicense
|
|
21
|
-
- and/or sell copies of the Software
|
|
22
|
-
|
|
23
|
-
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## Conditions
|
|
28
|
-
|
|
29
|
-
The above copyright notice and this permission notice shall be included in all
|
|
30
|
-
copies or substantial portions of the Software.
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## Disclaimer
|
|
35
|
-
|
|
36
|
-
THE SOFTWARE IS PROVIDED **“AS IS”**, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
37
|
-
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
|
|
38
|
-
AND NONINFRINGEMENT.
|
|
39
|
-
|
|
40
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES,
|
|
41
|
-
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM,
|
|
42
|
-
OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## Additional Notes (Project-Specific)
|
|
47
|
-
|
|
48
|
-
- You are free to use JuiceToast in **personal, educational, and commercial projects**.
|
|
49
|
-
- Attribution is appreciated but not required beyond the MIT notice.
|
|
50
|
-
- Contributions, improvements, and community extensions are welcome.
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
*Lightweight. Modern. Developer-friendly.*
|
/package/{EoL.md → Notice.md}
RENAMED
|
File without changes
|