Commit 974e1d48 by Vladislav Lagunov

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

parent e44c6488
...@@ -9,7 +9,7 @@ import { StandardProps, Popover } from '@material-ui/core'; ...@@ -9,7 +9,7 @@ import { StandardProps, Popover } from '@material-ui/core';
import Icon from './Icon'; import Icon from './Icon';
import 'react-dates/initialize'; import 'react-dates/initialize';
import 'react-dates/lib/css/_datepicker.css'; import 'react-dates/lib/css/_datepicker.css';
import DayPicker from 'react-dates/lib/components/DayPicker'; import DayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';
// Props // Props
...@@ -17,6 +17,7 @@ export type Props = StandardProps<React.HTMLProps<HTMLDivElement>, ClassKey, 'va ...@@ -17,6 +17,7 @@ export type Props = StandardProps<React.HTMLProps<HTMLDivElement>, ClassKey, 'va
InputProps?: Partial<TextFieldProps>; InputProps?: Partial<TextFieldProps>;
format?: string; format?: string;
nonNull?: boolean; nonNull?: boolean;
dayPickerProps?: Partial<Record<string, any>>;
} }
...@@ -131,7 +132,7 @@ class MomentField extends React.Component<Props, State> { ...@@ -131,7 +132,7 @@ class MomentField extends React.Component<Props, State> {
} }
render() { 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 { rootEl } = this;
const { open } = this.state; const { open } = this.state;
const self = this; const self = this;
...@@ -154,11 +155,12 @@ class MomentField extends React.Component<Props, State> { ...@@ -154,11 +155,12 @@ class MomentField extends React.Component<Props, State> {
value={inputValue(this.state, this.props)} value={inputValue(this.state, this.props)}
/> />
{rootEl && <Popover anchorEl={rootEl} open={open} onClose={this.handleClose} anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }} disableAutoFocus disableEnforceFocus disableRestoreFocus hideBackdrop> {rootEl && <Popover anchorEl={rootEl} open={open} onClose={this.handleClose} anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }} disableAutoFocus disableEnforceFocus disableRestoreFocus hideBackdrop>
<DayPicker <DayPickerSingleDateController
ref={this.handlePickerRef} ref={this.handlePickerRef}
date={value} date={value}
onDayClick={this.handleDatesChange} onDateChange={this.handleDatesChange}
numberOfMonths={1} numberOfMonths={1}
{...dayPickerProps}
/> />
</Popover>} </Popover>}
</div>; </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