@tmagic/form 1.3.9 → 1.3.11
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 +11 -0
- package/dist/tmagic-form.js +156 -84
- package/dist/tmagic-form.umd.cjs +155 -82
- package/package.json +3 -3
- package/src/containers/Container.vue +2 -1
- package/src/containers/GroupListItem.vue +4 -4
- package/src/containers/Panel.vue +1 -1
- package/src/containers/Table.vue +11 -5
- package/src/fields/Link.vue +1 -1
- package/src/fields/Text.vue +69 -25
- package/src/index.ts +5 -0
- package/src/schema.ts +2 -1
- package/src/theme/index.scss +1 -0
- package/src/theme/table.scss +4 -0
- package/src/theme/text.scss +6 -0
- package/types/index.d.ts +2 -0
- package/types/schema.d.ts +2 -1
- package/dist/tmagic-form.js.map +0 -1
- package/dist/tmagic-form.umd.cjs.map +0 -1
- package/src/utils/createForm.ts +0 -25
- package/types/utils/createForm.d.ts +0 -3
package/src/containers/Table.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div>
|
|
2
|
+
<div class="m-fields-table-wrap">
|
|
3
3
|
<teleport to="body" :disabled="!isFullscreen">
|
|
4
4
|
<div ref="mTable" class="m-fields-table" :class="{ 'm-fields-table-item-extra': config.itemExtra }">
|
|
5
5
|
<span v-if="config.extra" style="color: rgba(0, 0, 0, 0.45)" v-html="config.extra"></span>
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
type="primary"
|
|
55
55
|
:icon="ArrowUp"
|
|
56
56
|
:disabled="disabled"
|
|
57
|
-
|
|
57
|
+
link
|
|
58
58
|
@click="upHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
59
59
|
@dblclick="topHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
60
60
|
></TMagicButton>
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
type="primary"
|
|
71
71
|
:icon="ArrowDown"
|
|
72
72
|
:disabled="disabled"
|
|
73
|
-
|
|
73
|
+
link
|
|
74
74
|
@click="downHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
75
75
|
@dblclick="bottomHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
76
76
|
></TMagicButton>
|
|
@@ -202,6 +202,7 @@ import {
|
|
|
202
202
|
TMagicTableColumn,
|
|
203
203
|
TMagicTooltip,
|
|
204
204
|
TMagicUpload,
|
|
205
|
+
useZIndex,
|
|
205
206
|
} from '@tmagic/design';
|
|
206
207
|
import { asyncLoadJs, sleep } from '@tmagic/utils';
|
|
207
208
|
|
|
@@ -246,6 +247,8 @@ const emit = defineEmits(['change', 'select', 'addDiffCount']);
|
|
|
246
247
|
let timer: any | null = null;
|
|
247
248
|
const mForm = inject<FormState | undefined>('mForm');
|
|
248
249
|
|
|
250
|
+
const { nextZIndex } = useZIndex();
|
|
251
|
+
|
|
249
252
|
const tMagicTable = ref<InstanceType<typeof TMagicTable>>();
|
|
250
253
|
const excelBtn = ref<InstanceType<typeof TMagicUpload>>();
|
|
251
254
|
const mTable = ref<HTMLDivElement>();
|
|
@@ -620,11 +623,14 @@ const toggleMode = () => {
|
|
|
620
623
|
};
|
|
621
624
|
|
|
622
625
|
const toggleFullscreen = () => {
|
|
626
|
+
if (!mTable.value) return;
|
|
627
|
+
|
|
623
628
|
if (isFullscreen.value) {
|
|
624
|
-
mTable.value
|
|
629
|
+
mTable.value.classList.remove('fixed');
|
|
625
630
|
isFullscreen.value = false;
|
|
626
631
|
} else {
|
|
627
|
-
mTable.value
|
|
632
|
+
mTable.value.classList.add('fixed');
|
|
633
|
+
mTable.value.style.zIndex = `${nextZIndex()}`;
|
|
628
634
|
isFullscreen.value = true;
|
|
629
635
|
}
|
|
630
636
|
};
|
package/src/fields/Link.vue
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<a v-if="config.href && !disabled" target="_blank" :href="href" :style="config.css || {}">{{ displayText }}</a>
|
|
3
3
|
<span v-else-if="config.href && disabled" :style="config.disabledCss || {}">{{ displayText }}</span>
|
|
4
4
|
<div v-else class="m-fields-link">
|
|
5
|
-
<TMagicButton
|
|
5
|
+
<TMagicButton link type="primary" @click="editHandler">点击编辑</TMagicButton>
|
|
6
6
|
<FormDialog
|
|
7
7
|
ref="editor"
|
|
8
8
|
:title="config.formTitle || '编辑扩展配置'"
|
package/src/fields/Text.vue
CHANGED
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
:disabled="disabled"
|
|
8
|
-
@change="changeHandler"
|
|
9
|
-
@input="inputHandler"
|
|
10
|
-
@keyup="keyUpHandler($event)"
|
|
11
|
-
>
|
|
12
|
-
<template #append v-if="config.append">
|
|
13
|
-
<span v-if="typeof config.append === 'string'">{{ config.append }}</span>
|
|
14
|
-
<TMagicButton
|
|
15
|
-
v-if="typeof config.append === 'object' && config.append.type === 'button'"
|
|
16
|
-
style="color: #409eff"
|
|
2
|
+
<TMagicPopover :visible="popoverVisible" width="220px">
|
|
3
|
+
<template #reference>
|
|
4
|
+
<TMagicInput
|
|
5
|
+
v-model="model[name]"
|
|
6
|
+
clearable
|
|
17
7
|
:size="size"
|
|
18
|
-
|
|
8
|
+
:placeholder="config.placeholder"
|
|
9
|
+
:disabled="disabled"
|
|
10
|
+
@change="changeHandler"
|
|
11
|
+
@input="inputHandler"
|
|
12
|
+
@keyup="keyUpHandler($event)"
|
|
19
13
|
>
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
<template #append v-if="appendConfig">
|
|
15
|
+
<TMagicButton
|
|
16
|
+
v-if="appendConfig.type === 'button'"
|
|
17
|
+
style="color: #409eff"
|
|
18
|
+
:size="size"
|
|
19
|
+
@click.prevent="buttonClickHandler"
|
|
20
|
+
>
|
|
21
|
+
{{ appendConfig.text }}
|
|
22
|
+
</TMagicButton>
|
|
23
|
+
</template>
|
|
24
|
+
</TMagicInput>
|
|
22
25
|
</template>
|
|
23
|
-
|
|
26
|
+
|
|
27
|
+
<div class="m-form-item__content">
|
|
28
|
+
<div class="m-form-validate__warning">输入内容前后有空格,是否移除空格?</div>
|
|
29
|
+
<div style="display: flex; justify-content: flex-end">
|
|
30
|
+
<TMagicButton link size="small" @click="popoverVisible = false">保持原样</TMagicButton>
|
|
31
|
+
<TMagicButton type="primary" size="small" @click="confirmTrimHandler">移除空格</TMagicButton>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</TMagicPopover>
|
|
24
35
|
</template>
|
|
25
36
|
|
|
26
37
|
<script lang="ts" setup>
|
|
27
|
-
import { inject } from 'vue';
|
|
38
|
+
import { computed, inject, ref } from 'vue';
|
|
28
39
|
|
|
29
|
-
import { TMagicButton, TMagicInput } from '@tmagic/design';
|
|
40
|
+
import { TMagicButton, TMagicInput, TMagicPopover } from '@tmagic/design';
|
|
30
41
|
import { isNumber } from '@tmagic/utils';
|
|
31
42
|
|
|
32
43
|
import type { FieldProps, FormState, TextConfig } from '../schema';
|
|
@@ -47,20 +58,53 @@ useAddField(props.prop);
|
|
|
47
58
|
|
|
48
59
|
const mForm = inject<FormState | undefined>('mForm');
|
|
49
60
|
|
|
61
|
+
const appendConfig = computed(() => {
|
|
62
|
+
if (typeof props.config.append === 'string') {
|
|
63
|
+
return {
|
|
64
|
+
text: props.config.append,
|
|
65
|
+
type: 'button',
|
|
66
|
+
handler: undefined,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (props.config.append && typeof props.config.append === 'object') {
|
|
71
|
+
if (props.config.append.value === 0) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return props.config.append;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return false;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const popoverVisible = ref(false);
|
|
82
|
+
|
|
83
|
+
const confirmTrimHandler = () => {
|
|
84
|
+
emit('change', props.model[props.name].trim() || '');
|
|
85
|
+
popoverVisible.value = false;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const checkWhiteSpace = (value: unknown) => {
|
|
89
|
+
if (typeof value === 'string' && !props.config.trim) {
|
|
90
|
+
popoverVisible.value = value.trim() !== value;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
50
94
|
const changeHandler = (value: string) => {
|
|
51
95
|
emit('change', value);
|
|
52
96
|
};
|
|
53
97
|
|
|
54
98
|
const inputHandler = (v: string) => {
|
|
99
|
+
checkWhiteSpace(v);
|
|
55
100
|
emit('input', v);
|
|
56
101
|
mForm?.$emit('field-input', props.prop, v);
|
|
57
102
|
};
|
|
58
103
|
|
|
59
104
|
const buttonClickHandler = () => {
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
props.config.append.handler(mForm, {
|
|
105
|
+
if (!appendConfig.value) return;
|
|
106
|
+
if (typeof appendConfig.value.handler === 'function') {
|
|
107
|
+
appendConfig.value.handler(mForm, {
|
|
64
108
|
model: props.model,
|
|
65
109
|
values: mForm?.values,
|
|
66
110
|
});
|
package/src/index.ts
CHANGED
|
@@ -49,6 +49,7 @@ import Timerange from './fields/Timerange.vue';
|
|
|
49
49
|
import { setConfig } from './utils/config';
|
|
50
50
|
import Form from './Form.vue';
|
|
51
51
|
import FormDialog from './FormDialog.vue';
|
|
52
|
+
import type { FormConfig } from './schema';
|
|
52
53
|
|
|
53
54
|
import './theme/index.scss';
|
|
54
55
|
|
|
@@ -88,6 +89,10 @@ export { default as MSelect } from './fields/Select.vue';
|
|
|
88
89
|
export { default as MCascader } from './fields/Cascader.vue';
|
|
89
90
|
export { default as MDynamicField } from './fields/DynamicField.vue';
|
|
90
91
|
|
|
92
|
+
export const createForm = function (config: FormConfig) {
|
|
93
|
+
return config;
|
|
94
|
+
};
|
|
95
|
+
|
|
91
96
|
export interface InstallOptions {
|
|
92
97
|
[key: string]: any;
|
|
93
98
|
}
|
package/src/schema.ts
CHANGED
package/src/theme/index.scss
CHANGED
package/src/theme/table.scss
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { App } from 'vue';
|
|
2
|
+
import type { FormConfig } from './schema';
|
|
2
3
|
import './theme/index.scss';
|
|
3
4
|
export * from './schema';
|
|
4
5
|
export * from './utils/form';
|
|
@@ -34,6 +35,7 @@ export { default as MLink } from './fields/Link.vue';
|
|
|
34
35
|
export { default as MSelect } from './fields/Select.vue';
|
|
35
36
|
export { default as MCascader } from './fields/Cascader.vue';
|
|
36
37
|
export { default as MDynamicField } from './fields/DynamicField.vue';
|
|
38
|
+
export declare const createForm: (config: FormConfig) => FormConfig;
|
|
37
39
|
export interface InstallOptions {
|
|
38
40
|
[key: string]: any;
|
|
39
41
|
}
|
package/types/schema.d.ts
CHANGED
|
@@ -248,8 +248,9 @@ export interface TextConfig extends FormItem, Input {
|
|
|
248
248
|
/** 后置元素,一般为标签或按钮 */
|
|
249
249
|
append?: string | {
|
|
250
250
|
text: string;
|
|
251
|
+
value?: 0 | 1;
|
|
251
252
|
type: 'button';
|
|
252
|
-
handler
|
|
253
|
+
handler?: (mForm: FormState | undefined, data: {
|
|
253
254
|
model: any;
|
|
254
255
|
values: any;
|
|
255
256
|
}) => void;
|