vft 0.0.494 → 0.0.495
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/dist/index.css +1 -1
- package/es/components/carousel/use-carousel.js +1 -1
- package/es/components/input/input.vue2.js +4 -4
- package/es/components/input-tag/composables/use-input-tag.js +1 -1
- package/es/components/super-form/index.d.ts +9 -0
- package/es/components/super-form/super-form-item.vue2.js +219 -219
- package/es/components/super-form/super-form.vue2.js +97 -95
- package/es/components/super-form/types.d.ts +4 -0
- package/es/components/super-form/use/use-form-events.d.ts +1 -0
- package/es/components/super-form/use/use-form-events.js +205 -171
- package/es/components/table/field.js +60 -55
- package/es/components/table/index.d.ts +3 -3
- package/es/components/table/table.vue.d.ts +1 -1
- package/es/components/table/types.d.ts +2 -2
- package/es/components/table/use/use-data-source.d.ts +1 -1
- package/es/components/table/use/use-data-source.js +136 -119
- package/es/components/table/use/use-loading.js +15 -13
- package/es/hooks/use-z-index/index.js +3 -3
- package/es/package.json.d.ts +1 -1
- package/es/package.json.js +1 -1
- package/es/utils/vue/vnode.js +1 -1
- package/lib/components/input/input.vue2.cjs +1 -1
- package/lib/components/super-form/index.d.ts +9 -0
- package/lib/components/super-form/super-form-item.vue2.cjs +1 -1
- package/lib/components/super-form/super-form.vue2.cjs +1 -1
- package/lib/components/super-form/types.d.ts +4 -0
- package/lib/components/super-form/use/use-form-events.cjs +1 -1
- package/lib/components/super-form/use/use-form-events.d.ts +1 -0
- package/lib/components/table/field.cjs +1 -1
- package/lib/components/table/index.d.ts +3 -3
- package/lib/components/table/table.vue.d.ts +1 -1
- package/lib/components/table/types.d.ts +2 -2
- package/lib/components/table/use/use-data-source.cjs +1 -1
- package/lib/components/table/use/use-data-source.d.ts +1 -1
- package/lib/components/table/use/use-loading.cjs +1 -1
- package/lib/package.json.cjs +1 -1
- package/lib/package.json.d.ts +1 -1
- package/package.json +4 -4
- package/theme-style/index.css +1 -1
- package/theme-style/src/table.scss +2 -4
- package/theme-style/vft-table.css +1 -1
- package/web-types.json +1 -1
|
@@ -1,269 +1,303 @@
|
|
|
1
|
-
import { FormCompEnum as
|
|
1
|
+
import { FormCompEnum as T } from "../../../utils/form-register.js";
|
|
2
2
|
import "@vueuse/core";
|
|
3
|
-
import {
|
|
3
|
+
import { isFunction as b, isDef as H, isString as g, isObject as j, isArray as C, deepMerge as ot, findDifferentValuesForObj as st, isNullOrUndefined as J, isEmpty as at, isEmptyObject as ct } from "@vft/utils";
|
|
4
4
|
import "../../config-provider/hooks/use-global-config.js";
|
|
5
|
-
import {
|
|
6
|
-
import { get as
|
|
5
|
+
import { toRaw as I, unref as n, nextTick as Q } from "vue";
|
|
6
|
+
import { get as lt, cloneDeep as A, uniqBy as ft, isEqual as ut, set as X } from "lodash-es";
|
|
7
7
|
import "../../form/index.js";
|
|
8
8
|
import { formatToDate as W } from "@vft/utils/date";
|
|
9
|
-
import { isInput as
|
|
10
|
-
import { handleInputNumberValue as
|
|
11
|
-
function
|
|
12
|
-
const { show:
|
|
13
|
-
let
|
|
14
|
-
return typeof
|
|
9
|
+
import { isInput as dt, isDatePicker as ht } from "../component-map.js";
|
|
10
|
+
import { handleInputNumberValue as pt } from "./helper.js";
|
|
11
|
+
function L(p, F) {
|
|
12
|
+
const { show: c, ifShow: l } = p;
|
|
13
|
+
let y = !0, u = !0;
|
|
14
|
+
return typeof c == "boolean" ? y = c : typeof c == "function" && (y = c({
|
|
15
15
|
field: p.field,
|
|
16
|
-
model:
|
|
16
|
+
model: F,
|
|
17
17
|
values: {
|
|
18
|
-
...
|
|
18
|
+
...F
|
|
19
19
|
},
|
|
20
20
|
schema: p
|
|
21
|
-
})), typeof
|
|
21
|
+
})), typeof l == "boolean" ? u = l : typeof l == "function" && (u = l({
|
|
22
22
|
field: p.field,
|
|
23
|
-
model:
|
|
23
|
+
model: F,
|
|
24
24
|
values: {
|
|
25
|
-
...
|
|
25
|
+
...F
|
|
26
26
|
},
|
|
27
27
|
schema: p
|
|
28
|
-
})),
|
|
28
|
+
})), y && u;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
30
|
+
function Ft(p, F = {}) {
|
|
31
|
+
const c = /^\[(.+)\]$/;
|
|
32
|
+
if (c.test(p)) {
|
|
33
|
+
const l = p.match(c);
|
|
34
|
+
if (l && l[1]) {
|
|
35
|
+
const y = l[1].split(",");
|
|
36
|
+
if (!y.length)
|
|
37
37
|
return;
|
|
38
|
-
const
|
|
39
|
-
return
|
|
40
|
-
X(
|
|
41
|
-
}),
|
|
38
|
+
const u = [];
|
|
39
|
+
return y.forEach((v, V) => {
|
|
40
|
+
X(u, V, F[v.trim()]);
|
|
41
|
+
}), u.filter(Boolean).length ? u : void 0;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
45
|
+
function yt(p, F = {}) {
|
|
46
|
+
const c = /^\{(.+)\}$/;
|
|
47
|
+
if (c.test(p)) {
|
|
48
|
+
const l = p.match(c);
|
|
49
|
+
if (l && l[1]) {
|
|
50
|
+
const y = l[1].split(",");
|
|
51
|
+
if (!y.length)
|
|
52
52
|
return;
|
|
53
|
-
const
|
|
54
|
-
return
|
|
55
|
-
X(
|
|
56
|
-
}), Object.values(
|
|
53
|
+
const u = {};
|
|
54
|
+
return y.forEach((v) => {
|
|
55
|
+
X(u, v.trim(), F[v.trim()]);
|
|
56
|
+
}), Object.values(u).filter(Boolean).length ? u : void 0;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function Ct({
|
|
61
61
|
emit: p,
|
|
62
|
-
getProps:
|
|
63
|
-
formModel:
|
|
64
|
-
getSchema:
|
|
65
|
-
defaultValueRef:
|
|
66
|
-
formElRef:
|
|
67
|
-
schemaRef:
|
|
68
|
-
handleFormValues:
|
|
69
|
-
initValues:
|
|
62
|
+
getProps: F,
|
|
63
|
+
formModel: c,
|
|
64
|
+
getSchema: l,
|
|
65
|
+
defaultValueRef: y,
|
|
66
|
+
formElRef: u,
|
|
67
|
+
schemaRef: v,
|
|
68
|
+
handleFormValues: V,
|
|
69
|
+
initValues: S
|
|
70
70
|
}) {
|
|
71
71
|
async function Y(t) {
|
|
72
|
-
const { resetFunc:
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
72
|
+
const { resetFunc: i, submitOnReset: r } = n(F);
|
|
73
|
+
i && b(i) && await i();
|
|
74
|
+
const o = n(u);
|
|
75
|
+
if (o) {
|
|
76
76
|
if (t?.length)
|
|
77
|
-
return
|
|
78
|
-
Object.keys(
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
}), Q(() =>
|
|
77
|
+
return o.resetFields(t);
|
|
78
|
+
Object.keys(c).forEach((s) => {
|
|
79
|
+
const a = n(l).find((f) => f.field === s), e = A(y.value[s]);
|
|
80
|
+
c[s] = dt(a?.type) ? e || "" : e;
|
|
81
|
+
}), Q(() => O()), p("reset", I(c)), r && await z();
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
async function q(t,
|
|
85
|
-
const
|
|
86
|
-
(
|
|
87
|
-
),
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
let
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const { componentProps:
|
|
94
|
-
let
|
|
95
|
-
typeof
|
|
96
|
-
const G =
|
|
97
|
-
if (
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
if (Array.isArray(
|
|
101
|
-
const
|
|
102
|
-
for (const
|
|
103
|
-
|
|
104
|
-
n(
|
|
84
|
+
async function q(t, i = !0) {
|
|
85
|
+
const r = n(l).map((e) => e.field).filter(Boolean), o = ".", s = r.filter(
|
|
86
|
+
(e) => String(e).indexOf(o) >= 0
|
|
87
|
+
), a = [];
|
|
88
|
+
r.forEach((e) => {
|
|
89
|
+
const f = n(l).find((h) => h.field === e);
|
|
90
|
+
let d = lt(t, e);
|
|
91
|
+
const m = Reflect.has(t, e);
|
|
92
|
+
d = pt(f?.type, d);
|
|
93
|
+
const { componentProps: w } = f || {};
|
|
94
|
+
let D = w;
|
|
95
|
+
typeof w == "function" && (D = D({ formModel: n(c) }));
|
|
96
|
+
const G = Ft(e, t) || yt(e, t);
|
|
97
|
+
if (m || G) {
|
|
98
|
+
const h = G || d;
|
|
99
|
+
if (tt(e))
|
|
100
|
+
if (Array.isArray(h)) {
|
|
101
|
+
const E = [];
|
|
102
|
+
for (const B of h)
|
|
103
|
+
E.push(B ? W(B) : null);
|
|
104
|
+
n(c)[e] = E;
|
|
105
105
|
} else
|
|
106
|
-
n(
|
|
106
|
+
n(c)[e] = h ? D?.valueFormat ? h : W(h) : null;
|
|
107
107
|
else
|
|
108
|
-
n(
|
|
109
|
-
|
|
108
|
+
n(c)[e] = h;
|
|
109
|
+
D?.onChange && D?.onChange(h), a.push(e);
|
|
110
110
|
} else
|
|
111
|
-
|
|
111
|
+
s.forEach((h) => {
|
|
112
112
|
try {
|
|
113
|
-
const
|
|
114
|
-
H(
|
|
113
|
+
const E = h.split(".").reduce((B, rt) => B[rt], t);
|
|
114
|
+
H(E) && (n(c)[h] = n(E), a.push(h));
|
|
115
115
|
} catch {
|
|
116
|
-
H(
|
|
117
|
-
n(
|
|
116
|
+
H(y.value[h]) && (n(c)[h] = A(
|
|
117
|
+
n(y.value[h])
|
|
118
118
|
));
|
|
119
119
|
}
|
|
120
120
|
});
|
|
121
|
-
}),
|
|
122
|
-
await $(
|
|
121
|
+
}), i && Q(async () => {
|
|
122
|
+
await $(a).catch((e) => {
|
|
123
123
|
});
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
async function Z(t) {
|
|
127
|
-
const
|
|
127
|
+
const i = A(n(l));
|
|
128
128
|
if (!t)
|
|
129
129
|
return;
|
|
130
|
-
let
|
|
131
|
-
|
|
132
|
-
for (const
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
let r = g(t) ? [t] : t;
|
|
131
|
+
g(t) && (r = [t]);
|
|
132
|
+
for (const o of r)
|
|
133
|
+
P(o, i);
|
|
134
|
+
v.value = i;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
if (
|
|
138
|
-
const
|
|
139
|
-
|
|
136
|
+
function P(t, i) {
|
|
137
|
+
if (g(t)) {
|
|
138
|
+
const r = i.findIndex((o) => o.field === t);
|
|
139
|
+
r !== -1 && (delete c[t], i.splice(r, 1));
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
async function K(t,
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
145
|
-
|
|
142
|
+
async function K(t, i, r = !1) {
|
|
143
|
+
const o = A(n(l)), s = o.findIndex((e) => e.field === i), a = j(t) ? [t] : t;
|
|
144
|
+
if (!i || s === -1 || r) {
|
|
145
|
+
r ? o.unshift(...a) : o.push(...a), v.value = o, x(t);
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
|
-
|
|
148
|
+
s !== -1 && o.splice(s + 1, 0, ...a), x(t), v.value = o;
|
|
149
149
|
}
|
|
150
150
|
async function k(t) {
|
|
151
|
-
let
|
|
152
|
-
if (
|
|
153
|
-
(
|
|
151
|
+
let i = [];
|
|
152
|
+
if (j(t) && i.push(t), C(t) && (i = [...t]), !i.every(
|
|
153
|
+
(o) => o.type === T.Divider || Reflect.has(o, "field") && o.field
|
|
154
154
|
)) {
|
|
155
155
|
console.error(
|
|
156
156
|
"All children of the form Schema array that need to be updated must contain the `field` field"
|
|
157
157
|
);
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
v.value = i;
|
|
161
161
|
}
|
|
162
162
|
async function N(t) {
|
|
163
|
-
let
|
|
164
|
-
if (
|
|
165
|
-
(
|
|
163
|
+
let i = [];
|
|
164
|
+
if (j(t) && i.push(t), C(t) && (i = [...t]), !i.every(
|
|
165
|
+
(a) => a.type === T.Divider || Reflect.has(a, "field") && a.field
|
|
166
166
|
)) {
|
|
167
167
|
console.error(
|
|
168
168
|
"All children of the form Schema array that need to be updated must contain the `field` field"
|
|
169
169
|
);
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
const
|
|
173
|
-
n(
|
|
174
|
-
let
|
|
175
|
-
if (
|
|
176
|
-
|
|
177
|
-
}),
|
|
178
|
-
const
|
|
179
|
-
|
|
172
|
+
const o = [], s = [];
|
|
173
|
+
n(l).forEach((a) => {
|
|
174
|
+
let e;
|
|
175
|
+
if (i.forEach((f) => {
|
|
176
|
+
a.field === f.field && (e = f), f.defaultValue && f.field && o.push(f.field);
|
|
177
|
+
}), e !== void 0 && a.field === e.field) {
|
|
178
|
+
const f = ot(a, e);
|
|
179
|
+
s.push(f);
|
|
180
180
|
} else
|
|
181
|
-
|
|
182
|
-
}),
|
|
181
|
+
s.push(a);
|
|
182
|
+
}), x(s, o), v.value = ft(s, "field");
|
|
183
183
|
}
|
|
184
|
-
function
|
|
185
|
-
if (
|
|
184
|
+
function x(t, i, r = !0) {
|
|
185
|
+
if (C(i) && i?.length === 0)
|
|
186
186
|
return;
|
|
187
|
-
let
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}),
|
|
187
|
+
let o = [];
|
|
188
|
+
j(t) && o.push(t), C(t) && (o = [...t]);
|
|
189
|
+
const s = {}, a = _();
|
|
190
|
+
o.forEach((e) => {
|
|
191
|
+
e.type !== T.Divider && Reflect.has(e, "field") && e.field && !J(e.defaultValue) && (!(e.field in a) || J(a[e.field]) || at(a[e.field])) && (s[e.field] = e.defaultValue);
|
|
192
|
+
}), ct(s) || q(s, r);
|
|
193
193
|
}
|
|
194
|
-
function
|
|
195
|
-
if (!n(
|
|
196
|
-
const
|
|
194
|
+
function _(t = !1) {
|
|
195
|
+
if (!n(u)) return {};
|
|
196
|
+
const r = V(I(n(c)));
|
|
197
197
|
if (t)
|
|
198
|
-
return
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
})
|
|
198
|
+
return r;
|
|
199
|
+
const o = n(l).filter((d) => L(d, n(c))).map((d) => d.field).filter(Boolean), s = {};
|
|
200
|
+
o.forEach((d) => {
|
|
201
|
+
d in r && (s[d] = r[d]);
|
|
202
|
+
});
|
|
203
|
+
const a = n(l), e = {};
|
|
204
|
+
o.forEach((d) => {
|
|
205
|
+
if (d in s) {
|
|
206
|
+
const m = a.find((D) => D.field === d);
|
|
207
|
+
let w = s[d];
|
|
208
|
+
m?.formatter && b(m.formatter) && (w = m.formatter(
|
|
209
|
+
w,
|
|
210
|
+
d,
|
|
211
|
+
s,
|
|
212
|
+
m
|
|
213
|
+
)), e[d] = w;
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
const { formatter: f } = n(F);
|
|
217
|
+
return f && b(f) ? f(e) : e;
|
|
203
218
|
}
|
|
204
|
-
function R(t) {
|
|
205
|
-
|
|
219
|
+
function R(t, i, r) {
|
|
220
|
+
const s = n(l).find((a) => a.field === t);
|
|
221
|
+
return s?.formatter && b(s.formatter) ? s.formatter(i, t, r, s) : i;
|
|
206
222
|
}
|
|
207
223
|
function M(t) {
|
|
208
|
-
|
|
224
|
+
if (!n(u)) return {};
|
|
225
|
+
if (!(t in n(c)))
|
|
226
|
+
return {};
|
|
227
|
+
const r = V(I(n(c))), o = r[t];
|
|
228
|
+
return R(t, o, r);
|
|
229
|
+
}
|
|
230
|
+
function tt(t) {
|
|
231
|
+
return n(l).some((i) => i.field === t ? ht(i.type) : !1);
|
|
209
232
|
}
|
|
210
233
|
async function $(t) {
|
|
211
|
-
return t || (t = n(
|
|
234
|
+
return t || (t = n(l).filter((r) => L(r, n(c))).map((r) => r.field).filter(Boolean)), n(u)?.validateField(t);
|
|
212
235
|
}
|
|
213
|
-
async function
|
|
214
|
-
return t || (t = n(
|
|
236
|
+
async function U(t) {
|
|
237
|
+
return t || (t = n(l).filter((r) => L(r, n(c))).map((r) => r.field).filter(Boolean)), await n(u)?.validate(t, () => {
|
|
215
238
|
});
|
|
216
239
|
}
|
|
217
|
-
async function
|
|
218
|
-
await n(
|
|
240
|
+
async function O(t) {
|
|
241
|
+
await n(u)?.clearValidate(t);
|
|
219
242
|
}
|
|
220
|
-
async function
|
|
221
|
-
await
|
|
243
|
+
async function et(t, i) {
|
|
244
|
+
await O(t), await N([{ field: t, itemProps: { error: i } }]);
|
|
222
245
|
}
|
|
223
|
-
async function
|
|
224
|
-
await n(
|
|
246
|
+
async function it(t, i) {
|
|
247
|
+
await n(u)?.scrollToField(t, i);
|
|
225
248
|
}
|
|
226
|
-
async function
|
|
227
|
-
const { autoCleanErrorMessage:
|
|
228
|
-
t && t.preventDefault(),
|
|
229
|
-
const { submitFunc:
|
|
230
|
-
if (
|
|
231
|
-
await
|
|
249
|
+
async function z(t) {
|
|
250
|
+
const { autoCleanErrorMessage: i, watchDataIsChange: r } = n(F);
|
|
251
|
+
t && t.preventDefault(), i && await O();
|
|
252
|
+
const { submitFunc: o, beforeSubmitFunc: s } = n(F);
|
|
253
|
+
if (s && b(s) && await s(), o && b(o)) {
|
|
254
|
+
await o();
|
|
232
255
|
return;
|
|
233
256
|
}
|
|
234
|
-
if (n(
|
|
257
|
+
if (n(u))
|
|
235
258
|
try {
|
|
236
|
-
if (!await
|
|
259
|
+
if (!await U())
|
|
237
260
|
return;
|
|
238
|
-
const
|
|
239
|
-
if (
|
|
240
|
-
const
|
|
241
|
-
p("submit",
|
|
261
|
+
const f = _();
|
|
262
|
+
if (r) {
|
|
263
|
+
const d = ut(S.value, f), m = st(S.value, f);
|
|
264
|
+
p("submit", f, !d, m);
|
|
242
265
|
} else
|
|
243
|
-
p("submit",
|
|
244
|
-
} catch (
|
|
245
|
-
if (
|
|
266
|
+
p("submit", f);
|
|
267
|
+
} catch (e) {
|
|
268
|
+
if (e?.outOfDate === !1 && e?.errorFields)
|
|
246
269
|
return;
|
|
247
|
-
throw new Error(
|
|
270
|
+
throw new Error(e.message);
|
|
248
271
|
}
|
|
249
272
|
}
|
|
273
|
+
function nt() {
|
|
274
|
+
const t = V(I(n(c))), i = n(l), r = {};
|
|
275
|
+
Object.keys(t).forEach((s) => {
|
|
276
|
+
const a = i.find((f) => f.field === s);
|
|
277
|
+
let e = t[s];
|
|
278
|
+
a?.formatter && b(a.formatter) && (e = a.formatter(e, s, t, a)), r[s] = e;
|
|
279
|
+
});
|
|
280
|
+
const { formatter: o } = n(F);
|
|
281
|
+
return o && b(o) ? o(r) : r;
|
|
282
|
+
}
|
|
250
283
|
return {
|
|
251
|
-
handleSubmit:
|
|
252
|
-
clearValidate:
|
|
253
|
-
validate:
|
|
284
|
+
handleSubmit: z,
|
|
285
|
+
clearValidate: O,
|
|
286
|
+
validate: U,
|
|
254
287
|
validateField: $,
|
|
255
|
-
getFieldsValue:
|
|
288
|
+
getFieldsValue: _,
|
|
256
289
|
updateSchema: N,
|
|
257
290
|
resetSchema: k,
|
|
258
291
|
appendSchemaByField: K,
|
|
259
292
|
removeSchemaByField: Z,
|
|
260
293
|
resetFields: Y,
|
|
261
294
|
setFieldsValue: q,
|
|
262
|
-
scrollToField:
|
|
263
|
-
getFieldValue:
|
|
264
|
-
setFormItemError:
|
|
295
|
+
scrollToField: it,
|
|
296
|
+
getFieldValue: M,
|
|
297
|
+
setFormItemError: et,
|
|
298
|
+
getFormattedFormModel: nt
|
|
265
299
|
};
|
|
266
300
|
}
|
|
267
301
|
export {
|
|
268
|
-
|
|
302
|
+
Ct as useFormEvents
|
|
269
303
|
};
|