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