@tmagic/form 1.1.0-beta.6 → 1.1.0-beta.7
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.mjs +98 -78
- package/dist/tmagic-form.mjs.map +1 -1
- package/dist/tmagic-form.umd.js +98 -78
- package/dist/tmagic-form.umd.js.map +1 -1
- package/package.json +2 -3
- package/src/fields/Daterange.vue +73 -52
- package/src/index.ts +1 -1
- package/types/fields/Daterange.vue.d.ts +97 -54
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.1.0-beta.
|
|
2
|
+
"version": "1.1.0-beta.7",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*",
|
|
@@ -35,10 +35,9 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@element-plus/icons-vue": "^2.0.6",
|
|
38
|
-
"@tmagic/utils": "1.1.0-beta.
|
|
38
|
+
"@tmagic/utils": "1.1.0-beta.7",
|
|
39
39
|
"element-plus": "^2.2.6",
|
|
40
40
|
"lodash-es": "^4.17.21",
|
|
41
|
-
"moment": "^2.29.2",
|
|
42
41
|
"sortablejs": "^1.14.0",
|
|
43
42
|
"vue": "^3.2.37"
|
|
44
43
|
},
|
package/src/fields/Daterange.vue
CHANGED
|
@@ -13,70 +13,91 @@
|
|
|
13
13
|
></el-date-picker>
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
|
-
<script lang="ts">
|
|
17
|
-
import {
|
|
16
|
+
<script lang="ts" setup>
|
|
17
|
+
import { ref, watch } from 'vue';
|
|
18
18
|
|
|
19
19
|
import { datetimeFormatter } from '@tmagic/utils';
|
|
20
20
|
|
|
21
21
|
import { DaterangeConfig } from '../schema';
|
|
22
|
-
import fieldProps from '../utils/fieldProps';
|
|
23
22
|
import { useAddField } from '../utils/useAddField';
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const props = defineProps<{
|
|
25
|
+
config: DaterangeConfig;
|
|
26
|
+
model: any;
|
|
27
|
+
initValues?: any;
|
|
28
|
+
values?: any;
|
|
29
|
+
name: string;
|
|
30
|
+
prop: string;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
size: 'mini' | 'small' | 'medium';
|
|
33
|
+
}>();
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
...fieldProps,
|
|
30
|
-
config: {
|
|
31
|
-
type: Object as PropType<DaterangeConfig>,
|
|
32
|
-
required: true,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
+
const emit = defineEmits(['change']);
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
useAddField(props.prop);
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
// eslint-disable-next-line vue/no-setup-props-destructure
|
|
40
|
+
const { names } = props.config;
|
|
41
|
+
const value = ref<(Date | undefined)[] | null>([]);
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
if (props.model !== undefined) {
|
|
44
|
+
if (names?.length) {
|
|
45
|
+
watch(
|
|
46
|
+
[() => props.model[names[0]], () => props.model[names[1]]],
|
|
47
|
+
([start, end], [preStart, preEnd]) => {
|
|
48
|
+
if (!value.value) {
|
|
49
|
+
value.value = [];
|
|
50
|
+
}
|
|
51
|
+
if (!start || !end) value.value = [];
|
|
52
|
+
if (start !== preStart) value.value[0] = new Date(start);
|
|
53
|
+
if (end !== preEnd) value.value[1] = new Date(end);
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
immediate: true,
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
} else if (props.name && props.model[props.name]) {
|
|
60
|
+
watch(
|
|
61
|
+
() => props.model[props.name],
|
|
62
|
+
(start, preStart) => {
|
|
63
|
+
if (start !== preStart) value.value = start.map((item: string) => (item ? new Date(item) : undefined));
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
immediate: true,
|
|
67
|
+
},
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
44
71
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
value.value = props.model[props.name].map((item: string) => datetimeFormatter(item, ''));
|
|
50
|
-
}
|
|
72
|
+
const setValue = (v: Date[] | Date) => {
|
|
73
|
+
names?.forEach((item, index) => {
|
|
74
|
+
if (!props.model) {
|
|
75
|
+
return;
|
|
51
76
|
}
|
|
77
|
+
if (Array.isArray(v)) {
|
|
78
|
+
props.model[item] = datetimeFormatter(v[index]?.toString(), '');
|
|
79
|
+
} else {
|
|
80
|
+
props.model[item] = undefined;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
};
|
|
52
84
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
names.forEach((item, index) => {
|
|
56
|
-
if (props.model) {
|
|
57
|
-
props.model[item] = datetimeFormatter(v[index].toString(), '');
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
} else if (props.model && props.name && v instanceof Date) {
|
|
61
|
-
props.model[props.name] = datetimeFormatter(v.toString(), '');
|
|
62
|
-
} else if (names?.length) {
|
|
63
|
-
names.forEach((item) => {
|
|
64
|
-
if (props.model) {
|
|
65
|
-
props.model[item] = undefined;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
} else if (props.name) {
|
|
69
|
-
props.model[props.name] = undefined;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
85
|
+
const changeHandler = (v: Date[]) => {
|
|
86
|
+
const value = v || [];
|
|
72
87
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
88
|
+
if (props.name) {
|
|
89
|
+
emit(
|
|
90
|
+
'change',
|
|
91
|
+
value.map((item?: Date) => {
|
|
92
|
+
if (item) return datetimeFormatter(item, '');
|
|
93
|
+
return undefined;
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
96
|
+
} else {
|
|
97
|
+
if (names?.length) {
|
|
98
|
+
setValue(value);
|
|
99
|
+
}
|
|
100
|
+
emit('change', value);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
82
103
|
</script>
|
package/src/index.ts
CHANGED
|
@@ -111,7 +111,7 @@ const install = (app: App, opt: any) => {
|
|
|
111
111
|
app.component(Time.name, Time);
|
|
112
112
|
app.component(Checkbox.name, Checkbox);
|
|
113
113
|
app.component(Switch.name, Switch);
|
|
114
|
-
app.component(
|
|
114
|
+
app.component('m-fields-daterange', Daterange);
|
|
115
115
|
app.component('m-fields-color-picker', ColorPicker);
|
|
116
116
|
app.component(CheckboxGroup.name, CheckboxGroup);
|
|
117
117
|
app.component(RadioGroup.name, RadioGroup);
|
|
@@ -1,57 +1,100 @@
|
|
|
1
|
-
import { PropType } from 'vue';
|
|
2
1
|
import { DaterangeConfig } from '../schema';
|
|
3
|
-
declare const _default:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
2
|
+
declare const _default: {
|
|
3
|
+
new (...args: any[]): {
|
|
4
|
+
$: import("vue").ComponentInternalInstance;
|
|
5
|
+
$data: {};
|
|
6
|
+
$props: Partial<{}> & Omit<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
7
|
+
config: DaterangeConfig;
|
|
8
|
+
model: any;
|
|
9
|
+
initValues?: any;
|
|
10
|
+
values?: any;
|
|
11
|
+
name: string;
|
|
12
|
+
prop: string;
|
|
13
|
+
disabled?: boolean | undefined;
|
|
14
|
+
size: 'mini' | 'small' | 'medium';
|
|
15
|
+
}>>> & {
|
|
16
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
17
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>;
|
|
18
|
+
$attrs: {
|
|
19
|
+
[x: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
$refs: {
|
|
22
|
+
[x: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
$slots: Readonly<{
|
|
25
|
+
[name: string]: import("vue").Slot | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
$root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
|
|
28
|
+
$parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
|
|
29
|
+
$emit: (event: "change", ...args: any[]) => void;
|
|
30
|
+
$el: any;
|
|
31
|
+
$options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
32
|
+
config: DaterangeConfig;
|
|
33
|
+
model: any;
|
|
34
|
+
initValues?: any;
|
|
35
|
+
values?: any;
|
|
36
|
+
name: string;
|
|
37
|
+
prop: string;
|
|
38
|
+
disabled?: boolean | undefined;
|
|
39
|
+
size: 'mini' | 'small' | 'medium';
|
|
40
|
+
}>>> & {
|
|
41
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
42
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "change"[], string, {}> & {
|
|
43
|
+
beforeCreate?: ((() => void) | (() => void)[]) | undefined;
|
|
44
|
+
created?: ((() => void) | (() => void)[]) | undefined;
|
|
45
|
+
beforeMount?: ((() => void) | (() => void)[]) | undefined;
|
|
46
|
+
mounted?: ((() => void) | (() => void)[]) | undefined;
|
|
47
|
+
beforeUpdate?: ((() => void) | (() => void)[]) | undefined;
|
|
48
|
+
updated?: ((() => void) | (() => void)[]) | undefined;
|
|
49
|
+
activated?: ((() => void) | (() => void)[]) | undefined;
|
|
50
|
+
deactivated?: ((() => void) | (() => void)[]) | undefined;
|
|
51
|
+
beforeDestroy?: ((() => void) | (() => void)[]) | undefined;
|
|
52
|
+
beforeUnmount?: ((() => void) | (() => void)[]) | undefined;
|
|
53
|
+
destroyed?: ((() => void) | (() => void)[]) | undefined;
|
|
54
|
+
unmounted?: ((() => void) | (() => void)[]) | undefined;
|
|
55
|
+
renderTracked?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
|
|
56
|
+
renderTriggered?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
|
|
57
|
+
errorCaptured?: (((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void)[]) | undefined;
|
|
58
|
+
};
|
|
59
|
+
$forceUpdate: () => void;
|
|
60
|
+
$nextTick: typeof import("vue").nextTick;
|
|
61
|
+
$watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
|
|
62
|
+
} & Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
63
|
+
config: DaterangeConfig;
|
|
64
|
+
model: any;
|
|
65
|
+
initValues?: any;
|
|
66
|
+
values?: any;
|
|
67
|
+
name: string;
|
|
68
|
+
prop: string;
|
|
69
|
+
disabled?: boolean | undefined;
|
|
70
|
+
size: 'mini' | 'small' | 'medium';
|
|
71
|
+
}>>> & {
|
|
72
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
73
|
+
} & import("vue").ShallowUnwrapRef<{}> & {} & import("vue").ComponentCustomProperties;
|
|
74
|
+
__isFragment?: undefined;
|
|
75
|
+
__isTeleport?: undefined;
|
|
76
|
+
__isSuspense?: undefined;
|
|
77
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
78
|
+
config: DaterangeConfig;
|
|
79
|
+
model: any;
|
|
80
|
+
initValues?: any;
|
|
81
|
+
values?: any;
|
|
53
82
|
name: string;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
83
|
+
prop: string;
|
|
84
|
+
disabled?: boolean | undefined;
|
|
85
|
+
size: 'mini' | 'small' | 'medium';
|
|
86
|
+
}>>> & {
|
|
87
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
88
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "change"[], "change", {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
89
|
+
$slots: {};
|
|
90
|
+
});
|
|
57
91
|
export default _default;
|
|
92
|
+
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
93
|
+
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
94
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
95
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
96
|
+
} : {
|
|
97
|
+
type: import('vue').PropType<T[K]>;
|
|
98
|
+
required: true;
|
|
99
|
+
};
|
|
100
|
+
};
|