@edgar208/sileo-vue 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +106 -0
- package/dist/components/Toast.vue.d.ts +11 -0
- package/dist/components/ToastContainer.vue.d.ts +3 -0
- package/dist/composables/useToast.d.ts +33 -0
- package/dist/index.d.ts +5 -0
- package/dist/plugin/index.d.ts +5 -0
- package/dist/sileo-vue.js +203 -0
- package/dist/sileo-vue.umd.cjs +1 -0
- package/dist/style.css +1 -0
- package/dist/types/index.d.ts +24 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Edgar II, Ramos O.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Sileo-Vue 🍞
|
|
2
|
+
|
|
3
|
+
A premium, production-ready Vue 3 toast notification library inspired by Sileo. Featuring glassmorphism, smooth animations, and a modern iOS-like aesthetic.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🍦 **Vue 3 Support**: Built with the Composition API.
|
|
8
|
+
- ✨ **Premium Design**: Modern glassmorphism (blur + transparency) and detached pill headers.
|
|
9
|
+
- 🎬 **Smooth Animations**: Tailored entrance and exit transitions.
|
|
10
|
+
- 🖐️ **Swipe to Dismiss**: Natural gestures for both mouse and touch.
|
|
11
|
+
- 📦 **NPM Ready**: Bundled with Vite library mode, includes TypeScript types.
|
|
12
|
+
- 🌓 **Dark Mode**: Optimized for dark UI by default.
|
|
13
|
+
- 🛠️ **Configurable**: Global and per-toast options.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install sileo-vue
|
|
19
|
+
# or
|
|
20
|
+
yarn add sileo-vue
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
### 1. Register the Plugin
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { createApp } from 'vue';
|
|
29
|
+
import { SileoPlugin } from 'sileo-vue';
|
|
30
|
+
import 'sileo-vue/style.css'; // Don't forget the styles!
|
|
31
|
+
|
|
32
|
+
const app = createApp(App);
|
|
33
|
+
|
|
34
|
+
app.use(SileoPlugin, {
|
|
35
|
+
position: 'top-right',
|
|
36
|
+
duration: 4000
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
app.mount('#app');
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
### Using the Composable
|
|
45
|
+
|
|
46
|
+
```vue
|
|
47
|
+
<script setup>
|
|
48
|
+
import { useToast } from 'sileo-vue';
|
|
49
|
+
|
|
50
|
+
const { toast } = useToast();
|
|
51
|
+
|
|
52
|
+
const showToast = () => {
|
|
53
|
+
toast.success('Settings saved successfully!');
|
|
54
|
+
};
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<button @click="showToast">Show Toast</button>
|
|
59
|
+
</template>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### API Options
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
toast({
|
|
66
|
+
title: 'Notification',
|
|
67
|
+
message: 'This is a message',
|
|
68
|
+
type: 'info', // 'success' | 'error' | 'warning' | 'info' | 'default'
|
|
69
|
+
duration: 5000,
|
|
70
|
+
position: 'top-center',
|
|
71
|
+
showProgress: true,
|
|
72
|
+
swipeToDismiss: true
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Shorthands
|
|
76
|
+
toast.success('Success message');
|
|
77
|
+
toast.error('Error message');
|
|
78
|
+
toast.warning('Warning message');
|
|
79
|
+
toast.info('Info message');
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Advanced Customization
|
|
83
|
+
|
|
84
|
+
| Option | Type | Default | Description |
|
|
85
|
+
| --- | --- | --- | --- |
|
|
86
|
+
| `title` | `string` | `undefined` | Optional title shown in the detached pill header. |
|
|
87
|
+
| `message` | `string` | `required` | The main content of the toast. |
|
|
88
|
+
| `type` | `string` | `'default'` | Toast variation: `success`, `error`, `warning`, `info`. |
|
|
89
|
+
| `duration` | `number` | `4000` | Auto-dismiss delay in ms. Set to `0` to persist. |
|
|
90
|
+
| `position` | `string` | `'top-right'` | Corner placement. |
|
|
91
|
+
| `showProgress` | `boolean` | `true` | Show/hide the animated progress bar. |
|
|
92
|
+
| `swipeToDismiss`| `boolean` | `true` | Enable swipe gestures to clear toasts. |
|
|
93
|
+
|
|
94
|
+
## Development
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# Install dependencies
|
|
98
|
+
npm install
|
|
99
|
+
|
|
100
|
+
# Build the library
|
|
101
|
+
npm run build
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
MIT
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Toast } from '../types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
toast: Toast;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
close: (...args: any[]) => void;
|
|
7
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
8
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
9
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Toast, ToastOptions, GlobalConfig } from '../types';
|
|
2
|
+
export declare function useToast(): {
|
|
3
|
+
toasts: import("vue").Reactive<Toast[]>;
|
|
4
|
+
toast: ((options: ToastOptions | string) => string) & {
|
|
5
|
+
success: (msg: string | ToastOptions) => string;
|
|
6
|
+
error: (msg: string | ToastOptions) => string;
|
|
7
|
+
warning: (msg: string | ToastOptions) => string;
|
|
8
|
+
info: (msg: string | ToastOptions) => string;
|
|
9
|
+
clear: () => 0;
|
|
10
|
+
config: (newConfig: GlobalConfig) => {
|
|
11
|
+
position?: import("../types").ToastPosition | undefined;
|
|
12
|
+
duration?: number | undefined;
|
|
13
|
+
maxToasts?: number | undefined;
|
|
14
|
+
} & GlobalConfig;
|
|
15
|
+
};
|
|
16
|
+
removeToast: (id: string) => void;
|
|
17
|
+
};
|
|
18
|
+
export declare const toastManager: {
|
|
19
|
+
toasts: import("vue").Reactive<Toast[]>;
|
|
20
|
+
toast: ((options: ToastOptions | string) => string) & {
|
|
21
|
+
success: (msg: string | ToastOptions) => string;
|
|
22
|
+
error: (msg: string | ToastOptions) => string;
|
|
23
|
+
warning: (msg: string | ToastOptions) => string;
|
|
24
|
+
info: (msg: string | ToastOptions) => string;
|
|
25
|
+
clear: () => 0;
|
|
26
|
+
config: (newConfig: GlobalConfig) => {
|
|
27
|
+
position?: import("../types").ToastPosition | undefined;
|
|
28
|
+
duration?: number | undefined;
|
|
29
|
+
maxToasts?: number | undefined;
|
|
30
|
+
} & GlobalConfig;
|
|
31
|
+
};
|
|
32
|
+
removeToast: (id: string) => void;
|
|
33
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { reactive as M, markRaw as I, defineComponent as $, ref as h, computed as T, onUnmounted as S, openBlock as n, createElementBlock as a, normalizeStyle as E, normalizeClass as B, createElementVNode as l, createBlock as D, resolveDynamicComponent as z, toDisplayString as y, createCommentVNode as k, withModifiers as P, Fragment as b, renderList as x, createVNode as A, TransitionGroup as j, withCtx as N, unref as R, createApp as V, h as F } from "vue";
|
|
2
|
+
const m = M([]), w = M({
|
|
3
|
+
position: "top-right",
|
|
4
|
+
duration: 4e3,
|
|
5
|
+
maxToasts: 5
|
|
6
|
+
}), G = () => Math.random().toString(36).substring(2, 9);
|
|
7
|
+
function O() {
|
|
8
|
+
const e = (t) => {
|
|
9
|
+
const u = {
|
|
10
|
+
type: "default",
|
|
11
|
+
duration: w.duration || 4e3,
|
|
12
|
+
position: w.position || "top-right",
|
|
13
|
+
showProgress: !0,
|
|
14
|
+
closeOnClick: !0,
|
|
15
|
+
swipeToDismiss: !0
|
|
16
|
+
}, i = typeof t == "string" ? { message: t } : t;
|
|
17
|
+
m.length >= (w.maxToasts || 5) && m.shift();
|
|
18
|
+
const v = G(), o = {
|
|
19
|
+
...u,
|
|
20
|
+
...i,
|
|
21
|
+
id: v,
|
|
22
|
+
createdAt: Date.now()
|
|
23
|
+
};
|
|
24
|
+
return o.icon && typeof o.icon != "string" && (o.icon = I(o.icon)), m.push(o), o.duration > 0 && setTimeout(() => {
|
|
25
|
+
d(v);
|
|
26
|
+
}, o.duration), v;
|
|
27
|
+
}, d = (t) => {
|
|
28
|
+
const u = m.findIndex((i) => i.id === t);
|
|
29
|
+
u !== -1 && m.splice(u, 1);
|
|
30
|
+
}, r = Object.assign(e, {
|
|
31
|
+
success: (t) => e(typeof t == "string" ? { message: t, type: "success" } : { ...t, type: "success" }),
|
|
32
|
+
error: (t) => e(typeof t == "string" ? { message: t, type: "error" } : { ...t, type: "error" }),
|
|
33
|
+
warning: (t) => e(typeof t == "string" ? { message: t, type: "warning" } : { ...t, type: "warning" }),
|
|
34
|
+
info: (t) => e(typeof t == "string" ? { message: t, type: "info" } : { ...t, type: "info" }),
|
|
35
|
+
clear: () => m.length = 0,
|
|
36
|
+
config: (t) => Object.assign(w, t)
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
toasts: m,
|
|
40
|
+
toast: r,
|
|
41
|
+
removeToast: d
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const _ = O(), U = { class: "sileo-toast__header" }, q = { class: "sileo-toast__icon" }, H = { key: 1 }, J = {
|
|
45
|
+
key: 2,
|
|
46
|
+
class: "sileo-toast__default-icon"
|
|
47
|
+
}, K = {
|
|
48
|
+
key: 0,
|
|
49
|
+
viewBox: "0 0 24 24",
|
|
50
|
+
fill: "none",
|
|
51
|
+
stroke: "currentColor",
|
|
52
|
+
"stroke-width": "2.5"
|
|
53
|
+
}, Q = {
|
|
54
|
+
key: 1,
|
|
55
|
+
viewBox: "0 0 24 24",
|
|
56
|
+
fill: "none",
|
|
57
|
+
stroke: "currentColor",
|
|
58
|
+
"stroke-width": "2.5"
|
|
59
|
+
}, W = {
|
|
60
|
+
key: 2,
|
|
61
|
+
viewBox: "0 0 24 24",
|
|
62
|
+
fill: "none",
|
|
63
|
+
stroke: "currentColor",
|
|
64
|
+
"stroke-width": "2.5"
|
|
65
|
+
}, Y = {
|
|
66
|
+
key: 3,
|
|
67
|
+
viewBox: "0 0 24 24",
|
|
68
|
+
fill: "none",
|
|
69
|
+
stroke: "currentColor",
|
|
70
|
+
"stroke-width": "2.5"
|
|
71
|
+
}, Z = {
|
|
72
|
+
key: 0,
|
|
73
|
+
class: "sileo-toast__title"
|
|
74
|
+
}, tt = { class: "sileo-toast__body" }, et = { class: "sileo-toast__message" }, ot = {
|
|
75
|
+
key: 0,
|
|
76
|
+
class: "sileo-toast__progress"
|
|
77
|
+
}, st = /* @__PURE__ */ $({
|
|
78
|
+
__name: "Toast",
|
|
79
|
+
props: {
|
|
80
|
+
toast: {}
|
|
81
|
+
},
|
|
82
|
+
emits: ["close"],
|
|
83
|
+
setup(e, { emit: d }) {
|
|
84
|
+
const r = e, t = d, u = h(null), i = h(!1), v = h(0), o = h(0), p = T(() => r.toast.icon), C = T(() => {
|
|
85
|
+
const c = `translateX(${o.value}px) scale(${i.value ? 0.98 : 1})`, s = Math.max(0, 1 - Math.abs(o.value) / 200);
|
|
86
|
+
return {
|
|
87
|
+
transform: c,
|
|
88
|
+
opacity: s,
|
|
89
|
+
transition: i.value ? "none" : "all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275)"
|
|
90
|
+
};
|
|
91
|
+
}), L = (c) => {
|
|
92
|
+
r.toast.swipeToDismiss && (i.value = !0, v.value = "touches" in c ? c.touches[0].clientX : c.clientX, "touches" in c ? (window.addEventListener("touchmove", f), window.addEventListener("touchend", g)) : (window.addEventListener("mousemove", f), window.addEventListener("mouseup", g)));
|
|
93
|
+
}, f = (c) => {
|
|
94
|
+
if (!i.value) return;
|
|
95
|
+
const s = "touches" in c ? c.touches[0].clientX : c.clientX;
|
|
96
|
+
o.value = s - v.value;
|
|
97
|
+
}, g = () => {
|
|
98
|
+
i.value && (i.value = !1, Math.abs(o.value) > 100 ? t("close") : o.value = 0, window.removeEventListener("mousemove", f), window.removeEventListener("mouseup", g), window.removeEventListener("touchmove", f), window.removeEventListener("touchend", g));
|
|
99
|
+
};
|
|
100
|
+
return S(() => {
|
|
101
|
+
window.removeEventListener("mousemove", f), window.removeEventListener("mouseup", g), window.removeEventListener("touchmove", f), window.removeEventListener("touchend", g);
|
|
102
|
+
}), (c, s) => (n(), a("div", {
|
|
103
|
+
ref_key: "toastRef",
|
|
104
|
+
ref: u,
|
|
105
|
+
class: B(["sileo-toast", [`sileo-toast--${e.toast.type}`]]),
|
|
106
|
+
style: E(C.value),
|
|
107
|
+
onMousedown: L,
|
|
108
|
+
onTouchstart: L
|
|
109
|
+
}, [
|
|
110
|
+
l("div", U, [
|
|
111
|
+
l("div", q, [
|
|
112
|
+
typeof e.toast.icon != "string" && e.toast.icon ? (n(), D(z(p.value), { key: 0 })) : typeof e.toast.icon == "string" ? (n(), a("span", H, y(e.toast.icon), 1)) : (n(), a("div", J, [
|
|
113
|
+
e.toast.type === "success" ? (n(), a("svg", K, [...s[1] || (s[1] = [
|
|
114
|
+
l("path", { d: "M20 6L9 17L4 12" }, null, -1)
|
|
115
|
+
])])) : e.toast.type === "error" ? (n(), a("svg", Q, [...s[2] || (s[2] = [
|
|
116
|
+
l("path", { d: "M18 6L6 18M6 6l12 12" }, null, -1)
|
|
117
|
+
])])) : e.toast.type === "warning" ? (n(), a("svg", W, [...s[3] || (s[3] = [
|
|
118
|
+
l("path", { d: "M12 9v4m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 17c-.77 1.333.192 3 1.732 3z" }, null, -1)
|
|
119
|
+
])])) : (n(), a("svg", Y, [...s[4] || (s[4] = [
|
|
120
|
+
l("path", { d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }, null, -1)
|
|
121
|
+
])]))
|
|
122
|
+
]))
|
|
123
|
+
]),
|
|
124
|
+
e.toast.title ? (n(), a("span", Z, y(e.toast.title), 1)) : k("", !0),
|
|
125
|
+
e.toast.closeOnClick ? (n(), a("button", {
|
|
126
|
+
key: 1,
|
|
127
|
+
class: "sileo-toast__close",
|
|
128
|
+
onClick: s[0] || (s[0] = P((ct) => c.$emit("close"), ["stop"]))
|
|
129
|
+
}, [...s[5] || (s[5] = [
|
|
130
|
+
l("svg", {
|
|
131
|
+
viewBox: "0 0 24 24",
|
|
132
|
+
fill: "none",
|
|
133
|
+
stroke: "currentColor",
|
|
134
|
+
"stroke-width": "2"
|
|
135
|
+
}, [
|
|
136
|
+
l("path", { d: "M18 6L6 18M6 6l12 12" })
|
|
137
|
+
], -1)
|
|
138
|
+
])])) : k("", !0)
|
|
139
|
+
]),
|
|
140
|
+
l("div", tt, [
|
|
141
|
+
l("p", et, y(e.toast.message), 1)
|
|
142
|
+
]),
|
|
143
|
+
e.toast.duration > 0 && e.toast.showProgress ? (n(), a("div", ot, [
|
|
144
|
+
l("div", {
|
|
145
|
+
class: "sileo-toast__progress-inner",
|
|
146
|
+
style: E({ animationDuration: `${e.toast.duration}ms` })
|
|
147
|
+
}, null, 4)
|
|
148
|
+
])) : k("", !0)
|
|
149
|
+
], 38));
|
|
150
|
+
}
|
|
151
|
+
}), X = (e, d) => {
|
|
152
|
+
const r = e.__vccOpts || e;
|
|
153
|
+
for (const [t, u] of d)
|
|
154
|
+
r[t] = u;
|
|
155
|
+
return r;
|
|
156
|
+
}, nt = /* @__PURE__ */ X(st, [["__scopeId", "data-v-fcd6b8c9"]]), it = { class: "sileo-wrapper" }, at = /* @__PURE__ */ $({
|
|
157
|
+
__name: "ToastContainer",
|
|
158
|
+
setup(e) {
|
|
159
|
+
const { toasts: d, removeToast: r } = O(), t = [
|
|
160
|
+
"top-left",
|
|
161
|
+
"top-center",
|
|
162
|
+
"top-right",
|
|
163
|
+
"bottom-left",
|
|
164
|
+
"bottom-center",
|
|
165
|
+
"bottom-right"
|
|
166
|
+
], u = (i) => d.filter((v) => v.position === i);
|
|
167
|
+
return (i, v) => (n(), a("div", it, [
|
|
168
|
+
(n(), a(b, null, x(t, (o) => l("div", {
|
|
169
|
+
key: o,
|
|
170
|
+
class: B(["sileo-container", [`sileo-container--${o}`]])
|
|
171
|
+
}, [
|
|
172
|
+
A(j, { name: "sileo-list" }, {
|
|
173
|
+
default: N(() => [
|
|
174
|
+
(n(!0), a(b, null, x(u(o), (p) => (n(), D(nt, {
|
|
175
|
+
key: p.id,
|
|
176
|
+
toast: p,
|
|
177
|
+
onClose: (C) => R(r)(p.id)
|
|
178
|
+
}, null, 8, ["toast", "onClose"]))), 128))
|
|
179
|
+
]),
|
|
180
|
+
_: 2
|
|
181
|
+
}, 1024)
|
|
182
|
+
], 2)), 64))
|
|
183
|
+
]));
|
|
184
|
+
}
|
|
185
|
+
}), rt = /* @__PURE__ */ X(at, [["__scopeId", "data-v-7d7ea511"]]), dt = {
|
|
186
|
+
install(e, d = {}) {
|
|
187
|
+
if (Object.keys(d).length > 0 && _.toast.config(d), typeof document < "u") {
|
|
188
|
+
const r = "sileo-toast-container";
|
|
189
|
+
let t = document.getElementById(r);
|
|
190
|
+
t || (t = document.createElement("div"), t.id = r, document.body.appendChild(t), V({
|
|
191
|
+
render: () => F(rt)
|
|
192
|
+
}).mount(t));
|
|
193
|
+
}
|
|
194
|
+
e.config.globalProperties.$toast = _.toast, e.provide("toast", _.toast);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
export {
|
|
198
|
+
dt as SileoPlugin,
|
|
199
|
+
nt as Toast,
|
|
200
|
+
rt as ToastContainer,
|
|
201
|
+
_ as toastManager,
|
|
202
|
+
O as useToast
|
|
203
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(c,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(c=typeof globalThis<"u"?globalThis:c||self,t(c.SileoVue={},c.Vue))})(this,function(c,t){"use strict";const f=t.reactive([]),y=t.reactive({position:"top-right",duration:4e3,maxToasts:5}),T=()=>Math.random().toString(36).substring(2,9);function u(){const o=e=>{const d={type:"default",duration:y.duration||4e3,position:y.position||"top-right",showProgress:!0,closeOnClick:!0,swipeToDismiss:!0},i=typeof e=="string"?{message:e}:e;f.length>=(y.maxToasts||5)&&f.shift();const m=T(),n={...d,...i,id:m,createdAt:Date.now()};return n.icon&&typeof n.icon!="string"&&(n.icon=t.markRaw(n.icon)),f.push(n),n.duration>0&&setTimeout(()=>{l(m)},n.duration),m},l=e=>{const d=f.findIndex(i=>i.id===e);d!==-1&&f.splice(d,1)},a=Object.assign(o,{success:e=>o(typeof e=="string"?{message:e,type:"success"}:{...e,type:"success"}),error:e=>o(typeof e=="string"?{message:e,type:"error"}:{...e,type:"error"}),warning:e=>o(typeof e=="string"?{message:e,type:"warning"}:{...e,type:"warning"}),info:e=>o(typeof e=="string"?{message:e,type:"info"}:{...e,type:"info"}),clear:()=>f.length=0,config:e=>Object.assign(y,e)});return{toasts:f,toast:a,removeToast:l}}const h=u(),L={class:"sileo-toast__header"},b={class:"sileo-toast__icon"},V={key:1},M={key:2,class:"sileo-toast__default-icon"},N={key:0,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5"},x={key:1,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5"},S={key:2,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5"},D={key:3,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5"},$={key:0,class:"sileo-toast__title"},O={class:"sileo-toast__body"},z={class:"sileo-toast__message"},P={key:0,class:"sileo-toast__progress"},X=t.defineComponent({__name:"Toast",props:{toast:{}},emits:["close"],setup(o,{emit:l}){const a=o,e=l,d=t.ref(null),i=t.ref(!1),m=t.ref(0),n=t.ref(0),g=t.computed(()=>a.toast.icon),_=t.computed(()=>{const r=`translateX(${n.value}px) scale(${i.value?.98:1})`,s=Math.max(0,1-Math.abs(n.value)/200);return{transform:r,opacity:s,transition:i.value?"none":"all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275)"}}),C=r=>{a.toast.swipeToDismiss&&(i.value=!0,m.value="touches"in r?r.touches[0].clientX:r.clientX,"touches"in r?(window.addEventListener("touchmove",p),window.addEventListener("touchend",k)):(window.addEventListener("mousemove",p),window.addEventListener("mouseup",k)))},p=r=>{if(!i.value)return;const s="touches"in r?r.touches[0].clientX:r.clientX;n.value=s-m.value},k=()=>{i.value&&(i.value=!1,Math.abs(n.value)>100?e("close"):n.value=0,window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",k),window.removeEventListener("touchmove",p),window.removeEventListener("touchend",k))};return t.onUnmounted(()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",k),window.removeEventListener("touchmove",p),window.removeEventListener("touchend",k)}),(r,s)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"toastRef",ref:d,class:t.normalizeClass(["sileo-toast",[`sileo-toast--${o.toast.type}`]]),style:t.normalizeStyle(_.value),onMousedown:C,onTouchstart:C},[t.createElementVNode("div",L,[t.createElementVNode("div",b,[typeof o.toast.icon!="string"&&o.toast.icon?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(g.value),{key:0})):typeof o.toast.icon=="string"?(t.openBlock(),t.createElementBlock("span",V,t.toDisplayString(o.toast.icon),1)):(t.openBlock(),t.createElementBlock("div",M,[o.toast.type==="success"?(t.openBlock(),t.createElementBlock("svg",N,[...s[1]||(s[1]=[t.createElementVNode("path",{d:"M20 6L9 17L4 12"},null,-1)])])):o.toast.type==="error"?(t.openBlock(),t.createElementBlock("svg",x,[...s[2]||(s[2]=[t.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):o.toast.type==="warning"?(t.openBlock(),t.createElementBlock("svg",S,[...s[3]||(s[3]=[t.createElementVNode("path",{d:"M12 9v4m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 17c-.77 1.333.192 3 1.732 3z"},null,-1)])])):(t.openBlock(),t.createElementBlock("svg",D,[...s[4]||(s[4]=[t.createElementVNode("path",{d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)])]))]))]),o.toast.title?(t.openBlock(),t.createElementBlock("span",$,t.toDisplayString(o.toast.title),1)):t.createCommentVNode("",!0),o.toast.closeOnClick?(t.openBlock(),t.createElementBlock("button",{key:1,class:"sileo-toast__close",onClick:s[0]||(s[0]=t.withModifiers(v=>r.$emit("close"),["stop"]))},[...s[5]||(s[5]=[t.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[t.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])])):t.createCommentVNode("",!0)]),t.createElementVNode("div",O,[t.createElementVNode("p",z,t.toDisplayString(o.toast.message),1)]),o.toast.duration>0&&o.toast.showProgress?(t.openBlock(),t.createElementBlock("div",P,[t.createElementVNode("div",{class:"sileo-toast__progress-inner",style:t.normalizeStyle({animationDuration:`${o.toast.duration}ms`})},null,4)])):t.createCommentVNode("",!0)],38))}}),w=(o,l)=>{const a=o.__vccOpts||o;for(const[e,d]of l)a[e]=d;return a},E=w(X,[["__scopeId","data-v-fcd6b8c9"]]),I={class:"sileo-wrapper"},B=w(t.defineComponent({__name:"ToastContainer",setup(o){const{toasts:l,removeToast:a}=u(),e=["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"],d=i=>l.filter(m=>m.position===i);return(i,m)=>(t.openBlock(),t.createElementBlock("div",I,[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(e,n=>t.createElementVNode("div",{key:n,class:t.normalizeClass(["sileo-container",[`sileo-container--${n}`]])},[t.createVNode(t.TransitionGroup,{name:"sileo-list"},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(d(n),g=>(t.openBlock(),t.createBlock(E,{key:g.id,toast:g,onClose:_=>t.unref(a)(g.id)},null,8,["toast","onClose"]))),128))]),_:2},1024)],2)),64))]))}}),[["__scopeId","data-v-7d7ea511"]]),j={install(o,l={}){if(Object.keys(l).length>0&&h.toast.config(l),typeof document<"u"){const a="sileo-toast-container";let e=document.getElementById(a);e||(e=document.createElement("div"),e.id=a,document.body.appendChild(e),t.createApp({render:()=>t.h(B)}).mount(e))}o.config.globalProperties.$toast=h.toast,o.provide("toast",h.toast)}};c.SileoPlugin=j,c.Toast=E,c.ToastContainer=B,c.toastManager=h,c.useToast=u,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.sileo-toast[data-v-fcd6b8c9]{position:relative;width:320px;pointer-events:auto;margin-bottom:12px;-webkit-user-select:none;user-select:none;z-index:1000;display:flex;flex-direction:column;gap:8px}.sileo-toast__header[data-v-fcd6b8c9]{display:flex;align-items:center;gap:8px;background:#ffffff1a;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);padding:6px 12px;border-radius:100px;width:fit-content;border:1px solid rgba(255,255,255,.1);box-shadow:0 4px 15px #0003;color:#fff}.sileo-toast__icon[data-v-fcd6b8c9]{width:18px;height:18px;display:flex;align-items:center;justify-content:center}.sileo-toast__default-icon svg[data-v-fcd6b8c9]{width:100%;height:100%}.sileo-toast__title[data-v-fcd6b8c9]{font-size:13px;font-weight:600;letter-spacing:-.2px}.sileo-toast__close[data-v-fcd6b8c9]{background:none;border:none;cursor:pointer;padding:0;margin-left:4px;color:#ffffff80;display:flex;align-items:center;transition:color .2s}.sileo-toast__close[data-v-fcd6b8c9]:hover{color:#fff}.sileo-toast__close svg[data-v-fcd6b8c9]{width:14px;height:14px}.sileo-toast__body[data-v-fcd6b8c9]{background:#141414b3;backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);padding:16px 20px;border-radius:24px;border:1px solid rgba(255,255,255,.1);box-shadow:0 10px 30px #0000004d;overflow:hidden;position:relative}.sileo-toast__message[data-v-fcd6b8c9]{margin:0;font-size:15px;line-height:1.4;color:#ffffffe6;font-weight:400}.sileo-toast--success .sileo-toast__header[data-v-fcd6b8c9]{border-color:#34c7594d;color:#34c759}.sileo-toast--error .sileo-toast__header[data-v-fcd6b8c9]{border-color:#ff3b304d;color:#ff3b30}.sileo-toast--warning .sileo-toast__header[data-v-fcd6b8c9]{border-color:#ff9f0a4d;color:#ff9f0a}.sileo-toast--info .sileo-toast__header[data-v-fcd6b8c9]{border-color:#007aff4d;color:#007aff}.sileo-toast__progress[data-v-fcd6b8c9]{position:absolute;bottom:0;left:0;right:0;height:3px;background:#ffffff0d}.sileo-toast__progress-inner[data-v-fcd6b8c9]{height:100%;background:currentColor;width:0%;animation:sileo-progress-fcd6b8c9 linear forwards}@keyframes sileo-progress-fcd6b8c9{0%{width:100%}to{width:0%}}.sileo-toast--success[data-v-fcd6b8c9]{color:#34c759}.sileo-toast--error[data-v-fcd6b8c9]{color:#ff3b30}.sileo-toast--warning[data-v-fcd6b8c9]{color:#ff9f0a}.sileo-toast--info[data-v-fcd6b8c9]{color:#007aff}.sileo-toast--default[data-v-fcd6b8c9]{color:#ffffff80}.sileo-container[data-v-7d7ea511]{position:fixed;z-index:9999;padding:20px;pointer-events:none;display:flex;flex-direction:column}.sileo-container--top-left[data-v-7d7ea511]{top:0;left:0;align-items:flex-start}.sileo-container--top-center[data-v-7d7ea511]{top:0;left:50%;transform:translate(-50%);align-items:center}.sileo-container--top-right[data-v-7d7ea511]{top:0;right:0;align-items:flex-end}.sileo-container--bottom-left[data-v-7d7ea511]{bottom:0;left:0;align-items:flex-start;flex-direction:column-reverse}.sileo-container--bottom-center[data-v-7d7ea511]{bottom:0;left:50%;transform:translate(-50%);align-items:center;flex-direction:column-reverse}.sileo-container--bottom-right[data-v-7d7ea511]{bottom:0;right:0;align-items:flex-end;flex-direction:column-reverse}.sileo-list-enter-active[data-v-7d7ea511],.sileo-list-leave-active[data-v-7d7ea511]{transition:all .5s cubic-bezier(.19,1,.22,1)}.sileo-list-enter-from[data-v-7d7ea511]{opacity:0;transform:translateY(-20px) scale(.9)}.sileo-list-leave-to[data-v-7d7ea511]{opacity:0;transform:translateY(-10px) scale(.95)}.sileo-list-move[data-v-7d7ea511]{transition:transform .4s ease}.sileo-container--bottom-left .sileo-list-enter-from[data-v-7d7ea511],.sileo-container--bottom-center .sileo-list-enter-from[data-v-7d7ea511],.sileo-container--bottom-right .sileo-list-enter-from[data-v-7d7ea511]{transform:translateY(20px) scale(.9)}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type ToastType = 'success' | 'error' | 'warning' | 'info' | 'default';
|
|
2
|
+
export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
3
|
+
export interface ToastOptions {
|
|
4
|
+
title?: string;
|
|
5
|
+
message: string;
|
|
6
|
+
type?: ToastType;
|
|
7
|
+
duration?: number;
|
|
8
|
+
position?: ToastPosition;
|
|
9
|
+
icon?: any;
|
|
10
|
+
showProgress?: boolean;
|
|
11
|
+
closeOnClick?: boolean;
|
|
12
|
+
swipeToDismiss?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface Toast extends Required<Omit<ToastOptions, 'icon' | 'title'>> {
|
|
15
|
+
id: string;
|
|
16
|
+
title?: string;
|
|
17
|
+
icon?: any;
|
|
18
|
+
createdAt: number;
|
|
19
|
+
}
|
|
20
|
+
export interface GlobalConfig {
|
|
21
|
+
position?: ToastPosition;
|
|
22
|
+
duration?: number;
|
|
23
|
+
maxToasts?: number;
|
|
24
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@edgar208/sileo-vue",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A production-ready Vue 3 toast notification library inspired by Sileo.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/sileo-vue.umd.cjs",
|
|
7
|
+
"module": "./dist/sileo-vue.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/sileo-vue.js",
|
|
12
|
+
"require": "./dist/sileo-vue.umd.cjs",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./style.css": "./dist/style.css"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dev": "vite",
|
|
22
|
+
"build": "vite build && vue-tsc --emitDeclarationOnly",
|
|
23
|
+
"preview": "vite preview"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"vue": "^3.3.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.0.0",
|
|
30
|
+
"@vitejs/plugin-vue": "^5.0.0",
|
|
31
|
+
"typescript": "^5.2.2",
|
|
32
|
+
"vite": "^5.0.0",
|
|
33
|
+
"vue": "^3.3.0",
|
|
34
|
+
"vue-tsc": "^3.2.6"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"vue",
|
|
38
|
+
"vue3",
|
|
39
|
+
"toast",
|
|
40
|
+
"notification",
|
|
41
|
+
"sileo",
|
|
42
|
+
"glassmorphism",
|
|
43
|
+
"ui-library"
|
|
44
|
+
],
|
|
45
|
+
"author": "",
|
|
46
|
+
"license": "MIT"
|
|
47
|
+
}
|