Move Input#validPresent to utils#isValuePresent
parent
f24d12800f
commit
1dafc5676f
|
@ -2,6 +2,7 @@ import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { themr } from 'react-css-themr';
|
import { themr } from 'react-css-themr';
|
||||||
|
import { isValuePresent } from '../utils/utils';
|
||||||
import { INPUT } from '../identifiers';
|
import { INPUT } from '../identifiers';
|
||||||
import InjectedFontIcon from '../font_icon/FontIcon';
|
import InjectedFontIcon from '../font_icon/FontIcon';
|
||||||
|
|
||||||
|
@ -159,13 +160,6 @@ const factory = (FontIcon) => {
|
||||||
this.inputNode.focus();
|
this.inputNode.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
valuePresent = value => (
|
|
||||||
value !== null
|
|
||||||
&& value !== undefined
|
|
||||||
&& value !== ''
|
|
||||||
&& !(typeof value === 'number' && isNaN(value))
|
|
||||||
)
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { children, defaultValue, disabled, error, floating, hint, icon,
|
const { children, defaultValue, disabled, error, floating, hint, icon,
|
||||||
name, label: labelText, maxLength, multiline, required, role,
|
name, label: labelText, maxLength, multiline, required, role,
|
||||||
|
@ -180,7 +174,7 @@ const factory = (FontIcon) => {
|
||||||
[theme.withIcon]: icon,
|
[theme.withIcon]: icon,
|
||||||
}, this.props.className);
|
}, this.props.className);
|
||||||
|
|
||||||
const valuePresent = this.valuePresent(value) || this.valuePresent(defaultValue);
|
const valuePresent = isValuePresent(value) || isValuePresent(defaultValue);
|
||||||
|
|
||||||
const inputElementProps = {
|
const inputElementProps = {
|
||||||
...others,
|
...others,
|
||||||
|
|
|
@ -74,3 +74,10 @@ export const getAnimationModule = (animation, theme) => compose(
|
||||||
transformKeys(removeNamespace(animation)),
|
transformKeys(removeNamespace(animation)),
|
||||||
pickBy((v, k) => k.startsWith(animation)),
|
pickBy((v, k) => k.startsWith(animation)),
|
||||||
)(theme);
|
)(theme);
|
||||||
|
|
||||||
|
export const isValuePresent = value => (
|
||||||
|
value !== null
|
||||||
|
&& value !== undefined
|
||||||
|
&& value !== ''
|
||||||
|
&& !(typeof value === 'number' && isNaN(value))
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in New Issue