UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

181 lines (180 loc) 7.27 kB
import { CSSProperties, KeyboardEventHandler, ReactNode } from 'react'; import moment, { Moment, MomentInput } from 'moment'; import { TimeStep } from 'choerodon-ui/dataset/interface'; import TriggerField, { TriggerFieldProps } from '../trigger-field/TriggerField'; import { ValidationMessages } from '../validator/Validator'; import { ViewMode } from './enum'; import { FieldType } from '../data-set/enum'; import Field from '../data-set/Field'; import { RenderProps } from '../field/FormField'; import ObserverTextField from '../text-field/TextField'; import { Action } from '../trigger/enum'; export declare type RenderFunction = (props: object, text: string, currentDate: Moment, selected: Moment) => ReactNode; export { TimeStep }; export declare type TimeZone = string | ((moment: Moment) => string); export interface DatePickerProps extends TriggerFieldProps { /** * 显示模式date|dateTime|time|year|month|week */ mode?: ViewMode; /** * 单元格渲染 */ cellRenderer?: (mode: ViewMode) => RenderFunction | undefined; filter?: (currentDate: Moment, selected: Moment, mode?: ViewMode, rangeTarget?: 0 | 1, rangeValue?: [any, any]) => boolean; min?: MomentInput | null; max?: MomentInput | null; step?: TimeStep; renderExtraFooter?: () => ReactNode; extraFooterPlacement?: 'top' | 'bottom'; /** * 时区显示 */ timeZone?: TimeZone; /** * 编辑器在下拉框中显示 */ editorInPopup?: boolean; /** * 默认显示 */ defaultTime?: Moment | [Moment, Moment]; /** * 允许使用非法日期 */ useInvalidDate?: boolean; } export interface DatePickerKeyboardEvent { handleKeyDownRight: KeyboardEventHandler<any>; handleKeyDownLeft: KeyboardEventHandler<any>; handleKeyDownDown: KeyboardEventHandler<any>; handleKeyDownUp: KeyboardEventHandler<any>; handleKeyDownEnd: KeyboardEventHandler<any>; handleKeyDownHome: KeyboardEventHandler<any>; handleKeyDownPageUp: KeyboardEventHandler<any>; handleKeyDownPageDown: KeyboardEventHandler<any>; handleKeyDownEnter: KeyboardEventHandler<any>; } export default class DatePicker extends TriggerField<DatePickerProps> implements DatePickerKeyboardEvent { static displayName: string; static defaultProps: { suffixCls: string; mode: ViewMode; useInvalidDate: boolean; clearButton: boolean; popupPlacement: string; triggerShowDelay: number; triggerHiddenDelay: number; viewMode: import("../trigger-field/enum").TriggerViewMode; multiple: boolean; border: boolean; valueChangeAction: import("../text-field/enum").ValueChangeAction; waitType: import("../core/enum").WaitType; readOnly: boolean; disabled: boolean; noValidate: boolean; trim: import("../data-set/enum").FieldTrim; }; componentWillUnmount(): void; get value(): any | undefined; set value(value: any | undefined); get defaultValidationMessages(): ValidationMessages; get min(): Moment | undefined | null; get max(): Moment | undefined | null; view: DatePickerKeyboardEvent | null; cursorDate?: Moment | undefined; mode?: ViewMode; timeID?: number; rangeValueExchange?: boolean; /** * hover 时显示值 */ hoverValue?: Moment | undefined; popupInputEditor?: HTMLInputElement | ObserverTextField | null; savePopupInputEditor(node: HTMLInputElement | ObserverTextField | null): void; isEditable(): boolean; isEditableLike(): boolean; getOmitPropsKeys(): string[]; getOtherProps(): any; getObservableProps(props: any, context: any): any; defaultRenderer(props: RenderProps): ReactNode; getDefaultTime(): [Moment, Moment]; getDefaultViewMode(): any; getPopupClassName(defaultClassName: string | undefined): string | undefined; handlePopupRangeEditorBlur(): void; getDefaultAction(): Action[]; getPopupEditor(): JSX.Element | undefined; getHoverValue(isPopup: boolean): string | undefined; handleDateMouseEnter: (currentDate?: moment.Moment | undefined) => void; handleDateMouseLeave: () => void; getEditorTextInfo(rangeTarget?: 0 | 1): { text: string; width: number; placeholder?: string; }; getRangeInputValue(startText: string, endText: string): string; getInputClassString(className: string): string; getPopupContent(): JSX.Element; getCellRenderer(mode: ViewMode): RenderFunction | undefined; getTriggerIconFont(): string; getFieldType(): FieldType; getViewMode(): ViewMode; toMoment(item: Moment | Date | string | undefined, field?: Field | undefined, noCheck?: boolean): Moment | undefined; checkMoment(item: any): moment.Moment | undefined; compare(oldValue: any, newValue: any): boolean; setText(text?: string): void; afterSetValue(): void; momentToTimestamp(value: any): any; getSelectedDate(): Moment; getCursorDate(): Moment; getLimit(minOrMax: 'min' | 'max'): Moment | undefined; getLimitWithType(limit: Moment, minOrMax: 'min' | 'max'): Moment; getPopupStyleFromAlign(): CSSProperties | undefined; handleCursorDateChange(cursorDate: Moment, selectedDate: Moment, mode?: ViewMode): void; handleSelectedDateChange(selectedDate: Moment, mode?: ViewMode): void; handelViewModeChange(mode: ViewMode): void; handlePopupAnimateAppear(): void; handlePopupAnimateEnd(key: any, exists: any): void; handleSelect(date: Moment, expand?: boolean): void; handleKeyDown(e: any): void; handleKeyDownHome(e: any): void; handleKeyDownEnd(e: any): void; handleKeyDownLeft(e: any): void; handleKeyDownRight(e: any): void; handleKeyDownUp(e: any): void; handleKeyDownDown(e: any): void; handleKeyDownPageUp(e: any): void; handleKeyDownPageDown(e: any): void; handleKeyDownEnter(_e: any): void; handleKeyDownEsc(e: any): void; handleKeyDownTab(): void; handleKeyDownSpace(e: any): void; handleKeyDownBackSpace(e: any): void; handleKeyDownDelete(e: any): void; afterKeyDownInputIsClear(event: any): boolean; handlePopupEditorKeyDown(e: any): void; handleEnterDown(e: any): void; prepareSetValue(...value: any[]): void; syncValueOnBlur(value: any): void; getValueKey(v: any): any; exchangeRangeValue(start: Moment, end: Moment): void; changeCursorDate(cursorDate: Moment): void; isSelected(date: Moment): boolean; unChoose(date: Moment): void; /** * * @param date 返回的时间 * @param expand 是否保持时间选择器的展开 */ choose(date: Moment, expand?: boolean): void; setRangeTarget(target: any): void; getValidDate(date: Moment): Moment; isLowerRange(m1: any, m2: any): boolean; isUnderRange(date: Moment, mode?: ViewMode): boolean; isDateOutOfFilter(currentDate: Moment, selected: Moment, mode?: ViewMode): boolean; isValidDate(currentDate: Moment, selected: Moment, mode?: ViewMode): boolean; isValidNowDate(selected: Moment): boolean; isExistValue(): boolean; getValidatorProp(key: string): any; renderLengthInfo(): ReactNode; }