|
import type { |
|
PickerRef, |
|
PickerProps as RcPickerProps, |
|
RangePickerProps as RcRangePickerProps, |
|
} from 'rc-picker'; |
|
import type { Locale as RcPickerLocale } from 'rc-picker/lib/interface'; |
|
|
|
import type { InputStatus } from '../../_util/statusUtils'; |
|
import type { AnyObject } from '../../_util/type'; |
|
import type { SizeType } from '../../config-provider/SizeContext'; |
|
import type { Variant } from '../../config-provider'; |
|
import type { TimePickerLocale } from '../../time-picker'; |
|
|
|
const _DataPickerPlacements = ['bottomLeft', 'bottomRight', 'topLeft', 'topRight'] as const; |
|
|
|
type DataPickerPlacement = (typeof _DataPickerPlacements)[number]; |
|
|
|
type SemanticName = 'root'; |
|
type PopupSemantic = 'root'; |
|
|
|
export type PickerLocale = { |
|
lang: RcPickerLocale & AdditionalPickerLocaleLangProps; |
|
timePickerLocale: TimePickerLocale; |
|
} & AdditionalPickerLocaleProps; |
|
|
|
|
|
export type AdditionalPickerLocaleProps = { |
|
|
|
|
|
|
|
|
|
dateFormat?: string; |
|
|
|
|
|
|
|
|
|
dateTimeFormat?: string; |
|
|
|
|
|
|
|
|
|
weekFormat?: string; |
|
|
|
|
|
|
|
|
|
monthFormat?: string; |
|
}; |
|
|
|
export type AdditionalPickerLocaleLangProps = { |
|
placeholder: string; |
|
yearPlaceholder?: string; |
|
quarterPlaceholder?: string; |
|
monthPlaceholder?: string; |
|
weekPlaceholder?: string; |
|
rangeYearPlaceholder?: [string, string]; |
|
rangeQuarterPlaceholder?: [string, string]; |
|
rangeMonthPlaceholder?: [string, string]; |
|
rangeWeekPlaceholder?: [string, string]; |
|
rangePlaceholder?: [string, string]; |
|
}; |
|
|
|
export type PickerClassNames = Partial<Record<SemanticName, string>> & { |
|
popup?: Partial<Record<PopupSemantic, string>>; |
|
}; |
|
|
|
export type PickerStyles = Partial<Record<SemanticName, React.CSSProperties>> & { |
|
popup?: Partial<Record<PopupSemantic, React.CSSProperties>>; |
|
}; |
|
|
|
export type RequiredSemanticPicker = readonly [ |
|
classNames: Required<Record<SemanticName, string>> & { |
|
popup: Required<Record<PopupSemantic, string>>; |
|
}, |
|
styles: Required<Record<SemanticName, React.CSSProperties>> & { |
|
popup: Required<Record<PopupSemantic, React.CSSProperties>>; |
|
}, |
|
]; |
|
|
|
type InjectDefaultProps<Props> = Omit< |
|
Props, |
|
'locale' | 'generateConfig' | 'hideHeader' | 'classNames' | 'styles' |
|
> & { |
|
locale?: PickerLocale; |
|
size?: SizeType; |
|
placement?: DataPickerPlacement; |
|
|
|
bordered?: boolean; |
|
status?: InputStatus; |
|
|
|
|
|
|
|
|
|
variant?: Variant; |
|
|
|
|
|
|
|
|
|
|
|
dropdownClassName?: string; |
|
|
|
|
|
|
|
popupClassName?: string; |
|
rootClassName?: string; |
|
|
|
|
|
|
|
popupStyle?: React.CSSProperties; |
|
styles?: PickerStyles; |
|
classNames?: PickerClassNames; |
|
}; |
|
|
|
|
|
export type PickerProps<DateType extends AnyObject = any> = InjectDefaultProps< |
|
RcPickerProps<DateType> |
|
>; |
|
|
|
|
|
export type RangePickerProps<DateType extends AnyObject = any> = InjectDefaultProps< |
|
RcRangePickerProps<DateType> |
|
>; |
|
|
|
export type GenericTimePickerProps<DateType extends AnyObject = any> = Omit< |
|
PickerProps<DateType>, |
|
'picker' | 'showTime' |
|
> & { |
|
|
|
onSelect?: (value: DateType) => void; |
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
export type PickerPropsWithMultiple< |
|
DateType extends AnyObject = any, |
|
InnerPickerProps extends PickerProps<DateType> = PickerProps<DateType>, |
|
ValueType = DateType, |
|
> = Omit<InnerPickerProps, 'defaultValue' | 'value' | 'onChange' | 'onOk'> & |
|
React.RefAttributes<PickerRef> & { |
|
defaultValue?: ValueType | null; |
|
value?: ValueType | null; |
|
onChange?: (date: ValueType, dateString: string | string[]) => void; |
|
onOk?: (date: ValueType) => void; |
|
}; |
|
|