vuesp-components 2.0.7 → 2.0.9

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.
@@ -1,116 +1,109 @@
1
- import { ref as z, reactive as y, watch as B, computed as k } from "vue";
2
- import { u as R, a as W } from "../useSwipeDown-E8KeNvRa.js";
3
- function I(w) {
4
- const { validationSchema: l, initialValues: m = {} } = w, d = typeof l == "function", v = z(
5
- d ? l(m) : l
6
- ), F = (t) => {
7
- v.value = t;
8
- const e = Object.keys(t), o = Object.keys(c);
9
- e.forEach((s) => {
10
- s in c || (c[s] = m[s] ?? "", a[s] = [], u[s] = !1, h[s] = !1);
11
- }), o.forEach((s) => {
12
- e.includes(s) || (delete c[s], delete a[s], delete u[s], delete h[s]);
13
- }), E();
14
- }, c = y({}), a = y({}), u = y({}), h = y({}), f = /* @__PURE__ */ new Map(), D = () => {
15
- Object.keys(v.value).forEach((t) => {
16
- c[t] = m[t] ?? "", a[t] = [], u[t] = !1, h[t] = !1;
17
- });
18
- }, i = () => d ? l(c) : v.value, g = (t, e) => {
19
- const s = i()[t] || [], n = [];
20
- for (const r of s) {
21
- const p = r(e, c);
22
- p !== !0 && n.push(p);
23
- }
24
- return a[t] = n, n.length === 0;
25
- }, S = (t, e) => {
26
- const o = i();
27
- if (!o[t]) return;
28
- g(t, e);
29
- const s = f.get(t);
30
- s && s.forEach((n) => {
31
- o[n] && g(n, c[n]);
32
- });
33
- }, E = () => {
34
- f.clear();
35
- const t = i();
36
- Object.keys(t).forEach((e) => {
37
- (t[e] || []).forEach((s) => {
38
- if (typeof s == "function" && s.name === "sameAs") {
39
- const n = s.toString().match(/['"](.*?)['"]/);
40
- if (n) {
41
- const r = n[1];
42
- f.has(r) || f.set(r, /* @__PURE__ */ new Set()), f.get(r).add(e);
43
- }
44
- }
45
- });
46
- });
47
- }, O = () => {
48
- const t = i();
49
- let e = !0;
50
- return Object.keys(t).forEach((o) => {
51
- g(o, c[o]) || (e = !1);
52
- }), e;
53
- }, V = (t, e = {}) => {
54
- i()[t] || console.warn(`Field "${t}" not found in current validationSchema`);
55
- const s = k({
56
- get: () => c[t],
57
- set: (r) => {
58
- c[t] = r, h[t] = !0, S(t, r);
59
- }
60
- }), n = k(() => {
61
- var j;
62
- const r = {
63
- errors: a[t] || [],
64
- touched: u[t] || !1,
65
- dirty: h[t] || !1
66
- }, p = {
67
- message: (j = a[t]) == null ? void 0 : j[0],
68
- onInput: (b) => {
69
- const K = b.target;
70
- s.value = K.value;
71
- },
72
- onBlur: () => {
73
- u[t] = !0, S(t, c[t]);
74
- }
75
- };
76
- if (e.props) {
77
- const b = e.props(r);
78
- return { ...p, ...b };
79
- }
80
- return p;
81
- });
82
- return [s, n];
83
- }, x = (t) => async (e) => {
84
- e && e.preventDefault();
85
- const o = i();
86
- Object.keys(o).forEach((n) => {
87
- u[n] = !0;
88
- }), O() && await t(c);
89
- }, A = () => {
90
- const t = i();
91
- Object.keys(t).forEach((e) => {
92
- c[e] = m[e] || "", a[e] = [], u[e] = !1, h[e] = !1;
93
- });
94
- };
95
- return D(), E(), d && B(
96
- () => c,
97
- () => {
98
- const t = l(c), e = v.value, o = Object.keys(t), s = Object.keys(e);
99
- (o.length !== s.length || o.some((n) => !s.includes(n))) && F(t);
100
- },
101
- { deep: !0 }
102
- ), {
103
- values: c,
104
- errors: a,
105
- defineField: V,
106
- handleSubmit: x,
107
- resetForm: A,
108
- validate: O,
109
- updateSchema: F
110
- };
1
+ import { n as e, t } from "../useDialog-Biu5-ZSJ.js";
2
+ import { computed as n, reactive as r, ref as i, watch as a } from "vue";
3
+ //#region src/composables/useForms.ts
4
+ function o(e) {
5
+ let { validationSchema: t, initialValues: o = {} } = e, s = typeof t == "function", c = i(s ? t(o) : t), l = (e) => {
6
+ c.value = e;
7
+ let t = Object.keys(e), n = Object.keys(u);
8
+ t.forEach((e) => {
9
+ e in u || (u[e] = o[e] ?? "", d[e] = [], f[e] = !1, p[e] = !1);
10
+ }), n.forEach((e) => {
11
+ t.includes(e) || (delete u[e], delete d[e], delete f[e], delete p[e]);
12
+ }), y();
13
+ }, u = r({}), d = r({}), f = r({}), p = r({}), m = /* @__PURE__ */ new Map(), h = () => {
14
+ Object.keys(c.value).forEach((e) => {
15
+ u[e] = o[e] ?? "", d[e] = [], f[e] = !1, p[e] = !1;
16
+ });
17
+ }, g = () => s ? t(u) : c.value, _ = (e, t) => {
18
+ let n = g()[e] || [], r = [];
19
+ for (let e of n) {
20
+ let n = e(t, u);
21
+ n !== !0 && r.push(n);
22
+ }
23
+ return d[e] = r, r.length === 0;
24
+ }, v = (e, t) => {
25
+ let n = g();
26
+ if (!n[e]) return;
27
+ _(e, t);
28
+ let r = m.get(e);
29
+ r && r.forEach((e) => {
30
+ n[e] && _(e, u[e]);
31
+ });
32
+ }, y = () => {
33
+ m.clear();
34
+ let e = g();
35
+ Object.keys(e).forEach((t) => {
36
+ (e[t] || []).forEach((e) => {
37
+ if (typeof e == "function" && e.name === "sameAs") {
38
+ let n = e.toString().match(/['"](.*?)['"]/);
39
+ if (n) {
40
+ let e = n[1];
41
+ m.has(e) || m.set(e, /* @__PURE__ */ new Set()), m.get(e).add(t);
42
+ }
43
+ }
44
+ });
45
+ });
46
+ }, b = () => {
47
+ let e = g(), t = !0;
48
+ return Object.keys(e).forEach((e) => {
49
+ _(e, u[e]) || (t = !1);
50
+ }), t;
51
+ };
52
+ return h(), y(), s && a(() => u, () => {
53
+ let e = t(u), n = c.value, r = Object.keys(e), i = Object.keys(n);
54
+ (r.length !== i.length || r.some((e) => !i.includes(e))) && l(e);
55
+ }, { deep: !0 }), {
56
+ values: u,
57
+ errors: d,
58
+ defineField: (e, t = {}) => {
59
+ g()[e] || console.warn(`Field "${e}" not found in current validationSchema`);
60
+ let r = n({
61
+ get: () => u[e],
62
+ set: (t) => {
63
+ u[e] = t, p[e] = !0, v(e, t);
64
+ }
65
+ });
66
+ return [r, n(() => {
67
+ let n = {
68
+ errors: d[e] || [],
69
+ touched: f[e] || !1,
70
+ dirty: p[e] || !1
71
+ }, i = {
72
+ message: d[e]?.[0],
73
+ onInput: (e) => {
74
+ let t = e.target;
75
+ r.value = t.value;
76
+ },
77
+ onBlur: () => {
78
+ f[e] = !0, v(e, u[e]);
79
+ }
80
+ };
81
+ if (t.props) {
82
+ let e = t.props(n);
83
+ return {
84
+ ...i,
85
+ ...e
86
+ };
87
+ }
88
+ return i;
89
+ })];
90
+ },
91
+ handleSubmit: (e) => async (t) => {
92
+ t && t.preventDefault();
93
+ let n = g();
94
+ Object.keys(n).forEach((e) => {
95
+ f[e] = !0;
96
+ }), b() && await e(u);
97
+ },
98
+ resetForm: () => {
99
+ let e = g();
100
+ Object.keys(e).forEach((e) => {
101
+ u[e] = o[e] || "", d[e] = [], f[e] = !1, p[e] = !1;
102
+ });
103
+ },
104
+ validate: b,
105
+ updateSchema: l
106
+ };
111
107
  }
112
- export {
113
- R as useDialog,
114
- I as useForm,
115
- W as useSwipeDown
116
- };
108
+ //#endregion
109
+ export { t as useDialog, o as useForm, e as useSwipeDown };
@@ -1,39 +1,33 @@
1
- const v = (t, r) => {
2
- const c = t.split(".");
3
- let e = r;
4
- for (const n of c)
5
- if (e !== null && typeof e == "object" && n in e)
6
- e = e[n];
7
- else
8
- return;
9
- return e;
10
- }, i = ({ args: t }, r) => t.map((c) => v(c, r)), u = (t) => t ? (t = t.includes("return") ? t : `return ${t}`, new Function("v", "a", "b", "c", t)) : null, F = (t, r, c) => {
11
- const [, ...e] = i(t, c);
12
- let n = null;
13
- try {
14
- const o = u(t.set);
15
- o && (n = o(r, ...e));
16
- } catch (o) {
17
- console.warn(o);
18
- }
19
- return n;
20
- }, p = (t, r) => {
21
- const c = i(t, r), [e, n, o, l] = c;
22
- let s = e ?? "", g = s;
23
- try {
24
- const a = u(t.get);
25
- a && (s = a(s, n, o, l));
26
- const f = u(t.getTo);
27
- f && (g = f(s, n, o, l));
28
- } catch (a) {
29
- console.warn(a);
30
- }
31
- return { ...t, value: s, valueTo: g };
32
- };
33
- export {
34
- v as getDataValue,
35
- u as getFunction,
36
- i as getParamsData,
37
- p as getStateItem,
38
- F as setStateItem
1
+ //#region src/dashboard/index.ts
2
+ var e = (e, t) => {
3
+ let n = e.split("."), r = t;
4
+ for (let e of n) if (typeof r == "object" && r && e in r) r = r[e];
5
+ else return;
6
+ return r;
7
+ }, t = ({ args: t }, n) => t.map((t) => e(t, n)), n = (e) => e ? (e = e.includes("return") ? e : `return ${e}`, Function("v", "a", "b", "c", e)) : null, r = (e, r, i) => {
8
+ let [, ...a] = t(e, i), o = null;
9
+ try {
10
+ let t = n(e.set);
11
+ t && (o = t(r, ...a));
12
+ } catch (e) {
13
+ console.warn(e);
14
+ }
15
+ return o;
16
+ }, i = (e, r) => {
17
+ let [i, a, o, s] = t(e, r), c = i ?? "", l = c;
18
+ try {
19
+ let t = n(e.get);
20
+ t && (c = t(c, a, o, s));
21
+ let r = n(e.getTo);
22
+ r && (l = r(c, a, o, s));
23
+ } catch (e) {
24
+ console.warn(e);
25
+ }
26
+ return {
27
+ ...e,
28
+ value: c,
29
+ valueTo: l
30
+ };
39
31
  };
32
+ //#endregion
33
+ export { e as getDataValue, n as getFunction, t as getParamsData, i as getStateItem, r as setStateItem };
@@ -1,56 +1,46 @@
1
- const c = (t) => {
2
- try {
3
- return t ? JSON.parse(t) : null;
4
- } catch (e) {
5
- return console.warn(e), t;
6
- }
7
- }, s = (t) => typeof t == "object" ? JSON.stringify(t) : t, g = (t) => c(s(t)), h = (t) => {
8
- const e = ["B", "KB", "MB"];
9
- if (t == 0) return "0 B";
10
- let o = Math.floor(Math.log(t) / Math.log(1024));
11
- return o > 1 && (o = 1), Math.round(t / Math.pow(1024, o)) + " " + e[o];
12
- }, f = (t, e = { year: "numeric", month: "numeric", day: "numeric" }, o = []) => new Date(t).toLocaleDateString(o, e), S = (t, e = { minute: "2-digit", hour: "2-digit" }, o = []) => new Date(t).toLocaleTimeString(o, e), r = (t) => t >= 10 ? t : `0${t}`, p = (t) => {
13
- const e = Math.floor(t % 31536e3 % 2628e3 / 86400), o = Math.floor(t % (3600 * 24) / 3600), n = Math.floor(t % 3600 / 60), m = Math.floor(t % 60);
14
- return `${e ? e + " days " : ""} ${r(o)}:${r(n)}:${r(m)}`;
15
- }, w = (t) => t.join("."), y = (t) => t.split(".").map((e) => +e), M = (t, e = "file") => {
16
- const o = document.createElement("a");
17
- o.setAttribute("download", e), o.href = t, document.body.appendChild(o), o.click(), o.remove();
18
- }, T = (t) => new Promise((e, o) => {
19
- const n = document.createElement("script");
20
- n.src = t, n.type = "text/javascript", n.async = !0, n.onload = () => e(n), n.onerror = () => o(new Error(`Ошибка загрузки скрипта: ${t}`)), document.head.appendChild(n);
21
- }), i = (t) => (e, o) => o ? c(t.getItem(e)) : t.getItem(e), l = (t) => (e, o) => {
22
- t && t.setItem(e, typeof o == "string" ? o : s(o));
23
- }, u = i(localStorage), a = l(localStorage), E = i(sessionStorage), L = l(sessionStorage), $ = (t = "isShow") => {
24
- const e = u(t);
25
- return e || a(t, "true"), !e;
26
- }, j = (t) => {
27
- a("theme", t), document.documentElement.classList.remove("dark"), document.documentElement.classList.remove("light"), document.documentElement.classList.add(t);
28
- }, d = (t, e) => {
29
- if (!t) return null;
30
- for (const o of t)
31
- if (!(e === "/" || o.path === "/") && (o.path === e || e.includes(o.path)))
32
- return o;
33
- return null;
34
- }, B = (t, e) => d(t, e);
35
- export {
36
- r as addZero,
37
- w as arrToStr,
38
- j as changeTheme,
39
- g as clone,
40
- M as createDownloadLink,
41
- f as dateUtcToString,
42
- d as findMenuItem,
43
- B as getPageTitle,
44
- $ as isNewVersion,
45
- c as jsonParse,
46
- s as jsonString,
47
- T as loadScript,
48
- u as localGet,
49
- a as localSet,
50
- p as secToTime,
51
- E as sessionGet,
52
- L as sessionSet,
53
- y as strToArr,
54
- S as timeUtcToString,
55
- h as toByte
56
- };
1
+ //#region src/helpers/general.ts
2
+ var e = (e) => {
3
+ try {
4
+ return e ? JSON.parse(e) : null;
5
+ } catch (t) {
6
+ return console.warn(t), e;
7
+ }
8
+ }, t = (e) => typeof e == "object" ? JSON.stringify(e) : e, n = (n) => e(t(n)), r = (e) => {
9
+ let t = [
10
+ "B",
11
+ "KB",
12
+ "MB"
13
+ ];
14
+ if (e == 0) return "0 B";
15
+ let n = Math.floor(Math.log(e) / Math.log(1024));
16
+ return n > 1 && (n = 1), Math.round(e / 1024 ** n) + " " + t[n];
17
+ }, i = (e, t = {
18
+ year: "numeric",
19
+ month: "numeric",
20
+ day: "numeric"
21
+ }, n = []) => new Date(e).toLocaleDateString(n, t), a = (e, t = {
22
+ minute: "2-digit",
23
+ hour: "2-digit"
24
+ }, n = []) => new Date(e).toLocaleTimeString(n, t), o = (e) => e >= 10 ? e : `0${e}`, s = (e) => {
25
+ let t = Math.floor(e % 31536e3 % 2628e3 / 86400), n = Math.floor(e % (3600 * 24) / 3600), r = Math.floor(e % 3600 / 60), i = Math.floor(e % 60);
26
+ return `${t ? t + " days " : ""} ${o(n)}:${o(r)}:${o(i)}`;
27
+ }, c = (e) => e.join("."), l = (e) => e.split(".").map((e) => +e), u = (e, t = "file") => {
28
+ let n = document.createElement("a");
29
+ n.setAttribute("download", t), n.href = e, document.body.appendChild(n), n.click(), n.remove();
30
+ }, d = (e) => new Promise((t, n) => {
31
+ let r = document.createElement("script");
32
+ r.src = e, r.type = "text/javascript", r.async = !0, r.onload = () => t(r), r.onerror = () => n(/* @__PURE__ */ Error(`Ошибка загрузки скрипта: ${e}`)), document.head.appendChild(r);
33
+ }), f = (t) => (n, r) => r ? e(t.getItem(n)) : t.getItem(n), p = (e) => (n, r) => {
34
+ e && e.setItem(n, typeof r == "string" ? r : t(r));
35
+ }, m = f(localStorage), h = p(localStorage), g = f(sessionStorage), _ = p(sessionStorage), v = (e = "isShow") => {
36
+ let t = m(e);
37
+ return t || h(e, "true"), !t;
38
+ }, y = (e) => {
39
+ h("theme", e), document.documentElement.classList.remove("dark"), document.documentElement.classList.remove("light"), document.documentElement.classList.add(e);
40
+ }, b = (e, t) => {
41
+ if (!e) return null;
42
+ for (let n of e) if (!(t === "/" || n.path === "/") && (n.path === t || t.includes(n.path))) return n;
43
+ return null;
44
+ }, x = (e, t) => b(e, t);
45
+ //#endregion
46
+ export { o as addZero, c as arrToStr, y as changeTheme, n as clone, u as createDownloadLink, i as dateUtcToString, b as findMenuItem, x as getPageTitle, v as isNewVersion, e as jsonParse, t as jsonString, d as loadScript, m as localGet, h as localSet, s as secToTime, g as sessionGet, _ as sessionSet, l as strToArr, a as timeUtcToString, r as toByte };