/**
* @file DateRangePicker
* @description 自定义日期范围时间选择器组件
* @author fex
*/
///
import React from 'react';
import moment, { unitOfTime } from 'moment';
import { ShortCuts } from './DatePicker';
import { ThemeProps } from 'amis-core';
import type { PlainObject } from 'amis-core';
import { LocaleProps } from 'amis-core';
export interface DateRangePickerProps extends ThemeProps, LocaleProps {
className?: string;
popoverClassName?: string;
startPlaceholder?: string;
endPlaceholder?: string;
theme?: any;
format: string;
utc?: boolean;
inputFormat?: string;
ranges?: string | Array;
clearable?: boolean;
minDate?: moment.Moment;
maxDate?: moment.Moment;
minDuration?: moment.Duration;
maxDuration?: moment.Duration;
joinValues: boolean;
delimiter: string;
value?: any;
onChange: (value: any) => void;
data?: any;
disabled?: boolean;
closeOnSelect?: boolean;
overlayPlacement: string;
timeFormat?: string;
resetValue?: any;
popOverContainer?: any;
dateFormat?: string;
embed?: boolean;
viewMode?: 'days' | 'months' | 'years' | 'time' | 'quarters';
borderMode?: 'full' | 'half' | 'none';
useMobileUI?: boolean;
onFocus?: Function;
onBlur?: Function;
type?: string;
onRef?: any;
label?: string | false;
/** 是否开启游标动画 */
animation?: boolean;
}
export interface DateRangePickerState {
isOpened: boolean;
isFocused: boolean;
/** 开始时间 */
startDate?: moment.Moment;
/** 结束时间 */
endDate?: moment.Moment;
/** 最近一次confirm的开始时间 */
oldStartDate?: moment.Moment;
/** 最近一次confirm的结束时间 */
oldEndDate?: moment.Moment;
/** 当前编辑的时间类型:开始时间 | 结束时间 */
editState?: 'start' | 'end';
/** 开始时间输入值 */
startInputValue?: string;
/** 结束时间输入值 */
endInputValue?: string;
endDateOpenedFirst: boolean;
}
export declare const availableRanges: {
[propName: string]: any;
};
export declare const advancedRanges: {
regexp: RegExp;
resolve: (__: any, _: string, hours: string) => {
label: any;
startDate: (now: moment.Moment) => moment.Moment;
endDate: (now: moment.Moment) => moment.Moment;
};
}[];
export declare class DateRangePicker extends React.Component {
static defaultProps: {
startPlaceholder: string;
endPlaceholder: string;
format: string;
inputFormat: string;
joinValues: boolean;
clearable: boolean;
delimiter: string;
ranges: string;
resetValue: string;
closeOnSelect: boolean;
overlayPlacement: string;
endDateOpenedFirst: boolean;
};
innerDom: any;
popover: any;
input?: HTMLInputElement;
isFirstClick: boolean;
static formatValue(newValue: any, format: string, joinValues: boolean, delimiter: string, utc?: boolean): any;
static unFormatValue(value: any, format: string, joinValues: boolean, delimiter: string): {
startDate: moment.Moment | undefined;
endDate: moment.Moment | undefined;
};
dom: React.RefObject;
calendarRef: React.RefObject;
nextMonth: moment.Moment;
currentMonth: moment.Moment;
startInputRef: React.RefObject;
endInputRef: React.RefObject;
separatorRef: React.RefObject;
constructor(props: DateRangePickerProps);
componentDidMount(): void;
componentWillUnmount(): void;
handleOutClick(e: Event): void;
componentDidUpdate(prevProps: DateRangePickerProps): void;
focus(): void;
blur(): void;
handleFocus(e: React.SyntheticEvent): void;
handleBlur(e: React.SyntheticEvent): void;
open(): void;
openStart(): void;
openEnd(): void;
close(isConfirm?: boolean): void;
handleClick(): void;
handlePopOverClick(e: React.MouseEvent): void;
handleKeyPress(e: React.KeyboardEvent): void;
confirm(): void;
filterDate(date: moment.Moment, originValue?: moment.Moment, timeFormat?: string, type?: 'start' | 'end'): moment.Moment;
handleDateChange(newValue: moment.Moment): void;
handleStartDateChange(newValue: moment.Moment): void;
handelEndDateChange(newValue: moment.Moment): void;
startInputChange(e: React.ChangeEvent): void;
endInputChange(e: React.ChangeEvent): void;
getEndDateByDuration(newValue: moment.Moment): moment.Moment;
getStartDateByDuration(newValue: moment.Moment): moment.Moment;
handleTimeStartChange(newValue: moment.Moment): void;
handleTimeEndChange(newValue: moment.Moment): void;
handleMobileChange(data: any, callback?: () => void): void;
selectRannge(range: PlainObject): void;
renderRanges(ranges: string | Array | undefined): JSX.Element | null;
clearValue(e: React.MouseEvent): void;
clear(): void;
reset(): void;
checkStartIsValidDate(currentDate: moment.Moment): boolean;
checkEndIsValidDate(currentDate: moment.Moment): boolean;
renderDay(props: any, currentDate: moment.Moment): JSX.Element;
renderMonth(props: any, month: number, year: number, date: any): JSX.Element;
renderQuarter(props: any, quarter: number, year: number): JSX.Element;
renderYear(props: any, year: number): JSX.Element;
renderCalendar(): JSX.Element;
getDisabledElementProps(currentDate: moment.Moment, granularity?: unitOfTime.StartOf): {
className: string;
onClick: undefined;
} | {
className: string;
onClick?: undefined;
};
/** 获取宽度类型变量的值 */
getValidWidthValue(element: HTMLElement, propsName: string): number;
renderActiveCursor(): JSX.Element;
render(): JSX.Element;
}
declare const _default: {
new (props: Omit & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps): {
ref: any;
childRef(ref: any): void;
getWrappedInstance(): any;
render(): JSX.Element; /** 当前编辑的时间类型:开始时间 | 结束时间 */
context: any;
setState(state: {} | ((prevState: Readonly<{}>, props: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
forceUpdate(callback?: (() => void) | undefined): void;
readonly props: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps> & Readonly<{
children?: import("react").ReactNode;
}>;
state: Readonly<{}>;
refs: {
[key: string]: import("react").ReactInstance;
};
componentDidMount?(): void;
shouldComponentUpdate?(nextProps: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>, nextState: Readonly<{}>, nextContext: any): boolean;
componentWillUnmount?(): void;
componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void;
getSnapshotBeforeUpdate?(prevProps: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>, prevState: Readonly<{}>): any;
componentDidUpdate?(prevProps: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>, prevState: Readonly<{}>, snapshot?: any): void;
componentWillMount?(): void;
UNSAFE_componentWillMount?(): void;
componentWillReceiveProps?(nextProps: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>, nextContext: any): void;
UNSAFE_componentWillReceiveProps?(nextProps: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>, nextContext: any): void;
componentWillUpdate?(nextProps: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>, nextState: Readonly<{}>, nextContext: any): void;
UNSAFE_componentWillUpdate?(nextProps: Readonly & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps, keyof ThemeProps> & import("amis-core/lib/theme").ThemeOutterProps>, nextState: Readonly<{}>, nextContext: any): void;
};
displayName: string;
contextType: import("react").Context;
ComposedComponent: import("react").ComponentType & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps> & {
themeKey?: string | undefined;
}>;
} & import("hoist-non-react-statics").NonReactStatics & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps> & {
themeKey?: string | undefined;
}, {}> & {
ComposedComponent: import("react").ComponentType & {
locale?: string | undefined;
translate?: ((str: string, ...args: any[]) => string) | undefined;
} & ThemeProps> & {
themeKey?: string | undefined;
};
};
export default _default;