@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.
- package/dist/style.css +1 -1
- package/dist/tmagic-form.js +3673 -0
- package/dist/tmagic-form.js.map +1 -0
- package/dist/tmagic-form.umd.cjs +3713 -0
- package/dist/tmagic-form.umd.cjs.map +1 -0
- package/package.json +10 -9
- package/src/Form.vue +124 -159
- package/src/FormDialog.vue +108 -126
- package/src/containers/Col.vue +24 -38
- package/src/containers/Container.vue +143 -171
- package/src/containers/Fieldset.vue +15 -8
- package/src/containers/GroupList.vue +86 -116
- package/src/containers/GroupListItem.vue +91 -125
- package/src/containers/Panel.vue +29 -49
- package/src/containers/Row.vue +20 -40
- package/src/containers/Step.vue +38 -48
- package/src/containers/Table.vue +466 -481
- package/src/containers/Tabs.vue +94 -118
- package/src/fields/Cascader.vue +88 -136
- package/src/fields/Checkbox.vue +46 -50
- package/src/fields/CheckboxGroup.vue +39 -35
- package/src/fields/ColorPicker.vue +5 -3
- package/src/fields/Date.vue +21 -27
- package/src/fields/DateTime.vue +31 -39
- package/src/fields/Daterange.vue +4 -3
- package/src/fields/Display.vue +1 -1
- package/src/fields/DynamicField.vue +63 -77
- package/src/fields/Hidden.vue +1 -1
- package/src/fields/Link.vue +65 -86
- package/src/fields/Number.vue +32 -34
- package/src/fields/RadioGroup.vue +23 -23
- package/src/fields/Select.vue +294 -310
- package/src/fields/SelectOptionGroups.vue +11 -6
- package/src/fields/SelectOptions.vue +5 -3
- package/src/fields/Switch.vue +46 -49
- package/src/fields/Text.vue +99 -107
- package/src/fields/Textarea.vue +32 -44
- package/src/fields/Time.vue +21 -30
- package/src/index.ts +22 -23
- package/src/schema.ts +50 -12
- package/src/theme/form.scss +1 -1
- package/src/utils/form.ts +9 -5
- package/types/Form.vue.d.ts +211 -111
- package/types/FormDialog.vue.d.ts +813 -154
- package/types/containers/Col.vue.d.ts +96 -40
- package/types/containers/Container.vue.d.ts +126 -65
- package/types/containers/Fieldset.vue.d.ts +5 -3
- package/types/containers/GroupList.vue.d.ts +90 -53
- package/types/containers/GroupListItem.vue.d.ts +101 -67
- package/types/containers/Panel.vue.d.ts +96 -39
- package/types/containers/Row.vue.d.ts +96 -39
- package/types/containers/Step.vue.d.ts +106 -42
- package/types/containers/Table.vue.d.ts +161 -130
- package/types/containers/Tabs.vue.d.ts +97 -50
- package/types/fields/Cascader.vue.d.ts +95 -71
- package/types/fields/Checkbox.vue.d.ts +95 -56
- package/types/fields/CheckboxGroup.vue.d.ts +95 -53
- package/types/fields/ColorPicker.vue.d.ts +1 -3
- package/types/fields/Date.vue.d.ts +95 -54
- package/types/fields/DateTime.vue.d.ts +95 -54
- package/types/fields/Daterange.vue.d.ts +1 -3
- package/types/fields/Display.vue.d.ts +1 -3
- package/types/fields/DynamicField.vue.d.ts +95 -64
- package/types/fields/Hidden.vue.d.ts +1 -3
- package/types/fields/Link.vue.d.ts +60 -657
- package/types/fields/Number.vue.d.ts +99 -56
- package/types/fields/RadioGroup.vue.d.ts +96 -52
- package/types/fields/Select.vue.d.ts +97 -65
- package/types/fields/SelectOptionGroups.vue.d.ts +1 -3
- package/types/fields/SelectOptions.vue.d.ts +1 -3
- package/types/fields/Switch.vue.d.ts +95 -56
- package/types/fields/Text.vue.d.ts +98 -57
- package/types/fields/Textarea.vue.d.ts +100 -60
- package/types/fields/Time.vue.d.ts +95 -55
- package/types/index.d.ts +0 -1
- package/types/schema.d.ts +42 -9
- package/types/utils/form.d.ts +2 -1
- package/dist/tmagic-form.mjs +0 -3925
- package/dist/tmagic-form.mjs.map +0 -1
- package/dist/tmagic-form.umd.js +0 -3965
- package/dist/tmagic-form.umd.js.map +0 -1
- package/src/utils/fieldProps.ts +0 -39
- package/types/utils/fieldProps.d.ts +0 -21
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
2
|
+
<TMagicOptionGroup v-for="(group, index) in options" :key="index" :label="group.label" :disabled="group.disabled">
|
|
3
|
+
<component
|
|
4
4
|
v-for="(item, index) in group.options"
|
|
5
|
+
:is="uiComponent.component"
|
|
5
6
|
:key="index"
|
|
6
|
-
:label="item.label"
|
|
7
|
+
:label="item.label || item.text"
|
|
7
8
|
:value="item.value"
|
|
8
9
|
:disabled="item.disabled"
|
|
9
10
|
>
|
|
10
|
-
</
|
|
11
|
-
</
|
|
11
|
+
</component>
|
|
12
|
+
</TMagicOptionGroup>
|
|
12
13
|
</template>
|
|
13
14
|
|
|
14
|
-
<script lang="ts" setup>
|
|
15
|
+
<script lang="ts" setup name="MFormSelectOptionGroups">
|
|
16
|
+
import { getConfig, TMagicOptionGroup } from '@tmagic/design';
|
|
17
|
+
|
|
15
18
|
import { SelectGroupOption } from '../schema';
|
|
16
19
|
|
|
17
20
|
defineProps<{
|
|
18
21
|
options: SelectGroupOption[];
|
|
19
22
|
}>();
|
|
23
|
+
|
|
24
|
+
const uiComponent = getConfig('components').option;
|
|
20
25
|
</script>
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<TMagicOption
|
|
3
3
|
v-for="option in options"
|
|
4
4
|
:label="option.text"
|
|
5
5
|
:value="option.value"
|
|
6
6
|
:key="valueKey ? option.value[valueKey] : option.value"
|
|
7
7
|
:disabled="option.disabled"
|
|
8
|
-
></
|
|
8
|
+
></TMagicOption>
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
|
-
<script lang="ts" setup>
|
|
11
|
+
<script lang="ts" setup name="MFormSelectOptions">
|
|
12
|
+
import { TMagicOption } from '@tmagic/design';
|
|
13
|
+
|
|
12
14
|
import { SelectOption } from '../schema';
|
|
13
15
|
|
|
14
16
|
defineProps<{
|
package/src/fields/Switch.vue
CHANGED
|
@@ -1,65 +1,62 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
v-
|
|
4
|
-
v-model="model[n]"
|
|
2
|
+
<TMagicSwitch
|
|
3
|
+
v-model="model[name]"
|
|
5
4
|
:size="size"
|
|
6
5
|
:activeValue="activeValue"
|
|
7
6
|
:inactiveValue="inactiveValue"
|
|
8
7
|
:disabled="disabled"
|
|
9
8
|
@change="changeHandler"
|
|
10
|
-
></
|
|
9
|
+
></TMagicSwitch>
|
|
11
10
|
</template>
|
|
12
11
|
|
|
13
|
-
<script lang="ts">
|
|
14
|
-
import { computed
|
|
12
|
+
<script lang="ts" setup name="MFormSwitch">
|
|
13
|
+
import { computed } from 'vue';
|
|
14
|
+
|
|
15
|
+
import { TMagicSwitch } from '@tmagic/design';
|
|
15
16
|
|
|
16
17
|
import { SwitchConfig } from '../schema';
|
|
17
|
-
import fieldProps from '../utils/fieldProps';
|
|
18
18
|
import { useAddField } from '../utils/useAddField';
|
|
19
|
-
export default defineComponent({
|
|
20
|
-
name: 'm-fields-switch',
|
|
21
|
-
|
|
22
|
-
props: {
|
|
23
|
-
...fieldProps,
|
|
24
|
-
config: {
|
|
25
|
-
type: Object as PropType<SwitchConfig>,
|
|
26
|
-
required: true,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
emits: ['change'],
|
|
31
19
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
const props = defineProps<{
|
|
21
|
+
config: SwitchConfig;
|
|
22
|
+
model: any;
|
|
23
|
+
initValues?: any;
|
|
24
|
+
values?: any;
|
|
25
|
+
name: string;
|
|
26
|
+
prop: string;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
size: 'mini' | 'small' | 'medium';
|
|
29
|
+
}>();
|
|
30
|
+
|
|
31
|
+
const emit = defineEmits(['change']);
|
|
32
|
+
|
|
33
|
+
useAddField(props.prop);
|
|
34
|
+
|
|
35
|
+
const changeHandler = (value: number) => {
|
|
36
|
+
emit('change', value);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const activeValue = computed(() => {
|
|
40
|
+
if (typeof props.config.activeValue === 'undefined') {
|
|
41
|
+
if (props.config.filter === 'number') {
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
return props.config.activeValue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return true;
|
|
49
|
+
});
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return props.config.inactiveValue;
|
|
55
|
-
}
|
|
51
|
+
const inactiveValue = computed(() => {
|
|
52
|
+
if (typeof props.config.inactiveValue === 'undefined') {
|
|
53
|
+
if (props.config.filter === 'number') {
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
return props.config.inactiveValue;
|
|
58
|
+
}
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
}),
|
|
59
|
-
changeHandler: (v: boolean | number | string) => {
|
|
60
|
-
emit('change', v);
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
},
|
|
60
|
+
return false;
|
|
64
61
|
});
|
|
65
62
|
</script>
|
package/src/fields/Text.vue
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
v-model="model[
|
|
2
|
+
<TMagicInput
|
|
3
|
+
v-model="model[name]"
|
|
4
4
|
clearable
|
|
5
5
|
:size="size"
|
|
6
6
|
:placeholder="config.placeholder"
|
|
@@ -20,117 +20,109 @@
|
|
|
20
20
|
{{ config.append.text }}
|
|
21
21
|
</el-button>
|
|
22
22
|
</template>
|
|
23
|
-
</
|
|
23
|
+
</TMagicInput>
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
|
-
<script lang="ts">
|
|
27
|
-
import {
|
|
26
|
+
<script lang="ts" setup name="MFormText">
|
|
27
|
+
import { inject } from 'vue';
|
|
28
28
|
|
|
29
|
+
import { TMagicInput } from '@tmagic/design';
|
|
29
30
|
import { isNumber } from '@tmagic/utils';
|
|
30
31
|
|
|
31
32
|
import { FormState, TextConfig } from '../schema';
|
|
32
|
-
import fieldProps from '../utils/fieldProps';
|
|
33
33
|
import { useAddField } from '../utils/useAddField';
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
props.model[modelName.value] = `${num}${unit || ''}`;
|
|
131
|
-
emit('change', props.model[modelName.value]);
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
},
|
|
135
|
-
});
|
|
35
|
+
const props = defineProps<{
|
|
36
|
+
config: TextConfig;
|
|
37
|
+
model: any;
|
|
38
|
+
initValues?: any;
|
|
39
|
+
values?: any;
|
|
40
|
+
name: string;
|
|
41
|
+
prop: string;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
size: 'mini' | 'small' | 'medium';
|
|
44
|
+
}>();
|
|
45
|
+
|
|
46
|
+
const emit = defineEmits(['change', 'input']);
|
|
47
|
+
|
|
48
|
+
useAddField(props.prop);
|
|
49
|
+
|
|
50
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
51
|
+
|
|
52
|
+
const changeHandler = (value: number) => {
|
|
53
|
+
emit('change', value);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const inputHandler = (v: string) => {
|
|
57
|
+
emit('input', v);
|
|
58
|
+
mForm?.$emit('field-input', props.prop, v);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const buttonClickHandler = () => {
|
|
62
|
+
if (typeof props.config.append === 'string') return;
|
|
63
|
+
|
|
64
|
+
if (props.config.append?.handler) {
|
|
65
|
+
props.config.append.handler(mForm, {
|
|
66
|
+
model: props.model,
|
|
67
|
+
values: mForm?.values,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const keyUpHandler = ($event: KeyboardEvent) => {
|
|
73
|
+
if (!props.model) return;
|
|
74
|
+
if (!props.name) return;
|
|
75
|
+
|
|
76
|
+
const arrowUp = $event.key === 'ArrowUp';
|
|
77
|
+
const arrowDown = $event.key === 'ArrowDown';
|
|
78
|
+
|
|
79
|
+
if (!arrowUp && !arrowDown) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const value = props.model[props.name];
|
|
84
|
+
let num;
|
|
85
|
+
let unit;
|
|
86
|
+
if (isNumber(value)) {
|
|
87
|
+
num = +value;
|
|
88
|
+
} else {
|
|
89
|
+
value.replace(/^([0-9.]+)([a-z%]+)$/, ($0: string, $1: string, $2: string) => {
|
|
90
|
+
num = +$1;
|
|
91
|
+
unit = $2;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (num === undefined) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const ctrl = navigator.platform.match('Mac') ? $event.metaKey : $event.ctrlKey;
|
|
100
|
+
const shift = $event.shiftKey;
|
|
101
|
+
const alt = $event.altKey;
|
|
102
|
+
|
|
103
|
+
if (arrowUp) {
|
|
104
|
+
if (ctrl) {
|
|
105
|
+
num += 100;
|
|
106
|
+
} else if (alt) {
|
|
107
|
+
num = (num * 10000 + 1000) / 10000;
|
|
108
|
+
} else if (shift) {
|
|
109
|
+
num = num + 10;
|
|
110
|
+
} else {
|
|
111
|
+
num += 1;
|
|
112
|
+
}
|
|
113
|
+
} else if (arrowDown) {
|
|
114
|
+
if (ctrl) {
|
|
115
|
+
num -= 100;
|
|
116
|
+
} else if (alt) {
|
|
117
|
+
num = (num * 10000 - 1000) / 10000;
|
|
118
|
+
} else if (shift) {
|
|
119
|
+
num -= 10;
|
|
120
|
+
} else {
|
|
121
|
+
num -= 1;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
props.model[props.name] = `${num}${unit || ''}`;
|
|
126
|
+
emit('change', props.model[props.name]);
|
|
127
|
+
};
|
|
136
128
|
</script>
|
package/src/fields/Textarea.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<TMagicInput
|
|
3
3
|
v-model="model[name]"
|
|
4
4
|
type="textarea"
|
|
5
5
|
:size="size"
|
|
@@ -9,52 +9,40 @@
|
|
|
9
9
|
@change="changeHandler"
|
|
10
10
|
@input="inputHandler"
|
|
11
11
|
>
|
|
12
|
-
</
|
|
12
|
+
</TMagicInput>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
|
-
<script lang="ts">
|
|
16
|
-
import {
|
|
15
|
+
<script lang="ts" setup name="MFormTextarea">
|
|
16
|
+
import { inject } from 'vue';
|
|
17
|
+
|
|
18
|
+
import { TMagicInput } from '@tmagic/design';
|
|
17
19
|
|
|
18
20
|
import { FormState, TextareaConfig } from '../schema';
|
|
19
|
-
import fieldProps from '../utils/fieldProps';
|
|
20
21
|
import { useAddField } from '../utils/useAddField';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
mForm,
|
|
49
|
-
changeHandler: (v: string) => {
|
|
50
|
-
emit('change', v);
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
inputHandler: (v: string) => {
|
|
54
|
-
emit('input', v);
|
|
55
|
-
mForm?.$emit('field-input', props.prop, v);
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
});
|
|
22
|
+
|
|
23
|
+
const props = defineProps<{
|
|
24
|
+
config: TextareaConfig;
|
|
25
|
+
model: any;
|
|
26
|
+
initValues?: any;
|
|
27
|
+
values?: any;
|
|
28
|
+
name: string;
|
|
29
|
+
prop: string;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
size: 'mini' | 'small' | 'medium';
|
|
32
|
+
}>();
|
|
33
|
+
|
|
34
|
+
const emit = defineEmits(['change', 'input']);
|
|
35
|
+
|
|
36
|
+
useAddField(props.prop);
|
|
37
|
+
|
|
38
|
+
const mForm = inject<FormState | null>('mForm');
|
|
39
|
+
|
|
40
|
+
const changeHandler = (value: number) => {
|
|
41
|
+
emit('change', value);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const inputHandler = (v: string) => {
|
|
45
|
+
emit('input', v);
|
|
46
|
+
mForm?.$emit('field-input', props.prop, v);
|
|
47
|
+
};
|
|
60
48
|
</script>
|
package/src/fields/Time.vue
CHANGED
|
@@ -1,46 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<TMagicTimePicker
|
|
3
3
|
v-model="model[name]"
|
|
4
|
+
:value-format="config.valueFormat || 'HH:mm:ss'"
|
|
5
|
+
:format="config.format || 'HH:mm:ss'"
|
|
4
6
|
:size="size"
|
|
5
|
-
value-format="HH:mm:ss"
|
|
6
7
|
:placeholder="config.placeholder"
|
|
7
8
|
:disabled="disabled"
|
|
8
9
|
@change="changeHandler"
|
|
9
|
-
></
|
|
10
|
+
></TMagicTimePicker>
|
|
10
11
|
</template>
|
|
11
12
|
|
|
12
|
-
<script lang="ts">
|
|
13
|
-
import {
|
|
13
|
+
<script lang="ts" setup name="MFormTime">
|
|
14
|
+
import { TMagicTimePicker } from '@tmagic/design';
|
|
14
15
|
|
|
15
16
|
import { TimeConfig } from '../schema';
|
|
16
|
-
import fieldProps from '../utils/fieldProps';
|
|
17
17
|
import { useAddField } from '../utils/useAddField';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const props = defineProps<{
|
|
20
|
+
config: TimeConfig;
|
|
21
|
+
model: any;
|
|
22
|
+
initValues?: any;
|
|
23
|
+
values?: any;
|
|
24
|
+
name: string;
|
|
25
|
+
prop: string;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
size: 'mini' | 'small' | 'medium';
|
|
28
|
+
}>();
|
|
21
29
|
|
|
22
|
-
|
|
23
|
-
...fieldProps,
|
|
24
|
-
config: {
|
|
25
|
-
type: Object as PropType<TimeConfig>,
|
|
26
|
-
required: true,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
30
|
+
const emit = defineEmits(['change']);
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
change(values: Date) {
|
|
32
|
-
return values;
|
|
33
|
-
},
|
|
34
|
-
},
|
|
32
|
+
useAddField(props.prop);
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
changeHandler: (v: Date) => {
|
|
41
|
-
emit('change', v);
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
});
|
|
34
|
+
const changeHandler = (v: string) => {
|
|
35
|
+
emit('change', v);
|
|
36
|
+
};
|
|
46
37
|
</script>
|
package/src/index.ts
CHANGED
|
@@ -53,7 +53,6 @@ import './theme/index.scss';
|
|
|
53
53
|
export * from './schema';
|
|
54
54
|
export * from './utils/form';
|
|
55
55
|
export * from './utils/useAddField';
|
|
56
|
-
export { default as fieldProps } from './utils/fieldProps';
|
|
57
56
|
|
|
58
57
|
export { default as MForm } from './Form.vue';
|
|
59
58
|
export { default as MFormDialog } from './FormDialog.vue';
|
|
@@ -92,34 +91,34 @@ const install = (app: App, opt: any) => {
|
|
|
92
91
|
app.config.globalProperties.$MAGIC_FORM = option;
|
|
93
92
|
setConfig(option);
|
|
94
93
|
|
|
95
|
-
app.component(
|
|
96
|
-
app.component(
|
|
97
|
-
app.component(
|
|
94
|
+
app.component('m-form', Form);
|
|
95
|
+
app.component('m-form-dialog', FormDialog);
|
|
96
|
+
app.component('m-form-container', Container);
|
|
98
97
|
app.component('m-form-fieldset', Fieldset);
|
|
99
|
-
app.component(
|
|
100
|
-
app.component(
|
|
101
|
-
app.component(
|
|
102
|
-
app.component(
|
|
98
|
+
app.component('m-form-group-list', GroupList);
|
|
99
|
+
app.component('m-form-panel', Panel);
|
|
100
|
+
app.component('m-form-row', Row);
|
|
101
|
+
app.component('m-form-step', MStep);
|
|
103
102
|
app.component('m-form-table', Table);
|
|
104
|
-
app.component(
|
|
105
|
-
app.component(
|
|
106
|
-
app.component(
|
|
107
|
-
app.component(
|
|
103
|
+
app.component('m-form-tab', Tabs);
|
|
104
|
+
app.component('m-fields-text', Text);
|
|
105
|
+
app.component('m-fields-number', Number);
|
|
106
|
+
app.component('m-fields-textarea', Textarea);
|
|
108
107
|
app.component('m-fields-hidden', Hidden);
|
|
109
|
-
app.component(
|
|
110
|
-
app.component(
|
|
111
|
-
app.component(Time.name, Time);
|
|
112
|
-
app.component(Checkbox.name, Checkbox);
|
|
113
|
-
app.component(Switch.name, Switch);
|
|
108
|
+
app.component('m-fields-date', Date);
|
|
109
|
+
app.component('m-fields-datetime', DateTime);
|
|
114
110
|
app.component('m-fields-daterange', Daterange);
|
|
111
|
+
app.component('m-fields-time', Time);
|
|
112
|
+
app.component('m-fields-checkbox', Checkbox);
|
|
113
|
+
app.component('m-fields-switch', Switch);
|
|
115
114
|
app.component('m-fields-color-picker', ColorPicker);
|
|
116
|
-
app.component(
|
|
117
|
-
app.component(
|
|
115
|
+
app.component('m-fields-checkbox-group', CheckboxGroup);
|
|
116
|
+
app.component('m-fields-radio-group', RadioGroup);
|
|
118
117
|
app.component('m-fields-display', Display);
|
|
119
|
-
app.component(
|
|
120
|
-
app.component(
|
|
121
|
-
app.component(
|
|
122
|
-
app.component(
|
|
118
|
+
app.component('m-fields-link', Link);
|
|
119
|
+
app.component('m-fields-select', Select);
|
|
120
|
+
app.component('m-fields-cascader', Cascader);
|
|
121
|
+
app.component('m-fields-dynamic-field', DynamicField);
|
|
123
122
|
};
|
|
124
123
|
|
|
125
124
|
export default {
|