@dennykuo/glass-toast 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +142 -76
- package/README.zh-TW.md +229 -0
- package/dist/auto.d.cts +1 -0
- package/dist/auto.js +2 -3
- package/dist/glass-toast.css +1 -1
- package/dist/glass-toast.css.d.ts +1 -0
- package/dist/glass-toast.js +1 -2
- package/dist/glass-toast.umd.cjs +2 -1
- package/dist/glass-toast.umd.js +2 -0
- package/dist/icons.d.cts +7 -0
- package/dist/index.d.cts +1 -0
- package/dist/toast-GM0D-R2d.js +312 -0
- package/dist/toast.d.cts +97 -0
- package/dist/toast.d.ts +11 -4
- package/package.json +38 -18
- package/dist/toast-Bh3vjjkJ.js +0 -237
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dennykuo/glass-toast",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Zero-dependency glassmorphism toast notifications — vanilla JS, framework-free, Tailwind-free. 毛玻璃質感 toast 通知,零相依開箱即用。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/dennykuo/glass-toast.git"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://github.
|
|
12
|
+
"homepage": "https://dennykuo.github.io/glass-toast/",
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/dennykuo/glass-toast/issues"
|
|
15
15
|
},
|
|
@@ -27,51 +27,71 @@
|
|
|
27
27
|
"sideEffects": [
|
|
28
28
|
"**/*.css",
|
|
29
29
|
"./dist/auto.js",
|
|
30
|
-
"./src/auto.js"
|
|
30
|
+
"./src/auto.js",
|
|
31
|
+
"./docs/**"
|
|
31
32
|
],
|
|
32
33
|
"main": "./dist/glass-toast.umd.cjs",
|
|
33
34
|
"module": "./dist/glass-toast.js",
|
|
34
35
|
"types": "./dist/index.d.ts",
|
|
35
|
-
"unpkg": "./dist/glass-toast.umd.
|
|
36
|
-
"jsdelivr": "./dist/glass-toast.umd.
|
|
36
|
+
"unpkg": "./dist/glass-toast.umd.js",
|
|
37
|
+
"jsdelivr": "./dist/glass-toast.umd.js",
|
|
37
38
|
"exports": {
|
|
38
39
|
".": {
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
"import": {
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"default": "./dist/glass-toast.js"
|
|
43
|
+
},
|
|
44
|
+
"require": {
|
|
45
|
+
"types": "./dist/index.d.cts",
|
|
46
|
+
"default": "./dist/glass-toast.umd.cjs"
|
|
47
|
+
}
|
|
42
48
|
},
|
|
43
49
|
"./auto": {
|
|
44
50
|
"types": "./dist/auto.d.ts",
|
|
45
51
|
"import": "./dist/auto.js",
|
|
46
52
|
"default": "./dist/auto.js"
|
|
47
53
|
},
|
|
48
|
-
"./style.css":
|
|
54
|
+
"./style.css": {
|
|
55
|
+
"types": "./dist/glass-toast.css.d.ts",
|
|
56
|
+
"default": "./dist/glass-toast.css"
|
|
57
|
+
},
|
|
49
58
|
"./package.json": "./package.json"
|
|
50
59
|
},
|
|
51
60
|
"files": [
|
|
52
61
|
"dist",
|
|
53
62
|
"README.md",
|
|
63
|
+
"README.zh-TW.md",
|
|
64
|
+
"CHANGELOG.md",
|
|
54
65
|
"LICENSE"
|
|
55
66
|
],
|
|
56
67
|
"scripts": {
|
|
57
|
-
"dev": "vite
|
|
58
|
-
"build": "vite build
|
|
68
|
+
"dev": "vite docs",
|
|
69
|
+
"build:docs": "vite build docs",
|
|
70
|
+
"build": "vite build && vite build --mode umd && node scripts/build-cdn.mjs && node scripts/build-css.mjs && tsc -p tsconfig.json && node scripts/build-cts.mjs",
|
|
59
71
|
"test": "vitest run",
|
|
72
|
+
"test:browser": "npm run build && playwright test",
|
|
60
73
|
"test:watch": "vitest",
|
|
61
|
-
"lint": "eslint src test scripts",
|
|
62
|
-
"
|
|
74
|
+
"lint": "eslint src test scripts docs",
|
|
75
|
+
"check:package": "node scripts/check-package.mjs",
|
|
76
|
+
"prepublishOnly": "npm run build && npm run check:package"
|
|
63
77
|
},
|
|
64
78
|
"engines": {
|
|
65
|
-
"node": ">=
|
|
79
|
+
"node": "^22.13.0 || >=24.0.0"
|
|
80
|
+
},
|
|
81
|
+
"overrides": {
|
|
82
|
+
"minimatch": "^11.0.1"
|
|
66
83
|
},
|
|
67
84
|
"devDependencies": {
|
|
68
|
-
"@
|
|
69
|
-
"eslint": "^
|
|
85
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
86
|
+
"@eslint/js": "^10.0.1",
|
|
87
|
+
"@playwright/test": "^1.64.1",
|
|
88
|
+
"eslint": "^10.14.0",
|
|
70
89
|
"globals": "^16.5.0",
|
|
71
90
|
"jsdom": "^29.1.1",
|
|
72
91
|
"lightningcss": "^1.32.0",
|
|
92
|
+
"publint": "^0.3.25",
|
|
73
93
|
"typescript": "^5.7.0",
|
|
74
|
-
"vite": "^8.
|
|
75
|
-
"vitest": "^4.1.
|
|
94
|
+
"vite": "^8.3.5",
|
|
95
|
+
"vitest": "^4.1.12"
|
|
76
96
|
}
|
|
77
97
|
}
|
package/dist/toast-Bh3vjjkJ.js
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
//#region src/icons.js
|
|
2
|
-
var e = {
|
|
3
|
-
success: "<svg viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z\" clip-rule=\"evenodd\"/></svg>",
|
|
4
|
-
error: "<svg viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z\" clip-rule=\"evenodd\"/></svg>",
|
|
5
|
-
warning: "<svg viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.168 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 6a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 6zm0 9a1 1 0 100-2 1 1 0 000 2z\" clip-rule=\"evenodd\"/></svg>",
|
|
6
|
-
info: "<svg viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z\" clip-rule=\"evenodd\"/></svg>",
|
|
7
|
-
close: "<svg viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z\"/></svg>"
|
|
8
|
-
}, t = ".glass-toast-container,.glass-toast,.glass-toast *{box-sizing:border-box}.glass-toast-container{z-index:2147483647;pointer-events:none;flex-direction:column;gap:.75rem;display:flex;position:fixed}.glass-toast-container--top-right{align-items:flex-end;top:1rem;right:1rem}.glass-toast-container--bottom-right{align-items:flex-end;bottom:1rem;right:1rem}.glass-toast-container--bottom-center{align-items:center;bottom:1rem;left:50%;transform:translate(-50%)}.glass-toast{--gt-bg:#fffc;--gt-bg-opaque:#fffffff5;--gt-border:#e5e7eb66;--gt-text:#4a5565;--gt-blur:24px;--gt-radius:1rem;--gt-shadow:0 4px 24px -4px #00000014, 0 1px 2px #0000000a;--gt-close-bg:#f9fafb;--gt-close-border:#e5e7eb;--gt-close-text:#99a1af;--gt-close-bg-hover:#f3f4f6;--gt-close-border-hover:#d1d5dc;--gt-close-text-hover:#4a5565;--gt-focus-ring:#2563eb;pointer-events:auto;background-color:var(--gt-bg);width:24rem;max-width:calc(100vw - 2rem);-webkit-backdrop-filter:blur(var(--gt-blur));backdrop-filter:blur(var(--gt-blur));border:1px solid var(--gt-border);border-radius:var(--gt-radius);box-shadow:var(--gt-shadow);align-items:center;gap:.75rem;padding:.875rem 1rem;display:flex;position:relative;overflow:hidden}@supports not ((-webkit-backdrop-filter:blur(1px)) or (backdrop-filter:blur(1px))){.glass-toast{background-color:var(--gt-bg-opaque)}}.glass-toast--success{--gt-pill-bg:#d0fae5;--gt-icon:#047857;--gt-bar:#00bb7f;--gt-ring:16, 185, 129}.glass-toast--error{--gt-pill-bg:#ffe2e2;--gt-icon:#dc2626;--gt-bar:#ff6568;--gt-ring:239, 68, 68}.glass-toast--warning{--gt-pill-bg:#fef3c6;--gt-icon:#b45309;--gt-bar:#fcbb00;--gt-ring:245, 158, 11}.glass-toast--info{--gt-pill-bg:#e2eaf1;--gt-icon:#3a5b7a;--gt-bar:#6f92ad;--gt-ring:76, 112, 144}.glass-toast--animated{transition:all .28s cubic-bezier(0,0,.2,1)}.glass-toast--leaving{transition-timing-function:cubic-bezier(.4,0,1,1)}.glass-toast--enter,.glass-toast--faded{opacity:0}.glass-toast--enter[data-position=top-right],.glass-toast--enter[data-position=bottom-right]{transform:translate(2rem)}.glass-toast--enter[data-position=bottom-center]{transform:translateY(2rem)}.glass-toast__icon{background-color:var(--gt-pill-bg);width:1.75rem;height:1.75rem;color:var(--gt-icon);border-radius:.5rem;flex-shrink:0;justify-content:center;align-items:center;display:flex}.glass-toast__icon svg{flex-shrink:0;width:18px;height:18px;display:block}.glass-toast__message{min-width:0;color:var(--gt-text);overflow-wrap:anywhere;-webkit-line-clamp:5;line-clamp:5;-webkit-box-orient:vertical;flex:1;margin:0;font-size:.9375rem;line-height:1.625;display:-webkit-box;overflow:hidden}.glass-toast__action{border:1px solid var(--gt-action-border,var(--gt-border));background-color:var(--gt-action-bg,transparent);color:var(--gt-action-text,var(--gt-icon));font:inherit;white-space:nowrap;cursor:pointer;appearance:none;border-radius:.5rem;flex-shrink:0;align-self:center;padding:.3125rem .75rem;font-size:.8125rem;font-weight:600;line-height:1;transition:background-color .15s cubic-bezier(.4,0,.2,1),border-color .15s cubic-bezier(.4,0,.2,1)}.glass-toast__action:hover{background-color:var(--gt-action-bg-hover,var(--gt-pill-bg))}.glass-toast__action:focus-visible{outline:2px solid var(--gt-focus-ring);outline-offset:2px}.glass-toast__close{border:1px solid var(--gt-close-border);background-color:var(--gt-close-bg);width:2rem;height:2rem;color:var(--gt-close-text);font:inherit;cursor:pointer;appearance:none;border-radius:9999px;flex-shrink:0;justify-content:center;align-self:center;align-items:center;padding:0;transition:all .15s cubic-bezier(.4,0,.2,1);display:flex}.glass-toast__close:hover{background-color:var(--gt-close-bg-hover);border-color:var(--gt-close-border-hover);color:var(--gt-close-text-hover)}.glass-toast__close:focus-visible{outline:2px solid var(--gt-focus-ring);outline-offset:2px}.glass-toast__close svg{width:.875rem;height:.875rem;display:block}.glass-toast__bar{background-color:var(--gt-bar);opacity:.4;border-radius:9999px;height:2px;position:absolute;bottom:0;left:0}@media (width>=768px){.glass-toast__message{font-size:14px}}@media (prefers-color-scheme:dark){:where(:root:not([data-theme=light]):not(.light)) .glass-toast{--gt-bg:#1c1c1eb8;--gt-bg-opaque:#1c1c1eeb;--gt-border:#ffffff1a;--gt-text:#e5e7eb;--gt-close-bg:#ffffff0f;--gt-close-border:#ffffff1f;--gt-close-text:#cbd5e1;--gt-close-bg-hover:#ffffff1f;--gt-close-border-hover:#ffffff38;--gt-close-text-hover:#f1f5f9;--gt-focus-ring:#93c5fd}}:where([data-theme=dark],.dark) .glass-toast{--gt-bg:#1c1c1eb8;--gt-bg-opaque:#1c1c1eeb;--gt-border:#ffffff1a;--gt-text:#e5e7eb;--gt-close-bg:#ffffff0f;--gt-close-border:#ffffff1f;--gt-close-text:#cbd5e1;--gt-close-bg-hover:#ffffff1f;--gt-close-border-hover:#ffffff38;--gt-close-text-hover:#f1f5f9;--gt-focus-ring:#93c5fd}", n = 280, r = 12, i = 1400, a = { error: 1e4 }, o = 5500, s = 4, c = "info", l = "top-right", u = {
|
|
9
|
-
success: {
|
|
10
|
-
role: "status",
|
|
11
|
-
live: "polite",
|
|
12
|
-
ringRgb: "16, 185, 129"
|
|
13
|
-
},
|
|
14
|
-
error: {
|
|
15
|
-
role: "alert",
|
|
16
|
-
live: "assertive",
|
|
17
|
-
ringRgb: "239, 68, 68"
|
|
18
|
-
},
|
|
19
|
-
warning: {
|
|
20
|
-
role: "status",
|
|
21
|
-
live: "polite",
|
|
22
|
-
ringRgb: "245, 158, 11"
|
|
23
|
-
},
|
|
24
|
-
info: {
|
|
25
|
-
role: "status",
|
|
26
|
-
live: "polite",
|
|
27
|
-
ringRgb: "76, 112, 144"
|
|
28
|
-
}
|
|
29
|
-
}, d = {
|
|
30
|
-
"top-right": "glass-toast-container--top-right",
|
|
31
|
-
"bottom-right": "glass-toast-container--bottom-right",
|
|
32
|
-
"bottom-center": "glass-toast-container--bottom-center"
|
|
33
|
-
}, f = "0 4px 24px -4px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04)", p = !0;
|
|
34
|
-
function m() {
|
|
35
|
-
if (typeof document > "u" || document.querySelector("style[data-glass-toast], link[data-glass-toast]")) return;
|
|
36
|
-
let e = document.createElement("style");
|
|
37
|
-
e.setAttribute("data-glass-toast", ""), e.textContent = t, document.head.prepend(e);
|
|
38
|
-
}
|
|
39
|
-
var h = () => window.matchMedia?.("(prefers-reduced-motion: reduce)").matches, g = /* @__PURE__ */ new Map(), _ = !1;
|
|
40
|
-
function v(e) {
|
|
41
|
-
let t = g.get(e);
|
|
42
|
-
if (t && t.isConnected) return t;
|
|
43
|
-
let n = document.createElement("div");
|
|
44
|
-
return n.className = `glass-toast-container ${d[e]}`, n.dataset.toastContainer = e, document.body.appendChild(n), g.set(e, n), n;
|
|
45
|
-
}
|
|
46
|
-
function y(e) {
|
|
47
|
-
let t = [...e.children].filter((e) => !e.dataset.dismissing);
|
|
48
|
-
for (; t.length >= s;) {
|
|
49
|
-
let e = t.shift();
|
|
50
|
-
typeof e.__dismiss == "function" ? e.__dismiss() : e.remove();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function b(e) {
|
|
54
|
-
if (e && e.isConnected && typeof e.focus == "function") {
|
|
55
|
-
e.focus();
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
let t = document.querySelector(".glass-toast__close");
|
|
59
|
-
t && t.focus();
|
|
60
|
-
}
|
|
61
|
-
function x(t, { type: n, position: r, persistent: i, duration: a, action: o }) {
|
|
62
|
-
let s = u[n], c = h(), l = document.createElement("div");
|
|
63
|
-
l.setAttribute("role", s.role), l.setAttribute("aria-live", s.live), l.dataset.position = r, l.className = [
|
|
64
|
-
"glass-toast",
|
|
65
|
-
`glass-toast--${n}`,
|
|
66
|
-
c ? "glass-toast--faded" : "glass-toast--animated glass-toast--enter"
|
|
67
|
-
].join(" ");
|
|
68
|
-
let d = document.createElement("span");
|
|
69
|
-
d.className = "glass-toast__icon", d.innerHTML = e[n];
|
|
70
|
-
let f = document.createElement("p");
|
|
71
|
-
f.className = "glass-toast__message", f.textContent = t, l.append(d, f);
|
|
72
|
-
let p = null;
|
|
73
|
-
o && o.label && (p = document.createElement("button"), p.type = "button", p.className = "glass-toast__action", p.textContent = o.label, l.appendChild(p));
|
|
74
|
-
let m = document.createElement("button");
|
|
75
|
-
if (m.type = "button", m.className = "glass-toast__close", m.setAttribute("aria-label", "關閉通知"), m.innerHTML = e.close, l.appendChild(m), !i) {
|
|
76
|
-
let e = document.createElement("div");
|
|
77
|
-
e.className = "glass-toast__bar", e.style.width = "100%", e.style.transition = `width ${a}ms linear`, l.appendChild(e), requestAnimationFrame(() => {
|
|
78
|
-
requestAnimationFrame(() => {
|
|
79
|
-
e.style.width = "0%";
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
el: l,
|
|
85
|
-
btn: m,
|
|
86
|
-
actionBtn: p
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function S(e, t) {
|
|
90
|
-
if (h() || typeof e.animate != "function") return;
|
|
91
|
-
let n = getComputedStyle(e), r = n.getPropertyValue("--gt-ring").trim().replace(/\s*,\s*/g, ", ") || u[t].ringRgb, a = n.getPropertyValue("--gt-shadow").trim() || f;
|
|
92
|
-
e.animate([
|
|
93
|
-
{
|
|
94
|
-
boxShadow: `0 0 18px 6px rgba(${r}, 0.75), ${a}`,
|
|
95
|
-
offset: 0
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
boxShadow: `0 0 22px 8px rgba(${r}, 0.7), ${a}`,
|
|
99
|
-
offset: .35
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
boxShadow: `0 0 56px 26px rgba(${r}, 0), ${a}`,
|
|
103
|
-
offset: 1
|
|
104
|
-
}
|
|
105
|
-
], {
|
|
106
|
-
duration: i,
|
|
107
|
-
easing: "ease-out",
|
|
108
|
-
fill: "none"
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
function C(e, t) {
|
|
112
|
-
e.remove();
|
|
113
|
-
let n = g.get(t);
|
|
114
|
-
n && n.children.length === 0 && (n.remove(), g.delete(t));
|
|
115
|
-
}
|
|
116
|
-
function w(e, t, i) {
|
|
117
|
-
if (e.dataset.dismissing) return;
|
|
118
|
-
e.dataset.dismissing = "true";
|
|
119
|
-
let a = e.contains(document.activeElement), o = () => {
|
|
120
|
-
C(e, t), a && b(i);
|
|
121
|
-
};
|
|
122
|
-
if (h()) {
|
|
123
|
-
e.classList.add("glass-toast--faded"), setTimeout(o, n);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
e.classList.add("glass-toast--leaving");
|
|
127
|
-
let s = e.offsetHeight;
|
|
128
|
-
e.style.height = `${s}px`, e.offsetHeight, e.classList.add("glass-toast--enter"), e.style.height = "0px", e.style.paddingTop = "0", e.style.paddingBottom = "0", e.style.borderTopWidth = "0", e.style.borderBottomWidth = "0", e.style.marginTop = `-${r}px`, setTimeout(o, n);
|
|
129
|
-
}
|
|
130
|
-
function T(e, t = {}) {
|
|
131
|
-
if (_) return () => {};
|
|
132
|
-
let { type: n = c, position: r = l, persistent: i = !1, action: s } = t;
|
|
133
|
-
u[n] || (n = c), d[r] || (r = l);
|
|
134
|
-
let f = t.duration !== void 0, g = f ? t.duration : a[n] ?? o;
|
|
135
|
-
(s && s.label && !f || g <= 0) && (i = !0), p && m();
|
|
136
|
-
let b = v(r);
|
|
137
|
-
y(b);
|
|
138
|
-
let { el: C, btn: T, actionBtn: E } = x(e, {
|
|
139
|
-
type: n,
|
|
140
|
-
position: r,
|
|
141
|
-
persistent: i,
|
|
142
|
-
duration: g,
|
|
143
|
-
action: s
|
|
144
|
-
}), D = typeof document < "u" ? document.activeElement : null;
|
|
145
|
-
b.appendChild(C);
|
|
146
|
-
let O = h() ? "glass-toast--faded" : "glass-toast--enter";
|
|
147
|
-
requestAnimationFrame(() => {
|
|
148
|
-
requestAnimationFrame(() => {
|
|
149
|
-
C.classList.remove(O), S(C, n);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
let k = () => w(C, r, D);
|
|
153
|
-
if (C.__dismiss = k, T.addEventListener("click", k), E && E.addEventListener("click", () => {
|
|
154
|
-
s.onClick?.(), k();
|
|
155
|
-
}), C.addEventListener("keydown", (e) => {
|
|
156
|
-
e.key === "Escape" && (e.stopPropagation(), k());
|
|
157
|
-
}), !i) {
|
|
158
|
-
let e = C.querySelector(".glass-toast__bar"), t = g, n = Date.now(), r = setTimeout(k, t), i = !1, a = !1, o = !1, s = () => {
|
|
159
|
-
if (!i && (i = !0, clearTimeout(r), t -= Date.now() - n, e)) {
|
|
160
|
-
let t = e.getBoundingClientRect().width;
|
|
161
|
-
e.style.transition = "none", e.style.width = `${t}px`;
|
|
162
|
-
}
|
|
163
|
-
}, c = () => {
|
|
164
|
-
if (i) {
|
|
165
|
-
if (i = !1, t <= 0) {
|
|
166
|
-
k();
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
n = Date.now(), r = setTimeout(k, t), e && requestAnimationFrame(() => {
|
|
170
|
-
e.style.transition = `width ${t}ms linear`, e.style.width = "0%";
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}, l = () => {
|
|
174
|
-
!a && !o && c();
|
|
175
|
-
};
|
|
176
|
-
C.addEventListener("mouseenter", () => {
|
|
177
|
-
a = !0, s();
|
|
178
|
-
}), C.addEventListener("mouseleave", () => {
|
|
179
|
-
a = !1, l();
|
|
180
|
-
}), C.addEventListener("focusin", () => {
|
|
181
|
-
o = !0, s();
|
|
182
|
-
}), C.addEventListener("focusout", (e) => {
|
|
183
|
-
C.contains(e.relatedTarget) || (o = !1, l());
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
return k;
|
|
187
|
-
}
|
|
188
|
-
function E({ suppress: e = !1 } = {}) {
|
|
189
|
-
e && (_ = !0);
|
|
190
|
-
for (let e of g.values()) e.remove();
|
|
191
|
-
g.clear();
|
|
192
|
-
}
|
|
193
|
-
function D() {
|
|
194
|
-
_ = !1;
|
|
195
|
-
}
|
|
196
|
-
function O(e, t) {
|
|
197
|
-
return T(e, {
|
|
198
|
-
...t,
|
|
199
|
-
type: "success"
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
function k(e, t) {
|
|
203
|
-
return T(e, {
|
|
204
|
-
...t,
|
|
205
|
-
type: "error"
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
function A(e, t) {
|
|
209
|
-
return T(e, {
|
|
210
|
-
...t,
|
|
211
|
-
type: "warning"
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
function j(e, t) {
|
|
215
|
-
return T(e, {
|
|
216
|
-
...t,
|
|
217
|
-
type: "info"
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
var M = {
|
|
221
|
-
show: T,
|
|
222
|
-
success: O,
|
|
223
|
-
error: k,
|
|
224
|
-
warning: A,
|
|
225
|
-
info: j,
|
|
226
|
-
dismissAll: E,
|
|
227
|
-
resume: D
|
|
228
|
-
};
|
|
229
|
-
function N({ global: e = !0, injectStyles: t = !0, target: n } = {}) {
|
|
230
|
-
if (p = t, t && m(), e) {
|
|
231
|
-
let e = n ?? (typeof window < "u" ? window : void 0);
|
|
232
|
-
e && (e.toast = M);
|
|
233
|
-
}
|
|
234
|
-
return M;
|
|
235
|
-
}
|
|
236
|
-
//#endregion
|
|
237
|
-
export { N as a, O as c, j as i, A as l, m as n, D as o, k as r, T as s, E as t };
|