types(DatetimePicker): use tsx (#8181)

This commit is contained in:
neverland
2021-02-19 20:21:42 +08:00
committed by GitHub
parent d092d669f2
commit 7daca89102
7 changed files with 77 additions and 47 deletions
+21 -7
View File
@@ -1,20 +1,34 @@
import { PropType } from 'vue';
import { isNaN } from '../utils/validate/number';
import { pickerProps } from '../picker';
export type ColumnType = 'year' | 'month' | 'day' | 'hour' | 'minute';
export type DatetimePickerType =
| 'date'
| 'time'
| 'datetime'
| 'datehour'
| 'month-day'
| 'year-month';
export const sharedProps = {
...pickerProps,
filter: Function,
modelValue: null,
columnsOrder: Array,
filter: Function as PropType<(type: string, values: string[]) => string[]>,
columnsOrder: Array as PropType<ColumnType[]>,
formatter: {
type: Function,
default: (type: string, value: unknown) => value,
type: Function as PropType<(type: string, value: string) => string>,
default: (type: string, value: string) => value,
},
};
export function times(n: number, iteratee: (index: number) => any[]) {
export const pickerKeys = Object.keys(pickerProps) as Array<
keyof typeof pickerProps
>;
export function times<T>(n: number, iteratee: (index: number) => T) {
let index = -1;
const result = Array(n);
const result: T[] = Array(n);
while (++index < n) {
result[index] = iteratee(index);