vft 0.0.342 → 0.0.343

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,231 +1,237 @@
1
- import { isDef as G, isFunction as j, isString as A, isObject as V, isArray as I, deepMerge as it, findDifferentValuesForObj as nt, isNullOrUndefined as H, isEmpty as rt, isEmptyObject as lt } from "@vft/utils";
2
- import { formatToDate as J } from "@vft/utils/date";
3
- import { get as st, cloneDeep as O, uniqBy as ot, isEqual as ft, set as W } from "lodash-es";
4
- import { unref as n, toRaw as S, nextTick as P } from "vue";
5
- import { isInput as ct, FormCompEnum as x, isDatePicker as at } from "../component-map.js";
1
+ import { isDef as H, isFunction as m, isString as A, isObject as E, isArray as V, deepMerge as it, findDifferentValuesForObj as nt, isNullOrUndefined as J, isEmpty as lt, isEmptyObject as st } from "@vft/utils";
2
+ import { formatToDate as P } from "@vft/utils/date";
3
+ import { get as rt, cloneDeep as I, uniqBy as ot, isEqual as at, set as W } from "lodash-es";
4
+ import { unref as n, toRaw as x, nextTick as Q } from "vue";
5
+ import { isInput as ft, FormCompEnum as S, isDatePicker as ct } from "../component-map.js";
6
6
  import { handleInputNumberValue as ut } from "./helper.js";
7
- function Q(h, y) {
8
- const { show: s, ifShow: f } = h;
9
- let p = !0, a = !0;
10
- return typeof s == "boolean" ? p = s : typeof s == "function" && (p = s({
7
+ function _(h, v) {
8
+ const { show: o, ifShow: f } = h;
9
+ let p = !0, c = !0;
10
+ return typeof o == "boolean" ? p = o : typeof o == "function" && (p = o({
11
11
  field: h.field,
12
- model: y,
12
+ model: v,
13
13
  values: {
14
- ...y
14
+ ...v
15
15
  },
16
16
  schema: h
17
- })), typeof f == "boolean" ? a = f : typeof f == "function" && (a = f({
17
+ })), typeof f == "boolean" ? c = f : typeof f == "function" && (c = f({
18
18
  field: h.field,
19
- model: y,
19
+ model: v,
20
20
  values: {
21
- ...y
21
+ ...v
22
22
  },
23
23
  schema: h
24
- })), p && a;
24
+ })), p && c;
25
25
  }
26
- function dt(h, y = {}) {
27
- const s = /^\[(.+)\]$/;
28
- if (s.test(h)) {
29
- const f = h.match(s);
26
+ function dt(h, v = {}) {
27
+ const o = /^\[(.+)\]$/;
28
+ if (o.test(h)) {
29
+ const f = h.match(o);
30
30
  if (f && f[1]) {
31
31
  const p = f[1].split(",");
32
32
  if (!p.length)
33
33
  return;
34
- const a = [];
35
- return p.forEach((v, D) => {
36
- W(a, D, y[v.trim()]);
37
- }), a.filter(Boolean).length ? a : void 0;
34
+ const c = [];
35
+ return p.forEach((y, B) => {
36
+ W(c, B, v[y.trim()]);
37
+ }), c.filter(Boolean).length ? c : void 0;
38
38
  }
39
39
  }
40
40
  }
41
- function ht(h, y = {}) {
42
- const s = /^\{(.+)\}$/;
43
- if (s.test(h)) {
44
- const f = h.match(s);
41
+ function ht(h, v = {}) {
42
+ const o = /^\{(.+)\}$/;
43
+ if (o.test(h)) {
44
+ const f = h.match(o);
45
45
  if (f && f[1]) {
46
46
  const p = f[1].split(",");
47
47
  if (!p.length)
48
48
  return;
49
- const a = {};
50
- return p.forEach((v) => {
51
- W(a, v.trim(), y[v.trim()]);
52
- }), Object.values(a).filter(Boolean).length ? a : void 0;
49
+ const c = {};
50
+ return p.forEach((y) => {
51
+ W(c, y.trim(), v[y.trim()]);
52
+ }), Object.values(c).filter(Boolean).length ? c : void 0;
53
53
  }
54
54
  }
55
55
  }
56
- function Dt({
56
+ function wt({
57
57
  emit: h,
58
- getProps: y,
59
- formModel: s,
58
+ getProps: v,
59
+ formModel: o,
60
60
  getSchema: f,
61
61
  defaultValueRef: p,
62
- formElRef: a,
63
- schemaRef: v,
64
- handleFormValues: D,
65
- initValues: _
62
+ formElRef: c,
63
+ schemaRef: y,
64
+ handleFormValues: B,
65
+ initValues: T
66
66
  }) {
67
67
  async function X(t) {
68
- const { resetFunc: i, submitOnReset: l } = n(y);
69
- i && j(i) && await i();
70
- const r = n(a);
71
- if (r) {
68
+ const { resetFunc: i, submitOnReset: s } = n(v);
69
+ i && m(i) && await i();
70
+ const l = n(c);
71
+ if (l) {
72
72
  if (t?.length)
73
- return r.resetFields(t);
74
- Object.keys(s).forEach((c) => {
75
- const o = n(f).find((u) => u.field === c), e = O(p.value[c]);
76
- s[c] = ct(o?.type) ? e || "" : e;
77
- }), P(() => B()), h("reset", S(s)), l && await $();
73
+ return l.resetFields(t);
74
+ Object.keys(o).forEach((a) => {
75
+ const r = n(f).find((u) => u.field === a), e = I(p.value[a]);
76
+ o[a] = ft(r?.type) ? e || "" : e;
77
+ }), Q(() => C()), h("reset", x(o)), s && await U();
78
78
  }
79
79
  }
80
- async function m(t, i = !0) {
81
- const l = n(f).map((e) => e.field).filter(Boolean), r = ".", c = l.filter(
82
- (e) => String(e).indexOf(r) >= 0
83
- ), o = [];
84
- l.forEach((e) => {
80
+ async function q(t, i = !0) {
81
+ const s = n(f).map((e) => e.field).filter(Boolean), l = ".", a = s.filter(
82
+ (e) => String(e).indexOf(l) >= 0
83
+ ), r = [];
84
+ s.forEach((e) => {
85
85
  const u = n(f).find((d) => d.field === e);
86
- let b = st(t, e);
87
- const C = Reflect.has(t, e);
86
+ let b = rt(t, e);
87
+ const j = Reflect.has(t, e);
88
88
  b = ut(u?.type, b);
89
- const { componentProps: U } = u || {};
90
- let w = U;
91
- typeof U == "function" && (w = w({ formModel: n(s) }));
92
- const z = dt(e, t) || ht(e, t);
93
- if (C || z) {
94
- const d = z || b;
89
+ const { componentProps: z } = u || {};
90
+ let D = z;
91
+ typeof z == "function" && (D = D({ formModel: n(o) }));
92
+ const G = dt(e, t) || ht(e, t);
93
+ if (j || G) {
94
+ const d = G || b;
95
95
  if (M(e))
96
96
  if (Array.isArray(d)) {
97
97
  const F = [];
98
- for (const E of d)
99
- F.push(E ? J(E) : null);
100
- n(s)[e] = F;
98
+ for (const w of d)
99
+ F.push(w ? P(w) : null);
100
+ n(o)[e] = F;
101
101
  } else
102
- n(s)[e] = d ? w?.valueFormat ? d : J(d) : null;
102
+ n(o)[e] = d ? D?.valueFormat ? d : P(d) : null;
103
103
  else
104
- n(s)[e] = d;
105
- w?.onChange && w?.onChange(d), o.push(e);
104
+ n(o)[e] = d;
105
+ D?.onChange && D?.onChange(d), r.push(e);
106
106
  } else
107
- c.forEach((d) => {
107
+ a.forEach((d) => {
108
108
  try {
109
- const F = d.split(".").reduce((E, et) => E[et], t);
110
- G(F) && (n(s)[d] = n(F), o.push(d));
109
+ const F = d.split(".").reduce((w, et) => w[et], t);
110
+ H(F) && (n(o)[d] = n(F), r.push(d));
111
111
  } catch {
112
- G(p.value[d]) && (n(s)[d] = O(
112
+ H(p.value[d]) && (n(o)[d] = I(
113
113
  n(p.value[d])
114
114
  ));
115
115
  }
116
116
  });
117
- }), i && P(async () => {
118
- await q(o).catch((e) => {
117
+ }), i && Q(async () => {
118
+ await N(r).catch((e) => {
119
119
  });
120
120
  });
121
121
  }
122
122
  async function Y(t) {
123
- const i = O(n(f));
123
+ const i = I(n(f));
124
124
  if (!t)
125
125
  return;
126
- let l = A(t) ? [t] : t;
127
- A(t) && (l = [t]);
128
- for (const r of l)
129
- Z(r, i);
130
- v.value = i;
126
+ let s = A(t) ? [t] : t;
127
+ A(t) && (s = [t]);
128
+ for (const l of s)
129
+ Z(l, i);
130
+ y.value = i;
131
131
  }
132
132
  function Z(t, i) {
133
133
  if (A(t)) {
134
- const l = i.findIndex((r) => r.field === t);
135
- l !== -1 && (delete s[t], i.splice(l, 1));
134
+ const s = i.findIndex((l) => l.field === t);
135
+ s !== -1 && (delete o[t], i.splice(s, 1));
136
136
  }
137
137
  }
138
- async function L(t, i, l = !1) {
139
- const r = O(n(f)), c = r.findIndex((e) => e.field === i), o = V(t) ? [t] : t;
140
- if (!i || c === -1 || l) {
141
- l ? r.unshift(...o) : r.push(...o), v.value = r, g(t);
138
+ async function L(t, i, s = !1) {
139
+ const l = I(n(f)), a = l.findIndex((e) => e.field === i), r = E(t) ? [t] : t;
140
+ if (!i || a === -1 || s) {
141
+ s ? l.unshift(...r) : l.push(...r), y.value = l, O(t);
142
142
  return;
143
143
  }
144
- c !== -1 && r.splice(c + 1, 0, ...o), g(t), v.value = r;
144
+ a !== -1 && l.splice(a + 1, 0, ...r), O(t), y.value = l;
145
145
  }
146
146
  async function K(t) {
147
147
  let i = [];
148
- if (V(t) && i.push(t), I(t) && (i = [...t]), !i.every(
149
- (r) => r.type === x.DIVIDER || Reflect.has(r, "field") && r.field
148
+ if (E(t) && i.push(t), V(t) && (i = [...t]), !i.every(
149
+ (l) => l.type === S.DIVIDER || Reflect.has(l, "field") && l.field
150
150
  )) {
151
151
  console.error(
152
152
  "All children of the form Schema array that need to be updated must contain the `field` field"
153
153
  );
154
154
  return;
155
155
  }
156
- v.value = i;
156
+ y.value = i;
157
157
  }
158
158
  async function R(t) {
159
159
  let i = [];
160
- if (V(t) && i.push(t), I(t) && (i = [...t]), !i.every(
161
- (o) => o.type === x.DIVIDER || Reflect.has(o, "field") && o.field
160
+ if (E(t) && i.push(t), V(t) && (i = [...t]), !i.every(
161
+ (r) => r.type === S.DIVIDER || Reflect.has(r, "field") && r.field
162
162
  )) {
163
163
  console.error(
164
164
  "All children of the form Schema array that need to be updated must contain the `field` field"
165
165
  );
166
166
  return;
167
167
  }
168
- const r = [], c = [];
169
- n(f).forEach((o) => {
168
+ const l = [], a = [];
169
+ n(f).forEach((r) => {
170
170
  let e;
171
171
  if (i.forEach((u) => {
172
- o.field === u.field && (e = u), u.defaultValue && u.field && r.push(u.field);
173
- }), e !== void 0 && o.field === e.field) {
174
- const u = it(o, e);
175
- c.push(u);
172
+ r.field === u.field && (e = u), u.defaultValue && u.field && l.push(u.field);
173
+ }), e !== void 0 && r.field === e.field) {
174
+ const u = it(r, e);
175
+ a.push(u);
176
176
  } else
177
- c.push(o);
178
- }), g(c, r), v.value = ot(c, "field");
177
+ a.push(r);
178
+ }), O(a, l), y.value = ot(a, "field");
179
179
  }
180
- function g(t, i, l = !0) {
181
- if (I(i) && i?.length === 0)
180
+ function O(t, i, s = !0) {
181
+ if (V(i) && i?.length === 0)
182
182
  return;
183
- let r = [];
184
- V(t) && r.push(t), I(t) && (r = [...t]);
185
- const c = {}, o = T();
186
- r.forEach((e) => {
187
- e.type !== x.DIVIDER && Reflect.has(e, "field") && e.field && !H(e.defaultValue) && (!(e.field in o) || H(o[e.field]) || rt(o[e.field])) && (c[e.field] = e.defaultValue);
188
- }), lt(c) || m(c, l);
183
+ let l = [];
184
+ E(t) && l.push(t), V(t) && (l = [...t]);
185
+ const a = {}, r = g();
186
+ l.forEach((e) => {
187
+ e.type !== S.DIVIDER && Reflect.has(e, "field") && e.field && !J(e.defaultValue) && (!(e.field in r) || J(r[e.field]) || lt(r[e.field])) && (a[e.field] = e.defaultValue);
188
+ }), st(a) || q(a, s);
189
189
  }
190
- function T() {
191
- return n(a) ? D(S(n(s))) : {};
190
+ function g(t = fasle) {
191
+ if (!n(c)) return {};
192
+ const s = B(x(n(o)));
193
+ if (t)
194
+ return s;
195
+ const l = n(f).filter((r) => _(r, n(o))).map((r) => r.field).filter(Boolean), a = {};
196
+ return l.forEach((r) => {
197
+ r in s && (a[r] = s[r]);
198
+ }), a;
192
199
  }
193
200
  function k(t) {
194
- return n(a) ? S(n(s))[t] : {};
201
+ return n(c) ? x(n(o))[t] : {};
195
202
  }
196
203
  function M(t) {
197
- return n(f).some((i) => i.field === t ? at(i.type) : !1);
198
- }
199
- async function q(t) {
200
- return t || (t = n(f).filter((l) => Q(l, n(s))).map((l) => l.field).filter(Boolean)), n(a)?.validateField(t);
204
+ return n(f).some((i) => i.field === t ? ct(i.type) : !1);
201
205
  }
202
206
  async function N(t) {
203
- return t || (t = n(f).filter((l) => Q(l, n(s))).map((l) => l.field).filter(Boolean)), await n(a)?.validate(() => {
207
+ return t || (t = n(f).filter((s) => _(s, n(o))).map((s) => s.field).filter(Boolean)), n(c)?.validateField(t);
208
+ }
209
+ async function $(t) {
210
+ return t || (t = n(f).filter((s) => _(s, n(o))).map((s) => s.field).filter(Boolean)), await n(c)?.validate(() => {
204
211
  }, t);
205
212
  }
206
- async function B(t) {
207
- await n(a)?.clearValidate(t);
213
+ async function C(t) {
214
+ await n(c)?.clearValidate(t);
208
215
  }
209
216
  async function tt(t, i) {
210
- await n(a)?.scrollToField(t, i);
217
+ await n(c)?.scrollToField(t, i);
211
218
  }
212
- async function $(t) {
213
- const { autoCleanErrorMessage: i, watchDataIsChange: l } = n(y);
214
- t && t.preventDefault(), i && await B();
215
- const { submitFunc: r, beforeSubmitFunc: c } = n(y);
216
- if (c && j(c) && await c(), r && j(r)) {
217
- await r();
219
+ async function U(t) {
220
+ const { autoCleanErrorMessage: i, watchDataIsChange: s } = n(v);
221
+ t && t.preventDefault(), i && await C();
222
+ const { submitFunc: l, beforeSubmitFunc: a } = n(v);
223
+ if (a && m(a) && await a(), l && m(l)) {
224
+ await l();
218
225
  return;
219
226
  }
220
- if (n(a))
227
+ if (n(c))
221
228
  try {
222
- const e = await N();
223
- if (!e)
229
+ if (!await $())
224
230
  return;
225
- const u = D(e);
226
- if (l) {
227
- const b = ft(_.value, u), C = nt(_.value, u);
228
- h("submit", u, !b, C);
231
+ const u = g();
232
+ if (s) {
233
+ const b = at(T.value, u), j = nt(T.value, u);
234
+ h("submit", u, !b, j);
229
235
  } else
230
236
  h("submit", u);
231
237
  } catch (e) {
@@ -235,21 +241,21 @@ function Dt({
235
241
  }
236
242
  }
237
243
  return {
238
- handleSubmit: $,
239
- clearValidate: B,
240
- validate: N,
241
- validateField: q,
242
- getFieldsValue: T,
244
+ handleSubmit: U,
245
+ clearValidate: C,
246
+ validate: $,
247
+ validateField: N,
248
+ getFieldsValue: g,
243
249
  updateSchema: R,
244
250
  resetSchema: K,
245
251
  appendSchemaByField: L,
246
252
  removeSchemaByField: Y,
247
253
  resetFields: X,
248
- setFieldsValue: m,
254
+ setFieldsValue: q,
249
255
  scrollToField: tt,
250
256
  getFieldValue: k
251
257
  };
252
258
  }
253
259
  export {
254
- Dt as useFormEvents
260
+ wt as useFormEvents
255
261
  };
@@ -1,6 +1,6 @@
1
1
  declare const _default: {
2
2
  "name": "vft",
3
- "version": "0.0.342",
3
+ "version": "0.0.343",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "es/index.js",
@@ -1,4 +1,4 @@
1
- const o = "0.0.342";
1
+ const o = "0.0.343";
2
2
  export {
3
3
  o as version
4
4
  };
@@ -24,12 +24,12 @@ export declare const VftButton: import("vft/es/utils").SFCWithInstall<{
24
24
  size: {
25
25
  type: import("vue").PropType<import("../types").ComponentSize>;
26
26
  };
27
- icon: {
28
- type: import("vue").PropType<string | import("vft/es/vft").IconProps>;
29
- };
30
27
  dark: {
31
28
  type: import("vue").PropType<boolean>;
32
29
  };
30
+ icon: {
31
+ type: import("vue").PropType<string | import("vft/es/vft").IconProps>;
32
+ };
33
33
  loading: {
34
34
  type: import("vue").PropType<boolean>;
35
35
  };
@@ -114,12 +114,12 @@ export declare const VftButton: import("vft/es/utils").SFCWithInstall<{
114
114
  size: {
115
115
  type: import("vue").PropType<import("../types").ComponentSize>;
116
116
  };
117
- icon: {
118
- type: import("vue").PropType<string | import("vft/es/vft").IconProps>;
119
- };
120
117
  dark: {
121
118
  type: import("vue").PropType<boolean>;
122
119
  };
120
+ icon: {
121
+ type: import("vue").PropType<string | import("vft/es/vft").IconProps>;
122
+ };
123
123
  loading: {
124
124
  type: import("vue").PropType<boolean>;
125
125
  };
@@ -199,12 +199,12 @@ export declare const VftButton: import("vft/es/utils").SFCWithInstall<{
199
199
  size: {
200
200
  type: import("vue").PropType<import("../types").ComponentSize>;
201
201
  };
202
- icon: {
203
- type: import("vue").PropType<string | import("vft/es/vft").IconProps>;
204
- };
205
202
  dark: {
206
203
  type: import("vue").PropType<boolean>;
207
204
  };
205
+ icon: {
206
+ type: import("vue").PropType<string | import("vft/es/vft").IconProps>;
207
+ };
208
208
  loading: {
209
209
  type: import("vue").PropType<boolean>;
210
210
  };
@@ -32,10 +32,10 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
32
32
  }>>> & Readonly<{
33
33
  "onUpdate:error"?: ((val: string) => any) | undefined;
34
34
  }>, {
35
- required: boolean;
36
35
  labelWidth: string | number;
37
36
  inlineMessage: string | boolean;
38
37
  showMessage: boolean;
38
+ required: boolean;
39
39
  hideLabel: boolean;
40
40
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
41
41
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;