vft 0.0.326 → 0.0.328
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/super-form/super-form-item.vue2.js +103 -95
- package/es/components/super-form/types.d.ts +3 -1
- package/es/package.json.d.ts +1 -1
- package/es/package.json.js +1 -1
- package/lib/components/super-form/super-form-item.vue2.cjs +1 -1
- package/lib/components/super-form/types.d.ts +3 -1
- package/lib/package.json.cjs +1 -1
- package/lib/package.json.d.ts +1 -1
- package/package.json +3 -3
- package/web-types.json +1 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { VftCol as
|
|
3
|
-
import { VftDivider as
|
|
4
|
-
import { VftFormItem as
|
|
1
|
+
import { defineComponent as $, computed as v, ref as ee, unref as u, useSlots as te, createVNode as f, mergeProps as L, withDirectives as re, vShow as ne, isVNode as oe, createTextVNode as G, resolveComponent as q } from "vue";
|
|
2
|
+
import { VftCol as J } from "../col/index.js";
|
|
3
|
+
import { VftDivider as le } from "../divider/index.js";
|
|
4
|
+
import { VftFormItem as se } from "../form/index.js";
|
|
5
5
|
import "@vueuse/core";
|
|
6
|
-
import { isFunction as
|
|
6
|
+
import { isFunction as g, isBoolean as j, cloneDeep as ie, isArray as X, isNull as ae, upperFirst as ce, isString as ue } from "@vft/utils";
|
|
7
7
|
import "../config-provider/hooks/use-global-config.js";
|
|
8
8
|
import "lodash-es";
|
|
9
|
-
import { useNamespace as
|
|
9
|
+
import { useNamespace as fe } from "../../hooks/use-namespace/index.js";
|
|
10
10
|
import "../../hooks/use-model-toggle/index.js";
|
|
11
11
|
import "@popperjs/core";
|
|
12
12
|
import "../../hooks/use-z-index/index.js";
|
|
13
|
-
import { FormCompEnum as e, componentMap as
|
|
14
|
-
import { createPlaceholderMessage as
|
|
15
|
-
function
|
|
16
|
-
return typeof n == "function" || Object.prototype.toString.call(n) === "[object Object]" && !
|
|
13
|
+
import { FormCompEnum as e, componentMap as z, isInput as de, isDatePicker as me, isRangePicker as he } from "./component-map.js";
|
|
14
|
+
import { createPlaceholderMessage as W } from "./use/helper.js";
|
|
15
|
+
function k(n) {
|
|
16
|
+
return typeof n == "function" || Object.prototype.toString.call(n) === "[object Object]" && !oe(n);
|
|
17
17
|
}
|
|
18
|
-
const
|
|
18
|
+
const pe = $({
|
|
19
19
|
inheritAttrs: !1
|
|
20
|
-
}),
|
|
21
|
-
...
|
|
20
|
+
}), Ne = /* @__PURE__ */ $({
|
|
21
|
+
...pe,
|
|
22
22
|
__name: "super-form-item",
|
|
23
23
|
props: {
|
|
24
24
|
schema: {},
|
|
@@ -30,7 +30,7 @@ const me = W({
|
|
|
30
30
|
formActionType: {}
|
|
31
31
|
},
|
|
32
32
|
setup(n) {
|
|
33
|
-
const D =
|
|
33
|
+
const D = fe("super-form"), P = v(() => {
|
|
34
34
|
const {
|
|
35
35
|
mergeDynamicData: t
|
|
36
36
|
} = n.formProps;
|
|
@@ -42,13 +42,14 @@ const me = W({
|
|
|
42
42
|
...n.allDefaultValues,
|
|
43
43
|
...n.formModel
|
|
44
44
|
},
|
|
45
|
-
schema: n.schema
|
|
45
|
+
schema: n.schema,
|
|
46
|
+
elRef: w
|
|
46
47
|
};
|
|
47
|
-
}), K =
|
|
48
|
+
}), K = v(() => {
|
|
48
49
|
let {
|
|
49
50
|
componentProps: t = {}
|
|
50
51
|
} = n.schema;
|
|
51
|
-
|
|
52
|
+
g(t) && (t = t({
|
|
52
53
|
schema: n.schema,
|
|
53
54
|
formModel: n.formModel,
|
|
54
55
|
formActionType: n.formActionType
|
|
@@ -97,7 +98,7 @@ const me = W({
|
|
|
97
98
|
"end-placeholder": "结束月份"
|
|
98
99
|
}]]);
|
|
99
100
|
return r.has(n.schema.type) && (t = Object.assign(r.get(n.schema.type) || {}, t)), n.formProps.inputMaxLength && [e.INPUT].includes(n.schema.type) && !t?.maxlength && (t.maxlength = n.formProps.inputMaxLength), t;
|
|
100
|
-
}),
|
|
101
|
+
}), Y = v(() => {
|
|
101
102
|
const {
|
|
102
103
|
disabled: t
|
|
103
104
|
} = n.formProps, {
|
|
@@ -106,20 +107,20 @@ const me = W({
|
|
|
106
107
|
disabled: a = !1
|
|
107
108
|
} = u(K);
|
|
108
109
|
let i = !!t || a;
|
|
109
|
-
return
|
|
110
|
+
return j(r) && (i = r), g(r) && (i = r(u(P))), i;
|
|
110
111
|
});
|
|
111
|
-
function
|
|
112
|
+
function V() {
|
|
112
113
|
const {
|
|
113
114
|
show: t,
|
|
114
115
|
ifShow: r
|
|
115
116
|
} = n.schema;
|
|
116
117
|
let a = !0, i = !0;
|
|
117
|
-
return
|
|
118
|
+
return j(t) && (a = t), j(r) && (i = r), g(t) && (a = t(u(P))), g(r) && (i = r(u(P))), {
|
|
118
119
|
isShow: a,
|
|
119
120
|
isIfShow: i
|
|
120
121
|
};
|
|
121
122
|
}
|
|
122
|
-
function
|
|
123
|
+
function Q() {
|
|
123
124
|
const {
|
|
124
125
|
rules: t = [],
|
|
125
126
|
type: r = e.INPUT,
|
|
@@ -127,26 +128,26 @@ const me = W({
|
|
|
127
128
|
label: i,
|
|
128
129
|
title: p,
|
|
129
130
|
dynamicRule: c,
|
|
130
|
-
required:
|
|
131
|
-
dynamicRuleAdd:
|
|
131
|
+
required: C,
|
|
132
|
+
dynamicRuleAdd: I = !0
|
|
132
133
|
} = n.schema, m = i || p;
|
|
133
|
-
if (
|
|
134
|
+
if (g(c) && !I)
|
|
134
135
|
return c(u(P));
|
|
135
|
-
let o =
|
|
136
|
+
let o = ie(X(t) ? t : [t]);
|
|
136
137
|
const {
|
|
137
138
|
rulesMessageJoinLabel: b
|
|
138
|
-
} = n.formProps, y = Reflect.has(n.schema, "rulesMessageJoinLabel") ? a : b, A =
|
|
139
|
+
} = n.formProps, y = Reflect.has(n.schema, "rulesMessageJoinLabel") ? a : b, A = W(r, `${y ? m : ""}`);
|
|
139
140
|
function M(l, s) {
|
|
140
141
|
const N = l.message || A;
|
|
141
|
-
return s === void 0 ||
|
|
142
|
+
return s === void 0 || ae(s) || Array.isArray(s) && s.length === 0 || typeof s == "string" && s.trim() === "" || typeof s == "object" && Reflect.has(s, "checked") && Reflect.has(s, "halfChecked") && Array.isArray(s.checked) && Array.isArray(s.halfChecked) && s.checked.length === 0 && s.halfChecked.length === 0 ? Promise.reject(N) : Promise.resolve();
|
|
142
143
|
}
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
required:
|
|
144
|
+
const d = g(C) ? C(u(P)) : C, T = [e.RADIO, e.SELECT, e.RADIO, e.RADIO_SINGLE, e.RADIO_BUTTON, e.CHECKBOX, e.CHECKBOX_SINGLE, e.CHECKBOX_BUTTON, e.AUTOCOMPLETE, e.Cascader, e.ColorPicker, e.Upload, e.Slider].includes(r);
|
|
145
|
+
d && (!o || o.length === 0 ? o = [{
|
|
146
|
+
required: d,
|
|
146
147
|
validator: M,
|
|
147
148
|
trigger: T ? "change" : "blur"
|
|
148
149
|
}] : o.findIndex((s) => Reflect.has(s, "required")) === -1 && o.unshift({
|
|
149
|
-
required:
|
|
150
|
+
required: d,
|
|
150
151
|
validator: M,
|
|
151
152
|
trigger: T ? "change" : "blur"
|
|
152
153
|
}));
|
|
@@ -154,23 +155,23 @@ const me = W({
|
|
|
154
155
|
if (x !== -1) {
|
|
155
156
|
const l = o[x], {
|
|
156
157
|
isShow: s
|
|
157
|
-
} =
|
|
158
|
+
} = V();
|
|
158
159
|
s || (l.required = !1), r && (l.message = l.message || A);
|
|
159
160
|
}
|
|
160
161
|
const h = o.findIndex((l) => l.min), E = o.findIndex((l) => l.max);
|
|
161
|
-
function
|
|
162
|
-
const O = o[s],
|
|
163
|
-
return ["min", "all"].includes(N) &&
|
|
162
|
+
function R(l, s, N = "all") {
|
|
163
|
+
const O = o[s], H = O.isNumber ? isNaN(l) ? l?.length || 0 : Number(l) : l?.length || 0;
|
|
164
|
+
return ["min", "all"].includes(N) && H < O.min ? Promise.reject(m + "至少为" + O.min + "位") : ["max", "all"].includes(N) && H > O.max ? Promise.reject(m + "最多" + O.max + "位") : Promise.resolve();
|
|
164
165
|
}
|
|
165
|
-
(h !== -1 || E !== -1) && (h !== -1 && E !== -1 && !o[h].validator && !o[h].message ? o[h].validator = (l, s) =>
|
|
166
|
+
(h !== -1 || E !== -1) && (h !== -1 && E !== -1 && !o[h].validator && !o[h].message ? o[h].validator = (l, s) => R(s, h) : h !== -1 && !o[h].validator && !o[h].message ? o[h].validator = (l, s) => R(s, h, "min") : E !== -1 && !o[E].validator && !o[E].message && (o[E].validator = (l, s) => R(s, E, "max")));
|
|
166
167
|
const S = o.findIndex((l) => l.len);
|
|
167
|
-
if (S !== -1 && (o[S].validator = (l, s) => s.length !== o[S].len ? Promise.reject(m + "必须是" + o[S].len + "位") : Promise.resolve()),
|
|
168
|
+
if (S !== -1 && (o[S].validator = (l, s) => s.length !== o[S].len ? Promise.reject(m + "必须是" + o[S].len + "位") : Promise.resolve()), g(c) && I) {
|
|
168
169
|
let l = c(u(P));
|
|
169
|
-
l =
|
|
170
|
+
l = X(l) ? l : [l], o = o.concat(l);
|
|
170
171
|
}
|
|
171
172
|
return o;
|
|
172
173
|
}
|
|
173
|
-
const
|
|
174
|
+
const w = ee(), Z = () => {
|
|
174
175
|
const {
|
|
175
176
|
renderComponentContent: t,
|
|
176
177
|
type: r = e.INPUT,
|
|
@@ -178,66 +179,73 @@ const me = W({
|
|
|
178
179
|
changeEvent: i = "change",
|
|
179
180
|
valueField: p,
|
|
180
181
|
label: c,
|
|
181
|
-
title:
|
|
182
|
-
placeholderJoinLabel:
|
|
182
|
+
title: C,
|
|
183
|
+
placeholderJoinLabel: I = !0
|
|
183
184
|
} = n.schema;
|
|
184
185
|
let m = i;
|
|
185
|
-
|
|
186
|
-
const o = `on${
|
|
187
|
-
[o]: (...
|
|
188
|
-
const [S] =
|
|
189
|
-
|
|
186
|
+
de(r) ? m = "input" : me(r) || r === e.TIME_PICKER || [e.INPUT_TAG, e.AUTOCOMPLETE, e.Cascader, e.ColorPicker, e.Slider].includes(r) ? m = "update:modelValue" : r === e.Upload && (m = "update:fileList");
|
|
187
|
+
const o = `on${ce(m)}`, b = {
|
|
188
|
+
[o]: (...R) => {
|
|
189
|
+
const [S] = R;
|
|
190
|
+
d[o] && d[o](...R);
|
|
190
191
|
const l = S ? S.target : null, s = l ? l.value : S;
|
|
191
192
|
n.setFormModel(a, s, n.schema);
|
|
192
193
|
}
|
|
193
|
-
}, y =
|
|
194
|
+
}, y = z.get(r), {
|
|
194
195
|
autoSetPlaceHolder: A,
|
|
195
196
|
size: M
|
|
196
|
-
} = n.formProps,
|
|
197
|
+
} = n.formProps, d = {
|
|
197
198
|
clearable: !0,
|
|
198
199
|
...u(K)
|
|
199
200
|
};
|
|
200
|
-
if ([e.SEARCH].includes(r) || (
|
|
201
|
-
const
|
|
202
|
-
|
|
201
|
+
if ([e.SEARCH].includes(r) || (d.size = u(K)?.size || M, d.disabled = u(Y)), !d.disabled && A && !he(r) && r) {
|
|
202
|
+
const R = c || C;
|
|
203
|
+
d.placeholder = u(K)?.placeholder || W(r, I && ue(R) ? R : "");
|
|
203
204
|
}
|
|
204
205
|
const x = {
|
|
205
206
|
[p || "model-value"]: n.formModel[a]
|
|
206
207
|
}, h = {
|
|
207
208
|
...b,
|
|
208
|
-
...
|
|
209
|
+
...d,
|
|
209
210
|
...x
|
|
210
211
|
};
|
|
211
212
|
if (!t && r !== e.Upload)
|
|
212
|
-
return
|
|
213
|
+
return f(y, L({
|
|
214
|
+
ref: w
|
|
215
|
+
}, h), null);
|
|
213
216
|
let E;
|
|
214
|
-
if (E =
|
|
215
|
-
...t(
|
|
217
|
+
if (E = g(t) ? {
|
|
218
|
+
...t({
|
|
219
|
+
...u(P),
|
|
220
|
+
elRef: w
|
|
221
|
+
})
|
|
216
222
|
} : {
|
|
217
223
|
default: () => t
|
|
218
224
|
}, r === e.Upload && !t) {
|
|
219
225
|
const {
|
|
220
|
-
drag:
|
|
226
|
+
drag: R
|
|
221
227
|
} = u(K);
|
|
222
|
-
E =
|
|
223
|
-
default: () =>
|
|
228
|
+
E = R ? {
|
|
229
|
+
default: () => f(q("vft-icon"), {
|
|
224
230
|
icon: "icon-arrow-upload"
|
|
225
231
|
}, null)
|
|
226
232
|
} : {
|
|
227
|
-
default: () =>
|
|
233
|
+
default: () => f(q("vft-button"), {
|
|
228
234
|
type: "primary"
|
|
229
235
|
}, {
|
|
230
|
-
default: () => [
|
|
236
|
+
default: () => [f(q("vft-icon"), {
|
|
231
237
|
icon: "icon-arrow-upload"
|
|
232
238
|
}, null)]
|
|
233
239
|
})
|
|
234
240
|
};
|
|
235
241
|
}
|
|
236
|
-
return
|
|
242
|
+
return f(y, L({
|
|
243
|
+
ref: w
|
|
244
|
+
}, h), k(E) ? E : {
|
|
237
245
|
default: () => [E]
|
|
238
246
|
});
|
|
239
247
|
};
|
|
240
|
-
function
|
|
248
|
+
function U() {
|
|
241
249
|
const {
|
|
242
250
|
showLabel: t = !0,
|
|
243
251
|
label: r,
|
|
@@ -246,22 +254,22 @@ const me = W({
|
|
|
246
254
|
labelRequired: p
|
|
247
255
|
} = n.schema;
|
|
248
256
|
let c = r || a;
|
|
249
|
-
return c = p ?
|
|
257
|
+
return c = p ? f("span", null, [f("span", {
|
|
250
258
|
class: "label-required"
|
|
251
|
-
}, [
|
|
259
|
+
}, [G("*")]), f("span", null, [c])]) : c, t && c ? i ? f("span", null, [c, G(" "), f("span", {
|
|
252
260
|
class: "sub-label"
|
|
253
261
|
}, [i])]) : c : void 0;
|
|
254
262
|
}
|
|
255
|
-
const
|
|
256
|
-
function
|
|
263
|
+
const B = te();
|
|
264
|
+
function F(t, r = "default", a) {
|
|
257
265
|
if (!t || !Reflect.has(t, r))
|
|
258
266
|
return null;
|
|
259
|
-
if (!
|
|
267
|
+
if (!g(t[r]))
|
|
260
268
|
return console.error(`${r} is not a function!`), null;
|
|
261
269
|
const i = t[r];
|
|
262
270
|
return i ? i(a) : null;
|
|
263
271
|
}
|
|
264
|
-
function
|
|
272
|
+
function _() {
|
|
265
273
|
const {
|
|
266
274
|
itemProps: t,
|
|
267
275
|
slot: r,
|
|
@@ -269,18 +277,18 @@ const me = W({
|
|
|
269
277
|
field: i,
|
|
270
278
|
suffix: p,
|
|
271
279
|
prefix: c,
|
|
272
|
-
prefixParentStyle:
|
|
280
|
+
prefixParentStyle: C
|
|
273
281
|
} = n.schema, {
|
|
274
|
-
autoCleanErrorMessage:
|
|
282
|
+
autoCleanErrorMessage: I,
|
|
275
283
|
compFullWidth: m
|
|
276
|
-
} = n.formProps, o = () => r ?
|
|
284
|
+
} = n.formProps, o = () => r ? F(B, r, u(P)) : a ? a(u(P)) : Z(), b = !!p, y = !!c, A = g(p) ? p(u(P)) : p, M = g(c) ? c(u(P)) : c, d = () => {
|
|
277
285
|
n.updateSchema([{
|
|
278
286
|
field: i,
|
|
279
287
|
itemProps: {
|
|
280
288
|
error: ""
|
|
281
289
|
}
|
|
282
290
|
}]);
|
|
283
|
-
}, T = () =>
|
|
291
|
+
}, T = () => f(se, L({
|
|
284
292
|
style: {
|
|
285
293
|
marginRight: n.formProps.customLayout ? "10px" : 0
|
|
286
294
|
},
|
|
@@ -292,22 +300,22 @@ const me = W({
|
|
|
292
300
|
}, D.e("item")]
|
|
293
301
|
}, t, {
|
|
294
302
|
label: t?.label || t?.title,
|
|
295
|
-
"onUpdate:error":
|
|
303
|
+
"onUpdate:error": I ? d : () => {
|
|
296
304
|
},
|
|
297
|
-
rules:
|
|
305
|
+
rules: Q()
|
|
298
306
|
}), {
|
|
299
|
-
default: () => [
|
|
307
|
+
default: () => [f("div", {
|
|
300
308
|
class: D.e("container")
|
|
301
|
-
}, [
|
|
309
|
+
}, [f("div", {
|
|
302
310
|
class: D.e("content")
|
|
303
|
-
}, [o(), b &&
|
|
311
|
+
}, [o(), b && f("span", {
|
|
304
312
|
class: D.m("suffix")
|
|
305
313
|
}, [A])])])],
|
|
306
|
-
label:
|
|
314
|
+
label: U() ? () => U() : void 0
|
|
307
315
|
});
|
|
308
|
-
return y ?
|
|
309
|
-
style:
|
|
310
|
-
}, [
|
|
316
|
+
return y ? f("div", {
|
|
317
|
+
style: C
|
|
318
|
+
}, [f("span", {
|
|
311
319
|
class: D.m("prefix")
|
|
312
320
|
}, [M]), T()]) : T();
|
|
313
321
|
}
|
|
@@ -319,20 +327,20 @@ const me = W({
|
|
|
319
327
|
renderColContent: i,
|
|
320
328
|
type: p = e.INPUT,
|
|
321
329
|
render: c,
|
|
322
|
-
quickColSpan:
|
|
330
|
+
quickColSpan: C
|
|
323
331
|
} = n.schema;
|
|
324
|
-
if (!
|
|
332
|
+
if (!z.has(p) && !i && !c)
|
|
325
333
|
return null;
|
|
326
334
|
const {
|
|
327
|
-
baseColProps:
|
|
335
|
+
baseColProps: I = {},
|
|
328
336
|
quickColSpan: m
|
|
329
337
|
} = n.formProps, o = m ? {
|
|
330
338
|
span: Math.ceil(24 / m),
|
|
331
|
-
...
|
|
339
|
+
...I
|
|
332
340
|
} : {
|
|
333
|
-
...
|
|
334
|
-
}, b =
|
|
335
|
-
span: Math.ceil(24 /
|
|
341
|
+
...I
|
|
342
|
+
}, b = C ? {
|
|
343
|
+
span: Math.ceil(24 / C),
|
|
336
344
|
...r
|
|
337
345
|
} : {
|
|
338
346
|
...r
|
|
@@ -342,23 +350,23 @@ const me = W({
|
|
|
342
350
|
}, {
|
|
343
351
|
isIfShow: A,
|
|
344
352
|
isShow: M
|
|
345
|
-
} =
|
|
353
|
+
} = V(), d = u(P), T = () => a ? F(B, a, d) : i ? i(d) : _();
|
|
346
354
|
if (p === e.DIVIDER) {
|
|
347
355
|
let x;
|
|
348
|
-
return
|
|
356
|
+
return f(J, L({
|
|
349
357
|
span: 24
|
|
350
358
|
}, b), {
|
|
351
|
-
default: () => [
|
|
359
|
+
default: () => [f(le, u(K), k(x = U()) ? x : {
|
|
352
360
|
default: () => [x]
|
|
353
361
|
})]
|
|
354
362
|
});
|
|
355
363
|
}
|
|
356
|
-
return A && (n.formProps.customLayout ? T() :
|
|
364
|
+
return A && (n.formProps.customLayout ? T() : re(f(J, y, k(t = T()) ? t : {
|
|
357
365
|
default: () => [t]
|
|
358
|
-
}), [[
|
|
366
|
+
}), [[ne, M]]));
|
|
359
367
|
};
|
|
360
368
|
}
|
|
361
369
|
});
|
|
362
370
|
export {
|
|
363
|
-
|
|
371
|
+
Ne as default
|
|
364
372
|
};
|
|
@@ -4,7 +4,7 @@ import type { FormItemProp, FormItemProps, FormProps } from 'vft/es/components/f
|
|
|
4
4
|
import type { RowProps } from 'vft/es/components/row';
|
|
5
5
|
import type { ComponentSize } from 'vft/es/constants';
|
|
6
6
|
import type { InternalRuleItem, RuleItem } from 'async-validator';
|
|
7
|
-
import type { StyleValue, VNode } from 'vue';
|
|
7
|
+
import type { ComponentPublicInstance, Ref, StyleValue, VNode } from 'vue';
|
|
8
8
|
import type { Arrayable } from 'vft/es/utils';
|
|
9
9
|
import type { Recordable } from '../types';
|
|
10
10
|
import { FormCompEnum } from './component-map';
|
|
@@ -47,6 +47,8 @@ export interface RenderCallbackParams {
|
|
|
47
47
|
model: Recordable;
|
|
48
48
|
/** 字段名 */
|
|
49
49
|
field: string;
|
|
50
|
+
/** 组件实例引用 */
|
|
51
|
+
elRef?: Ref<ComponentPublicInstance | null>;
|
|
50
52
|
}
|
|
51
53
|
/** 表单操作方法接口 */
|
|
52
54
|
export interface FormActionType {
|
package/es/package.json.d.ts
CHANGED
package/es/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),U=require("../col/index.cjs"),$=require("../divider/index.cjs"),J=require("../form/index.cjs");require("@vueuse/core");const c=require("@vft/utils");require("../config-provider/hooks/use-global-config.cjs");require("lodash-es");const X=require("../../hooks/use-namespace/index.cjs");require("../../hooks/use-model-toggle/index.cjs");require("@popperjs/core");require("../../hooks/use-z-index/index.cjs");const e=require("./component-map.cjs"),j=require("./use/helper.cjs");function K(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!o.isVNode(t)}const z=o.defineComponent({inheritAttrs:!1}),W=o.defineComponent({...z,__name:"super-form-item",props:{schema:{},formProps:{},allDefaultValues:{},formModel:{},setFormModel:{},updateSchema:{},formActionType:{}},setup(t){const M=X.useNamespace("super-form"),h=o.computed(()=>{const{mergeDynamicData:r}=t.formProps;return{field:t.schema.field,model:t.formModel,values:{...r,...t.allDefaultValues,...t.formModel},schema:t.schema,elRef:V}}),S=o.computed(()=>{let{componentProps:r={}}=t.schema;c.isFunction(r)&&(r=r({schema:t.schema,formModel:t.formModel,formActionType:t.formActionType})??{});const n=new Map([[e.FormCompEnum.DIVIDER,{type:"horizontal"}],[e.FormCompEnum.TEXTAREA,{type:"textarea"}],[e.FormCompEnum.PASSWORD,{type:"password","show-password":!0}],[e.FormCompEnum.INPUT_NUMBER,{type:"number"}],[e.FormCompEnum.CHECKBOX_BUTTON,{useButton:!0}],[e.FormCompEnum.RADIO_BUTTON,{useButton:!0}],[e.FormCompEnum.YEAR_PICKER,{type:e.FormCompEnum.YEAR_PICKER}],[e.FormCompEnum.MONTH_PICKER,{type:e.FormCompEnum.MONTH_PICKER}],[e.FormCompEnum.DATE_PICKER,{type:e.FormCompEnum.DATE_PICKER}],[e.FormCompEnum.DATES_PICKER,{type:e.FormCompEnum.DATES_PICKER}],[e.FormCompEnum.DATETIME_PICKER,{type:e.FormCompEnum.DATETIME_PICKER}],[e.FormCompEnum.WEEK_PICKER,{type:e.FormCompEnum.WEEK_PICKER}],[e.FormCompEnum.TIMERANGE_PICKER,{type:e.FormCompEnum.TIME_PICKER,"is-range":!0,"start-placeholder":"开始时间","end-placeholder":"结束时间"}],[e.FormCompEnum.DATETIMERANGE_PICKER,{type:e.FormCompEnum.DATETIMERANGE_PICKER,"start-placeholder":"开始日期","end-placeholder":"结束日期"}],[e.FormCompEnum.DATERANGE_PICKER,{type:e.FormCompEnum.DATERANGE_PICKER,"start-placeholder":"开始日期","end-placeholder":"结束日期"}],[e.FormCompEnum.MONTHRANGE_PICKER,{type:e.FormCompEnum.MONTHRANGE_PICKER,"start-placeholder":"开始月份","end-placeholder":"结束月份"}]]);return n.has(t.schema.type)&&(r=Object.assign(n.get(t.schema.type)||{},r)),t.formProps.inputMaxLength&&[e.FormCompEnum.INPUT].includes(t.schema.type)&&!r?.maxlength&&(r.maxlength=t.formProps.inputMaxLength),r}),B=o.computed(()=>{const{disabled:r}=t.formProps,{dynamicDisabled:n}=t.schema,{disabled:a=!1}=o.unref(S);let i=!!r||a;return c.isBoolean(n)&&(i=n),c.isFunction(n)&&(i=n(o.unref(h))),i});function O(){const{show:r,ifShow:n}=t.schema;let a=!0,i=!0;return c.isBoolean(r)&&(a=r),c.isBoolean(n)&&(i=n),c.isFunction(r)&&(a=r(o.unref(h))),c.isFunction(n)&&(i=n(o.unref(h))),{isShow:a,isIfShow:i}}function k(){const{rules:r=[],type:n=e.FormCompEnum.INPUT,rulesMessageJoinLabel:a,label:i,title:E,dynamicRule:u,required:F,dynamicRuleAdd:g=!0}=t.schema,f=i||E;if(c.isFunction(u)&&!g)return u(o.unref(h));let l=c.cloneDeep(c.isArray(r)?r:[r]);const{rulesMessageJoinLabel:R}=t.formProps,N=Reflect.has(t.schema,"rulesMessageJoinLabel")?a:R,b=j.createPlaceholderMessage(n,`${N?f:""}`);function T(m,s){const x=m.message||b;return s===void 0||c.isNull(s)||Array.isArray(s)&&s.length===0||typeof s=="string"&&s.trim()===""||typeof s=="object"&&Reflect.has(s,"checked")&&Reflect.has(s,"halfChecked")&&Array.isArray(s.checked)&&Array.isArray(s.halfChecked)&&s.checked.length===0&&s.halfChecked.length===0?Promise.reject(x):Promise.resolve()}const d=c.isFunction(F)?F(o.unref(h)):F,I=[e.FormCompEnum.RADIO,e.FormCompEnum.SELECT,e.FormCompEnum.RADIO,e.FormCompEnum.RADIO_SINGLE,e.FormCompEnum.RADIO_BUTTON,e.FormCompEnum.CHECKBOX,e.FormCompEnum.CHECKBOX_SINGLE,e.FormCompEnum.CHECKBOX_BUTTON,e.FormCompEnum.AUTOCOMPLETE,e.FormCompEnum.Cascader,e.FormCompEnum.ColorPicker,e.FormCompEnum.Upload,e.FormCompEnum.Slider].includes(n);d&&(!l||l.length===0?l=[{required:d,validator:T,trigger:I?"change":"blur"}]:l.findIndex(s=>Reflect.has(s,"required"))===-1&&l.unshift({required:d,validator:T,trigger:I?"change":"blur"}));const y=l.findIndex(m=>Reflect.has(m,"required")&&!Reflect.has(m,"validator"));if(y!==-1){const m=l[y],{isShow:s}=O();s||(m.required=!1),n&&(m.message=m.message||b)}const p=l.findIndex(m=>m.min),C=l.findIndex(m=>m.max);function P(m,s,x="all"){const D=l[s],L=D.isNumber?isNaN(m)?m?.length||0:Number(m):m?.length||0;return["min","all"].includes(x)&&L<D.min?Promise.reject(f+"至少为"+D.min+"位"):["max","all"].includes(x)&&L>D.max?Promise.reject(f+"最多"+D.max+"位"):Promise.resolve()}(p!==-1||C!==-1)&&(p!==-1&&C!==-1&&!l[p].validator&&!l[p].message?l[p].validator=(m,s)=>P(s,p):p!==-1&&!l[p].validator&&!l[p].message?l[p].validator=(m,s)=>P(s,p,"min"):C!==-1&&!l[C].validator&&!l[C].message&&(l[C].validator=(m,s)=>P(s,C,"max")));const A=l.findIndex(m=>m.len);if(A!==-1&&(l[A].validator=(m,s)=>s.length!==l[A].len?Promise.reject(f+"必须是"+l[A].len+"位"):Promise.resolve()),c.isFunction(u)&&g){let m=u(o.unref(h));m=c.isArray(m)?m:[m],l=l.concat(m)}return l}const V=o.ref(),H=()=>{const{renderComponentContent:r,type:n=e.FormCompEnum.INPUT,field:a,changeEvent:i="change",valueField:E,label:u,title:F,placeholderJoinLabel:g=!0}=t.schema;let f=i;e.isInput(n)?f="input":e.isDatePicker(n)||n===e.FormCompEnum.TIME_PICKER||[e.FormCompEnum.INPUT_TAG,e.FormCompEnum.AUTOCOMPLETE,e.FormCompEnum.Cascader,e.FormCompEnum.ColorPicker,e.FormCompEnum.Slider].includes(n)?f="update:modelValue":n===e.FormCompEnum.Upload&&(f="update:fileList");const l=`on${c.upperFirst(f)}`,R={[l]:(...P)=>{const[A]=P;d[l]&&d[l](...P);const m=A?A.target:null,s=m?m.value:A;t.setFormModel(a,s,t.schema)}},N=e.componentMap.get(n),{autoSetPlaceHolder:b,size:T}=t.formProps,d={clearable:!0,...o.unref(S)};if([e.FormCompEnum.SEARCH].includes(n)||(d.size=o.unref(S)?.size||T,d.disabled=o.unref(B)),!d.disabled&&b&&!e.isRangePicker(n)&&n){const P=u||F;d.placeholder=o.unref(S)?.placeholder||j.createPlaceholderMessage(n,g&&c.isString(P)?P:"")}const y={[E||"model-value"]:t.formModel[a]},p={...R,...d,...y};if(!r&&n!==e.FormCompEnum.Upload)return o.createVNode(N,o.mergeProps({ref:V},p),null);let C;if(C=c.isFunction(r)?{...r({...o.unref(h),elRef:V})}:{default:()=>r},n===e.FormCompEnum.Upload&&!r){const{drag:P}=o.unref(S);C=P?{default:()=>o.createVNode(o.resolveComponent("vft-icon"),{icon:"icon-arrow-upload"},null)}:{default:()=>o.createVNode(o.resolveComponent("vft-button"),{type:"primary"},{default:()=>[o.createVNode(o.resolveComponent("vft-icon"),{icon:"icon-arrow-upload"},null)]})}}return o.createVNode(N,o.mergeProps({ref:V},p),K(C)?C:{default:()=>[C]})};function q(){const{showLabel:r=!0,label:n,title:a,subLabel:i,labelRequired:E}=t.schema;let u=n||a;return u=E?o.createVNode("span",null,[o.createVNode("span",{class:"label-required"},[o.createTextVNode("*")]),o.createVNode("span",null,[u])]):u,r&&u?i?o.createVNode("span",null,[u,o.createTextVNode(" "),o.createVNode("span",{class:"sub-label"},[i])]):u:void 0}const v=o.useSlots();function w(r,n="default",a){if(!r||!Reflect.has(r,n))return null;if(!c.isFunction(r[n]))return console.error(`${n} is not a function!`),null;const i=r[n];return i?i(a):null}function G(){const{itemProps:r,slot:n,render:a,field:i,suffix:E,prefix:u,prefixParentStyle:F}=t.schema,{autoCleanErrorMessage:g,compFullWidth:f}=t.formProps,l=()=>n?w(v,n,o.unref(h)):a?a(o.unref(h)):H(),R=!!E,N=!!u,b=c.isFunction(E)?E(o.unref(h)):E,T=c.isFunction(u)?u(o.unref(h)):u,d=()=>{t.updateSchema([{field:i,itemProps:{error:""}}])},I=()=>o.createVNode(J.VftFormItem,o.mergeProps({style:{marginRight:t.formProps.customLayout?"10px":0},prop:i,class:[{[M.is("suffix")]:R},{[M.is("comp-full-width")]:f},M.e("item")]},r,{label:r?.label||r?.title,"onUpdate:error":g?d:()=>{},rules:k()}),{default:()=>[o.createVNode("div",{class:M.e("container")},[o.createVNode("div",{class:M.e("content")},[l(),R&&o.createVNode("span",{class:M.m("suffix")},[b])])])],label:q()?()=>q():void 0});return N?o.createVNode("div",{style:F},[o.createVNode("span",{class:M.m("prefix")},[T]),I()]):I()}return()=>{let r;const{colProps:n={},colSlot:a,renderColContent:i,type:E=e.FormCompEnum.INPUT,render:u,quickColSpan:F}=t.schema;if(!e.componentMap.has(E)&&!i&&!u)return null;const{baseColProps:g={},quickColSpan:f}=t.formProps,l=f?{span:Math.ceil(24/f),...g}:{...g},R=F?{span:Math.ceil(24/F),...n}:{...n},N={...l,...R},{isIfShow:b,isShow:T}=O(),d=o.unref(h),I=()=>a?w(v,a,d):i?i(d):G();if(E===e.FormCompEnum.DIVIDER){let y;return o.createVNode(U.VftCol,o.mergeProps({span:24},R),{default:()=>[o.createVNode($.VftDivider,o.unref(S),K(y=q())?y:{default:()=>[y]})]})}return b&&(t.formProps.customLayout?I():o.withDirectives(o.createVNode(U.VftCol,N,K(r=I())?r:{default:()=>[r]}),[[o.vShow,T]]))}}});exports.default=W;
|
|
@@ -4,7 +4,7 @@ import type { FormItemProp, FormItemProps, FormProps } from 'vft/es/components/f
|
|
|
4
4
|
import type { RowProps } from 'vft/es/components/row';
|
|
5
5
|
import type { ComponentSize } from 'vft/es/constants';
|
|
6
6
|
import type { InternalRuleItem, RuleItem } from 'async-validator';
|
|
7
|
-
import type { StyleValue, VNode } from 'vue';
|
|
7
|
+
import type { ComponentPublicInstance, Ref, StyleValue, VNode } from 'vue';
|
|
8
8
|
import type { Arrayable } from 'vft/es/utils';
|
|
9
9
|
import type { Recordable } from '../types';
|
|
10
10
|
import { FormCompEnum } from './component-map';
|
|
@@ -47,6 +47,8 @@ export interface RenderCallbackParams {
|
|
|
47
47
|
model: Recordable;
|
|
48
48
|
/** 字段名 */
|
|
49
49
|
field: string;
|
|
50
|
+
/** 组件实例引用 */
|
|
51
|
+
elRef?: Ref<ComponentPublicInstance | null>;
|
|
50
52
|
}
|
|
51
53
|
/** 表单操作方法接口 */
|
|
52
54
|
export interface FormActionType {
|
package/lib/package.json.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.0.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.0.328";exports.version=e;
|
package/lib/package.json.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vft",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.328",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"@vft/router": "0.0.65",
|
|
60
60
|
"@vft/store": "0.0.54",
|
|
61
61
|
"@vft/use": "0.0.76",
|
|
62
|
-
"@vft/
|
|
63
|
-
"@vft/
|
|
62
|
+
"@vft/directives": "0.0.33",
|
|
63
|
+
"@vft/utils": "0.0.128"
|
|
64
64
|
},
|
|
65
65
|
"vetur": {
|
|
66
66
|
"tags": "tags.json",
|
package/web-types.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"http://json.schemastore.org/web-types","framework":"vue","name":"vft","version":"0.0.
|
|
1
|
+
{"$schema":"http://json.schemastore.org/web-types","framework":"vue","name":"vft","version":"0.0.328","js-types-syntax":"typescript","description-markup":"markdown","contributions":{"html":{}}}
|