@edgar208/sileo-vue 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composables/useToast.d.ts +20 -0
- package/dist/sileo-vue.js +17 -16
- package/dist/sileo-vue.umd.cjs +1 -1
- package/package.json +1 -1
|
@@ -51,3 +51,23 @@ export declare const toastManager: {
|
|
|
51
51
|
destroyToast: (id: string) => void;
|
|
52
52
|
updateToast: (id: string, options: Partial<ToastOptions>) => void;
|
|
53
53
|
};
|
|
54
|
+
export declare const toast: ((options: ToastOptions | string) => string) & {
|
|
55
|
+
success: (msg: string | ToastOptions) => string;
|
|
56
|
+
error: (msg: string | ToastOptions) => string;
|
|
57
|
+
warning: (msg: string | ToastOptions) => string;
|
|
58
|
+
info: (msg: string | ToastOptions) => string;
|
|
59
|
+
promise: <T>(promise: Promise<T>, options: {
|
|
60
|
+
loading: string | ToastOptions;
|
|
61
|
+
success: string | ((data: T) => string | ToastOptions);
|
|
62
|
+
error: string | ((err: any) => string | ToastOptions);
|
|
63
|
+
}) => Promise<T>;
|
|
64
|
+
clear: () => 0;
|
|
65
|
+
config: (newConfig: GlobalConfig) => {
|
|
66
|
+
position?: import("../types").ToastPosition | undefined;
|
|
67
|
+
duration?: number | undefined;
|
|
68
|
+
maxToasts?: number | undefined;
|
|
69
|
+
swipeToDismiss?: boolean | undefined;
|
|
70
|
+
closeOnClick?: boolean | undefined;
|
|
71
|
+
theme?: "light" | "dark" | "system" | undefined;
|
|
72
|
+
} & GlobalConfig;
|
|
73
|
+
};
|
package/dist/sileo-vue.js
CHANGED
|
@@ -64,7 +64,7 @@ function V() {
|
|
|
64
64
|
updateToast: y
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
const
|
|
67
|
+
const $ = V(), kt = $.toast, ot = { class: "sileo-root-wrapper" }, st = /* @__PURE__ */ P({
|
|
68
68
|
__name: "ToastContainer",
|
|
69
69
|
setup(o) {
|
|
70
70
|
const { toasts: m, removeToast: e, destroyToast: y } = V(), x = [
|
|
@@ -108,8 +108,8 @@ const D = V(), ot = { class: "sileo-root-wrapper" }, st = /* @__PURE__ */ P({
|
|
|
108
108
|
(d(!0), f(I, null, S(t(c), (g) => (d(), R(a, {
|
|
109
109
|
key: g.id,
|
|
110
110
|
toast: g,
|
|
111
|
-
onClose: (
|
|
112
|
-
onDestroy: (
|
|
111
|
+
onClose: (B) => X(e)(g.id),
|
|
112
|
+
onDestroy: (B) => X(y)(g.id)
|
|
113
113
|
}, null, 8, ["toast", "onClose", "onDestroy"]))), 128))
|
|
114
114
|
]),
|
|
115
115
|
_: 2
|
|
@@ -118,16 +118,16 @@ const D = V(), ot = { class: "sileo-root-wrapper" }, st = /* @__PURE__ */ P({
|
|
|
118
118
|
]);
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
|
-
}),
|
|
121
|
+
}), bt = {
|
|
122
122
|
install(o, m = {}) {
|
|
123
|
-
if (Object.keys(m).length > 0 &&
|
|
123
|
+
if (Object.keys(m).length > 0 && $.toast.config(m), typeof document < "u") {
|
|
124
124
|
const e = "sileo-toast-container";
|
|
125
125
|
let y = document.getElementById(e);
|
|
126
126
|
y || (y = document.createElement("div"), y.id = e, document.body.appendChild(y), K({
|
|
127
127
|
render: () => Q(st)
|
|
128
128
|
}).mount(y));
|
|
129
129
|
}
|
|
130
|
-
o.config.globalProperties.$toast =
|
|
130
|
+
o.config.globalProperties.$toast = $.toast, o.provide("toast", $.toast);
|
|
131
131
|
}
|
|
132
132
|
}, nt = { class: "sileo-header-pill" }, it = {
|
|
133
133
|
key: 0,
|
|
@@ -163,7 +163,7 @@ const D = V(), ot = { class: "sileo-root-wrapper" }, st = /* @__PURE__ */ P({
|
|
|
163
163
|
}, gt = { class: "sileo-main-wrapper" }, pt = { class: "sileo-main-body" }, ht = { class: "sileo-body-content" }, xt = {
|
|
164
164
|
key: 0,
|
|
165
165
|
class: "sileo-message"
|
|
166
|
-
},
|
|
166
|
+
}, Tt = /* @__PURE__ */ P({
|
|
167
167
|
__name: "Toast",
|
|
168
168
|
props: {
|
|
169
169
|
toast: {}
|
|
@@ -182,13 +182,13 @@ const D = V(), ot = { class: "sileo-root-wrapper" }, st = /* @__PURE__ */ P({
|
|
|
182
182
|
y("destroy");
|
|
183
183
|
}, 1e3)) : y("destroy"));
|
|
184
184
|
});
|
|
185
|
-
const
|
|
185
|
+
const B = p(() => e.toast.icon), W = p(() => e.toast.duration === 0 && (e.toast.type === "default" || !e.toast.type)), b = p(() => {
|
|
186
186
|
const u = e.toast.position || "top-right";
|
|
187
187
|
return u.includes("center") ? "center" : u.includes("left") ? "left" : "right";
|
|
188
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),
|
|
189
|
+
const u = i.value, l = Math.max(0, 1 - Math.abs(u) / 300), D = t.value ? 0.95 : 1, G = b.value === "center" ? "center" : b.value === "left" ? "flex-start" : "flex-end";
|
|
190
190
|
return {
|
|
191
|
-
transform: `translateX(${u}px) scale(${
|
|
191
|
+
transform: `translateX(${u}px) scale(${D})`,
|
|
192
192
|
opacity: l,
|
|
193
193
|
transition: t.value ? "none" : "opacity 0.4s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1)",
|
|
194
194
|
display: "flex",
|
|
@@ -231,7 +231,7 @@ const D = V(), ot = { class: "sileo-root-wrapper" }, st = /* @__PURE__ */ P({
|
|
|
231
231
|
b.value !== "left" ? (d(), f("div", it)) : h("", !0),
|
|
232
232
|
b.value !== "right" ? (d(), f("div", at)) : h("", !0),
|
|
233
233
|
r("div", rt, [
|
|
234
|
-
typeof o.toast.icon != "string" && o.toast.icon ? (d(), R(tt(
|
|
234
|
+
typeof o.toast.icon != "string" && o.toast.icon ? (d(), R(tt(B.value), {
|
|
235
235
|
key: 0,
|
|
236
236
|
class: "sileo-custom-icon"
|
|
237
237
|
})) : typeof o.toast.icon == "string" ? (d(), f("span", lt, E(o.toast.icon), 1)) : (d(), f("div", ct, [
|
|
@@ -325,7 +325,7 @@ const D = V(), ot = { class: "sileo-root-wrapper" }, st = /* @__PURE__ */ P({
|
|
|
325
325
|
o.toast.closeOnClick ? (d(), f("button", {
|
|
326
326
|
key: 3,
|
|
327
327
|
class: "sileo-close-btn",
|
|
328
|
-
onClick: l[0] || (l[0] = A((
|
|
328
|
+
onClick: l[0] || (l[0] = A((D) => u.$emit("close"), ["stop"]))
|
|
329
329
|
}, [...l[7] || (l[7] = [
|
|
330
330
|
r("svg", {
|
|
331
331
|
viewBox: "0 0 24 24",
|
|
@@ -354,7 +354,7 @@ const D = V(), ot = { class: "sileo-root-wrapper" }, st = /* @__PURE__ */ P({
|
|
|
354
354
|
o.toast.action ? (d(), f("button", {
|
|
355
355
|
key: 1,
|
|
356
356
|
class: "sileo-action-trigger",
|
|
357
|
-
onClick: l[1] || (l[1] = A((
|
|
357
|
+
onClick: l[1] || (l[1] = A((D) => o.toast.action.onClick(o.toast.id), ["stop"]))
|
|
358
358
|
}, E(o.toast.action.label), 1)) : h("", !0)
|
|
359
359
|
])
|
|
360
360
|
])
|
|
@@ -365,9 +365,10 @@ const D = V(), ot = { class: "sileo-root-wrapper" }, st = /* @__PURE__ */ P({
|
|
|
365
365
|
}
|
|
366
366
|
});
|
|
367
367
|
export {
|
|
368
|
-
|
|
369
|
-
|
|
368
|
+
bt as SileoPlugin,
|
|
369
|
+
Tt as Toast,
|
|
370
370
|
st as ToastContainer,
|
|
371
|
-
|
|
371
|
+
kt as toast,
|
|
372
|
+
$ as toastManager,
|
|
372
373
|
V as useToast
|
|
373
374
|
};
|
package/dist/sileo-vue.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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"})});
|
|
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 w=B(),L=w.toast,S={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",S,[(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))])}}}),D={install(n,y={}){if(Object.keys(y).length>0&&w.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=w.toast,n.provide("toast",w.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: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),J=e.computed(()=>o.toast.duration===0&&(o.toast.type==="default"||!o.toast.type)),x=e.computed(()=>{const d=o.toast.position||"top-right";return d.includes("center")?"center":d.includes("left")?"left":"right"}),K=e.computed(()=>(o.toast.position||"top-right").includes("top")),Q=e.computed(()=>{const d=a.value,r=Math.max(0,1-Math.abs(d)/300),T=t.value?.95:1,Y=x.value==="center"?"center":x.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:Y,width:"100%",pointerEvents:"auto",marginBottom:"16px","--sileo-y-dir":K.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-${x.value}`,n.toast.theme==="light"?"sileo-theme-light":"",n.toast.theme==="dark"?"sileo-theme-dark":"",{"sileo-is-dragging":t.value}]]),style:e.normalizeStyle(Q.value),onMousedown:N,onTouchstart:N},[e.createElementVNode("div",{class:e.normalizeClass(["sileo-combined-shape",{"is-expanded":i.value}])},[e.createElementVNode("div",$,[x.value!=="left"?(e.openBlock(),e.createElementBlock("div",M)):e.createCommentVNode("",!0),x.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(V.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,[...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)])]))]))]),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",_,[e.createElementVNode("div",F,[e.createElementVNode("div",q,[e.createElementVNode("div",G,[c.value?(e.openBlock(),e.createElementBlock("p",U,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=D,f.Toast=H,f.ToastContainer=b,f.toast=L,f.toastManager=w,f.useToast=B,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|