Commit 974e1d48 by Vladislav Lagunov

MomentField использует DayPickerSingleDateController

parent e44c6488
......@@ -9,7 +9,7 @@ import { StandardProps, Popover } from '@material-ui/core';
import Icon from './Icon';
import 'react-dates/initialize';
import 'react-dates/lib/css/_datepicker.css';
import DayPicker from 'react-dates/lib/components/DayPicker';
import DayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';
// Props
......@@ -17,6 +17,7 @@ export type Props = StandardProps<React.HTMLProps<HTMLDivElement>, ClassKey, 'va
InputProps?: Partial<TextFieldProps>;
format?: string;
nonNull?: boolean;
dayPickerProps?: Partial<Record<string, any>>;
}
......@@ -131,7 +132,7 @@ class MomentField extends React.Component<Props, State> {
}
render() {
const { classes, ctx, error, InputProps, onBlur, onChange, onFocus, value, format: formapProps, disabled, nonNull, ...rest } = this.props;
const { classes, ctx, error, InputProps, onBlur, onChange, onFocus, value, format: formapProps, disabled, nonNull, dayPickerProps, ...rest } = this.props;
const { rootEl } = this;
const { open } = this.state;
const self = this;
......@@ -154,11 +155,12 @@ class MomentField extends React.Component<Props, State> {
value={inputValue(this.state, this.props)}
/>
{rootEl && <Popover anchorEl={rootEl} open={open} onClose={this.handleClose} anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }} disableAutoFocus disableEnforceFocus disableRestoreFocus hideBackdrop>
<DayPicker
<DayPickerSingleDateController
ref={this.handlePickerRef}
date={value}
onDayClick={this.handleDatesChange}
onDateChange={this.handleDatesChange}
numberOfMonths={1}
{...dayPickerProps}
/>
</Popover>}
</div>;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment