@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
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <el-row :gutter="10">
2
+ <TMagicRow :gutter="10">
3
3
  <Col
4
4
  v-for="(col, index) in config.items"
5
5
  :key="col[mForm?.keyProp || '__key'] ?? index"
@@ -10,55 +10,35 @@
10
10
  :model="name ? model[name] : model"
11
11
  :prop="prop"
12
12
  :size="size"
13
+ :disabled="disabled"
13
14
  @change="changeHandler"
14
15
  />
15
- </el-row>
16
+ </TMagicRow>
16
17
  </template>
17
18
 
18
- <script lang="ts">
19
- import { defineComponent, inject, PropType } from 'vue';
19
+ <script setup lang="ts" name="MFormRow">
20
+ import { inject } from 'vue';
21
+
22
+ import { TMagicRow } from '@tmagic/design';
20
23
 
21
24
  import { FormState, RowConfig } from '../schema';
22
25
 
23
26
  import Col from './Col.vue';
24
27
 
25
- export default defineComponent({
26
- name: 'm-form-row',
27
-
28
- components: { Col },
29
-
30
- props: {
31
- labelWidth: String,
32
- expandMore: Boolean,
33
-
34
- model: {
35
- type: Object,
36
- default: () => ({}),
37
- },
38
-
39
- config: {
40
- type: Object as PropType<RowConfig>,
41
- default: () => ({}),
42
- },
43
-
44
- prop: String,
45
-
46
- name: String,
47
-
48
- size: String,
49
- },
50
-
51
- emits: ['change'],
28
+ const props = defineProps<{
29
+ model: any;
30
+ config: RowConfig;
31
+ name: string;
32
+ labelWidth?: string;
33
+ prop?: string;
34
+ size?: string;
35
+ expandMore?: boolean;
36
+ disabled?: boolean;
37
+ }>();
52
38
 
53
- setup(props, { emit }) {
54
- const mForm = inject<FormState | undefined>('mForm');
39
+ const emit = defineEmits(['change']);
55
40
 
56
- const changeHandler = () => emit('change', props.name ? props.model[props.name] : props.model);
41
+ const mForm = inject<FormState | undefined>('mForm');
57
42
 
58
- return {
59
- mForm,
60
- changeHandler,
61
- };
62
- },
63
- });
43
+ const changeHandler = () => emit('change', props.name ? props.model[props.name] : props.model);
64
44
  </script>
@@ -1,82 +1,72 @@
1
1
  <template>
2
2
  <div>
3
- <el-steps :active="active" align-center :space="config.space">
4
- <el-step
3
+ <TMagicSteps :active="active" align-center :space="config.space">
4
+ <TMagicStep
5
5
  v-for="(item, index) in config.items"
6
6
  :key="item.__key"
7
7
  :title="item.title"
8
8
  :active="active"
9
9
  @click="stepClick(index)"
10
- ></el-step>
11
- </el-steps>
10
+ ></TMagicStep>
11
+ </TMagicSteps>
12
12
 
13
13
  <template v-for="(step, index) in config.items">
14
14
  <template v-for="item in step.items">
15
- <m-form-container
15
+ <Container
16
16
  v-if="item"
17
17
  v-show="active - 1 === index"
18
18
  :key="item[mForm?.keyProp || '__key']"
19
19
  :config="item"
20
20
  :model="step.name ? model[step.name] : model"
21
- :prop="step.name"
21
+ :prop="`${step.name}`"
22
22
  :size="size"
23
+ :disabled="disabled"
23
24
  :label-width="config.labelWidth || labelWidth"
24
25
  @change="changeHandler"
25
- ></m-form-container>
26
+ ></Container>
26
27
  </template>
27
28
  </template>
28
29
  </div>
29
30
  </template>
30
31
 
31
- <script lang="ts">
32
- import { defineComponent, inject, PropType, ref, watchEffect } from 'vue';
32
+ <script setup lang="ts" name="MFormStep">
33
+ import { inject, ref, watchEffect } from 'vue';
33
34
 
34
- import { FormState, StepConfig } from '../schema';
35
-
36
- export default defineComponent({
37
- name: 'm-form-step',
38
-
39
- props: {
40
- model: {
41
- type: Object,
42
- default: () => ({}),
43
- },
35
+ import { TMagicStep, TMagicSteps } from '@tmagic/design';
44
36
 
45
- config: {
46
- type: Object as PropType<StepConfig>,
47
- default: () => ({}),
48
- },
49
-
50
- stepActive: {
51
- type: Number,
52
- default: () => 1,
53
- },
37
+ import { FormState, StepConfig } from '../schema';
54
38
 
55
- size: String,
39
+ import Container from './Container.vue';
56
40
 
57
- labelWidth: String,
41
+ const props = withDefaults(
42
+ defineProps<{
43
+ model: any;
44
+ config: StepConfig;
45
+ stepActive?: number;
46
+ labelWidth?: string;
47
+ size?: string;
48
+ disabled?: boolean;
49
+ }>(),
50
+ {
51
+ stepActive: 1,
58
52
  },
53
+ );
59
54
 
60
- emits: ['change'],
55
+ const emit = defineEmits(['change']);
61
56
 
62
- setup(props, { emit }) {
63
- const mForm = inject<FormState | undefined>('mForm');
64
- const active = ref(1);
57
+ const mForm = inject<FormState | undefined>('mForm');
58
+ const active = ref(1);
65
59
 
66
- watchEffect(() => {
67
- active.value = props.stepActive;
68
- });
69
-
70
- const stepClick = (index: number) => {
71
- active.value = index + 1;
72
- mForm?.$emit('update:stepActive', active.value);
73
- };
60
+ watchEffect(() => {
61
+ active.value = props.stepActive;
62
+ });
74
63
 
75
- const changeHandler = () => {
76
- emit('change', props.model);
77
- };
64
+ const stepClick = (index: number) => {
65
+ active.value = index + 1;
66
+ mForm?.$emit('update:stepActive', active.value);
67
+ };
78
68
 
79
- return { mForm, active, stepClick, changeHandler };
80
- },
81
- });
69
+ const changeHandler = () => {
70
+ emit('change', props.model);
71
+ };
82
72
  </script>