mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* feat(types): [utils] add ExtractPublicPropTypes type * feat(types): [components] add props public type * chore(types): use type-only import for Prop from 'vue' Co-authored-by: Noblet Ouways <91417411+Dsaquel@users.noreply.github.com> --------- Co-authored-by: Noblet Ouways <91417411+Dsaquel@users.noreply.github.com>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import {
|
|
buildProps,
|
|
definePropType,
|
|
isArray,
|
|
isDate,
|
|
} from '@element-plus/utils'
|
|
import { INPUT_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants'
|
|
|
|
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'
|
|
|
|
export type CalendarDateType =
|
|
| 'prev-month'
|
|
| 'next-month'
|
|
| 'prev-year'
|
|
| 'next-year'
|
|
| 'today'
|
|
|
|
const isValidRange = (range: unknown): range is [Date, Date] =>
|
|
isArray(range) && range.length === 2 && range.every((item) => isDate(item))
|
|
|
|
export const calendarProps = buildProps({
|
|
/**
|
|
* @description binding value
|
|
*/
|
|
modelValue: {
|
|
type: Date,
|
|
},
|
|
/**
|
|
* @description time range, including start time and end time.
|
|
* Start time must be start day of week, end time must be end day of week, the time span cannot exceed two months.
|
|
*/
|
|
range: {
|
|
type: definePropType<[Date, Date]>(Array),
|
|
validator: isValidRange,
|
|
},
|
|
} as const)
|
|
export type CalendarProps = ExtractPropTypes<typeof calendarProps>
|
|
export type CalendarPropsPublic = __ExtractPublicPropTypes<typeof calendarProps>
|
|
|
|
export const calendarEmits = {
|
|
[UPDATE_MODEL_EVENT]: (value: Date) => isDate(value),
|
|
[INPUT_EVENT]: (value: Date) => isDate(value),
|
|
}
|
|
export type CalendarEmits = typeof calendarEmits
|