@tmagic/form 1.0.0-beta.13 → 1.0.0-beta.16

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.
Files changed (70) hide show
  1. package/coverage/clover.xml +274 -261
  2. package/coverage/coverage-final.json +37 -36
  3. package/coverage/lcov-report/index.html +18 -18
  4. package/coverage/lcov-report/src/Form.vue.html +2 -2
  5. package/coverage/lcov-report/src/FormDialog.vue.html +1 -1
  6. package/coverage/lcov-report/src/containers/Col.vue.html +253 -0
  7. package/coverage/lcov-report/src/containers/Container.vue.html +28 -16
  8. package/coverage/lcov-report/src/containers/Fieldset.vue.html +1 -1
  9. package/coverage/lcov-report/src/containers/GroupList.vue.html +1 -1
  10. package/coverage/lcov-report/src/containers/GroupListItem.vue.html +5 -5
  11. package/coverage/lcov-report/src/containers/Panel.vue.html +1 -1
  12. package/coverage/lcov-report/src/containers/Row.vue.html +22 -34
  13. package/coverage/lcov-report/src/containers/Step.vue.html +1 -1
  14. package/coverage/lcov-report/src/containers/Table.vue.html +32 -8
  15. package/coverage/lcov-report/src/containers/Tabs.vue.html +1 -1
  16. package/coverage/lcov-report/src/containers/index.html +41 -26
  17. package/coverage/lcov-report/src/fields/Cascader.vue.html +1 -1
  18. package/coverage/lcov-report/src/fields/Checkbox.vue.html +3 -3
  19. package/coverage/lcov-report/src/fields/CheckboxGroup.vue.html +1 -1
  20. package/coverage/lcov-report/src/fields/ColorPicker.vue.html +1 -1
  21. package/coverage/lcov-report/src/fields/Date.vue.html +1 -1
  22. package/coverage/lcov-report/src/fields/DateTime.vue.html +1 -1
  23. package/coverage/lcov-report/src/fields/Daterange.vue.html +1 -1
  24. package/coverage/lcov-report/src/fields/Display.vue.html +1 -1
  25. package/coverage/lcov-report/src/fields/DynamicField.vue.html +1 -1
  26. package/coverage/lcov-report/src/fields/Hidden.vue.html +1 -1
  27. package/coverage/lcov-report/src/fields/Link.vue.html +2 -2
  28. package/coverage/lcov-report/src/fields/Number.vue.html +1 -1
  29. package/coverage/lcov-report/src/fields/RadioGroup.vue.html +1 -1
  30. package/coverage/lcov-report/src/fields/Select.vue.html +1 -1
  31. package/coverage/lcov-report/src/fields/Switch.vue.html +1 -1
  32. package/coverage/lcov-report/src/fields/Text.vue.html +1 -1
  33. package/coverage/lcov-report/src/fields/Textarea.vue.html +13 -19
  34. package/coverage/lcov-report/src/fields/Time.vue.html +1 -1
  35. package/coverage/lcov-report/src/fields/index.html +1 -1
  36. package/coverage/lcov-report/src/index.html +1 -1
  37. package/coverage/lcov-report/src/index.ts.html +1 -1
  38. package/coverage/lcov-report/src/theme/index.html +1 -1
  39. package/coverage/lcov-report/src/theme/index.scss.html +1 -1
  40. package/coverage/lcov-report/src/utils/config.ts.html +1 -1
  41. package/coverage/lcov-report/src/utils/createForm.ts.html +1 -1
  42. package/coverage/lcov-report/src/utils/fieldProps.ts.html +1 -1
  43. package/coverage/lcov-report/src/utils/form.ts.html +1 -1
  44. package/coverage/lcov-report/src/utils/index.html +1 -1
  45. package/coverage/lcov-report/src/utils/useAddField.ts.html +1 -1
  46. package/coverage/lcov.info +528 -497
  47. package/dist/style.css +7 -9
  48. package/dist/tmagic-form.es.js +143 -99
  49. package/dist/tmagic-form.es.js.map +1 -1
  50. package/dist/tmagic-form.umd.js +143 -99
  51. package/dist/tmagic-form.umd.js.map +1 -1
  52. package/dist/types/src/Form.vue.d.ts +362 -0
  53. package/dist/types/src/FormDialog.vue.d.ts +757 -0
  54. package/dist/types/src/containers/Col.vue.d.ts +42 -0
  55. package/dist/types/src/containers/Container.vue.d.ts +1 -0
  56. package/dist/types/src/containers/Row.vue.d.ts +0 -1
  57. package/dist/types/src/containers/Table.vue.d.ts +2601 -0
  58. package/dist/types/src/fields/Checkbox.vue.d.ts +2 -2
  59. package/dist/types/src/fields/Link.vue.d.ts +1596 -0
  60. package/package.json +10 -6
  61. package/src/Form.vue +1 -1
  62. package/src/containers/Col.vue +56 -0
  63. package/src/containers/Container.vue +9 -5
  64. package/src/containers/GroupListItem.vue +4 -4
  65. package/src/containers/Row.vue +13 -17
  66. package/src/containers/Table.vue +14 -6
  67. package/src/fields/Checkbox.vue +2 -2
  68. package/src/fields/Link.vue +1 -1
  69. package/src/fields/Textarea.vue +11 -13
  70. package/src/theme/form.scss +24 -17
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
- "version": "1.0.0-beta.13",
2
+ "version": "1.0.0-beta.16",
3
3
  "name": "@tmagic/form",
4
- "sideEffects": false,
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,7 +17,8 @@
14
17
  "./dist/style.css": {
15
18
  "import": "./dist/style.css",
16
19
  "require": "./dist/style.css"
17
- }
20
+ },
21
+ "./*": "./*"
18
22
  },
19
23
  "license": "Apache-2.0",
20
24
  "scripts": {
@@ -31,8 +35,8 @@
31
35
  },
32
36
  "dependencies": {
33
37
  "@element-plus/icons": "0.0.11",
34
- "@tmagic/utils": "^1.0.0-beta.13",
35
- "element-plus": "^2.1.7",
38
+ "@tmagic/utils": "^1.0.0-beta.16",
39
+ "element-plus": "^2.2.0",
36
40
  "lodash-es": "^4.17.21",
37
41
  "moment": "^2.29.2",
38
42
  "sortablejs": "^1.14.0",
@@ -58,5 +62,5 @@
58
62
  "vite-plugin-dts": "^0.9.6",
59
63
  "vue-tsc": "^0.0.24"
60
64
  },
61
- "gitHead": "ca2b203614cbdaff580e5cb6f35630f50b827451"
65
+ "gitHead": "2aebfb1b8ceb5c8e26dfb59b643ed9f4f4b7bd15"
62
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>
@@ -25,15 +25,16 @@
25
25
  :prop="itemProp"
26
26
  :step-active="stepActive"
27
27
  :expand-more="expand"
28
- :label-width="config.labelWidth || labelWidth"
28
+ :label-width="itemLabelWidth"
29
29
  @change="onChangeHandler"
30
30
  ></component>
31
31
 
32
32
  <template v-else-if="type && display">
33
33
  <el-form-item
34
34
  :style="config.tip ? 'flex: 1' : ''"
35
+ :class="{ hidden: itemLabelWidth === 0 || !config.text }"
35
36
  :prop="itemProp"
36
- :label-width="config.text ? config.labelWidth || labelWidth : '0'"
37
+ :label-width="itemLabelWidth"
37
38
  :rules="rule"
38
39
  >
39
40
  <template #label><span v-html="type === 'checkbox' ? '' : config.text"></span></template>
@@ -70,7 +71,7 @@
70
71
  <div v-if="extra" v-html="extra" class="m-form-tip"></div>
71
72
  </el-form-item>
72
73
 
73
- <el-tooltip v-if="config.tip" placement="top">
74
+ <el-tooltip v-if="config.tip" placement="left">
74
75
  <el-icon style="line-height: 40px; margin-left: 5px"><warning-filled /></el-icon>
75
76
  <template #content>
76
77
  <div v-html="config.tip"></div>
@@ -88,7 +89,7 @@
88
89
  :size="size"
89
90
  :step-active="stepActive"
90
91
  :expand-more="expand"
91
- :label-width="config.labelWidth || labelWidth"
92
+ :label-width="itemLabelWidth"
92
93
  :prop="itemProp"
93
94
  @change="onChangeHandler"
94
95
  ></m-form-container>
@@ -96,7 +97,7 @@
96
97
  </template>
97
98
 
98
99
  <div style="text-align: center" v-if="config.expand && type !== 'fieldset'">
99
- <el-button type="text" @click="expandHandler">{{ expand ? '收起配置' : '展开更多配置' }}</el-button>
100
+ <el-button text @click="expandHandler">{{ expand ? '收起配置' : '展开更多配置' }}</el-button>
100
101
  </div>
101
102
  </div>
102
103
  </template>
@@ -188,6 +189,8 @@ export default defineComponent({
188
189
  return displayFunction(mForm, props.config.display, props);
189
190
  });
190
191
 
192
+ const itemLabelWidth = computed(() => props.config.labelWidth || props.labelWidth);
193
+
191
194
  watchEffect(() => {
192
195
  expand.value = props.expandMore;
193
196
  });
@@ -263,6 +266,7 @@ export default defineComponent({
263
266
  itemProp,
264
267
  items,
265
268
  display,
269
+ itemLabelWidth,
266
270
  tagName,
267
271
  rule,
268
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 type="text" @click="expandHandler">{{ title }}</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
- type="text"
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" type="text" size="small" @click="changeOrder(-1)"
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" type="text" size="small" @click="changeOrder(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>
@@ -1,21 +1,17 @@
1
1
  <template>
2
2
  <el-row :gutter="10">
3
- <el-col
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
- <m-form-container
10
- :model="name ? model[name] : model"
11
- :config="col"
12
- :prop="prop"
13
- :label-width="config.labelWidth || labelWidth"
14
- :expand-more="expandMore"
15
- :size="size"
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
- import { display as displayFunction } from '../utils/form';
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
  },
@@ -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
- style="color: #f56c6c"
29
- type="text"
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
- type="text"
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
- type="text"
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> &nbsp;
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 :icon="FullScreen" size="small" @click="toggleFullscreen" v-if="config.enableFullscreen !== false">
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
@@ -43,7 +43,7 @@ export default defineComponent({
43
43
  return props.config.activeValue;
44
44
  }
45
45
 
46
- return 'true';
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 'false';
58
+ return undefined;
59
59
  }),
60
60
 
61
61
  changeHandler(value: number | boolean) {
@@ -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="text" @click="editHandler">点击编辑</el-button>
5
+ <el-button text type="primary" @click="editHandler">点击编辑</el-button>
6
6
  <m-form-dialog
7
7
  ref="editor"
8
8
  :title="config.formTitle || '编辑扩展配置'"
@@ -1,17 +1,15 @@
1
1
  <template>
2
- <div v-if="model">
3
- <el-input
4
- v-model="model[name]"
5
- type="textarea"
6
- :size="size"
7
- clearable
8
- :placeholder="config.placeholder"
9
- :disabled="disabled"
10
- @change="changeHandler"
11
- @input="inputHandler"
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">
@@ -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-panel.el-card .el-card__body {
11
- color: #333;
12
- background-color: #fff;
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 .m-form-tip {
16
- color: rgba(0, 0, 0, 0.45);
17
- font-size: 12px;
18
- transition: color 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
19
- }
17
+ .m-form-schematic {
18
+ max-width: 50%;
19
+ height: 100%;
20
+ }
20
21
 
21
- .m-form .m-form-schematic {
22
- max-width: 50%;
23
- height: 100%;
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-table {
27
- .cell > div.m-form-container {
28
- display: block;
32
+ .el-form-item.hidden {
33
+ .el-form-item__label {
34
+ display: none;
35
+ }
29
36
  }
30
37
  }