@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,166 @@
|
|
|
1
|
+
import { defineComponent, PropType, h, Component } from 'vue';
|
|
2
|
+
import { connect, mapProps, mapReadPretty } from '@formily/vue';
|
|
3
|
+
import {
|
|
4
|
+
composeExport,
|
|
5
|
+
transformComponent,
|
|
6
|
+
resolveComponent,
|
|
7
|
+
SlotTypes,
|
|
8
|
+
} from '../__builtins__/shared';
|
|
9
|
+
|
|
10
|
+
import { ElCheckbox, ElCheckboxGroup, ElCheckboxButton } from '@cicctencent/jtui';
|
|
11
|
+
import { PreviewText } from '../preview-text';
|
|
12
|
+
|
|
13
|
+
type ElCheckboxProps = Omit<typeof ElCheckbox, 'value'> & {
|
|
14
|
+
value: ElCheckboxProps['label'];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export interface CheckboxProps extends ElCheckboxProps {
|
|
18
|
+
option: Omit<typeof ElCheckbox, 'value'> & {
|
|
19
|
+
value: ElCheckboxProps['label'];
|
|
20
|
+
label: SlotTypes;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const CheckboxOption = defineComponent({
|
|
25
|
+
name: 'FCheckbox',
|
|
26
|
+
inheritAttrs: false,
|
|
27
|
+
props: {
|
|
28
|
+
option: {
|
|
29
|
+
type: Object,
|
|
30
|
+
default: null,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
setup(curtomProps, { attrs, slots }) {
|
|
34
|
+
return () => {
|
|
35
|
+
const props = attrs as unknown as CheckboxProps;
|
|
36
|
+
const option = curtomProps?.option;
|
|
37
|
+
if (option) {
|
|
38
|
+
const children = {
|
|
39
|
+
default: () => [
|
|
40
|
+
resolveComponent(slots.default ?? option.label, {
|
|
41
|
+
option,
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
const newProps = {} as Partial<ElCheckboxProps>;
|
|
46
|
+
Object.assign(newProps, option);
|
|
47
|
+
newProps.label = option.value;
|
|
48
|
+
delete newProps.value;
|
|
49
|
+
|
|
50
|
+
return h(
|
|
51
|
+
attrs.optionType === 'button'
|
|
52
|
+
? ElCheckboxButton
|
|
53
|
+
: ElCheckbox,
|
|
54
|
+
{
|
|
55
|
+
...newProps,
|
|
56
|
+
},
|
|
57
|
+
children
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return h(
|
|
62
|
+
ElCheckbox,
|
|
63
|
+
{
|
|
64
|
+
...props,
|
|
65
|
+
},
|
|
66
|
+
slots
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export type CheckboxGroupProps = typeof ElCheckboxGroup & {
|
|
73
|
+
value: any[];
|
|
74
|
+
options?: Array<CheckboxProps | string>;
|
|
75
|
+
optionType: 'default' | 'button';
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const TransformElCheckboxGroup = transformComponent(ElCheckboxGroup, {
|
|
79
|
+
change: 'change',
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const CheckboxGroupOption: Component = defineComponent({
|
|
83
|
+
name: 'FCheckboxGroup',
|
|
84
|
+
props: {
|
|
85
|
+
options: {
|
|
86
|
+
type: Array,
|
|
87
|
+
default: () => [],
|
|
88
|
+
},
|
|
89
|
+
optionType: {
|
|
90
|
+
type: String as PropType<CheckboxGroupProps['optionType']>,
|
|
91
|
+
default: 'default',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
setup(customProps, { attrs, slots }) {
|
|
95
|
+
return (): any => {
|
|
96
|
+
const options = customProps.options || [];
|
|
97
|
+
const children =
|
|
98
|
+
options.length !== 0
|
|
99
|
+
? {
|
|
100
|
+
default: () =>
|
|
101
|
+
options.map(option => {
|
|
102
|
+
if (typeof option === 'string') {
|
|
103
|
+
return h(
|
|
104
|
+
Checkbox,
|
|
105
|
+
{
|
|
106
|
+
option: {
|
|
107
|
+
label: option,
|
|
108
|
+
value: option,
|
|
109
|
+
},
|
|
110
|
+
optionType:
|
|
111
|
+
customProps.optionType,
|
|
112
|
+
},
|
|
113
|
+
slots?.option
|
|
114
|
+
? {
|
|
115
|
+
default: () =>
|
|
116
|
+
slots.option!({
|
|
117
|
+
option,
|
|
118
|
+
}),
|
|
119
|
+
}
|
|
120
|
+
: {}
|
|
121
|
+
);
|
|
122
|
+
} else {
|
|
123
|
+
return h(
|
|
124
|
+
Checkbox as any,
|
|
125
|
+
{
|
|
126
|
+
option,
|
|
127
|
+
optionType:
|
|
128
|
+
customProps.optionType,
|
|
129
|
+
},
|
|
130
|
+
slots?.option
|
|
131
|
+
? {
|
|
132
|
+
default: () =>
|
|
133
|
+
slots.option!({
|
|
134
|
+
option,
|
|
135
|
+
}),
|
|
136
|
+
}
|
|
137
|
+
: {}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}),
|
|
141
|
+
}
|
|
142
|
+
: slots;
|
|
143
|
+
return h(
|
|
144
|
+
TransformElCheckboxGroup,
|
|
145
|
+
{
|
|
146
|
+
...attrs,
|
|
147
|
+
},
|
|
148
|
+
children
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const CheckboxGroup = connect(
|
|
155
|
+
CheckboxGroupOption,
|
|
156
|
+
mapProps({ dataSource: 'options', value: 'modelValue' }),
|
|
157
|
+
mapReadPretty(PreviewText.Select, {
|
|
158
|
+
multiple: true,
|
|
159
|
+
})
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
export const Checkbox = composeExport(connect(CheckboxOption), {
|
|
163
|
+
Group: CheckboxGroup,
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
export default Checkbox;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { transformComponent } from '../__builtins__';
|
|
2
|
+
import { connect, mapProps } from '@formily/vue';
|
|
3
|
+
|
|
4
|
+
import JtCloudButton from '../base/CloudButton/index.vue';
|
|
5
|
+
|
|
6
|
+
export type JtCloudButtonProps = typeof JtCloudButton;
|
|
7
|
+
|
|
8
|
+
const TransformJtCloudButton = transformComponent<JtCloudButtonProps>(
|
|
9
|
+
JtCloudButton,
|
|
10
|
+
{ change: 'update:modelValue' }
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export const CloudButton = connect(
|
|
14
|
+
TransformJtCloudButton,
|
|
15
|
+
mapProps({
|
|
16
|
+
value: 'modelValue',
|
|
17
|
+
readOnly: 'readonly',
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export default CloudButton;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { transformComponent } from '../__builtins__';
|
|
2
|
+
import { mapProps, connect } from '@formily/vue';
|
|
3
|
+
import _ColorGroup from '../base/ColorGroup/index.vue';
|
|
4
|
+
|
|
5
|
+
export type ColorGroupProps = typeof _ColorGroup;
|
|
6
|
+
|
|
7
|
+
const TransformColorGroup = transformComponent<ColorGroupProps>(_ColorGroup, {
|
|
8
|
+
change: 'update:modelValue',
|
|
9
|
+
});
|
|
10
|
+
export const ColorGroup = connect(
|
|
11
|
+
TransformColorGroup,
|
|
12
|
+
mapProps({
|
|
13
|
+
value: 'modelValue',
|
|
14
|
+
readOnly: 'readonly',
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export default ColorGroup;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { transformComponent } from '../__builtins__';
|
|
2
|
+
import { mapProps, connect } from '@formily/vue';
|
|
3
|
+
import _ColorPicker from '../base/ColorPicker/index.vue';
|
|
4
|
+
|
|
5
|
+
export type ColorPickerProps = typeof _ColorPicker;
|
|
6
|
+
|
|
7
|
+
const TransformColorPicker = transformComponent<ColorPickerProps>(_ColorPicker, {
|
|
8
|
+
change: 'update:modelValue',
|
|
9
|
+
});
|
|
10
|
+
export const ColorPicker = connect(
|
|
11
|
+
TransformColorPicker,
|
|
12
|
+
mapProps({
|
|
13
|
+
value: 'modelValue',
|
|
14
|
+
readOnly: 'readonly',
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export default ColorPicker;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { transformComponent } from '../__builtins__';
|
|
2
|
+
import { mapProps, connect } from '@formily/vue';
|
|
3
|
+
import FormilyContainer from '../base/Container/index.vue';
|
|
4
|
+
|
|
5
|
+
export type FormilyContainerProps = typeof FormilyContainer;
|
|
6
|
+
|
|
7
|
+
const TransformFormilyContainer = transformComponent<FormilyContainerProps>(FormilyContainer, {
|
|
8
|
+
change: 'update:modelValue',
|
|
9
|
+
});
|
|
10
|
+
export const Container = connect(
|
|
11
|
+
TransformFormilyContainer,
|
|
12
|
+
mapProps({
|
|
13
|
+
value: 'modelValue',
|
|
14
|
+
readOnly: 'readonly',
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export default Container;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { transformComponent } from '../__builtins__';
|
|
2
|
+
import { connect, mapProps } from '@formily/vue';
|
|
3
|
+
// import ElDatePicker from '../base/dateTime/index.vue';
|
|
4
|
+
import {ElDatePicker} from '@cicctencent/jtui';
|
|
5
|
+
import 'dayjs/locale/zh-cn';
|
|
6
|
+
export type DateTimeProps = typeof ElDatePicker;
|
|
7
|
+
|
|
8
|
+
const TransformDateTime = transformComponent<DateTimeProps>(ElDatePicker, {
|
|
9
|
+
change: 'update:modelValue',
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const DateTime = connect(
|
|
13
|
+
TransformDateTime,
|
|
14
|
+
mapProps(
|
|
15
|
+
{
|
|
16
|
+
value: 'modelValue',
|
|
17
|
+
readOnly: 'readonly',
|
|
18
|
+
},
|
|
19
|
+
props => {
|
|
20
|
+
return Object.assign({type: 'datetimerange'},props);
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
);
|
|
24
|
+
export default DateTime;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { transformComponent } from '../__builtins__/shared';
|
|
2
|
+
import { connect, mapProps, mapReadPretty } from '@formily/vue';
|
|
3
|
+
import { ElDatePicker } from '@cicctencent/jtui';
|
|
4
|
+
|
|
5
|
+
import { PreviewText } from '../preview-text';
|
|
6
|
+
|
|
7
|
+
export type DatePickerProps = typeof ElDatePicker;
|
|
8
|
+
|
|
9
|
+
const TransformElDatePicker = transformComponent<DatePickerProps>(
|
|
10
|
+
ElDatePicker,
|
|
11
|
+
{
|
|
12
|
+
change: 'update:modelValue',
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const getDefaultFormat = (props: DatePickerProps, formatType = 'format') => {
|
|
17
|
+
const type = props.type;
|
|
18
|
+
|
|
19
|
+
if (type === 'week' && formatType === 'format') {
|
|
20
|
+
return '[Week] ww';
|
|
21
|
+
} else if (type === 'month') {
|
|
22
|
+
return 'YYYY-MM';
|
|
23
|
+
} else if (type === 'year') {
|
|
24
|
+
return 'YYYY';
|
|
25
|
+
} else if (type === 'datetime' || type === 'datetimerange') {
|
|
26
|
+
return 'YYYY-MM-DD HH:mm:ss';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return 'YYYY-MM-DD';
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const DatePicker = connect(
|
|
33
|
+
TransformElDatePicker,
|
|
34
|
+
mapProps(
|
|
35
|
+
{
|
|
36
|
+
value: 'modelValue',
|
|
37
|
+
readOnly: 'readonly',
|
|
38
|
+
},
|
|
39
|
+
(props: any) => {
|
|
40
|
+
return {
|
|
41
|
+
...props,
|
|
42
|
+
format: props.format || getDefaultFormat(props),
|
|
43
|
+
valueFormat:
|
|
44
|
+
props.valueFormat || getDefaultFormat(props, 'valueFormat'),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
mapReadPretty(PreviewText.DatePicker)
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
export default DatePicker;
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { defineComponent, ref, onBeforeUnmount, Ref, h } from 'vue';
|
|
2
|
+
import { observer } from '@formily/reactive-vue';
|
|
3
|
+
import { reaction } from '@formily/reactive';
|
|
4
|
+
import { isVoidField, Field } from '@formily/core';
|
|
5
|
+
import { useField } from '@formily/vue';
|
|
6
|
+
import { ElPopover } from '@cicctencent/jtui';
|
|
7
|
+
import { Edit, ChatDotRound, Close } from '@cicctencent/icons-vue';
|
|
8
|
+
import { stylePrefix } from '../__builtins__/configs';
|
|
9
|
+
import { FormBaseItem, FormItemProps } from '../form-item';
|
|
10
|
+
import { composeExport } from '../__builtins__/shared';
|
|
11
|
+
|
|
12
|
+
export type EditableProps = FormItemProps;
|
|
13
|
+
export type EditablePopoverProps = typeof ElPopover;
|
|
14
|
+
|
|
15
|
+
const getParentPattern = (fieldRef: Ref<Field>) => {
|
|
16
|
+
const field = fieldRef.value;
|
|
17
|
+
return field?.parent?.pattern || field?.form?.pattern;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const getFormItemProps = (fieldRef: Ref<Field>): FormItemProps => {
|
|
21
|
+
const field = fieldRef.value;
|
|
22
|
+
|
|
23
|
+
if (isVoidField(field)) return {};
|
|
24
|
+
if (!field) return {};
|
|
25
|
+
const takeMessage = () => {
|
|
26
|
+
if (field.selfErrors.length) return field.selfErrors[0];
|
|
27
|
+
if (field.selfWarnings.length) return field.selfWarnings[0];
|
|
28
|
+
if (field.selfSuccesses.length) return field.selfSuccesses[0];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
feedbackStatus:
|
|
33
|
+
field.validateStatus === 'validating'
|
|
34
|
+
? 'pending'
|
|
35
|
+
: field.validateStatus,
|
|
36
|
+
feedbackText: takeMessage(),
|
|
37
|
+
extra: field.description,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const EditableInner = observer(
|
|
42
|
+
defineComponent<EditableProps>({
|
|
43
|
+
name: 'FEditable',
|
|
44
|
+
setup(props, { attrs, slots }) {
|
|
45
|
+
const fieldRef = useField<Field>();
|
|
46
|
+
const innerRef = ref(document.body);
|
|
47
|
+
|
|
48
|
+
const prefixCls = `${stylePrefix}-editable`;
|
|
49
|
+
const setEditable = (payload: boolean) => {
|
|
50
|
+
const pattern = getParentPattern(fieldRef as any);
|
|
51
|
+
|
|
52
|
+
if (pattern !== 'editable') return;
|
|
53
|
+
fieldRef.value.setPattern(payload ? 'editable' : 'readPretty');
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const dispose = reaction(
|
|
57
|
+
() => {
|
|
58
|
+
const pattern = getParentPattern(fieldRef as any);
|
|
59
|
+
|
|
60
|
+
return pattern;
|
|
61
|
+
},
|
|
62
|
+
pattern => {
|
|
63
|
+
if (pattern === 'editable') {
|
|
64
|
+
fieldRef.value.setPattern('readPretty');
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
fireImmediately: true,
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
onBeforeUnmount(dispose);
|
|
73
|
+
|
|
74
|
+
return () => {
|
|
75
|
+
const field = fieldRef.value;
|
|
76
|
+
const editable = field.pattern === 'editable';
|
|
77
|
+
const pattern = getParentPattern(fieldRef as any);
|
|
78
|
+
const itemProps = getFormItemProps(fieldRef as any);
|
|
79
|
+
|
|
80
|
+
const recover = () => {
|
|
81
|
+
if (editable && !fieldRef.value?.errors?.length) {
|
|
82
|
+
setEditable(false);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const onClick = (e: MouseEvent) => {
|
|
87
|
+
const target = e.target as HTMLElement;
|
|
88
|
+
const close = innerRef.value.querySelector(
|
|
89
|
+
`.${prefixCls}-close-btn`
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
if (target?.contains(close) || close?.contains(target)) {
|
|
93
|
+
recover();
|
|
94
|
+
} else if (!editable) {
|
|
95
|
+
setTimeout(() => {
|
|
96
|
+
setEditable(true);
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
innerRef.value.querySelector('input')?.focus();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const renderEditHelper = () => {
|
|
105
|
+
if (editable) return null;
|
|
106
|
+
|
|
107
|
+
return h(
|
|
108
|
+
FormBaseItem,
|
|
109
|
+
{
|
|
110
|
+
...attrs,
|
|
111
|
+
...itemProps,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
default: () => {
|
|
115
|
+
return h(
|
|
116
|
+
pattern === 'editable'
|
|
117
|
+
? Edit
|
|
118
|
+
: ChatDotRound,
|
|
119
|
+
{
|
|
120
|
+
class: [`${prefixCls}-edit-btn`],
|
|
121
|
+
},
|
|
122
|
+
{}
|
|
123
|
+
);
|
|
124
|
+
},
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const renderCloseHelper = () => {
|
|
130
|
+
if (!editable) return null;
|
|
131
|
+
return h(
|
|
132
|
+
FormBaseItem,
|
|
133
|
+
{
|
|
134
|
+
...attrs,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
default: () => {
|
|
138
|
+
return h(
|
|
139
|
+
Close,
|
|
140
|
+
{
|
|
141
|
+
class: [`${prefixCls}-close-btn`],
|
|
142
|
+
},
|
|
143
|
+
{}
|
|
144
|
+
);
|
|
145
|
+
},
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
return h(
|
|
151
|
+
'div',
|
|
152
|
+
{
|
|
153
|
+
class: prefixCls,
|
|
154
|
+
ref: innerRef,
|
|
155
|
+
onClick,
|
|
156
|
+
},
|
|
157
|
+
h(
|
|
158
|
+
'div',
|
|
159
|
+
{
|
|
160
|
+
class: `${prefixCls}-content`,
|
|
161
|
+
},
|
|
162
|
+
[
|
|
163
|
+
h(
|
|
164
|
+
FormBaseItem,
|
|
165
|
+
{
|
|
166
|
+
...attrs,
|
|
167
|
+
...itemProps,
|
|
168
|
+
},
|
|
169
|
+
slots
|
|
170
|
+
),
|
|
171
|
+
renderEditHelper(),
|
|
172
|
+
renderCloseHelper(),
|
|
173
|
+
]
|
|
174
|
+
)
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
})
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
const EditablePopover = observer(
|
|
182
|
+
defineComponent<EditablePopoverProps>({
|
|
183
|
+
name: 'FEditablePopover',
|
|
184
|
+
setup(props, { attrs, slots }) {
|
|
185
|
+
const fieldRef = useField<Field>();
|
|
186
|
+
|
|
187
|
+
const prefixCls = `${stylePrefix}-editable`;
|
|
188
|
+
const visible = ref(false);
|
|
189
|
+
|
|
190
|
+
return () => {
|
|
191
|
+
const field = fieldRef.value;
|
|
192
|
+
const pattern = getParentPattern(fieldRef as any);
|
|
193
|
+
return h(
|
|
194
|
+
ElPopover as any,
|
|
195
|
+
{
|
|
196
|
+
...attrs,
|
|
197
|
+
class: [prefixCls].concat(attrs.class as string[]),
|
|
198
|
+
title: attrs.title || field.title,
|
|
199
|
+
value: visible.value,
|
|
200
|
+
trigger: 'click',
|
|
201
|
+
onInput: (value: any) => {
|
|
202
|
+
visible.value = value;
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
default: slots.default,
|
|
207
|
+
reference: () =>
|
|
208
|
+
h(
|
|
209
|
+
'div',
|
|
210
|
+
{ class: prefixCls },
|
|
211
|
+
h(
|
|
212
|
+
FormBaseItem,
|
|
213
|
+
{ class: [`${prefixCls}-trigger`] },
|
|
214
|
+
{
|
|
215
|
+
default: () =>
|
|
216
|
+
h(
|
|
217
|
+
'div',
|
|
218
|
+
{
|
|
219
|
+
class: [
|
|
220
|
+
`${prefixCls}-content`,
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
[
|
|
224
|
+
h(
|
|
225
|
+
'span',
|
|
226
|
+
{
|
|
227
|
+
class: [
|
|
228
|
+
`${prefixCls}-preview`,
|
|
229
|
+
],
|
|
230
|
+
},
|
|
231
|
+
attrs.title ||
|
|
232
|
+
field.title
|
|
233
|
+
),
|
|
234
|
+
h(
|
|
235
|
+
pattern === 'editable'
|
|
236
|
+
? Edit
|
|
237
|
+
: ChatDotRound,
|
|
238
|
+
{
|
|
239
|
+
class: [
|
|
240
|
+
`${prefixCls}-edit-btn`,
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
{}
|
|
244
|
+
),
|
|
245
|
+
]
|
|
246
|
+
),
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
),
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
};
|
|
253
|
+
},
|
|
254
|
+
})
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
export const Editable: any = composeExport(EditableInner, {
|
|
258
|
+
Popover: EditablePopover,
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
export default Editable;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
@import '../__builtins__/styles/common.scss';
|
|
2
|
+
|
|
3
|
+
$editable-prefix-cls: '#{$formily-prefix}-editable';
|
|
4
|
+
|
|
5
|
+
.#{$editable-prefix-cls} {
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
display: inline-block !important;
|
|
8
|
+
|
|
9
|
+
.#{$formily-prefix}-form-text {
|
|
10
|
+
.#{$formily-prefix}-tag {
|
|
11
|
+
transition: none !important;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.#{$formily-prefix}-tag:last-child {
|
|
15
|
+
margin-right: 0 !important;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&-content {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
|
|
23
|
+
> * {
|
|
24
|
+
margin-right: 3px;
|
|
25
|
+
&:last-child {
|
|
26
|
+
margin-right: 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.#{$editable-prefix-cls}-edit-btn,
|
|
32
|
+
.#{$editable-prefix-cls}-close-btn {
|
|
33
|
+
transition: all 0.25s ease-in-out;
|
|
34
|
+
width: 14px;
|
|
35
|
+
height: 14px;
|
|
36
|
+
|
|
37
|
+
&:hover {
|
|
38
|
+
color: $--color-primary;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.#{$formily-prefix}-form-text {
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.#{$editable-prefix-cls}-preview {
|
|
48
|
+
white-space: nowrap;
|
|
49
|
+
text-overflow: ellipsis;
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
word-break: break-all;
|
|
52
|
+
max-width: 100px;
|
|
53
|
+
display: block;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isVoidField } from '@formily/core';
|
|
2
|
+
import { connect, mapProps } from '@formily/vue';
|
|
3
|
+
|
|
4
|
+
import type { ElFormItem as _ElFormItemProps } from '@cicctencent/jtui';
|
|
5
|
+
import { ElFormItem as ElFormItemComponent } from '@cicctencent/jtui';
|
|
6
|
+
|
|
7
|
+
export type ElFormItemProps = typeof _ElFormItemProps & { title: string };
|
|
8
|
+
|
|
9
|
+
export const ElFormItem = connect(
|
|
10
|
+
ElFormItemComponent,
|
|
11
|
+
mapProps({ title: 'label', required: true }, (props, field) => {
|
|
12
|
+
return {
|
|
13
|
+
...props,
|
|
14
|
+
error: !isVoidField(field)
|
|
15
|
+
? field.selfErrors[0] ?? undefined
|
|
16
|
+
: undefined,
|
|
17
|
+
};
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export default ElFormItem;
|