@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,18 @@
|
|
|
1
|
+
import { transformComponent } from '../__builtins__';
|
|
2
|
+
import { connect, mapProps } from '@formily/vue';
|
|
3
|
+
|
|
4
|
+
import JtLink from '../base/Link/index.vue';
|
|
5
|
+
|
|
6
|
+
export type LinkProps = typeof JtLink;
|
|
7
|
+
|
|
8
|
+
const TransformLink = transformComponent<LinkProps>(JtLink);
|
|
9
|
+
|
|
10
|
+
export const Link = connect(
|
|
11
|
+
TransformLink,
|
|
12
|
+
mapProps({
|
|
13
|
+
value: 'modelValue',
|
|
14
|
+
readOnly: 'readonly',
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export default Link;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { transformComponent } from '../__builtins__';
|
|
2
|
+
import { connect, mapProps } from '@formily/vue';
|
|
3
|
+
|
|
4
|
+
import _Middleware from '../base/Middleware/index.vue';
|
|
5
|
+
|
|
6
|
+
export type MiddlewareProps = typeof _Middleware;
|
|
7
|
+
|
|
8
|
+
const TransformMiddleware = transformComponent<MiddlewareProps>(
|
|
9
|
+
_Middleware,
|
|
10
|
+
{ change: 'update:modelValue' }
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export const Middleware = connect(
|
|
14
|
+
TransformMiddleware,
|
|
15
|
+
mapProps({
|
|
16
|
+
value: 'modelValue',
|
|
17
|
+
readOnly: 'readonly',
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export default Middleware;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { transformComponent } from '../__builtins__';
|
|
2
|
+
import { mapProps, connect } from '@formily/vue';
|
|
3
|
+
|
|
4
|
+
import JtOneOf from '../base/OneOf/index.vue';
|
|
5
|
+
|
|
6
|
+
export type JtOneOfProps = typeof JtOneOf;
|
|
7
|
+
|
|
8
|
+
const TransformJtOneAny = transformComponent<JtOneOfProps>(JtOneOf, {
|
|
9
|
+
change: 'update:modelValue',
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const OneOf = connect(
|
|
13
|
+
TransformJtOneAny,
|
|
14
|
+
mapProps({
|
|
15
|
+
value: 'modelValue',
|
|
16
|
+
readOnly: 'readonly',
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export default OneOf;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { transformComponent } from '../__builtins__';
|
|
2
|
+
import { connect, mapProps } from '@formily/vue';
|
|
3
|
+
|
|
4
|
+
import FormilyPlaceholderInput from './index.vue';
|
|
5
|
+
|
|
6
|
+
export type FormilyPlaceholderInputProps = typeof FormilyPlaceholderInput;
|
|
7
|
+
|
|
8
|
+
const TransformFormilyPlaceholderInput = transformComponent<FormilyPlaceholderInputProps>(
|
|
9
|
+
FormilyPlaceholderInput,
|
|
10
|
+
{ change: 'update:modelValue' }
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export const PlaceholderInput = connect(
|
|
14
|
+
TransformFormilyPlaceholderInput,
|
|
15
|
+
mapProps({
|
|
16
|
+
value: 'modelValue',
|
|
17
|
+
readOnly: 'readonly',
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export default PlaceholderInput;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<el-input
|
|
4
|
+
:rows="4"
|
|
5
|
+
type="textarea"
|
|
6
|
+
:model-Value="modelValue"
|
|
7
|
+
@blur="handleBlur"
|
|
8
|
+
@input="handleInput"
|
|
9
|
+
></el-input>
|
|
10
|
+
<div class="placeholder-group">
|
|
11
|
+
<div
|
|
12
|
+
v-for="item in placeholderList"
|
|
13
|
+
:key="item"
|
|
14
|
+
class="placeholder-group--item"
|
|
15
|
+
@click="insertPlaceholder(item)"
|
|
16
|
+
>
|
|
17
|
+
{{ item.text }} {{ item.description }}
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script lang="ts">
|
|
24
|
+
import { computed, defineComponent, ref } from 'vue';
|
|
25
|
+
|
|
26
|
+
export default defineComponent({
|
|
27
|
+
name: 'PlaceholderInput',
|
|
28
|
+
emits: ['change'],
|
|
29
|
+
props: {
|
|
30
|
+
modelValue: String,
|
|
31
|
+
placeholderList: {
|
|
32
|
+
type: Array,
|
|
33
|
+
default: () => {
|
|
34
|
+
return [];
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
setup(props, ctx) {
|
|
39
|
+
// 光标位置
|
|
40
|
+
const cursorPosition = ref<number>(0);
|
|
41
|
+
|
|
42
|
+
// 失焦记录光标位置
|
|
43
|
+
function handleBlur(e) {
|
|
44
|
+
cursorPosition.value = e.target.selectionStart;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function handleInput(e) {
|
|
48
|
+
emitValue(e);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let time = null;
|
|
52
|
+
function emitValue(value) {
|
|
53
|
+
if (time) clearTimeout(time);
|
|
54
|
+
|
|
55
|
+
time = setTimeout(() => {
|
|
56
|
+
ctx.emit('change', value);
|
|
57
|
+
}, 100);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function insertPlaceholder(data) {
|
|
61
|
+
emitValue(
|
|
62
|
+
props.modelValue.slice(0, cursorPosition.value) +
|
|
63
|
+
data.text +
|
|
64
|
+
props.modelValue.slice(cursorPosition.value)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return { handleBlur, insertPlaceholder, handleInput };
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<style scoped lang="scss">
|
|
73
|
+
.placeholder-group {
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-wrap: wrap;
|
|
76
|
+
&--item {
|
|
77
|
+
border: 1px solid #999;
|
|
78
|
+
padding: 0px 4px;
|
|
79
|
+
border-radius: 4px;
|
|
80
|
+
margin-top: 10px;
|
|
81
|
+
margin-right: 10px;
|
|
82
|
+
font-size: 12px;
|
|
83
|
+
line-height: 24px;
|
|
84
|
+
cursor: pointer;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
</style>
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { defineComponent, computed, toRef, Ref, h } from 'vue';
|
|
2
|
+
import {
|
|
3
|
+
createContext,
|
|
4
|
+
resolveComponent,
|
|
5
|
+
useContext,
|
|
6
|
+
composeExport,
|
|
7
|
+
} from '../__builtins__/shared';
|
|
8
|
+
import { Field } from '@formily/core';
|
|
9
|
+
import { observer } from '@formily/reactive-vue';
|
|
10
|
+
import { useField } from '@formily/vue';
|
|
11
|
+
import { isArr, isValid } from '@formily/shared';
|
|
12
|
+
import { stylePrefix } from '../__builtins__/configs';
|
|
13
|
+
import { InputProps } from '../input';
|
|
14
|
+
import type { SelectProps } from '../select';
|
|
15
|
+
import type { CascaderProps } from '../cascader';
|
|
16
|
+
import type { DatePickerProps } from '../date-picker';
|
|
17
|
+
import type { TimePickerProps } from '../time-picker';
|
|
18
|
+
import { Space } from '../space';
|
|
19
|
+
import { ElTag } from '@cicctencent/jtui';
|
|
20
|
+
|
|
21
|
+
const prefixCls = `${stylePrefix}-preview-text`;
|
|
22
|
+
const PlaceholderContext = createContext('N/A');
|
|
23
|
+
|
|
24
|
+
export const usePlaceholder = (value?: Ref<any>) => {
|
|
25
|
+
const placeholderCtx = useContext(PlaceholderContext);
|
|
26
|
+
const placeholder = computed(() => {
|
|
27
|
+
return isValid(value?.value) && value?.value !== ''
|
|
28
|
+
? value?.value
|
|
29
|
+
: resolveComponent(placeholderCtx.value) || 'N/A';
|
|
30
|
+
});
|
|
31
|
+
return placeholder;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const Input = defineComponent({
|
|
35
|
+
name: 'FPreviewTextInput',
|
|
36
|
+
props: ['value'],
|
|
37
|
+
setup(props, { attrs, slots }) {
|
|
38
|
+
const value = toRef(props, 'value');
|
|
39
|
+
const placeholder = usePlaceholder(value);
|
|
40
|
+
return () => {
|
|
41
|
+
return h(
|
|
42
|
+
Space,
|
|
43
|
+
{
|
|
44
|
+
class: [prefixCls],
|
|
45
|
+
style: attrs.style,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
default: () =>
|
|
49
|
+
[
|
|
50
|
+
slots?.prepend?.(),
|
|
51
|
+
slots?.prefix?.(),
|
|
52
|
+
placeholder.value,
|
|
53
|
+
slots?.suffix?.(),
|
|
54
|
+
slots?.append?.(),
|
|
55
|
+
].filter(child => !!child),
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const Select = observer(
|
|
63
|
+
defineComponent<SelectProps>({
|
|
64
|
+
name: 'FPreviewTextSelect',
|
|
65
|
+
setup(_props, { attrs }) {
|
|
66
|
+
const fieldRef = useField<Field>();
|
|
67
|
+
const field = fieldRef.value;
|
|
68
|
+
const props = attrs as unknown as SelectProps;
|
|
69
|
+
const dataSource: any[] = field?.dataSource?.length
|
|
70
|
+
? field.dataSource
|
|
71
|
+
: props?.options?.length
|
|
72
|
+
? props.options
|
|
73
|
+
: [];
|
|
74
|
+
const placeholder = usePlaceholder();
|
|
75
|
+
const getSelected = () => {
|
|
76
|
+
const value = props.value;
|
|
77
|
+
if (props.multiple) {
|
|
78
|
+
return isArr(value)
|
|
79
|
+
? value.map(val => ({ label: val, value: val }))
|
|
80
|
+
: [];
|
|
81
|
+
} else {
|
|
82
|
+
return isValid(value) ? [{ label: value, value }] : [];
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const getLabels = () => {
|
|
87
|
+
const selected = getSelected();
|
|
88
|
+
if (!selected.length) {
|
|
89
|
+
return h(
|
|
90
|
+
ElTag,
|
|
91
|
+
{},
|
|
92
|
+
{
|
|
93
|
+
default: () => placeholder.value,
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return selected.map(({ value, label }, key) => {
|
|
98
|
+
const text =
|
|
99
|
+
dataSource?.find(item => item.value == value)?.label ||
|
|
100
|
+
label;
|
|
101
|
+
return h(
|
|
102
|
+
ElTag,
|
|
103
|
+
{
|
|
104
|
+
key,
|
|
105
|
+
type: 'info',
|
|
106
|
+
effect: 'light',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
default: () => text || placeholder.value,
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
return () => {
|
|
116
|
+
return h(
|
|
117
|
+
Space,
|
|
118
|
+
{
|
|
119
|
+
class: [prefixCls],
|
|
120
|
+
style: attrs.style,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
default: () => getLabels(),
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
})
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const Cascader = observer(
|
|
132
|
+
defineComponent<CascaderProps>({
|
|
133
|
+
name: 'FPreviewTextCascader',
|
|
134
|
+
setup(_props, { attrs }) {
|
|
135
|
+
const fieldRef = useField<Field>();
|
|
136
|
+
const field = fieldRef.value;
|
|
137
|
+
const props = attrs as unknown as CascaderProps;
|
|
138
|
+
const dataSource: any[] = field?.dataSource?.length
|
|
139
|
+
? field.dataSource
|
|
140
|
+
: props?.options?.length
|
|
141
|
+
? props.options
|
|
142
|
+
: [];
|
|
143
|
+
const placeholder = usePlaceholder();
|
|
144
|
+
const valueKey = props.props?.value || 'value';
|
|
145
|
+
const labelKey = props.props?.label || 'label';
|
|
146
|
+
const getSelected = () => {
|
|
147
|
+
return isArr(props.value) ? props.value : [];
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const findLabel: (value: any, dataSource: any) => any = (
|
|
151
|
+
value,
|
|
152
|
+
dataSource
|
|
153
|
+
) => {
|
|
154
|
+
for (let i = 0; i < dataSource?.length; i++) {
|
|
155
|
+
const item = dataSource[i];
|
|
156
|
+
if (item?.[valueKey] === value) {
|
|
157
|
+
return item?.[labelKey];
|
|
158
|
+
} else {
|
|
159
|
+
const childLabel = findLabel(value, item?.children);
|
|
160
|
+
if (childLabel) return childLabel;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const getLabels = () => {
|
|
166
|
+
const selected = getSelected();
|
|
167
|
+
if (!selected?.length) {
|
|
168
|
+
return h(
|
|
169
|
+
ElTag,
|
|
170
|
+
{},
|
|
171
|
+
{
|
|
172
|
+
default: () => placeholder.value,
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
return selected.map((value, key) => {
|
|
177
|
+
const text = findLabel(value, dataSource);
|
|
178
|
+
return h(
|
|
179
|
+
ElTag,
|
|
180
|
+
{
|
|
181
|
+
key,
|
|
182
|
+
type: 'info',
|
|
183
|
+
effect: 'light',
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
default: () => text || placeholder.value,
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
return () => {
|
|
193
|
+
return h(
|
|
194
|
+
Space,
|
|
195
|
+
{
|
|
196
|
+
class: [prefixCls],
|
|
197
|
+
style: attrs.style,
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
default: () => getLabels(),
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
})
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
const DatePicker = defineComponent<DatePickerProps>({
|
|
209
|
+
name: 'FPreviewTextDatePicker',
|
|
210
|
+
setup(_props, { attrs }) {
|
|
211
|
+
const props = attrs as unknown as DatePickerProps;
|
|
212
|
+
const placeholder = usePlaceholder();
|
|
213
|
+
const getLabels = () => {
|
|
214
|
+
if (isArr(props.value)) {
|
|
215
|
+
const labels = (props.value as any[]).map(
|
|
216
|
+
(value: string | Date) => value || placeholder.value
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
return labels.join('~');
|
|
220
|
+
} else {
|
|
221
|
+
return props.value || placeholder.value;
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
return () => {
|
|
226
|
+
return h(
|
|
227
|
+
'div',
|
|
228
|
+
{
|
|
229
|
+
class: [prefixCls],
|
|
230
|
+
style: attrs.style,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
default: () => getLabels(),
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
};
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
const TimePicker = defineComponent<TimePickerProps>({
|
|
241
|
+
name: 'FPreviewTextTimePicker',
|
|
242
|
+
setup(_props, { attrs }) {
|
|
243
|
+
const props = attrs as unknown as TimePickerProps;
|
|
244
|
+
// const format = props.pickerOptions?.format || 'HH:mm:ss'
|
|
245
|
+
const placeholder = usePlaceholder();
|
|
246
|
+
const getLabels = () => {
|
|
247
|
+
if (isArr(props.value)) {
|
|
248
|
+
const labels = props.value.map(
|
|
249
|
+
(value: string | Date) => value || placeholder.value
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
return labels.join('~');
|
|
253
|
+
} else {
|
|
254
|
+
return props.value || placeholder.value;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
return () => {
|
|
259
|
+
return h(
|
|
260
|
+
'div',
|
|
261
|
+
{
|
|
262
|
+
class: [prefixCls],
|
|
263
|
+
style: attrs.style,
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
default: () => getLabels(),
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
const Text = defineComponent<any>({
|
|
274
|
+
name: 'FPreviewText',
|
|
275
|
+
setup(_props, { attrs }) {
|
|
276
|
+
const placeholder = usePlaceholder();
|
|
277
|
+
|
|
278
|
+
return () => {
|
|
279
|
+
return h(
|
|
280
|
+
'div',
|
|
281
|
+
{
|
|
282
|
+
class: [prefixCls],
|
|
283
|
+
style: attrs.style,
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
default: () => placeholder.value,
|
|
287
|
+
}
|
|
288
|
+
);
|
|
289
|
+
};
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
export const PreviewText = composeExport(Text, {
|
|
294
|
+
Input,
|
|
295
|
+
Select,
|
|
296
|
+
Cascader,
|
|
297
|
+
DatePicker,
|
|
298
|
+
TimePicker,
|
|
299
|
+
Placeholder: PlaceholderContext.Provider,
|
|
300
|
+
usePlaceholder,
|
|
301
|
+
}) as any;
|
|
302
|
+
|
|
303
|
+
export default PreviewText;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { connect, mapProps, mapReadPretty } from '@formily/vue';
|
|
2
|
+
import { defineComponent, PropType, h } from 'vue';
|
|
3
|
+
import {
|
|
4
|
+
composeExport,
|
|
5
|
+
transformComponent,
|
|
6
|
+
resolveComponent,
|
|
7
|
+
SlotTypes,
|
|
8
|
+
} from '../__builtins__/shared';
|
|
9
|
+
import { PreviewText } from '../preview-text';
|
|
10
|
+
|
|
11
|
+
import { ElRadio, ElRadioGroup, ElRadioButton } from '@cicctencent/jtui';
|
|
12
|
+
|
|
13
|
+
export type ElRadioProps = typeof ElRadio;
|
|
14
|
+
export type RadioGroupProps = typeof ElRadioGroup & {
|
|
15
|
+
value: any;
|
|
16
|
+
options?: (
|
|
17
|
+
| (Omit<ElRadioProps, 'value'> & {
|
|
18
|
+
value: ElRadioProps['label'];
|
|
19
|
+
label: SlotTypes;
|
|
20
|
+
})
|
|
21
|
+
| string
|
|
22
|
+
)[];
|
|
23
|
+
optionType: 'defalt' | 'button';
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const TransformElRadioGroup = transformComponent(ElRadioGroup, {
|
|
27
|
+
change: 'input',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const RadioGroupOption = defineComponent({
|
|
31
|
+
name: 'FRadioGroup',
|
|
32
|
+
props: {
|
|
33
|
+
options: {
|
|
34
|
+
type: Array as PropType<RadioGroupProps['options']>,
|
|
35
|
+
default: () => [],
|
|
36
|
+
},
|
|
37
|
+
optionType: {
|
|
38
|
+
type: String as PropType<RadioGroupProps['optionType']>,
|
|
39
|
+
default: 'default',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
setup(customProps, { attrs, slots }) {
|
|
43
|
+
return () => {
|
|
44
|
+
const options = customProps.options || [];
|
|
45
|
+
const OptionType =
|
|
46
|
+
customProps.optionType === 'button' ? ElRadioButton : ElRadio;
|
|
47
|
+
const children =
|
|
48
|
+
options.length !== 0
|
|
49
|
+
? {
|
|
50
|
+
default: () =>
|
|
51
|
+
options.map(option => {
|
|
52
|
+
if (typeof option === 'string') {
|
|
53
|
+
return h(
|
|
54
|
+
OptionType,
|
|
55
|
+
{ label: option },
|
|
56
|
+
{
|
|
57
|
+
default: () => [
|
|
58
|
+
resolveComponent(
|
|
59
|
+
slots?.option ?? option,
|
|
60
|
+
{ option }
|
|
61
|
+
),
|
|
62
|
+
],
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
} else {
|
|
66
|
+
return h(
|
|
67
|
+
OptionType,
|
|
68
|
+
{
|
|
69
|
+
...option,
|
|
70
|
+
value: undefined,
|
|
71
|
+
label: option.value,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
default: () => [
|
|
75
|
+
resolveComponent(
|
|
76
|
+
slots?.option ??
|
|
77
|
+
option.label,
|
|
78
|
+
{
|
|
79
|
+
option,
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
],
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}),
|
|
87
|
+
}
|
|
88
|
+
: slots;
|
|
89
|
+
return h(
|
|
90
|
+
TransformElRadioGroup,
|
|
91
|
+
{
|
|
92
|
+
...attrs,
|
|
93
|
+
},
|
|
94
|
+
children
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const RadioGroup = connect(
|
|
101
|
+
RadioGroupOption,
|
|
102
|
+
mapProps({ dataSource: 'options', value: 'modelValue' }),
|
|
103
|
+
mapReadPretty(PreviewText.Select)
|
|
104
|
+
);
|
|
105
|
+
export const Radio = composeExport(ElRadio, {
|
|
106
|
+
Group: RadioGroup,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
export default Radio;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { IFieldResetOptions } from '@formily/core'
|
|
2
|
+
import { h, useParentForm } from '@formily/vue'
|
|
3
|
+
import { observer } from '@formily/reactive-vue'
|
|
4
|
+
import { defineComponent } from 'vue'
|
|
5
|
+
|
|
6
|
+
import type { ElButton as ElButtonProps } from '@cicctencent/jtui'
|
|
7
|
+
import { ElButton } from '@cicctencent/jtui'
|
|
8
|
+
|
|
9
|
+
export type ResetProps = IFieldResetOptions & typeof ElButtonProps
|
|
10
|
+
|
|
11
|
+
export const Reset = observer(
|
|
12
|
+
defineComponent({
|
|
13
|
+
name: 'FReset',
|
|
14
|
+
props: {
|
|
15
|
+
forceClear: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: false,
|
|
18
|
+
},
|
|
19
|
+
validate: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: false,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
setup(props, { attrs, slots }: any) {
|
|
25
|
+
const formRef = useParentForm()
|
|
26
|
+
return () => {
|
|
27
|
+
const form = formRef?.value
|
|
28
|
+
return h(
|
|
29
|
+
ElButton,
|
|
30
|
+
{
|
|
31
|
+
...attrs,
|
|
32
|
+
onClick: (e: MouseEvent) => {
|
|
33
|
+
if (attrs?.click) {
|
|
34
|
+
if (attrs.click(e) === false) return
|
|
35
|
+
}
|
|
36
|
+
form
|
|
37
|
+
?.reset('*', {
|
|
38
|
+
forceClear: props.forceClear,
|
|
39
|
+
validate: props.validate,
|
|
40
|
+
})
|
|
41
|
+
.then(attrs.resetValidateSuccess as (e: any) => void)
|
|
42
|
+
.catch(attrs.resetValidateFailed as (e: any) => void)
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
slots
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
export default Reset
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@cicctencent/jtui/theme-chalk/src/button.scss'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { transformComponent } from '../__builtins__';
|
|
2
|
+
import JtRichEditor from '../base/RichEditor/index.vue';
|
|
3
|
+
import { connect, mapProps } from '@formily/vue';
|
|
4
|
+
|
|
5
|
+
export type JtRichEditorProps = typeof JtRichEditor;
|
|
6
|
+
|
|
7
|
+
const TransformJtRichEditor =
|
|
8
|
+
transformComponent<JtRichEditorProps>(JtRichEditor);
|
|
9
|
+
|
|
10
|
+
export const RichEditor = connect(
|
|
11
|
+
TransformJtRichEditor,
|
|
12
|
+
mapProps({
|
|
13
|
+
value: 'modelValue',
|
|
14
|
+
readOnly: 'readonly',
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export default RichEditor;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { transformComponent } from '../__builtins__';
|
|
2
|
+
import { connect, mapProps } from '@formily/vue';
|
|
3
|
+
|
|
4
|
+
import FormilyRow from './index.vue';
|
|
5
|
+
|
|
6
|
+
export type FormilyRowProps = typeof FormilyRow;
|
|
7
|
+
|
|
8
|
+
const TransformFormilyRow = transformComponent<FormilyRowProps>(FormilyRow, {
|
|
9
|
+
change: 'update:modelValue',
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const Row = connect(
|
|
13
|
+
TransformFormilyRow,
|
|
14
|
+
mapProps({
|
|
15
|
+
value: 'modelValue',
|
|
16
|
+
readOnly: 'readonly',
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export default Row;
|