@tmagic/form 1.0.0-beta.12 → 1.0.0-beta.15
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/coverage/clover.xml +1361 -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 +913 -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 +1963 -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 +1267 -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 +3060 -0
- package/dist/style.css +2 -2
- package/dist/tmagic-form.es.js +131 -95
- package/dist/tmagic-form.es.js.map +1 -1
- package/dist/tmagic-form.umd.js +132 -97
- 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/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/package.json +22 -9
- package/src/Form.vue +1 -1
- package/src/containers/Col.vue +56 -0
- package/src/containers/Container.vue +2 -2
- package/src/containers/GroupListItem.vue +4 -4
- package/src/containers/Row.vue +13 -17
- package/src/containers/Table.vue +4 -4
- package/src/fields/Checkbox.vue +2 -2
- package/src/fields/Link.vue +1 -1
- package/src/fields/Textarea.vue +11 -13
- 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-beta.
|
|
2
|
+
"version": "1.0.0-beta.15",
|
|
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,32 @@
|
|
|
28
35
|
},
|
|
29
36
|
"dependencies": {
|
|
30
37
|
"@element-plus/icons": "0.0.11",
|
|
31
|
-
"@tmagic/utils": "^1.0.0-beta.
|
|
32
|
-
"element-plus": "^2.
|
|
38
|
+
"@tmagic/utils": "^1.0.0-beta.15",
|
|
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
|
},
|
|
38
45
|
"devDependencies": {
|
|
46
|
+
"@types/jest": "^26.0.23",
|
|
39
47
|
"@types/lodash-es": "^4.17.4",
|
|
40
48
|
"@types/node": "^15.12.4",
|
|
41
49
|
"@types/sortablejs": "^1.10.7",
|
|
42
50
|
"@vitejs/plugin-vue": "^1.2.3",
|
|
43
51
|
"@vitejs/plugin-vue-jsx": "^1.1.6",
|
|
44
52
|
"@vue/compiler-sfc": "^3.2.0",
|
|
45
|
-
"@vue/test-utils": "^2.0.0-rc.
|
|
53
|
+
"@vue/test-utils": "^2.0.0-rc.20",
|
|
54
|
+
"@vue/vue3-jest": "^27.0.0-alpha.4",
|
|
55
|
+
"jest": "^27.5.1",
|
|
56
|
+
"jest-serializer-vue": "^2.0.2",
|
|
57
|
+
"jest-transform-stub": "^2.0.0",
|
|
46
58
|
"sass": "^1.35.1",
|
|
59
|
+
"ts-jest": "^27.1.4",
|
|
47
60
|
"typescript": "^4.3.4",
|
|
48
61
|
"vite": "^2.3.7",
|
|
49
62
|
"vite-plugin-dts": "^0.9.6",
|
|
50
63
|
"vue-tsc": "^0.0.24"
|
|
51
64
|
},
|
|
52
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "340e4e3018c8699d6cf49001e0c367996ecea857"
|
|
53
66
|
}
|
package/src/Form.vue
CHANGED
|
@@ -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
|
|
|
@@ -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>
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
<div v-if="extra" v-html="extra" class="m-form-tip"></div>
|
|
71
71
|
</el-form-item>
|
|
72
72
|
|
|
73
|
-
<el-tooltip v-if="config.tip" placement="
|
|
73
|
+
<el-tooltip v-if="config.tip" placement="left">
|
|
74
74
|
<el-icon style="line-height: 40px; margin-left: 5px"><warning-filled /></el-icon>
|
|
75
75
|
<template #content>
|
|
76
76
|
<div v-html="config.tip"></div>
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
</template>
|
|
97
97
|
|
|
98
98
|
<div style="text-align: center" v-if="config.expand && type !== 'fieldset'">
|
|
99
|
-
<el-button
|
|
99
|
+
<el-button text @click="expandHandler">{{ expand ? '收起配置' : '展开更多配置' }}</el-button>
|
|
100
100
|
</div>
|
|
101
101
|
</div>
|
|
102
102
|
</template>
|
|
@@ -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>
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
plain
|
|
45
45
|
size="small"
|
|
46
46
|
:icon="ArrowUp"
|
|
47
|
-
|
|
47
|
+
text
|
|
48
48
|
@click="upHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
49
49
|
@dblclick="topHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
50
50
|
></el-button>
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
plain
|
|
59
59
|
size="small"
|
|
60
60
|
:icon="ArrowDown"
|
|
61
|
-
|
|
61
|
+
text
|
|
62
62
|
@click="downHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
63
63
|
@dblclick="bottomHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
64
64
|
></el-button>
|
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
|
|
5
|
+
<el-button text @click="editHandler">点击编辑</el-button>
|
|
6
6
|
<m-form-dialog
|
|
7
7
|
ref="editor"
|
|
8
8
|
:title="config.formTitle || '编辑扩展配置'"
|
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/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'));
|