veloce-vue 0.24.0 → 0.25.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.
@@ -0,0 +1,89 @@
1
+ import { Component, DefineComponent, ExtractPropTypes, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
2
+ import { Severity } from '../../exports/types';
3
+ declare function __VLS_template(): {
4
+ attrs: Partial<{}>;
5
+ slots: {
6
+ icon?(_: {}): any;
7
+ default?(_: {}): any;
8
+ };
9
+ refs: {};
10
+ rootEl: any;
11
+ };
12
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
13
+ declare const __VLS_component: DefineComponent<ExtractPropTypes<{
14
+ id: {
15
+ type: StringConstructor;
16
+ required: true;
17
+ };
18
+ message: {
19
+ type: StringConstructor;
20
+ default: string;
21
+ };
22
+ severity: {
23
+ type: () => Severity;
24
+ default: string;
25
+ };
26
+ icon: {
27
+ type: () => Component;
28
+ default: () => null;
29
+ };
30
+ duration: {
31
+ type: NumberConstructor;
32
+ default: number;
33
+ };
34
+ closable: {
35
+ type: BooleanConstructor;
36
+ default: boolean;
37
+ };
38
+ position: {
39
+ type: () => "top-left" | "top-right" | "top-center" | "bottom-left" | "bottom-right" | "bottom-center";
40
+ default: string;
41
+ };
42
+ }>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
43
+ close: (id: string) => any;
44
+ }, string, PublicProps, Readonly< ExtractPropTypes<{
45
+ id: {
46
+ type: StringConstructor;
47
+ required: true;
48
+ };
49
+ message: {
50
+ type: StringConstructor;
51
+ default: string;
52
+ };
53
+ severity: {
54
+ type: () => Severity;
55
+ default: string;
56
+ };
57
+ icon: {
58
+ type: () => Component;
59
+ default: () => null;
60
+ };
61
+ duration: {
62
+ type: NumberConstructor;
63
+ default: number;
64
+ };
65
+ closable: {
66
+ type: BooleanConstructor;
67
+ default: boolean;
68
+ };
69
+ position: {
70
+ type: () => "top-left" | "top-right" | "top-center" | "bottom-left" | "bottom-right" | "bottom-center";
71
+ default: string;
72
+ };
73
+ }>> & Readonly<{
74
+ onClose?: ((id: string) => any) | undefined;
75
+ }>, {
76
+ icon: Component;
77
+ message: string;
78
+ position: "top-left" | "top-right" | "top-center" | "bottom-left" | "bottom-right" | "bottom-center";
79
+ duration: number;
80
+ severity: Severity;
81
+ closable: boolean;
82
+ }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
83
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
84
+ export default _default;
85
+ type __VLS_WithTemplateSlots<T, S> = T & {
86
+ new (): {
87
+ $slots: S;
88
+ };
89
+ };
@@ -0,0 +1,151 @@
1
+ import { defineComponent as q, computed as o, ref as n, onMounted as U, onUnmounted as X, createBlock as _, openBlock as f, unref as i, normalizeClass as D, withCtx as F, createElementVNode as b, createElementBlock as I, createCommentVNode as y, renderSlot as B, toDisplayString as G, createVNode as $, normalizeStyle as H } from "vue";
2
+ import J from "../../icons/Alert.vue.js";
3
+ import K from "../../icons/CheckCircle.vue.js";
4
+ import L from "../../icons/Close.vue.js";
5
+ import s from "../../icons/Info.vue.js";
6
+ import Q from "../../icons/XCircle.vue.js";
7
+ import M from "../icon/Icon.vue.js";
8
+ import { motion as P } from "motion-v";
9
+ const R = { class: "flex items-start gap-3 p-4" }, W = { class: "flex-1" }, Y = { class: "text-sm font-medium" }, Z = {
10
+ key: 0,
11
+ class: "absolute bottom-0 left-0 h-1 w-full overflow-hidden bg-black/10 dark:bg-white/10"
12
+ }, le = /* @__PURE__ */ q({
13
+ __name: "Toast",
14
+ props: {
15
+ id: { type: String, required: !0 },
16
+ message: { type: String, default: "" },
17
+ severity: { type: String, default: "info" },
18
+ icon: { type: Object, default: () => null },
19
+ duration: { type: Number, default: 5e3 },
20
+ closable: { type: Boolean, default: !0 },
21
+ position: { type: String, default: "top-right" }
22
+ },
23
+ emits: ["close"],
24
+ setup(l, { emit: z }) {
25
+ const e = l, N = z, V = {
26
+ success: K,
27
+ info: s,
28
+ warning: J,
29
+ error: Q,
30
+ primary: s,
31
+ secondary: s,
32
+ neutral: s
33
+ }, h = {
34
+ success: "bg-success-light dark:bg-success/20 text-success border-success/30",
35
+ info: "bg-info-light dark:bg-info/20 text-info border-info/30",
36
+ warning: "bg-warning-light dark:bg-warning/20 text-warning border-warning/30",
37
+ error: "bg-error-light dark:bg-error/20 text-error border-error/30",
38
+ primary: "bg-primary-light dark:bg-primary/20 text-primary border-primary/30",
39
+ secondary: "bg-secondary-light dark:bg-secondary/20 text-secondary border-secondary/30",
40
+ neutral: "bg-neutral-100 dark:bg-neutral-800 text-neutral-700 dark:text-neutral-200 border-neutral-300 dark:border-neutral-700"
41
+ }, w = {
42
+ success: "bg-success",
43
+ info: "bg-info",
44
+ warning: "bg-warning",
45
+ error: "bg-error",
46
+ primary: "bg-primary",
47
+ secondary: "bg-secondary",
48
+ neutral: "bg-neutral-500"
49
+ }, A = o(() => h[e.severity] || h.info), E = o(() => w[e.severity] || w.info), k = o(() => e.icon || V[e.severity] || s), g = o(() => {
50
+ let t = e.position.includes("top") ? -50 : 50;
51
+ return {
52
+ initial: { opacity: 0, x: 0, y: t, scale: 0.9 },
53
+ animate: { opacity: 1, x: 0, y: 0, scale: 1 },
54
+ exit: { opacity: 0, x: 0, y: t, scale: 0.9 }
55
+ };
56
+ }), a = n(0), r = n(!1);
57
+ let u = null, c = null;
58
+ const x = n(Date.now()), d = n(0), p = n(0), C = o(() => {
59
+ if (e.duration <= 0) return 100;
60
+ const t = e.duration - a.value;
61
+ return Math.max(0, Math.min(100, t / e.duration * 100));
62
+ }), O = () => {
63
+ if (!r.value && e.duration > 0) {
64
+ const t = Date.now();
65
+ a.value = t - x.value - p.value, a.value >= e.duration && m();
66
+ }
67
+ }, m = () => {
68
+ N("close", e.id);
69
+ }, T = () => {
70
+ if (e.duration > 0) {
71
+ if (r.value && d.value > 0) {
72
+ const S = Date.now() - d.value;
73
+ p.value += S, d.value = 0;
74
+ } else
75
+ x.value = Date.now(), a.value = 0, p.value = 0;
76
+ r.value = !1, v(), c = setInterval(O, 16);
77
+ const t = e.duration - a.value;
78
+ t > 0 ? u = setTimeout(() => {
79
+ m();
80
+ }, t) : m();
81
+ }
82
+ }, j = () => {
83
+ r.value || (r.value = !0, d.value = Date.now(), v());
84
+ }, v = () => {
85
+ u && (clearTimeout(u), u = null), c && (clearInterval(c), c = null);
86
+ };
87
+ return U(() => {
88
+ T();
89
+ }), X(() => {
90
+ v();
91
+ }), (t, S) => (f(), _(i(P).div, {
92
+ class: D([A.value, "relative flex min-w-[300px] max-w-[400px] flex-col overflow-hidden rounded-lg border shadow-lg backdrop-blur-sm"]),
93
+ layout: "",
94
+ initial: g.value.initial,
95
+ animate: g.value.animate,
96
+ exit: g.value.exit,
97
+ transition: {
98
+ duration: 0.3,
99
+ ease: [0.4, 0, 0.2, 1],
100
+ layout: {
101
+ duration: 0.3,
102
+ ease: [0.4, 0, 0.2, 1]
103
+ }
104
+ },
105
+ onMouseenter: j,
106
+ onMouseleave: T
107
+ }, {
108
+ default: F(() => [
109
+ b("div", R, [
110
+ t.$slots.icon ? B(t.$slots, "icon", { key: 0 }) : k.value ? (f(), _(i(M), {
111
+ key: 1,
112
+ icon: k.value,
113
+ class: "mt-0.5 size-5"
114
+ }, null, 8, ["icon"])) : y("", !0),
115
+ b("div", W, [
116
+ B(t.$slots, "default", {}, () => [
117
+ b("p", Y, G(l.message), 1)
118
+ ])
119
+ ]),
120
+ l.closable ? (f(), I("button", {
121
+ key: 2,
122
+ type: "button",
123
+ class: "ml-auto shrink-0 rounded p-0.5 transition-colors hover:bg-black/10 dark:hover:bg-white/10",
124
+ onClick: m
125
+ }, [
126
+ $(i(M), {
127
+ icon: i(L),
128
+ class: "size-4"
129
+ }, null, 8, ["icon"])
130
+ ])) : y("", !0)
131
+ ]),
132
+ l.duration > 0 ? (f(), I("div", Z, [
133
+ $(i(P).div, {
134
+ class: D([E.value, "h-full"]),
135
+ style: H({ width: `${C.value}%` }),
136
+ initial: { width: "100%" },
137
+ animate: { width: `${C.value}%` },
138
+ transition: {
139
+ duration: r.value ? 0 : 0.16,
140
+ ease: "linear"
141
+ }
142
+ }, null, 8, ["class", "style", "animate", "transition"])
143
+ ])) : y("", !0)
144
+ ]),
145
+ _: 3
146
+ }, 8, ["class", "initial", "animate", "exit"]));
147
+ }
148
+ });
149
+ export {
150
+ le as default
151
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./Toast.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,31 @@
1
+ import { Ref, DefineComponent, ExtractPropTypes, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
2
+ import { ToastItem } from '../../exports/toast';
3
+ declare const toasts: Ref<ToastItem[]>;
4
+ declare const _default: DefineComponent<ExtractPropTypes<{
5
+ position: {
6
+ type: () => "top-center" | "bottom-center" | "top-right" | "top-left" | "bottom-right" | "bottom-left";
7
+ default: string;
8
+ };
9
+ maxToasts: {
10
+ type: NumberConstructor;
11
+ default: number;
12
+ };
13
+ }>, {
14
+ addToast: (toast: ToastItem) => void;
15
+ removeToast: (id: string) => void;
16
+ clearAll: () => void;
17
+ toasts: typeof toasts;
18
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly< ExtractPropTypes<{
19
+ position: {
20
+ type: () => "top-center" | "bottom-center" | "top-right" | "top-left" | "bottom-right" | "bottom-left";
21
+ default: string;
22
+ };
23
+ maxToasts: {
24
+ type: NumberConstructor;
25
+ default: number;
26
+ };
27
+ }>> & Readonly<{}>, {
28
+ position: "top-left" | "top-right" | "top-center" | "bottom-left" | "bottom-right" | "bottom-center";
29
+ maxToasts: number;
30
+ }, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLDivElement>;
31
+ export default _default;
@@ -0,0 +1,67 @@
1
+ import { defineComponent as f, ref as v, computed as g, onMounted as x, createElementBlock as u, openBlock as l, normalizeClass as b, createVNode as h, unref as y, withCtx as C, Fragment as T, renderList as _, createBlock as k, normalizeStyle as w } from "vue";
2
+ import { AnimatePresence as z } from "motion-v";
3
+ import B from "./Toast.vue.js";
4
+ import { useRandomId as I } from "../../utils/useRandomId.js";
5
+ import { setToastContainer as $ } from "../../composables/useToast.js";
6
+ const L = /* @__PURE__ */ f({
7
+ __name: "ToastContainer",
8
+ props: {
9
+ position: { type: String, default: "top-right" },
10
+ maxToasts: { type: Number, default: 5 }
11
+ },
12
+ setup(r, { expose: m }) {
13
+ const s = r, t = v([]), p = g(() => {
14
+ const e = "fixed z-[9999] flex flex-col gap-3 p-4 pointer-events-none", o = {
15
+ "top-left": "top-0 left-0",
16
+ "top-right": "top-0 right-0",
17
+ "top-center": "top-0 left-1/2 -translate-x-1/2",
18
+ "bottom-left": "bottom-0 left-0",
19
+ "bottom-right": "bottom-0 right-0",
20
+ "bottom-center": "bottom-0 left-1/2 -translate-x-1/2"
21
+ };
22
+ return `${e} ${o[s.position] || o["top-right"]}`;
23
+ }), a = (e) => {
24
+ const o = {
25
+ id: e.id || I(),
26
+ message: e.message,
27
+ severity: e.severity || "info",
28
+ icon: e.icon,
29
+ duration: e.duration ?? 5e3,
30
+ closable: e.closable ?? !0
31
+ };
32
+ s.position.includes("top") ? t.value.unshift(o) : t.value.push(o), t.value.length > s.maxToasts && t.value.shift();
33
+ }, i = (e) => {
34
+ const o = t.value.findIndex((n) => n.id === e);
35
+ o > -1 && t.value.splice(o, 1);
36
+ }, c = () => {
37
+ t.value = [];
38
+ };
39
+ return x(() => {
40
+ $({ addToast: a, removeToast: i, clearAll: c, toasts: t });
41
+ }), m({ addToast: a, removeToast: i, clearAll: c, toasts: t }), (e, o) => (l(), u("div", {
42
+ class: b([p.value, "w-full sm:w-auto"])
43
+ }, [
44
+ h(y(z), null, {
45
+ default: C(() => [
46
+ (l(!0), u(T, null, _(t.value, (n, d) => (l(), k(B, {
47
+ key: n.id,
48
+ icon: n.icon,
49
+ class: "pointer-events-auto",
50
+ style: w({ zIndex: d + 1 }),
51
+ id: n.id,
52
+ message: n.message,
53
+ severity: n.severity,
54
+ duration: n.duration,
55
+ closable: n.closable,
56
+ position: r.position,
57
+ onClose: i
58
+ }, null, 8, ["icon", "style", "id", "message", "severity", "duration", "closable", "position"]))), 128))
59
+ ]),
60
+ _: 1
61
+ })
62
+ ], 2));
63
+ }
64
+ });
65
+ export {
66
+ L as default
67
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./ToastContainer.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,9 @@
1
+ import { computed as a, watch as l, onBeforeMount as d } from "vue";
2
+ import { useStorage as s } from "@vueuse/core";
3
+ const m = () => {
4
+ const e = s("color-mode", "dark"), o = a(() => e.value === "dark"), t = () => e.value = o.value ? "light" : "dark";
5
+ return l(e, (r) => document.documentElement.classList.toggle("dark", r === "dark")), d(() => document.documentElement.classList.toggle("dark", o.value)), { mode: e, isDark: o, toggleDark: t };
6
+ };
7
+ export {
8
+ m as useColorMode
9
+ };
@@ -0,0 +1,25 @@
1
+ import { useRandomId as a } from "../utils/useRandomId.js";
2
+ let n = null;
3
+ const f = (t) => {
4
+ n = t;
5
+ }, s = (t) => {
6
+ if (!n) {
7
+ console.warn("Toast container not initialized. Make sure to add <ToastContainer> to your app.");
8
+ return;
9
+ }
10
+ const o = {
11
+ id: a(),
12
+ message: t.message,
13
+ severity: t.severity || "info",
14
+ icon: t.icon,
15
+ duration: t.duration ?? 5e3,
16
+ closable: t.closable ?? !0
17
+ };
18
+ n.addToast(o);
19
+ }, w = () => ({ success: (e, r) => s({ ...r, message: e, severity: "success" }), error: (e, r) => s({ ...r, message: e, severity: "error" }), warning: (e, r) => s({ ...r, message: e, severity: "warning" }), info: (e, r) => s({ ...r, message: e, severity: "info" }), show: (e, r) => s({ ...r, message: e }), clear: () => {
20
+ n && n.clearAll();
21
+ } });
22
+ export {
23
+ f as setToastContainer,
24
+ w as useToast
25
+ };
package/composables.js ADDED
@@ -0,0 +1,4 @@
1
+ import { useColorMode as r } from "./composables/useColorMode.js";
2
+ export {
3
+ r as useColorMode
4
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veloce-vue",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "A Vue 3 library built with Vite + TypeScript + Tailwind CSS.",
@@ -30,6 +30,31 @@
30
30
  "import": "./config.js",
31
31
  "default": "./config.js"
32
32
  },
33
+ "./toast": {
34
+ "types": "./exports/toast.d.ts",
35
+ "import": "./toast.js",
36
+ "default": "./toast.js"
37
+ },
38
+ "./types": {
39
+ "types": "./exports/types.d.ts",
40
+ "import": "./types.js",
41
+ "default": "./types.js"
42
+ },
43
+ "./typography": {
44
+ "types": "./exports/typography.d.ts",
45
+ "import": "./typography.js",
46
+ "default": "./typography.js"
47
+ },
48
+ "./utils": {
49
+ "types": "./exports/utils.d.ts",
50
+ "import": "./utils.js",
51
+ "default": "./utils.js"
52
+ },
53
+ "./composables": {
54
+ "types": "./exports/composables.d.ts",
55
+ "import": "./composables.js",
56
+ "default": "./composables.js"
57
+ },
33
58
  "./styles.css": "./veloce.css"
34
59
  },
35
60
  "peerDependencies": {
package/toast.js ADDED
@@ -0,0 +1,9 @@
1
+ import { default as a } from "./components/toast/Toast.vue.js";
2
+ import { default as r } from "./components/toast/ToastContainer.vue.js";
3
+ import { setToastContainer as f, useToast as n } from "./composables/useToast.js";
4
+ export {
5
+ a as Toast,
6
+ r as ToastContainer,
7
+ f as setToastContainer,
8
+ n as useToast
9
+ };
package/types.js ADDED
@@ -0,0 +1 @@
1
+
package/typography.js ADDED
@@ -0,0 +1,26 @@
1
+ import { default as a } from "./components/typography/Blockquote.vue.js";
2
+ import { default as f } from "./components/typography/Code.vue.js";
3
+ import { default as l } from "./components/typography/H1.vue.js";
4
+ import { default as p } from "./components/typography/H2.vue.js";
5
+ import { default as u } from "./components/typography/H3.vue.js";
6
+ import { default as x } from "./components/typography/H4.vue.js";
7
+ import { default as L } from "./components/typography/H5.vue.js";
8
+ import { default as c } from "./components/typography/H6.vue.js";
9
+ import { default as k } from "./components/typography/Label.vue.js";
10
+ import { default as q } from "./components/typography/List.vue.js";
11
+ import { default as C } from "./components/typography/P.vue.js";
12
+ import { default as S } from "./components/typography/Span.vue.js";
13
+ export {
14
+ a as Blockquote,
15
+ f as Code,
16
+ l as H1,
17
+ p as H2,
18
+ u as H3,
19
+ x as H4,
20
+ L as H5,
21
+ c as H6,
22
+ k as Label,
23
+ q as List,
24
+ C as P,
25
+ S as Span
26
+ };
package/utils.js ADDED
@@ -0,0 +1,10 @@
1
+ import { useRandomId as e } from "./utils/useRandomId.js";
2
+ import { getTypography as g } from "./utils/typography.js";
3
+ import { getMargin as m } from "./utils/margin.js";
4
+ import { getPadding as d } from "./utils/padding.js";
5
+ export {
6
+ m as getMargin,
7
+ d as getPadding,
8
+ g as getTypography,
9
+ e as useRandomId
10
+ };