@edgar208/sileo-vue 1.0.3 → 1.2.0
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/dist/sileo-vue.js +234 -167
- package/dist/sileo-vue.umd.cjs +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/sileo-vue.js
CHANGED
|
@@ -1,195 +1,245 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
const
|
|
1
|
+
import { reactive as O, markRaw as S, defineComponent as I, ref as b, computed as v, onUnmounted as N, openBlock as c, createElementBlock as u, normalizeStyle as w, normalizeClass as M, createElementVNode as a, createBlock as X, resolveDynamicComponent as V, toDisplayString as k, createCommentVNode as C, withModifiers as $, Fragment as z, renderList as D, createVNode as W, TransitionGroup as G, withCtx as H, unref as U, createApp as q, h as J } from "vue";
|
|
2
|
+
const y = O([]), T = O({
|
|
3
3
|
position: "top-right",
|
|
4
4
|
duration: 4e3,
|
|
5
5
|
maxToasts: 5
|
|
6
|
-
}),
|
|
7
|
-
function
|
|
8
|
-
const
|
|
6
|
+
}), K = () => Math.random().toString(36).substring(2, 9);
|
|
7
|
+
function j() {
|
|
8
|
+
const e = (t) => {
|
|
9
9
|
const o = {
|
|
10
10
|
type: "default",
|
|
11
|
-
duration:
|
|
12
|
-
position:
|
|
11
|
+
duration: T.duration || 4e3,
|
|
12
|
+
position: T.position || "top-right",
|
|
13
13
|
showProgress: !0,
|
|
14
14
|
closeOnClick: !0,
|
|
15
15
|
swipeToDismiss: !0
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
const n =
|
|
16
|
+
}, s = typeof t == "string" ? { message: t } : t;
|
|
17
|
+
y.length >= (T.maxToasts || 5) && y.shift();
|
|
18
|
+
const n = K(), i = {
|
|
19
19
|
...o,
|
|
20
|
-
...
|
|
20
|
+
...s,
|
|
21
21
|
id: n,
|
|
22
22
|
createdAt: Date.now()
|
|
23
23
|
};
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
const o =
|
|
29
|
-
o !== -1 &&
|
|
30
|
-
},
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
const n = { ...
|
|
34
|
-
typeof o.icon < "u" && o.icon && typeof o.icon != "string" && (n.icon =
|
|
24
|
+
return i.icon && typeof i.icon != "string" && (i.icon = S(i.icon)), y.push(i), i.duration > 0 && setTimeout(() => {
|
|
25
|
+
g(n);
|
|
26
|
+
}, i.duration), n;
|
|
27
|
+
}, g = (t) => {
|
|
28
|
+
const o = y.findIndex((s) => s.id === t);
|
|
29
|
+
o !== -1 && y.splice(o, 1);
|
|
30
|
+
}, p = (t, o) => {
|
|
31
|
+
const s = y.findIndex((n) => n.id === t);
|
|
32
|
+
if (s !== -1) {
|
|
33
|
+
const n = { ...y[s], ...o };
|
|
34
|
+
typeof o.icon < "u" && o.icon && typeof o.icon != "string" && (n.icon = S(o.icon)), y[s] = n;
|
|
35
35
|
}
|
|
36
|
-
},
|
|
37
|
-
success: (
|
|
38
|
-
error: (
|
|
39
|
-
warning: (
|
|
40
|
-
info: (
|
|
41
|
-
promise: async (
|
|
42
|
-
const
|
|
36
|
+
}, f = Object.assign(e, {
|
|
37
|
+
success: (t) => e(typeof t == "string" ? { message: t, type: "success" } : { ...t, type: "success" }),
|
|
38
|
+
error: (t) => e(typeof t == "string" ? { message: t, type: "error" } : { ...t, type: "error" }),
|
|
39
|
+
warning: (t) => e(typeof t == "string" ? { message: t, type: "warning" } : { ...t, type: "warning" }),
|
|
40
|
+
info: (t) => e(typeof t == "string" ? { message: t, type: "info" } : { ...t, type: "info" }),
|
|
41
|
+
promise: async (t, o) => {
|
|
42
|
+
const s = e(typeof o.loading == "string" ? { message: o.loading, type: "default", duration: 0 } : { ...o.loading, type: "default", duration: 0 });
|
|
43
43
|
try {
|
|
44
|
-
const n = await
|
|
45
|
-
return
|
|
44
|
+
const n = await t, i = typeof o.success == "function" ? o.success(n) : o.success, l = typeof i == "string" ? { message: i, type: "success" } : { ...i, type: "success" };
|
|
45
|
+
return p(s, { ...l, duration: l.duration || 4e3 }), setTimeout(() => g(s), l.duration || 4e3), n;
|
|
46
46
|
} catch (n) {
|
|
47
|
-
const
|
|
48
|
-
throw
|
|
47
|
+
const i = typeof o.error == "function" ? o.error(n) : o.error, l = typeof i == "string" ? { message: i, type: "error" } : { ...i, type: "error" };
|
|
48
|
+
throw p(s, { ...l, duration: l.duration || 4e3 }), setTimeout(() => g(s), l.duration || 4e3), n;
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
-
clear: () =>
|
|
52
|
-
config: (
|
|
51
|
+
clear: () => y.length = 0,
|
|
52
|
+
config: (t) => Object.assign(T, t)
|
|
53
53
|
});
|
|
54
54
|
return {
|
|
55
|
-
toasts:
|
|
56
|
-
toast:
|
|
57
|
-
removeToast:
|
|
58
|
-
updateToast:
|
|
55
|
+
toasts: y,
|
|
56
|
+
toast: f,
|
|
57
|
+
removeToast: g,
|
|
58
|
+
updateToast: p
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
const
|
|
61
|
+
const L = j(), Q = {
|
|
62
|
+
class: "sileo-icon-box",
|
|
63
|
+
style: { width: "18px", height: "18px", display: "flex", "align-items": "center", "justify-content": "center", "flex-shrink": "0" }
|
|
64
|
+
}, Y = {
|
|
65
|
+
key: 1,
|
|
66
|
+
style: { "font-size": "16px", "line-height": "1" }
|
|
67
|
+
}, Z = {
|
|
62
68
|
key: 2,
|
|
63
|
-
|
|
64
|
-
},
|
|
69
|
+
style: { width: "18px", height: "18px", display: "flex", "align-items": "center", "justify-content": "center" }
|
|
70
|
+
}, _ = {
|
|
65
71
|
key: 0,
|
|
66
|
-
class: "sileo-spinner",
|
|
67
|
-
viewBox: "0 0 50 50"
|
|
68
|
-
|
|
72
|
+
class: "sileo-loading-spinner",
|
|
73
|
+
viewBox: "0 0 50 50",
|
|
74
|
+
style: { width: "18px !important", height: "18px !important" }
|
|
75
|
+
}, tt = {
|
|
69
76
|
key: 1,
|
|
70
77
|
viewBox: "0 0 24 24",
|
|
71
78
|
fill: "none",
|
|
72
79
|
stroke: "currentColor",
|
|
73
80
|
"stroke-width": "3",
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
}, Y = {
|
|
81
|
+
style: { width: "18px !important", height: "18px !important" }
|
|
82
|
+
}, et = {
|
|
77
83
|
key: 2,
|
|
78
84
|
viewBox: "0 0 24 24",
|
|
79
85
|
fill: "none",
|
|
80
86
|
stroke: "currentColor",
|
|
81
87
|
"stroke-width": "3",
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
}, Z = {
|
|
88
|
+
style: { width: "18px !important", height: "18px !important" }
|
|
89
|
+
}, ot = {
|
|
85
90
|
key: 3,
|
|
86
91
|
viewBox: "0 0 24 24",
|
|
87
92
|
fill: "none",
|
|
88
93
|
stroke: "currentColor",
|
|
89
94
|
"stroke-width": "3",
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
}, tt = {
|
|
95
|
+
style: { width: "18px !important", height: "18px !important" }
|
|
96
|
+
}, nt = {
|
|
93
97
|
key: 4,
|
|
94
98
|
viewBox: "0 0 24 24",
|
|
95
99
|
fill: "none",
|
|
96
100
|
stroke: "currentColor",
|
|
97
101
|
"stroke-width": "3",
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
}, et = {
|
|
102
|
+
style: { width: "18px !important", height: "18px !important" }
|
|
103
|
+
}, it = {
|
|
101
104
|
key: 0,
|
|
102
|
-
|
|
103
|
-
},
|
|
105
|
+
style: { "font-size": "13px", "font-weight": "700", color: "rgba(255, 255, 255, 0.95)", "white-space": "nowrap" }
|
|
106
|
+
}, st = {
|
|
107
|
+
viewBox: "0 0 24 24",
|
|
108
|
+
fill: "none",
|
|
109
|
+
stroke: "currentColor",
|
|
110
|
+
"stroke-width": "3",
|
|
111
|
+
style: { width: "12px", height: "12px" }
|
|
112
|
+
}, rt = { style: { display: "flex", "align-items": "center", "justify-content": "space-between", gap: "16px" } }, at = { style: { margin: "0", "font-size": "15px", "line-height": "1.4", color: "rgba(255, 255, 255, 0.95)", "font-weight": "500" } }, lt = {
|
|
104
113
|
key: 0,
|
|
105
|
-
class: "sileo-
|
|
106
|
-
|
|
114
|
+
class: "sileo-progress-bar",
|
|
115
|
+
style: { position: "absolute", bottom: "8px", left: "24px", right: "24px", height: "3px", background: "rgba(255, 255, 255, 0.05)", "border-radius": "10px", overflow: "hidden" }
|
|
116
|
+
}, ct = /* @__PURE__ */ I({
|
|
107
117
|
__name: "Toast",
|
|
108
118
|
props: {
|
|
109
119
|
toast: {}
|
|
110
120
|
},
|
|
111
121
|
emits: ["close"],
|
|
112
|
-
setup(
|
|
113
|
-
const
|
|
114
|
-
const
|
|
122
|
+
setup(e, { emit: g }) {
|
|
123
|
+
const p = e, f = g, t = b(null), o = b(!1), s = b(0), n = b(0), i = v(() => p.toast.icon), l = v(() => p.toast.duration === 0 && (p.toast.type === "default" || !p.toast.type)), x = v(() => {
|
|
124
|
+
const d = p.toast.position || "top-right";
|
|
125
|
+
return d.includes("center") ? "center" : d.includes("left") ? "left" : "right";
|
|
126
|
+
}), A = v(() => {
|
|
127
|
+
const d = n.value, r = Math.max(0, 1 - Math.abs(d) / 300), E = o.value ? 0.95 : 1, R = x.value === "center" ? "center" : x.value === "left" ? "flex-start" : "flex-end";
|
|
115
128
|
return {
|
|
116
|
-
transform: `translateX(${
|
|
117
|
-
opacity:
|
|
118
|
-
transition: o.value ? "none" : "all 0.
|
|
129
|
+
transform: `translateX(${d}px) scale(${E})`,
|
|
130
|
+
opacity: r,
|
|
131
|
+
transition: o.value ? "none" : "all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275)",
|
|
132
|
+
display: "flex",
|
|
133
|
+
flexDirection: "column",
|
|
134
|
+
alignItems: R,
|
|
135
|
+
width: "100%",
|
|
136
|
+
pointerEvents: "auto",
|
|
137
|
+
marginBottom: "16px"
|
|
119
138
|
};
|
|
120
|
-
}),
|
|
121
|
-
|
|
122
|
-
|
|
139
|
+
}), F = v(() => ({
|
|
140
|
+
alignSelf: x.value === "center" ? "center" : x.value === "left" ? "flex-start" : "flex-end",
|
|
141
|
+
display: "flex",
|
|
142
|
+
alignItems: "center",
|
|
143
|
+
gap: "10px",
|
|
144
|
+
background: "rgba(255, 255, 255, 0.1)",
|
|
145
|
+
backdropFilter: "blur(20px) saturate(180%)",
|
|
146
|
+
webkitBackdropFilter: "blur(20px) saturate(180%)",
|
|
147
|
+
padding: "6px 14px",
|
|
148
|
+
borderRadius: "40px",
|
|
149
|
+
border: "1px solid rgba(255, 255, 255, 0.15)",
|
|
150
|
+
color: "#fff",
|
|
151
|
+
height: "36px",
|
|
152
|
+
boxSizing: "border-box",
|
|
153
|
+
marginBottom: "4px"
|
|
154
|
+
})), P = v(() => ({
|
|
155
|
+
background: "rgba(28, 28, 30, 0.85)",
|
|
156
|
+
backdropFilter: "blur(35px) saturate(200%)",
|
|
157
|
+
webkitBackdropFilter: "blur(35px) saturate(200%)",
|
|
158
|
+
padding: "16px 20px",
|
|
159
|
+
borderRadius: "28px",
|
|
160
|
+
border: "1px solid rgba(255, 255, 255, 0.1)",
|
|
161
|
+
width: "100%",
|
|
162
|
+
boxSizing: "border-box",
|
|
163
|
+
boxShadow: "0 10px 30px rgba(0, 0, 0, 0.4)"
|
|
164
|
+
})), B = (d) => {
|
|
165
|
+
p.toast.swipeToDismiss && (o.value = !0, s.value = "touches" in d ? d.touches[0].clientX : d.clientX, "touches" in d ? (window.addEventListener("touchmove", m), window.addEventListener("touchend", h)) : (window.addEventListener("mousemove", m), window.addEventListener("mouseup", h)));
|
|
166
|
+
}, m = (d) => {
|
|
123
167
|
if (!o.value) return;
|
|
124
|
-
const
|
|
125
|
-
n.value =
|
|
126
|
-
},
|
|
127
|
-
o.value && (o.value = !1, Math.abs(n.value) >
|
|
168
|
+
const r = "touches" in d ? d.touches[0].clientX : d.clientX;
|
|
169
|
+
n.value = (r - s.value) * 0.8;
|
|
170
|
+
}, h = () => {
|
|
171
|
+
o.value && (o.value = !1, Math.abs(n.value) > 100 ? f("close") : n.value = 0, window.removeEventListener("mousemove", m), window.removeEventListener("mouseup", h), window.removeEventListener("touchmove", m), window.removeEventListener("touchend", h));
|
|
128
172
|
};
|
|
129
|
-
return
|
|
130
|
-
window.removeEventListener("mousemove",
|
|
131
|
-
}), (
|
|
173
|
+
return N(() => {
|
|
174
|
+
window.removeEventListener("mousemove", m), window.removeEventListener("mouseup", h), window.removeEventListener("touchmove", m), window.removeEventListener("touchend", h);
|
|
175
|
+
}), (d, r) => (c(), u("div", {
|
|
132
176
|
ref_key: "toastRef",
|
|
133
|
-
ref:
|
|
134
|
-
class: M(["sileo-toast", [`sileo-
|
|
135
|
-
style:
|
|
136
|
-
onMousedown:
|
|
137
|
-
onTouchstart:
|
|
177
|
+
ref: t,
|
|
178
|
+
class: M(["sileo-toast-wrapper", [`sileo-type-${e.toast.type}`, `sileo-pos-align-${x.value}`, { "sileo-is-dragging": o.value }]]),
|
|
179
|
+
style: w(A.value),
|
|
180
|
+
onMousedown: B,
|
|
181
|
+
onTouchstart: B
|
|
138
182
|
}, [
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
183
|
+
a("div", {
|
|
184
|
+
class: "sileo-pill-header",
|
|
185
|
+
style: w(F.value)
|
|
186
|
+
}, [
|
|
187
|
+
a("div", Q, [
|
|
188
|
+
typeof e.toast.icon != "string" && e.toast.icon ? (c(), X(V(i.value), {
|
|
189
|
+
key: 0,
|
|
190
|
+
style: { width: "18px !important", height: "18px !important", display: "block" }
|
|
191
|
+
})) : typeof e.toast.icon == "string" ? (c(), u("span", Y, k(e.toast.icon), 1)) : (c(), u("div", Z, [
|
|
192
|
+
l.value ? (c(), u("svg", _, [...r[2] || (r[2] = [
|
|
193
|
+
a("circle", {
|
|
145
194
|
cx: "25",
|
|
146
195
|
cy: "25",
|
|
147
196
|
r: "20",
|
|
148
197
|
fill: "none",
|
|
198
|
+
stroke: "currentColor",
|
|
149
199
|
"stroke-width": "5"
|
|
150
200
|
}, null, -1)
|
|
151
|
-
])])) :
|
|
152
|
-
|
|
153
|
-
])])) :
|
|
154
|
-
|
|
201
|
+
])])) : e.toast.type === "success" ? (c(), u("svg", tt, [...r[3] || (r[3] = [
|
|
202
|
+
a("polyline", { points: "20 6 9 17 4 12" }, null, -1)
|
|
203
|
+
])])) : e.toast.type === "error" ? (c(), u("svg", et, [...r[4] || (r[4] = [
|
|
204
|
+
a("line", {
|
|
155
205
|
x1: "18",
|
|
156
206
|
y1: "6",
|
|
157
207
|
x2: "6",
|
|
158
208
|
y2: "18"
|
|
159
209
|
}, null, -1),
|
|
160
|
-
|
|
210
|
+
a("line", {
|
|
161
211
|
x1: "6",
|
|
162
212
|
y1: "6",
|
|
163
213
|
x2: "18",
|
|
164
214
|
y2: "18"
|
|
165
215
|
}, null, -1)
|
|
166
|
-
])])) :
|
|
167
|
-
|
|
168
|
-
|
|
216
|
+
])])) : e.toast.type === "warning" ? (c(), u("svg", ot, [...r[5] || (r[5] = [
|
|
217
|
+
a("path", { d: "M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" }, null, -1),
|
|
218
|
+
a("line", {
|
|
169
219
|
x1: "12",
|
|
170
220
|
y1: "9",
|
|
171
221
|
x2: "12",
|
|
172
222
|
y2: "13"
|
|
173
223
|
}, null, -1),
|
|
174
|
-
|
|
224
|
+
a("line", {
|
|
175
225
|
x1: "12",
|
|
176
226
|
y1: "17",
|
|
177
227
|
x2: "12.01",
|
|
178
228
|
y2: "17"
|
|
179
229
|
}, null, -1)
|
|
180
|
-
])])) : (
|
|
181
|
-
|
|
230
|
+
])])) : (c(), u("svg", nt, [...r[6] || (r[6] = [
|
|
231
|
+
a("circle", {
|
|
182
232
|
cx: "12",
|
|
183
233
|
cy: "12",
|
|
184
234
|
r: "10"
|
|
185
235
|
}, null, -1),
|
|
186
|
-
|
|
236
|
+
a("line", {
|
|
187
237
|
x1: "12",
|
|
188
238
|
y1: "16",
|
|
189
239
|
x2: "12",
|
|
190
240
|
y2: "12"
|
|
191
241
|
}, null, -1),
|
|
192
|
-
|
|
242
|
+
a("line", {
|
|
193
243
|
x1: "12",
|
|
194
244
|
y1: "8",
|
|
195
245
|
x2: "12.01",
|
|
@@ -198,103 +248,120 @@ const T = X(), q = { class: "sileo-toast__header" }, H = { class: "sileo-toast__
|
|
|
198
248
|
])]))
|
|
199
249
|
]))
|
|
200
250
|
]),
|
|
201
|
-
|
|
202
|
-
|
|
251
|
+
e.toast.title ? (c(), u("span", it, k(e.toast.title), 1)) : C("", !0),
|
|
252
|
+
e.toast.closeOnClick ? (c(), u("button", {
|
|
203
253
|
key: 1,
|
|
204
|
-
|
|
205
|
-
onClick:
|
|
206
|
-
}, [
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
fill: "none",
|
|
210
|
-
stroke: "currentColor",
|
|
211
|
-
"stroke-width": "2.5",
|
|
212
|
-
"stroke-linecap": "round",
|
|
213
|
-
"stroke-linejoin": "round"
|
|
214
|
-
}, [
|
|
215
|
-
r("line", {
|
|
254
|
+
style: { background: "none", border: "none", padding: "2px", cursor: "pointer", color: "rgba(255, 255, 255, 0.4)", display: "flex", "align-items": "center" },
|
|
255
|
+
onClick: r[0] || (r[0] = $((E) => d.$emit("close"), ["stop"]))
|
|
256
|
+
}, [
|
|
257
|
+
(c(), u("svg", st, [...r[7] || (r[7] = [
|
|
258
|
+
a("line", {
|
|
216
259
|
x1: "18",
|
|
217
260
|
y1: "6",
|
|
218
261
|
x2: "6",
|
|
219
262
|
y2: "18"
|
|
220
|
-
}),
|
|
221
|
-
|
|
263
|
+
}, null, -1),
|
|
264
|
+
a("line", {
|
|
222
265
|
x1: "6",
|
|
223
266
|
y1: "6",
|
|
224
267
|
x2: "18",
|
|
225
268
|
y2: "18"
|
|
226
|
-
})
|
|
227
|
-
]
|
|
228
|
-
])
|
|
229
|
-
]),
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
269
|
+
}, null, -1)
|
|
270
|
+
])]))
|
|
271
|
+
])) : C("", !0)
|
|
272
|
+
], 4),
|
|
273
|
+
a("div", {
|
|
274
|
+
class: "sileo-content-body",
|
|
275
|
+
style: w(P.value)
|
|
276
|
+
}, [
|
|
277
|
+
a("div", rt, [
|
|
278
|
+
a("p", at, k(e.toast.message), 1),
|
|
279
|
+
e.toast.action ? (c(), u("button", {
|
|
234
280
|
key: 0,
|
|
235
|
-
|
|
236
|
-
onClick:
|
|
237
|
-
}, k(
|
|
281
|
+
style: { background: "#fff", color: "#000", border: "none", "border-radius": "12px", padding: "6px 14px", "font-size": "13px", "font-weight": "700", cursor: "pointer", "white-space": "nowrap" },
|
|
282
|
+
onClick: r[1] || (r[1] = $((E) => e.toast.action.onClick(e.toast.id), ["stop"]))
|
|
283
|
+
}, k(e.toast.action.label), 1)) : C("", !0)
|
|
238
284
|
])
|
|
239
|
-
]),
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
class: "sileo-
|
|
243
|
-
style:
|
|
285
|
+
], 4),
|
|
286
|
+
e.toast.duration > 0 && e.toast.showProgress ? (c(), u("div", lt, [
|
|
287
|
+
a("div", {
|
|
288
|
+
class: "sileo-progress-bar-fill",
|
|
289
|
+
style: w({
|
|
290
|
+
animationDuration: `${e.toast.duration}ms`,
|
|
291
|
+
height: "100%",
|
|
292
|
+
background: "currentColor",
|
|
293
|
+
width: "100%"
|
|
294
|
+
})
|
|
244
295
|
}, null, 4)
|
|
245
|
-
])) :
|
|
296
|
+
])) : C("", !0)
|
|
246
297
|
], 38));
|
|
247
298
|
}
|
|
248
|
-
}),
|
|
249
|
-
const u = t.__vccOpts || t;
|
|
250
|
-
for (const [y, e] of d)
|
|
251
|
-
u[y] = e;
|
|
252
|
-
return u;
|
|
253
|
-
}, at = /* @__PURE__ */ S(rt, [["__scopeId", "data-v-f0bda554"]]), lt = { class: "sileo-wrapper" }, ct = /* @__PURE__ */ j({
|
|
299
|
+
}), dt = { class: "sileo-root-wrapper" }, ut = /* @__PURE__ */ I({
|
|
254
300
|
__name: "ToastContainer",
|
|
255
|
-
setup(
|
|
256
|
-
const { toasts:
|
|
301
|
+
setup(e) {
|
|
302
|
+
const { toasts: g, removeToast: p } = j(), f = [
|
|
257
303
|
"top-left",
|
|
258
304
|
"top-center",
|
|
259
305
|
"top-right",
|
|
260
306
|
"bottom-left",
|
|
261
307
|
"bottom-center",
|
|
262
308
|
"bottom-right"
|
|
263
|
-
],
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
309
|
+
], t = (s) => g.filter((n) => n.position === s), o = (s) => {
|
|
310
|
+
const n = s.startsWith("top"), i = s.endsWith("left"), l = s.endsWith("center");
|
|
311
|
+
return {
|
|
312
|
+
position: "absolute",
|
|
313
|
+
top: n ? "0" : "auto",
|
|
314
|
+
bottom: n ? "auto" : "0",
|
|
315
|
+
left: i ? "0" : l ? "50%" : "auto",
|
|
316
|
+
right: !i && !l ? "0" : "auto",
|
|
317
|
+
transform: l ? "translateX(-50%)" : "none",
|
|
318
|
+
padding: "24px",
|
|
319
|
+
display: "flex",
|
|
320
|
+
pointerEvents: "none",
|
|
321
|
+
boxSizing: "border-box",
|
|
322
|
+
alignItems: i ? "flex-start" : l ? "center" : "flex-end",
|
|
323
|
+
flexDirection: n ? "column" : "column-reverse"
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
return (s, n) => (c(), u("div", dt, [
|
|
327
|
+
(c(), u(z, null, D(f, (i) => a("div", {
|
|
328
|
+
key: i,
|
|
329
|
+
class: M(["sileo-position-container", [`sileo-pos-${i}`]]),
|
|
330
|
+
style: w(o(i))
|
|
268
331
|
}, [
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
332
|
+
W(G, {
|
|
333
|
+
name: "sileo-list",
|
|
334
|
+
tag: "div",
|
|
335
|
+
class: "sileo-stack"
|
|
336
|
+
}, {
|
|
337
|
+
default: H(() => [
|
|
338
|
+
(c(!0), u(z, null, D(t(i), (l) => (c(), X(ct, {
|
|
339
|
+
key: l.id,
|
|
340
|
+
toast: l,
|
|
341
|
+
onClose: (x) => U(p)(l.id)
|
|
275
342
|
}, null, 8, ["toast", "onClose"]))), 128))
|
|
276
343
|
]),
|
|
277
344
|
_: 2
|
|
278
345
|
}, 1024)
|
|
279
|
-
],
|
|
346
|
+
], 6)), 64))
|
|
280
347
|
]));
|
|
281
348
|
}
|
|
282
|
-
}),
|
|
283
|
-
install(
|
|
284
|
-
if (Object.keys(
|
|
285
|
-
const
|
|
286
|
-
let
|
|
287
|
-
|
|
288
|
-
render: () =>
|
|
289
|
-
}).mount(
|
|
349
|
+
}), gt = {
|
|
350
|
+
install(e, g = {}) {
|
|
351
|
+
if (Object.keys(g).length > 0 && L.toast.config(g), typeof document < "u") {
|
|
352
|
+
const p = "sileo-toast-container";
|
|
353
|
+
let f = document.getElementById(p);
|
|
354
|
+
f || (f = document.createElement("div"), f.id = p, document.body.appendChild(f), q({
|
|
355
|
+
render: () => J(ut)
|
|
356
|
+
}).mount(f));
|
|
290
357
|
}
|
|
291
|
-
|
|
358
|
+
e.config.globalProperties.$toast = L.toast, e.provide("toast", L.toast);
|
|
292
359
|
}
|
|
293
360
|
};
|
|
294
361
|
export {
|
|
295
|
-
|
|
296
|
-
|
|
362
|
+
gt as SileoPlugin,
|
|
363
|
+
ct as Toast,
|
|
297
364
|
ut as ToastContainer,
|
|
298
|
-
|
|
299
|
-
|
|
365
|
+
L as toastManager,
|
|
366
|
+
j as useToast
|
|
300
367
|
};
|
package/dist/sileo-vue.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(f,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(f=typeof globalThis<"u"?globalThis:f||self,t(f.SileoVue={},f.Vue))})(this,function(f,t){"use strict";const y=t.reactive([]),p=t.reactive({position:"top-right",duration:4e3,maxToasts:5}),T=()=>Math.random().toString(36).substring(2,9);function E(){const e=o=>{const n={type:"default",duration:p.duration||4e3,position:p.position||"top-right",showProgress:!0,closeOnClick:!0,swipeToDismiss:!0},a=typeof o=="string"?{message:o}:o;y.length>=(p.maxToasts||5)&&y.shift();const s=T(),i={...n,...a,id:s,createdAt:Date.now()};return i.icon&&typeof i.icon!="string"&&(i.icon=t.markRaw(i.icon)),y.push(i),i.duration>0&&setTimeout(()=>{c(s)},i.duration),s},c=o=>{const n=y.findIndex(a=>a.id===o);n!==-1&&y.splice(n,1)},l=(o,n)=>{const a=y.findIndex(s=>s.id===o);if(a!==-1){const s={...y[a],...n};typeof n.icon<"u"&&n.icon&&typeof n.icon!="string"&&(s.icon=t.markRaw(n.icon)),y[a]=s}},d=Object.assign(e,{success:o=>e(typeof o=="string"?{message:o,type:"success"}:{...o,type:"success"}),error:o=>e(typeof o=="string"?{message:o,type:"error"}:{...o,type:"error"}),warning:o=>e(typeof o=="string"?{message:o,type:"warning"}:{...o,type:"warning"}),info:o=>e(typeof o=="string"?{message:o,type:"info"}:{...o,type:"info"}),promise:async(o,n)=>{const a=e(typeof n.loading=="string"?{message:n.loading,type:"default",duration:0}:{...n.loading,type:"default",duration:0});try{const s=await o,i=typeof n.success=="function"?n.success(s):n.success,u=typeof i=="string"?{message:i,type:"success"}:{...i,type:"success"};return l(a,{...u,duration:u.duration||4e3}),setTimeout(()=>c(a),u.duration||4e3),s}catch(s){const i=typeof n.error=="function"?n.error(s):n.error,u=typeof i=="string"?{message:i,type:"error"}:{...i,type:"error"};throw l(a,{...u,duration:u.duration||4e3}),setTimeout(()=>c(a),u.duration||4e3),s}},clear:()=>y.length=0,config:o=>Object.assign(p,o)});return{toasts:y,toast:d,removeToast:c,updateToast:l}}const w=E(),N={class:"sileo-toast__header"},b={class:"sileo-toast__icon"},L={key:1},_={key:2,class:"sileo-toast__default-icon"},S={key:0,class:"sileo-spinner",viewBox:"0 0 50 50"},O={key:1,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round"},D={key:2,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round"},$={key:3,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round"},M={key:4,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round"},j={key:0,class:"sileo-toast__title"},I={class:"sileo-toast__body"},P={class:"sileo-toast__content"},X={class:"sileo-toast__message"},z={key:0,class:"sileo-toast__progress"},A=t.defineComponent({__name:"Toast",props:{toast:{}},emits:["close"],setup(e,{emit:c}){const l=e,d=c,o=t.ref(null),n=t.ref(!1),a=t.ref(0),s=t.ref(0),i=t.computed(()=>l.toast.icon),u=t.computed(()=>{const m=s.value,r=Math.max(0,1-Math.abs(m)/250),h=n.value?.98:1;return{transform:`translateX(${m}px) scale(${h})`,opacity:r,transition:n.value?"none":"all 0.5s cubic-bezier(0.19, 1, 0.22, 1)"}}),V=m=>{l.toast.swipeToDismiss&&(n.value=!0,a.value="touches"in m?m.touches[0].clientX:m.clientX,"touches"in m?(window.addEventListener("touchmove",k),window.addEventListener("touchend",g)):(window.addEventListener("mousemove",k),window.addEventListener("mouseup",g)))},k=m=>{if(!n.value)return;const r="touches"in m?m.touches[0].clientX:m.clientX;s.value=r-a.value},g=()=>{n.value&&(n.value=!1,Math.abs(s.value)>120?d("close"):s.value=0,window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",g),window.removeEventListener("touchmove",k),window.removeEventListener("touchend",g))};return t.onUnmounted(()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",g),window.removeEventListener("touchmove",k),window.removeEventListener("touchend",g)}),(m,r)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"toastRef",ref:o,class:t.normalizeClass(["sileo-toast",[`sileo-toast--${e.toast.type}`,{"sileo-toast--dragging":n.value}]]),style:t.normalizeStyle(u.value),onMousedown:V,onTouchstart:V},[t.createElementVNode("div",N,[t.createElementVNode("div",b,[typeof e.toast.icon!="string"&&e.toast.icon?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(i.value),{key:0})):typeof e.toast.icon=="string"?(t.openBlock(),t.createElementBlock("span",L,t.toDisplayString(e.toast.icon),1)):(t.openBlock(),t.createElementBlock("div",_,[e.toast.duration===0&&!e.toast.type||e.toast.type==="default"&&e.toast.duration===0?(t.openBlock(),t.createElementBlock("svg",S,[...r[2]||(r[2]=[t.createElementVNode("circle",{class:"path",cx:"25",cy:"25",r:"20",fill:"none","stroke-width":"5"},null,-1)])])):e.toast.type==="success"?(t.openBlock(),t.createElementBlock("svg",O,[...r[3]||(r[3]=[t.createElementVNode("polyline",{points:"20 6 9 17 4 12"},null,-1)])])):e.toast.type==="error"?(t.openBlock(),t.createElementBlock("svg",D,[...r[4]||(r[4]=[t.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"},null,-1),t.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"},null,-1)])])):e.toast.type==="warning"?(t.openBlock(),t.createElementBlock("svg",$,[...r[5]||(r[5]=[t.createElementVNode("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"},null,-1),t.createElementVNode("line",{x1:"12",y1:"9",x2:"12",y2:"13"},null,-1),t.createElementVNode("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"},null,-1)])])):(t.openBlock(),t.createElementBlock("svg",M,[...r[6]||(r[6]=[t.createElementVNode("circle",{cx:"12",cy:"12",r:"10"},null,-1),t.createElementVNode("line",{x1:"12",y1:"16",x2:"12",y2:"12"},null,-1),t.createElementVNode("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"},null,-1)])]))]))]),e.toast.title?(t.openBlock(),t.createElementBlock("span",j,t.toDisplayString(e.toast.title),1)):t.createCommentVNode("",!0),e.toast.closeOnClick?(t.openBlock(),t.createElementBlock("button",{key:1,class:"sileo-toast__close",onClick:r[0]||(r[0]=t.withModifiers(h=>m.$emit("close"),["stop"]))},[...r[7]||(r[7]=[t.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"},[t.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])])):t.createCommentVNode("",!0)]),t.createElementVNode("div",I,[t.createElementVNode("div",P,[t.createElementVNode("p",X,t.toDisplayString(e.toast.message),1),e.toast.action?(t.openBlock(),t.createElementBlock("button",{key:0,class:"sileo-toast__action",onClick:r[1]||(r[1]=t.withModifiers(h=>e.toast.action.onClick(e.toast.id),["stop"]))},t.toDisplayString(e.toast.action.label),1)):t.createCommentVNode("",!0)])]),e.toast.duration>0&&e.toast.showProgress?(t.openBlock(),t.createElementBlock("div",z,[t.createElementVNode("div",{class:"sileo-toast__progress-inner",style:t.normalizeStyle({animationDuration:`${e.toast.duration}ms`})},null,4)])):t.createCommentVNode("",!0)],38))}}),B=(e,c)=>{const l=e.__vccOpts||e;for(const[d,o]of c)l[d]=o;return l},x=B(A,[["__scopeId","data-v-f0bda554"]]),R={class:"sileo-wrapper"},C=B(t.defineComponent({__name:"ToastContainer",setup(e){const{toasts:c,removeToast:l}=E(),d=["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"],o=n=>c.filter(a=>a.position===n);return(n,a)=>(t.openBlock(),t.createElementBlock("div",R,[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(d,s=>t.createElementVNode("div",{key:s,class:t.normalizeClass(["sileo-container",[`sileo-container--${s}`]])},[t.createVNode(t.TransitionGroup,{name:"sileo-list"},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o(s),i=>(t.openBlock(),t.createBlock(x,{key:i.id,toast:i,onClose:u=>t.unref(l)(i.id)},null,8,["toast","onClose"]))),128))]),_:2},1024)],2)),64))]))}}),[["__scopeId","data-v-7d7ea511"]]),F={install(e,c={}){if(Object.keys(c).length>0&&w.toast.config(c),typeof document<"u"){const l="sileo-toast-container";let d=document.getElementById(l);d||(d=document.createElement("div"),d.id=l,document.body.appendChild(d),t.createApp({render:()=>t.h(C)}).mount(d))}e.config.globalProperties.$toast=w.toast,e.provide("toast",w.toast)}};f.SileoPlugin=F,f.Toast=x,f.ToastContainer=C,f.toastManager=w,f.useToast=E,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(p,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(p=typeof globalThis<"u"?globalThis:p||self,t(p.SileoVue={},p.Vue))})(this,function(p,t){"use strict";const g=t.reactive([]),h=t.reactive({position:"top-right",duration:4e3,maxToasts:5}),V=()=>Math.random().toString(36).substring(2,9);function w(){const o=e=>{const n={type:"default",duration:h.duration||4e3,position:h.position||"top-right",showProgress:!0,closeOnClick:!0,swipeToDismiss:!0},r=typeof e=="string"?{message:e}:e;g.length>=(h.maxToasts||5)&&g.shift();const i=V(),s={...n,...r,id:i,createdAt:Date.now()};return s.icon&&typeof s.icon!="string"&&(s.icon=t.markRaw(s.icon)),g.push(s),s.duration>0&&setTimeout(()=>{m(i)},s.duration),i},m=e=>{const n=g.findIndex(r=>r.id===e);n!==-1&&g.splice(n,1)},d=(e,n)=>{const r=g.findIndex(i=>i.id===e);if(r!==-1){const i={...g[r],...n};typeof n.icon<"u"&&n.icon&&typeof n.icon!="string"&&(i.icon=t.markRaw(n.icon)),g[r]=i}},f=Object.assign(o,{success:e=>o(typeof e=="string"?{message:e,type:"success"}:{...e,type:"success"}),error:e=>o(typeof e=="string"?{message:e,type:"error"}:{...e,type:"error"}),warning:e=>o(typeof e=="string"?{message:e,type:"warning"}:{...e,type:"warning"}),info:e=>o(typeof e=="string"?{message:e,type:"info"}:{...e,type:"info"}),promise:async(e,n)=>{const r=o(typeof n.loading=="string"?{message:n.loading,type:"default",duration:0}:{...n.loading,type:"default",duration:0});try{const i=await e,s=typeof n.success=="function"?n.success(i):n.success,a=typeof s=="string"?{message:s,type:"success"}:{...s,type:"success"};return d(r,{...a,duration:a.duration||4e3}),setTimeout(()=>m(r),a.duration||4e3),i}catch(i){const s=typeof n.error=="function"?n.error(i):n.error,a=typeof s=="string"?{message:s,type:"error"}:{...s,type:"error"};throw d(r,{...a,duration:a.duration||4e3}),setTimeout(()=>m(r),a.duration||4e3),i}},clear:()=>g.length=0,config:e=>Object.assign(h,e)});return{toasts:g,toast:f,removeToast:m,updateToast:d}}const k=w(),S={class:"sileo-icon-box",style:{width:"18px",height:"18px",display:"flex","align-items":"center","justify-content":"center","flex-shrink":"0"}},T={key:1,style:{"font-size":"16px","line-height":"1"}},N={key:2,style:{width:"18px",height:"18px",display:"flex","align-items":"center","justify-content":"center"}},L={key:0,class:"sileo-loading-spinner",viewBox:"0 0 50 50",style:{width:"18px !important",height:"18px !important"}},z={key:1,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3",style:{width:"18px !important",height:"18px !important"}},D={key:2,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3",style:{width:"18px !important",height:"18px !important"}},$={key:3,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3",style:{width:"18px !important",height:"18px !important"}},O={key:4,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3",style:{width:"18px !important",height:"18px !important"}},M={key:0,style:{"font-size":"13px","font-weight":"700",color:"rgba(255, 255, 255, 0.95)","white-space":"nowrap"}},j={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3",style:{width:"12px",height:"12px"}},I={style:{display:"flex","align-items":"center","justify-content":"space-between",gap:"16px"}},X={style:{margin:"0","font-size":"15px","line-height":"1.4",color:"rgba(255, 255, 255, 0.95)","font-weight":"500"}},P={key:0,class:"sileo-progress-bar",style:{position:"absolute",bottom:"8px",left:"24px",right:"24px",height:"3px",background:"rgba(255, 255, 255, 0.05)","border-radius":"10px",overflow:"hidden"}},E=t.defineComponent({__name:"Toast",props:{toast:{}},emits:["close"],setup(o,{emit:m}){const d=o,f=m,e=t.ref(null),n=t.ref(!1),r=t.ref(0),i=t.ref(0),s=t.computed(()=>d.toast.icon),a=t.computed(()=>d.toast.duration===0&&(d.toast.type==="default"||!d.toast.type)),y=t.computed(()=>{const c=d.toast.position||"top-right";return c.includes("center")?"center":c.includes("left")?"left":"right"}),A=t.computed(()=>{const c=i.value,l=Math.max(0,1-Math.abs(c)/300),b=n.value?.95:1,G=y.value==="center"?"center":y.value==="left"?"flex-start":"flex-end";return{transform:`translateX(${c}px) scale(${b})`,opacity:l,transition:n.value?"none":"all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275)",display:"flex",flexDirection:"column",alignItems:G,width:"100%",pointerEvents:"auto",marginBottom:"16px"}}),W=t.computed(()=>({alignSelf:y.value==="center"?"center":y.value==="left"?"flex-start":"flex-end",display:"flex",alignItems:"center",gap:"10px",background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(20px) saturate(180%)",webkitBackdropFilter:"blur(20px) saturate(180%)",padding:"6px 14px",borderRadius:"40px",border:"1px solid rgba(255, 255, 255, 0.15)",color:"#fff",height:"36px",boxSizing:"border-box",marginBottom:"4px"})),q=t.computed(()=>({background:"rgba(28, 28, 30, 0.85)",backdropFilter:"blur(35px) saturate(200%)",webkitBackdropFilter:"blur(35px) saturate(200%)",padding:"16px 20px",borderRadius:"28px",border:"1px solid rgba(255, 255, 255, 0.1)",width:"100%",boxSizing:"border-box",boxShadow:"0 10px 30px rgba(0, 0, 0, 0.4)"})),C=c=>{d.toast.swipeToDismiss&&(n.value=!0,r.value="touches"in c?c.touches[0].clientX:c.clientX,"touches"in c?(window.addEventListener("touchmove",u),window.addEventListener("touchend",x)):(window.addEventListener("mousemove",u),window.addEventListener("mouseup",x)))},u=c=>{if(!n.value)return;const l="touches"in c?c.touches[0].clientX:c.clientX;i.value=(l-r.value)*.8},x=()=>{n.value&&(n.value=!1,Math.abs(i.value)>100?f("close"):i.value=0,window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",x),window.removeEventListener("touchmove",u),window.removeEventListener("touchend",x))};return t.onUnmounted(()=>{window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",x),window.removeEventListener("touchmove",u),window.removeEventListener("touchend",x)}),(c,l)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"toastRef",ref:e,class:t.normalizeClass(["sileo-toast-wrapper",[`sileo-type-${o.toast.type}`,`sileo-pos-align-${y.value}`,{"sileo-is-dragging":n.value}]]),style:t.normalizeStyle(A.value),onMousedown:C,onTouchstart:C},[t.createElementVNode("div",{class:"sileo-pill-header",style:t.normalizeStyle(W.value)},[t.createElementVNode("div",S,[typeof o.toast.icon!="string"&&o.toast.icon?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(s.value),{key:0,style:{width:"18px !important",height:"18px !important",display:"block"}})):typeof o.toast.icon=="string"?(t.openBlock(),t.createElementBlock("span",T,t.toDisplayString(o.toast.icon),1)):(t.openBlock(),t.createElementBlock("div",N,[a.value?(t.openBlock(),t.createElementBlock("svg",L,[...l[2]||(l[2]=[t.createElementVNode("circle",{cx:"25",cy:"25",r:"20",fill:"none",stroke:"currentColor","stroke-width":"5"},null,-1)])])):o.toast.type==="success"?(t.openBlock(),t.createElementBlock("svg",z,[...l[3]||(l[3]=[t.createElementVNode("polyline",{points:"20 6 9 17 4 12"},null,-1)])])):o.toast.type==="error"?(t.openBlock(),t.createElementBlock("svg",D,[...l[4]||(l[4]=[t.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"},null,-1),t.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"},null,-1)])])):o.toast.type==="warning"?(t.openBlock(),t.createElementBlock("svg",$,[...l[5]||(l[5]=[t.createElementVNode("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"},null,-1),t.createElementVNode("line",{x1:"12",y1:"9",x2:"12",y2:"13"},null,-1),t.createElementVNode("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"},null,-1)])])):(t.openBlock(),t.createElementBlock("svg",O,[...l[6]||(l[6]=[t.createElementVNode("circle",{cx:"12",cy:"12",r:"10"},null,-1),t.createElementVNode("line",{x1:"12",y1:"16",x2:"12",y2:"12"},null,-1),t.createElementVNode("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"},null,-1)])]))]))]),o.toast.title?(t.openBlock(),t.createElementBlock("span",M,t.toDisplayString(o.toast.title),1)):t.createCommentVNode("",!0),o.toast.closeOnClick?(t.openBlock(),t.createElementBlock("button",{key:1,style:{background:"none",border:"none",padding:"2px",cursor:"pointer",color:"rgba(255, 255, 255, 0.4)",display:"flex","align-items":"center"},onClick:l[0]||(l[0]=t.withModifiers(b=>c.$emit("close"),["stop"]))},[(t.openBlock(),t.createElementBlock("svg",j,[...l[7]||(l[7]=[t.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"},null,-1),t.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"},null,-1)])]))])):t.createCommentVNode("",!0)],4),t.createElementVNode("div",{class:"sileo-content-body",style:t.normalizeStyle(q.value)},[t.createElementVNode("div",I,[t.createElementVNode("p",X,t.toDisplayString(o.toast.message),1),o.toast.action?(t.openBlock(),t.createElementBlock("button",{key:0,style:{background:"#fff",color:"#000",border:"none","border-radius":"12px",padding:"6px 14px","font-size":"13px","font-weight":"700",cursor:"pointer","white-space":"nowrap"},onClick:l[1]||(l[1]=t.withModifiers(b=>o.toast.action.onClick(o.toast.id),["stop"]))},t.toDisplayString(o.toast.action.label),1)):t.createCommentVNode("",!0)])],4),o.toast.duration>0&&o.toast.showProgress?(t.openBlock(),t.createElementBlock("div",P,[t.createElementVNode("div",{class:"sileo-progress-bar-fill",style:t.normalizeStyle({animationDuration:`${o.toast.duration}ms`,height:"100%",background:"currentColor",width:"100%"})},null,4)])):t.createCommentVNode("",!0)],38))}}),F={class:"sileo-root-wrapper"},B=t.defineComponent({__name:"ToastContainer",setup(o){const{toasts:m,removeToast:d}=w(),f=["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"],e=r=>m.filter(i=>i.position===r),n=r=>{const i=r.startsWith("top"),s=r.endsWith("left"),a=r.endsWith("center");return{position:"absolute",top:i?"0":"auto",bottom:i?"auto":"0",left:s?"0":a?"50%":"auto",right:!s&&!a?"0":"auto",transform:a?"translateX(-50%)":"none",padding:"24px",display:"flex",pointerEvents:"none",boxSizing:"border-box",alignItems:s?"flex-start":a?"center":"flex-end",flexDirection:i?"column":"column-reverse"}};return(r,i)=>(t.openBlock(),t.createElementBlock("div",F,[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(f,s=>t.createElementVNode("div",{key:s,class:t.normalizeClass(["sileo-position-container",[`sileo-pos-${s}`]]),style:t.normalizeStyle(n(s))},[t.createVNode(t.TransitionGroup,{name:"sileo-list",tag:"div",class:"sileo-stack"},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e(s),a=>(t.openBlock(),t.createBlock(E,{key:a.id,toast:a,onClose:y=>t.unref(d)(a.id)},null,8,["toast","onClose"]))),128))]),_:2},1024)],6)),64))]))}}),R={install(o,m={}){if(Object.keys(m).length>0&&k.toast.config(m),typeof document<"u"){const d="sileo-toast-container";let f=document.getElementById(d);f||(f=document.createElement("div"),f.id=d,document.body.appendChild(f),t.createApp({render:()=>t.h(B)}).mount(f))}o.config.globalProperties.$toast=k.toast,o.provide("toast",k.toast)}};p.SileoPlugin=R,p.Toast=E,p.ToastContainer=B,p.toastManager=k,p.useToast=w,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.sileo-toast
|
|
1
|
+
.sileo-toast-wrapper{position:relative!important;width:340px!important;max-width:90vw!important;-webkit-user-select:none!important;user-select:none!important;z-index:10000!important;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif!important;box-sizing:border-box!important}.sileo-loading-spinner{animation:sileo-rotate 1.5s linear infinite!important}.sileo-loading-spinner circle{stroke:currentColor!important;stroke-linecap:round!important;animation:sileo-dash 1.5s ease-in-out infinite!important}@keyframes sileo-rotate{to{transform:rotate(360deg)}}@keyframes sileo-dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}.sileo-progress-bar-fill{animation:sileo-progress-anim linear forwards!important}@keyframes sileo-progress-anim{0%{transform:translate(0)}to{transform:translate(-100%)}}.sileo-type-success{color:#32d74b!important}.sileo-type-error{color:#ff453a!important}.sileo-type-warning{color:#ffd60a!important}.sileo-type-info{color:#0a84ff!important}.sileo-type-default{color:#fff9!important}.sileo-list-enter-active,.sileo-list-leave-active{transition:all .5s cubic-bezier(.19,1,.22,1)!important}.sileo-list-enter-from{opacity:0!important;transform:translateY(-20px) scale(.9)!important}.sileo-list-leave-to{opacity:0!important;transform:scale(.9)!important}.sileo-is-dragging{z-index:10001!important}.sileo-root-wrapper{pointer-events:none!important;position:fixed!important;top:0!important;left:0!important;right:0!important;bottom:0!important;z-index:999999!important;overflow:hidden!important}.sileo-stack{display:flex!important;flex-direction:column!important;gap:12px!important}.sileo-list-move{transition:transform .4s ease!important}
|