| | |
| | | options: null |
| | | } |
| | | |
| | | timer = null |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { defaultValue, value, options } = this.props |
| | | let val = '' |
| | |
| | | } |
| | | |
| | | changeValue = (e) => { |
| | | const { clear } = this.props |
| | | const { unit } = this.state |
| | | let val = e.target.value |
| | | |
| | |
| | | value: _val, |
| | | }) |
| | | |
| | | if (this.props.onChange) { |
| | | if (!_val) { |
| | | this.props.onChange('0px') |
| | | } else { |
| | | this.props.onChange(`${_val}${unit}`) |
| | | clearTimeout(this.timer) |
| | | |
| | | this.timer = setTimeout(() => { |
| | | if (this.props.onChange) { |
| | | if (_val === '') { |
| | | this.props.onChange(clear ? '' : '0px') |
| | | } else { |
| | | this.props.onChange(`${_val}${unit}`) |
| | | } |
| | | } |
| | | } |
| | | }, 100) |
| | | } |
| | | |
| | | changeUnit = (val) => { |
| | | const { value } = this.state |
| | | |
| | | this.setState({unit: val}) |
| | | |
| | | if (val === 'auto') { |
| | | this.setState({value: ''}) |
| | | this.props.onChange('auto') |
| | | } else { |
| | | if (value && this.props.onChange) { |
| | | this.props.onChange(`${value}${val}`) |
| | | this.setState({unit: val}, () => { |
| | | if (val === 'auto') { |
| | | this.setState({value: ''}) |
| | | this.props.onChange('auto') |
| | | } else { |
| | | if (value && this.props.onChange) { |
| | | this.props.onChange(`${value}${val}`) |
| | | } else { |
| | | this.props.onChange('') |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | render () { |