choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
161 lines (160 loc) • 6.5 kB
TypeScript
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';
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) => boolean;
min?: MomentInput | null;
max?: MomentInput | null;
step?: TimeStep;
renderExtraFooter?: () => ReactNode;
extraFooterPlacement?: 'top' | 'bottom';
/**
* 时区显示
*/
timeZone?: TimeZone;
/**
* 编辑器在下拉框中显示
*/
editorInPopup?: boolean;
/**
* 默认显示
*/
defaultTime?: Moment | [Moment, Moment];
}
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;
clearButton: boolean;
popupPlacement: string;
triggerShowDelay: number;
triggerHiddenDelay: number;
viewMode: import("../trigger-field/TriggerField").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;
};
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;
selectedDate?: Moment;
mode?: ViewMode;
/**
* hover 时显示值
*/
hoverValue?: string | null;
popupRangeEditor?: HTMLInputElement | null;
savePopupRangeEditor(node: HTMLInputElement | null): void;
isEditable(): boolean;
isEditableLike(): boolean;
getOmitPropsKeys(): string[];
getOtherProps(): any;
getObservableProps(props: any, context: any): any;
defaultRenderer(props: RenderProps): ReactNode;
getDefaultTime(): [Moment, Moment];
getDefaultViewMode(): ViewMode.time | ViewMode.dateTime | ViewMode.week | ViewMode.date | ViewMode.date | ViewMode.month | ViewMode.year;
getPopupClassName(defaultClassName: string | undefined): string | undefined;
getPopupEditor(): JSX.Element | undefined;
getHoverValue(isPopup: boolean): string | null | 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;
getLimit(minOrMax: 'min' | 'max'): Moment | undefined;
getLimitWithType(limit: Moment, minOrMax: 'min' | 'max'): Moment;
getPopupStyleFromAlign(): CSSProperties | undefined;
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;
handleEnterDown(e: any): void;
prepareSetValue(...value: any[]): void;
syncValueOnBlur(value: any): void;
getValueKey(v: any): any;
exchangeRangeValue(start: Moment, end: Moment): void;
changeSelectedDate(selectedDate: 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;
isValidDate(currentDate: Moment, selected: Moment): boolean;
isValidNowDate(selected: Moment): boolean;
getValidatorProp(key: string): any;
renderLengthInfo(): ReactNode;
}