@tmagic/form 1.2.0-beta.2 → 1.2.0-beta.21

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 (83) hide show
  1. package/dist/style.css +1 -1
  2. package/dist/tmagic-form.js +3673 -0
  3. package/dist/tmagic-form.js.map +1 -0
  4. package/dist/tmagic-form.umd.cjs +3713 -0
  5. package/dist/tmagic-form.umd.cjs.map +1 -0
  6. package/package.json +10 -9
  7. package/src/Form.vue +124 -159
  8. package/src/FormDialog.vue +108 -126
  9. package/src/containers/Col.vue +24 -38
  10. package/src/containers/Container.vue +143 -171
  11. package/src/containers/Fieldset.vue +15 -8
  12. package/src/containers/GroupList.vue +86 -116
  13. package/src/containers/GroupListItem.vue +91 -125
  14. package/src/containers/Panel.vue +29 -49
  15. package/src/containers/Row.vue +20 -40
  16. package/src/containers/Step.vue +38 -48
  17. package/src/containers/Table.vue +466 -481
  18. package/src/containers/Tabs.vue +94 -118
  19. package/src/fields/Cascader.vue +88 -136
  20. package/src/fields/Checkbox.vue +46 -50
  21. package/src/fields/CheckboxGroup.vue +39 -35
  22. package/src/fields/ColorPicker.vue +5 -3
  23. package/src/fields/Date.vue +21 -27
  24. package/src/fields/DateTime.vue +31 -39
  25. package/src/fields/Daterange.vue +4 -3
  26. package/src/fields/Display.vue +1 -1
  27. package/src/fields/DynamicField.vue +63 -77
  28. package/src/fields/Hidden.vue +1 -1
  29. package/src/fields/Link.vue +65 -86
  30. package/src/fields/Number.vue +32 -34
  31. package/src/fields/RadioGroup.vue +23 -23
  32. package/src/fields/Select.vue +294 -310
  33. package/src/fields/SelectOptionGroups.vue +11 -6
  34. package/src/fields/SelectOptions.vue +5 -3
  35. package/src/fields/Switch.vue +46 -49
  36. package/src/fields/Text.vue +99 -107
  37. package/src/fields/Textarea.vue +32 -44
  38. package/src/fields/Time.vue +21 -30
  39. package/src/index.ts +22 -23
  40. package/src/schema.ts +50 -12
  41. package/src/theme/form.scss +1 -1
  42. package/src/utils/form.ts +9 -5
  43. package/types/Form.vue.d.ts +211 -111
  44. package/types/FormDialog.vue.d.ts +813 -154
  45. package/types/containers/Col.vue.d.ts +96 -40
  46. package/types/containers/Container.vue.d.ts +126 -65
  47. package/types/containers/Fieldset.vue.d.ts +5 -3
  48. package/types/containers/GroupList.vue.d.ts +90 -53
  49. package/types/containers/GroupListItem.vue.d.ts +101 -67
  50. package/types/containers/Panel.vue.d.ts +96 -39
  51. package/types/containers/Row.vue.d.ts +96 -39
  52. package/types/containers/Step.vue.d.ts +106 -42
  53. package/types/containers/Table.vue.d.ts +161 -130
  54. package/types/containers/Tabs.vue.d.ts +97 -50
  55. package/types/fields/Cascader.vue.d.ts +95 -71
  56. package/types/fields/Checkbox.vue.d.ts +95 -56
  57. package/types/fields/CheckboxGroup.vue.d.ts +95 -53
  58. package/types/fields/ColorPicker.vue.d.ts +1 -3
  59. package/types/fields/Date.vue.d.ts +95 -54
  60. package/types/fields/DateTime.vue.d.ts +95 -54
  61. package/types/fields/Daterange.vue.d.ts +1 -3
  62. package/types/fields/Display.vue.d.ts +1 -3
  63. package/types/fields/DynamicField.vue.d.ts +95 -64
  64. package/types/fields/Hidden.vue.d.ts +1 -3
  65. package/types/fields/Link.vue.d.ts +60 -657
  66. package/types/fields/Number.vue.d.ts +99 -56
  67. package/types/fields/RadioGroup.vue.d.ts +96 -52
  68. package/types/fields/Select.vue.d.ts +97 -65
  69. package/types/fields/SelectOptionGroups.vue.d.ts +1 -3
  70. package/types/fields/SelectOptions.vue.d.ts +1 -3
  71. package/types/fields/Switch.vue.d.ts +95 -56
  72. package/types/fields/Text.vue.d.ts +98 -57
  73. package/types/fields/Textarea.vue.d.ts +100 -60
  74. package/types/fields/Time.vue.d.ts +95 -55
  75. package/types/index.d.ts +0 -1
  76. package/types/schema.d.ts +42 -9
  77. package/types/utils/form.d.ts +2 -1
  78. package/dist/tmagic-form.mjs +0 -3925
  79. package/dist/tmagic-form.mjs.map +0 -1
  80. package/dist/tmagic-form.umd.js +0 -3965
  81. package/dist/tmagic-form.umd.js.map +0 -1
  82. package/src/utils/fieldProps.ts +0 -39
  83. package/types/utils/fieldProps.d.ts +0 -21
package/src/Form.vue CHANGED
@@ -1,17 +1,17 @@
1
1
  <template>
2
- <el-form
2
+ <TMagicForm
3
3
  class="m-form"
4
- ref="elForm"
4
+ ref="tMagicForm"
5
5
  :model="values"
6
6
  :label-width="labelWidth"
7
- :disabled="disabled"
8
7
  :style="`height: ${height}`"
9
8
  :inline="inline"
10
9
  :label-position="labelPosition"
11
10
  >
12
11
  <template v-if="initialized && Array.isArray(config)">
13
- <m-form-container
12
+ <Container
14
13
  v-for="(item, index) in config"
14
+ :disabled="disabled"
15
15
  :key="item[keyProp] ?? index"
16
16
  :config="item"
17
17
  :model="values"
@@ -19,175 +19,140 @@
19
19
  :step-active="stepActive"
20
20
  :size="size"
21
21
  @change="changeHandler"
22
- ></m-form-container>
22
+ ></Container>
23
23
  </template>
24
- </el-form>
24
+ </TMagicForm>
25
25
  </template>
26
26
 
27
- <script lang="ts">
28
- import { defineComponent, PropType, provide, reactive, ref, toRaw, watch } from 'vue';
29
- import { cloneDeep, isEqual } from 'lodash-es';
27
+ <script setup lang="ts" name="MForm">
28
+ import { provide, reactive, ref, toRaw, watch, watchEffect } from 'vue';
29
+ import cloneDeep from 'lodash-es/cloneDeep';
30
+ import isEqual from 'lodash-es/isEqual';
30
31
 
32
+ import { TMagicForm } from '@tmagic/design';
33
+
34
+ import Container from './containers/Container.vue';
31
35
  import { getConfig } from './utils/config';
32
36
  import { initValue } from './utils/form';
33
- import { FormConfig, FormState, FormValue } from './schema';
34
-
35
- interface ValidateError {
36
- message: string;
37
- field: string;
38
- }
39
-
40
- export default defineComponent({
41
- name: 'm-form',
42
-
43
- props: {
44
- // 表单初始化值
45
- initValues: {
46
- type: Object,
47
- required: true,
48
- default: () => ({}),
49
- },
50
-
51
- parentValues: {
52
- type: Object,
53
- default: () => ({}),
54
- },
55
-
56
- // 表单配置
57
- config: {
58
- type: Array as PropType<FormConfig>,
59
- required: true,
60
- default: () => [],
61
- },
62
-
63
- labelWidth: {
64
- type: String,
65
- default: () => '200px',
66
- },
67
-
68
- disabled: {
69
- type: Boolean,
70
- default: () => false,
71
- },
72
-
73
- height: {
74
- type: String,
75
- default: () => 'auto',
76
- },
77
-
78
- stepActive: {
79
- type: [String, Number],
80
- default: () => 1,
81
- },
82
-
83
- size: {
84
- type: String as PropType<'small' | 'default' | 'large'>,
85
- },
86
-
87
- inline: {
88
- type: Boolean,
89
- default: false,
90
- },
91
-
92
- labelPosition: {
93
- type: String,
94
- default: 'right',
95
- },
96
-
97
- keyProp: {
98
- type: String,
99
- default: '__key',
100
- },
101
-
102
- popperClass: {
103
- type: String,
104
- },
37
+ import type { FormConfig, FormState, FormValue, ValidateError } from './schema';
38
+
39
+ const props = withDefaults(
40
+ defineProps<{
41
+ config: FormConfig;
42
+ initValues: Object;
43
+ parentValues?: Object;
44
+ labelWidth?: string;
45
+ disabled?: boolean;
46
+ height?: string;
47
+ stepActive?: string | number;
48
+ size?: 'small' | 'default' | 'large';
49
+ inline?: boolean;
50
+ labelPosition?: string;
51
+ keyProp?: string;
52
+ popperClass?: string;
53
+ }>(),
54
+ {
55
+ config: () => [],
56
+ initValues: () => ({}),
57
+ parentValues: () => ({}),
58
+ labelWidth: '200px',
59
+ disabled: false,
60
+ height: 'auto',
61
+ stepActive: 1,
62
+ inline: false,
63
+ labelPosition: 'right',
64
+ keyProp: '__key',
65
+ },
66
+ );
67
+
68
+ const emit = defineEmits(['change', 'field-input', 'field-change']);
69
+
70
+ const tMagicForm = ref<InstanceType<typeof TMagicForm>>();
71
+ const initialized = ref(false);
72
+ const values = ref<FormValue>({});
73
+ const fields = new Map<string, any>();
74
+
75
+ const requestFuc = getConfig('request') as Function;
76
+
77
+ const formState: FormState = reactive<FormState>({
78
+ keyProp: props.keyProp,
79
+ popperClass: props.popperClass,
80
+ config: props.config,
81
+ initValues: props.initValues,
82
+ parentValues: props.parentValues,
83
+ values,
84
+ $emit: emit as (event: string, ...args: any[]) => void,
85
+ fields,
86
+ setField: (prop: string, field: any) => fields.set(prop, field),
87
+ getField: (prop: string) => fields.get(prop),
88
+ deleteField: (prop: string) => fields.delete(prop),
89
+ post: (options: any) => {
90
+ if (requestFuc) {
91
+ return requestFuc({
92
+ ...options,
93
+ method: 'POST',
94
+ });
95
+ }
105
96
  },
97
+ });
106
98
 
107
- emits: ['change', 'field-input', 'field-change'],
99
+ watchEffect(() => {
100
+ formState.initValues = props.initValues;
101
+ formState.config = props.config;
102
+ formState.keyProp = props.keyProp;
103
+ formState.popperClass = props.popperClass;
104
+ formState.parentValues = props.parentValues;
105
+ });
108
106
 
109
- setup(props, { emit }) {
110
- // InstanceType<typeof ElForm>,构建types的时候会出错
111
- const elForm = ref<any>();
112
- const initialized = ref(false);
113
- const values = ref<FormValue>({});
114
- const fields = new Map<string, any>();
107
+ provide('mForm', formState);
115
108
 
116
- const requestFuc = getConfig('request') as Function;
109
+ watch(
110
+ [() => props.config, () => props.initValues],
111
+ ([config], [preConfig]) => {
112
+ if (!isEqual(toRaw(config), toRaw(preConfig))) {
113
+ initialized.value = false;
114
+ }
117
115
 
118
- const formState: FormState = reactive<FormState>({
119
- keyProp: props.keyProp,
120
- popperClass: props.popperClass,
121
- config: props.config,
116
+ initValue(formState, {
122
117
  initValues: props.initValues,
123
- parentValues: props.parentValues,
124
- values,
125
- $emit: emit as (event: string, ...args: any[]) => void,
126
- fields,
127
- setField: (prop: string, field: any) => fields.set(prop, field),
128
- getField: (prop: string) => fields.get(prop),
129
- deleteField: (prop: string) => fields.delete(prop),
130
- post: (options: any) => {
131
- if (requestFuc) {
132
- return requestFuc({
133
- ...options,
134
- method: 'POST',
135
- });
136
- }
137
- },
118
+ config: props.config,
119
+ }).then((value) => {
120
+ values.value = value;
121
+ initialized.value = true;
138
122
  });
139
-
140
- provide('mForm', formState);
141
-
142
- watch(
143
- [() => props.config, () => props.initValues],
144
- ([config], [preConfig]) => {
145
- if (!isEqual(toRaw(config), toRaw(preConfig))) {
146
- initialized.value = false;
147
- }
148
-
149
- initValue(formState, {
150
- initValues: props.initValues,
151
- config: props.config,
152
- }).then((value) => {
153
- values.value = value;
154
- initialized.value = true;
123
+ },
124
+ { immediate: true },
125
+ );
126
+
127
+ const changeHandler = () => {
128
+ emit('change', values.value);
129
+ };
130
+
131
+ defineExpose({
132
+ values,
133
+ formState,
134
+ initialized,
135
+
136
+ changeHandler,
137
+
138
+ resetForm: () => tMagicForm.value?.resetFields(),
139
+
140
+ submitForm: async (native?: boolean): Promise<any> => {
141
+ try {
142
+ await tMagicForm.value?.validate();
143
+ return native ? values.value : cloneDeep(toRaw(values.value));
144
+ } catch (invalidFields: any) {
145
+ const error: string[] = [];
146
+
147
+ Object.entries(invalidFields).forEach(([, ValidateError]) => {
148
+ (ValidateError as ValidateError[]).forEach(({ field, message }) => {
149
+ if (field && message) error.push(`${field} -> ${message}`);
150
+ if (field && !message) error.push(`${field} -> 出现错误`);
151
+ if (!field && message) error.push(`${message}`);
155
152
  });
156
- },
157
- { immediate: true },
158
- );
159
-
160
- return {
161
- initialized,
162
- values,
163
- elForm,
164
-
165
- formState,
166
-
167
- changeHandler: () => {
168
- emit('change', values.value);
169
- },
170
-
171
- resetForm: () => elForm.value?.resetFields(),
172
-
173
- submitForm: async (native?: boolean): Promise<any> => {
174
- try {
175
- await elForm.value?.validate();
176
- return native ? values.value : cloneDeep(toRaw(values.value));
177
- } catch (invalidFields: any) {
178
- const error: string[] = [];
179
-
180
- Object.entries(invalidFields).forEach(([, ValidateError]) => {
181
- (ValidateError as ValidateError[]).forEach(({ field, message }) => {
182
- if (field && message) error.push(`${field} -> ${message}`);
183
- if (field && !message) error.push(`${field} -> 出现错误`);
184
- if (!field && message) error.push(`${message}`);
185
- });
186
- });
187
- throw new Error(error.join('<br>'));
188
- }
189
- },
190
- };
153
+ });
154
+ throw new Error(error.join('<br>'));
155
+ }
191
156
  },
192
157
  });
193
158
  </script>
@@ -1,11 +1,12 @@
1
1
  <template>
2
- <el-dialog
2
+ <TMagicDialog
3
3
  v-model="dialogVisible"
4
4
  class="m-form-dialog"
5
5
  top="20px"
6
6
  append-to-body
7
7
  :title="title"
8
8
  :width="width"
9
+ :zIndex="zIndex"
9
10
  :fullscreen="fullscreen"
10
11
  :close-on-click-modal="false"
11
12
  @close="closeHandler"
@@ -15,159 +16,140 @@
15
16
  class="m-dialog-body"
16
17
  :style="`max-height: ${bodyHeight}; overflow-y: auto; overflow-x: hidden;`"
17
18
  >
18
- <m-form
19
+ <Form
19
20
  v-model="stepActive"
20
21
  ref="form"
21
22
  :size="size"
23
+ :disabled="disabled"
22
24
  :config="config"
23
25
  :init-values="values"
24
26
  :parent-values="parentValues"
25
27
  :label-width="labelWidth"
26
28
  @change="changeHandler"
27
- ></m-form>
29
+ ></Form>
28
30
  <slot></slot>
29
31
  </div>
30
32
 
31
33
  <template #footer>
32
- <el-row class="dialog-footer">
33
- <el-col :span="12" style="text-align: left">
34
+ <TMagicRow class="dialog-footer">
35
+ <TMagicCol :span="12" style="text-align: left">
34
36
  <div style="min-height: 1px">
35
37
  <slot name="left"></slot>
36
38
  </div>
37
- </el-col>
38
- <el-col :span="12">
39
+ </TMagicCol>
40
+ <TMagicCol :span="12">
39
41
  <slot name="footer">
40
- <el-button @click="cancel" size="small">取 消</el-button>
41
- <el-button v-if="hasStep && stepActive > 1" type="info" size="small" @click="preStep">上一步</el-button>
42
- <el-button v-if="hasStep && stepCount > stepActive" type="info" size="small" @click="nextStep"
43
- >下一步</el-button
42
+ <TMagicButton @click="cancel" size="small">取 消</TMagicButton>
43
+ <TMagicButton v-if="hasStep && stepActive > 1" type="info" size="small" @click="preStep"
44
+ >上一步</TMagicButton
44
45
  >
45
- <el-button v-else type="primary" size="small" :loading="saveFetch" @click="save">{{
46
+ <TMagicButton v-if="hasStep && stepCount > stepActive" type="info" size="small" @click="nextStep"
47
+ >下一步</TMagicButton
48
+ >
49
+ <TMagicButton v-else type="primary" size="small" :loading="saveFetch" @click="save">{{
46
50
  confirmText
47
- }}</el-button>
51
+ }}</TMagicButton>
48
52
  </slot>
49
- </el-col>
50
- </el-row>
53
+ </TMagicCol>
54
+ </TMagicRow>
51
55
  </template>
52
- </el-dialog>
56
+ </TMagicDialog>
53
57
  </template>
54
58
 
55
- <script lang="ts">
56
- import { computed, defineComponent, PropType, ref } from 'vue';
59
+ <script setup lang="ts" name="MFormDialog">
60
+ import { computed, ref } from 'vue';
61
+
62
+ import { TMagicButton, TMagicCol, TMagicDialog, TMagicRow } from '@tmagic/design';
57
63
 
58
64
  import Form from './Form.vue';
59
65
  import { FormConfig, StepConfig } from './schema';
60
66
 
61
- export default defineComponent({
62
- name: 'm-form-dialog',
63
-
64
- props: {
65
- values: {
66
- type: Object,
67
- default: () => ({}),
68
- },
69
-
70
- parentValues: {
71
- type: Object,
72
- },
73
-
74
- width: [Number, String],
75
-
76
- fullscreen: Boolean,
77
-
78
- title: String,
79
-
80
- config: {
81
- type: Array as PropType<FormConfig>,
82
- required: true,
83
- default: () => [],
84
- },
85
-
86
- labelWidth: [Number, String],
67
+ const props = withDefaults(
68
+ defineProps<{
69
+ config?: FormConfig;
70
+ values?: Object;
71
+ parentValues?: Object;
72
+ width?: string | number;
73
+ labelWidth?: string;
74
+ fullscreen?: boolean;
75
+ disabled?: boolean;
76
+ title?: string;
77
+ zIndex?: number;
78
+ size?: 'small' | 'default' | 'large';
79
+ confirmText?: string;
80
+ }>(),
81
+ {
82
+ config: () => [],
83
+ values: () => ({}),
84
+ confirmText: '确定',
85
+ },
86
+ );
87
+
88
+ const emit = defineEmits(['close', 'submit', 'error', 'change']);
89
+
90
+ const form = ref<InstanceType<typeof Form>>();
91
+ const dialogVisible = ref(false);
92
+ const saveFetch = ref(false);
93
+ const stepActive = ref(1);
94
+ const bodyHeight = ref(`${document.body.clientHeight - 194}px`);
95
+
96
+ const stepCount = computed(() => {
97
+ const { length } = props.config;
98
+ for (let index = 0; index < length; index++) {
99
+ if (props.config[index].type === 'step') {
100
+ return (props.config[index] as StepConfig).items.length;
101
+ }
102
+ }
103
+ return 0;
104
+ });
87
105
 
88
- size: String as PropType<'small' | 'default' | 'large'>,
106
+ const hasStep = computed(() => {
107
+ const { length } = props.config;
108
+ for (let index = 0; index < length; index++) {
109
+ if (props.config[index].type === 'step') {
110
+ return true;
111
+ }
112
+ }
89
113
 
90
- confirmText: {
91
- type: String,
92
- default: '确定',
93
- },
94
- },
114
+ return false;
115
+ });
95
116
 
96
- emits: ['close', 'submit', 'error', 'change'],
97
-
98
- setup(props, { emit }) {
99
- const form = ref<InstanceType<typeof Form>>();
100
- const dialogVisible = ref(false);
101
- const saveFetch = ref(false);
102
- const stepActive = ref(1);
103
- const bodyHeight = ref(`${document.body.clientHeight - 194}px`);
104
-
105
- const stepCount = computed(() => {
106
- const { length } = props.config;
107
- for (let index = 0; index < length; index++) {
108
- if (props.config[index].type === 'step') {
109
- return (props.config[index] as StepConfig).items.length;
110
- }
111
- }
112
- return 0;
113
- });
114
-
115
- const hasStep = computed(() => {
116
- const { length } = props.config;
117
- for (let index = 0; index < length; index++) {
118
- if (props.config[index].type === 'step') {
119
- return true;
120
- }
121
- }
122
-
123
- return false;
124
- });
125
-
126
- const cancel = () => {
127
- dialogVisible.value = false;
128
- };
129
-
130
- const closeHandler = () => {
131
- stepActive.value = 1;
132
- emit('close');
133
- };
134
-
135
- const save = async () => {
136
- try {
137
- const values = await form.value?.submitForm();
138
- emit('submit', values);
139
- } catch (e) {
140
- emit('error', e);
141
- }
142
- };
143
-
144
- const preStep = () => {
145
- stepActive.value -= 1;
146
- };
147
-
148
- const nextStep = () => {
149
- stepActive.value += 1;
150
- };
151
-
152
- const changeHandler = (value: any) => {
153
- emit('change', value);
154
- };
155
-
156
- return {
157
- form,
158
- saveFetch,
159
- stepActive,
160
- dialogVisible,
161
- bodyHeight,
162
- stepCount,
163
- hasStep,
164
- cancel,
165
- closeHandler,
166
- save,
167
- preStep,
168
- nextStep,
169
- changeHandler,
170
- };
171
- },
117
+ const cancel = () => {
118
+ dialogVisible.value = false;
119
+ };
120
+
121
+ const closeHandler = () => {
122
+ stepActive.value = 1;
123
+ emit('close');
124
+ };
125
+
126
+ const save = async () => {
127
+ try {
128
+ const values = await form.value?.submitForm();
129
+ emit('submit', values);
130
+ } catch (e) {
131
+ emit('error', e);
132
+ }
133
+ };
134
+
135
+ const preStep = () => {
136
+ stepActive.value -= 1;
137
+ };
138
+
139
+ const nextStep = () => {
140
+ stepActive.value += 1;
141
+ };
142
+
143
+ const changeHandler = (value: any) => {
144
+ emit('change', value);
145
+ };
146
+
147
+ defineExpose({
148
+ form,
149
+ saveFetch,
150
+ dialogVisible,
151
+
152
+ cancel,
153
+ save,
172
154
  });
173
155
  </script>
@@ -1,56 +1,42 @@
1
1
  <template>
2
- <el-col v-show="display && config.type !== 'hidden'" :span="span">
3
- <m-form-container
2
+ <TMagicCol v-show="display && config.type !== 'hidden'" :span="span">
3
+ <Container
4
4
  :model="model"
5
5
  :config="config"
6
6
  :prop="prop"
7
7
  :label-width="config.labelWidth || labelWidth"
8
8
  :expand-more="expandMore"
9
9
  :size="size"
10
+ :disabled="disabled"
10
11
  @change="changeHandler"
11
- ></m-form-container>
12
- </el-col>
12
+ ></Container>
13
+ </TMagicCol>
13
14
  </template>
14
15
 
15
- <script lang="ts">
16
- import { computed, defineComponent, inject, PropType } from 'vue';
16
+ <script setup lang="ts" name="MFormCol">
17
+ import { computed, inject } from 'vue';
18
+
19
+ import { TMagicCol } from '@tmagic/design';
17
20
 
18
21
  import { ChildConfig, FormState } from '../schema';
19
22
  import { display as displayFunction } from '../utils/form';
20
23
 
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'],
24
+ import Container from './Container.vue';
43
25
 
44
- setup(props, { emit }) {
45
- const mForm = inject<FormState | undefined>('mForm');
26
+ const props = defineProps<{
27
+ model: any;
28
+ config: ChildConfig;
29
+ labelWidth?: string;
30
+ expandMore?: boolean;
31
+ span?: number;
32
+ size?: string;
33
+ prop?: string;
34
+ disabled?: boolean;
35
+ }>();
46
36
 
47
- const changeHandler = () => emit('change', props.model);
37
+ const emit = defineEmits(['change']);
48
38
 
49
- return {
50
- mForm,
51
- display: computed(() => displayFunction(mForm, props.config.display, props)),
52
- changeHandler,
53
- };
54
- },
55
- });
39
+ const mForm = inject<FormState | undefined>('mForm');
40
+ const display = computed(() => displayFunction(mForm, props.config.display, props));
41
+ const changeHandler = () => emit('change', props.model);
56
42
  </script>