@tmagic/form 1.5.0-beta.6 → 1.5.0-beta.8
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/tmagic-form.js +85 -96
- package/dist/tmagic-form.umd.cjs +85 -96
- package/package.json +8 -8
- package/src/containers/Container.vue +1 -2
- package/src/fields/Date.vue +1 -1
- package/src/fields/Daterange.vue +14 -18
- package/src/fields/Text.vue +0 -1
- package/src/index.ts +3 -3
- package/types/index.d.ts +1085 -1757
package/src/fields/Daterange.vue
CHANGED
|
@@ -35,9 +35,8 @@ const emit = defineEmits(['change']);
|
|
|
35
35
|
|
|
36
36
|
useAddField(props.prop);
|
|
37
37
|
|
|
38
|
-
// eslint-disable-next-line vue/no-setup-props-destructure
|
|
39
38
|
const { names } = props.config;
|
|
40
|
-
const value = ref<(Date | undefined)[] | null>([]);
|
|
39
|
+
const value = ref<(Date | string | undefined)[] | null>([]);
|
|
41
40
|
|
|
42
41
|
if (props.model !== undefined) {
|
|
43
42
|
if (names?.length) {
|
|
@@ -47,9 +46,11 @@ if (props.model !== undefined) {
|
|
|
47
46
|
if (!value.value) {
|
|
48
47
|
value.value = [];
|
|
49
48
|
}
|
|
49
|
+
|
|
50
|
+
const format = `${props.config.dateFormat || 'YYYY/MM/DD'} ${props.config.timeFormat || 'HH:mm:ss'}`;
|
|
50
51
|
if (!start || !end) value.value = [];
|
|
51
|
-
if (start !== preStart) value.value[0] =
|
|
52
|
-
if (end !== preEnd) value.value[1] =
|
|
52
|
+
if (start !== preStart) value.value[0] = datetimeFormatter(start, '', format) as string;
|
|
53
|
+
if (end !== preEnd) value.value[1] = datetimeFormatter(end, '', format) as string;
|
|
53
54
|
},
|
|
54
55
|
{
|
|
55
56
|
immediate: true,
|
|
@@ -59,7 +60,12 @@ if (props.model !== undefined) {
|
|
|
59
60
|
watch(
|
|
60
61
|
() => props.model[props.name],
|
|
61
62
|
(start, preStart) => {
|
|
62
|
-
|
|
63
|
+
const format = `${props.config.dateFormat || 'YYYY/MM/DD'} ${props.config.timeFormat || 'HH:mm:ss'}`;
|
|
64
|
+
|
|
65
|
+
if (start !== preStart)
|
|
66
|
+
value.value = start.map((item: string) =>
|
|
67
|
+
item ? (datetimeFormatter(item, '', format) as string) : undefined,
|
|
68
|
+
);
|
|
63
69
|
},
|
|
64
70
|
{
|
|
65
71
|
immediate: true,
|
|
@@ -74,11 +80,7 @@ const setValue = (v: Date[] | Date) => {
|
|
|
74
80
|
return;
|
|
75
81
|
}
|
|
76
82
|
if (Array.isArray(v)) {
|
|
77
|
-
props.model[item] =
|
|
78
|
-
v[index]?.toString(),
|
|
79
|
-
'',
|
|
80
|
-
props.config.valueFormat || 'YYYY/MM/DD HH:mm:ss',
|
|
81
|
-
);
|
|
83
|
+
props.model[item] = v[index];
|
|
82
84
|
} else {
|
|
83
85
|
props.model[item] = undefined;
|
|
84
86
|
}
|
|
@@ -89,18 +91,12 @@ const changeHandler = (v: Date[]) => {
|
|
|
89
91
|
const value = v || [];
|
|
90
92
|
|
|
91
93
|
if (props.name) {
|
|
92
|
-
emit(
|
|
93
|
-
'change',
|
|
94
|
-
value.map((item?: Date) => {
|
|
95
|
-
if (item) return datetimeFormatter(item, '', props.config.valueFormat || 'YYYY/MM/DD HH:mm:ss');
|
|
96
|
-
return undefined;
|
|
97
|
-
}),
|
|
98
|
-
);
|
|
94
|
+
emit('change', value);
|
|
99
95
|
} else {
|
|
100
96
|
if (names?.length) {
|
|
101
97
|
setValue(value);
|
|
102
98
|
}
|
|
103
|
-
emit('change',
|
|
99
|
+
emit('change', props.model);
|
|
104
100
|
}
|
|
105
101
|
};
|
|
106
102
|
</script>
|
package/src/fields/Text.vue
CHANGED
package/src/index.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import { App } from 'vue';
|
|
19
|
+
import type { App } from 'vue';
|
|
20
20
|
|
|
21
21
|
import Container from './containers/Container.vue';
|
|
22
22
|
import Fieldset from './containers/Fieldset.vue';
|
|
@@ -98,8 +98,8 @@ export interface FormInstallOptions {
|
|
|
98
98
|
const defaultInstallOpt: FormInstallOptions = {};
|
|
99
99
|
|
|
100
100
|
export default {
|
|
101
|
-
install(app: App, opt
|
|
102
|
-
const option = Object.assign(defaultInstallOpt, opt);
|
|
101
|
+
install(app: App, opt?: FormInstallOptions) {
|
|
102
|
+
const option = Object.assign(defaultInstallOpt, opt || {});
|
|
103
103
|
|
|
104
104
|
// eslint-disable-next-line no-param-reassign
|
|
105
105
|
app.config.globalProperties.$MAGIC_FORM = option;
|