vft 0.0.496 → 0.0.498
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/component.js +18 -16
- package/es/components/autocomplete/autocomplete.vue.d.ts +2 -2
- package/es/components/autocomplete/index.d.ts +6 -6
- package/es/components/button/index.d.ts +9 -9
- package/es/components/index.d.ts +1 -0
- package/es/components/index.js +257 -255
- package/es/components/modal/index.d.ts +6 -0
- package/es/components/modal/modal.vue.d.ts +3 -0
- package/es/components/modal/modal.vue2.js +12 -12
- 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 +4 -0
- package/es/components/select/defaults.js +7 -3
- package/es/components/select/index.d.ts +13 -4
- package/es/components/select/select.vue.d.ts +13 -4
- package/es/components/select/select.vue.js +9 -8
- package/es/components/select/select.vue2.js +40 -29
- package/es/components/select/token.d.ts +4 -1
- package/es/components/select/useSelect.d.ts +4 -4
- package/es/components/super-form/index.d.ts +9 -0
- package/es/components/super-form/style/css.d.ts +1 -0
- package/es/components/super-form/style/css.js +2 -0
- package/es/components/super-form/style/index.d.ts +1 -0
- package/es/components/super-form/style/index.js +2 -0
- package/es/components/super-form/super-form-item.vue2.js +355 -255
- package/es/components/super-form/super-form.vue2.js +1 -1
- package/es/components/super-form/types.d.ts +26 -1
- package/es/components/super-form/use/helper.js +37 -36
- package/es/components/super-form/use/use-form-events.js +126 -125
- package/es/components/table/index.d.ts +9 -6
- package/es/components/table/style/css.js +2 -0
- package/es/components/table/style/index.js +2 -0
- package/es/components/table/table.vue.d.ts +2 -1
- package/es/components/table/table.vue2.js +99 -94
- package/es/components/table/types.d.ts +5 -3
- package/es/components/table/use/use-data-source.d.ts +6 -4
- package/es/components/table/use/use-data-source.js +150 -148
- package/es/components/table/use/use-table.js +8 -8
- package/es/components/tree/index.d.ts +71 -71
- package/es/components/tree/tree-node.vue.d.ts +1 -1
- package/es/components/tree/tree.type.d.ts +2 -0
- package/es/components/tree/tree.vue.d.ts +14 -14
- package/es/components/tree-select/cache-options.d.ts +20 -0
- package/es/components/tree-select/cache-options.js +30 -0
- package/es/components/tree-select/index.d.ts +8 -0
- package/es/components/tree-select/index.js +10 -0
- package/es/components/tree-select/instance.d.ts +5 -0
- package/es/components/tree-select/instance.js +1 -0
- package/es/components/tree-select/select.d.ts +10 -0
- package/es/components/tree-select/select.js +129 -0
- package/es/components/tree-select/style/css.d.ts +4 -0
- package/es/components/tree-select/style/css.js +11 -0
- package/es/components/tree-select/style/index.d.ts +4 -0
- package/es/components/tree-select/style/index.js +11 -0
- package/es/components/tree-select/tree-select-option.d.ts +42 -0
- package/es/components/tree-select/tree-select-option.js +35 -0
- package/es/components/tree-select/tree-select.vue.d.ts +4 -0
- package/es/components/tree-select/tree-select.vue.js +5 -0
- package/es/components/tree-select/tree-select.vue2.js +155 -0
- package/es/components/tree-select/tree.d.ts +11 -0
- package/es/components/tree-select/tree.js +201 -0
- package/es/components/tree-select/utils.d.ts +10 -0
- package/es/components/tree-select/utils.js +45 -0
- package/es/index.js +1 -0
- package/es/package.json.d.ts +1 -1
- package/es/package.json.js +1 -1
- package/es/script.css +1 -1
- package/es/utils/form-register.d.ts +1 -0
- package/es/utils/form-register.js +11 -10
- package/lib/component.cjs +1 -1
- package/lib/components/autocomplete/autocomplete.vue.d.ts +2 -2
- package/lib/components/autocomplete/index.d.ts +6 -6
- package/lib/components/button/index.d.ts +9 -9
- package/lib/components/index.cjs +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/modal/index.d.ts +6 -0
- package/lib/components/modal/modal.vue.d.ts +3 -0
- package/lib/components/modal/modal.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 +4 -0
- package/lib/components/select/index.d.ts +13 -4
- package/lib/components/select/select.vue.cjs +1 -1
- package/lib/components/select/select.vue.d.ts +13 -4
- package/lib/components/select/select.vue2.cjs +1 -1
- package/lib/components/select/token.d.ts +4 -1
- package/lib/components/select/useSelect.d.ts +4 -4
- package/lib/components/super-form/index.d.ts +9 -0
- package/lib/components/super-form/style/css.cjs +1 -1
- package/lib/components/super-form/style/css.d.ts +1 -0
- package/lib/components/super-form/style/index.cjs +1 -1
- package/lib/components/super-form/style/index.d.ts +1 -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 +26 -1
- package/lib/components/super-form/use/helper.cjs +1 -1
- package/lib/components/super-form/use/use-form-events.cjs +1 -1
- package/lib/components/table/index.d.ts +9 -6
- package/lib/components/table/style/css.cjs +1 -1
- package/lib/components/table/style/index.cjs +1 -1
- package/lib/components/table/table.vue.d.ts +2 -1
- package/lib/components/table/table.vue2.cjs +1 -1
- package/lib/components/table/types.d.ts +5 -3
- package/lib/components/table/use/use-data-source.cjs +1 -1
- package/lib/components/table/use/use-data-source.d.ts +6 -4
- package/lib/components/table/use/use-table.cjs +1 -1
- package/lib/components/tree/index.d.ts +71 -71
- package/lib/components/tree/tree-node.vue.d.ts +1 -1
- package/lib/components/tree/tree.type.d.ts +2 -0
- package/lib/components/tree/tree.vue.d.ts +14 -14
- package/lib/components/tree-select/cache-options.cjs +1 -0
- package/lib/components/tree-select/cache-options.d.ts +20 -0
- package/lib/components/tree-select/index.cjs +1 -0
- package/lib/components/tree-select/index.d.ts +8 -0
- package/lib/components/tree-select/instance.cjs +1 -0
- package/lib/components/tree-select/instance.d.ts +5 -0
- package/lib/components/tree-select/select.cjs +1 -0
- package/lib/components/tree-select/select.d.ts +10 -0
- package/lib/components/tree-select/style/css.cjs +1 -0
- package/lib/components/tree-select/style/css.d.ts +4 -0
- package/lib/components/tree-select/style/index.cjs +1 -0
- package/lib/components/tree-select/style/index.d.ts +4 -0
- package/lib/components/tree-select/tree-select-option.cjs +1 -0
- package/lib/components/tree-select/tree-select-option.d.ts +42 -0
- package/lib/components/tree-select/tree-select.vue.cjs +1 -0
- package/lib/components/tree-select/tree-select.vue.d.ts +4 -0
- package/lib/components/tree-select/tree-select.vue2.cjs +1 -0
- package/lib/components/tree-select/tree.cjs +1 -0
- package/lib/components/tree-select/tree.d.ts +11 -0
- package/lib/components/tree-select/utils.cjs +1 -0
- package/lib/components/tree-select/utils.d.ts +10 -0
- package/lib/index.cjs +1 -1
- package/lib/package.json.cjs +1 -1
- package/lib/package.json.d.ts +1 -1
- package/lib/script.css +1 -1
- package/lib/utils/form-register.cjs +1 -1
- package/lib/utils/form-register.d.ts +1 -0
- package/package.json +5 -5
- package/theme-style/index.css +1 -1
- package/theme-style/src/cascader.scss +1 -12
- package/theme-style/src/tree-select.scss +10 -1
- package/theme-style/vft-cascader.css +1 -1
- package/theme-style/vft-tree-select.css +1 -1
- package/web-types.json +1 -1
|
@@ -111,6 +111,7 @@ const _e = J({
|
|
|
111
111
|
labelWidth: {
|
|
112
112
|
default: "auto"
|
|
113
113
|
},
|
|
114
|
+
labelSuffix: {},
|
|
114
115
|
formatter: {},
|
|
115
116
|
disabled: {
|
|
116
117
|
type: Boolean
|
|
@@ -120,7 +121,6 @@ const _e = J({
|
|
|
120
121
|
requireAsteriskPosition: {
|
|
121
122
|
default: "left"
|
|
122
123
|
},
|
|
123
|
-
labelSuffix: {},
|
|
124
124
|
inline: {
|
|
125
125
|
type: Boolean
|
|
126
126
|
},
|
|
@@ -24,7 +24,7 @@ import type { ComponentSize } from 'vft/es/constants';
|
|
|
24
24
|
import type { Arrayable } from 'vft/es/utils';
|
|
25
25
|
import { type FormCompEnumType } from 'vft/es/utils';
|
|
26
26
|
import type { InternalRuleItem, RuleItem } from 'async-validator';
|
|
27
|
-
import type { ComponentPublicInstance, Ref, StyleValue, VNode } from 'vue';
|
|
27
|
+
import type { ComponentPublicInstance, Ref, StyleValue, VNode, WatchOptions } from 'vue';
|
|
28
28
|
import type { Recordable } from '../types';
|
|
29
29
|
/** 按钮配置选项 */
|
|
30
30
|
export type ButtonOptions = Partial<ButtonProps> & {
|
|
@@ -57,6 +57,12 @@ type FormItemRule = Omit<RuleItem, 'validator'> & Rule & {
|
|
|
57
57
|
};
|
|
58
58
|
export type SchemaCompOptions = InputProps | SelectV2Props | RadioGroupProps | CheckboxGroupProps | DatePickerProps | TimePickerDefaultProps | CascaderProps | AutocompleteProps | ColorPickerProps | UploadProps | SliderProps | InputNumberProps | InputTagProps | DividerProps | SearchProps | SwitchProps | {
|
|
59
59
|
onClear?: Function;
|
|
60
|
+
} | {
|
|
61
|
+
/** 组件异步请求数据 */
|
|
62
|
+
request?: RequestConfig;
|
|
63
|
+
/** 组件异步请求数据结果 */
|
|
64
|
+
requestResult?: any;
|
|
65
|
+
[key: string]: any;
|
|
60
66
|
} | Record<string, any>;
|
|
61
67
|
/** 渲染回调参数接口 */
|
|
62
68
|
export interface RenderCallbackParams {
|
|
@@ -70,7 +76,22 @@ export interface RenderCallbackParams {
|
|
|
70
76
|
field: string;
|
|
71
77
|
/** 组件实例引用 */
|
|
72
78
|
elRef?: Ref<ComponentPublicInstance | null>;
|
|
79
|
+
/** 表单操作方法 */
|
|
80
|
+
formActionType?: Partial<FormActionType>;
|
|
73
81
|
}
|
|
82
|
+
/** Promise 函数类型 */
|
|
83
|
+
type PromiseFn<T, R = any> = (params: T) => Promise<R>;
|
|
84
|
+
/** 组件异步请求配置 */
|
|
85
|
+
export type RequestConfig = PromiseFn<RenderCallbackParams, any> | {
|
|
86
|
+
/** 指定监听的字段名, 当该字段值发生变化时会调用 callback */
|
|
87
|
+
watchFields: string[];
|
|
88
|
+
callback: PromiseFn<RenderCallbackParams, any>;
|
|
89
|
+
options?: WatchOptions;
|
|
90
|
+
/** debounce 请求防抖 */
|
|
91
|
+
wait?: number;
|
|
92
|
+
/** 请求成功后的回调函数 */
|
|
93
|
+
onSuccess?: (result: any, params: RenderCallbackParams) => void | Promise<void>;
|
|
94
|
+
};
|
|
74
95
|
/** 表单操作方法接口 */
|
|
75
96
|
export interface FormActionType {
|
|
76
97
|
/** 提交表单 */
|
|
@@ -197,6 +218,8 @@ export interface SuperFormProps extends FormInnerProps {
|
|
|
197
218
|
submitResetReverse?: boolean;
|
|
198
219
|
labelPosition?: 'left' | 'right' | 'top';
|
|
199
220
|
labelWidth?: string | number;
|
|
221
|
+
/** Label 后缀字符,如 ':',默认为空字符串 */
|
|
222
|
+
labelSuffix?: string;
|
|
200
223
|
/** 表单值格式化函数,用于格式化 getFieldsValue 的输出值 */
|
|
201
224
|
formatter?: (values: Recordable) => Recordable;
|
|
202
225
|
}
|
|
@@ -284,6 +307,8 @@ export interface FormSchema {
|
|
|
284
307
|
helpIcon?: IconProps | string;
|
|
285
308
|
/** 帮助提示配置 */
|
|
286
309
|
helpTooltip?: string | ToolTipProps;
|
|
310
|
+
/** Label 后缀字符,如 ':',优先级高于 formProps.labelSuffix */
|
|
311
|
+
labelSuffix?: string;
|
|
287
312
|
/** 字段值格式化函数,用于格式化该字段在 getFieldsValue 中的输出值 */
|
|
288
313
|
formatter?: (value: any, field: string, values: Recordable, schema: FormSchema) => any;
|
|
289
314
|
}
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import { isBoolean as l, isFunction as a, isNumber as
|
|
2
|
-
import { isInput as
|
|
1
|
+
import { isBoolean as l, isFunction as a, isNumber as S } from "@vft/utils";
|
|
2
|
+
import { isInput as h } from "../component-map.js";
|
|
3
3
|
import { FormCompEnum as i } from "../../../utils/form-register.js";
|
|
4
4
|
import "@vueuse/core";
|
|
5
5
|
import "../../config-provider/hooks/use-global-config.js";
|
|
6
6
|
import "vue";
|
|
7
7
|
import "lodash-es";
|
|
8
8
|
import "../../form/index.js";
|
|
9
|
-
function
|
|
9
|
+
function b(t, e = "") {
|
|
10
10
|
return e = (e || "").replace(":", "") || "", [
|
|
11
11
|
i.Input,
|
|
12
12
|
i.InputNumber,
|
|
13
13
|
i.Textarea,
|
|
14
14
|
i.AutoComplete
|
|
15
|
-
].includes(
|
|
15
|
+
].includes(t) ? "请输入" + e : [i.Password].includes(t) ? "请输入密码" : [
|
|
16
16
|
i.Select,
|
|
17
17
|
i.Radio,
|
|
18
18
|
i.RadioSingle,
|
|
19
19
|
i.RadioButton,
|
|
20
20
|
i.Cascader,
|
|
21
|
+
i.TreeSelect,
|
|
21
22
|
i.ColorPicker,
|
|
22
23
|
i.Checkbox,
|
|
23
24
|
i.CheckboxButton
|
|
24
|
-
].includes(
|
|
25
|
+
].includes(t) ? "请选择" + e : [i.CheckboxSingle].includes(t) ? "请勾选" + e : [i.Search].includes(t) ? "请输入要搜索的内容" : [i.InputTag].includes(t) ? "请输入标签内容" : [i.Upload].includes(t) ? "请选择上传文件" : [i.Slider].includes(t) ? "请拖动滑块" : [
|
|
25
26
|
i.TimePicker,
|
|
26
27
|
i.YearPicker,
|
|
27
28
|
i.MonthPicker,
|
|
@@ -32,59 +33,59 @@ function P(n, e = "") {
|
|
|
32
33
|
i.DateTimeRangePicker,
|
|
33
34
|
i.DateRangePicker,
|
|
34
35
|
i.MonthRangePicker
|
|
35
|
-
].includes(
|
|
36
|
+
].includes(t) ? "请选择时间" : "";
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
-
return
|
|
38
|
+
function P(t, e) {
|
|
39
|
+
return t && h(t) && e && S(e) ? `${e}` : e;
|
|
39
40
|
}
|
|
40
|
-
function k(
|
|
41
|
-
const { show:
|
|
42
|
-
let
|
|
43
|
-
return l(
|
|
41
|
+
function k(t, e) {
|
|
42
|
+
const { show: n, ifShow: o } = t;
|
|
43
|
+
let u = !0, c = !0;
|
|
44
|
+
return l(n) ? u = n : a(n) && e && (u = n(e)), l(o) ? c = o : a(o) && e && (c = o(e)), { isShow: u, isIfShow: c };
|
|
44
45
|
}
|
|
45
|
-
function m(
|
|
46
|
-
const { baseColProps:
|
|
47
|
-
return
|
|
46
|
+
function m(t, e) {
|
|
47
|
+
const { baseColProps: n = {}, quickColSpan: o } = e;
|
|
48
|
+
return t.type === i.Divider ? 24 : t.colProps?.span !== void 0 ? t.colProps.span : t.quickColSpan ? Math.ceil(24 / t.quickColSpan) : n.span !== void 0 ? n.span : o ? Math.ceil(24 / o) : 24;
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
+
function q(t, e, n, o) {
|
|
50
51
|
if (e.customLayout)
|
|
51
52
|
return {
|
|
52
53
|
willExceed: !1,
|
|
53
54
|
totalSpan: 0,
|
|
54
55
|
visibleItems: []
|
|
55
56
|
};
|
|
56
|
-
const
|
|
57
|
-
let
|
|
58
|
-
for (const
|
|
59
|
-
const
|
|
60
|
-
field:
|
|
61
|
-
model:
|
|
57
|
+
const u = [];
|
|
58
|
+
let c = 0;
|
|
59
|
+
for (const r of t) {
|
|
60
|
+
const p = n && o ? {
|
|
61
|
+
field: r.field,
|
|
62
|
+
model: n,
|
|
62
63
|
values: {
|
|
63
64
|
...o,
|
|
64
|
-
...
|
|
65
|
+
...n
|
|
65
66
|
},
|
|
66
|
-
schema:
|
|
67
|
-
} : void 0, { isIfShow:
|
|
68
|
-
if (!
|
|
67
|
+
schema: r
|
|
68
|
+
} : void 0, { isIfShow: f } = k(r, p);
|
|
69
|
+
if (!f)
|
|
69
70
|
continue;
|
|
70
|
-
const s = m(
|
|
71
|
-
|
|
71
|
+
const s = m(r, e);
|
|
72
|
+
u.push({ field: r.field, span: s }), c += s;
|
|
72
73
|
}
|
|
73
74
|
const d = e.showCommonButton || e.showResetButton || e.showSubmitButton;
|
|
74
75
|
if (e.actionInline && e.showActionButtonGroup && d && !e.customLayout) {
|
|
75
|
-
const
|
|
76
|
-
|
|
76
|
+
const r = e.quickColSpan ? Math.ceil(24 / e.quickColSpan) : e.baseColProps?.span || 24;
|
|
77
|
+
c += r;
|
|
77
78
|
}
|
|
78
79
|
return {
|
|
79
|
-
willExceed:
|
|
80
|
-
totalSpan:
|
|
81
|
-
visibleItems:
|
|
80
|
+
willExceed: c > 24,
|
|
81
|
+
totalSpan: c,
|
|
82
|
+
visibleItems: u
|
|
82
83
|
};
|
|
83
84
|
}
|
|
84
85
|
export {
|
|
85
86
|
m as calculateSchemaSpan,
|
|
86
|
-
|
|
87
|
+
b as createPlaceholderMessage,
|
|
87
88
|
k as getSchemaShowState,
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
P as handleInputNumberValue,
|
|
90
|
+
q as willFormExceedOneRow
|
|
90
91
|
};
|
|
@@ -1,156 +1,156 @@
|
|
|
1
|
-
import { FormCompEnum as
|
|
1
|
+
import { FormCompEnum as _ } from "../../../utils/form-register.js";
|
|
2
2
|
import "@vueuse/core";
|
|
3
|
-
import { isDef as H, isFunction as E, isString as
|
|
3
|
+
import { isDef as H, isFunction as E, isString as T, isObject as C, isArray as I, deepMerge as rt, findDifferentValuesForObj as st, isNullOrUndefined as J, isEmpty as ot, isEmptyObject as lt } from "@vft/utils";
|
|
4
4
|
import "../../config-provider/hooks/use-global-config.js";
|
|
5
|
-
import { unref as n, toRaw as
|
|
6
|
-
import { get as
|
|
5
|
+
import { unref as n, toRaw as S, nextTick as P } from "vue";
|
|
6
|
+
import { get as at, cloneDeep as A, uniqBy as ct, isEqual as ft, set as W } from "lodash-es";
|
|
7
7
|
import "../../form/index.js";
|
|
8
8
|
import { formatToDate as Q } from "@vft/utils/date";
|
|
9
9
|
import { isInput as ut, isDatePicker as dt } from "../component-map.js";
|
|
10
10
|
import { handleInputNumberValue as pt } from "./helper.js";
|
|
11
|
-
function
|
|
12
|
-
const { show:
|
|
13
|
-
let
|
|
14
|
-
return typeof
|
|
11
|
+
function q(h, y) {
|
|
12
|
+
const { show: l, ifShow: c } = h;
|
|
13
|
+
let F = !0, u = !0;
|
|
14
|
+
return typeof l == "boolean" ? F = l : typeof l == "function" && (F = l({
|
|
15
15
|
field: h.field,
|
|
16
|
-
model:
|
|
16
|
+
model: y,
|
|
17
17
|
values: {
|
|
18
|
-
...
|
|
18
|
+
...y
|
|
19
19
|
},
|
|
20
20
|
schema: h
|
|
21
21
|
})), typeof c == "boolean" ? u = c : typeof c == "function" && (u = c({
|
|
22
22
|
field: h.field,
|
|
23
|
-
model:
|
|
23
|
+
model: y,
|
|
24
24
|
values: {
|
|
25
|
-
...
|
|
25
|
+
...y
|
|
26
26
|
},
|
|
27
27
|
schema: h
|
|
28
|
-
})),
|
|
28
|
+
})), F && u;
|
|
29
29
|
}
|
|
30
|
-
function ht(h,
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
const c = h.match(
|
|
30
|
+
function ht(h, y = {}) {
|
|
31
|
+
const l = /^\[(.+)\]$/;
|
|
32
|
+
if (l.test(h)) {
|
|
33
|
+
const c = h.match(l);
|
|
34
34
|
if (c && c[1]) {
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
35
|
+
const F = c[1].split(",");
|
|
36
|
+
if (!F.length)
|
|
37
37
|
return;
|
|
38
38
|
const u = [];
|
|
39
|
-
return
|
|
40
|
-
W(u, V,
|
|
39
|
+
return F.forEach((v, V) => {
|
|
40
|
+
W(u, V, y[v.trim()]);
|
|
41
41
|
}), u.filter(Boolean).length ? u : void 0;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
const c = h.match(
|
|
45
|
+
function yt(h, y = {}) {
|
|
46
|
+
const l = /^\{(.+)\}$/;
|
|
47
|
+
if (l.test(h)) {
|
|
48
|
+
const c = h.match(l);
|
|
49
49
|
if (c && c[1]) {
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
50
|
+
const F = c[1].split(",");
|
|
51
|
+
if (!F.length)
|
|
52
52
|
return;
|
|
53
53
|
const u = {};
|
|
54
|
-
return
|
|
55
|
-
W(u, v.trim(),
|
|
54
|
+
return F.forEach((v) => {
|
|
55
|
+
W(u, v.trim(), y[v.trim()]);
|
|
56
56
|
}), Object.values(u).filter(Boolean).length ? u : void 0;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function jt({
|
|
61
61
|
emit: h,
|
|
62
|
-
getProps:
|
|
63
|
-
formModel:
|
|
62
|
+
getProps: y,
|
|
63
|
+
formModel: l,
|
|
64
64
|
getSchema: c,
|
|
65
|
-
defaultValueRef:
|
|
65
|
+
defaultValueRef: F,
|
|
66
66
|
formElRef: u,
|
|
67
67
|
schemaRef: v,
|
|
68
68
|
handleFormValues: V,
|
|
69
|
-
initValues:
|
|
69
|
+
initValues: L
|
|
70
70
|
}) {
|
|
71
71
|
async function X(t) {
|
|
72
|
-
const { resetFunc: i, submitOnReset: r } = n(
|
|
72
|
+
const { resetFunc: i, submitOnReset: r } = n(y);
|
|
73
73
|
i && E(i) && await i();
|
|
74
74
|
const s = n(u);
|
|
75
75
|
if (s) {
|
|
76
76
|
if (t?.length)
|
|
77
77
|
return s.resetFields(t);
|
|
78
|
-
Object.keys(
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
}), P(() =>
|
|
78
|
+
Object.keys(l).forEach((o) => {
|
|
79
|
+
const a = n(c).find((f) => f.field === o), e = A(F.value[o]);
|
|
80
|
+
l[o] = ut(a?.type) ? e || "" : e;
|
|
81
|
+
}), P(() => O()), h("reset", S(l)), r && await G();
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
async function
|
|
84
|
+
async function N(t, i = !0) {
|
|
85
85
|
const r = n(c).map((e) => e.field).filter(Boolean), s = ".", o = r.filter(
|
|
86
86
|
(e) => String(e).indexOf(s) >= 0
|
|
87
|
-
),
|
|
87
|
+
), a = [];
|
|
88
88
|
r.forEach((e) => {
|
|
89
89
|
const f = n(c).find((p) => p.field === e);
|
|
90
|
-
let
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const { componentProps:
|
|
94
|
-
let
|
|
95
|
-
typeof
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
const p =
|
|
90
|
+
let b = at(t, e);
|
|
91
|
+
const d = Reflect.has(t, e);
|
|
92
|
+
b = pt(f?.type, b);
|
|
93
|
+
const { componentProps: w } = f || {};
|
|
94
|
+
let m = w;
|
|
95
|
+
typeof w == "function" && (m = m({ formModel: n(l) }));
|
|
96
|
+
const B = ht(e, t) || yt(e, t);
|
|
97
|
+
if (d || B) {
|
|
98
|
+
const p = B || b;
|
|
99
99
|
if (tt(e))
|
|
100
100
|
if (Array.isArray(p)) {
|
|
101
101
|
const D = [];
|
|
102
|
-
for (const
|
|
103
|
-
D.push(
|
|
104
|
-
n(
|
|
102
|
+
for (const j of p)
|
|
103
|
+
D.push(j ? Q(j) : null);
|
|
104
|
+
n(l)[e] = D;
|
|
105
105
|
} else
|
|
106
|
-
n(
|
|
106
|
+
n(l)[e] = p ? m?.valueFormat ? p : Q(p) : null;
|
|
107
107
|
else
|
|
108
|
-
n(
|
|
109
|
-
|
|
108
|
+
n(l)[e] = p;
|
|
109
|
+
m?.onChange && m?.onChange(p), a.push(e);
|
|
110
110
|
} else
|
|
111
111
|
o.forEach((p) => {
|
|
112
112
|
try {
|
|
113
|
-
const D = p.split(".").reduce((
|
|
114
|
-
H(D) && (n(
|
|
113
|
+
const D = p.split(".").reduce((j, nt) => j[nt], t);
|
|
114
|
+
H(D) && (n(l)[p] = n(D), a.push(p));
|
|
115
115
|
} catch {
|
|
116
|
-
H(
|
|
117
|
-
n(
|
|
116
|
+
H(F.value[p]) && (n(l)[p] = A(
|
|
117
|
+
n(F.value[p])
|
|
118
118
|
));
|
|
119
119
|
}
|
|
120
120
|
});
|
|
121
121
|
}), i && P(async () => {
|
|
122
|
-
await
|
|
122
|
+
await U(a).catch((e) => {
|
|
123
123
|
});
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
async function Y(t) {
|
|
127
|
-
const i =
|
|
127
|
+
const i = A(n(c));
|
|
128
128
|
if (!t)
|
|
129
129
|
return;
|
|
130
|
-
let r =
|
|
131
|
-
|
|
130
|
+
let r = T(t) ? [t] : t;
|
|
131
|
+
T(t) && (r = [t]);
|
|
132
132
|
for (const s of r)
|
|
133
133
|
Z(s, i);
|
|
134
134
|
v.value = i;
|
|
135
135
|
}
|
|
136
136
|
function Z(t, i) {
|
|
137
|
-
if (
|
|
137
|
+
if (T(t)) {
|
|
138
138
|
const r = i.findIndex((s) => s.field === t);
|
|
139
|
-
r !== -1 && (delete
|
|
139
|
+
r !== -1 && (delete l[t], i.splice(r, 1));
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
async function K(t, i, r = !1) {
|
|
143
|
-
const s =
|
|
143
|
+
const s = A(n(c)), o = s.findIndex((e) => e.field === i), a = C(t) ? [t] : t;
|
|
144
144
|
if (!i || o === -1 || r) {
|
|
145
|
-
r ? s.unshift(...
|
|
145
|
+
r ? s.unshift(...a) : s.push(...a), v.value = s, g(t);
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
|
-
o !== -1 && s.splice(o + 1, 0, ...
|
|
148
|
+
o !== -1 && s.splice(o + 1, 0, ...a), g(t), v.value = s;
|
|
149
149
|
}
|
|
150
150
|
async function k(t) {
|
|
151
151
|
let i = [];
|
|
152
152
|
if (C(t) && i.push(t), I(t) && (i = [...t]), !i.every(
|
|
153
|
-
(s) => s.type ===
|
|
153
|
+
(s) => s.type === _.Divider || Reflect.has(s, "field") && s.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"
|
|
@@ -159,10 +159,10 @@ function Ct({
|
|
|
159
159
|
}
|
|
160
160
|
v.value = i;
|
|
161
161
|
}
|
|
162
|
-
async function
|
|
162
|
+
async function $(t) {
|
|
163
163
|
let i = [];
|
|
164
164
|
if (C(t) && i.push(t), I(t) && (i = [...t]), !i.every(
|
|
165
|
-
(
|
|
165
|
+
(a) => a.type === _.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"
|
|
@@ -170,123 +170,124 @@ function Ct({
|
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
172
|
const s = [], o = [];
|
|
173
|
-
n(c).forEach((
|
|
173
|
+
n(c).forEach((a) => {
|
|
174
174
|
let e;
|
|
175
175
|
if (i.forEach((f) => {
|
|
176
|
-
|
|
177
|
-
}), e !== void 0 &&
|
|
178
|
-
const f = rt(
|
|
176
|
+
a.field === f.field && (e = f), f.defaultValue && f.field && s.push(f.field);
|
|
177
|
+
}), e !== void 0 && a.field === e.field) {
|
|
178
|
+
const f = rt(a, e);
|
|
179
179
|
o.push(f);
|
|
180
180
|
} else
|
|
181
|
-
o.push(
|
|
182
|
-
}),
|
|
181
|
+
o.push(a);
|
|
182
|
+
}), g(o, s), v.value = ct(o, "field");
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function g(t, i, r = !0) {
|
|
185
185
|
if (I(i) && i?.length === 0)
|
|
186
186
|
return;
|
|
187
187
|
let s = [];
|
|
188
188
|
C(t) && s.push(t), I(t) && (s = [...t]);
|
|
189
|
-
const o = {},
|
|
189
|
+
const o = {}, a = x();
|
|
190
190
|
s.forEach((e) => {
|
|
191
|
-
e.type !==
|
|
192
|
-
}),
|
|
191
|
+
e.type !== _.Divider && Reflect.has(e, "field") && e.field && !J(e.defaultValue) && (!(e.field in a) || J(a[e.field]) || ot(a[e.field])) && (o[e.field] = e.defaultValue);
|
|
192
|
+
}), lt(o) || N(o, r);
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function x(t = !1) {
|
|
195
195
|
if (!n(u)) return {};
|
|
196
|
-
const r = V(
|
|
196
|
+
const r = V(S(n(l)));
|
|
197
197
|
if (t)
|
|
198
198
|
return r;
|
|
199
|
-
const s = n(c).filter((d) =>
|
|
199
|
+
const s = n(c).filter((d) => q(d, n(l))).map((d) => d.field).filter(Boolean), o = {};
|
|
200
200
|
s.forEach((d) => {
|
|
201
|
-
d in r
|
|
201
|
+
o[d] = d in r ? r[d] ?? null : null;
|
|
202
202
|
});
|
|
203
|
-
const
|
|
203
|
+
const a = n(c), e = {};
|
|
204
204
|
s.forEach((d) => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
m
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
)), e[d] = m;
|
|
214
|
-
}
|
|
205
|
+
const w = a.find((B) => B.field === d);
|
|
206
|
+
let m = o[d];
|
|
207
|
+
m != null && w?.formatter && E(w.formatter) && (m = w.formatter(
|
|
208
|
+
m,
|
|
209
|
+
d,
|
|
210
|
+
o,
|
|
211
|
+
w
|
|
212
|
+
)), e[d] = m ?? null;
|
|
215
213
|
});
|
|
216
|
-
const { formatter: f } = n(
|
|
217
|
-
|
|
214
|
+
const { formatter: f } = n(y);
|
|
215
|
+
let b = f && E(f) ? f(e) : e;
|
|
216
|
+
return Object.keys(b).forEach((d) => {
|
|
217
|
+
b[d] === void 0 && (b[d] = null);
|
|
218
|
+
}), b;
|
|
218
219
|
}
|
|
219
220
|
function R(t, i, r) {
|
|
220
|
-
const o = n(c).find((
|
|
221
|
+
const o = n(c).find((a) => a.field === t);
|
|
221
222
|
return i && o?.formatter && E(o.formatter) ? o.formatter(i, t, r, o) : i;
|
|
222
223
|
}
|
|
223
224
|
function M(t) {
|
|
224
225
|
if (!n(u)) return {};
|
|
225
|
-
if (!(t in n(
|
|
226
|
+
if (!(t in n(l)))
|
|
226
227
|
return {};
|
|
227
|
-
const r = V(
|
|
228
|
+
const r = V(S(n(l))), s = r[t];
|
|
228
229
|
return R(t, s, r);
|
|
229
230
|
}
|
|
230
231
|
function tt(t) {
|
|
231
232
|
return n(c).some((i) => i.field === t ? dt(i.type) : !1);
|
|
232
233
|
}
|
|
233
|
-
async function $(t) {
|
|
234
|
-
return t || (t = n(c).filter((r) => S(r, n(a))).map((r) => r.field).filter(Boolean)), n(u)?.validateField(t);
|
|
235
|
-
}
|
|
236
234
|
async function U(t) {
|
|
237
|
-
return t || (t = n(c).filter((r) =>
|
|
235
|
+
return t || (t = n(c).filter((r) => q(r, n(l))).map((r) => r.field).filter(Boolean)), n(u)?.validateField(t);
|
|
236
|
+
}
|
|
237
|
+
async function z(t) {
|
|
238
|
+
return t || (t = n(c).filter((r) => q(r, n(l))).map((r) => r.field).filter(Boolean)), await n(u)?.validate(t, () => {
|
|
238
239
|
});
|
|
239
240
|
}
|
|
240
|
-
async function
|
|
241
|
+
async function O(t) {
|
|
241
242
|
await n(u)?.clearValidate(t);
|
|
242
243
|
}
|
|
243
244
|
async function et(t, i) {
|
|
244
|
-
await
|
|
245
|
+
await O(t), await $([{ field: t, itemProps: { error: i } }]);
|
|
245
246
|
}
|
|
246
247
|
async function it(t, i) {
|
|
247
248
|
await n(u)?.scrollToField(t, i);
|
|
248
249
|
}
|
|
249
|
-
async function
|
|
250
|
-
const { autoCleanErrorMessage: i, watchDataIsChange: r } = n(
|
|
251
|
-
t && t.preventDefault(), i && await
|
|
252
|
-
const { submitFunc: s, beforeSubmitFunc: o } = n(
|
|
250
|
+
async function G(t) {
|
|
251
|
+
const { autoCleanErrorMessage: i, watchDataIsChange: r } = n(y);
|
|
252
|
+
t && t.preventDefault(), i && await O();
|
|
253
|
+
const { submitFunc: s, beforeSubmitFunc: o } = n(y);
|
|
253
254
|
if (o && E(o) && await o(), s && E(s)) {
|
|
254
255
|
await s();
|
|
255
256
|
return;
|
|
256
257
|
}
|
|
257
258
|
if (n(u))
|
|
258
259
|
try {
|
|
259
|
-
if (!await
|
|
260
|
+
if (!await z())
|
|
260
261
|
return;
|
|
261
|
-
const f =
|
|
262
|
+
const f = x();
|
|
262
263
|
if (r) {
|
|
263
|
-
const
|
|
264
|
-
h("submit", f, !
|
|
264
|
+
const b = ft(L.value, f), d = st(L.value, f);
|
|
265
|
+
h("submit", f, !b, d);
|
|
265
266
|
} else
|
|
266
267
|
h("submit", f);
|
|
267
268
|
} catch (e) {
|
|
268
|
-
if (console.log(e
|
|
269
|
+
if (console.log(e), e?.outOfDate === !1 && e?.errorFields)
|
|
269
270
|
return;
|
|
270
271
|
throw new Error(e.message);
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
274
|
return {
|
|
274
|
-
handleSubmit:
|
|
275
|
-
clearValidate:
|
|
276
|
-
validate:
|
|
277
|
-
validateField:
|
|
278
|
-
getFieldsValue:
|
|
279
|
-
updateSchema:
|
|
275
|
+
handleSubmit: G,
|
|
276
|
+
clearValidate: O,
|
|
277
|
+
validate: z,
|
|
278
|
+
validateField: U,
|
|
279
|
+
getFieldsValue: x,
|
|
280
|
+
updateSchema: $,
|
|
280
281
|
resetSchema: k,
|
|
281
282
|
appendSchemaByField: K,
|
|
282
283
|
removeSchemaByField: Y,
|
|
283
284
|
resetFields: X,
|
|
284
|
-
setFieldsValue:
|
|
285
|
+
setFieldsValue: N,
|
|
285
286
|
scrollToField: it,
|
|
286
287
|
getFieldValue: M,
|
|
287
288
|
setFormItemError: et
|
|
288
289
|
};
|
|
289
290
|
}
|
|
290
291
|
export {
|
|
291
|
-
|
|
292
|
+
jt as useFormEvents
|
|
292
293
|
};
|