vft 0.0.370 → 0.0.372
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/button/index.d.ts +9 -9
- package/es/components/carousel/use-carousel.js +1 -1
- package/es/components/form/form-item.vue.d.ts +1 -1
- package/es/components/form/form-item.vue2.js +3 -2
- package/es/components/form/index.d.ts +30 -30
- package/es/components/input/input.vue2.js +4 -4
- package/es/components/input-tag/composables/use-input-tag.js +1 -1
- package/es/components/popconfirm/index.d.ts +15 -15
- package/es/components/popconfirm/popconfirm.vue.d.ts +1 -1
- package/es/components/select/defaults.d.ts +7 -2
- package/es/components/select/defaults.js +3 -1
- package/es/components/select/option-item.vue.d.ts +12 -2
- package/es/components/select/select-dropdown.js +6 -6
- package/es/components/skeleton/index.d.ts +12 -0
- package/es/components/skeleton/skeleton-item.vue.d.ts +2 -0
- package/es/components/skeleton/skeleton-item.vue2.js +22 -16
- package/es/components/super-form/index.d.ts +5 -0
- package/es/components/super-form/super-form-action.vue2.js +42 -40
- package/es/components/super-form/super-form-item.vue2.js +312 -188
- package/es/components/super-form/super-form.vue.d.ts +2 -0
- package/es/components/super-form/super-form.vue2.js +64 -63
- package/es/components/super-form/types.d.ts +6 -0
- package/es/components/super-form/use/use-form-context.d.ts +1 -0
- 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/button/index.d.ts +9 -9
- package/lib/components/form/form-item.vue.d.ts +1 -1
- package/lib/components/form/form-item.vue2.cjs +1 -1
- package/lib/components/form/index.d.ts +30 -30
- package/lib/components/input/input.vue2.cjs +1 -1
- package/lib/components/popconfirm/index.d.ts +15 -15
- package/lib/components/popconfirm/popconfirm.vue.d.ts +1 -1
- package/lib/components/select/defaults.cjs +1 -1
- package/lib/components/select/defaults.d.ts +7 -2
- package/lib/components/select/option-item.vue.d.ts +12 -2
- package/lib/components/select/select-dropdown.cjs +1 -1
- package/lib/components/skeleton/index.d.ts +12 -0
- package/lib/components/skeleton/skeleton-item.vue.d.ts +2 -0
- package/lib/components/skeleton/skeleton-item.vue2.cjs +1 -1
- package/lib/components/super-form/index.d.ts +5 -0
- package/lib/components/super-form/super-form-action.vue2.cjs +1 -1
- package/lib/components/super-form/super-form-item.vue2.cjs +1 -1
- package/lib/components/super-form/super-form.vue.d.ts +2 -0
- package/lib/components/super-form/super-form.vue2.cjs +1 -1
- package/lib/components/super-form/types.d.ts +6 -0
- package/lib/components/super-form/use/use-form-context.d.ts +1 -0
- package/lib/package.json.cjs +1 -1
- package/lib/package.json.d.ts +1 -1
- package/package.json +5 -5
- package/theme-style/index.css +1 -1
- package/theme-style/src/common/icon.scss +1 -0
- package/theme-style/src/super-form.scss +15 -0
- package/theme-style/vft-super-form.css +1 -1
- package/web-types.json +1 -1
|
@@ -51,6 +51,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
51
51
|
reset: (data: Recordable) => void;
|
|
52
52
|
submit: (formData: Record<string, any>, isChange?: boolean | undefined, changeData?: any[] | undefined) => void;
|
|
53
53
|
"field-value-change": () => void;
|
|
54
|
+
"common-btn-click": () => void;
|
|
54
55
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<SuperFormProps>, {
|
|
55
56
|
size: string;
|
|
56
57
|
labelPosition: string;
|
|
@@ -80,6 +81,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
80
81
|
onSubmit?: ((formData: Record<string, any>, isChange?: boolean | undefined, changeData?: any[] | undefined) => any) | undefined;
|
|
81
82
|
onRegister?: ((instance: Partial<FormActionType>) => any) | undefined;
|
|
82
83
|
"onField-value-change"?: (() => any) | undefined;
|
|
84
|
+
"onCommon-btn-click"?: (() => any) | undefined;
|
|
83
85
|
}>, {
|
|
84
86
|
size: import("vft/es/constants").ComponentSize;
|
|
85
87
|
labelPosition: "left" | "right" | "top";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as j, useAttrs as
|
|
1
|
+
import { defineComponent as j, useAttrs as se, reactive as le, ref as i, computed as c, unref as o, watch as h, nextTick as re, useSlots as ue, createBlock as u, createCommentVNode as K, openBlock as l, mergeProps as y, withKeys as ie, withModifiers as me, withCtx as v, renderSlot as O, normalizeProps as U, createElementBlock as fe, Fragment as ce, renderList as W, createSlots as pe, resolveDynamicComponent as E, h as de } from "vue";
|
|
2
2
|
import { VftCol as Be } from "../col/index.js";
|
|
3
3
|
import { VftForm as he } from "../form/index.js";
|
|
4
4
|
import { VftRow as ye } from "../row/index.js";
|
|
@@ -10,10 +10,10 @@ import { useNamespace as Se } 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
|
|
14
|
-
import
|
|
15
|
-
import { useAutoFocus as
|
|
16
|
-
import { createFormContext as
|
|
13
|
+
import ke from "./super-form-action.vue2.js";
|
|
14
|
+
import Ce from "./super-form-item.vue2.js";
|
|
15
|
+
import { useAutoFocus as Ae } from "./use/use-auto-focus.js";
|
|
16
|
+
import { createFormContext as Oe } from "./use/use-form-context.js";
|
|
17
17
|
import { useFormEvents as Ee } from "./use/use-form-events.js";
|
|
18
18
|
import { useFormValues as Pe } from "./use/use-form-values.js";
|
|
19
19
|
const Ve = j({
|
|
@@ -147,19 +147,19 @@ const Ve = j({
|
|
|
147
147
|
type: Boolean
|
|
148
148
|
}
|
|
149
149
|
},
|
|
150
|
-
emits: ["register", "reset", "submit", "field-value-change"],
|
|
150
|
+
emits: ["register", "reset", "submit", "field-value-change", "common-btn-click"],
|
|
151
151
|
setup(J, {
|
|
152
152
|
expose: Q,
|
|
153
153
|
emit: X
|
|
154
154
|
}) {
|
|
155
|
-
const Y = Se("super-form"),
|
|
156
|
-
...
|
|
155
|
+
const Y = Se("super-form"), P = J, b = X, Z = se(), r = le({}), g = i({}), p = i(!1), d = i({}), V = i(), F = i(null), I = i(), t = c(() => ({
|
|
156
|
+
...P,
|
|
157
157
|
...o(d)
|
|
158
|
-
})), m =
|
|
158
|
+
})), m = c(() => ({
|
|
159
159
|
...Z,
|
|
160
|
-
...
|
|
160
|
+
...P,
|
|
161
161
|
...o(t)
|
|
162
|
-
})),
|
|
162
|
+
})), s = c(() => {
|
|
163
163
|
const e = o(V);
|
|
164
164
|
return ge(e);
|
|
165
165
|
}), {
|
|
@@ -167,58 +167,59 @@ const Ve = j({
|
|
|
167
167
|
initDefault: _
|
|
168
168
|
} = Pe({
|
|
169
169
|
getProps: t,
|
|
170
|
-
defaultValueRef:
|
|
171
|
-
getSchema:
|
|
170
|
+
defaultValueRef: g,
|
|
171
|
+
getSchema: s,
|
|
172
172
|
formModel: r
|
|
173
173
|
});
|
|
174
|
-
|
|
175
|
-
getSchema:
|
|
174
|
+
Ae({
|
|
175
|
+
getSchema: s,
|
|
176
176
|
getProps: t,
|
|
177
|
-
isInitedDefault:
|
|
178
|
-
formElRef:
|
|
177
|
+
isInitedDefault: p,
|
|
178
|
+
formElRef: F
|
|
179
179
|
});
|
|
180
180
|
const {
|
|
181
181
|
handleSubmit: f,
|
|
182
|
-
setFieldsValue:
|
|
182
|
+
setFieldsValue: w,
|
|
183
183
|
clearValidate: D,
|
|
184
184
|
validate: T,
|
|
185
185
|
validateField: q,
|
|
186
|
-
getFieldsValue:
|
|
187
|
-
updateSchema:
|
|
186
|
+
getFieldsValue: R,
|
|
187
|
+
updateSchema: S,
|
|
188
188
|
resetSchema: B,
|
|
189
189
|
appendSchemaByField: L,
|
|
190
190
|
removeSchemaByField: $,
|
|
191
|
-
resetFields:
|
|
191
|
+
resetFields: k,
|
|
192
192
|
scrollToField: ee,
|
|
193
193
|
getFieldValue: N,
|
|
194
194
|
setFormItemError: x
|
|
195
195
|
} = Ee({
|
|
196
|
-
emit:
|
|
196
|
+
emit: b,
|
|
197
197
|
getProps: t,
|
|
198
198
|
formModel: r,
|
|
199
|
-
getSchema:
|
|
200
|
-
defaultValueRef:
|
|
201
|
-
formElRef:
|
|
199
|
+
getSchema: s,
|
|
200
|
+
defaultValueRef: g,
|
|
201
|
+
formElRef: F,
|
|
202
202
|
schemaRef: V,
|
|
203
203
|
handleFormValues: M,
|
|
204
204
|
initValues: I
|
|
205
205
|
});
|
|
206
|
-
|
|
207
|
-
resetAction:
|
|
208
|
-
submitAction: f
|
|
206
|
+
Oe({
|
|
207
|
+
resetAction: k,
|
|
208
|
+
submitAction: f,
|
|
209
|
+
commonAction: () => b("common-btn-click")
|
|
209
210
|
}), h(() => o(t).model, () => {
|
|
210
211
|
const {
|
|
211
212
|
model: e
|
|
212
213
|
} = o(t);
|
|
213
|
-
e &&
|
|
214
|
+
e && w(e);
|
|
214
215
|
}, {
|
|
215
216
|
immediate: !0
|
|
216
217
|
}), h(() => o(t).schemas, (e, a) => {
|
|
217
218
|
Fe(e, a) || B(e ?? []);
|
|
218
|
-
}), h(() =>
|
|
219
|
+
}), h(() => s.value, (e) => {
|
|
219
220
|
re(() => {
|
|
220
|
-
}), !o(
|
|
221
|
-
I.value =
|
|
221
|
+
}), !o(p) && e?.length && (_(), p.value = !0, t.value?.watchDataIsChange && ve(() => {
|
|
222
|
+
I.value = R();
|
|
222
223
|
}, 40));
|
|
223
224
|
}), h(() => r, be(() => {
|
|
224
225
|
o(t).submitOnChange && f();
|
|
@@ -226,26 +227,26 @@ const Ve = j({
|
|
|
226
227
|
deep: !0
|
|
227
228
|
});
|
|
228
229
|
async function G(e) {
|
|
229
|
-
d.value = Re(o(d) || {}, e),
|
|
230
|
+
d.value = Re(o(d) || {}, e), p.value || (B(d.value?.schemas ?? []), _());
|
|
230
231
|
}
|
|
231
|
-
function te(e, a,
|
|
232
|
-
r[e] = a,
|
|
232
|
+
function te(e, a, n) {
|
|
233
|
+
r[e] = a, n && n.itemProps;
|
|
233
234
|
}
|
|
234
235
|
function oe(e) {
|
|
235
236
|
const {
|
|
236
237
|
autoSubmitOnEnter: a
|
|
237
238
|
} = o(t);
|
|
238
239
|
if (a && e.key === "Enter" && e.target && e.target instanceof HTMLElement) {
|
|
239
|
-
const
|
|
240
|
-
|
|
240
|
+
const n = e.target;
|
|
241
|
+
n && n.tagName && n.tagName.toUpperCase() === "INPUT" && f();
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
244
|
const H = {
|
|
244
|
-
getFieldsValue:
|
|
245
|
+
getFieldsValue: R,
|
|
245
246
|
getFieldValue: N,
|
|
246
|
-
setFieldsValue:
|
|
247
|
-
resetFields:
|
|
248
|
-
updateSchema:
|
|
247
|
+
setFieldsValue: w,
|
|
248
|
+
resetFields: k,
|
|
249
|
+
updateSchema: S,
|
|
249
250
|
resetSchema: B,
|
|
250
251
|
setProps: G,
|
|
251
252
|
removeSchemaByField: $,
|
|
@@ -257,18 +258,18 @@ const Ve = j({
|
|
|
257
258
|
submit: f,
|
|
258
259
|
scrollToField: ee
|
|
259
260
|
};
|
|
260
|
-
|
|
261
|
-
const ae =
|
|
261
|
+
b("register", H);
|
|
262
|
+
const ae = c(() => we(t.value, ["showResetButton", "showCommonButton", "showSubmitButton", "resetButtonOptions", "submitButtonOptions", "commonButtonOptions", "actionRowOptions", "actionSpan", "submitResetReverse"])), C = ue(), A = (e) => e ? de(ke, ae.value, {
|
|
262
263
|
resetBefore: (a) => C.resetBefore?.(a),
|
|
263
264
|
submitBefore: (a) => C.submitBefore?.(a),
|
|
264
265
|
submitAfter: (a) => C.submitAfter?.(a)
|
|
265
266
|
}) : null;
|
|
266
267
|
return Q({
|
|
267
|
-
getFieldsValue:
|
|
268
|
+
getFieldsValue: R,
|
|
268
269
|
getFieldValue: N,
|
|
269
|
-
setFieldsValue:
|
|
270
|
-
resetFields:
|
|
271
|
-
updateSchema:
|
|
270
|
+
setFieldsValue: w,
|
|
271
|
+
resetFields: k,
|
|
272
|
+
updateSchema: S,
|
|
272
273
|
resetSchema: B,
|
|
273
274
|
setProps: G,
|
|
274
275
|
removeSchemaByField: $,
|
|
@@ -277,40 +278,40 @@ const Ve = j({
|
|
|
277
278
|
validateField: q,
|
|
278
279
|
validate: T,
|
|
279
280
|
submit: f,
|
|
280
|
-
getSchema:
|
|
281
|
+
getSchema: s,
|
|
281
282
|
setFormItemError: x,
|
|
282
|
-
formModel:
|
|
283
|
-
}), (e, a) =>
|
|
283
|
+
formModel: c(() => M(r))
|
|
284
|
+
}), (e, a) => s.value?.length ? (l(), u(o(he), y({
|
|
284
285
|
key: 0
|
|
285
286
|
}, m.value, {
|
|
286
287
|
ref_key: "formElRef",
|
|
287
|
-
ref:
|
|
288
|
+
ref: F,
|
|
288
289
|
class: o(Y).b(),
|
|
289
290
|
model: r,
|
|
290
291
|
onSubmit: a[0] || (a[0] = me(() => {
|
|
291
292
|
}, ["prevent"])),
|
|
292
293
|
onKeypress: ie(oe, ["enter"])
|
|
293
294
|
}), {
|
|
294
|
-
default: v(() => [
|
|
295
|
+
default: v(() => [s.value?.length ? (l(), u(o(ye), U(y({
|
|
295
296
|
key: 0
|
|
296
297
|
}, m.value?.rowProps)), {
|
|
297
|
-
default: v(() => [O(e.$slots, "formHeader"), (l(!0), fe(
|
|
298
|
-
key:
|
|
298
|
+
default: v(() => [O(e.$slots, "formHeader"), (l(!0), fe(ce, null, W(s.value, (n) => (l(), u(Ce, {
|
|
299
|
+
key: n.field,
|
|
299
300
|
"form-action-type": H,
|
|
300
|
-
schema:
|
|
301
|
+
schema: n,
|
|
301
302
|
"form-props": t.value,
|
|
302
|
-
"all-default-values":
|
|
303
|
+
"all-default-values": g.value,
|
|
303
304
|
"form-model": r,
|
|
304
305
|
"set-form-model": te,
|
|
305
|
-
"update-schema": o(
|
|
306
|
-
},
|
|
306
|
+
"update-schema": o(S)
|
|
307
|
+
}, pe({
|
|
307
308
|
_: 2
|
|
308
309
|
}, [W(Object.keys(e.$slots), (z) => ({
|
|
309
310
|
name: z,
|
|
310
|
-
fn: v((
|
|
311
|
+
fn: v((ne) => [O(e.$slots, z, y({
|
|
311
312
|
ref_for: !0
|
|
312
|
-
},
|
|
313
|
-
}))]), 1032, ["schema", "form-props", "all-default-values", "form-model", "update-schema"]))), 128)), t.value?.customLayout ? (l(), u(A(
|
|
313
|
+
}, ne || {}))])
|
|
314
|
+
}))]), 1032, ["schema", "form-props", "all-default-values", "form-model", "update-schema"]))), 128)), t.value?.customLayout ? (l(), u(E(A(t.value?.showActionButtonGroup && t.value?.actionInline)), {
|
|
314
315
|
key: 1
|
|
315
316
|
})) : (l(), u(o(Be), U(y({
|
|
316
317
|
key: 0
|
|
@@ -318,11 +319,11 @@ const Ve = j({
|
|
|
318
319
|
span: Math.ceil(24 / m.value?.quickColSpan),
|
|
319
320
|
...m.value?.baseColProps
|
|
320
321
|
} : {})), {
|
|
321
|
-
default: v(() => [(l(), u(A(
|
|
322
|
+
default: v(() => [(l(), u(E(A(t.value?.showActionButtonGroup && t.value?.actionInline))))]),
|
|
322
323
|
_: 1
|
|
323
324
|
}, 16))]),
|
|
324
325
|
_: 3
|
|
325
|
-
}, 16)) : K("", !0), (l(), u(A(
|
|
326
|
+
}, 16)) : K("", !0), (l(), u(E(A(t.value?.showActionButtonGroup && !t.value?.actionInline)))), O(e.$slots, "formFooter")]),
|
|
326
327
|
_: 3
|
|
327
328
|
}, 16, ["class", "model"])) : K("", !0);
|
|
328
329
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ButtonProps } from 'vft/es/components/button';
|
|
2
2
|
import type { ColProps } from 'vft/es/components/col';
|
|
3
3
|
import type { FormItemProp, FormItemProps, FormProps } from 'vft/es/components/form';
|
|
4
|
+
import type { IconProps } from 'vft/es/components/icon';
|
|
4
5
|
import type { RowProps } from 'vft/es/components/row';
|
|
6
|
+
import type { ToolTipProps } from 'vft/es/components/tooltip';
|
|
5
7
|
import type { ComponentSize } from 'vft/es/constants';
|
|
6
8
|
import type { InternalRuleItem, RuleItem } from 'async-validator';
|
|
7
9
|
import type { ComponentPublicInstance, Ref, StyleValue, VNode } from 'vue';
|
|
@@ -256,6 +258,10 @@ export interface FormSchema {
|
|
|
256
258
|
dynamicRule?: (renderCallbackParams: RenderCallbackParams) => Arrayable<FormItemRule>;
|
|
257
259
|
/** 是否添加动态规则 */
|
|
258
260
|
dynamicRuleAdd?: boolean;
|
|
261
|
+
/** 帮助图标配置 */
|
|
262
|
+
helpIcon?: IconProps | string;
|
|
263
|
+
/** 帮助提示配置 */
|
|
264
|
+
helpTooltip?: string | ToolTipProps;
|
|
259
265
|
}
|
|
260
266
|
/** 表单项属性接口 */
|
|
261
267
|
export interface SuperFormItemProps {
|
package/es/package.json.d.ts
CHANGED
package/es/package.json.js
CHANGED
package/es/utils/vue/vnode.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray as E, hasOwn as m, camelize as N } from "@vft/utils";
|
|
2
2
|
import { isVNode as o, Fragment as S, Comment as A, Text as s, createCommentVNode as L, createBlock as _, openBlock as C } from "vue";
|
|
3
3
|
import { debugWarn as O } from "../error.js";
|
|
4
4
|
const R = "utils/vue/vnode";
|
|
@@ -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>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue")
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");require("../icon/index.cjs");const oe=require("@vueuse/core"),m=require("@vft/utils"),b=require("../../utils/helper.cjs"),g=require("lodash-es"),le=require("../../hooks/use-id/index.cjs"),ae=require("../../hooks/use-namespace/index.cjs");require("../../hooks/use-model-toggle/index.cjs");require("@popperjs/core");require("../../hooks/use-z-index/index.cjs");const se=require("async-validator"),z=require("./constants.cjs"),ie=require("./form-label-wrap.cjs"),ne=require("./hooks/use-form-common-props.cjs"),ue=["role","aria-labelledby"],de=e.defineComponent({name:"vft-form-item"}),ce=e.defineComponent({...de,props:{label:{},labelWidth:{default:""},labelPosition:{},prop:{},required:{type:Boolean,default:void 0},rules:{},error:{},for:{},validateStatus:{},inlineMessage:{type:[String,Boolean],default:""},showMessage:{type:Boolean,default:!0},size:{},hideRequiredAsterisk:{type:Boolean},hideLabel:{type:Boolean,default:!1}},emits:["update:error"],setup($,{expose:A,emit:j}){const r=$,E=j,B=e.useSlots(),l=e.inject(z.formContextKey,void 0),L=e.inject(z.formItemContextKey,void 0),y=ne.useFormSize(void 0,{formItem:!1}),s=ae.useNamespace("form-item"),q=le.useId().value,d=e.ref([]),c=e.ref(""),D=oe.refDebounced(c,100),n=e.ref(""),x=e.ref();let F,v=!1;const h=e.computed(()=>r.labelPosition||l?.labelPosition),M=e.computed(()=>{if(h.value==="top")return{};const t=b.addUnit(r.labelWidth||l?.labelWidth||"");return t?{width:t}:{}}),T=e.computed(()=>{if(h.value==="top"||l?.inline)return{};if(!r.label&&!r.labelWidth&&O)return{};const t=b.addUnit(r.labelWidth||l?.labelWidth||"");return!r.label&&!B.label?{marginLeft:t}:{}}),K=e.computed(()=>[s.b(),s.m(y.value),s.is("error",c.value==="error"),s.is("validating",c.value==="validating"),s.is("success",c.value==="success"),s.is("required",Q.value||r.required),s.is("no-asterisk",r?.hideRequiredAsterisk||l?.hideRequiredAsterisk),l?.requireAsteriskPosition==="right"?"asterisk-right":"asterisk-left",{[s.m("feedback")]:l?.statusIcon,[s.m(`label-${h.value}`)]:h.value}]),U=e.computed(()=>m.isBoolean(r.inlineMessage)?r.inlineMessage:l?.inlineMessage||!1),G=e.computed(()=>[s.e("error"),{[s.em("error","inline")]:U.value}]),P=e.computed(()=>r.prop?g.isArray(r.prop)?r.prop.join("."):r.prop:""),S=e.computed(()=>!!(r.label||B.label)),C=e.computed(()=>r.for??(d.value.length===1?d.value[0]:void 0)),k=e.computed(()=>!C.value&&S.value),O=!!L,V=e.computed(()=>{const t=l?.model;if(!(!t||!r.prop))return m.getProp(t,r.prop).value}),w=e.computed(()=>{const{required:t}=r,o=[];r.rules&&o.push(...b.castArray(r.rules).map(a=>(a.trigger=a.trigger||"blur",a)));const i=l?.rules;if(i&&r.prop){const a=m.getProp(i,r.prop).value;a&&o.push(...b.castArray(a))}if(t!==void 0){const a=o.map((u,f)=>[u,f]).filter(([u])=>Object.keys(u).includes("required"));if(a.length>0)for(const[u,f]of a)u.required!==t&&(o[f]={...u,required:t});else o.push({required:t})}return o}),H=e.computed(()=>w.value.length>0),J=t=>w.value.filter(i=>!i.trigger||!t?!0:g.isArray(i.trigger)?i.trigger.includes(t):i.trigger===t).map(({trigger:i,...a})=>a),Q=e.computed(()=>w.value.some(t=>t.required)),X=e.computed(()=>D.value==="error"&&r.showMessage&&(l?.showMessage??!0)),R=e.computed(()=>`${r.label||""}${l?.labelSuffix||""}`),p=t=>{c.value=t},Y=t=>{const{errors:o,fields:i}=t;(!o||!i)&&console.error(t),p("error"),n.value=o?o?.[0]?.message??`${r.prop} is required`:"",l?.emit("validate",r.prop,!1,n.value)},Z=()=>{p("success"),l?.emit("validate",r.prop,!0,"")},ee=async t=>{const o=P.value;return new se({[o]:t}).validate({[o]:V.value},{firstFields:!0}).then(()=>(Z(),!0)).catch(a=>(Y(a),Promise.reject(a)))},N=async(t,o)=>{if(v||!r.prop)return!1;const i=m.isFunction(o);if(!H.value)return o?.(!1),!1;const a=J(t);return a.length===0?(o?.(!0),!0):(p("validating"),ee(a).then(()=>(o?.(!0),!0)).catch(u=>{const{fields:f}=u;return o?.(!1,f),i?!1:Promise.reject(f)}))},I=()=>{r.error&&E("update:error",""),p(""),n.value="",v=!1},W=async()=>{const t=l?.model;if(!t||!r.prop)return;const o=m.getProp(t,r.prop);v=!0,o.value=g.clone(F),await e.nextTick(),I(),v=!1},te=t=>{d.value.includes(t)||d.value.push(t)},re=t=>{d.value=d.value.filter(o=>o!==t)};e.watch(()=>r.error,t=>{n.value=t||"",p(t?"error":"")},{immediate:!0}),e.watch(()=>r.validateStatus,t=>p(t||""));const _=e.reactive({...e.toRefs(r),$el:x,size:y,validateMessage:n,validateState:c,labelId:q,inputIds:d,isGroup:k,hasLabel:S,fieldValue:V,addInputId:te,removeInputId:re,resetField:W,clearValidate:I,validate:N,propString:P});return e.provide(z.formItemContextKey,_),e.onMounted(()=>{r.prop&&(l?.addField(_),F=g.clone(V.value))}),e.onBeforeUnmount(()=>{l?.removeField(_)}),A({size:y,validateMessage:n,validateState:c,validate:N,clearValidate:I,resetField:W}),(t,o)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"formItemRef",ref:x,class:e.normalizeClass(K.value),role:k.value?"group":void 0,"aria-labelledby":k.value?e.unref(q):void 0},[t.hideLabel?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(ie.default),{key:0,"is-auto-width":M.value.width==="auto","update-all":e.unref(l)?.labelWidth==="auto"},{default:e.withCtx(()=>[S.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(C.value?"label":"div"),{key:0,id:e.unref(q),for:C.value,class:e.normalizeClass(e.unref(s).e("label")),style:e.normalizeStyle(M.value)},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"label",{label:R.value},()=>[e.createTextVNode(e.toDisplayString(R.value),1)])]),_:3},8,["id","for","class","style"])):e.createCommentVNode("",!0)]),_:3},8,["is-auto-width","update-all"])),e.createElementVNode("div",{class:e.normalizeClass(e.unref(s).e("content")),style:e.normalizeStyle(T.value)},[e.renderSlot(t.$slots,"default"),e.createVNode(e.TransitionGroup,{name:`${e.unref(s).namespace.value}-zoom-in-top`},{default:e.withCtx(()=>[X.value?e.renderSlot(t.$slots,"error",{key:0,error:n.value},()=>[e.createElementVNode("div",{class:e.normalizeClass(G.value)},e.toDisplayString(n.value),3)]):e.createCommentVNode("",!0)]),_:3},8,["name"])],6)],10,ue))}});exports.default=ce;
|
|
@@ -206,10 +206,6 @@ export declare const VftForm: import("vft/es/utils").SFCWithInstall<{
|
|
|
206
206
|
size: {
|
|
207
207
|
type: import("vue").PropType<import("vft/es/constants").ComponentSize>;
|
|
208
208
|
};
|
|
209
|
-
required: {
|
|
210
|
-
type: import("vue").PropType<boolean>;
|
|
211
|
-
default: undefined;
|
|
212
|
-
};
|
|
213
209
|
rules: {
|
|
214
210
|
type: import("vue").PropType<import("vft/es/utils").Arrayable<import("./types").FormItemRule>>;
|
|
215
211
|
};
|
|
@@ -231,6 +227,10 @@ export declare const VftForm: import("vft/es/utils").SFCWithInstall<{
|
|
|
231
227
|
hideRequiredAsterisk: {
|
|
232
228
|
type: import("vue").PropType<boolean>;
|
|
233
229
|
};
|
|
230
|
+
required: {
|
|
231
|
+
type: import("vue").PropType<boolean>;
|
|
232
|
+
default: undefined;
|
|
233
|
+
};
|
|
234
234
|
for: {
|
|
235
235
|
type: import("vue").PropType<string>;
|
|
236
236
|
};
|
|
@@ -253,10 +253,10 @@ export declare const VftForm: import("vft/es/utils").SFCWithInstall<{
|
|
|
253
253
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
254
254
|
"update:error": (val: string) => void;
|
|
255
255
|
}, import("vue").PublicProps, {
|
|
256
|
-
required: boolean;
|
|
257
256
|
labelWidth: string | number;
|
|
258
257
|
inlineMessage: string | boolean;
|
|
259
258
|
showMessage: boolean;
|
|
259
|
+
required: boolean;
|
|
260
260
|
hideLabel: boolean;
|
|
261
261
|
}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
262
262
|
P: {};
|
|
@@ -278,10 +278,6 @@ export declare const VftForm: import("vft/es/utils").SFCWithInstall<{
|
|
|
278
278
|
size: {
|
|
279
279
|
type: import("vue").PropType<import("vft/es/constants").ComponentSize>;
|
|
280
280
|
};
|
|
281
|
-
required: {
|
|
282
|
-
type: import("vue").PropType<boolean>;
|
|
283
|
-
default: undefined;
|
|
284
|
-
};
|
|
285
281
|
rules: {
|
|
286
282
|
type: import("vue").PropType<import("vft/es/utils").Arrayable<import("./types").FormItemRule>>;
|
|
287
283
|
};
|
|
@@ -303,6 +299,10 @@ export declare const VftForm: import("vft/es/utils").SFCWithInstall<{
|
|
|
303
299
|
hideRequiredAsterisk: {
|
|
304
300
|
type: import("vue").PropType<boolean>;
|
|
305
301
|
};
|
|
302
|
+
required: {
|
|
303
|
+
type: import("vue").PropType<boolean>;
|
|
304
|
+
default: undefined;
|
|
305
|
+
};
|
|
306
306
|
for: {
|
|
307
307
|
type: import("vue").PropType<string>;
|
|
308
308
|
};
|
|
@@ -323,10 +323,10 @@ export declare const VftForm: import("vft/es/utils").SFCWithInstall<{
|
|
|
323
323
|
clearValidate: () => void;
|
|
324
324
|
resetField: () => void;
|
|
325
325
|
}, {}, {}, {}, {
|
|
326
|
-
required: boolean;
|
|
327
326
|
labelWidth: string | number;
|
|
328
327
|
inlineMessage: string | boolean;
|
|
329
328
|
showMessage: boolean;
|
|
329
|
+
required: boolean;
|
|
330
330
|
hideLabel: boolean;
|
|
331
331
|
}>;
|
|
332
332
|
__isFragment?: never;
|
|
@@ -345,10 +345,6 @@ export declare const VftForm: import("vft/es/utils").SFCWithInstall<{
|
|
|
345
345
|
size: {
|
|
346
346
|
type: import("vue").PropType<import("vft/es/constants").ComponentSize>;
|
|
347
347
|
};
|
|
348
|
-
required: {
|
|
349
|
-
type: import("vue").PropType<boolean>;
|
|
350
|
-
default: undefined;
|
|
351
|
-
};
|
|
352
348
|
rules: {
|
|
353
349
|
type: import("vue").PropType<import("vft/es/utils").Arrayable<import("./types").FormItemRule>>;
|
|
354
350
|
};
|
|
@@ -370,6 +366,10 @@ export declare const VftForm: import("vft/es/utils").SFCWithInstall<{
|
|
|
370
366
|
hideRequiredAsterisk: {
|
|
371
367
|
type: import("vue").PropType<boolean>;
|
|
372
368
|
};
|
|
369
|
+
required: {
|
|
370
|
+
type: import("vue").PropType<boolean>;
|
|
371
|
+
default: undefined;
|
|
372
|
+
};
|
|
373
373
|
for: {
|
|
374
374
|
type: import("vue").PropType<string>;
|
|
375
375
|
};
|
|
@@ -392,10 +392,10 @@ export declare const VftForm: import("vft/es/utils").SFCWithInstall<{
|
|
|
392
392
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
393
393
|
"update:error": (val: string) => void;
|
|
394
394
|
}, string, {
|
|
395
|
-
required: boolean;
|
|
396
395
|
labelWidth: string | number;
|
|
397
396
|
inlineMessage: string | boolean;
|
|
398
397
|
showMessage: boolean;
|
|
398
|
+
required: boolean;
|
|
399
399
|
hideLabel: boolean;
|
|
400
400
|
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
401
401
|
$slots: {
|
|
@@ -423,10 +423,6 @@ export declare const VftFormItem: import("vft/es/utils").SFCWithInstall<{
|
|
|
423
423
|
size: {
|
|
424
424
|
type: import("vue").PropType<import("vft/es/constants").ComponentSize>;
|
|
425
425
|
};
|
|
426
|
-
required: {
|
|
427
|
-
type: import("vue").PropType<boolean>;
|
|
428
|
-
default: undefined;
|
|
429
|
-
};
|
|
430
426
|
rules: {
|
|
431
427
|
type: import("vue").PropType<import("vft/es/utils").Arrayable<import("./types").FormItemRule>>;
|
|
432
428
|
};
|
|
@@ -448,6 +444,10 @@ export declare const VftFormItem: import("vft/es/utils").SFCWithInstall<{
|
|
|
448
444
|
hideRequiredAsterisk: {
|
|
449
445
|
type: import("vue").PropType<boolean>;
|
|
450
446
|
};
|
|
447
|
+
required: {
|
|
448
|
+
type: import("vue").PropType<boolean>;
|
|
449
|
+
default: undefined;
|
|
450
|
+
};
|
|
451
451
|
for: {
|
|
452
452
|
type: import("vue").PropType<string>;
|
|
453
453
|
};
|
|
@@ -470,10 +470,10 @@ export declare const VftFormItem: import("vft/es/utils").SFCWithInstall<{
|
|
|
470
470
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
471
471
|
"update:error": (val: string) => void;
|
|
472
472
|
}, import("vue").PublicProps, {
|
|
473
|
-
required: boolean;
|
|
474
473
|
labelWidth: string | number;
|
|
475
474
|
inlineMessage: string | boolean;
|
|
476
475
|
showMessage: boolean;
|
|
476
|
+
required: boolean;
|
|
477
477
|
hideLabel: boolean;
|
|
478
478
|
}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
479
479
|
P: {};
|
|
@@ -495,10 +495,6 @@ export declare const VftFormItem: import("vft/es/utils").SFCWithInstall<{
|
|
|
495
495
|
size: {
|
|
496
496
|
type: import("vue").PropType<import("vft/es/constants").ComponentSize>;
|
|
497
497
|
};
|
|
498
|
-
required: {
|
|
499
|
-
type: import("vue").PropType<boolean>;
|
|
500
|
-
default: undefined;
|
|
501
|
-
};
|
|
502
498
|
rules: {
|
|
503
499
|
type: import("vue").PropType<import("vft/es/utils").Arrayable<import("./types").FormItemRule>>;
|
|
504
500
|
};
|
|
@@ -520,6 +516,10 @@ export declare const VftFormItem: import("vft/es/utils").SFCWithInstall<{
|
|
|
520
516
|
hideRequiredAsterisk: {
|
|
521
517
|
type: import("vue").PropType<boolean>;
|
|
522
518
|
};
|
|
519
|
+
required: {
|
|
520
|
+
type: import("vue").PropType<boolean>;
|
|
521
|
+
default: undefined;
|
|
522
|
+
};
|
|
523
523
|
for: {
|
|
524
524
|
type: import("vue").PropType<string>;
|
|
525
525
|
};
|
|
@@ -540,10 +540,10 @@ export declare const VftFormItem: import("vft/es/utils").SFCWithInstall<{
|
|
|
540
540
|
clearValidate: () => void;
|
|
541
541
|
resetField: () => void;
|
|
542
542
|
}, {}, {}, {}, {
|
|
543
|
-
required: boolean;
|
|
544
543
|
labelWidth: string | number;
|
|
545
544
|
inlineMessage: string | boolean;
|
|
546
545
|
showMessage: boolean;
|
|
546
|
+
required: boolean;
|
|
547
547
|
hideLabel: boolean;
|
|
548
548
|
}>;
|
|
549
549
|
__isFragment?: never;
|
|
@@ -562,10 +562,6 @@ export declare const VftFormItem: import("vft/es/utils").SFCWithInstall<{
|
|
|
562
562
|
size: {
|
|
563
563
|
type: import("vue").PropType<import("vft/es/constants").ComponentSize>;
|
|
564
564
|
};
|
|
565
|
-
required: {
|
|
566
|
-
type: import("vue").PropType<boolean>;
|
|
567
|
-
default: undefined;
|
|
568
|
-
};
|
|
569
565
|
rules: {
|
|
570
566
|
type: import("vue").PropType<import("vft/es/utils").Arrayable<import("./types").FormItemRule>>;
|
|
571
567
|
};
|
|
@@ -587,6 +583,10 @@ export declare const VftFormItem: import("vft/es/utils").SFCWithInstall<{
|
|
|
587
583
|
hideRequiredAsterisk: {
|
|
588
584
|
type: import("vue").PropType<boolean>;
|
|
589
585
|
};
|
|
586
|
+
required: {
|
|
587
|
+
type: import("vue").PropType<boolean>;
|
|
588
|
+
default: undefined;
|
|
589
|
+
};
|
|
590
590
|
for: {
|
|
591
591
|
type: import("vue").PropType<string>;
|
|
592
592
|
};
|
|
@@ -609,10 +609,10 @@ export declare const VftFormItem: import("vft/es/utils").SFCWithInstall<{
|
|
|
609
609
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
610
610
|
"update:error": (val: string) => void;
|
|
611
611
|
}, string, {
|
|
612
|
-
required: boolean;
|
|
613
612
|
labelWidth: string | number;
|
|
614
613
|
inlineMessage: string | boolean;
|
|
615
614
|
showMessage: boolean;
|
|
615
|
+
required: boolean;
|
|
616
616
|
hideLabel: boolean;
|
|
617
617
|
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
618
618
|
$slots: {
|