diff --git a/packages/components/src/DateTimePicker/DatePicker.js b/packages/components/src/DateTimePicker/DatePicker.js index eb34191b..a2d03386 100644 --- a/packages/components/src/DateTimePicker/DatePicker.js +++ b/packages/components/src/DateTimePicker/DatePicker.js @@ -5,6 +5,7 @@ import { Input } from '../Input'; import { isEqualDateTime, getLocalizedDate, getLocalizedTime } from './dateUtils'; import DatePickerDialog from './DatePickerDialog'; import TimePickerDialog from './TimePickerDialog'; +import { IconButton } from '../IconButton'; class DatePicker extends ComponentBase { static propTypes = { @@ -96,6 +97,7 @@ class DatePicker extends ComponentBase { this.handleFocus = this.handleFocus.bind(this); this.handleFocusDateInput = this.handleFocusDateInput.bind(this); this.handleFocusTimeInput = this.handleFocusTimeInput.bind(this); + this.clearDate = this.clearDate.bind(this); } componentWillMount() { @@ -244,6 +246,10 @@ class DatePicker extends ComponentBase { return dateResult && timeResult; } + clearDate() { + this.setState({ date: '' }); + } + renderDate() { const { valueConstraint, @@ -286,14 +292,42 @@ class DatePicker extends ComponentBase { noDialog, } = this.props; - let cloneSuffixText = this.props.suffixText; + const iconStyle = { + color: this.props.context.theme.boaPalette.pri500, + width: 18, + height: 18, + }; + let cloneSuffixText = this.props.suffixText; + const dateSuffix = +
+ {this.state.date && } + + {cloneSuffixText} +
; if (this.props.pageType !== 'browse' && this.props.suffixText) { cloneSuffixText = React.cloneElement(this.props.suffixText, { onClick: this.handleFocusDateInput.bind(this), }); } - const inputLocalizedDate = getLocalizedDate(this.state.date, dateFormat); // inputLocalizedDate=inputLocalizedDate== '' ?undefined:inputLocalizedDate; const isMobile = this.isMobile(); @@ -311,11 +345,11 @@ class DatePicker extends ComponentBase { valueConstraint={valueConstraint} hintText={hintTextDate} floatingLabelText={floatingLabelTextDate} - onFocus={this.handleFocusDateInput} + // onFocus={this.handleFocusDateInput} value={inputLocalizedDate} mask={this.props.formats.dateMask} prefixText={this.props.prefixText} - suffixText={cloneSuffixText} + suffixText={dateSuffix} inputAlign={this.props.style.inputAlign} ref={r => (this.bActionInputDate = r)} disabled={disabled} @@ -410,6 +444,26 @@ class DatePicker extends ComponentBase { // ...other } = this.props; + const iconStyle = { + color: this.props.context.theme.boaPalette.pri500, + width: 16, + height: 16, + }; + const timeSuffix = +
+ {this.state.date && !dateFormat && } +
; const inputLocalizedTime = getLocalizedTime(this.state.date, datetimeOption, timeFormat); const isMobile = this.isMobile(); if (timeFormat) { @@ -436,7 +490,7 @@ class DatePicker extends ComponentBase { disabled={disabled} errorText={errorTextTime} prefixText={null} - suffixText={null} + suffixText={timeSuffix} /> )}