|
| 1 | +import Field from './Field'; |
| 2 | +import {UnconnectedNumeric} from './Numeric'; |
| 3 | +import {UnconnectedText} from './Text'; |
| 4 | +import PropTypes from 'prop-types'; |
| 5 | +import React, {Component} from 'react'; |
| 6 | +import {connectToContainer} from 'lib'; |
| 7 | +import {isDateTime} from 'plotly.js/src/lib'; |
| 8 | +import {isJSDate} from 'plotly.js/src/lib/dates'; |
| 9 | + |
| 10 | +export class UnconnectedNumericOrDate extends Component { |
| 11 | + render() { |
| 12 | + const fullValueIsDate = |
| 13 | + typeof this.props.fullValue === 'string' && |
| 14 | + (isDateTime(this.props.fullValue) || isJSDate(this.props.fullValue)); |
| 15 | + |
| 16 | + return fullValueIsDate ? ( |
| 17 | + <UnconnectedText {...this.props} placeholder={'yyyy-mm-dd 00:00:00.00'} /> |
| 18 | + ) : ( |
| 19 | + <UnconnectedNumeric {...this.props} /> |
| 20 | + ); |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +UnconnectedNumericOrDate.propTypes = { |
| 25 | + defaultValue: PropTypes.any, |
| 26 | + fullValue: PropTypes.any, |
| 27 | + min: PropTypes.number, |
| 28 | + max: PropTypes.number, |
| 29 | + multiValued: PropTypes.bool, |
| 30 | + hideArrows: PropTypes.bool, |
| 31 | + showSlider: PropTypes.bool, |
| 32 | + step: PropTypes.number, |
| 33 | + fullContainer: PropTypes.object, |
| 34 | + updatePlot: PropTypes.func, |
| 35 | + ...Field.propTypes, |
| 36 | +}; |
| 37 | + |
| 38 | +export default connectToContainer(UnconnectedNumericOrDate); |
0 commit comments