@cicctencent/formily 0.0.0-stage → 0.0.1
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/.eslintrc.js +40 -0
- package/.prettierrc.js +28 -0
- package/.vscode/launch.json +23 -0
- package/CHANGELOG.md +8 -0
- package/README.md +22 -2
- package/babel.config.js +3 -0
- package/build/build.js +96 -0
- package/build/rollup.config.bundle.js +63 -0
- package/build/update.version.js +35 -0
- package/dist/index.css +2516 -0
- package/dist/index.js +8377 -0
- package/dist/schema-field/index.css +2466 -0
- package/dist/schema-field/index.js +8213 -0
- package/dist/transform/index.js +551 -0
- package/dist/validate/index.js +1104 -0
- package/dist/vue-form/index.css +2516 -0
- package/dist/vue-form/index.js +8359 -0
- package/docs/.vuepress/client.ts +15 -0
- package/docs/.vuepress/components/code-preview.vue +203 -0
- package/docs/.vuepress/components/highlight.ts +53 -0
- package/docs/.vuepress/config.ts +39 -0
- package/docs/.vuepress/util.ts +7 -0
- package/docs/README.md +30 -0
- package/docs/components/anyOf.md +26 -0
- package/docs/components/array-cards.md +12 -0
- package/docs/components/array-collapse.md +12 -0
- package/docs/components/array-items.md +12 -0
- package/docs/components/array-table.md +12 -0
- package/docs/components/array-tabs.md +16 -0
- package/docs/components/cascader.md +12 -0
- package/docs/components/checkbox.md +12 -0
- package/docs/components/event.md +27 -0
- package/docs/components/hotArea.md +25 -0
- package/docs/components/index.md +4 -0
- package/docs/components/input.md +30 -0
- package/docs/components/layout-group.md +19 -0
- package/docs/components/link.md +22 -0
- package/docs/components/oneOf.md +8 -0
- package/docs/components/radio.md +12 -0
- package/docs/components/rich-editor.md +21 -0
- package/docs/components/select.md +34 -0
- package/docs/components/space.md +11 -0
- package/docs/components/switch.md +20 -0
- package/docs/components/text.md +21 -0
- package/docs/components/time-picker.md +11 -0
- package/docs/components/transfer.md +14 -0
- package/docs/components/upload-button.md +28 -0
- package/docs/demos/any-of/index.vue +66 -0
- package/docs/demos/array-cards/index.vue +105 -0
- package/docs/demos/array-collapse/index.vue +155 -0
- package/docs/demos/array-items/index.vue +171 -0
- package/docs/demos/array-table/index.vue +115 -0
- package/docs/demos/array-tabs/index.vue +56 -0
- package/docs/demos/cascader/index.vue +297 -0
- package/docs/demos/checkbox/index.vue +39 -0
- package/docs/demos/event/index.vue +436 -0
- package/docs/demos/hotArea/index.vue +240 -0
- package/docs/demos/index.vue +36 -0
- package/docs/demos/input/index.vue +46 -0
- package/docs/demos/layout-group/index.vue +51 -0
- package/docs/demos/link/index.vue +32 -0
- package/docs/demos/radio/index.vue +36 -0
- package/docs/demos/rich-editor/index.vue +22 -0
- package/docs/demos/select/index.vue +76 -0
- package/docs/demos/space/index.vue +93 -0
- package/docs/demos/switch/index.vue +31 -0
- package/docs/demos/text/index.vue +38 -0
- package/docs/demos/time-picker/index.vue +39 -0
- package/docs/demos/transfer/index.vue +26 -0
- package/docs/demos/upload-button/index.vue +27 -0
- package/docs/demos/x-data/add-button-title.vue +101 -0
- package/docs/demos/x-data/send-message.vue +33 -0
- package/docs/demos/x-reactions/any-of.vue +40 -0
- package/docs/demos/x-reactions/x-reactions.vue +39 -0
- package/docs/guide/component-extend.md +23 -0
- package/docs/guide/extra-bury-report.md +64 -0
- package/docs/guide/schema.md +22 -0
- package/docs/guide/x-data.md +41 -0
- package/docs/guide/x-reactions.md +20 -0
- package/example/.browserslistrc +4 -0
- package/example/.eslintrc.js +20 -0
- package/example/README.md +24 -0
- package/example/index.html +15 -0
- package/example/jest.config.js +26 -0
- package/example/package.json +50 -0
- package/example/public/favicon.ico +0 -0
- package/example/public/index.html +17 -0
- package/example/src/App.vue +25 -0
- package/example/src/assets/logo.png +0 -0
- package/example/src/components/HelloWorld.vue +148 -0
- package/example/src/components/group/index.vue +16 -0
- package/example/src/components/uploadBtn/index.vue +44 -0
- package/example/src/components/uploadBtn/upload-icon.svg +6 -0
- package/example/src/layout/component/Aside.vue +39 -0
- package/example/src/layout/component/Main.vue +9 -0
- package/example/src/layout/index.vue +15 -0
- package/example/src/main.ts +17 -0
- package/example/src/router/index.ts +99 -0
- package/example/src/shims-vue.d.ts +6 -0
- package/example/src/store/index.ts +9 -0
- package/example/src/views/demo/any-of/data.ts +38 -0
- package/example/src/views/demo/any-of/index.vue +35 -0
- package/example/src/views/demo/array-cards/data.ts +65 -0
- package/example/src/views/demo/array-cards/index.vue +33 -0
- package/example/src/views/demo/array-items/data.ts +29 -0
- package/example/src/views/demo/array-items/index.vue +33 -0
- package/example/src/views/demo/cloud-button/data.ts +14 -0
- package/example/src/views/demo/cloud-button/index.vue +22 -0
- package/example/src/views/demo/color-group/data.ts +15 -0
- package/example/src/views/demo/color-group/index.vue +22 -0
- package/example/src/views/demo/color-picker/data.ts +21 -0
- package/example/src/views/demo/color-picker/index.vue +33 -0
- package/example/src/views/demo/datatime/data.ts +62 -0
- package/example/src/views/demo/datatime/index.vue +22 -0
- package/example/src/views/demo/event/data.ts +184 -0
- package/example/src/views/demo/event/index.vue +33 -0
- package/example/src/views/demo/hot-area/data.ts +196 -0
- package/example/src/views/demo/hot-area/index.vue +33 -0
- package/example/src/views/demo/input/data.ts +39 -0
- package/example/src/views/demo/input/index.vue +33 -0
- package/example/src/views/demo/link/data.ts +23 -0
- package/example/src/views/demo/link/index.vue +22 -0
- package/example/src/views/demo/one-of/data.ts +139 -0
- package/example/src/views/demo/one-of/index.vue +33 -0
- package/example/src/views/demo/rich-editor/data.ts +12 -0
- package/example/src/views/demo/rich-editor/index.vue +24 -0
- package/example/src/views/demo/select/data.ts +38 -0
- package/example/src/views/demo/select/index.vue +33 -0
- package/example/src/views/demo/upload-button/data1.ts +11 -0
- package/example/src/views/demo/upload-button/data2.ts +12 -0
- package/example/src/views/demo/upload-button/index.vue +42 -0
- package/example/tsconfig.json +32 -0
- package/example/vite.config.ts +12 -0
- package/jest.config.js +4 -0
- package/package.json +92 -4
- package/src/components/__builtins__/configs/index.ts +1 -0
- package/src/components/__builtins__/index.ts +2 -0
- package/src/components/__builtins__/shared/create-context.ts +54 -0
- package/src/components/__builtins__/shared/index.ts +7 -0
- package/src/components/__builtins__/shared/loading.ts +20 -0
- package/src/components/__builtins__/shared/portal.ts +43 -0
- package/src/components/__builtins__/shared/resolve-component.ts +22 -0
- package/src/components/__builtins__/shared/transform-component.ts +33 -0
- package/src/components/__builtins__/shared/types.ts +8 -0
- package/src/components/__builtins__/shared/utils.ts +35 -0
- package/src/components/__builtins__/styles/common.scss +22 -0
- package/src/components/__builtins__/styles/element-plus.scss +1094 -0
- package/src/components/any-of/index.ts +20 -0
- package/src/components/array-base/index.ts +413 -0
- package/src/components/array-base/style.scss +53 -0
- package/src/components/array-base/style.ts +2 -0
- package/src/components/array-cards/index.ts +253 -0
- package/src/components/array-cards/style.scss +33 -0
- package/src/components/array-cards/style.ts +7 -0
- package/src/components/array-collapse/index.ts +381 -0
- package/src/components/array-collapse/style.scss +38 -0
- package/src/components/array-collapse/style.ts +10 -0
- package/src/components/array-items/index.ts +213 -0
- package/src/components/array-items/style.scss +82 -0
- package/src/components/array-items/style.ts +4 -0
- package/src/components/array-table/index.ts +567 -0
- package/src/components/array-table/style.scss +84 -0
- package/src/components/array-table/style.ts +11 -0
- package/src/components/array-tabs/index.ts +141 -0
- package/src/components/array-tabs/style.scss +16 -0
- package/src/components/array-tabs/style.ts +5 -0
- package/src/components/base/AnyOf/index.ts +155 -0
- package/src/components/base/AnyOf/index.vue +111 -0
- package/src/components/base/CloudButton/index.ts +46 -0
- package/src/components/base/CloudButton/index.vue +128 -0
- package/src/components/base/ColorGroup/index.ts +57 -0
- package/src/components/base/ColorGroup/index.vue +30 -0
- package/src/components/base/ColorPicker/index.ts +45 -0
- package/src/components/base/ColorPicker/index.vue +50 -0
- package/src/components/base/Container/index.vue +39 -0
- package/src/components/base/HotArea/index.ts +698 -0
- package/src/components/base/HotArea/index.vue +565 -0
- package/src/components/base/HotArea/type.ts +18 -0
- package/src/components/base/Input/index.vue +150 -0
- package/src/components/base/LayoutGroup/index.vue +40 -0
- package/src/components/base/Link/index.vue +43 -0
- package/src/components/base/Middleware/index.ts +235 -0
- package/src/components/base/Middleware/index.vue +169 -0
- package/src/components/base/OneOf/index.ts +105 -0
- package/src/components/base/OneOf/index.vue +85 -0
- package/src/components/base/RichEditor/index.ts +13 -0
- package/src/components/base/RichEditor/index.vue +120 -0
- package/src/components/base/RichEditor/options.ts +24 -0
- package/src/components/base/Select/index.ts +106 -0
- package/src/components/base/Select/index.vue +161 -0
- package/src/components/base/Switch/index.vue +42 -0
- package/src/components/base/Text/index.vue +47 -0
- package/src/components/base/event/index.ts +226 -0
- package/src/components/base/event/index.vue +356 -0
- package/src/components/cascader/index.ts +48 -0
- package/src/components/cascader/style.ts +5 -0
- package/src/components/checkbox/index.ts +166 -0
- package/src/components/checkbox/style.ts +5 -0
- package/src/components/cloud-button/index.ts +21 -0
- package/src/components/color-group/index.ts +18 -0
- package/src/components/color-picker/index.ts +18 -0
- package/src/components/container/index.ts +18 -0
- package/src/components/data-time/index.ts +24 -0
- package/src/components/date-picker/index.ts +51 -0
- package/src/components/date-picker/style.ts +4 -0
- package/src/components/editable/index.ts +261 -0
- package/src/components/editable/style.scss +55 -0
- package/src/components/editable/style.ts +5 -0
- package/src/components/el-form-item/index.ts +21 -0
- package/src/components/el-form-item/style.ts +3 -0
- package/src/components/event/index.ts +16 -0
- package/src/components/form/index.ts +94 -0
- package/src/components/form/style.scss +0 -0
- package/src/components/form/style.ts +3 -0
- package/src/components/form-button-group/index.ts +74 -0
- package/src/components/form-button-group/style.scss +0 -0
- package/src/components/form-button-group/style.ts +4 -0
- package/src/components/form-collapse/index.ts +215 -0
- package/src/components/form-collapse/style.scss +6 -0
- package/src/components/form-collapse/style.ts +4 -0
- package/src/components/form-dialog/index.ts +433 -0
- package/src/components/form-dialog/style.ts +4 -0
- package/src/components/form-drawer/index.ts +424 -0
- package/src/components/form-drawer/style.scss +21 -0
- package/src/components/form-drawer/style.ts +4 -0
- package/src/components/form-grid/index.ts +181 -0
- package/src/components/form-grid/style.scss +5 -0
- package/src/components/form-grid/style.ts +1 -0
- package/src/components/form-item/animation.scss +72 -0
- package/src/components/form-item/grid.scss +171 -0
- package/src/components/form-item/index.ts +642 -0
- package/src/components/form-item/style.scss +521 -0
- package/src/components/form-item/style.ts +2 -0
- package/src/components/form-item/var.scss +17 -0
- package/src/components/form-layout/index.ts +161 -0
- package/src/components/form-layout/style.scss +6 -0
- package/src/components/form-layout/style.ts +1 -0
- package/src/components/form-layout/useResponsiveFormLayout.ts +118 -0
- package/src/components/form-step/index.ts +210 -0
- package/src/components/form-step/style.ts +2 -0
- package/src/components/form-tab/index.ts +172 -0
- package/src/components/form-tab/style.scss +6 -0
- package/src/components/form-tab/style.ts +4 -0
- package/src/components/hot-area/index.ts +20 -0
- package/src/components/index.ts +49 -0
- package/src/components/input/index.ts +35 -0
- package/src/components/input/style.ts +4 -0
- package/src/components/input-number/index.ts +36 -0
- package/src/components/input-number/style.ts +3 -0
- package/src/components/layout-group/index.ts +18 -0
- package/src/components/link/index.ts +18 -0
- package/src/components/middleware/index.ts +21 -0
- package/src/components/one-of/index.ts +20 -0
- package/src/components/placeholder-input/index.ts +21 -0
- package/src/components/placeholder-input/index.vue +87 -0
- package/src/components/preview-text/index.ts +303 -0
- package/src/components/preview-text/style.ts +9 -0
- package/src/components/radio/index.ts +109 -0
- package/src/components/radio/style.ts +3 -0
- package/src/components/reset/index.ts +52 -0
- package/src/components/reset/style.ts +1 -0
- package/src/components/rich-editor/index.ts +18 -0
- package/src/components/row/index.ts +20 -0
- package/src/components/row/index.vue +53 -0
- package/src/components/select/index.ts +19 -0
- package/src/components/select/style.ts +5 -0
- package/src/components/space/index.ts +98 -0
- package/src/components/space/style.scss +24 -0
- package/src/components/space/style.ts +1 -0
- package/src/components/submit/index.ts +59 -0
- package/src/components/submit/style.ts +1 -0
- package/src/components/switch/index.ts +9 -0
- package/src/components/switch/style.ts +1 -0
- package/src/components/text/index.ts +21 -0
- package/src/components/time-picker/index.ts +21 -0
- package/src/components/time-picker/style.ts +4 -0
- package/src/components/transfer/index.ts +12 -0
- package/src/components/transfer/style.ts +1 -0
- package/src/components/upload/index.ts +136 -0
- package/src/components/upload/style.ts +2 -0
- package/src/components/upload-button/index.ts +21 -0
- package/src/components/upload-button/index.vue +199 -0
- package/src/createScemaField.ts +14 -0
- package/src/index.ts +41 -0
- package/src/schema-field/index.ts +11 -0
- package/src/scope.ts +29 -0
- package/src/transform/core.ts +404 -0
- package/src/transform/index.ts +11 -0
- package/src/transform/transform.ts +59 -0
- package/src/transform/utils/constant.ts +79 -0
- package/src/transform/utils/func.ts +145 -0
- package/src/typings/common.ts +37 -0
- package/src/typings/vue-shim.d.ts +7 -0
- package/src/typings/vue-test-utils.d.ts +11 -0
- package/src/utils/anyof_utils.ts +95 -0
- package/src/utils/common.ts +15 -0
- package/src/validate/index.ts +648 -0
- package/src/validate/utils/constant.ts +2 -0
- package/src/vue-form/index.ts +18 -0
- package/src/vue-form/index.vue +106 -0
- package/src/vue-form/useForm.ts +112 -0
- package/tests/data/anyof.ts +40 -0
- package/tests/data/image.ts +472 -0
- package/tests/fixtures/validate.ts +63 -0
- package/tests/unit/transform.spec.ts +253 -0
- package/tests/unit/utils.spec.ts +10 -0
- package/tests/unit/validate.spec.ts +256 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,642 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ref,
|
|
3
|
+
defineComponent,
|
|
4
|
+
onMounted,
|
|
5
|
+
Ref,
|
|
6
|
+
onBeforeUnmount,
|
|
7
|
+
watch,
|
|
8
|
+
provide,
|
|
9
|
+
h,
|
|
10
|
+
} from 'vue';
|
|
11
|
+
import { isVoidField } from '@formily/core';
|
|
12
|
+
import { connect, mapProps } from '@formily/vue';
|
|
13
|
+
|
|
14
|
+
// error: () => h('i', { class: 'el-icon-circle-close' }, {}),
|
|
15
|
+
// success: () => h('i', { class: 'el-icon-circle-check' }, {}),
|
|
16
|
+
// warning: () => h('i', { class: 'el-icon-warning-outline' }, {}),
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
InfoFilled,
|
|
20
|
+
CircleClose,
|
|
21
|
+
CircleCheck,
|
|
22
|
+
Warning,
|
|
23
|
+
} from '@cicctencent/icons-vue';
|
|
24
|
+
import { useFormLayout, FormLayoutShallowContext } from '../form-layout';
|
|
25
|
+
import { composeExport, resolveComponent, stylePrefix } from '../__builtins__';
|
|
26
|
+
import { Component } from 'vue';
|
|
27
|
+
import { ElTooltip, ElIcon } from '@cicctencent/jtui';
|
|
28
|
+
import ResizeObserver from 'resize-observer-polyfill';
|
|
29
|
+
import { IFormGridProps, useGridColumn } from '../form-grid';
|
|
30
|
+
import './style.scss';
|
|
31
|
+
export type FormItemProps = {
|
|
32
|
+
className?: string;
|
|
33
|
+
required?: boolean;
|
|
34
|
+
label?: string | Component;
|
|
35
|
+
colon?: boolean;
|
|
36
|
+
tooltip?: string | Component;
|
|
37
|
+
layout?: 'vertical' | 'horizontal' | 'inline';
|
|
38
|
+
labelStyle?: Record<string, any>;
|
|
39
|
+
labelAlign?: 'left' | 'right';
|
|
40
|
+
labelWrap?: boolean;
|
|
41
|
+
labelWidth?: number;
|
|
42
|
+
wrapperWidth?: number;
|
|
43
|
+
labelCol?: number;
|
|
44
|
+
wrapperCol?: number;
|
|
45
|
+
wrapperAlign?: 'left' | 'right';
|
|
46
|
+
wrapperWrap?: boolean;
|
|
47
|
+
wrapperStyle?: Record<string, any>;
|
|
48
|
+
fullness?: boolean;
|
|
49
|
+
addonBefore?: string | Component;
|
|
50
|
+
addonAfter?: string | Component;
|
|
51
|
+
size?: 'small' | 'default' | 'large';
|
|
52
|
+
extra?: string;
|
|
53
|
+
feedbackText?: string | Component;
|
|
54
|
+
feedbackLayout?: 'loose' | 'terse' | 'popover' | 'none' | (string & {});
|
|
55
|
+
feedbackStatus?:
|
|
56
|
+
| 'error'
|
|
57
|
+
| 'warning'
|
|
58
|
+
| 'success'
|
|
59
|
+
| 'pending'
|
|
60
|
+
| (string & {});
|
|
61
|
+
tooltipLayout?: 'icon' | 'text';
|
|
62
|
+
feedbackIcon?: string | Component;
|
|
63
|
+
asterisk?: boolean;
|
|
64
|
+
gridSpan?: number | string;
|
|
65
|
+
bordered?: boolean;
|
|
66
|
+
inset?: boolean;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const useOverflow = (containerRef: Ref<HTMLElement>) => {
|
|
70
|
+
const overflow = ref(false);
|
|
71
|
+
let resizeObserver: ResizeObserver | undefined;
|
|
72
|
+
|
|
73
|
+
const cleanup = () => {
|
|
74
|
+
if (resizeObserver) {
|
|
75
|
+
resizeObserver.unobserve(containerRef.value);
|
|
76
|
+
resizeObserver = null;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const observer = () => {
|
|
81
|
+
const container = containerRef.value;
|
|
82
|
+
const content = container.querySelector('label');
|
|
83
|
+
const containerWidth = container.getBoundingClientRect().width;
|
|
84
|
+
const contentWidth = content.getBoundingClientRect().width;
|
|
85
|
+
|
|
86
|
+
if (containerWidth !== 0) {
|
|
87
|
+
if (contentWidth > containerWidth) {
|
|
88
|
+
overflow.value = true;
|
|
89
|
+
} else {
|
|
90
|
+
overflow.value = false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const stopWatch = watch(
|
|
96
|
+
() => containerRef.value,
|
|
97
|
+
el => {
|
|
98
|
+
cleanup();
|
|
99
|
+
|
|
100
|
+
if (el) {
|
|
101
|
+
resizeObserver = new ResizeObserver(observer);
|
|
102
|
+
resizeObserver.observe(el);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{ immediate: true, flush: 'post' }
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
onBeforeUnmount(() => {
|
|
109
|
+
cleanup();
|
|
110
|
+
stopWatch();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
return overflow;
|
|
114
|
+
};
|
|
115
|
+
const tooltipIcon =
|
|
116
|
+
'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjMiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyMyAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CjxyZWN0IG9wYWNpdHk9IjAuNiIgd2lkdGg9IjIyLjIyMjIiIGhlaWdodD0iMjQiIGZpbGw9InVybCgjcGF0dGVybjApIi8+CjxkZWZzPgo8cGF0dGVybiBpZD0icGF0dGVybjAiIHBhdHRlcm5Db250ZW50VW5pdHM9Im9iamVjdEJvdW5kaW5nQm94IiB3aWR0aD0iMSIgaGVpZ2h0PSIxIj4KPHVzZSB4bGluazpocmVmPSIjaW1hZ2UwXzQzM183NDIwIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwIC0wLjAwMzgxMjYyKSBzY2FsZSgwLjAxNDcwNTkgMC4wMTM2MTY2KSIvPgo8L3BhdHRlcm4+CjxpbWFnZSBpZD0iaW1hZ2UwXzQzM183NDIwIiB3aWR0aD0iNjgiIGhlaWdodD0iNzQiIHhsaW5rOmhyZWY9ImRhdGE6aW1hZ2UvcG5nO2Jhc2U2NCxpVkJPUncwS0dnb0FBQUFOU1VoRVVnQUFBRVFBQUFCS0NBWUFBQUFDR2ZMQ0FBQURNRWxFUVZSNEFlMlpNVzRiUVF4RmZjQTBQa0I2TjZtTkZHbmRHbkNYQXdSd2xTcElrMHRJY3VRN0NEbkVHbC93VDZpUGtiSkRjbFlTd0FFR0k2NVdKUC9iUDdNR2ZEUFZPQ0J3Y3hCVk1CVVFNVUVCS1NCQ1FNSnlTQUVSQWhLV1F3cUlFSkN3SEZKQWhJQ0U1WkFDSWdRa0xJY1VFQ0VnWVRua2tvQnNYbDRuem0vUDN5ZE9YcE5lRndrWGRRaUZmdjd5TUgyNC9UaHI0bDZBV21vc0FnUWdlaUFjZzBVSGpZUXpGTWovUUFBU0o4Vmk1YlZUWUVaQkdRWUV3bHFDSUJhZzVnNkNhdVhDZDlsakNKQVdqRjRRTGFHdHZObFEwb0ZBdUgyYUdTQVVUcXVHM3VPTlU0Rm9vOWxQejRwVXQ2QjJ4a2dEb2cyT2hFSGhJMnFtQUlrMnRsci9udTQrM2UvbmFyMmwzbGxydExZV0NRUEJHOE9lR2IzTzJPMytIUHdldVhDdFp5aVVucmVZMWdrRHNjMzB3a0F6OXZjRTY4bGp6Ni9JZVJJQ29tS1U5cHc0d3lHb28wNzF1aVFOaU9lcEV0aHFzLzEzaG16NnpoRG13SnJoa2hBUVdoenJKWXdNbDdpQjJPMFNjVWMyU09zU3o3WnhBN0dGbzBEd2Uwd0k4SWl3VUsxTFBJZXJHMGpXZHJGZ2tkTWp3Z0xCNTBodkxpRFJwMkFGS0pDTTg4am03SFhjMllHZ1lRdjRLb0ZndjlPVzBmT0RibUcrQXZKT0pCTkk1SUc1dGt5a0lCMmg2MVVEc1hzKzQ2MEFPQVZFTEpJSjVLcmZNdVJ5MVVDeUxaNmRMd0xYZGFoQ1FNU1dkSVZkSXlKc0hudmdlODQzTjVEc2czVUVFTS9mU0NsQUlBYUFJaU1MU0RTUEd3akUyMjNqc2VlUG43Lysvc2ZmQ3NHVHhjVDNQY051RjQ4N1VDc0V4RzZiWHBkQXJJVnc3SE1QRkp2akxFQWlMc2tHWXQzcWhSRjJDQktvUzNxYUFSVGNqL240OUhVL0dXT2Q2dzdjYTkyQnZyd2p0R1ZZVkJ0Q3ZOVElycDBDQk9Lekc1c0RkRVROTkNBUVlQY3hMRHpTS1FyRDg1WnJRVThGMG9LUzFTaWJ4NW1sNEROcnBBTkI0L3IwTXR6U0FwR1JsNkM1RGdGeURBb0Y5R3lsWXlDWWkwS3kxbUZBMkdETExSQ0RDYXRqNGg1T1hzUEsrM1RGZHdBMVlnd0hncVlwVm9YMXhpTkJFTzRpUUZpTWNFNDlmWVZFQ0tNY1lYdkQ1OFdCMkFZZ0VwTU93c3ByU3dHdy9ad2RpRFp6Q2ZGWkhYSUpBTFNIQWlKRUNrZ0JFUUlTbGtNS2lCQ1FzQnhTUUlTQWhPV1FBaUlFSkN5SEZCQWhJR0U1UklDOEFiM1VzWnR1eFNuaEFBQUFBRWxGVGtTdVFtQ0MiLz4KPC9kZWZzPgo8L3N2Zz4K';
|
|
117
|
+
|
|
118
|
+
const tooltipStyle = {
|
|
119
|
+
background: `url(${tooltipIcon})`,
|
|
120
|
+
objectFit: 'cover',
|
|
121
|
+
width: '22.22px',
|
|
122
|
+
height: '24px',
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const ICON_MAP = {
|
|
126
|
+
info: () => h(ElIcon, {}, { default: () => h(InfoFilled, {}, {}) }),
|
|
127
|
+
error: () => h(ElIcon, {}, { default: () => h(CircleClose, {}, {}) }),
|
|
128
|
+
success: () => h(ElIcon, {}, { default: () => h(CircleCheck, {}, {}) }),
|
|
129
|
+
warning: () => h(ElIcon, {}, { default: () => h(Warning, {}, {}) }),
|
|
130
|
+
tooltip: () => h(ElIcon, {}, { default: () => h(Warning, {}, {}) }),
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const FormBaseItem = defineComponent({
|
|
134
|
+
name: 'FormItem',
|
|
135
|
+
props: {
|
|
136
|
+
className: {},
|
|
137
|
+
required: {},
|
|
138
|
+
label: {},
|
|
139
|
+
// 冒号
|
|
140
|
+
colon: {
|
|
141
|
+
default: false,
|
|
142
|
+
},
|
|
143
|
+
layout: {},
|
|
144
|
+
tooltip: {},
|
|
145
|
+
labelStyle: {},
|
|
146
|
+
labelAlign: {},
|
|
147
|
+
labelWrap: {},
|
|
148
|
+
labelWidth: {},
|
|
149
|
+
wrapperWidth: {},
|
|
150
|
+
labelCol: {},
|
|
151
|
+
wrapperCol: {},
|
|
152
|
+
wrapperAlign: {},
|
|
153
|
+
wrapperWrap: {},
|
|
154
|
+
wrapperStyle: {},
|
|
155
|
+
fullness: {},
|
|
156
|
+
addonBefore: {},
|
|
157
|
+
addonAfter: {},
|
|
158
|
+
size: {},
|
|
159
|
+
extra: {},
|
|
160
|
+
feedbackText: {},
|
|
161
|
+
feedbackLayout: {},
|
|
162
|
+
tooltipLayout: {},
|
|
163
|
+
feedbackStatus: {},
|
|
164
|
+
feedbackIcon: {},
|
|
165
|
+
asterisk: {},
|
|
166
|
+
gridSpan: {},
|
|
167
|
+
bordered: { default: true },
|
|
168
|
+
inset: { default: false },
|
|
169
|
+
},
|
|
170
|
+
setup(props, { slots, attrs }) {
|
|
171
|
+
const active = ref(false);
|
|
172
|
+
const deepLayoutRef = useFormLayout();
|
|
173
|
+
const prefixCls = `${stylePrefix}-form-item`;
|
|
174
|
+
|
|
175
|
+
const containerRef = ref<HTMLElement>(null);
|
|
176
|
+
const overflow = useOverflow(containerRef);
|
|
177
|
+
|
|
178
|
+
provide(FormLayoutShallowContext, ref({}));
|
|
179
|
+
|
|
180
|
+
return () => {
|
|
181
|
+
const gridColumn = useGridColumn(props.gridSpan as string);
|
|
182
|
+
const gridStyles: Record<string, any> = {};
|
|
183
|
+
|
|
184
|
+
if (gridColumn) {
|
|
185
|
+
gridStyles.gridColumn = gridColumn;
|
|
186
|
+
}
|
|
187
|
+
const deepLayout = deepLayoutRef.value;
|
|
188
|
+
const {
|
|
189
|
+
label,
|
|
190
|
+
colon = deepLayout.colon ?? true,
|
|
191
|
+
layout = deepLayout.layout ?? 'horizontal',
|
|
192
|
+
// TODO 拿不到 x-decorator-props 属性
|
|
193
|
+
tooltip,
|
|
194
|
+
labelStyle = {},
|
|
195
|
+
labelWrap = deepLayout.labelWrap ?? false,
|
|
196
|
+
labelWidth = deepLayout.labelWidth,
|
|
197
|
+
wrapperWidth = deepLayout.wrapperWidth,
|
|
198
|
+
labelCol = deepLayout.labelCol,
|
|
199
|
+
wrapperCol = deepLayout.wrapperCol,
|
|
200
|
+
wrapperAlign = deepLayout.wrapperAlign ?? 'left',
|
|
201
|
+
wrapperWrap = deepLayout.wrapperWrap,
|
|
202
|
+
wrapperStyle = {},
|
|
203
|
+
fullness = deepLayout.fullness,
|
|
204
|
+
addonBefore,
|
|
205
|
+
addonAfter,
|
|
206
|
+
size = deepLayout.size,
|
|
207
|
+
extra,
|
|
208
|
+
feedbackText,
|
|
209
|
+
feedbackLayout = deepLayout.feedbackLayout ?? 'loose',
|
|
210
|
+
tooltipLayout = deepLayout.tooltipLayout ?? 'icon',
|
|
211
|
+
feedbackStatus,
|
|
212
|
+
feedbackIcon,
|
|
213
|
+
asterisk,
|
|
214
|
+
bordered = deepLayout.bordered,
|
|
215
|
+
inset = deepLayout.inset,
|
|
216
|
+
} = props as any;
|
|
217
|
+
const labelAlign =
|
|
218
|
+
deepLayout.layout === 'vertical'
|
|
219
|
+
? props.labelAlign ?? deepLayout.labelAlign ?? 'left'
|
|
220
|
+
: props.labelAlign ?? deepLayout.labelAlign ?? 'right';
|
|
221
|
+
|
|
222
|
+
// 固定宽度
|
|
223
|
+
let enableCol = false;
|
|
224
|
+
if (labelWidth || wrapperWidth) {
|
|
225
|
+
if (labelWidth) {
|
|
226
|
+
labelStyle.width = `${labelWidth}px`;
|
|
227
|
+
labelStyle.maxWidth = `${labelWidth}px`;
|
|
228
|
+
}
|
|
229
|
+
if (wrapperWidth) {
|
|
230
|
+
wrapperStyle.width = `${wrapperWidth}px`;
|
|
231
|
+
wrapperStyle.maxWidth = `${wrapperWidth}px`;
|
|
232
|
+
}
|
|
233
|
+
// 栅格模式
|
|
234
|
+
} else if (labelCol || wrapperCol) {
|
|
235
|
+
enableCol = true;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const formatChildren =
|
|
239
|
+
feedbackLayout === 'popover'
|
|
240
|
+
? h(
|
|
241
|
+
'el-popover',
|
|
242
|
+
{
|
|
243
|
+
props: {
|
|
244
|
+
disabled: !feedbackText,
|
|
245
|
+
placement: 'top',
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
reference: () =>
|
|
250
|
+
h(
|
|
251
|
+
'div',
|
|
252
|
+
{},
|
|
253
|
+
{ default: () => slots.default?.() }
|
|
254
|
+
),
|
|
255
|
+
default: () => [
|
|
256
|
+
h(
|
|
257
|
+
'div',
|
|
258
|
+
{
|
|
259
|
+
class: {
|
|
260
|
+
[`${prefixCls}-${feedbackStatus}-help`]:
|
|
261
|
+
!!feedbackStatus,
|
|
262
|
+
[`${prefixCls}-help`]: true,
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
default: () => [
|
|
267
|
+
feedbackStatus &&
|
|
268
|
+
[
|
|
269
|
+
'error',
|
|
270
|
+
'success',
|
|
271
|
+
'warning',
|
|
272
|
+
].includes(
|
|
273
|
+
feedbackStatus as string
|
|
274
|
+
)
|
|
275
|
+
? ICON_MAP[
|
|
276
|
+
feedbackStatus as
|
|
277
|
+
| 'error'
|
|
278
|
+
| 'success'
|
|
279
|
+
| 'warning'
|
|
280
|
+
]()
|
|
281
|
+
: '',
|
|
282
|
+
resolveComponent(feedbackText),
|
|
283
|
+
],
|
|
284
|
+
}
|
|
285
|
+
),
|
|
286
|
+
],
|
|
287
|
+
}
|
|
288
|
+
)
|
|
289
|
+
: slots.default?.();
|
|
290
|
+
|
|
291
|
+
const renderLabelText = () => {
|
|
292
|
+
const labelChildren = h(
|
|
293
|
+
'div',
|
|
294
|
+
{
|
|
295
|
+
class: `${prefixCls}-label-content`,
|
|
296
|
+
ref: 'containerRef',
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
default: () => [
|
|
300
|
+
asterisk &&
|
|
301
|
+
h(
|
|
302
|
+
'span',
|
|
303
|
+
{ class: `${prefixCls}-asterisk` },
|
|
304
|
+
{ default: () => ['*'] }
|
|
305
|
+
),
|
|
306
|
+
h(
|
|
307
|
+
'label',
|
|
308
|
+
{},
|
|
309
|
+
{ default: () => [resolveComponent(label)] }
|
|
310
|
+
),
|
|
311
|
+
],
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
const isTextTooltip = tooltip && tooltipLayout === 'text';
|
|
315
|
+
if (isTextTooltip || overflow.value) {
|
|
316
|
+
return h(
|
|
317
|
+
ElTooltip,
|
|
318
|
+
{ effect: 'light', placement: 'bottom' },
|
|
319
|
+
{
|
|
320
|
+
default: () => [labelChildren],
|
|
321
|
+
content: () =>
|
|
322
|
+
h(
|
|
323
|
+
'div',
|
|
324
|
+
{},
|
|
325
|
+
{
|
|
326
|
+
default: () => [
|
|
327
|
+
overflow.value &&
|
|
328
|
+
resolveComponent(label),
|
|
329
|
+
isTextTooltip &&
|
|
330
|
+
resolveComponent(tooltip),
|
|
331
|
+
],
|
|
332
|
+
}
|
|
333
|
+
),
|
|
334
|
+
}
|
|
335
|
+
);
|
|
336
|
+
} else {
|
|
337
|
+
return labelChildren;
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
const renderTooltipIcon = () => {
|
|
341
|
+
if (tooltip && tooltipLayout === 'icon') {
|
|
342
|
+
return h(
|
|
343
|
+
'span',
|
|
344
|
+
{
|
|
345
|
+
class: `${prefixCls}-label-tooltip`,
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
default: () => [
|
|
349
|
+
h(
|
|
350
|
+
ElTooltip,
|
|
351
|
+
{
|
|
352
|
+
placement: 'bottom',
|
|
353
|
+
effect: 'light',
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
default: ICON_MAP.tooltip,
|
|
357
|
+
content: () =>
|
|
358
|
+
h(
|
|
359
|
+
'div',
|
|
360
|
+
{
|
|
361
|
+
class: `${prefixCls}-label-tooltip-content`,
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
default: () => [
|
|
365
|
+
resolveComponent(
|
|
366
|
+
tooltip
|
|
367
|
+
),
|
|
368
|
+
],
|
|
369
|
+
}
|
|
370
|
+
),
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
],
|
|
374
|
+
}
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
const renderLabel =
|
|
379
|
+
label &&
|
|
380
|
+
h(
|
|
381
|
+
'div',
|
|
382
|
+
{
|
|
383
|
+
class: {
|
|
384
|
+
[`${prefixCls}-label`]: true,
|
|
385
|
+
[`${prefixCls}-label-tooltip`]:
|
|
386
|
+
(tooltip && tooltipLayout === 'text') ||
|
|
387
|
+
overflow.value,
|
|
388
|
+
[`${prefixCls}-item-col-${labelCol}`]:
|
|
389
|
+
enableCol && !!labelCol,
|
|
390
|
+
},
|
|
391
|
+
style: labelStyle,
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
default: () => [
|
|
395
|
+
// label content
|
|
396
|
+
renderLabelText(),
|
|
397
|
+
// label tooltip
|
|
398
|
+
renderTooltipIcon(),
|
|
399
|
+
// label colon
|
|
400
|
+
label &&
|
|
401
|
+
h(
|
|
402
|
+
'span',
|
|
403
|
+
{
|
|
404
|
+
class: `${prefixCls}-colon`,
|
|
405
|
+
},
|
|
406
|
+
{ default: () => [colon ? ':' : ''] }
|
|
407
|
+
),
|
|
408
|
+
],
|
|
409
|
+
}
|
|
410
|
+
);
|
|
411
|
+
|
|
412
|
+
const renderFeedback =
|
|
413
|
+
!!feedbackText &&
|
|
414
|
+
feedbackLayout !== 'popover' &&
|
|
415
|
+
feedbackLayout !== 'none' &&
|
|
416
|
+
h(
|
|
417
|
+
'div',
|
|
418
|
+
{
|
|
419
|
+
class: {
|
|
420
|
+
[`${prefixCls}-${feedbackStatus}-help`]:
|
|
421
|
+
!!feedbackStatus,
|
|
422
|
+
[`${prefixCls}-help`]: true,
|
|
423
|
+
[`${prefixCls}-help-enter`]: true,
|
|
424
|
+
[`${prefixCls}-help-enter-active`]: true,
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
{ default: () => [resolveComponent(feedbackText)] }
|
|
428
|
+
);
|
|
429
|
+
|
|
430
|
+
const renderExtra =
|
|
431
|
+
extra &&
|
|
432
|
+
h(
|
|
433
|
+
'div',
|
|
434
|
+
{ class: `${prefixCls}-extra` },
|
|
435
|
+
{ default: () => [extra] }
|
|
436
|
+
);
|
|
437
|
+
const renderContent = h(
|
|
438
|
+
'div',
|
|
439
|
+
{
|
|
440
|
+
class: {
|
|
441
|
+
[`${prefixCls}-control`]: true,
|
|
442
|
+
[`${prefixCls}-item-col-${wrapperCol}`]:
|
|
443
|
+
enableCol && !!wrapperCol,
|
|
444
|
+
},
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
default: () => [
|
|
448
|
+
h(
|
|
449
|
+
'div',
|
|
450
|
+
{ class: `${prefixCls}-control-content` },
|
|
451
|
+
{
|
|
452
|
+
default: () => [
|
|
453
|
+
addonBefore &&
|
|
454
|
+
h(
|
|
455
|
+
'div',
|
|
456
|
+
{
|
|
457
|
+
class: `${prefixCls}-addon-before`,
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
default: () => [
|
|
461
|
+
resolveComponent(
|
|
462
|
+
addonBefore
|
|
463
|
+
),
|
|
464
|
+
],
|
|
465
|
+
}
|
|
466
|
+
),
|
|
467
|
+
h(
|
|
468
|
+
'div',
|
|
469
|
+
{
|
|
470
|
+
class: {
|
|
471
|
+
[`${prefixCls}-control-content-component`]:
|
|
472
|
+
true,
|
|
473
|
+
[`${prefixCls}-control-content-component-has-feedback-icon`]:
|
|
474
|
+
!!feedbackIcon,
|
|
475
|
+
},
|
|
476
|
+
style: wrapperStyle,
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
default: () => [
|
|
480
|
+
formatChildren,
|
|
481
|
+
feedbackIcon &&
|
|
482
|
+
h(
|
|
483
|
+
'div',
|
|
484
|
+
{
|
|
485
|
+
class: `${prefixCls}-feedback-icon`,
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
default: () => [
|
|
489
|
+
typeof feedbackIcon ===
|
|
490
|
+
'string'
|
|
491
|
+
? h(
|
|
492
|
+
'i',
|
|
493
|
+
{
|
|
494
|
+
class: feedbackIcon,
|
|
495
|
+
},
|
|
496
|
+
{}
|
|
497
|
+
)
|
|
498
|
+
: resolveComponent(
|
|
499
|
+
feedbackIcon
|
|
500
|
+
),
|
|
501
|
+
],
|
|
502
|
+
}
|
|
503
|
+
),
|
|
504
|
+
],
|
|
505
|
+
}
|
|
506
|
+
),
|
|
507
|
+
addonAfter &&
|
|
508
|
+
h(
|
|
509
|
+
'div',
|
|
510
|
+
{
|
|
511
|
+
class: `${prefixCls}-addon-after`,
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
default: () => [
|
|
515
|
+
resolveComponent(
|
|
516
|
+
addonAfter
|
|
517
|
+
),
|
|
518
|
+
],
|
|
519
|
+
}
|
|
520
|
+
),
|
|
521
|
+
],
|
|
522
|
+
}
|
|
523
|
+
),
|
|
524
|
+
renderFeedback,
|
|
525
|
+
renderExtra,
|
|
526
|
+
],
|
|
527
|
+
}
|
|
528
|
+
);
|
|
529
|
+
return h(
|
|
530
|
+
'div',
|
|
531
|
+
{
|
|
532
|
+
style: {
|
|
533
|
+
...gridStyles,
|
|
534
|
+
},
|
|
535
|
+
class: {
|
|
536
|
+
[`${prefixCls}`]: true,
|
|
537
|
+
[`${prefixCls}-layout-${layout}`]: true,
|
|
538
|
+
[`${prefixCls}-${feedbackStatus}`]: !!feedbackStatus,
|
|
539
|
+
[`${prefixCls}-feedback-has-text`]: !!feedbackText,
|
|
540
|
+
[`${prefixCls}-size-${size}`]: !!size,
|
|
541
|
+
[`${prefixCls}-feedback-layout-${feedbackLayout}`]:
|
|
542
|
+
!!feedbackLayout,
|
|
543
|
+
[`${prefixCls}-fullness`]:
|
|
544
|
+
!!fullness || !!inset || !!feedbackIcon,
|
|
545
|
+
[`${prefixCls}-inset`]: !!inset,
|
|
546
|
+
[`${prefixCls}-active`]: active.value,
|
|
547
|
+
[`${prefixCls}-inset-active`]: !!inset && active.value,
|
|
548
|
+
[`${prefixCls}-label-align-${labelAlign}`]: true,
|
|
549
|
+
[`${prefixCls}-control-align-${wrapperAlign}`]: true,
|
|
550
|
+
[`${prefixCls}-label-wrap`]: !!labelWrap,
|
|
551
|
+
[`${prefixCls}-control-wrap`]: !!wrapperWrap,
|
|
552
|
+
[`${prefixCls}-bordered-none`]:
|
|
553
|
+
bordered === false || !!inset || !!feedbackIcon,
|
|
554
|
+
[`${props.className}`]: !!props.className,
|
|
555
|
+
},
|
|
556
|
+
on: {
|
|
557
|
+
'!focus': () => {
|
|
558
|
+
if (feedbackIcon || inset) {
|
|
559
|
+
active.value = true;
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
'!blur': () => {
|
|
563
|
+
if (feedbackIcon || inset) {
|
|
564
|
+
active.value = false;
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
default: () => [renderLabel, renderContent],
|
|
571
|
+
}
|
|
572
|
+
);
|
|
573
|
+
};
|
|
574
|
+
},
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
const Item = connect(
|
|
578
|
+
FormBaseItem,
|
|
579
|
+
mapProps(
|
|
580
|
+
{ validateStatus: true, title: 'label', required: true },
|
|
581
|
+
(props, field:any) => {
|
|
582
|
+
if (isVoidField(field)) return props;
|
|
583
|
+
if (!field) return props;
|
|
584
|
+
const takeMessage = () => {
|
|
585
|
+
const split = (messages: any[]) => {
|
|
586
|
+
return messages.reduce((buf, text, index) => {
|
|
587
|
+
if (!text) return buf;
|
|
588
|
+
return index < messages.length - 1
|
|
589
|
+
? buf.concat([text, ', '])
|
|
590
|
+
: buf.concat([text]);
|
|
591
|
+
}, []);
|
|
592
|
+
};
|
|
593
|
+
if (field.validating) return;
|
|
594
|
+
if (props.feedbackText) return props.feedbackText;
|
|
595
|
+
if (field.selfErrors.length) return split(field.selfErrors);
|
|
596
|
+
if (field.selfWarnings.length) return split(field.selfWarnings);
|
|
597
|
+
if (field.selfSuccesses.length)
|
|
598
|
+
return split(field.selfSuccesses);
|
|
599
|
+
};
|
|
600
|
+
const errorMessages = takeMessage();
|
|
601
|
+
return {
|
|
602
|
+
feedbackText: Array.isArray(errorMessages)
|
|
603
|
+
? errorMessages.join(', ')
|
|
604
|
+
: errorMessages,
|
|
605
|
+
extra: props.extra || field.description,
|
|
606
|
+
};
|
|
607
|
+
},
|
|
608
|
+
(props, field) => {
|
|
609
|
+
if (isVoidField(field)) return props;
|
|
610
|
+
if (!field) return props;
|
|
611
|
+
return {
|
|
612
|
+
feedbackStatus:
|
|
613
|
+
field.validateStatus === 'validating'
|
|
614
|
+
? 'pending'
|
|
615
|
+
: (Array.isArray(field.decorator) &&
|
|
616
|
+
field.decorator[1]?.feedbackStatus) ||
|
|
617
|
+
field.validateStatus,
|
|
618
|
+
};
|
|
619
|
+
},
|
|
620
|
+
(props, field) => {
|
|
621
|
+
if (isVoidField(field)) return props;
|
|
622
|
+
|
|
623
|
+
if (!field) return props;
|
|
624
|
+
let asterisk = false;
|
|
625
|
+
if (field.required && field.pattern !== 'readPretty') {
|
|
626
|
+
asterisk = true;
|
|
627
|
+
}
|
|
628
|
+
if ('asterisk' in props) {
|
|
629
|
+
asterisk = props.asterisk;
|
|
630
|
+
}
|
|
631
|
+
return {
|
|
632
|
+
asterisk,
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
)
|
|
636
|
+
);
|
|
637
|
+
|
|
638
|
+
export const FormItem = composeExport(Item, {
|
|
639
|
+
BaseItem: FormBaseItem,
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
export default FormItem;
|