@tmagic/form 1.3.0-alpha.16 → 1.3.0-alpha.17

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 (60) hide show
  1. package/dist/style.css +8 -0
  2. package/dist/tmagic-form.js +177 -110
  3. package/dist/tmagic-form.js.map +1 -1
  4. package/dist/tmagic-form.umd.cjs +198 -130
  5. package/dist/tmagic-form.umd.cjs.map +1 -1
  6. package/package.json +3 -3
  7. package/src/FormDrawer.vue +3 -1
  8. package/src/containers/Container.vue +10 -8
  9. package/src/containers/GroupList.vue +1 -0
  10. package/src/containers/GroupListItem.vue +8 -2
  11. package/src/fields/Cascader.vue +2 -12
  12. package/src/fields/Checkbox.vue +2 -12
  13. package/src/fields/CheckboxGroup.vue +2 -12
  14. package/src/fields/ColorPicker.vue +5 -13
  15. package/src/fields/Date.vue +5 -13
  16. package/src/fields/DateTime.vue +5 -13
  17. package/src/fields/Daterange.vue +2 -12
  18. package/src/fields/Display.vue +2 -10
  19. package/src/fields/DynamicField.vue +3 -13
  20. package/src/fields/Hidden.vue +2 -10
  21. package/src/fields/Link.vue +2 -12
  22. package/src/fields/Number.vue +7 -14
  23. package/src/fields/NumberRange.vue +50 -0
  24. package/src/fields/RadioGroup.vue +2 -12
  25. package/src/fields/Select.vue +2 -12
  26. package/src/fields/Switch.vue +6 -14
  27. package/src/fields/Text.vue +7 -14
  28. package/src/fields/Textarea.vue +7 -14
  29. package/src/fields/Time.vue +5 -13
  30. package/src/index.ts +3 -0
  31. package/src/schema.ts +22 -1
  32. package/src/theme/index.scss +1 -0
  33. package/src/theme/number-range.scss +8 -0
  34. package/src/utils/config.ts +1 -1
  35. package/src/utils/form.ts +2 -1
  36. package/types/Form.vue.d.ts +2 -2
  37. package/types/FormDialog.vue.d.ts +5 -5
  38. package/types/FormDrawer.vue.d.ts +10 -5
  39. package/types/fields/Cascader.vue.d.ts +2 -22
  40. package/types/fields/Checkbox.vue.d.ts +2 -22
  41. package/types/fields/CheckboxGroup.vue.d.ts +2 -22
  42. package/types/fields/ColorPicker.vue.d.ts +2 -24
  43. package/types/fields/Date.vue.d.ts +2 -24
  44. package/types/fields/DateTime.vue.d.ts +2 -24
  45. package/types/fields/Daterange.vue.d.ts +2 -22
  46. package/types/fields/Display.vue.d.ts +2 -18
  47. package/types/fields/DynamicField.vue.d.ts +2 -22
  48. package/types/fields/Hidden.vue.d.ts +2 -18
  49. package/types/fields/Link.vue.d.ts +2 -22
  50. package/types/fields/Number.vue.d.ts +2 -25
  51. package/types/fields/NumberRange.vue.d.ts +12 -0
  52. package/types/fields/RadioGroup.vue.d.ts +2 -22
  53. package/types/fields/Select.vue.d.ts +2 -22
  54. package/types/fields/Switch.vue.d.ts +2 -24
  55. package/types/fields/Text.vue.d.ts +2 -25
  56. package/types/fields/Textarea.vue.d.ts +2 -25
  57. package/types/fields/Time.vue.d.ts +2 -24
  58. package/types/index.d.ts +1 -0
  59. package/types/schema.d.ts +20 -1
  60. package/types/utils/config.d.ts +1 -1
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.0-alpha.16",
2
+ "version": "1.3.0-alpha.17",
3
3
  "name": "@tmagic/form",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -36,8 +36,8 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@element-plus/icons-vue": "^2.0.9",
39
- "@tmagic/design": "1.3.0-alpha.16",
40
- "@tmagic/utils": "1.3.0-alpha.16",
39
+ "@tmagic/design": "1.3.0-alpha.17",
40
+ "@tmagic/utils": "1.3.0-alpha.17",
41
41
  "lodash-es": "^4.17.21",
42
42
  "sortablejs": "^1.14.0",
43
43
  "vue": "^3.3.4"
@@ -3,7 +3,7 @@
3
3
  class="m-form-drawer"
4
4
  v-model="visible"
5
5
  :title="title"
6
- :close-on-press-escape="true"
6
+ :close-on-press-escape="closeOnPressEscape"
7
7
  :append-to-body="true"
8
8
  :show-close="true"
9
9
  :close-on-click-modal="true"
@@ -66,12 +66,14 @@ withDefaults(
66
66
  width?: string | number;
67
67
  labelWidth?: string;
68
68
  disabled?: boolean;
69
+ closeOnPressEscape?: boolean;
69
70
  title?: string;
70
71
  zIndex?: number;
71
72
  size?: 'small' | 'default' | 'large';
72
73
  confirmText?: string;
73
74
  }>(),
74
75
  {
76
+ closeOnPressEscape: true,
75
77
  config: () => [],
76
78
  values: () => ({}),
77
79
  confirmText: '确定',
@@ -14,7 +14,7 @@
14
14
  ></m-fields-hidden>
15
15
 
16
16
  <component
17
- v-else-if="items && !config.text && type && display"
17
+ v-else-if="items && !text && type && display"
18
18
  :key="key(config)"
19
19
  :size="size"
20
20
  :is="tagName"
@@ -35,12 +35,12 @@
35
35
  <template v-else-if="type && display && !showDiff">
36
36
  <TMagicFormItem
37
37
  :style="config.tip ? 'flex: 1' : ''"
38
- :class="{ hidden: `${itemLabelWidth}` === '0' || !config.text }"
38
+ :class="{ hidden: `${itemLabelWidth}` === '0' || !text }"
39
39
  :prop="itemProp"
40
40
  :label-width="itemLabelWidth"
41
41
  :rules="rule"
42
42
  >
43
- <template #label><span v-html="type === 'checkbox' ? '' : config.text"></span></template>
43
+ <template #label><span v-html="type === 'checkbox' ? '' : text"></span></template>
44
44
  <TMagicTooltip v-if="tooltip">
45
45
  <component
46
46
  :key="key(config)"
@@ -91,13 +91,13 @@
91
91
  <!-- 上次内容 -->
92
92
  <TMagicFormItem
93
93
  :style="config.tip ? 'flex: 1' : ''"
94
- :class="{ hidden: `${itemLabelWidth}` === '0' || !config.text }"
94
+ :class="{ hidden: `${itemLabelWidth}` === '0' || !text }"
95
95
  :prop="itemProp"
96
96
  :label-width="itemLabelWidth"
97
97
  :rules="rule"
98
98
  style="background: #f7dadd"
99
99
  >
100
- <template #label><span v-html="type === 'checkbox' ? '' : config.text"></span></template>
100
+ <template #label><span v-html="type === 'checkbox' ? '' : text"></span></template>
101
101
  <TMagicTooltip v-if="tooltip">
102
102
  <component
103
103
  :key="key(config)"
@@ -140,13 +140,13 @@
140
140
  <!-- 当前内容 -->
141
141
  <TMagicFormItem
142
142
  :style="config.tip ? 'flex: 1' : ''"
143
- :class="{ hidden: `${itemLabelWidth}` === '0' || !config.text }"
143
+ :class="{ hidden: `${itemLabelWidth}` === '0' || !text }"
144
144
  :prop="itemProp"
145
145
  :label-width="itemLabelWidth"
146
146
  :rules="rule"
147
147
  style="background: #def7da"
148
148
  >
149
- <template #label><span v-html="type === 'checkbox' ? '' : config.text"></span></template>
149
+ <template #label><span v-html="type === 'checkbox' ? '' : text"></span></template>
150
150
  <TMagicTooltip v-if="tooltip">
151
151
  <component
152
152
  :key="key(config)"
@@ -294,6 +294,8 @@ const tagName = computed(() => {
294
294
 
295
295
  const disabled = computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
296
296
 
297
+ const text = computed(() => filterFunction(mForm, props.config.text, props));
298
+
297
299
  const tooltip = computed(() => filterFunction(mForm, props.config.tooltip, props));
298
300
 
299
301
  const extra = computed(() => filterFunction(mForm, props.config.extra, props));
@@ -331,7 +333,7 @@ watch(
331
333
  showDiff,
332
334
  (showDiff) => {
333
335
  if (type.value === 'hidden') return;
334
- if (items.value && !props.config.text && type.value && display.value) return;
336
+ if (items.value && !text.value && type.value && display.value) return;
335
337
  if (display.value && showDiff && type.value) {
336
338
  emit('addDiffCount');
337
339
  }
@@ -132,6 +132,7 @@ const toggleMode = () => {
132
132
  text: null,
133
133
  }))) as any;
134
134
  };
135
+
135
136
  const onAddDiffCount = () => emit('addDiffCount');
136
137
 
137
138
  const getLastValues = (item: any, index: number) => item?.[index] || {};
@@ -88,7 +88,13 @@ const title = computed(() => {
88
88
  return props.model[props.config.titleKey];
89
89
  }
90
90
 
91
- return `组 ${String(props.index)}`;
91
+ if (props.config.title) {
92
+ return filterFunction(mForm, props.config.title, props);
93
+ }
94
+
95
+ const titlePrefix = props.config.titlePrefix || '组';
96
+
97
+ return `${titlePrefix} ${String(props.index + 1)}`;
92
98
  });
93
99
 
94
100
  const length = computed(() => props.groupModel?.length || 0);
@@ -113,7 +119,7 @@ const showDelete = (index: number) => {
113
119
  };
114
120
 
115
121
  // 调换顺序
116
- const changeOrder = (offset = 0) => emit('swap-item', props.index, `${String(props.index)}${offset}`);
122
+ const changeOrder = (offset = 0) => emit('swap-item', props.index, props.index + offset);
117
123
 
118
124
  const movable = () => {
119
125
  const { movable } = props.config;
@@ -19,7 +19,7 @@ import { inject, ref, watchEffect } from 'vue';
19
19
 
20
20
  import { TMagicCascader } from '@tmagic/design';
21
21
 
22
- import { CascaderConfig, FormState } from '../schema';
22
+ import type { CascaderConfig, FieldProps, FormState } from '../schema';
23
23
  import { getConfig } from '../utils/config';
24
24
  import { useAddField } from '../utils/useAddField';
25
25
 
@@ -27,17 +27,7 @@ defineOptions({
27
27
  name: 'MFormCascader',
28
28
  });
29
29
 
30
- const props = defineProps<{
31
- config: CascaderConfig;
32
- model: any;
33
- initValues?: any;
34
- values?: any;
35
- name: string;
36
- prop: string;
37
- disabled?: boolean;
38
- size?: 'large' | 'default' | 'small';
39
- lastValues?: Record<string, any>;
40
- }>();
30
+ const props = defineProps<FieldProps<CascaderConfig>>();
41
31
 
42
32
  const emit = defineEmits(['change']);
43
33
 
@@ -15,24 +15,14 @@ import { computed } from 'vue';
15
15
 
16
16
  import { TMagicCheckbox } from '@tmagic/design';
17
17
 
18
- import { CheckboxConfig } from '../schema';
18
+ import type { CheckboxConfig, FieldProps } from '../schema';
19
19
  import { useAddField } from '../utils/useAddField';
20
20
 
21
21
  defineOptions({
22
22
  name: 'MFormCheckbox',
23
23
  });
24
24
 
25
- const props = defineProps<{
26
- config: CheckboxConfig;
27
- model: any;
28
- initValues?: any;
29
- values?: any;
30
- name: string;
31
- prop: string;
32
- disabled?: boolean;
33
- size?: 'large' | 'default' | 'small';
34
- lastValues?: Record<string, any>;
35
- }>();
25
+ const props = defineProps<FieldProps<CheckboxConfig>>();
36
26
 
37
27
  const emit = defineEmits(['change']);
38
28
 
@@ -16,7 +16,7 @@ import { computed, inject } from 'vue';
16
16
 
17
17
  import { TMagicCheckbox, TMagicCheckboxGroup } from '@tmagic/design';
18
18
 
19
- import { CheckboxGroupConfig, FormState } from '../schema';
19
+ import type { CheckboxGroupConfig, FieldProps, FormState } from '../schema';
20
20
  import { filterFunction } from '../utils/form';
21
21
  import { useAddField } from '../utils/useAddField';
22
22
 
@@ -24,17 +24,7 @@ defineOptions({
24
24
  name: 'MFormCheckGroup',
25
25
  });
26
26
 
27
- const props = defineProps<{
28
- config: CheckboxGroupConfig;
29
- model: any;
30
- initValues?: any;
31
- values?: any;
32
- name: string;
33
- prop: string;
34
- disabled?: boolean;
35
- size?: 'large' | 'default' | 'small';
36
- lastValues?: Record<string, any>;
37
- }>();
27
+ const props = defineProps<FieldProps<CheckboxGroupConfig>>();
38
28
 
39
29
  const emit = defineEmits(['change']);
40
30
 
@@ -11,26 +11,18 @@
11
11
  <script lang="ts" setup>
12
12
  import { TMagicColorPicker } from '@tmagic/design';
13
13
 
14
- import { ColorPickConfig } from '../schema';
14
+ import type { ColorPickConfig, FieldProps } from '../schema';
15
15
  import { useAddField } from '../utils/useAddField';
16
16
 
17
17
  defineOptions({
18
18
  name: 'MFormColorPicker',
19
19
  });
20
20
 
21
- const props = defineProps<{
22
- config: ColorPickConfig;
23
- model: any;
24
- initValues?: any;
25
- values?: any;
26
- name: string;
27
- prop: string;
28
- disabled?: boolean;
29
- size?: 'large' | 'default' | 'small';
30
- lastValues?: Record<string, any>;
31
- }>();
21
+ const props = defineProps<FieldProps<ColorPickConfig>>();
32
22
 
33
- const emit = defineEmits(['change']);
23
+ const emit = defineEmits<{
24
+ change: [value: string];
25
+ }>();
34
26
 
35
27
  useAddField(props.prop);
36
28
 
@@ -15,26 +15,18 @@
15
15
  import { TMagicDatePicker } from '@tmagic/design';
16
16
  import { datetimeFormatter } from '@tmagic/utils';
17
17
 
18
- import { DateConfig } from '../schema';
18
+ import type { DateConfig, FieldProps } from '../schema';
19
19
  import { useAddField } from '../utils/useAddField';
20
20
 
21
21
  defineOptions({
22
22
  name: 'MFormDate',
23
23
  });
24
24
 
25
- const props = defineProps<{
26
- config: DateConfig;
27
- model: any;
28
- initValues?: any;
29
- values?: any;
30
- name: string;
31
- prop: string;
32
- disabled?: boolean;
33
- size?: 'large' | 'default' | 'small';
34
- lastValues?: Record<string, any>;
35
- }>();
25
+ const props = defineProps<FieldProps<DateConfig>>();
36
26
 
37
- const emit = defineEmits(['change']);
27
+ const emit = defineEmits<{
28
+ change: [value: string];
29
+ }>();
38
30
 
39
31
  useAddField(props.prop);
40
32
 
@@ -17,26 +17,18 @@
17
17
  import { TMagicDatePicker } from '@tmagic/design';
18
18
  import { datetimeFormatter } from '@tmagic/utils';
19
19
 
20
- import { DateTimeConfig } from '../schema';
20
+ import type { DateTimeConfig, FieldProps } from '../schema';
21
21
  import { useAddField } from '../utils/useAddField';
22
22
 
23
23
  defineOptions({
24
24
  name: 'MFormDateTime',
25
25
  });
26
26
 
27
- const props = defineProps<{
28
- config: DateTimeConfig;
29
- model: any;
30
- initValues?: any;
31
- values?: any;
32
- name: string;
33
- prop: string;
34
- disabled?: boolean;
35
- size?: 'large' | 'default' | 'small';
36
- lastValues?: Record<string, any>;
37
- }>();
27
+ const props = defineProps<FieldProps<DateTimeConfig>>();
38
28
 
39
- const emit = defineEmits(['change']);
29
+ const emit = defineEmits<{
30
+ change: [value: string];
31
+ }>();
40
32
 
41
33
  useAddField(props.prop);
42
34
 
@@ -19,24 +19,14 @@ import { ref, watch } from 'vue';
19
19
  import { TMagicDatePicker } from '@tmagic/design';
20
20
  import { datetimeFormatter } from '@tmagic/utils';
21
21
 
22
- import { DaterangeConfig } from '../schema';
22
+ import type { DaterangeConfig, FieldProps } from '../schema';
23
23
  import { useAddField } from '../utils/useAddField';
24
24
 
25
25
  defineOptions({
26
26
  name: 'MFormDateRange',
27
27
  });
28
28
 
29
- const props = defineProps<{
30
- config: DaterangeConfig;
31
- model: any;
32
- initValues?: any;
33
- values?: any;
34
- name: string;
35
- prop: string;
36
- disabled?: boolean;
37
- size?: 'large' | 'default' | 'small';
38
- lastValues?: Record<string, any>;
39
- }>();
29
+ const props = defineProps<FieldProps<DaterangeConfig>>();
40
30
 
41
31
  const emit = defineEmits(['change']);
42
32
 
@@ -3,22 +3,14 @@
3
3
  </template>
4
4
 
5
5
  <script setup lang="ts">
6
- import { DisplayConfig } from '../schema';
6
+ import type { DisplayConfig, FieldProps } from '../schema';
7
7
  import { useAddField } from '../utils/useAddField';
8
8
 
9
9
  defineOptions({
10
10
  name: 'MFormDisplay',
11
11
  });
12
12
 
13
- const props = defineProps<{
14
- config: DisplayConfig;
15
- model: any;
16
- initValues?: any;
17
- values?: any;
18
- name: string;
19
- prop: string;
20
- lastValues?: Record<string, any>;
21
- }>();
13
+ const props = defineProps<FieldProps<DisplayConfig>>();
22
14
 
23
15
  if (props.config.initValue && props.model) {
24
16
  // eslint-disable-next-line vue/no-setup-props-destructure
@@ -27,7 +27,7 @@ import { onBeforeUnmount, reactive, watch } from 'vue';
27
27
 
28
28
  import { TMagicForm, TMagicFormItem, TMagicInput } from '@tmagic/design';
29
29
 
30
- import { DynamicFieldConfig } from '../schema';
30
+ import type { DynamicFieldConfig, FieldProps } from '../schema';
31
31
  import { getConfig } from '../utils/config';
32
32
  import { useAddField } from '../utils/useAddField';
33
33
 
@@ -35,23 +35,13 @@ defineOptions({
35
35
  name: 'MFormDynamicField',
36
36
  });
37
37
 
38
- const props = defineProps<{
39
- config: DynamicFieldConfig;
40
- model: any;
41
- initValues?: any;
42
- values?: any;
43
- name: string;
44
- prop: string;
45
- disabled?: boolean;
46
- size?: 'large' | 'default' | 'small';
47
- lastValues?: Record<string, any>;
48
- }>();
38
+ const props = defineProps<FieldProps<DynamicFieldConfig>>();
49
39
 
50
40
  const emit = defineEmits(['change']);
51
41
 
52
42
  useAddField(props.prop);
53
43
 
54
- const request = getConfig('request') as Function;
44
+ const request = getConfig<Function>('request');
55
45
  const fieldMap = reactive<{ [key: string]: any }>({
56
46
  value: {},
57
47
  });
@@ -3,22 +3,14 @@
3
3
  </template>
4
4
 
5
5
  <script setup lang="ts">
6
- import { HiddenConfig } from '../schema';
6
+ import type { FieldProps, HiddenConfig } from '../schema';
7
7
  import { useAddField } from '../utils/useAddField';
8
8
 
9
9
  defineOptions({
10
10
  name: 'MFormHidden',
11
11
  });
12
12
 
13
- const props = defineProps<{
14
- config: HiddenConfig;
15
- model: any;
16
- initValues?: any;
17
- values?: any;
18
- name: string;
19
- prop: string;
20
- lastValues?: Record<string, any>;
21
- }>();
13
+ const props = defineProps<FieldProps<HiddenConfig>>();
22
14
 
23
15
  useAddField(props.prop);
24
16
  </script>
@@ -22,24 +22,14 @@ import { computed, inject, ref } from 'vue';
22
22
  import { TMagicButton } from '@tmagic/design';
23
23
 
24
24
  import FormDialog from '../FormDialog.vue';
25
- import { FormState, LinkConfig } from '../schema';
25
+ import type { FieldProps, FormState, LinkConfig } from '../schema';
26
26
  import { useAddField } from '../utils/useAddField';
27
27
 
28
28
  defineOptions({
29
29
  name: 'MFormLink',
30
30
  });
31
31
 
32
- const props = defineProps<{
33
- config: LinkConfig;
34
- model: any;
35
- initValues?: any;
36
- values?: any;
37
- name: string;
38
- prop: string;
39
- disabled?: boolean;
40
- size?: 'large' | 'default' | 'small';
41
- lastValues?: Record<string, any>;
42
- }>();
32
+ const props = defineProps<FieldProps<LinkConfig>>();
43
33
 
44
34
  const emit = defineEmits(['change']);
45
35
 
@@ -20,26 +20,19 @@ import { inject } from 'vue';
20
20
 
21
21
  import { TMagicInputNumber } from '@tmagic/design';
22
22
 
23
- import { FormState, NumberConfig } from '../schema';
23
+ import type { FieldProps, FormState, NumberConfig } from '../schema';
24
24
  import { useAddField } from '../utils/useAddField';
25
25
 
26
26
  defineOptions({
27
27
  name: 'MFormNumber',
28
28
  });
29
29
 
30
- const props = defineProps<{
31
- config: NumberConfig;
32
- model: any;
33
- initValues?: any;
34
- values?: any;
35
- name: string;
36
- prop: string;
37
- disabled?: boolean;
38
- size?: 'large' | 'default' | 'small';
39
- lastValues?: Record<string, any>;
40
- }>();
30
+ const props = defineProps<FieldProps<NumberConfig>>();
41
31
 
42
- const emit = defineEmits(['change', 'input']);
32
+ const emit = defineEmits<{
33
+ change: [values: number];
34
+ input: [values: number];
35
+ }>();
43
36
 
44
37
  useAddField(props.prop);
45
38
 
@@ -49,7 +42,7 @@ const changeHandler = (value: number) => {
49
42
  emit('change', value);
50
43
  };
51
44
 
52
- const inputHandler = (v: string) => {
45
+ const inputHandler = (v: number) => {
53
46
  emit('input', v);
54
47
  mForm?.$emit('field-input', props.prop, v);
55
48
  };
@@ -0,0 +1,50 @@
1
+ <template>
2
+ <div class="m-fields-number-range">
3
+ <TMagicInput
4
+ v-model="model[name][0]"
5
+ clearable
6
+ :size="size"
7
+ :disabled="disabled"
8
+ @change="minChangeHandler"
9
+ ></TMagicInput>
10
+ <span class="split-tag">-</span>
11
+ <TMagicInput
12
+ v-model="model[name][1]"
13
+ clearable
14
+ :size="size"
15
+ :disabled="disabled"
16
+ @change="maxChangeHandler"
17
+ ></TMagicInput>
18
+ </div>
19
+ </template>
20
+
21
+ <script lang="ts" setup>
22
+ import { TMagicInput } from '@tmagic/design';
23
+
24
+ import type { FieldProps, NumberRangeConfig } from '../schema';
25
+ import { useAddField } from '../utils/useAddField';
26
+
27
+ defineOptions({
28
+ name: 'MFormNumberRange',
29
+ });
30
+
31
+ const props = defineProps<FieldProps<NumberRangeConfig>>();
32
+
33
+ const emit = defineEmits<{
34
+ change: [values: [number, number]];
35
+ }>();
36
+
37
+ useAddField(props.prop);
38
+
39
+ if (!Array.isArray(props.model[props.name])) {
40
+ props.model[props.name] = [];
41
+ }
42
+
43
+ const minChangeHandler = (v: string) => {
44
+ emit('change', [Number(v), props.model[props.name][1]]);
45
+ };
46
+
47
+ const maxChangeHandler = (v: string) => {
48
+ emit('change', [props.model[props.name][0], Number(v)]);
49
+ };
50
+ </script>
@@ -13,24 +13,14 @@
13
13
  <script lang="ts" setup>
14
14
  import { TMagicRadio, TMagicRadioGroup } from '@tmagic/design';
15
15
 
16
- import { RadioGroupConfig } from '../schema';
16
+ import type { FieldProps, RadioGroupConfig } from '../schema';
17
17
  import { useAddField } from '../utils/useAddField';
18
18
 
19
19
  defineOptions({
20
20
  name: 'MFormRadioGroup',
21
21
  });
22
22
 
23
- const props = defineProps<{
24
- config: RadioGroupConfig;
25
- model: any;
26
- initValues?: any;
27
- values?: any;
28
- name: string;
29
- prop: string;
30
- disabled?: boolean;
31
- size?: 'large' | 'default' | 'small';
32
- lastValues?: Record<string, any>;
33
- }>();
23
+ const props = defineProps<FieldProps<RadioGroupConfig>>();
34
24
 
35
25
  const emit = defineEmits(['change']);
36
26
 
@@ -31,7 +31,7 @@ import { inject, onBeforeMount, Ref, ref, watch, watchEffect } from 'vue';
31
31
  import { TMagicSelect } from '@tmagic/design';
32
32
  import { getValueByKeyPath } from '@tmagic/utils';
33
33
 
34
- import { FormState, SelectConfig, SelectGroupOption, SelectOption } from '../schema';
34
+ import type { FieldProps, FormState, SelectConfig, SelectGroupOption, SelectOption } from '../schema';
35
35
  import { getConfig } from '../utils/config';
36
36
  import { useAddField } from '../utils/useAddField';
37
37
 
@@ -42,17 +42,7 @@ defineOptions({
42
42
  name: 'MFormSelect',
43
43
  });
44
44
 
45
- const props = defineProps<{
46
- config: SelectConfig;
47
- model: any;
48
- initValues?: any;
49
- values?: any;
50
- name: string;
51
- prop: string;
52
- disabled?: boolean;
53
- size?: 'large' | 'default' | 'small';
54
- lastValues?: Record<string, any>;
55
- }>();
45
+ const props = defineProps<FieldProps<SelectConfig>>();
56
46
 
57
47
  const emit = defineEmits(['change']);
58
48
 
@@ -14,30 +14,22 @@ import { computed } from 'vue';
14
14
 
15
15
  import { TMagicSwitch } from '@tmagic/design';
16
16
 
17
- import { SwitchConfig } from '../schema';
17
+ import type { FieldProps, SwitchConfig } from '../schema';
18
18
  import { useAddField } from '../utils/useAddField';
19
19
 
20
20
  defineOptions({
21
21
  name: 'MFormSwitch',
22
22
  });
23
23
 
24
- const props = defineProps<{
25
- config: SwitchConfig;
26
- model: any;
27
- initValues?: any;
28
- values?: any;
29
- name: string;
30
- prop: string;
31
- disabled?: boolean;
32
- size?: 'large' | 'default' | 'small';
33
- lastValues?: Record<string, any>;
34
- }>();
24
+ const props = defineProps<FieldProps<SwitchConfig>>();
35
25
 
36
- const emit = defineEmits(['change']);
26
+ const emit = defineEmits<{
27
+ change: [value: any];
28
+ }>();
37
29
 
38
30
  useAddField(props.prop);
39
31
 
40
- const changeHandler = (value: number) => {
32
+ const changeHandler = (value: any) => {
41
33
  emit('change', value);
42
34
  };
43
35