ph-material-pickers
Version:
React components, that implements material design pickers for material-ui v4
87 lines (86 loc) • 3.49 kB
TypeScript
import * as React from 'react';
import { TextFieldProps } from '@material-ui/core/TextField';
import { IconButtonProps } from '@material-ui/core/IconButton';
import { InputAdornmentProps } from '@material-ui/core/InputAdornment';
import { ParsableDate } from '../constants/prop-types';
import { MuiPickersAdapter } from './hooks/useUtils';
export declare type MuiTextFieldProps = TextFieldProps | Omit<TextFieldProps, 'variant'>;
export interface DateInputProps<TInputValue = ParsableDate<unknown>, TDateValue = unknown> {
open: boolean;
rawValue: TInputValue;
inputFormat: string;
onChange: (date: TDateValue, keyboardInputValue?: string) => void;
openPicker: () => void;
readOnly?: boolean;
disabled?: boolean;
validationError?: boolean;
label?: TextFieldProps['label'];
InputProps?: TextFieldProps['InputProps'];
TextFieldProps?: Partial<MuiTextFieldProps>;
onBlur?: () => void;
ignoreInvalidInputs?: boolean;
/**
* The `renderInput` prop allows you to customize the rendered input.
* The `props` argument of this render prop contains props of [TextField](https://material-ui.com/api/text-field/#textfield-api) that you need to forward.
* Pay specific attention to the `ref` and `inputProps` keys.
* @example ```jsx
* renderInput={props => <TextField {...props} />}
* ````
*/
renderInput: (props: MuiTextFieldProps) => React.ReactElement;
/**
* Icon displaying for open picker button.
*/
openPickerIcon?: React.ReactNode;
/**
* Custom mask. Can be used to override generate from format. (e.g. __/__/____ __:__ or __/__/____ __:__ _M)
*/
mask?: string;
/**
* Regular expression to detect "accepted" symbols.
*
* @default /\dap/gi
*/
acceptRegex?: RegExp;
/**
* Props to pass to keyboard input adornment.
*
* @type {Partial<InputAdornmentProps>}
*/
InputAdornmentProps?: Partial<InputAdornmentProps>;
/**
* Props to pass to keyboard adornment button.
*
* @type {Partial<IconButtonProps>}
*/
OpenPickerButtonProps?: Partial<IconButtonProps>;
/**
* Custom formatter to be passed into Rifm component.
*/
rifmFormatter?: (str: string) => string;
/**
* Do not render open picker button (renders only text field with validation).
*
* @default false
*/
disableOpenPicker?: boolean;
/**
* Disable mask on the keyboard, this should be used rarely. Consider passing proper mask for your format.
*
* @default false
*/
disableMaskedInput?: boolean;
/**
* Get aria-label text for control that opens picker dialog. Aria-label text must include selected date. @DateIOType
*
* @default (value, utils) => `Choose date, selected date is ${utils.format(utils.date(value), 'fullDate')}`
*/
getOpenDialogAriaText?: (value: ParsableDate, utils: MuiPickersAdapter) => string;
}
export declare type ExportedDateInputProps<TInputValue, TDateValue> = Omit<DateInputProps<TInputValue, TDateValue>, 'openPicker' | 'inputValue' | 'onChange' | 'inputFormat' | 'validationError' | 'rawValue' | 'forwardedRef' | 'open' | 'TextFieldProps' | 'onBlur'>;
export interface DateInputRefs {
inputRef?: React.Ref<HTMLInputElement>;
containerRef?: React.Ref<HTMLDivElement>;
forwardedRef?: React.Ref<HTMLInputElement>;
}
export declare const PureDateInput: React.FC<DateInputProps & DateInputRefs>;