vft 0.0.340 → 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.
- package/es/components/button/index.d.ts +9 -9
- package/es/components/form/form-item.vue.d.ts +1 -1
- package/es/components/form/form.vue.d.ts +1 -1
- package/es/components/form/form.vue2.js +10 -10
- package/es/components/form/index.d.ts +33 -33
- package/es/components/popconfirm/index.d.ts +15 -15
- package/es/components/popconfirm/popconfirm.vue.d.ts +1 -1
- package/es/components/super-form/index.d.ts +3 -3
- package/es/components/super-form/super-form.vue.d.ts +1 -1
- package/es/components/super-form/types.d.ts +1 -1
- package/es/components/super-form/use/use-form-events.d.ts +1 -1
- package/es/components/super-form/use/use-form-events.js +136 -126
- package/es/package.json.d.ts +1 -1
- package/es/package.json.js +1 -1
- package/lib/components/button/index.d.ts +9 -9
- package/lib/components/form/form-item.vue.d.ts +1 -1
- package/lib/components/form/form.vue.d.ts +1 -1
- package/lib/components/form/form.vue2.cjs +1 -1
- package/lib/components/form/index.d.ts +33 -33
- package/lib/components/popconfirm/index.d.ts +15 -15
- package/lib/components/popconfirm/popconfirm.vue.d.ts +1 -1
- package/lib/components/super-form/index.d.ts +3 -3
- package/lib/components/super-form/super-form.vue.d.ts +1 -1
- package/lib/components/super-form/types.d.ts +1 -1
- package/lib/components/super-form/use/use-form-events.cjs +1 -1
- package/lib/components/super-form/use/use-form-events.d.ts +1 -1
- package/lib/package.json.cjs +1 -1
- package/lib/package.json.d.ts +1 -1
- package/package.json +2 -2
- package/web-types.json +1 -1
|
@@ -1,227 +1,237 @@
|
|
|
1
|
-
import { isDef as
|
|
2
|
-
import { formatToDate as
|
|
3
|
-
import { get as rt, cloneDeep as
|
|
4
|
-
import { unref as n, toRaw as
|
|
5
|
-
import { isInput as ft, FormCompEnum as
|
|
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
|
|
8
|
-
const { show:
|
|
9
|
-
let p = !0,
|
|
10
|
-
return typeof
|
|
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:
|
|
12
|
+
model: v,
|
|
13
13
|
values: {
|
|
14
|
-
...
|
|
14
|
+
...v
|
|
15
15
|
},
|
|
16
16
|
schema: h
|
|
17
|
-
})), typeof
|
|
17
|
+
})), typeof f == "boolean" ? c = f : typeof f == "function" && (c = f({
|
|
18
18
|
field: h.field,
|
|
19
|
-
model:
|
|
19
|
+
model: v,
|
|
20
20
|
values: {
|
|
21
|
-
...
|
|
21
|
+
...v
|
|
22
22
|
},
|
|
23
23
|
schema: h
|
|
24
|
-
})), p &&
|
|
24
|
+
})), p && c;
|
|
25
25
|
}
|
|
26
|
-
function dt(h,
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
const p =
|
|
26
|
+
function dt(h, v = {}) {
|
|
27
|
+
const o = /^\[(.+)\]$/;
|
|
28
|
+
if (o.test(h)) {
|
|
29
|
+
const f = h.match(o);
|
|
30
|
+
if (f && f[1]) {
|
|
31
|
+
const p = f[1].split(",");
|
|
32
32
|
if (!p.length)
|
|
33
33
|
return;
|
|
34
|
-
const
|
|
35
|
-
return p.forEach((
|
|
36
|
-
W(
|
|
37
|
-
}),
|
|
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,
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
46
|
-
const p =
|
|
41
|
+
function ht(h, v = {}) {
|
|
42
|
+
const o = /^\{(.+)\}$/;
|
|
43
|
+
if (o.test(h)) {
|
|
44
|
+
const f = h.match(o);
|
|
45
|
+
if (f && f[1]) {
|
|
46
|
+
const p = f[1].split(",");
|
|
47
47
|
if (!p.length)
|
|
48
48
|
return;
|
|
49
|
-
const
|
|
50
|
-
return p.forEach((
|
|
51
|
-
W(
|
|
52
|
-
}), Object.values(
|
|
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
|
|
56
|
+
function wt({
|
|
57
57
|
emit: h,
|
|
58
|
-
getProps:
|
|
59
|
-
formModel:
|
|
60
|
-
getSchema:
|
|
58
|
+
getProps: v,
|
|
59
|
+
formModel: o,
|
|
60
|
+
getSchema: f,
|
|
61
61
|
defaultValueRef: p,
|
|
62
|
-
formElRef:
|
|
63
|
-
schemaRef:
|
|
64
|
-
handleFormValues:
|
|
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: s } = n(
|
|
69
|
-
i &&
|
|
70
|
-
const l = n(
|
|
68
|
+
const { resetFunc: i, submitOnReset: s } = n(v);
|
|
69
|
+
i && m(i) && await i();
|
|
70
|
+
const l = n(c);
|
|
71
71
|
if (l) {
|
|
72
72
|
if (t?.length)
|
|
73
73
|
return l.resetFields(t);
|
|
74
|
-
Object.keys(
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
}),
|
|
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
|
|
81
|
-
const s = n(
|
|
80
|
+
async function q(t, i = !0) {
|
|
81
|
+
const s = n(f).map((e) => e.field).filter(Boolean), l = ".", a = s.filter(
|
|
82
82
|
(e) => String(e).indexOf(l) >= 0
|
|
83
|
-
),
|
|
83
|
+
), r = [];
|
|
84
84
|
s.forEach((e) => {
|
|
85
|
-
const u = n(
|
|
85
|
+
const u = n(f).find((d) => d.field === e);
|
|
86
86
|
let b = rt(t, e);
|
|
87
|
-
const
|
|
87
|
+
const j = Reflect.has(t, e);
|
|
88
88
|
b = ut(u?.type, b);
|
|
89
|
-
const { componentProps:
|
|
90
|
-
let
|
|
91
|
-
typeof
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
94
|
-
const d =
|
|
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
|
|
99
|
-
F.push(
|
|
100
|
-
n(
|
|
98
|
+
for (const w of d)
|
|
99
|
+
F.push(w ? P(w) : null);
|
|
100
|
+
n(o)[e] = F;
|
|
101
101
|
} else
|
|
102
|
-
n(
|
|
102
|
+
n(o)[e] = d ? D?.valueFormat ? d : P(d) : null;
|
|
103
103
|
else
|
|
104
|
-
n(
|
|
105
|
-
|
|
104
|
+
n(o)[e] = d;
|
|
105
|
+
D?.onChange && D?.onChange(d), r.push(e);
|
|
106
106
|
} else
|
|
107
|
-
|
|
107
|
+
a.forEach((d) => {
|
|
108
108
|
try {
|
|
109
|
-
const F = d.split(".").reduce((
|
|
110
|
-
|
|
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
|
-
|
|
112
|
+
H(p.value[d]) && (n(o)[d] = I(
|
|
113
113
|
n(p.value[d])
|
|
114
114
|
));
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
|
-
}), i &&
|
|
118
|
-
await
|
|
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 =
|
|
123
|
+
const i = I(n(f));
|
|
124
124
|
if (!t)
|
|
125
125
|
return;
|
|
126
126
|
let s = A(t) ? [t] : t;
|
|
127
127
|
A(t) && (s = [t]);
|
|
128
128
|
for (const l of s)
|
|
129
129
|
Z(l, i);
|
|
130
|
-
|
|
130
|
+
y.value = i;
|
|
131
131
|
}
|
|
132
132
|
function Z(t, i) {
|
|
133
133
|
if (A(t)) {
|
|
134
134
|
const s = i.findIndex((l) => l.field === t);
|
|
135
|
-
s !== -1 && (delete
|
|
135
|
+
s !== -1 && (delete o[t], i.splice(s, 1));
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
async function L(t, i, s = !1) {
|
|
139
|
-
const l =
|
|
140
|
-
if (!i ||
|
|
141
|
-
s ? l.unshift(...
|
|
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
|
-
|
|
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 (
|
|
149
|
-
(l) => l.type ===
|
|
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
|
-
|
|
156
|
+
y.value = i;
|
|
157
157
|
}
|
|
158
158
|
async function R(t) {
|
|
159
159
|
let i = [];
|
|
160
|
-
if (
|
|
161
|
-
(
|
|
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 l = [],
|
|
169
|
-
n(
|
|
168
|
+
const l = [], a = [];
|
|
169
|
+
n(f).forEach((r) => {
|
|
170
170
|
let e;
|
|
171
171
|
if (i.forEach((u) => {
|
|
172
|
-
|
|
173
|
-
}), e !== void 0 &&
|
|
174
|
-
const u = it(
|
|
175
|
-
|
|
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
|
-
|
|
178
|
-
}),
|
|
177
|
+
a.push(r);
|
|
178
|
+
}), O(a, l), y.value = ot(a, "field");
|
|
179
179
|
}
|
|
180
|
-
function
|
|
181
|
-
if (
|
|
180
|
+
function O(t, i, s = !0) {
|
|
181
|
+
if (V(i) && i?.length === 0)
|
|
182
182
|
return;
|
|
183
183
|
let l = [];
|
|
184
|
-
|
|
185
|
-
const
|
|
184
|
+
E(t) && l.push(t), V(t) && (l = [...t]);
|
|
185
|
+
const a = {}, r = g();
|
|
186
186
|
l.forEach((e) => {
|
|
187
|
-
e.type !==
|
|
188
|
-
}), st(
|
|
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
|
|
191
|
-
|
|
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(
|
|
201
|
+
return n(c) ? x(n(o))[t] : {};
|
|
195
202
|
}
|
|
196
203
|
function M(t) {
|
|
197
|
-
return n(
|
|
198
|
-
}
|
|
199
|
-
async function q(t) {
|
|
200
|
-
return t || (t = n(c).filter((s) => Q(s, n(r))).map((s) => s.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(
|
|
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(() => {
|
|
211
|
+
}, t);
|
|
204
212
|
}
|
|
205
|
-
async function
|
|
206
|
-
await n(
|
|
213
|
+
async function C(t) {
|
|
214
|
+
await n(c)?.clearValidate(t);
|
|
207
215
|
}
|
|
208
216
|
async function tt(t, i) {
|
|
209
|
-
await n(
|
|
217
|
+
await n(c)?.scrollToField(t, i);
|
|
210
218
|
}
|
|
211
|
-
async function
|
|
212
|
-
const { autoCleanErrorMessage: i, watchDataIsChange: s } = n(
|
|
213
|
-
t && t.preventDefault(), i && await
|
|
214
|
-
const { submitFunc: l, beforeSubmitFunc:
|
|
215
|
-
if (
|
|
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)) {
|
|
216
224
|
await l();
|
|
217
225
|
return;
|
|
218
226
|
}
|
|
219
|
-
if (n(
|
|
227
|
+
if (n(c))
|
|
220
228
|
try {
|
|
221
|
-
|
|
229
|
+
if (!await $())
|
|
230
|
+
return;
|
|
231
|
+
const u = g();
|
|
222
232
|
if (s) {
|
|
223
|
-
const b =
|
|
224
|
-
h("submit", u, !b,
|
|
233
|
+
const b = at(T.value, u), j = nt(T.value, u);
|
|
234
|
+
h("submit", u, !b, j);
|
|
225
235
|
} else
|
|
226
236
|
h("submit", u);
|
|
227
237
|
} catch (e) {
|
|
@@ -231,21 +241,21 @@ function Dt({
|
|
|
231
241
|
}
|
|
232
242
|
}
|
|
233
243
|
return {
|
|
234
|
-
handleSubmit:
|
|
235
|
-
clearValidate:
|
|
236
|
-
validate:
|
|
237
|
-
validateField:
|
|
238
|
-
getFieldsValue:
|
|
244
|
+
handleSubmit: U,
|
|
245
|
+
clearValidate: C,
|
|
246
|
+
validate: $,
|
|
247
|
+
validateField: N,
|
|
248
|
+
getFieldsValue: g,
|
|
239
249
|
updateSchema: R,
|
|
240
250
|
resetSchema: K,
|
|
241
251
|
appendSchemaByField: L,
|
|
242
252
|
removeSchemaByField: Y,
|
|
243
253
|
resetFields: X,
|
|
244
|
-
setFieldsValue:
|
|
254
|
+
setFieldsValue: q,
|
|
245
255
|
scrollToField: tt,
|
|
246
256
|
getFieldValue: k
|
|
247
257
|
};
|
|
248
258
|
}
|
|
249
259
|
export {
|
|
250
|
-
|
|
260
|
+
wt as useFormEvents
|
|
251
261
|
};
|
package/es/package.json.d.ts
CHANGED
package/es/package.json.js
CHANGED
|
@@ -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>>;
|
|
@@ -7,7 +7,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
7
7
|
/**
|
|
8
8
|
* @description Validate the whole form. Receives a callback or returns `Promise`.
|
|
9
9
|
*/
|
|
10
|
-
validate: (callback?: FormValidateCallback) => FormValidationResult;
|
|
10
|
+
validate: (callback?: FormValidateCallback, props?: Arrayable<FormItemProp>) => FormValidationResult;
|
|
11
11
|
/**
|
|
12
12
|
* @description Validate specified fields.
|
|
13
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue");require("@vueuse/core");const E=require("@vft/utils"),d=require("../../utils/error.cjs");require("../config-provider/hooks/use-global-config.cjs");require("lodash-es");const k=require("../../hooks/use-namespace/index.cjs");require("../../hooks/use-model-toggle/index.cjs");require("@popperjs/core");require("../../hooks/use-z-index/index.cjs");const R=require("./constants.cjs"),W=require("./hooks/use-form-common-props.cjs"),u=require("./utils.cjs"),x=r.defineComponent({name:"vft-form"}),M=r.defineComponent({...x,props:{size:{},disabled:{type:Boolean},model:{},rules:{},labelPosition:{default:"right"},requireAsteriskPosition:{default:"left"},labelWidth:{default:""},labelSuffix:{default:""},inline:{type:Boolean},inlineMessage:{type:Boolean},statusIcon:{type:Boolean},showMessage:{type:Boolean,default:!0},validateOnRuleChange:{type:Boolean,default:!0},hideRequiredAsterisk:{type:Boolean,default:!1},scrollToError:{type:Boolean},scrollIntoViewOptions:{type:Boolean,default:!0}},emits:["validate"],setup(o,{expose:y,emit:q}){const g=q,p=r.getCurrentInstance(),c=r.ref(),l=r.reactive([]),w=W.useFormSize(),s=k.useNamespace("form"),B=r.computed(()=>[s.b(),s.m(w.value||"default"),{[s.m(`label-${o.labelPosition}`)]:o.labelPosition,[s.m("inline")]:o.inline}]),m=e=>u.filterFields(l,[e])[0],V=e=>{l.push(e)},C=e=>{e.prop&&l.splice(l.indexOf(e),1)},h=(e=[])=>{if(!o.model){d.debugWarn(s.b(),"model is required for resetFields to work.");return}u.filterFields(l,e).forEach(t=>t.resetField())},v=(e=[])=>{u.filterFields(l,e).forEach(t=>t.clearValidate())},I=r.computed(()=>{const e=!!o.model;return e||d.debugWarn(s.b(),"model is required for validate to work."),e}),O=e=>{if(l.length===0)return[];const t=u.filterFields(l,e);return t.length?t:(d.debugWarn(s.b(),"please pass correct props!"),[])},F=async
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue");require("@vueuse/core");const E=require("@vft/utils"),d=require("../../utils/error.cjs");require("../config-provider/hooks/use-global-config.cjs");require("lodash-es");const k=require("../../hooks/use-namespace/index.cjs");require("../../hooks/use-model-toggle/index.cjs");require("@popperjs/core");require("../../hooks/use-z-index/index.cjs");const R=require("./constants.cjs"),W=require("./hooks/use-form-common-props.cjs"),u=require("./utils.cjs"),x=r.defineComponent({name:"vft-form"}),M=r.defineComponent({...x,props:{size:{},disabled:{type:Boolean},model:{},rules:{},labelPosition:{default:"right"},requireAsteriskPosition:{default:"left"},labelWidth:{default:""},labelSuffix:{default:""},inline:{type:Boolean},inlineMessage:{type:Boolean},statusIcon:{type:Boolean},showMessage:{type:Boolean,default:!0},validateOnRuleChange:{type:Boolean,default:!0},hideRequiredAsterisk:{type:Boolean,default:!1},scrollToError:{type:Boolean},scrollIntoViewOptions:{type:Boolean,default:!0}},emits:["validate"],setup(o,{expose:y,emit:q}){const g=q,p=r.getCurrentInstance(),c=r.ref(),l=r.reactive([]),w=W.useFormSize(),s=k.useNamespace("form"),B=r.computed(()=>[s.b(),s.m(w.value||"default"),{[s.m(`label-${o.labelPosition}`)]:o.labelPosition,[s.m("inline")]:o.inline}]),m=e=>u.filterFields(l,[e])[0],V=e=>{l.push(e)},C=e=>{e.prop&&l.splice(l.indexOf(e),1)},h=(e=[])=>{if(!o.model){d.debugWarn(s.b(),"model is required for resetFields to work.");return}u.filterFields(l,e).forEach(t=>t.resetField())},v=(e=[])=>{u.filterFields(l,e).forEach(t=>t.clearValidate())},I=r.computed(()=>{const e=!!o.model;return e||d.debugWarn(s.b(),"model is required for validate to work."),e}),O=e=>{if(l.length===0)return[];const t=u.filterFields(l,e);return t.length?t:(d.debugWarn(s.b(),"please pass correct props!"),[])},F=async(e,t)=>f(t||void 0,e),P=async(e=[])=>{if(!I.value)return!1;const t=O(e);if(t.length===0)return!0;let i={};for(const a of t)try{await a.validate(""),a.validateState==="error"&&a.resetField()}catch(n){i={...i,...n}}return Object.keys(i).length===0?!0:Promise.reject(i)},f=async(e=[],t)=>{let i=!1;const a=!E.isFunction(t);try{return i=await P(e),i===!0&&await t?.(i),o.model}catch(n){if(n instanceof Error)throw n;const b=n;return o.scrollToError&&c.value&&c.value.querySelector(`.${s.b()}-item.is-error`)?.scrollIntoView(o.scrollIntoViewOptions),console.error(n),!i&&await t?.(!1,b),a&&Promise.reject(b)}},S=e=>{const t=m(e);t&&t.$el?.scrollIntoView(o.scrollIntoViewOptions)};return r.watch(()=>o.rules,()=>{o.validateOnRuleChange&&F().catch(e=>d.debugWarn(e))},{deep:!0,flush:"post"}),r.provide(R.formContextKey,r.reactive({...r.toRefs(p.props),emit:g,resetFields:h,clearValidate:v,validateField:f,getField:m,addField:V,removeField:C,...u.useFormLabelWidth()})),y({validate:F,validateField:f,resetFields:h,clearValidate:v,scrollToField:S}),(e,t)=>(r.openBlock(),r.createElementBlock("form",{ref_key:"formRef",ref:c,class:r.normalizeClass(B.value)},[r.renderSlot(e.$slots,"default")],2))}});exports.default=M;
|