import type { FocusEventHandler, MouseEventHandler } from '../../_util/EventInterface'; import type { CSSProperties } from 'vue'; import type { PickerLocale } from '.'; import type { SizeType } from '../../config-provider'; import type { PresetDate, CustomFormat, DisabledTime, DisabledTimes, EventValue, PanelMode, PickerMode, RangeValue, } from '../../vc-picker/interface'; import type { DateRender } from '../../vc-picker/panels/DatePanel/DateBody'; import type { MonthCellRender } from '../../vc-picker/panels/MonthPanel/MonthBody'; import type { SharedTimeProps } from '../../vc-picker/panels/TimePanel'; import type { RangeDateRender, RangeInfo, RangeType } from '../../vc-picker/RangePicker'; import type { VueNode } from '../../_util/type'; import { stringType, arrayType, someType, booleanType, objectType, functionType, } from '../../_util/type'; import type { InputStatus } from '../../_util/statusUtils'; const DataPickerPlacements = ['bottomLeft', 'bottomRight', 'topLeft', 'topRight'] as const; type DataPickerPlacement = (typeof DataPickerPlacements)[number]; type RangeShowTimeObject = Omit, 'defaultValue'> & { defaultValue?: DateType[]; }; function commonProps() { return { id: String, /** * @deprecated `dropdownClassName` is deprecated which will be removed in next major * version.Please use `popupClassName` instead. */ dropdownClassName: String, popupClassName: String, popupStyle: objectType(), transitionName: String, placeholder: String, allowClear: booleanType(), autofocus: booleanType(), disabled: booleanType(), tabindex: Number, open: booleanType(), defaultOpen: booleanType(), /** Make input readOnly to avoid popup keyboard in mobile */ inputReadOnly: booleanType(), format: someType | (string | CustomFormat)[]>([ String, Function, Array, ]), // Value // format: string | CustomFormat | (string | CustomFormat)[]; // Render // suffixIcon?: VueNode; // clearIcon?: VueNode; // prevIcon?: VueNode; // nextIcon?: VueNode; // superPrevIcon?: VueNode; // superNextIcon?: VueNode; getPopupContainer: functionType<(node: HTMLElement) => HTMLElement>(), panelRender: functionType<(originPanel: VueNode) => VueNode>(), // // Events onChange: functionType<(value: DateType | string | null, dateString: string) => void>(), 'onUpdate:value': functionType<(value: DateType | string | null) => void>(), onOk: functionType<(value: DateType | string | null) => void>(), onOpenChange: functionType<(open: boolean) => void>(), 'onUpdate:open': functionType<(open: boolean) => void>(), onFocus: functionType(), onBlur: functionType(), onMousedown: functionType(), onMouseup: functionType(), onMouseenter: functionType(), onMouseleave: functionType(), onClick: functionType(), onContextmenu: functionType(), onKeydown: functionType<(event: KeyboardEvent, preventDefault: () => void) => void>(), // WAI-ARIA role: String, name: String, autocomplete: String, direction: stringType<'ltr' | 'rtl'>(), showToday: booleanType(), showTime: someType>([Boolean, Object]), locale: objectType(), size: stringType(), bordered: booleanType(), dateRender: functionType>(), disabledDate: functionType<(date: DateType) => boolean>(), mode: stringType(), picker: stringType(), valueFormat: String, placement: stringType(), status: stringType(), /** @deprecated Please use `disabledTime` instead. */ disabledHours: functionType(), /** @deprecated Please use `disabledTime` instead. */ disabledMinutes: functionType(), /** @deprecated Please use `disabledTime` instead. */ disabledSeconds: functionType(), }; } export interface CommonProps { id?: string; prefixCls?: string; /** * @deprecated `dropdownClassName` is deprecated which will be removed in next major * version.Please use `popupClassName` instead. */ dropdownClassName?: string; popupClassName?: string; popupStyle?: CSSProperties; transitionName?: string; placeholder?: string; allowClear?: boolean; autofocus?: boolean; disabled?: boolean; tabindex?: number; open?: boolean; defaultOpen?: boolean; inputReadOnly?: boolean; format?: string | CustomFormat | (string | CustomFormat)[]; suffixIcon?: VueNode; clearIcon?: VueNode; prevIcon?: VueNode; nextIcon?: VueNode; superPrevIcon?: VueNode; superNextIcon?: VueNode; getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement; panelRender?: (originPanel: VueNode) => VueNode; onChange?: (value: DateType | string | null, dateString: string) => void; 'onUpdate:value'?: (value: DateType | string | null) => void; onOk?: (value: DateType | string | null) => void; onOpenChange?: (open: boolean) => void; 'onUpdate:open'?: (open: boolean) => void; onFocus?: FocusEventHandler; onBlur?: FocusEventHandler; onMousedown?: MouseEventHandler; onMouseup?: MouseEventHandler; onMouseenter?: MouseEventHandler; onMouseleave?: MouseEventHandler; onClick?: MouseEventHandler; onContextmenu?: MouseEventHandler; onKeydown?: (event: KeyboardEvent, preventDefault: () => void) => void; role?: string; name?: string; autocomplete?: string; direction?: 'ltr' | 'rtl'; showToday?: boolean; showTime?: boolean | SharedTimeProps; locale?: PickerLocale; size?: SizeType; bordered?: boolean; dateRender?: DateRender; disabledDate?: (date: DateType) => boolean; mode?: PanelMode; picker?: PickerMode; valueFormat?: string; placement?: DataPickerPlacement; status?: InputStatus; } function datePickerProps() { return { defaultPickerValue: someType([Object, String]), defaultValue: someType([Object, String]), value: someType([Object, String]), presets: arrayType[]>(), disabledTime: functionType>(), renderExtraFooter: functionType<(mode: PanelMode) => VueNode>(), showNow: booleanType(), monthCellRender: functionType>(), // deprecated Please use `monthCellRender"` instead.', monthCellContentRender: functionType>(), }; } export interface DatePickerProps { defaultPickerValue?: DateType | string; defaultValue?: DateType | string; value?: DateType | string; presets?: PresetDate[]; disabledTime?: DisabledTime; renderExtraFooter?: (mode: PanelMode) => VueNode; showNow?: boolean; monthCellRender?: MonthCellRender; // deprecated Please use `monthCellRender"` instead.', monthCellContentRender?: MonthCellRender; } function rangePickerProps() { return { allowEmpty: arrayType<[boolean, boolean]>(), dateRender: functionType>(), defaultPickerValue: arrayType | RangeValue>(), defaultValue: arrayType | RangeValue>(), value: arrayType | RangeValue>(), presets: arrayType>[]>(), disabledTime: functionType<(date: EventValue, type: RangeType) => DisabledTimes>(), disabled: someType([Boolean, Array]), renderExtraFooter: functionType<() => VueNode>(), separator: { type: String }, showTime: someType>([Boolean, Object]), ranges: objectType< Record< string, Exclude, null> | (() => Exclude, null>) > >(), placeholder: arrayType(), mode: arrayType<[PanelMode, PanelMode]>(), onChange: functionType< ( value: RangeValue | RangeValue | null, dateString: [string, string], ) => void >(), 'onUpdate:value': functionType<(value: RangeValue | RangeValue | null) => void>(), onCalendarChange: functionType< ( values: RangeValue | RangeValue, formatString: [string, string], info: RangeInfo, ) => void >(), onPanelChange: functionType< (values: RangeValue | RangeValue, modes: [PanelMode, PanelMode]) => void >(), onOk: functionType<(dates: RangeValue | RangeValue) => void>(), }; } export interface RangePickerProps { allowEmpty?: [boolean, boolean]; dateRender?: RangeDateRender; defaultPickerValue?: RangeValue | RangeValue; defaultValue?: RangeValue | RangeValue; value?: RangeValue | RangeValue; presets?: PresetDate>[]; disabledTime?: (date: EventValue, type: RangeType) => DisabledTimes; disabled?: [boolean, boolean]; renderExtraFooter?: () => VueNode; separator?: string; showTime?: boolean | RangeShowTimeObject; ranges?: Record< string, Exclude, null> | (() => Exclude, null>) >; placeholder?: [string, string]; mode?: [PanelMode, PanelMode]; onChange?: ( value: RangeValue | RangeValue | null, dateString: [string, string], ) => void; 'onUpdate:value'?: (value: RangeValue | RangeValue | null) => void; onCalendarChange?: ( values: RangeValue | RangeValue, formatString: [string, string], info: RangeInfo, ) => void; onPanelChange?: ( values: RangeValue | RangeValue, modes: [PanelMode, PanelMode], ) => void; onOk?: (dates: RangeValue | RangeValue) => void; } export type ExtraDatePickerProps = { valueFormat?: string; defaultPickerValue?: DateType | string; defaultValue?: DateType | string; value?: DateType | string; }; export type ExtraRangePickerProps = { valueFormat?: string; defaultPickerValue?: RangeValue | RangeValue; defaultValue?: RangeValue | RangeValue; value?: RangeValue | RangeValue; }; export { commonProps, datePickerProps, rangePickerProps };