vlite3 0.4.4 → 0.4.6

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.
@@ -19,29 +19,29 @@ function te(b) {
19
19
  u.value = {};
20
20
  }, O = (e) => e.when ? w(e.when, S()) : !0, D = (e) => w(e.disabled, S()), I = (e) => w(e.readonly, S()), P = (e) => {
21
21
  const l = C(e.name);
22
- let s = "";
23
- if (e.required && (l == null || l === "" || Array.isArray(l) && l.length === 0) && (s = `${e.label || e.name} is required`), !s && e.maxFileSize) {
22
+ let a = "";
23
+ if (e.required && (l == null || l === "" || Array.isArray(l) && l.length === 0) && (a = `${e.label || e.name} is required`), !a && e.maxFileSize) {
24
24
  const i = e.maxFileSize * 1024 * 1024;
25
25
  if (l != null && l !== "") {
26
26
  const n = Array.isArray(l) ? l : [l];
27
- for (const a of n) {
28
- const c = a instanceof File ? a.size : a?.fileSize || a?.file?.size || a?.size;
27
+ for (const s of n) {
28
+ const c = s instanceof File ? s.size : s?.fileSize || s?.file?.size || s?.size;
29
29
  if (c !== void 0 && c > i) {
30
- s = `${e.label || e.name} size must be less than ${e.maxFileSize}MB`;
30
+ a = `${e.label || e.name} size must be less than ${e.maxFileSize}MB`;
31
31
  break;
32
32
  }
33
33
  }
34
34
  }
35
35
  }
36
- if (!s && (e.type === "file" || e.type === "fileUploader") && (e.props?.multiple || e.maxFiles)) {
36
+ if (!a && (e.type === "file" || e.type === "fileUploader") && (e.props?.multiple || e.maxFiles)) {
37
37
  const i = e.maxFiles || e.props?.maxFiles;
38
- i && Array.isArray(l) && l.length > i && (s = `Maximum ${i} files allowed`);
38
+ i && Array.isArray(l) && l.length > i && (a = `Maximum ${i} files allowed`);
39
39
  }
40
- return !s && e.validation && (s = e.validation({
40
+ return !a && e.validation && (a = e.validation({
41
41
  value: l,
42
42
  values: t.value,
43
43
  isUpdate: F
44
- })), s ? u.value[e.name] = s : delete u.value[e.name], s;
44
+ })), a ? u.value[e.name] = a : delete u.value[e.name], a;
45
45
  }, $ = () => {
46
46
  A();
47
47
  let e = !0;
@@ -50,36 +50,34 @@ function te(b) {
50
50
  P(l) && (e = !1);
51
51
  }
52
52
  return e;
53
- }, R = (e, l, s) => {
53
+ }, R = (e, l, a) => {
54
54
  t.value = x(t.value, e, l), d.value = !0, delete u.value[e];
55
55
  const i = y.value.find((n) => n.name === e);
56
56
  if (i?.updateValues) {
57
57
  const n = i.updateValues({
58
58
  values: t.value,
59
- data: s,
59
+ data: a,
60
60
  isUpdate: F,
61
61
  updateError: N
62
62
  });
63
63
  n && typeof n == "object" && (t.value = { ...t.value, ...n });
64
64
  }
65
65
  }, G = async () => {
66
- const e = m(t.value), l = W(o, e), s = (a, c) => {
66
+ const e = m(t.value), l = W(o, e), a = (s, c) => {
67
67
  let r = null;
68
- return a instanceof File ? r = a : a && typeof a == "object" && a.file instanceof File && (r = a.file), {
69
- // Spread original item to keep any metadata like __typename
70
- ...typeof a == "object" && a !== null && !(a instanceof File) ? a : {},
71
- fileName: a?.fileName || r?.name || c.split("/").pop() || "unknown",
68
+ return s instanceof File ? r = s : s && typeof s == "object" && s.file instanceof File && (r = s.file), {
69
+ fileName: s?.fileName || r?.name || c.split("/").pop() || "unknown",
72
70
  fileUrl: c,
73
- fileType: a?.fileType || r?.type || "application/octet-stream",
74
- fileSize: a?.fileSize || r?.size || 0
71
+ fileType: s?.fileType || r?.type || "application/octet-stream",
72
+ fileSize: s?.fileSize || r?.size || 0
75
73
  };
76
- }, i = l.map(async (a) => {
77
- const { name: c, value: r, field: J } = a, k = J.returnFileObject === !0;
74
+ }, i = l.map(async (s) => {
75
+ const { name: c, value: r, field: J } = s, k = J.returnFileObject === !0;
78
76
  if (Array.isArray(r)) {
79
77
  const q = r.map(async (f) => {
80
78
  if (f instanceof File || f && typeof f == "object" && f.file instanceof File) {
81
79
  const z = await E(f, g);
82
- return z ? k ? s(f, z) : z : null;
80
+ return z ? k ? a(f, z) : z : null;
83
81
  }
84
82
  return f;
85
83
  }), p = await Promise.all(q);
@@ -88,22 +86,22 @@ function te(b) {
88
86
  if (r instanceof File || r && typeof r == "object" && r.file instanceof File) {
89
87
  const p = await E(r, g);
90
88
  if (p)
91
- return { name: c, value: k ? s(r, p) : p };
89
+ return { name: c, value: k ? a(r, p) : p };
92
90
  }
93
91
  return null;
94
92
  }
95
93
  });
96
- return (await Promise.all(i)).forEach((a) => {
97
- a && Object.assign(e, x(e, a.name, a.value));
94
+ return (await Promise.all(i)).forEach((s) => {
95
+ s && Object.assign(e, x(e, s.name, s.value));
98
96
  }), e;
99
97
  }, H = (e) => {
100
98
  const l = { ...e };
101
- for (const s of y.value)
102
- if (s.type === "customFields" && s.props?.schema) {
103
- const i = M(l, s.name);
99
+ for (const a of y.value)
100
+ if (a.type === "customFields" && a.props?.schema) {
101
+ const i = M(l, a.name);
104
102
  if (Array.isArray(i)) {
105
- const n = X(i, s.props.schema);
106
- Object.assign(l, x(l, s.name, n));
103
+ const n = X(i, a.props.schema);
104
+ Object.assign(l, x(l, a.name, n));
107
105
  }
108
106
  }
109
107
  return l;
@@ -1,93 +1,93 @@
1
1
  function k(e) {
2
2
  return !!e && typeof e == "object";
3
3
  }
4
- function p(e, n) {
5
- if (!n || !e) return;
6
- const r = n.split(".");
7
- let l = e;
8
- for (const t of r) {
9
- if (l == null) return;
10
- l = l[t];
4
+ function d(e, r) {
5
+ if (!r || !e) return;
6
+ const f = r.split(".");
7
+ let y = e;
8
+ for (const n of f) {
9
+ if (y == null) return;
10
+ y = y[n];
11
11
  }
12
- return l;
12
+ return y;
13
13
  }
14
- function m(e, n, r) {
15
- if (!n) return e;
16
- const l = n.split("."), t = { ...e };
17
- let o = t;
18
- for (let i = 0; i < l.length - 1; i++) {
19
- const c = l[i];
14
+ function v(e, r, f) {
15
+ if (!r) return e;
16
+ const y = r.split("."), n = { ...e };
17
+ let o = n;
18
+ for (let i = 0; i < y.length - 1; i++) {
19
+ const c = y[i];
20
20
  Array.isArray(o[c]) ? o[c] = [...o[c]] : o[c] = o[c] ? { ...o[c] } : {}, o = o[c];
21
21
  }
22
- return o[l[l.length - 1]] = r, t;
22
+ return o[y[y.length - 1]] = f, n;
23
23
  }
24
- function v(e, n) {
25
- return !k(n) || !n.name ? e : p(e, n.name) === void 0 && n.value !== void 0 ? m(e, n.name, n.value) : e;
24
+ function h(e, r) {
25
+ return !k(r) || !r.name ? e : d(e, r.name) === void 0 && r.value !== void 0 ? v(e, r.name, r.value) : e;
26
26
  }
27
- function E(e, n) {
28
- let r = n ? d(n) : {};
29
- const l = Array.isArray(e[0]) ? e.flat() : e;
30
- for (const t of l) {
31
- if (!t.name) continue;
32
- const o = t.mapFrom || t.name;
33
- let i = n ? p(n, o) : void 0;
27
+ function E(e, r) {
28
+ let f = r ? m(r) : {};
29
+ const y = Array.isArray(e[0]) ? e.flat() : e;
30
+ for (const n of y) {
31
+ if (!n.name) continue;
32
+ const o = n.mapFrom || n.name;
33
+ let i = r ? d(r, o) : void 0;
34
34
  if (i != null) {
35
- const c = t.valueKey || t.key;
35
+ const c = n.valueKey || n.key;
36
36
  c && (Array.isArray(i) ? i = i.map(
37
- (y) => y && typeof y == "object" ? p(y, c) : y
38
- ) : typeof i == "object" && (i = p(i, c))), t.format && (i = t.format(i, n || {}));
37
+ (u) => u && typeof u == "object" ? d(u, c) : u
38
+ ) : typeof i == "object" && (i = d(i, c))), n.format && (i = n.format(i, r || {}));
39
39
  }
40
40
  if (i === void 0) {
41
- if (t.mapFrom && n) {
42
- const c = p(n, t.name);
41
+ if (n.mapFrom && r) {
42
+ const c = d(r, n.name);
43
43
  c !== void 0 && (i = c);
44
44
  }
45
45
  if (i === void 0) {
46
- const c = typeof t.value == "function" ? t.value() : t.value;
47
- c !== void 0 && Object.assign(r, m(r, t.name, c));
46
+ const c = typeof n.value == "function" ? n.value() : n.value;
47
+ c !== void 0 && Object.assign(f, v(f, n.name, c));
48
48
  } else
49
- Object.assign(r, m(r, t.name, i));
49
+ Object.assign(f, v(f, n.name, i));
50
50
  } else
51
- Object.assign(r, m(r, t.name, i));
52
- r = v(r, t.addonLeft), r = v(r, t.addonRight);
51
+ Object.assign(f, v(f, n.name, i));
52
+ f = h(f, n.addonLeft), f = h(f, n.addonRight);
53
53
  }
54
- return r;
54
+ return f;
55
55
  }
56
- function O(e, n) {
57
- return e === void 0 ? !1 : typeof e == "boolean" ? e : typeof e == "function" ? e(n) : !1;
56
+ function O(e, r) {
57
+ return e === void 0 ? !1 : typeof e == "boolean" ? e : typeof e == "function" ? e(r) : !1;
58
58
  }
59
- function S(e, n) {
60
- return Array.isArray(e) ? e.filter((r) => r ? !n.every((t) => {
61
- const o = r[t.name];
59
+ function S(e, r) {
60
+ return Array.isArray(e) ? e.filter((f) => f ? !r.every((n) => {
61
+ const o = f[n.name];
62
62
  return o == null || o === "";
63
63
  }) : !1) : [];
64
64
  }
65
- function F(e, n) {
66
- const r = [], l = Array.isArray(e[0]) ? e.flat() : e;
67
- for (const t of l) {
68
- if (!t.name) continue;
69
- const o = t.type;
65
+ function F(e, r) {
66
+ const f = [], y = Array.isArray(e[0]) ? e.flat() : e;
67
+ for (const n of y) {
68
+ if (!n.name) continue;
69
+ const o = n.type;
70
70
  if (o === "file" || o === "avatarUpload" || o === "fileUploader") {
71
- const i = p(n, t.name);
72
- i && r.push({
73
- name: t.name,
71
+ const i = d(r, n.name);
72
+ i && f.push({
73
+ name: n.name,
74
74
  value: i,
75
75
  type: o,
76
- field: t
76
+ field: n
77
77
  });
78
78
  }
79
- if (o === "customFields" && t.props?.schema) {
80
- const i = p(n, t.name);
79
+ if (o === "customFields" && n.props?.schema) {
80
+ const i = d(r, n.name);
81
81
  if (Array.isArray(i)) {
82
- const y = t.props.schema.filter(
82
+ const u = n.props.schema.filter(
83
83
  (s) => s.type === "file" || s.type === "avatarUpload" || s.type === "fileUploader"
84
84
  );
85
- y.length > 0 && i.forEach((s, f) => {
86
- y.forEach((a) => {
87
- const u = s?.[a.name];
88
- u && r.push({
89
- name: `${t.name}.${f}.${a.name}`,
90
- value: u,
85
+ u.length > 0 && i.forEach((s, t) => {
86
+ u.forEach((a) => {
87
+ const l = s?.[a.name];
88
+ l && f.push({
89
+ name: `${n.name}.${t}.${a.name}`,
90
+ value: l,
91
91
  type: a.type,
92
92
  field: a
93
93
  });
@@ -96,64 +96,70 @@ function F(e, n) {
96
96
  }
97
97
  }
98
98
  }
99
- return r;
99
+ return f;
100
100
  }
101
- function d(e) {
101
+ function m(e) {
102
102
  if (e === null || typeof e != "object") return e;
103
103
  if (e instanceof Date) return new Date(e.getTime());
104
104
  if (e instanceof File) return e;
105
- if (Array.isArray(e)) return e.map((r) => d(r));
106
- const n = {};
107
- for (const r in e)
108
- Object.prototype.hasOwnProperty.call(e, r) && (n[r] = d(e[r]));
109
- return n;
105
+ if (Array.isArray(e)) return e.map((f) => m(f));
106
+ const r = {};
107
+ for (const f in e)
108
+ Object.prototype.hasOwnProperty.call(e, f) && (r[f] = m(e[f]));
109
+ return r;
110
110
  }
111
111
  function x(e) {
112
112
  return e ? typeof e == "object" && (typeof e.render == "function" || typeof e.setup == "function" || e.__name !== void 0 || e.name !== void 0) : !1;
113
113
  }
114
- function g(e, n, r, l) {
115
- const t = r === void 0 && l === void 0, o = t ? d(e) : {}, i = Array.isArray(n[0]) ? n.flat() : n, c = r || [], y = l || [];
114
+ function g(e, r, f, y) {
115
+ const n = f === void 0 && y === void 0, o = n ? m(e) : {}, i = Array.isArray(r[0]) ? r.flat() : r, c = f || [], u = y || [];
116
116
  for (const s of i) {
117
117
  if (!s.name) continue;
118
- let f = p(e, s.name);
119
- if (f === void 0) continue;
120
- if (s.type === "customFields" && s.props?.schema && Array.isArray(f)) {
118
+ let t = d(e, s.name);
119
+ if (t === void 0) continue;
120
+ if (t = m(t), s.type === "customFields" && s.props?.schema && Array.isArray(t)) {
121
121
  const A = s.props.schema;
122
- f = f.map((h) => g(h, A, r, l));
122
+ t = t.map((p) => g(p, A, f, y));
123
123
  }
124
124
  let a = !1;
125
- s.transform && (f = s.transform(f, e), a = !0);
126
- const u = s.mapTo || s.name;
127
- u !== s.name && (a = !0, t && !s.name.includes(".") && delete o[s.name]), !t || a ? Object.assign(o, m(o, u, f)) : Object.assign(o, m(o, s.name, f));
125
+ s.transform && (t = s.transform(t, e), a = !0);
126
+ const l = s.mapTo || s.name;
127
+ l !== s.name && (a = !0, n && !s.name.includes(".") && delete o[s.name]), !n || a ? Object.assign(o, v(o, l, t)) : Object.assign(o, v(o, s.name, t));
128
128
  }
129
129
  if (c.length > 0) {
130
- const s = (f, a) => {
131
- if (!(!f || typeof f != "object") && !(!a || typeof a != "object"))
132
- if (Array.isArray(f) && Array.isArray(a))
133
- f.forEach((u, A) => {
134
- a[A] && s(u, a[A]);
130
+ const s = (t, a) => {
131
+ if (!(!t || typeof t != "object") && !(!a || typeof a != "object"))
132
+ if (Array.isArray(t) && Array.isArray(a)) {
133
+ for (const l of c) {
134
+ const A = t.find((p) => p && typeof p == "object" && p[l] !== void 0)?.[l];
135
+ A !== void 0 && a.forEach((p) => {
136
+ p && typeof p == "object" && p[l] === void 0 && (p[l] = m(A));
137
+ });
138
+ }
139
+ t.forEach((l, A) => {
140
+ a[A] && s(l, a[A]);
135
141
  });
136
- else {
137
- for (const u of c)
138
- f[u] !== void 0 && a[u] === void 0 && (a[u] = d(f[u]));
139
- for (const u in a)
140
- typeof a[u] == "object" && a[u] !== null && typeof f[u] == "object" && f[u] !== null && s(f[u], a[u]);
142
+ } else {
143
+ for (const l of c)
144
+ t[l] !== void 0 && a[l] === void 0 && (a[l] = m(t[l]));
145
+ for (const l in a)
146
+ typeof a[l] == "object" && typeof t[l] == "object" && s(t[l], a[l]);
141
147
  }
142
148
  };
143
- for (const f of c)
144
- e[f] !== void 0 && o[f] === void 0 && (o[f] = d(e[f]));
149
+ for (const t of c)
150
+ e[t] !== void 0 && o[t] === void 0 && (o[t] = m(e[t]));
145
151
  s(e, o);
146
152
  }
147
- if (y.length > 0) {
148
- const s = (f) => {
149
- if (!(!f || typeof f != "object"))
150
- if (Array.isArray(f))
151
- f.forEach(s);
153
+ if (u.length > 0) {
154
+ const s = (t) => {
155
+ if (!(!t || typeof t != "object"))
156
+ if (Array.isArray(t))
157
+ t.forEach(s);
152
158
  else {
153
- for (const a of y)
154
- delete f[a];
155
- for (const a in f)
156
- s(f[a]);
159
+ for (const a of u)
160
+ delete t[a];
161
+ for (const a in t)
162
+ s(t[a]);
157
163
  }
158
164
  };
159
165
  s(o);
@@ -163,12 +169,12 @@ function g(e, n, r, l) {
163
169
  export {
164
170
  g as cleanSubmitValues,
165
171
  F as collectFileFields,
166
- d as deepClone,
172
+ m as deepClone,
167
173
  O as evaluateConditional,
168
174
  S as filterNullCustomFields,
169
- p as getNestedValue,
175
+ d as getNestedValue,
170
176
  E as initializeFormValues,
171
177
  k as isAddonObject,
172
178
  x as isComponent,
173
- m as setNestedValue
179
+ v as setNestedValue
174
180
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "private": false,
4
4
  "description": "A Vue 3 UI component library built with Tailwind CSS.",
5
5
  "license": "MIT",
6
- "version": "0.4.4",
6
+ "version": "0.4.6",
7
7
  "type": "module",
8
8
  "main": "index.js",
9
9
  "module": "index.js",