UNPKG

3.15 kBTypeScriptView Raw
1import * as PropTypes from 'prop-types';
2import * as React from 'react';
3import { IUtils } from '@date-io/core/IUtils';
4import { DateType } from '../constants/prop-types';
5import { MaterialUiPickersDate } from '../typings/date';
6import { WithUtilsProps } from './WithUtils';
7export interface BasePickerRenderArgs {
8 utils: IUtils<MaterialUiPickersDate>;
9 date: MaterialUiPickersDate;
10 isAccepted: boolean;
11 handleClear: () => void;
12 handleAccept: () => void;
13 handleSetTodayDate: () => void;
14 handleDismiss: () => void;
15 changeDate: (date: MaterialUiPickersDate, callback?: any) => void;
16 handleChange: (date: MaterialUiPickersDate, isFinish?: boolean) => void;
17 handleTextFieldChange: (date: MaterialUiPickersDate | null) => void;
18 handleAcceptedChange: (isAccepted: boolean, callback?: any) => void;
19 pick12hOr24hFormat: (default12hFormat: string, default24hFormat: string) => string;
20}
21export interface BasePickerProps {
22 /** Picker value */
23 value: DateType;
24 /** onChange callback */
25 onChange: (date: MaterialUiPickersDate) => void;
26 /** Auto accept date on selection */
27 autoOk?: boolean;
28 /** Control 12h or 24h view mode for clock */
29 ampm?: boolean;
30 /** Format string */
31 format?: string;
32 /** Dynamic formatter of text field label */
33 labelFunc?: (date: MaterialUiPickersDate, invalidLabel: string) => string;
34 /** Do not open picker on enter keypress */
35 disableOpenOnEnter?: boolean;
36 /** Date that will be initially highlighted */
37 initialFocusedDate?: DateType;
38 forwardedRef?: any;
39 mergePreviousDateOnChange?: boolean;
40}
41export interface OuterBasePickerProps extends BasePickerProps, WithUtilsProps {
42 children: (options: BasePickerRenderArgs) => React.ReactNode;
43}
44export declare class BasePicker extends React.Component<OuterBasePickerProps & WithUtilsProps> {
45 static propTypes: {
46 value: PropTypes.Requireable<string | number | object>;
47 onChange: PropTypes.Validator<(...args: any[]) => any>;
48 autoOk: PropTypes.Requireable<boolean>;
49 initialFocusedDate: PropTypes.Requireable<any>;
50 };
51 static defaultProps: {
52 value: Date;
53 autoOK: boolean;
54 ampm: boolean;
55 };
56 state: {
57 date: any;
58 isAccepted: boolean;
59 };
60 componentDidUpdate(prevProps: OuterBasePickerProps): void;
61 changeDate: (date: any, callback?: any) => void;
62 handleAcceptedChange: (isAccepted: boolean, callback?: any) => void;
63 handleClear: () => void;
64 handleAccept: () => void;
65 handleSetTodayDate: () => void;
66 handleTextFieldChange: (date: any) => void;
67 pick12hOr24hFormat: (default12hFormat: string, default24hFormat: string) => string;
68 handleChange: (newDate: any, isFinish?: boolean) => void;
69 handleDismiss: () => void;
70 render(): React.ReactNode;
71}
72declare const _default: React.FunctionComponent<Pick<OuterBasePickerProps & WithUtilsProps, "children" | "value" | "initialFocusedDate" | "onChange" | "autoOk" | "ampm" | "format" | "labelFunc" | "disableOpenOnEnter" | "forwardedRef" | "mergePreviousDateOnChange">>;
73export default _default;