@edgar208/sileo-vue 1.7.5 → 1.7.7
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 +285 -280
- package/dist/sileo-vue.umd.cjs +1 -1
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/sileo-vue.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
const y =
|
|
1
|
+
import { reactive as N, markRaw as X, defineComponent as R, ref as C, computed as h, onMounted as q, watch as I, onUnmounted as H, openBlock as u, createElementBlock as d, normalizeStyle as B, normalizeClass as D, createElementVNode as a, createCommentVNode as w, createBlock as V, resolveDynamicComponent as J, toDisplayString as $, withModifiers as z, Fragment as j, renderList as A, createVNode as K, TransitionGroup as Q, withCtx as Y, unref as P, createApp as Z, h as _ } from "vue";
|
|
2
|
+
const y = N([]), T = N({
|
|
3
3
|
position: "top-right",
|
|
4
4
|
duration: 6e3,
|
|
5
5
|
maxToasts: 5
|
|
6
|
-
}),
|
|
7
|
-
function
|
|
6
|
+
}), tt = () => Math.random().toString(36).substring(2, 9);
|
|
7
|
+
function W() {
|
|
8
8
|
const o = (t) => {
|
|
9
9
|
const e = {
|
|
10
10
|
type: "default",
|
|
@@ -14,45 +14,46 @@ function V() {
|
|
|
14
14
|
closeOnClick: !0,
|
|
15
15
|
swipeToDismiss: !0,
|
|
16
16
|
theme: T.theme
|
|
17
|
-
},
|
|
17
|
+
}, i = typeof t == "string" ? { message: t } : t;
|
|
18
18
|
y.length >= (T.maxToasts || 5) && y.shift();
|
|
19
|
-
const n =
|
|
19
|
+
const n = tt(), r = {
|
|
20
20
|
message: "",
|
|
21
21
|
...e,
|
|
22
|
-
...
|
|
22
|
+
...i,
|
|
23
23
|
id: n,
|
|
24
|
-
createdAt: Date.now()
|
|
24
|
+
createdAt: Date.now(),
|
|
25
|
+
closing: !1
|
|
25
26
|
};
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
const e = y.find((
|
|
27
|
+
return r.icon && typeof r.icon != "string" && (r.icon = X(r.icon)), y.push(r), r.duration && r.duration > 0 && setTimeout(() => {
|
|
28
|
+
v(n);
|
|
29
|
+
}, r.duration), n;
|
|
30
|
+
}, v = (t) => {
|
|
31
|
+
const e = y.find((i) => i.id === t);
|
|
31
32
|
e && (e.closing = !0);
|
|
32
33
|
}, s = (t) => {
|
|
33
|
-
const e = y.findIndex((
|
|
34
|
+
const e = y.findIndex((i) => i.id === t);
|
|
34
35
|
e > -1 && y.splice(e, 1);
|
|
35
36
|
}, f = () => {
|
|
36
37
|
y.forEach((t) => t.closing = !0);
|
|
37
38
|
}, p = (t, e) => {
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
const n = { ...y[
|
|
41
|
-
typeof e.icon < "u" && e.icon && typeof e.icon != "string" && (n.icon =
|
|
39
|
+
const i = y.findIndex((n) => n.id === t);
|
|
40
|
+
if (i !== -1) {
|
|
41
|
+
const n = { ...y[i], ...e };
|
|
42
|
+
typeof e.icon < "u" && e.icon && typeof e.icon != "string" && (n.icon = X(e.icon)), y[i] = n;
|
|
42
43
|
}
|
|
43
|
-
},
|
|
44
|
+
}, g = (t) => Object.assign(T, t), x = Object.assign(o, {
|
|
44
45
|
success: (t) => o(typeof t == "string" ? { message: t, type: "success" } : { ...t, type: "success" }),
|
|
45
46
|
error: (t) => o(typeof t == "string" ? { message: t, type: "error" } : { ...t, type: "error" }),
|
|
46
47
|
warning: (t) => o(typeof t == "string" ? { message: t, type: "warning" } : { ...t, type: "warning" }),
|
|
47
48
|
info: (t) => o(typeof t == "string" ? { message: t, type: "info" } : { ...t, type: "info" }),
|
|
48
49
|
promise: async (t, e) => {
|
|
49
|
-
const
|
|
50
|
+
const i = o(typeof e.loading == "string" ? { message: e.loading, type: "default", duration: 0 } : { ...e.loading, type: "default", duration: 0 });
|
|
50
51
|
try {
|
|
51
|
-
const n = await t,
|
|
52
|
-
return p(
|
|
52
|
+
const n = await t, r = typeof e.success == "function" ? e.success(n) : e.success, m = typeof r == "string" ? { message: r, type: "success" } : { ...r, type: "success" };
|
|
53
|
+
return p(i, { ...m, duration: m.duration || 4e3 }), setTimeout(() => v(i), m.duration || 4e3), n;
|
|
53
54
|
} catch (n) {
|
|
54
|
-
const
|
|
55
|
-
throw p(
|
|
55
|
+
const r = typeof e.error == "function" ? e.error(n) : e.error, m = typeof r == "string" ? { message: r, type: "error" } : { ...r, type: "error" };
|
|
56
|
+
throw p(i, { ...m, duration: m.duration || 4e3 }), setTimeout(() => v(i), m.duration || 4e3), n;
|
|
56
57
|
}
|
|
57
58
|
},
|
|
58
59
|
clear: () => y.length = 0,
|
|
@@ -60,320 +61,324 @@ function V() {
|
|
|
60
61
|
});
|
|
61
62
|
return {
|
|
62
63
|
toasts: y,
|
|
63
|
-
config:
|
|
64
|
+
config: g,
|
|
64
65
|
addToast: o,
|
|
65
|
-
removeToast:
|
|
66
|
+
removeToast: v,
|
|
66
67
|
destroyToast: s,
|
|
67
68
|
clearToasts: f,
|
|
68
69
|
updateToast: p,
|
|
69
|
-
toast:
|
|
70
|
+
toast: x
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
|
-
const
|
|
73
|
-
__name: "ToastContainer",
|
|
74
|
-
setup(o) {
|
|
75
|
-
const { toasts: m, removeToast: s, destroyToast: f } = V(), p = [
|
|
76
|
-
"top-left",
|
|
77
|
-
"top-center",
|
|
78
|
-
"top-right",
|
|
79
|
-
"bottom-left",
|
|
80
|
-
"bottom-center",
|
|
81
|
-
"bottom-right"
|
|
82
|
-
], v = (t) => m.filter((e) => e.position === t), w = (t) => {
|
|
83
|
-
const e = t.startsWith("top"), r = t.endsWith("left"), n = t.endsWith("center");
|
|
84
|
-
return {
|
|
85
|
-
position: "absolute",
|
|
86
|
-
top: e ? "0" : "auto",
|
|
87
|
-
bottom: e ? "auto" : "0",
|
|
88
|
-
left: r ? "0" : n ? "50%" : "auto",
|
|
89
|
-
right: !r && !n ? "0" : "auto",
|
|
90
|
-
transform: n ? "translateX(-50%)" : "none",
|
|
91
|
-
padding: "24px",
|
|
92
|
-
display: "flex",
|
|
93
|
-
pointerEvents: "none",
|
|
94
|
-
boxSizing: "border-box",
|
|
95
|
-
alignItems: r ? "flex-start" : n ? "center" : "flex-end",
|
|
96
|
-
flexDirection: e ? "column" : "column-reverse"
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
return (t, e) => {
|
|
100
|
-
const r = U("ToastItem");
|
|
101
|
-
return u(), d("div", ot, [
|
|
102
|
-
(u(), d(I, null, S(p, (n) => a("div", {
|
|
103
|
-
key: n,
|
|
104
|
-
class: $(["sileo-position-container", [`sileo-pos-${n}`]]),
|
|
105
|
-
style: N(w(n))
|
|
106
|
-
}, [
|
|
107
|
-
q(H, {
|
|
108
|
-
name: "sileo-list",
|
|
109
|
-
tag: "div",
|
|
110
|
-
class: "sileo-stack"
|
|
111
|
-
}, {
|
|
112
|
-
default: J(() => [
|
|
113
|
-
(u(!0), d(I, null, S(v(n), (i) => (u(), R(r, {
|
|
114
|
-
key: i.id,
|
|
115
|
-
toast: i,
|
|
116
|
-
onClose: (g) => X(s)(i.id),
|
|
117
|
-
onDestroy: (g) => X(f)(i.id)
|
|
118
|
-
}, null, 8, ["toast", "onClose", "onDestroy"]))), 128))
|
|
119
|
-
]),
|
|
120
|
-
_: 2
|
|
121
|
-
}, 1024)
|
|
122
|
-
], 6)), 64))
|
|
123
|
-
]);
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
}), bt = {
|
|
127
|
-
install(o, m = {}) {
|
|
128
|
-
if (Object.keys(m).length > 0 && B.toast.config(m), typeof document < "u") {
|
|
129
|
-
const s = "sileo-toast-container";
|
|
130
|
-
let f = document.getElementById(s);
|
|
131
|
-
f || (f = document.createElement("div"), f.id = s, document.body.appendChild(f), K({
|
|
132
|
-
render: () => Q(st)
|
|
133
|
-
}).mount(f));
|
|
134
|
-
}
|
|
135
|
-
o.config.globalProperties.$toast = B.toast, o.provide("toast", B.toast);
|
|
136
|
-
}
|
|
137
|
-
}, nt = { class: "sileo-header-pill" }, it = {
|
|
73
|
+
const O = W(), xt = O.toast, et = { class: "sileo-header-pill" }, ot = {
|
|
138
74
|
key: 0,
|
|
139
75
|
class: "sileo-sweep-left"
|
|
140
|
-
},
|
|
76
|
+
}, st = {
|
|
141
77
|
key: 1,
|
|
142
78
|
class: "sileo-sweep-right"
|
|
143
|
-
},
|
|
79
|
+
}, nt = { class: "sileo-icon-wrapper" }, it = {
|
|
144
80
|
key: 1,
|
|
145
81
|
class: "sileo-emoji"
|
|
146
|
-
},
|
|
82
|
+
}, at = {
|
|
147
83
|
key: 2,
|
|
148
84
|
class: "sileo-default-icon"
|
|
149
|
-
},
|
|
85
|
+
}, rt = {
|
|
150
86
|
key: 0,
|
|
151
87
|
class: "sileo-spin",
|
|
152
88
|
viewBox: "0 0 50 50"
|
|
153
|
-
},
|
|
89
|
+
}, lt = {
|
|
154
90
|
key: 1,
|
|
155
91
|
class: "sileo-icon-circle bg-success"
|
|
156
|
-
},
|
|
92
|
+
}, ct = {
|
|
157
93
|
key: 2,
|
|
158
94
|
class: "sileo-icon-circle bg-error"
|
|
159
|
-
},
|
|
95
|
+
}, ut = {
|
|
160
96
|
key: 3,
|
|
161
97
|
class: "sileo-icon-circle bg-warning"
|
|
162
|
-
},
|
|
98
|
+
}, dt = {
|
|
163
99
|
key: 4,
|
|
164
100
|
class: "sileo-icon-circle bg-info"
|
|
165
|
-
},
|
|
101
|
+
}, ft = {
|
|
166
102
|
key: 0,
|
|
167
103
|
class: "sileo-main-body-animator"
|
|
168
|
-
},
|
|
104
|
+
}, yt = { class: "sileo-main-wrapper" }, vt = { class: "sileo-main-body" }, gt = {
|
|
169
105
|
key: 0,
|
|
170
106
|
class: "sileo-message"
|
|
171
|
-
},
|
|
107
|
+
}, mt = /* @__PURE__ */ R({
|
|
172
108
|
__name: "Toast",
|
|
173
109
|
props: {
|
|
174
110
|
toast: {}
|
|
175
111
|
},
|
|
176
112
|
emits: ["close", "destroy"],
|
|
177
|
-
setup(o, { emit:
|
|
178
|
-
const s = o, f =
|
|
179
|
-
|
|
180
|
-
|
|
113
|
+
setup(o, { emit: v }) {
|
|
114
|
+
const s = o, f = v, p = C(null), g = C(!1), x = C(0), t = C(0), e = C(!1), i = h(() => s.toast.title ? s.toast.title : !s.toast.title && s.toast.message && !s.toast.action ? s.toast.message : null), n = h(() => s.toast.title && s.toast.message || !s.toast.title && s.toast.message && s.toast.action ? s.toast.message : null), r = h(() => !!n.value || !!s.toast.action);
|
|
115
|
+
q(() => {
|
|
116
|
+
r.value && setTimeout(() => {
|
|
181
117
|
e.value = !0;
|
|
182
118
|
}, 500);
|
|
183
|
-
}),
|
|
119
|
+
}), I(r, (c, l) => {
|
|
184
120
|
c === !0 && l === !1 && (e.value = !0);
|
|
185
|
-
}),
|
|
186
|
-
c && (
|
|
121
|
+
}), I(() => s.toast.closing, (c) => {
|
|
122
|
+
c === !0 && (r.value && e.value ? (e.value = !1, setTimeout(() => {
|
|
187
123
|
f("destroy");
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
const
|
|
124
|
+
}, 700)) : f("destroy"));
|
|
125
|
+
}, { immediate: !0 });
|
|
126
|
+
const m = h(() => s.toast.icon), F = h(() => s.toast.duration === 0 && (s.toast.type === "default" || !s.toast.type)), E = h(() => {
|
|
191
127
|
const c = s.toast.position || "top-right";
|
|
192
128
|
return c.includes("center") ? "center" : c.includes("left") ? "left" : "right";
|
|
193
|
-
}),
|
|
194
|
-
const c = t.value, l = Math.max(0, 1 - Math.abs(c) / 300),
|
|
129
|
+
}), G = h(() => (s.toast.position || "top-right").includes("top")), U = h(() => {
|
|
130
|
+
const c = t.value, l = Math.max(0, 1 - Math.abs(c) / 300), L = g.value ? 0.95 : 1, M = E.value === "center" ? "center" : E.value === "left" ? "flex-start" : "flex-end";
|
|
195
131
|
return {
|
|
196
|
-
transform: `translateX(${c}px) scale(${
|
|
132
|
+
transform: `translateX(${c}px) scale(${L})`,
|
|
197
133
|
opacity: l,
|
|
198
|
-
transition:
|
|
134
|
+
transition: g.value ? "none" : "opacity 0.4s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1)",
|
|
199
135
|
display: "flex",
|
|
200
136
|
flexDirection: "column",
|
|
201
|
-
alignItems:
|
|
137
|
+
alignItems: M,
|
|
202
138
|
width: "100%",
|
|
203
139
|
pointerEvents: "auto",
|
|
204
140
|
marginBottom: "16px",
|
|
205
|
-
"--sileo-y-dir":
|
|
141
|
+
"--sileo-y-dir": G.value ? "-50px" : "50px"
|
|
206
142
|
};
|
|
207
|
-
}),
|
|
208
|
-
s.toast.swipeToDismiss && (
|
|
143
|
+
}), S = (c) => {
|
|
144
|
+
s.toast.swipeToDismiss && (g.value = !0, x.value = "touches" in c ? c.touches[0].clientX : c.clientX, "touches" in c ? (window.addEventListener("touchmove", k), window.addEventListener("touchend", b)) : (window.addEventListener("mousemove", k), window.addEventListener("mouseup", b)));
|
|
209
145
|
}, k = (c) => {
|
|
210
|
-
if (!
|
|
146
|
+
if (!g.value) return;
|
|
211
147
|
const l = "touches" in c ? c.touches[0].clientX : c.clientX;
|
|
212
|
-
t.value = (l -
|
|
148
|
+
t.value = (l - x.value) * 0.8;
|
|
213
149
|
}, b = () => {
|
|
214
|
-
|
|
150
|
+
g.value && (g.value = !1, Math.abs(t.value) > 100 ? f("close") : t.value = 0, window.removeEventListener("mousemove", k), window.removeEventListener("mouseup", b), window.removeEventListener("touchmove", k), window.removeEventListener("touchend", b));
|
|
215
151
|
};
|
|
216
|
-
return
|
|
152
|
+
return H(() => {
|
|
217
153
|
window.removeEventListener("mousemove", k), window.removeEventListener("mouseup", b), window.removeEventListener("touchmove", k), window.removeEventListener("touchend", b);
|
|
218
|
-
}), (c, l) =>
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
class: $(["sileo-combined-shape", { "is-expanded": e.value }])
|
|
154
|
+
}), (c, l) => {
|
|
155
|
+
var L;
|
|
156
|
+
return u(), d("div", {
|
|
157
|
+
ref_key: "toastRef",
|
|
158
|
+
ref: p,
|
|
159
|
+
class: D(["sileo-toast-outer", [
|
|
160
|
+
`sileo-type-${o.toast.type || "default"}`,
|
|
161
|
+
`sileo-align-${E.value}`,
|
|
162
|
+
o.toast.theme === "light" ? "sileo-theme-light" : "",
|
|
163
|
+
o.toast.theme === "dark" ? "sileo-theme-dark" : "",
|
|
164
|
+
{ "sileo-is-dragging": g.value }
|
|
165
|
+
]]),
|
|
166
|
+
style: B(U.value),
|
|
167
|
+
onMousedown: S,
|
|
168
|
+
onTouchstart: S
|
|
234
169
|
}, [
|
|
235
|
-
a("div",
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
a("div",
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
r: "20",
|
|
248
|
-
fill: "none",
|
|
249
|
-
stroke: "currentColor",
|
|
250
|
-
"stroke-width": "5"
|
|
251
|
-
}, null, -1)
|
|
252
|
-
])])) : o.toast.type === "success" ? (u(), d("div", dt, [...l[3] || (l[3] = [
|
|
253
|
-
a("svg", {
|
|
254
|
-
viewBox: "0 0 24 24",
|
|
255
|
-
fill: "none",
|
|
256
|
-
class: "sileo-stroke-icon"
|
|
257
|
-
}, [
|
|
258
|
-
a("polyline", { points: "20 6 9 17 4 12" })
|
|
259
|
-
], -1)
|
|
260
|
-
])])) : o.toast.type === "error" ? (u(), d("div", ft, [...l[4] || (l[4] = [
|
|
261
|
-
a("svg", {
|
|
262
|
-
viewBox: "0 0 24 24",
|
|
263
|
-
fill: "none",
|
|
264
|
-
class: "sileo-stroke-icon"
|
|
265
|
-
}, [
|
|
266
|
-
a("line", {
|
|
267
|
-
x1: "18",
|
|
268
|
-
y1: "6",
|
|
269
|
-
x2: "6",
|
|
270
|
-
y2: "18"
|
|
271
|
-
}),
|
|
272
|
-
a("line", {
|
|
273
|
-
x1: "6",
|
|
274
|
-
y1: "6",
|
|
275
|
-
x2: "18",
|
|
276
|
-
y2: "18"
|
|
277
|
-
})
|
|
278
|
-
], -1)
|
|
279
|
-
])])) : o.toast.type === "warning" ? (u(), d("div", yt, [...l[5] || (l[5] = [
|
|
280
|
-
a("svg", {
|
|
281
|
-
viewBox: "0 0 24 24",
|
|
282
|
-
fill: "none",
|
|
283
|
-
class: "sileo-stroke-icon"
|
|
284
|
-
}, [
|
|
285
|
-
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" }),
|
|
286
|
-
a("line", {
|
|
287
|
-
x1: "12",
|
|
288
|
-
y1: "9",
|
|
289
|
-
x2: "12",
|
|
290
|
-
y2: "13"
|
|
291
|
-
}),
|
|
292
|
-
a("line", {
|
|
293
|
-
x1: "12",
|
|
294
|
-
y1: "17",
|
|
295
|
-
x2: "12.01",
|
|
296
|
-
y2: "17"
|
|
297
|
-
})
|
|
298
|
-
], -1)
|
|
299
|
-
])])) : (u(), d("div", mt, [...l[6] || (l[6] = [
|
|
300
|
-
a("svg", {
|
|
301
|
-
viewBox: "0 0 24 24",
|
|
302
|
-
fill: "none",
|
|
303
|
-
class: "sileo-stroke-icon"
|
|
304
|
-
}, [
|
|
170
|
+
a("div", {
|
|
171
|
+
class: D(["sileo-combined-shape", { "is-expanded": e.value }])
|
|
172
|
+
}, [
|
|
173
|
+
a("div", et, [
|
|
174
|
+
E.value !== "left" ? (u(), d("div", ot)) : w("", !0),
|
|
175
|
+
E.value !== "right" ? (u(), d("div", st)) : w("", !0),
|
|
176
|
+
a("div", nt, [
|
|
177
|
+
typeof o.toast.icon != "string" && o.toast.icon ? (u(), V(J(m.value), {
|
|
178
|
+
key: 0,
|
|
179
|
+
class: "sileo-custom-icon"
|
|
180
|
+
})) : typeof o.toast.icon == "string" ? (u(), d("span", it, $(o.toast.icon), 1)) : (u(), d("div", at, [
|
|
181
|
+
F.value ? (u(), d("svg", rt, [...l[2] || (l[2] = [
|
|
305
182
|
a("circle", {
|
|
306
|
-
cx: "
|
|
307
|
-
cy: "
|
|
308
|
-
r: "
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
183
|
+
cx: "25",
|
|
184
|
+
cy: "25",
|
|
185
|
+
r: "20",
|
|
186
|
+
fill: "none",
|
|
187
|
+
stroke: "currentColor",
|
|
188
|
+
"stroke-width": "5"
|
|
189
|
+
}, null, -1)
|
|
190
|
+
])])) : o.toast.type === "success" ? (u(), d("div", lt, [...l[3] || (l[3] = [
|
|
191
|
+
a("svg", {
|
|
192
|
+
viewBox: "0 0 24 24",
|
|
193
|
+
fill: "none",
|
|
194
|
+
class: "sileo-stroke-icon"
|
|
195
|
+
}, [
|
|
196
|
+
a("polyline", { points: "20 6 9 17 4 12" })
|
|
197
|
+
], -1)
|
|
198
|
+
])])) : o.toast.type === "error" ? (u(), d("div", ct, [...l[4] || (l[4] = [
|
|
199
|
+
a("svg", {
|
|
200
|
+
viewBox: "0 0 24 24",
|
|
201
|
+
fill: "none",
|
|
202
|
+
class: "sileo-stroke-icon"
|
|
203
|
+
}, [
|
|
204
|
+
a("line", {
|
|
205
|
+
x1: "18",
|
|
206
|
+
y1: "6",
|
|
207
|
+
x2: "6",
|
|
208
|
+
y2: "18"
|
|
209
|
+
}),
|
|
210
|
+
a("line", {
|
|
211
|
+
x1: "6",
|
|
212
|
+
y1: "6",
|
|
213
|
+
x2: "18",
|
|
214
|
+
y2: "18"
|
|
215
|
+
})
|
|
216
|
+
], -1)
|
|
217
|
+
])])) : o.toast.type === "warning" ? (u(), d("div", ut, [...l[5] || (l[5] = [
|
|
218
|
+
a("svg", {
|
|
219
|
+
viewBox: "0 0 24 24",
|
|
220
|
+
fill: "none",
|
|
221
|
+
class: "sileo-stroke-icon"
|
|
222
|
+
}, [
|
|
223
|
+
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" }),
|
|
224
|
+
a("line", {
|
|
225
|
+
x1: "12",
|
|
226
|
+
y1: "9",
|
|
227
|
+
x2: "12",
|
|
228
|
+
y2: "13"
|
|
229
|
+
}),
|
|
230
|
+
a("line", {
|
|
231
|
+
x1: "12",
|
|
232
|
+
y1: "17",
|
|
233
|
+
x2: "12.01",
|
|
234
|
+
y2: "17"
|
|
235
|
+
})
|
|
236
|
+
], -1)
|
|
237
|
+
])])) : (u(), d("div", dt, [...l[6] || (l[6] = [
|
|
238
|
+
a("svg", {
|
|
239
|
+
viewBox: "0 0 24 24",
|
|
240
|
+
fill: "none",
|
|
241
|
+
class: "sileo-stroke-icon"
|
|
242
|
+
}, [
|
|
243
|
+
a("circle", {
|
|
244
|
+
cx: "12",
|
|
245
|
+
cy: "12",
|
|
246
|
+
r: "10"
|
|
247
|
+
}),
|
|
248
|
+
a("line", {
|
|
249
|
+
x1: "12",
|
|
250
|
+
y1: "16",
|
|
251
|
+
x2: "12",
|
|
252
|
+
y2: "12"
|
|
253
|
+
}),
|
|
254
|
+
a("line", {
|
|
255
|
+
x1: "12",
|
|
256
|
+
y1: "8",
|
|
257
|
+
x2: "12.01",
|
|
258
|
+
y2: "8"
|
|
259
|
+
})
|
|
260
|
+
], -1)
|
|
261
|
+
])]))
|
|
262
|
+
]))
|
|
263
|
+
]),
|
|
264
|
+
i.value ? (u(), d("span", {
|
|
265
|
+
key: 2,
|
|
266
|
+
class: D(["sileo-title-text", `text-${o.toast.type || "default"}`])
|
|
267
|
+
}, $(i.value), 3)) : w("", !0),
|
|
268
|
+
o.toast.closeOnClick ? (u(), d("button", {
|
|
269
|
+
key: 3,
|
|
270
|
+
class: "sileo-close-btn",
|
|
271
|
+
onClick: l[0] || (l[0] = z((M) => c.$emit("close"), ["stop"]))
|
|
272
|
+
}, [...l[7] || (l[7] = [
|
|
273
|
+
a("svg", {
|
|
274
|
+
viewBox: "0 0 24 24",
|
|
275
|
+
fill: "none"
|
|
276
|
+
}, [
|
|
277
|
+
a("line", {
|
|
278
|
+
x1: "18",
|
|
279
|
+
y1: "6",
|
|
280
|
+
x2: "6",
|
|
281
|
+
y2: "18"
|
|
282
|
+
}),
|
|
283
|
+
a("line", {
|
|
284
|
+
x1: "6",
|
|
285
|
+
y1: "6",
|
|
286
|
+
x2: "18",
|
|
287
|
+
y2: "18"
|
|
288
|
+
})
|
|
289
|
+
], -1)
|
|
290
|
+
])])) : w("", !0)
|
|
325
291
|
]),
|
|
326
|
-
r.value ? (u(), d("
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
y1: "6",
|
|
342
|
-
x2: "6",
|
|
343
|
-
y2: "18"
|
|
344
|
-
}),
|
|
345
|
-
a("line", {
|
|
346
|
-
x1: "6",
|
|
347
|
-
y1: "6",
|
|
348
|
-
x2: "18",
|
|
349
|
-
y2: "18"
|
|
350
|
-
})
|
|
351
|
-
], -1)
|
|
352
|
-
])])) : x("", !0)
|
|
353
|
-
]),
|
|
354
|
-
i.value ? (u(), d("div", vt, [
|
|
355
|
-
a("div", gt, [
|
|
356
|
-
a("div", pt, [
|
|
357
|
-
a("div", ht, [
|
|
358
|
-
n.value ? (u(), d("p", xt, L(n.value), 1)) : x("", !0),
|
|
359
|
-
o.toast.action ? (u(), d("button", {
|
|
360
|
-
key: 1,
|
|
361
|
-
class: "sileo-action-trigger",
|
|
362
|
-
onClick: l[1] || (l[1] = j((D) => o.toast.action.onClick(o.toast.id), ["stop"]))
|
|
363
|
-
}, L(o.toast.action.label), 1)) : x("", !0)
|
|
292
|
+
r.value ? (u(), d("div", ft, [
|
|
293
|
+
a("div", yt, [
|
|
294
|
+
a("div", vt, [
|
|
295
|
+
a("div", {
|
|
296
|
+
class: "sileo-body-content",
|
|
297
|
+
style: B({ flexDirection: ((L = o.toast.action) == null ? void 0 : L.position) === "left" ? "row-reverse" : "row" })
|
|
298
|
+
}, [
|
|
299
|
+
n.value ? (u(), d("p", gt, $(n.value), 1)) : w("", !0),
|
|
300
|
+
o.toast.action ? (u(), d("button", {
|
|
301
|
+
key: 1,
|
|
302
|
+
class: "sileo-action-trigger",
|
|
303
|
+
style: B({ background: o.toast.action.color }),
|
|
304
|
+
onClick: l[1] || (l[1] = z((M) => o.toast.action.onClick(o.toast.id), ["stop"]))
|
|
305
|
+
}, $(o.toast.action.label), 5)) : w("", !0)
|
|
306
|
+
], 4)
|
|
364
307
|
])
|
|
365
308
|
])
|
|
366
|
-
])
|
|
367
|
-
]
|
|
368
|
-
],
|
|
369
|
-
|
|
309
|
+
])) : w("", !0)
|
|
310
|
+
], 2)
|
|
311
|
+
], 38);
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
}), pt = { class: "sileo-root-wrapper" }, ht = /* @__PURE__ */ R({
|
|
315
|
+
__name: "ToastContainer",
|
|
316
|
+
setup(o) {
|
|
317
|
+
const { toasts: v, removeToast: s, destroyToast: f } = W(), p = [
|
|
318
|
+
"top-left",
|
|
319
|
+
"top-center",
|
|
320
|
+
"top-right",
|
|
321
|
+
"bottom-left",
|
|
322
|
+
"bottom-center",
|
|
323
|
+
"bottom-right"
|
|
324
|
+
], g = (t) => v.filter((e) => e.position === t), x = (t) => {
|
|
325
|
+
const e = t.startsWith("top"), i = t.endsWith("left"), n = t.endsWith("center");
|
|
326
|
+
return {
|
|
327
|
+
position: "absolute",
|
|
328
|
+
top: e ? "0" : "auto",
|
|
329
|
+
bottom: e ? "auto" : "0",
|
|
330
|
+
left: i ? "0" : n ? "50%" : "auto",
|
|
331
|
+
right: !i && !n ? "0" : "auto",
|
|
332
|
+
transform: n ? "translateX(-50%)" : "none",
|
|
333
|
+
padding: "24px",
|
|
334
|
+
display: "flex",
|
|
335
|
+
pointerEvents: "none",
|
|
336
|
+
boxSizing: "border-box",
|
|
337
|
+
alignItems: i ? "flex-start" : n ? "center" : "flex-end",
|
|
338
|
+
flexDirection: e ? "column" : "column-reverse"
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
return (t, e) => (u(), d("div", pt, [
|
|
342
|
+
(u(), d(j, null, A(p, (i) => a("div", {
|
|
343
|
+
key: i,
|
|
344
|
+
class: D(["sileo-position-container", [`sileo-pos-${i}`]]),
|
|
345
|
+
style: B(x(i))
|
|
346
|
+
}, [
|
|
347
|
+
K(Q, {
|
|
348
|
+
name: "sileo-list",
|
|
349
|
+
tag: "div",
|
|
350
|
+
class: "sileo-stack"
|
|
351
|
+
}, {
|
|
352
|
+
default: Y(() => [
|
|
353
|
+
(u(!0), d(j, null, A(g(i), (n) => (u(), V(mt, {
|
|
354
|
+
key: n.id,
|
|
355
|
+
toast: n,
|
|
356
|
+
onClose: (r) => P(s)(n.id),
|
|
357
|
+
onDestroy: (r) => P(f)(n.id)
|
|
358
|
+
}, null, 8, ["toast", "onClose", "onDestroy"]))), 128))
|
|
359
|
+
]),
|
|
360
|
+
_: 2
|
|
361
|
+
}, 1024)
|
|
362
|
+
], 6)), 64))
|
|
363
|
+
]));
|
|
370
364
|
}
|
|
371
|
-
})
|
|
365
|
+
}), kt = {
|
|
366
|
+
install(o, v = {}) {
|
|
367
|
+
if (Object.keys(v).length > 0 && O.toast.config(v), typeof document < "u") {
|
|
368
|
+
const s = "sileo-toast-container";
|
|
369
|
+
let f = document.getElementById(s);
|
|
370
|
+
f || (f = document.createElement("div"), f.id = s, document.body.appendChild(f), Z({
|
|
371
|
+
render: () => _(ht)
|
|
372
|
+
}).mount(f));
|
|
373
|
+
}
|
|
374
|
+
o.config.globalProperties.$toast = O.toast, o.provide("toast", O.toast);
|
|
375
|
+
}
|
|
376
|
+
};
|
|
372
377
|
export {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
378
|
+
kt as SileoPlugin,
|
|
379
|
+
mt as Toast,
|
|
380
|
+
ht as ToastContainer,
|
|
381
|
+
xt as toast,
|
|
382
|
+
O as toastManager,
|
|
383
|
+
W as useToast
|
|
379
384
|
};
|
package/dist/sileo-vue.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(m,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(m=typeof globalThis<"u"?globalThis:m||self,e(m.SileoVue={},m.Vue))})(this,function(m,e){"use strict";const f=e.reactive([]),k=e.reactive({position:"top-right",duration:6e3,maxToasts:5}),C=()=>Math.random().toString(36).substring(2,9);function T(){const n=t=>{const o={type:"default",duration:k.duration||6e3,position:k.position||"top-right",showProgress:!0,closeOnClick:!0,swipeToDismiss:!0,theme:k.theme},l=typeof t=="string"?{message:t}:t;f.length>=(k.maxToasts||5)&&f.shift();const i=C(),a={message:"",...o,...l,id:i,createdAt:Date.now()};return a.icon&&typeof a.icon!="string"&&(a.icon=e.markRaw(a.icon)),f.push(a),a.duration&&a.duration>0&&setTimeout(()=>{p(i)},a.duration),i},p=t=>{const o=f.find(l=>l.id===t);o&&(o.closing=!0)},s=t=>{const o=f.findIndex(l=>l.id===t);o>-1&&f.splice(o,1)},d=()=>{f.forEach(t=>t.closing=!0)},u=(t,o)=>{const l=f.findIndex(i=>i.id===t);if(l!==-1){const i={...f[l],...o};typeof o.icon<"u"&&o.icon&&typeof o.icon!="string"&&(i.icon=e.markRaw(o.icon)),f[l]=i}},y=t=>Object.assign(k,t),h=Object.assign(n,{success:t=>n(typeof t=="string"?{message:t,type:"success"}:{...t,type:"success"}),error:t=>n(typeof t=="string"?{message:t,type:"error"}:{...t,type:"error"}),warning:t=>n(typeof t=="string"?{message:t,type:"warning"}:{...t,type:"warning"}),info:t=>n(typeof t=="string"?{message:t,type:"info"}:{...t,type:"info"}),promise:async(t,o)=>{const l=n(typeof o.loading=="string"?{message:o.loading,type:"default",duration:0}:{...o.loading,type:"default",duration:0});try{const i=await t,a=typeof o.success=="function"?o.success(i):o.success,g=typeof a=="string"?{message:a,type:"success"}:{...a,type:"success"};return u(l,{...g,duration:g.duration||4e3}),setTimeout(()=>p(l),g.duration||4e3),i}catch(i){const a=typeof o.error=="function"?o.error(i):o.error,g=typeof a=="string"?{message:a,type:"error"}:{...a,type:"error"};throw u(l,{...g,duration:g.duration||4e3}),setTimeout(()=>p(l),g.duration||4e3),i}},clear:()=>f.length=0,config:t=>Object.assign(k,t)});return{toasts:f,config:y,addToast:n,removeToast:p,destroyToast:s,clearToasts:d,updateToast:u,toast:h}}const x=T(),L=x.toast,S={class:"sileo-root-wrapper"},b=e.defineComponent({__name:"ToastContainer",setup(n){const{toasts:p,removeToast:s,destroyToast:d}=T(),u=["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"],y=t=>p.filter(o=>o.position===t),h=t=>{const o=t.startsWith("top"),l=t.endsWith("left"),i=t.endsWith("center");return{position:"absolute",top:o?"0":"auto",bottom:o?"auto":"0",left:l?"0":i?"50%":"auto",right:!l&&!i?"0":"auto",transform:i?"translateX(-50%)":"none",padding:"24px",display:"flex",pointerEvents:"none",boxSizing:"border-box",alignItems:l?"flex-start":i?"center":"flex-end",flexDirection:o?"column":"column-reverse"}};return(t,o)=>{const l=e.resolveComponent("ToastItem");return e.openBlock(),e.createElementBlock("div",S,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(u,i=>e.createElementVNode("div",{key:i,class:e.normalizeClass(["sileo-position-container",[`sileo-pos-${i}`]]),style:e.normalizeStyle(h(i))},[e.createVNode(e.TransitionGroup,{name:"sileo-list",tag:"div",class:"sileo-stack"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y(i),a=>(e.openBlock(),e.createBlock(l,{key:a.id,toast:a,onClose:g=>e.unref(s)(a.id),onDestroy:g=>e.unref(d)(a.id)},null,8,["toast","onClose","onDestroy"]))),128))]),_:2},1024)],6)),64))])}}}),D={install(n,p={}){if(Object.keys(p).length>0&&x.toast.config(p),typeof document<"u"){const s="sileo-toast-container";let d=document.getElementById(s);d||(d=document.createElement("div"),d.id=s,document.body.appendChild(d),e.createApp({render:()=>e.h(b)}).mount(d))}n.config.globalProperties.$toast=x.toast,n.provide("toast",x.toast)}},$={class:"sileo-header-pill"},M={key:0,class:"sileo-sweep-left"},O={key:1,class:"sileo-sweep-right"},z={class:"sileo-icon-wrapper"},I={key:1,class:"sileo-emoji"},X={key:2,class:"sileo-default-icon"},j={key:0,class:"sileo-spin",viewBox:"0 0 50 50"},P={key:1,class:"sileo-icon-circle bg-success"},A={key:2,class:"sileo-icon-circle bg-error"},R={key:3,class:"sileo-icon-circle bg-warning"},W={key:4,class:"sileo-icon-circle bg-info"},_={key:0,class:"sileo-main-body-animator"},F={class:"sileo-main-wrapper"},q={class:"sileo-main-body"},G={class:"sileo-body-content"},U={key:0,class:"sileo-message"},H=e.defineComponent({__name:"Toast",props:{toast:{}},emits:["close","destroy"],setup(n,{emit:p}){const s=n,d=p,u=e.ref(null),y=e.ref(!1),h=e.ref(0),t=e.ref(0),o=e.ref(!1),l=e.computed(()=>s.toast.title?s.toast.title:!s.toast.title&&s.toast.message&&!s.toast.action?s.toast.message:null),i=e.computed(()=>s.toast.title&&s.toast.message||!s.toast.title&&s.toast.message&&s.toast.action?s.toast.message:null),a=e.computed(()=>!!i.value||!!s.toast.action);e.onMounted(()=>{a.value&&setTimeout(()=>{o.value=!0},500)}),e.watch(a,(r,c)=>{r===!0&&c===!1&&(o.value=!0)}),e.watch(()=>s.toast.closing,r=>{r&&(a.value&&o.value?(o.value=!1,setTimeout(()=>{d("destroy")},1e3)):d("destroy"))});const g=e.computed(()=>s.toast.icon),J=e.computed(()=>s.toast.duration===0&&(s.toast.type==="default"||!s.toast.type)),B=e.computed(()=>{const r=s.toast.position||"top-right";return r.includes("center")?"center":r.includes("left")?"left":"right"}),K=e.computed(()=>(s.toast.position||"top-right").includes("top")),Q=e.computed(()=>{const r=t.value,c=Math.max(0,1-Math.abs(r)/300),V=y.value?.95:1,Y=B.value==="center"?"center":B.value==="left"?"flex-start":"flex-end";return{transform:`translateX(${r}px) scale(${V})`,opacity:c,transition:y.value?"none":"opacity 0.4s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1)",display:"flex",flexDirection:"column",alignItems:Y,width:"100%",pointerEvents:"auto",marginBottom:"16px","--sileo-y-dir":K.value?"-50px":"50px"}}),N=r=>{s.toast.swipeToDismiss&&(y.value=!0,h.value="touches"in r?r.touches[0].clientX:r.clientX,"touches"in r?(window.addEventListener("touchmove",E),window.addEventListener("touchend",w)):(window.addEventListener("mousemove",E),window.addEventListener("mouseup",w)))},E=r=>{if(!y.value)return;const c="touches"in r?r.touches[0].clientX:r.clientX;t.value=(c-h.value)*.8},w=()=>{y.value&&(y.value=!1,Math.abs(t.value)>100?d("close"):t.value=0,window.removeEventListener("mousemove",E),window.removeEventListener("mouseup",w),window.removeEventListener("touchmove",E),window.removeEventListener("touchend",w))};return e.onUnmounted(()=>{window.removeEventListener("mousemove",E),window.removeEventListener("mouseup",w),window.removeEventListener("touchmove",E),window.removeEventListener("touchend",w)}),(r,c)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"toastRef",ref:u,class:e.normalizeClass(["sileo-toast-outer",[`sileo-type-${n.toast.type||"default"}`,`sileo-align-${B.value}`,n.toast.theme==="light"?"sileo-theme-light":"",n.toast.theme==="dark"?"sileo-theme-dark":"",{"sileo-is-dragging":y.value}]]),style:e.normalizeStyle(Q.value),onMousedown:N,onTouchstart:N},[e.createElementVNode("div",{class:e.normalizeClass(["sileo-combined-shape",{"is-expanded":o.value}])},[e.createElementVNode("div",$,[B.value!=="left"?(e.openBlock(),e.createElementBlock("div",M)):e.createCommentVNode("",!0),B.value!=="right"?(e.openBlock(),e.createElementBlock("div",O)):e.createCommentVNode("",!0),e.createElementVNode("div",z,[typeof n.toast.icon!="string"&&n.toast.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(g.value),{key:0,class:"sileo-custom-icon"})):typeof n.toast.icon=="string"?(e.openBlock(),e.createElementBlock("span",I,e.toDisplayString(n.toast.icon),1)):(e.openBlock(),e.createElementBlock("div",X,[J.value?(e.openBlock(),e.createElementBlock("svg",j,[...c[2]||(c[2]=[e.createElementVNode("circle",{cx:"25",cy:"25",r:"20",fill:"none",stroke:"currentColor","stroke-width":"5"},null,-1)])])):n.toast.type==="success"?(e.openBlock(),e.createElementBlock("div",P,[...c[3]||(c[3]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",class:"sileo-stroke-icon"},[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"})],-1)])])):n.toast.type==="error"?(e.openBlock(),e.createElementBlock("div",A,[...c[4]||(c[4]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",class:"sileo-stroke-icon"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])])):n.toast.type==="warning"?(e.openBlock(),e.createElementBlock("div",R,[...c[5]||(c[5]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",class:"sileo-stroke-icon"},[e.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"}),e.createElementVNode("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.createElementVNode("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})],-1)])])):(e.openBlock(),e.createElementBlock("div",W,[...c[6]||(c[6]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",class:"sileo-stroke-icon"},[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"}),e.createElementVNode("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.createElementVNode("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})],-1)])]))]))]),l.value?(e.openBlock(),e.createElementBlock("span",{key:2,class:e.normalizeClass(["sileo-title-text",`text-${n.toast.type||"default"}`])},e.toDisplayString(l.value),3)):e.createCommentVNode("",!0),n.toast.closeOnClick?(e.openBlock(),e.createElementBlock("button",{key:3,class:"sileo-close-btn",onClick:c[0]||(c[0]=e.withModifiers(V=>r.$emit("close"),["stop"]))},[...c[7]||(c[7]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])])):e.createCommentVNode("",!0)]),a.value?(e.openBlock(),e.createElementBlock("div",_,[e.createElementVNode("div",F,[e.createElementVNode("div",q,[e.createElementVNode("div",G,[i.value?(e.openBlock(),e.createElementBlock("p",U,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0),n.toast.action?(e.openBlock(),e.createElementBlock("button",{key:1,class:"sileo-action-trigger",onClick:c[1]||(c[1]=e.withModifiers(V=>n.toast.action.onClick(n.toast.id),["stop"]))},e.toDisplayString(n.toast.action.label),1)):e.createCommentVNode("",!0)])])])])):e.createCommentVNode("",!0)],2)],38))}});m.SileoPlugin=D,m.Toast=H,m.ToastContainer=b,m.toast=L,m.toastManager=x,m.useToast=T,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(m,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(m=typeof globalThis<"u"?globalThis:m||self,e(m.SileoVue={},m.Vue))})(this,function(m,e){"use strict";const f=e.reactive([]),k=e.reactive({position:"top-right",duration:6e3,maxToasts:5}),S=()=>Math.random().toString(36).substring(2,9);function V(){const n=t=>{const o={type:"default",duration:k.duration||6e3,position:k.position||"top-right",showProgress:!0,closeOnClick:!0,swipeToDismiss:!0,theme:k.theme},a=typeof t=="string"?{message:t}:t;f.length>=(k.maxToasts||5)&&f.shift();const i=S(),l={message:"",...o,...a,id:i,createdAt:Date.now(),closing:!1};return l.icon&&typeof l.icon!="string"&&(l.icon=e.markRaw(l.icon)),f.push(l),l.duration&&l.duration>0&&setTimeout(()=>{y(i)},l.duration),i},y=t=>{const o=f.find(a=>a.id===t);o&&(o.closing=!0)},s=t=>{const o=f.findIndex(a=>a.id===t);o>-1&&f.splice(o,1)},d=()=>{f.forEach(t=>t.closing=!0)},u=(t,o)=>{const a=f.findIndex(i=>i.id===t);if(a!==-1){const i={...f[a],...o};typeof o.icon<"u"&&o.icon&&typeof o.icon!="string"&&(i.icon=e.markRaw(o.icon)),f[a]=i}},p=t=>Object.assign(k,t),h=Object.assign(n,{success:t=>n(typeof t=="string"?{message:t,type:"success"}:{...t,type:"success"}),error:t=>n(typeof t=="string"?{message:t,type:"error"}:{...t,type:"error"}),warning:t=>n(typeof t=="string"?{message:t,type:"warning"}:{...t,type:"warning"}),info:t=>n(typeof t=="string"?{message:t,type:"info"}:{...t,type:"info"}),promise:async(t,o)=>{const a=n(typeof o.loading=="string"?{message:o.loading,type:"default",duration:0}:{...o.loading,type:"default",duration:0});try{const i=await t,l=typeof o.success=="function"?o.success(i):o.success,g=typeof l=="string"?{message:l,type:"success"}:{...l,type:"success"};return u(a,{...g,duration:g.duration||4e3}),setTimeout(()=>y(a),g.duration||4e3),i}catch(i){const l=typeof o.error=="function"?o.error(i):o.error,g=typeof l=="string"?{message:l,type:"error"}:{...l,type:"error"};throw u(a,{...g,duration:g.duration||4e3}),setTimeout(()=>y(a),g.duration||4e3),i}},clear:()=>f.length=0,config:t=>Object.assign(k,t)});return{toasts:f,config:p,addToast:n,removeToast:y,destroyToast:s,clearToasts:d,updateToast:u,toast:h}}const x=V(),D=x.toast,$={class:"sileo-header-pill"},M={key:0,class:"sileo-sweep-left"},O={key:1,class:"sileo-sweep-right"},z={class:"sileo-icon-wrapper"},X={key:1,class:"sileo-emoji"},j={key:2,class:"sileo-default-icon"},I={key:0,class:"sileo-spin",viewBox:"0 0 50 50"},P={key:1,class:"sileo-icon-circle bg-success"},A={key:2,class:"sileo-icon-circle bg-error"},R={key:3,class:"sileo-icon-circle bg-warning"},W={key:4,class:"sileo-icon-circle bg-info"},F={key:0,class:"sileo-main-body-animator"},q={class:"sileo-main-wrapper"},G={class:"sileo-main-body"},U={key:0,class:"sileo-message"},T=e.defineComponent({__name:"Toast",props:{toast:{}},emits:["close","destroy"],setup(n,{emit:y}){const s=n,d=y,u=e.ref(null),p=e.ref(!1),h=e.ref(0),t=e.ref(0),o=e.ref(!1),a=e.computed(()=>s.toast.title?s.toast.title:!s.toast.title&&s.toast.message&&!s.toast.action?s.toast.message:null),i=e.computed(()=>s.toast.title&&s.toast.message||!s.toast.title&&s.toast.message&&s.toast.action?s.toast.message:null),l=e.computed(()=>!!i.value||!!s.toast.action);e.onMounted(()=>{l.value&&setTimeout(()=>{o.value=!0},500)}),e.watch(l,(c,r)=>{c===!0&&r===!1&&(o.value=!0)}),e.watch(()=>s.toast.closing,c=>{c===!0&&(l.value&&o.value?(o.value=!1,setTimeout(()=>{d("destroy")},700)):d("destroy"))},{immediate:!0});const g=e.computed(()=>s.toast.icon),K=e.computed(()=>s.toast.duration===0&&(s.toast.type==="default"||!s.toast.type)),B=e.computed(()=>{const c=s.toast.position||"top-right";return c.includes("center")?"center":c.includes("left")?"left":"right"}),Q=e.computed(()=>(s.toast.position||"top-right").includes("top")),Y=e.computed(()=>{const c=t.value,r=Math.max(0,1-Math.abs(c)/300),b=p.value?.95:1,N=B.value==="center"?"center":B.value==="left"?"flex-start":"flex-end";return{transform:`translateX(${c}px) scale(${b})`,opacity:r,transition:p.value?"none":"opacity 0.4s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1)",display:"flex",flexDirection:"column",alignItems:N,width:"100%",pointerEvents:"auto",marginBottom:"16px","--sileo-y-dir":Q.value?"-50px":"50px"}}),L=c=>{s.toast.swipeToDismiss&&(p.value=!0,h.value="touches"in c?c.touches[0].clientX:c.clientX,"touches"in c?(window.addEventListener("touchmove",E),window.addEventListener("touchend",w)):(window.addEventListener("mousemove",E),window.addEventListener("mouseup",w)))},E=c=>{if(!p.value)return;const r="touches"in c?c.touches[0].clientX:c.clientX;t.value=(r-h.value)*.8},w=()=>{p.value&&(p.value=!1,Math.abs(t.value)>100?d("close"):t.value=0,window.removeEventListener("mousemove",E),window.removeEventListener("mouseup",w),window.removeEventListener("touchmove",E),window.removeEventListener("touchend",w))};return e.onUnmounted(()=>{window.removeEventListener("mousemove",E),window.removeEventListener("mouseup",w),window.removeEventListener("touchmove",E),window.removeEventListener("touchend",w)}),(c,r)=>{var b;return e.openBlock(),e.createElementBlock("div",{ref_key:"toastRef",ref:u,class:e.normalizeClass(["sileo-toast-outer",[`sileo-type-${n.toast.type||"default"}`,`sileo-align-${B.value}`,n.toast.theme==="light"?"sileo-theme-light":"",n.toast.theme==="dark"?"sileo-theme-dark":"",{"sileo-is-dragging":p.value}]]),style:e.normalizeStyle(Y.value),onMousedown:L,onTouchstart:L},[e.createElementVNode("div",{class:e.normalizeClass(["sileo-combined-shape",{"is-expanded":o.value}])},[e.createElementVNode("div",$,[B.value!=="left"?(e.openBlock(),e.createElementBlock("div",M)):e.createCommentVNode("",!0),B.value!=="right"?(e.openBlock(),e.createElementBlock("div",O)):e.createCommentVNode("",!0),e.createElementVNode("div",z,[typeof n.toast.icon!="string"&&n.toast.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(g.value),{key:0,class:"sileo-custom-icon"})):typeof n.toast.icon=="string"?(e.openBlock(),e.createElementBlock("span",X,e.toDisplayString(n.toast.icon),1)):(e.openBlock(),e.createElementBlock("div",j,[K.value?(e.openBlock(),e.createElementBlock("svg",I,[...r[2]||(r[2]=[e.createElementVNode("circle",{cx:"25",cy:"25",r:"20",fill:"none",stroke:"currentColor","stroke-width":"5"},null,-1)])])):n.toast.type==="success"?(e.openBlock(),e.createElementBlock("div",P,[...r[3]||(r[3]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",class:"sileo-stroke-icon"},[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"})],-1)])])):n.toast.type==="error"?(e.openBlock(),e.createElementBlock("div",A,[...r[4]||(r[4]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",class:"sileo-stroke-icon"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])])):n.toast.type==="warning"?(e.openBlock(),e.createElementBlock("div",R,[...r[5]||(r[5]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",class:"sileo-stroke-icon"},[e.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"}),e.createElementVNode("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.createElementVNode("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})],-1)])])):(e.openBlock(),e.createElementBlock("div",W,[...r[6]||(r[6]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",class:"sileo-stroke-icon"},[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"}),e.createElementVNode("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.createElementVNode("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})],-1)])]))]))]),a.value?(e.openBlock(),e.createElementBlock("span",{key:2,class:e.normalizeClass(["sileo-title-text",`text-${n.toast.type||"default"}`])},e.toDisplayString(a.value),3)):e.createCommentVNode("",!0),n.toast.closeOnClick?(e.openBlock(),e.createElementBlock("button",{key:3,class:"sileo-close-btn",onClick:r[0]||(r[0]=e.withModifiers(N=>c.$emit("close"),["stop"]))},[...r[7]||(r[7]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])])):e.createCommentVNode("",!0)]),l.value?(e.openBlock(),e.createElementBlock("div",F,[e.createElementVNode("div",q,[e.createElementVNode("div",G,[e.createElementVNode("div",{class:"sileo-body-content",style:e.normalizeStyle({flexDirection:((b=n.toast.action)==null?void 0:b.position)==="left"?"row-reverse":"row"})},[i.value?(e.openBlock(),e.createElementBlock("p",U,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0),n.toast.action?(e.openBlock(),e.createElementBlock("button",{key:1,class:"sileo-action-trigger",style:e.normalizeStyle({background:n.toast.action.color}),onClick:r[1]||(r[1]=e.withModifiers(N=>n.toast.action.onClick(n.toast.id),["stop"]))},e.toDisplayString(n.toast.action.label),5)):e.createCommentVNode("",!0)],4)])])])):e.createCommentVNode("",!0)],2)],38)}}}),H={class:"sileo-root-wrapper"},C=e.defineComponent({__name:"ToastContainer",setup(n){const{toasts:y,removeToast:s,destroyToast:d}=V(),u=["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"],p=t=>y.filter(o=>o.position===t),h=t=>{const o=t.startsWith("top"),a=t.endsWith("left"),i=t.endsWith("center");return{position:"absolute",top:o?"0":"auto",bottom:o?"auto":"0",left:a?"0":i?"50%":"auto",right:!a&&!i?"0":"auto",transform:i?"translateX(-50%)":"none",padding:"24px",display:"flex",pointerEvents:"none",boxSizing:"border-box",alignItems:a?"flex-start":i?"center":"flex-end",flexDirection:o?"column":"column-reverse"}};return(t,o)=>(e.openBlock(),e.createElementBlock("div",H,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(u,a=>e.createElementVNode("div",{key:a,class:e.normalizeClass(["sileo-position-container",[`sileo-pos-${a}`]]),style:e.normalizeStyle(h(a))},[e.createVNode(e.TransitionGroup,{name:"sileo-list",tag:"div",class:"sileo-stack"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p(a),i=>(e.openBlock(),e.createBlock(T,{key:i.id,toast:i,onClose:l=>e.unref(s)(i.id),onDestroy:l=>e.unref(d)(i.id)},null,8,["toast","onClose","onDestroy"]))),128))]),_:2},1024)],6)),64))]))}}),J={install(n,y={}){if(Object.keys(y).length>0&&x.toast.config(y),typeof document<"u"){const s="sileo-toast-container";let d=document.getElementById(s);d||(d=document.createElement("div"),d.id=s,document.body.appendChild(d),e.createApp({render:()=>e.h(C)}).mount(d))}n.config.globalProperties.$toast=x.toast,n.provide("toast",x.toast)}};m.SileoPlugin=J,m.Toast=T,m.ToastContainer=C,m.toast=D,m.toastManager=x,m.useToast=V,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.sileo-
|
|
1
|
+
.sileo-toast-outer{--sileo-bg: #ffffff;--sileo-text-primary: #000000;--sileo-text-secondary: rgba(0, 0, 0, .65);--sileo-border: rgba(0, 0, 0, .08);--sileo-btn-bg: #1c1c1e;--sileo-btn-text: #ffffff;--sileo-timer-bg: rgba(0, 0, 0, .1);--sileo-close-color: rgba(0, 0, 0, .3);--sileo-close-hover: rgba(0, 0, 0, .7);position:relative!important;width:400px!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}@media (prefers-color-scheme: dark){.sileo-toast-outer:not(.sileo-theme-light){--sileo-bg: #1c1c1e;--sileo-text-primary: #ffffff;--sileo-text-secondary: rgba(255, 255, 255, .65);--sileo-border: rgba(255, 255, 255, .15);--sileo-btn-bg: #ffffff;--sileo-btn-text: #000000;--sileo-timer-bg: rgba(255, 255, 255, .15);--sileo-close-color: rgba(255, 255, 255, .3);--sileo-close-hover: rgba(255, 255, 255, .7)}}.sileo-toast-outer.sileo-theme-dark{--sileo-bg: #1c1c1e;--sileo-text-primary: #ffffff;--sileo-text-secondary: rgba(255, 255, 255, .65);--sileo-border: rgba(255, 255, 255, .15);--sileo-btn-bg: #ffffff;--sileo-btn-text: #000000;--sileo-timer-bg: rgba(255, 255, 255, .15);--sileo-close-color: rgba(255, 255, 255, .3);--sileo-close-hover: rgba(255, 255, 255, .7)}.sileo-combined-shape{display:flex!important;flex-direction:column!important;width:100%!important;filter:drop-shadow(0 0 1px var(--sileo-border))!important}.sileo-header-pill{display:flex!important;align-items:center!important;gap:8px!important;background:var(--sileo-bg)!important;padding:8px 16px 8px 14px!important;height:40px!important;border-radius:24px!important;transition:border-radius .5s cubic-bezier(.34,1.56,.64,1)!important;color:var(--sileo-text-primary)!important;box-sizing:border-box!important;width:fit-content!important;position:relative!important;z-index:2!important;margin-bottom:-1px!important}.sileo-align-center .sileo-header-pill{align-self:center!important}.sileo-align-left .sileo-header-pill{align-self:flex-start!important;margin-left:0!important}.sileo-align-right .sileo-header-pill{align-self:flex-end!important;margin-right:0!important}.sileo-combined-shape.is-expanded .sileo-header-pill{border-radius:24px 24px 0 0!important}.sileo-sweep-left,.sileo-sweep-right{position:absolute!important;bottom:0!important;width:24px!important;height:24px!important;z-index:-1!important;background:var(--sileo-bg)!important;pointer-events:none!important;opacity:0!important;transform:scaleY(0)!important;transform-origin:top!important;transition:opacity .3s ease,transform .5s cubic-bezier(.34,1.56,.64,1)!important}.sileo-combined-shape.is-expanded .sileo-sweep-left,.sileo-combined-shape.is-expanded .sileo-sweep-right{opacity:1!important;transform:scaleY(1)!important}.sileo-sweep-left{left:-24px!important;clip-path:path("M24 0 C24 13.255 13.255 24 0 24 L24 24 Z")!important}.sileo-sweep-right{right:-24px!important;clip-path:path("M0 0 C0 13.255 10.745 24 24 24 L0 24 Z")!important}.sileo-icon-wrapper{width:22px!important;height:22px!important;display:flex!important;align-items:center!important;justify-content:center!important;flex-shrink:0!important}.sileo-custom-icon{width:18px!important;height:18px!important;display:block!important}.sileo-emoji{font-size:16px!important;line-height:1!important}.sileo-default-icon{width:22px!important;height:22px!important;display:flex!important;align-items:center!important;justify-content:center!important}.sileo-icon-circle{width:22px!important;height:22px!important;border-radius:50%!important;display:flex!important;align-items:center!important;justify-content:center!important;background:#8080801a!important}.bg-success{background:#32d74b26!important;color:#32d74b!important}.bg-error{background:#ff453a26!important;color:#ff453a!important}.bg-warning{background:#ffd60a26!important;color:#ffd60a!important}.bg-info{background:#0a84ff26!important;color:#0a84ff!important}.sileo-stroke-icon{width:13px!important;height:13px!important;stroke:currentColor!important;stroke-width:3!important}.sileo-title-text{font-size:14.5px!important;font-weight:600!important;line-height:1!important;white-space:nowrap!important;letter-spacing:.2px!important}.text-success{color:#32d74b!important}.text-error{color:#ff453a!important}.text-warning{color:#ffd60a!important}.text-info{color:#0a84ff!important}.text-default{color:var(--sileo-text-primary)!important}.sileo-close-btn{background:none!important;border:none!important;padding:2px!important;cursor:pointer!important;color:var(--sileo-close-color)!important;display:flex!important;align-items:center!important;margin-left:2px!important;transition:color .2s!important}.sileo-close-btn svg{width:14px!important;height:14px!important;stroke:currentColor!important;stroke-width:2.5!important}.sileo-close-btn:hover{color:var(--sileo-close-hover)!important}.sileo-main-body-animator{display:grid!important;grid-template-rows:0fr!important;opacity:0!important;transition:grid-template-rows .5s cubic-bezier(.34,1.56,.64,1),opacity .4s ease!important}.sileo-combined-shape.is-expanded .sileo-main-body-animator{grid-template-rows:1fr!important;opacity:1!important}.sileo-main-wrapper{overflow:hidden!important}.sileo-main-body{background:var(--sileo-bg)!important;padding:18px 24px!important;border-radius:24px!important;width:100%!important;box-sizing:border-box!important;position:relative!important;z-index:1!important}.sileo-align-left .sileo-main-body{border-top-left-radius:0!important}.sileo-align-right .sileo-main-body{border-top-right-radius:0!important}.sileo-body-content{display:flex!important;align-items:center!important;justify-content:space-between!important;gap:16px!important}.sileo-message{margin:0!important;font-size:15.5px!important;line-height:1.5!important;color:var(--sileo-text-secondary)!important;font-weight:400!important;letter-spacing:.1px!important}.sileo-action-trigger{background:var(--sileo-btn-bg)!important;color:var(--sileo-btn-text)!important;border:none!important;border-radius:14px!important;padding:10px 18px!important;font-size:13.5px!important;font-weight:600!important;cursor:pointer!important;white-space:nowrap!important;flex-shrink:0!important;transition:transform .2s,background .2s!important}.sileo-action-trigger:hover{transform:scale(1.03)!important}@keyframes sileo-spin{to{transform:rotate(360deg)}}.sileo-spin{animation:sileo-spin 1.5s linear infinite!important;width:20px!important;height:20px!important}.sileo-spin circle{stroke:currentColor!important;stroke-linecap:round!important;animation:sileo-dash-pulse 1.5s ease-in-out infinite!important}@keyframes sileo-dash-pulse{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-list-enter-active{transition:opacity .5s ease,transform .6s cubic-bezier(.34,1.56,.64,1)!important}.sileo-list-leave-active{transition:opacity .3s ease,transform .5s cubic-bezier(.4,0,1,1)!important}.sileo-list-enter-from{opacity:0!important;transform:translateY(var(--sileo-y-dir, -50px)) scale(.85)!important}.sileo-list-leave-to{opacity:0!important;transform:scale(.85)!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 .5s cubic-bezier(.34,1.56,.64,1)!important}
|
package/dist/types/index.d.ts
CHANGED