@tmagic/form 1.2.13 → 1.2.15
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 +2 -2
- package/dist/tmagic-form.js +103 -108
- package/dist/tmagic-form.js.map +1 -1
- package/dist/tmagic-form.umd.cjs +103 -113
- package/dist/tmagic-form.umd.cjs.map +1 -1
- package/package.json +7 -7
- package/src/containers/Fieldset.vue +2 -9
- package/src/containers/Table.vue +1 -1
- package/src/containers/Tabs.vue +65 -60
- package/src/fields/Select.vue +2 -2
- package/src/fields/Text.vue +3 -3
- package/src/schema.ts +1 -0
- package/types/Form.vue.d.ts +5 -5
- package/types/FormDialog.vue.d.ts +41 -743
- package/types/containers/Col.vue.d.ts +2 -2
- package/types/containers/Container.vue.d.ts +3 -3
- package/types/containers/Fieldset.vue.d.ts +3 -3
- package/types/containers/GroupList.vue.d.ts +2 -2
- package/types/containers/GroupListItem.vue.d.ts +2 -2
- package/types/containers/Panel.vue.d.ts +22 -90
- package/types/containers/Row.vue.d.ts +2 -2
- package/types/containers/Step.vue.d.ts +3 -3
- package/types/containers/Table.vue.d.ts +42 -155
- package/types/containers/Tabs.vue.d.ts +3 -3
- package/types/fields/Cascader.vue.d.ts +4 -4
- package/types/fields/Checkbox.vue.d.ts +4 -4
- package/types/fields/CheckboxGroup.vue.d.ts +4 -4
- package/types/fields/ColorPicker.vue.d.ts +4 -4
- package/types/fields/Date.vue.d.ts +4 -4
- package/types/fields/DateTime.vue.d.ts +4 -4
- package/types/fields/Daterange.vue.d.ts +4 -4
- package/types/fields/Display.vue.d.ts +2 -2
- package/types/fields/DynamicField.vue.d.ts +4 -4
- package/types/fields/Hidden.vue.d.ts +2 -2
- package/types/fields/Link.vue.d.ts +4 -4
- package/types/fields/Number.vue.d.ts +4 -4
- package/types/fields/RadioGroup.vue.d.ts +4 -4
- package/types/fields/Select.vue.d.ts +4 -4
- package/types/fields/SelectOptionGroups.vue.d.ts +2 -2
- package/types/fields/SelectOptions.vue.d.ts +2 -2
- package/types/fields/Switch.vue.d.ts +4 -4
- package/types/fields/Text.vue.d.ts +4 -4
- package/types/fields/Textarea.vue.d.ts +4 -4
- package/types/fields/Time.vue.d.ts +4 -4
- package/types/schema.d.ts +15 -14
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.
|
|
2
|
+
"version": "1.2.15",
|
|
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.2.
|
|
40
|
-
"@tmagic/utils": "1.2.
|
|
39
|
+
"@tmagic/design": "1.2.15",
|
|
40
|
+
"@tmagic/utils": "1.2.15",
|
|
41
41
|
"lodash-es": "^4.17.21",
|
|
42
42
|
"sortablejs": "^1.14.0",
|
|
43
43
|
"vue": "^3.2.37"
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"@types/lodash-es": "^4.17.4",
|
|
51
51
|
"@types/node": "^15.12.4",
|
|
52
52
|
"@types/sortablejs": "^1.10.7",
|
|
53
|
-
"@vitejs/plugin-vue": "^
|
|
53
|
+
"@vitejs/plugin-vue": "^4.1.0",
|
|
54
54
|
"@vue/compiler-sfc": "^3.2.37",
|
|
55
55
|
"@vue/test-utils": "^2.0.0",
|
|
56
56
|
"rimraf": "^3.0.2",
|
|
57
57
|
"sass": "^1.35.1",
|
|
58
|
-
"typescript": "^
|
|
59
|
-
"vite": "^
|
|
58
|
+
"typescript": "^5.0.4",
|
|
59
|
+
"vite": "^4.2.1",
|
|
60
60
|
"vite-plugin-vue-setup-extend": "^0.4.0",
|
|
61
|
-
"vue-tsc": "^1.0
|
|
61
|
+
"vue-tsc": "^1.2.0"
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
:prop="`${prop}${prop ? '.' : ''}${config.name}.value`"
|
|
11
11
|
:true-label="1"
|
|
12
12
|
:false-label="0"
|
|
13
|
+
@update:modelValue="change"
|
|
13
14
|
><span v-html="config.legend"></span><span v-if="config.extra" v-html="config.extra" class="m-form-tip"></span
|
|
14
15
|
></TMagicCheckbox>
|
|
15
16
|
</component>
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
</template>
|
|
62
63
|
|
|
63
64
|
<script lang="ts" setup name="MFormFieldset">
|
|
64
|
-
import { computed, inject
|
|
65
|
+
import { computed, inject } from 'vue';
|
|
65
66
|
|
|
66
67
|
import { TMagicCheckbox } from '@tmagic/design';
|
|
67
68
|
|
|
@@ -115,13 +116,5 @@ const change = () => {
|
|
|
115
116
|
|
|
116
117
|
const key = (item: any, index: number) => item[mForm?.keyProp || '__key'] ?? index;
|
|
117
118
|
|
|
118
|
-
if (props.config.checkbox && name.value) {
|
|
119
|
-
watch(
|
|
120
|
-
() => props.model[name.value]?.value,
|
|
121
|
-
() => {
|
|
122
|
-
emit('change', props.model);
|
|
123
|
-
},
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
119
|
const onAddDiffCount = () => emit('addDiffCount');
|
|
127
120
|
</script>
|
package/src/containers/Table.vue
CHANGED
package/src/containers/Tabs.vue
CHANGED
|
@@ -1,71 +1,77 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<component
|
|
3
3
|
v-model="activeTabName"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
v-bind="
|
|
5
|
+
tabsComponent.props({
|
|
6
|
+
type: config.tabType,
|
|
7
|
+
editable: config.editable || false,
|
|
8
|
+
tabPosition: config.tabPosition || 'top',
|
|
9
|
+
})
|
|
10
|
+
"
|
|
11
|
+
:is="tabsComponent.component"
|
|
12
|
+
:class="`tmagic-design-tabs ${config.dynamic ? 'magic-form-dynamic-tab' : 'magic-form-tab'}`"
|
|
8
13
|
@tab-click="tabClickHandler"
|
|
9
14
|
@tab-add="onTabAdd"
|
|
10
15
|
@tab-remove="onTabRemove"
|
|
11
16
|
>
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
17
|
+
<component
|
|
18
|
+
v-for="(tab, tabIndex) in tabs"
|
|
19
|
+
:is="tabPaneComponent.component"
|
|
20
|
+
:key="tab[mForm?.keyProp || '__key'] ?? tabIndex"
|
|
21
|
+
v-bind="tabPaneComponent.props({ name: filter(tab.status) || tabIndex.toString(), lazy: tab.lazy || false })"
|
|
22
|
+
>
|
|
23
|
+
<template #label>
|
|
24
|
+
<span>
|
|
25
|
+
{{ filter(tab.title)
|
|
26
|
+
}}<TMagicBadge
|
|
27
|
+
:hidden="!diffCount[tabIndex]"
|
|
28
|
+
:value="diffCount[tabIndex]"
|
|
29
|
+
class="diff-count-badge"
|
|
30
|
+
></TMagicBadge>
|
|
31
|
+
</span>
|
|
32
|
+
</template>
|
|
33
|
+
<Container
|
|
34
|
+
v-for="item in tabItems(tab)"
|
|
35
|
+
:key="item[mForm?.keyProp || '__key']"
|
|
36
|
+
:config="item"
|
|
37
|
+
:disabled="disabled"
|
|
38
|
+
:model="
|
|
39
|
+
config.dynamic
|
|
40
|
+
? (name ? model[name] : model)[tabIndex]
|
|
41
|
+
: tab.name
|
|
42
|
+
? (name ? model[name] : model)[tab.name]
|
|
43
|
+
: name
|
|
44
|
+
? model[name]
|
|
45
|
+
: model
|
|
46
|
+
"
|
|
47
|
+
:last-values="
|
|
48
|
+
isEmpty(lastValues)
|
|
49
|
+
? {}
|
|
50
|
+
: config.dynamic
|
|
51
|
+
? (name ? lastValues[name] : lastValues)[tabIndex]
|
|
52
|
+
: tab.name
|
|
53
|
+
? (name ? lastValues[name] : lastValues)[tab.name]
|
|
54
|
+
: name
|
|
55
|
+
? lastValues[name]
|
|
56
|
+
: lastValues
|
|
57
|
+
"
|
|
58
|
+
:is-compare="isCompare"
|
|
59
|
+
:prop="config.dynamic ? `${prop}${prop ? '.' : ''}${String(tabIndex)}` : prop"
|
|
60
|
+
:size="size"
|
|
61
|
+
:label-width="tab.labelWidth || labelWidth"
|
|
62
|
+
:expand-more="expandMore"
|
|
63
|
+
@change="changeHandler"
|
|
64
|
+
@addDiffCount="onAddDiffCount(tabIndex)"
|
|
65
|
+
></Container>
|
|
66
|
+
</component>
|
|
67
|
+
</component>
|
|
62
68
|
</template>
|
|
63
69
|
|
|
64
70
|
<script setup lang="ts" name="MFormTabs">
|
|
65
71
|
import { computed, inject, ref, watchEffect } from 'vue';
|
|
66
72
|
import { cloneDeep, isEmpty } from 'lodash-es';
|
|
67
73
|
|
|
68
|
-
import { getConfig,
|
|
74
|
+
import { getConfig, TMagicBadge } from '@tmagic/design';
|
|
69
75
|
|
|
70
76
|
import { FormState, TabConfig, TabPaneConfig } from '../schema';
|
|
71
77
|
import { display as displayFunc, filterFunction } from '../utils/form';
|
|
@@ -76,7 +82,8 @@ type DiffCount = {
|
|
|
76
82
|
[tabIndex: number]: number;
|
|
77
83
|
};
|
|
78
84
|
|
|
79
|
-
const
|
|
85
|
+
const tabPaneComponent = getConfig('components').tabPane;
|
|
86
|
+
const tabsComponent = getConfig('components').tabs;
|
|
80
87
|
|
|
81
88
|
const getActive = (mForm: FormState | undefined, props: any, activeTabName: string) => {
|
|
82
89
|
const { config, model, prop } = props;
|
|
@@ -135,7 +142,7 @@ const tabs = computed(() => {
|
|
|
135
142
|
if (!props.config.name) throw new Error('dynamic tab 必须配置name');
|
|
136
143
|
return props.model[props.config.name] || [];
|
|
137
144
|
}
|
|
138
|
-
return props.config.items;
|
|
145
|
+
return props.config.items.filter((item) => displayFunc(mForm, item.display, props));
|
|
139
146
|
});
|
|
140
147
|
|
|
141
148
|
const filter = (config: any) => filterFunction(mForm, config, props);
|
|
@@ -193,8 +200,6 @@ const onTabRemove = (tabName: string) => {
|
|
|
193
200
|
mForm?.$emit('field-change', props.prop, props.model[props.config.name]);
|
|
194
201
|
};
|
|
195
202
|
|
|
196
|
-
const display = (displayConfig: any) => displayFunc(mForm, displayConfig, props);
|
|
197
|
-
|
|
198
203
|
const changeHandler = () => {
|
|
199
204
|
emit('change', props.model);
|
|
200
205
|
if (typeof props.config.onChange === 'function') {
|
package/src/fields/Select.vue
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
v-loading="loading"
|
|
6
6
|
class="m-select"
|
|
7
7
|
ref="tMagicSelect"
|
|
8
|
-
clearable
|
|
9
|
-
filterable
|
|
8
|
+
:clearable="typeof config.clearable !== 'undefined' ? config.clearable : true"
|
|
9
|
+
:filterable="typeof config.filterable !== 'undefined' ? config.filterable : true"
|
|
10
10
|
:popper-class="`m-select-popper ${popperClass}`"
|
|
11
11
|
:size="size"
|
|
12
12
|
:remote="remote"
|
package/src/fields/Text.vue
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
>
|
|
12
12
|
<template #append v-if="config.append">
|
|
13
13
|
<span v-if="typeof config.append === 'string'">{{ config.append }}</span>
|
|
14
|
-
<
|
|
14
|
+
<TMagicButton
|
|
15
15
|
v-if="typeof config.append === 'object' && config.append.type === 'button'"
|
|
16
16
|
style="color: #409eff"
|
|
17
17
|
:size="size"
|
|
18
18
|
@click.prevent="buttonClickHandler"
|
|
19
19
|
>
|
|
20
20
|
{{ config.append.text }}
|
|
21
|
-
</
|
|
21
|
+
</TMagicButton>
|
|
22
22
|
</template>
|
|
23
23
|
</TMagicInput>
|
|
24
24
|
</template>
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
<script lang="ts" setup name="MFormText">
|
|
27
27
|
import { inject } from 'vue';
|
|
28
28
|
|
|
29
|
-
import { TMagicInput } from '@tmagic/design';
|
|
29
|
+
import { TMagicButton, TMagicInput } from '@tmagic/design';
|
|
30
30
|
import { isNumber } from '@tmagic/utils';
|
|
31
31
|
|
|
32
32
|
import { FormState, TextConfig } from '../schema';
|
package/src/schema.ts
CHANGED
|
@@ -432,6 +432,7 @@ export interface SelectConfig extends FormItem, Input {
|
|
|
432
432
|
multiple?: boolean;
|
|
433
433
|
valueKey?: string;
|
|
434
434
|
allowCreate?: boolean;
|
|
435
|
+
filterable?: boolean;
|
|
435
436
|
group?: boolean;
|
|
436
437
|
options: SelectConfigOption[] | SelectConfigGroupOption[] | SelectOptionFunction;
|
|
437
438
|
remote: true;
|
package/types/Form.vue.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
13
13
|
disabled?: boolean | undefined;
|
|
14
14
|
height?: string | undefined;
|
|
15
15
|
stepActive?: string | number | undefined;
|
|
16
|
-
size?: "
|
|
16
|
+
size?: "default" | "small" | "large" | undefined;
|
|
17
17
|
inline?: boolean | undefined;
|
|
18
18
|
labelPosition?: string | undefined;
|
|
19
19
|
keyProp?: string | undefined;
|
|
@@ -53,7 +53,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
53
53
|
disabled?: boolean | undefined;
|
|
54
54
|
height?: string | undefined;
|
|
55
55
|
stepActive?: string | number | undefined;
|
|
56
|
-
size?: "
|
|
56
|
+
size?: "default" | "small" | "large" | undefined;
|
|
57
57
|
inline?: boolean | undefined;
|
|
58
58
|
labelPosition?: string | undefined;
|
|
59
59
|
keyProp?: string | undefined;
|
|
@@ -90,8 +90,8 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
90
90
|
labelPosition: string;
|
|
91
91
|
}>;
|
|
92
92
|
export default _default;
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
94
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
95
95
|
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
96
96
|
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
97
97
|
} : {
|
|
@@ -99,7 +99,7 @@ declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
|
99
99
|
required: true;
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
|
-
|
|
102
|
+
type __VLS_WithDefaults<P, D> = {
|
|
103
103
|
[K in keyof Pick<P, keyof P>]: K extends keyof D ? P[K] & {
|
|
104
104
|
default: D[K];
|
|
105
105
|
} : P[K];
|