@tmagic/form 1.0.0-beta.8 → 1.0.0-rc.3
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/README.md +1 -0
- package/coverage/clover.xml +1360 -0
- package/coverage/coverage-final.json +38 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +176 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/Form.vue.html +676 -0
- package/coverage/lcov-report/src/FormDialog.vue.html +583 -0
- package/coverage/lcov-report/src/containers/Col.vue.html +253 -0
- package/coverage/lcov-report/src/containers/Container.vue.html +925 -0
- package/coverage/lcov-report/src/containers/Fieldset.vue.html +499 -0
- package/coverage/lcov-report/src/containers/GroupList.vue.html +541 -0
- package/coverage/lcov-report/src/containers/GroupListItem.vue.html +562 -0
- package/coverage/lcov-report/src/containers/Panel.vue.html +403 -0
- package/coverage/lcov-report/src/containers/Row.vue.html +277 -0
- package/coverage/lcov-report/src/containers/Step.vue.html +331 -0
- package/coverage/lcov-report/src/containers/Table.vue.html +1987 -0
- package/coverage/lcov-report/src/containers/Tabs.vue.html +625 -0
- package/coverage/lcov-report/src/containers/index.html +251 -0
- package/coverage/lcov-report/src/fields/Cascader.vue.html +526 -0
- package/coverage/lcov-report/src/fields/Checkbox.vue.html +286 -0
- package/coverage/lcov-report/src/fields/CheckboxGroup.vue.html +217 -0
- package/coverage/lcov-report/src/fields/ColorPicker.vue.html +199 -0
- package/coverage/lcov-report/src/fields/Date.vue.html +238 -0
- package/coverage/lcov-report/src/fields/DateTime.vue.html +262 -0
- package/coverage/lcov-report/src/fields/Daterange.vue.html +310 -0
- package/coverage/lcov-report/src/fields/Display.vue.html +187 -0
- package/coverage/lcov-report/src/fields/DynamicField.vue.html +412 -0
- package/coverage/lcov-report/src/fields/Hidden.vue.html +172 -0
- package/coverage/lcov-report/src/fields/Link.vue.html +421 -0
- package/coverage/lcov-report/src/fields/Number.vue.html +244 -0
- package/coverage/lcov-report/src/fields/RadioGroup.vue.html +184 -0
- package/coverage/lcov-report/src/fields/Select.vue.html +1243 -0
- package/coverage/lcov-report/src/fields/Switch.vue.html +280 -0
- package/coverage/lcov-report/src/fields/Text.vue.html +487 -0
- package/coverage/lcov-report/src/fields/Textarea.vue.html +265 -0
- package/coverage/lcov-report/src/fields/Time.vue.html +229 -0
- package/coverage/lcov-report/src/fields/index.html +371 -0
- package/coverage/lcov-report/src/index.html +146 -0
- package/coverage/lcov-report/src/index.ts.html +466 -0
- package/coverage/lcov-report/src/theme/index.html +116 -0
- package/coverage/lcov-report/src/theme/index.scss.html +112 -0
- package/coverage/lcov-report/src/utils/config.ts.html +166 -0
- package/coverage/lcov-report/src/utils/createForm.ts.html +160 -0
- package/coverage/lcov-report/src/utils/fieldProps.ts.html +202 -0
- package/coverage/lcov-report/src/utils/form.ts.html +895 -0
- package/coverage/lcov-report/src/utils/index.html +176 -0
- package/coverage/lcov-report/src/utils/useAddField.ts.html +205 -0
- package/coverage/lcov.info +3061 -0
- package/dist/style.css +9 -11
- package/dist/tmagic-form.es.js +173 -123
- package/dist/tmagic-form.es.js.map +1 -1
- package/dist/tmagic-form.umd.js +176 -127
- package/dist/tmagic-form.umd.js.map +1 -1
- package/dist/types/src/Form.vue.d.ts +362 -0
- package/dist/types/src/FormDialog.vue.d.ts +757 -0
- package/dist/types/src/containers/Col.vue.d.ts +42 -0
- package/dist/types/src/containers/Container.vue.d.ts +1 -0
- package/dist/types/src/containers/Row.vue.d.ts +0 -1
- package/dist/types/src/containers/Table.vue.d.ts +2601 -0
- package/dist/types/src/fields/Checkbox.vue.d.ts +2 -2
- package/dist/types/src/fields/Link.vue.d.ts +1596 -0
- package/dist/types/src/schema.d.ts +1 -0
- package/package.json +28 -9
- package/src/Form.vue +2 -2
- package/src/FormDialog.vue +1 -1
- package/src/containers/Col.vue +56 -0
- package/src/containers/Container.vue +19 -7
- package/src/containers/GroupListItem.vue +4 -4
- package/src/containers/Row.vue +13 -17
- package/src/containers/Table.vue +14 -6
- package/src/fields/Checkbox.vue +2 -2
- package/src/fields/Link.vue +1 -1
- package/src/fields/Select.vue +6 -15
- package/src/fields/Text.vue +4 -4
- package/src/fields/Textarea.vue +11 -13
- package/src/schema.ts +1 -0
- package/src/theme/form.scss +24 -17
- package/src/utils/form.ts +5 -1
- package/tsconfig.json +0 -9
- package/vite.config.ts +0 -27
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-
|
|
2
|
+
"version": "1.0.0-rc.3",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
|
-
"sideEffects":
|
|
4
|
+
"sideEffects": [
|
|
5
|
+
"dist/*",
|
|
6
|
+
"src/theme/*"
|
|
7
|
+
],
|
|
5
8
|
"main": "dist/tmagic-form.umd.js",
|
|
6
9
|
"module": "dist/tmagic-form.es.js",
|
|
7
10
|
"style": "dist/style.css",
|
|
@@ -14,10 +17,14 @@
|
|
|
14
17
|
"./dist/style.css": {
|
|
15
18
|
"import": "./dist/style.css",
|
|
16
19
|
"require": "./dist/style.css"
|
|
17
|
-
}
|
|
20
|
+
},
|
|
21
|
+
"./*": "./*"
|
|
18
22
|
},
|
|
23
|
+
"license": "Apache-2.0",
|
|
19
24
|
"scripts": {
|
|
20
|
-
"build": "vite build"
|
|
25
|
+
"build": "vite build",
|
|
26
|
+
"test": "jest --maxWorkers=8",
|
|
27
|
+
"test:coverage": "jest --maxWorkers=16 --coverage"
|
|
21
28
|
},
|
|
22
29
|
"engines": {
|
|
23
30
|
"node": ">=14"
|
|
@@ -28,26 +35,38 @@
|
|
|
28
35
|
},
|
|
29
36
|
"dependencies": {
|
|
30
37
|
"@element-plus/icons": "0.0.11",
|
|
31
|
-
"@tmagic/utils": "^1.0.0-
|
|
32
|
-
"element-plus": "^2.
|
|
38
|
+
"@tmagic/utils": "^1.0.0-rc.3",
|
|
39
|
+
"element-plus": "^2.2.0",
|
|
33
40
|
"lodash-es": "^4.17.21",
|
|
34
|
-
"moment": "^2.29.
|
|
41
|
+
"moment": "^2.29.2",
|
|
35
42
|
"sortablejs": "^1.14.0",
|
|
36
43
|
"vue": "^3.2.0"
|
|
37
44
|
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"element-plus": "^2.2.0",
|
|
47
|
+
"vue": "^3.2.0"
|
|
48
|
+
},
|
|
38
49
|
"devDependencies": {
|
|
50
|
+
"@babel/core": "^7.18.0",
|
|
51
|
+
"@types/jest": "^27.5.1",
|
|
39
52
|
"@types/lodash-es": "^4.17.4",
|
|
40
53
|
"@types/node": "^15.12.4",
|
|
41
54
|
"@types/sortablejs": "^1.10.7",
|
|
42
55
|
"@vitejs/plugin-vue": "^1.2.3",
|
|
43
56
|
"@vitejs/plugin-vue-jsx": "^1.1.6",
|
|
44
57
|
"@vue/compiler-sfc": "^3.2.0",
|
|
45
|
-
"@vue/test-utils": "^2.0.0-rc.
|
|
58
|
+
"@vue/test-utils": "^2.0.0-rc.20",
|
|
59
|
+
"@vue/vue3-jest": "^27.0.0-alpha.4",
|
|
60
|
+
"babel-jest": "^27.0.6",
|
|
61
|
+
"jest": "^27.5.1",
|
|
62
|
+
"jest-serializer-vue": "^2.0.2",
|
|
63
|
+
"jest-transform-stub": "^2.0.0",
|
|
46
64
|
"sass": "^1.35.1",
|
|
65
|
+
"ts-jest": "^27.1.4",
|
|
47
66
|
"typescript": "^4.3.4",
|
|
48
67
|
"vite": "^2.3.7",
|
|
49
68
|
"vite-plugin-dts": "^0.9.6",
|
|
50
69
|
"vue-tsc": "^0.0.24"
|
|
51
70
|
},
|
|
52
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "d9f6ca25a0a6efba35d183e643a306e164b74af7"
|
|
53
72
|
}
|
package/src/Form.vue
CHANGED
|
@@ -86,7 +86,7 @@ export default defineComponent({
|
|
|
86
86
|
},
|
|
87
87
|
|
|
88
88
|
size: {
|
|
89
|
-
type: String
|
|
89
|
+
type: String as PropType<'small' | 'default' | 'large'>,
|
|
90
90
|
},
|
|
91
91
|
|
|
92
92
|
inline: {
|
|
@@ -177,7 +177,7 @@ export default defineComponent({
|
|
|
177
177
|
submitForm: async (native?: boolean): Promise<any> => {
|
|
178
178
|
try {
|
|
179
179
|
await elForm.value?.validate();
|
|
180
|
-
return native ? values.value : cloneDeep(values.value);
|
|
180
|
+
return native ? values.value : cloneDeep(toRaw(values.value));
|
|
181
181
|
} catch (invalidFields: any) {
|
|
182
182
|
const error: string[] = [];
|
|
183
183
|
|
package/src/FormDialog.vue
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-col v-show="display && config.type !== 'hidden'" :span="span">
|
|
3
|
+
<m-form-container
|
|
4
|
+
:model="model"
|
|
5
|
+
:config="config"
|
|
6
|
+
:prop="prop"
|
|
7
|
+
:label-width="config.labelWidth || labelWidth"
|
|
8
|
+
:expand-more="expandMore"
|
|
9
|
+
:size="size"
|
|
10
|
+
@change="changeHandler"
|
|
11
|
+
></m-form-container>
|
|
12
|
+
</el-col>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts">
|
|
16
|
+
import { computed, defineComponent, inject, PropType } from 'vue';
|
|
17
|
+
|
|
18
|
+
import { ChildConfig, FormState } from '../schema';
|
|
19
|
+
import { display as displayFunction } from '../utils/form';
|
|
20
|
+
|
|
21
|
+
export default defineComponent({
|
|
22
|
+
props: {
|
|
23
|
+
labelWidth: String,
|
|
24
|
+
expandMore: Boolean,
|
|
25
|
+
span: Number,
|
|
26
|
+
|
|
27
|
+
model: {
|
|
28
|
+
type: Object,
|
|
29
|
+
default: () => ({}),
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
config: {
|
|
33
|
+
type: Object as PropType<ChildConfig>,
|
|
34
|
+
default: () => ({}),
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
prop: String,
|
|
38
|
+
|
|
39
|
+
size: String,
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
emits: ['change'],
|
|
43
|
+
|
|
44
|
+
setup(props, { emit }) {
|
|
45
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
46
|
+
|
|
47
|
+
const changeHandler = () => emit('change', props.model);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
mForm,
|
|
51
|
+
display: computed(() => displayFunction(mForm, props.config.display, props)),
|
|
52
|
+
changeHandler,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
</script>
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
|
+
v-if="config"
|
|
4
|
+
:style="config.tip ? 'display: flex;align-items: baseline;' : ''"
|
|
5
|
+
:class="config.className"
|
|
6
|
+
class="m-form-container"
|
|
7
|
+
>
|
|
3
8
|
<m-fields-hidden
|
|
4
9
|
v-if="type === 'hidden'"
|
|
5
10
|
:model="model"
|
|
@@ -20,15 +25,16 @@
|
|
|
20
25
|
:prop="itemProp"
|
|
21
26
|
:step-active="stepActive"
|
|
22
27
|
:expand-more="expand"
|
|
23
|
-
:label-width="
|
|
28
|
+
:label-width="itemLabelWidth"
|
|
24
29
|
@change="onChangeHandler"
|
|
25
30
|
></component>
|
|
26
31
|
|
|
27
32
|
<template v-else-if="type && display">
|
|
28
33
|
<el-form-item
|
|
29
34
|
:style="config.tip ? 'flex: 1' : ''"
|
|
35
|
+
:class="{ hidden: itemLabelWidth === 0 || !config.text }"
|
|
30
36
|
:prop="itemProp"
|
|
31
|
-
:label-width="
|
|
37
|
+
:label-width="itemLabelWidth"
|
|
32
38
|
:rules="rule"
|
|
33
39
|
>
|
|
34
40
|
<template #label><span v-html="type === 'checkbox' ? '' : config.text"></span></template>
|
|
@@ -65,8 +71,8 @@
|
|
|
65
71
|
<div v-if="extra" v-html="extra" class="m-form-tip"></div>
|
|
66
72
|
</el-form-item>
|
|
67
73
|
|
|
68
|
-
<el-tooltip v-if="config.tip" placement="
|
|
69
|
-
<
|
|
74
|
+
<el-tooltip v-if="config.tip" placement="left">
|
|
75
|
+
<el-icon style="line-height: 40px; margin-left: 5px"><warning-filled /></el-icon>
|
|
70
76
|
<template #content>
|
|
71
77
|
<div v-html="config.tip"></div>
|
|
72
78
|
</template>
|
|
@@ -83,7 +89,7 @@
|
|
|
83
89
|
:size="size"
|
|
84
90
|
:step-active="stepActive"
|
|
85
91
|
:expand-more="expand"
|
|
86
|
-
:label-width="
|
|
92
|
+
:label-width="itemLabelWidth"
|
|
87
93
|
:prop="itemProp"
|
|
88
94
|
@change="onChangeHandler"
|
|
89
95
|
></m-form-container>
|
|
@@ -91,13 +97,14 @@
|
|
|
91
97
|
</template>
|
|
92
98
|
|
|
93
99
|
<div style="text-align: center" v-if="config.expand && type !== 'fieldset'">
|
|
94
|
-
<el-button
|
|
100
|
+
<el-button text @click="expandHandler">{{ expand ? '收起配置' : '展开更多配置' }}</el-button>
|
|
95
101
|
</div>
|
|
96
102
|
</div>
|
|
97
103
|
</template>
|
|
98
104
|
|
|
99
105
|
<script lang="ts">
|
|
100
106
|
import { computed, defineComponent, inject, PropType, ref, resolveComponent, watchEffect } from 'vue';
|
|
107
|
+
import { WarningFilled } from '@element-plus/icons';
|
|
101
108
|
|
|
102
109
|
import { ChildConfig, ContainerCommonConfig, FormState, FormValue } from '../schema';
|
|
103
110
|
import { display as displayFunction, filterFunction, getRules } from '../utils/form';
|
|
@@ -105,6 +112,8 @@ import { display as displayFunction, filterFunction, getRules } from '../utils/f
|
|
|
105
112
|
export default defineComponent({
|
|
106
113
|
name: 'm-form-container',
|
|
107
114
|
|
|
115
|
+
components: { WarningFilled },
|
|
116
|
+
|
|
108
117
|
props: {
|
|
109
118
|
labelWidth: String,
|
|
110
119
|
expandMore: Boolean,
|
|
@@ -180,6 +189,8 @@ export default defineComponent({
|
|
|
180
189
|
return displayFunction(mForm, props.config.display, props);
|
|
181
190
|
});
|
|
182
191
|
|
|
192
|
+
const itemLabelWidth = computed(() => props.config.labelWidth || props.labelWidth);
|
|
193
|
+
|
|
183
194
|
watchEffect(() => {
|
|
184
195
|
expand.value = props.expandMore;
|
|
185
196
|
});
|
|
@@ -255,6 +266,7 @@ export default defineComponent({
|
|
|
255
266
|
itemProp,
|
|
256
267
|
items,
|
|
257
268
|
display,
|
|
269
|
+
itemLabelWidth,
|
|
258
270
|
tagName,
|
|
259
271
|
rule,
|
|
260
272
|
tooltip,
|
|
@@ -5,21 +5,21 @@
|
|
|
5
5
|
><caret-bottom v-if="expand" /><caret-right v-else
|
|
6
6
|
/></el-icon>
|
|
7
7
|
|
|
8
|
-
<el-button
|
|
8
|
+
<el-button text @click="expandHandler">{{ title }}</el-button>
|
|
9
9
|
|
|
10
10
|
<el-button
|
|
11
11
|
v-show="showDelete(parseInt(String(index)))"
|
|
12
|
-
|
|
12
|
+
text
|
|
13
13
|
:icon="Delete"
|
|
14
14
|
style="color: #f56c6c"
|
|
15
15
|
@click="removeHandler"
|
|
16
16
|
></el-button>
|
|
17
17
|
|
|
18
18
|
<template v-if="movable()">
|
|
19
|
-
<el-button v-show="index !== 0"
|
|
19
|
+
<el-button v-show="index !== 0" text size="small" @click="changeOrder(-1)"
|
|
20
20
|
>上移<el-icon><CaretRight /></el-icon
|
|
21
21
|
></el-button>
|
|
22
|
-
<el-button v-show="index !== length - 1"
|
|
22
|
+
<el-button v-show="index !== length - 1" text size="small" @click="changeOrder(1)"
|
|
23
23
|
>下移<el-icon><CaretBottom /></el-icon
|
|
24
24
|
></el-button>
|
|
25
25
|
</template>
|
package/src/containers/Row.vue
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<el-row :gutter="10">
|
|
3
|
-
<
|
|
3
|
+
<Col
|
|
4
4
|
v-for="(col, index) in config.items"
|
|
5
|
-
:style="!display(col) || col.type === 'hidden' ? 'display: none' : ''"
|
|
6
5
|
:key="col[mForm?.keyProp || '__key'] ?? index"
|
|
7
6
|
:span="col.span || config.span || 24 / config.items.length"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@change="changeHandler"
|
|
17
|
-
></m-form-container>
|
|
18
|
-
</el-col>
|
|
7
|
+
:config="col"
|
|
8
|
+
:labelWidth="config.labelWidth || labelWidth"
|
|
9
|
+
:expandMore="expandMore"
|
|
10
|
+
:model="name ? model[name] : model"
|
|
11
|
+
:prop="prop"
|
|
12
|
+
:size="size"
|
|
13
|
+
@change="changeHandler"
|
|
14
|
+
/>
|
|
19
15
|
</el-row>
|
|
20
16
|
</template>
|
|
21
17
|
|
|
@@ -23,11 +19,14 @@
|
|
|
23
19
|
import { defineComponent, inject, PropType } from 'vue';
|
|
24
20
|
|
|
25
21
|
import { FormState, RowConfig } from '../schema';
|
|
26
|
-
|
|
22
|
+
|
|
23
|
+
import Col from './Col.vue';
|
|
27
24
|
|
|
28
25
|
export default defineComponent({
|
|
29
26
|
name: 'm-form-row',
|
|
30
27
|
|
|
28
|
+
components: { Col },
|
|
29
|
+
|
|
31
30
|
props: {
|
|
32
31
|
labelWidth: String,
|
|
33
32
|
expandMore: Boolean,
|
|
@@ -58,9 +57,6 @@ export default defineComponent({
|
|
|
58
57
|
|
|
59
58
|
return {
|
|
60
59
|
mForm,
|
|
61
|
-
display(config: any) {
|
|
62
|
-
return displayFunction(mForm, config.display, props);
|
|
63
|
-
},
|
|
64
60
|
changeHandler,
|
|
65
61
|
};
|
|
66
62
|
},
|
package/src/containers/Table.vue
CHANGED
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
<template v-slot="scope">
|
|
26
26
|
<el-button
|
|
27
27
|
v-show="showDelete(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
type="danger"
|
|
29
|
+
text
|
|
30
30
|
:icon="Delete"
|
|
31
31
|
@click="removeHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
32
32
|
></el-button>
|
|
@@ -43,8 +43,9 @@
|
|
|
43
43
|
<el-button
|
|
44
44
|
plain
|
|
45
45
|
size="small"
|
|
46
|
+
type="primary"
|
|
46
47
|
:icon="ArrowUp"
|
|
47
|
-
|
|
48
|
+
text
|
|
48
49
|
@click="upHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
49
50
|
@dblclick="topHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
50
51
|
></el-button>
|
|
@@ -57,8 +58,9 @@
|
|
|
57
58
|
<el-button
|
|
58
59
|
plain
|
|
59
60
|
size="small"
|
|
61
|
+
type="primary"
|
|
60
62
|
:icon="ArrowDown"
|
|
61
|
-
|
|
63
|
+
text
|
|
62
64
|
@click="downHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
63
65
|
@dblclick="bottomHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
64
66
|
></el-button>
|
|
@@ -107,10 +109,16 @@
|
|
|
107
109
|
</el-tooltip>
|
|
108
110
|
<slot></slot>
|
|
109
111
|
<el-button v-if="addable" size="small" type="primary" plain @click="newHandler()">添加</el-button>
|
|
110
|
-
<el-button :icon="Grid" size="small" @click="toggleMode" v-if="enableToggleMode && !isFullscreen"
|
|
112
|
+
<el-button :icon="Grid" size="small" type="primary" @click="toggleMode" v-if="enableToggleMode && !isFullscreen"
|
|
111
113
|
>展开配置</el-button
|
|
112
114
|
>
|
|
113
|
-
<el-button
|
|
115
|
+
<el-button
|
|
116
|
+
:icon="FullScreen"
|
|
117
|
+
size="small"
|
|
118
|
+
type="primary"
|
|
119
|
+
@click="toggleFullscreen"
|
|
120
|
+
v-if="config.enableFullscreen !== false"
|
|
121
|
+
>
|
|
114
122
|
{{ isFullscreen ? '退出全屏' : '全屏编辑' }}
|
|
115
123
|
</el-button>
|
|
116
124
|
<el-upload
|
package/src/fields/Checkbox.vue
CHANGED
|
@@ -43,7 +43,7 @@ export default defineComponent({
|
|
|
43
43
|
return props.config.activeValue;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
return
|
|
46
|
+
return undefined;
|
|
47
47
|
}),
|
|
48
48
|
|
|
49
49
|
inactiveValue: computed(() => {
|
|
@@ -55,7 +55,7 @@ export default defineComponent({
|
|
|
55
55
|
return props.config.inactiveValue;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
return
|
|
58
|
+
return undefined;
|
|
59
59
|
}),
|
|
60
60
|
|
|
61
61
|
changeHandler(value: number | boolean) {
|
package/src/fields/Link.vue
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<a v-if="config.href && !disabled" target="_blank" :href="href" :style="config.css || {}">{{ displayText }}</a>
|
|
3
3
|
<span v-else-if="config.href && disabled" :style="config.disabledCss || {}">{{ displayText }}</span>
|
|
4
4
|
<div v-else class="m-fields-link">
|
|
5
|
-
<el-button type="
|
|
5
|
+
<el-button text type="primary" @click="editHandler">点击编辑</el-button>
|
|
6
6
|
<m-form-dialog
|
|
7
7
|
ref="editor"
|
|
8
8
|
:title="config.formTitle || '编辑扩展配置'"
|
package/src/fields/Select.vue
CHANGED
|
@@ -15,20 +15,15 @@
|
|
|
15
15
|
:value-key="config.valueKey || 'value'"
|
|
16
16
|
:allow-create="config.allowCreate"
|
|
17
17
|
:disabled="disabled"
|
|
18
|
-
:remote-method="remoteMethod"
|
|
18
|
+
:remote-method="config.remote && remoteMethod"
|
|
19
19
|
@change="changeHandler"
|
|
20
20
|
@visible-change="visibleHandler"
|
|
21
21
|
>
|
|
22
22
|
<template v-if="config.group">
|
|
23
|
-
<el-option-group
|
|
24
|
-
v-for="(group, index) in options"
|
|
25
|
-
:key="group.label + index"
|
|
26
|
-
:label="group.label"
|
|
27
|
-
:disabled="group.disabled"
|
|
28
|
-
>
|
|
23
|
+
<el-option-group v-for="(group, index) in options" :key="index" :label="group.label" :disabled="group.disabled">
|
|
29
24
|
<el-option
|
|
30
25
|
v-for="(item, index) in group.options"
|
|
31
|
-
:key="
|
|
26
|
+
:key="index"
|
|
32
27
|
:label="item.label"
|
|
33
28
|
:value="item.value"
|
|
34
29
|
:disabled="item.disabled"
|
|
@@ -289,6 +284,7 @@ export default defineComponent({
|
|
|
289
284
|
Promise.resolve(
|
|
290
285
|
props.config.options(mForm, {
|
|
291
286
|
model: props.model,
|
|
287
|
+
prop: props.prop,
|
|
292
288
|
formValues: mForm?.values,
|
|
293
289
|
formValue: mForm?.values,
|
|
294
290
|
}),
|
|
@@ -349,12 +345,12 @@ export default defineComponent({
|
|
|
349
345
|
moreLoadingVisible,
|
|
350
346
|
popperClass: mForm?.popperClass,
|
|
351
347
|
|
|
348
|
+
getOptions,
|
|
349
|
+
|
|
352
350
|
getRequestFuc() {
|
|
353
351
|
return getConfig('request');
|
|
354
352
|
},
|
|
355
353
|
|
|
356
|
-
async getInitOption() {},
|
|
357
|
-
|
|
358
354
|
changeHandler(value: any) {
|
|
359
355
|
emit('change', value);
|
|
360
356
|
},
|
|
@@ -372,11 +368,6 @@ export default defineComponent({
|
|
|
372
368
|
}
|
|
373
369
|
},
|
|
374
370
|
|
|
375
|
-
async editAfterAction() {
|
|
376
|
-
pgIndex.value = 0;
|
|
377
|
-
options.value = await getOptions();
|
|
378
|
-
},
|
|
379
|
-
|
|
380
371
|
async remoteMethod(q: string) {
|
|
381
372
|
if (!localOptions.value.length) {
|
|
382
373
|
query.value = q;
|
package/src/fields/Text.vue
CHANGED
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
<el-button
|
|
15
15
|
v-if="typeof config.append === 'object' && config.append.type === 'button'"
|
|
16
16
|
style="color: #409eff"
|
|
17
|
-
|
|
17
|
+
:size="size"
|
|
18
|
+
@click.prevent="buttonClickHandler"
|
|
18
19
|
>
|
|
19
20
|
{{ config.append.text }}
|
|
20
21
|
</el-button>
|
|
@@ -43,6 +44,8 @@ export default defineComponent({
|
|
|
43
44
|
emits: ['change', 'input'],
|
|
44
45
|
|
|
45
46
|
setup(props, { emit }) {
|
|
47
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
48
|
+
|
|
46
49
|
useAddField(props.prop);
|
|
47
50
|
|
|
48
51
|
const modelName = computed(() => props.name || props.config.name || '');
|
|
@@ -54,14 +57,11 @@ export default defineComponent({
|
|
|
54
57
|
},
|
|
55
58
|
|
|
56
59
|
inputHandler(v: string | number) {
|
|
57
|
-
const mForm = inject<FormState | undefined>('mForm');
|
|
58
60
|
emit('input', v);
|
|
59
61
|
mForm?.$emit('field-input', props.prop, v);
|
|
60
62
|
},
|
|
61
63
|
|
|
62
64
|
buttonClickHandler() {
|
|
63
|
-
const mForm = inject<FormState | undefined>('mForm');
|
|
64
|
-
|
|
65
65
|
if (typeof props.config.append === 'string') return;
|
|
66
66
|
|
|
67
67
|
if (props.config.append?.handler) {
|
package/src/fields/Textarea.vue
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
</el-input>
|
|
14
|
-
</div>
|
|
2
|
+
<el-input
|
|
3
|
+
v-model="model[name]"
|
|
4
|
+
type="textarea"
|
|
5
|
+
:size="size"
|
|
6
|
+
clearable
|
|
7
|
+
:placeholder="config.placeholder"
|
|
8
|
+
:disabled="disabled"
|
|
9
|
+
@change="changeHandler"
|
|
10
|
+
@input="inputHandler"
|
|
11
|
+
>
|
|
12
|
+
</el-input>
|
|
15
13
|
</template>
|
|
16
14
|
|
|
17
15
|
<script lang="ts">
|
package/src/schema.ts
CHANGED
package/src/theme/form.scss
CHANGED
|
@@ -2,29 +2,36 @@
|
|
|
2
2
|
.fade-leave-active {
|
|
3
3
|
transition: opacity 0.5s;
|
|
4
4
|
}
|
|
5
|
+
|
|
5
6
|
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
|
|
6
7
|
opacity: 0;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
.m-form
|
|
10
|
-
.m-form-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
.m-form {
|
|
11
|
+
.m-form-tip {
|
|
12
|
+
color: rgba(0, 0, 0, 0.45);
|
|
13
|
+
font-size: 12px;
|
|
14
|
+
transition: color 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
|
|
15
|
+
}
|
|
14
16
|
|
|
15
|
-
.m-form
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
17
|
+
.m-form-schematic {
|
|
18
|
+
max-width: 50%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
}
|
|
20
21
|
|
|
21
|
-
.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
22
|
+
.el-table {
|
|
23
|
+
.cell > div.m-form-container {
|
|
24
|
+
display: block;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.el-tabs {
|
|
29
|
+
margin-bottom: 10px;
|
|
30
|
+
}
|
|
25
31
|
|
|
26
|
-
.el-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
.el-form-item.hidden {
|
|
33
|
+
.el-form-item__label {
|
|
34
|
+
display: none;
|
|
35
|
+
}
|
|
29
36
|
}
|
|
30
37
|
}
|
package/src/utils/form.ts
CHANGED
|
@@ -122,7 +122,11 @@ const initValueItem = function (
|
|
|
122
122
|
// 这种情况比较多,提前结束
|
|
123
123
|
if (name && !items && typeof initValue[name] !== 'undefined') {
|
|
124
124
|
if (typeof value[name] === 'undefined') {
|
|
125
|
-
|
|
125
|
+
if (type === 'number') {
|
|
126
|
+
value[name] = Number(initValue[name]);
|
|
127
|
+
} else {
|
|
128
|
+
value[name] = typeof initValue[name] === 'object' ? cloneDeep(initValue[name]) : initValue[name];
|
|
129
|
+
}
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
return value;
|
package/tsconfig.json
DELETED
package/vite.config.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { defineConfig } from 'vite';
|
|
20
|
-
|
|
21
|
-
import { getBaseConfig } from '../vite-config';
|
|
22
|
-
|
|
23
|
-
import pkg from './package.json';
|
|
24
|
-
|
|
25
|
-
const deps = Object.keys(pkg.dependencies);
|
|
26
|
-
|
|
27
|
-
export default defineConfig(getBaseConfig(deps, 'TMagicForm'));
|