@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
package/src/containers/Row.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
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
|
-
</
|
|
16
|
+
</TMagicRow>
|
|
16
17
|
</template>
|
|
17
18
|
|
|
18
|
-
<script lang="ts">
|
|
19
|
-
import {
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
54
|
-
const mForm = inject<FormState | undefined>('mForm');
|
|
39
|
+
const emit = defineEmits(['change']);
|
|
55
40
|
|
|
56
|
-
|
|
41
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
57
42
|
|
|
58
|
-
|
|
59
|
-
mForm,
|
|
60
|
-
changeHandler,
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
});
|
|
43
|
+
const changeHandler = () => emit('change', props.name ? props.model[props.name] : props.model);
|
|
64
44
|
</script>
|
package/src/containers/Step.vue
CHANGED
|
@@ -1,82 +1,72 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<
|
|
4
|
-
<
|
|
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
|
-
></
|
|
11
|
-
</
|
|
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
|
-
<
|
|
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
|
-
></
|
|
26
|
+
></Container>
|
|
26
27
|
</template>
|
|
27
28
|
</template>
|
|
28
29
|
</div>
|
|
29
30
|
</template>
|
|
30
31
|
|
|
31
|
-
<script lang="ts">
|
|
32
|
-
import {
|
|
32
|
+
<script setup lang="ts" name="MFormStep">
|
|
33
|
+
import { inject, ref, watchEffect } from 'vue';
|
|
33
34
|
|
|
34
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
39
|
+
import Container from './Container.vue';
|
|
56
40
|
|
|
57
|
-
|
|
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
|
-
|
|
55
|
+
const emit = defineEmits(['change']);
|
|
61
56
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const active = ref(1);
|
|
57
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
58
|
+
const active = ref(1);
|
|
65
59
|
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
64
|
+
const stepClick = (index: number) => {
|
|
65
|
+
active.value = index + 1;
|
|
66
|
+
mForm?.$emit('update:stepActive', active.value);
|
|
67
|
+
};
|
|
78
68
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
69
|
+
const changeHandler = () => {
|
|
70
|
+
emit('change', props.model);
|
|
71
|
+
};
|
|
82
72
|
</script>
|