@vs-form/vs-form
Version:
A schema-based form generator component for React using material-ui
79 lines (74 loc) • 2.69 kB
JavaScript
;
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var React = require('react');
var React__default = _interopDefault(React);
require('lodash/capitalize');
require('lodash/cloneDeep');
require('lodash/get');
require('lodash/has');
require('lodash/isArray');
require('lodash/isDate');
require('lodash/isBoolean');
require('lodash/isEmpty');
require('lodash/isFunction');
require('lodash/isInteger');
var isNull = _interopDefault(require('lodash/isNull'));
var isNumber = _interopDefault(require('lodash/isNumber'));
require('lodash/isObject');
require('lodash/isPlainObject');
require('lodash/isRegExp');
require('lodash/isString');
require('lodash/isUndefined');
require('lodash/merge');
var set = _interopDefault(require('lodash/set'));
require('lodash/toInteger');
var toNumber = _interopDefault(require('lodash/toNumber'));
require('lodash/trimEnd');
require('lodash/uniq');
require('lodash/debounce');
require('lodash/throttle');
require('./chunk-e8808437.js');
require('@material-ui/core/FormControl');
require('@material-ui/core/FormHelperText');
require('@material-ui/core/FormLabel');
require('@material-ui/core/TextField');
require('@material-ui/core/InputAdornment');
require('./chunk-7581cbb1.js');
require('@material-ui/core/Tooltip');
var __chunk_4 = require('./chunk-364f6801.js');
require('@material-ui/core/styles');
require('classnames');
require('@material-ui/core/Icon');
require('@material-ui/core/SvgIcon');
require('./chunk-41ea4037.js');
require('./chunk-2f21f066.js');
require('date-fns');
require('events');
require('@material-ui/core/Typography');
require('./chunk-819d0a62.js');
require('@material-ui/core/Grid');
require('@material-ui/core/IconButton');
require('./chunk-f9facc49.js');
class VsNumber extends React.Component {
constructor(props) {
super(props);
this.changeValue = (dataProps) => (evt) => {
const value = evt.target.value;
const schemaValue = value === '' ? null : toNumber(value);
dataProps.updateValue(value, schemaValue);
};
this.getProps = () => {
set(this.comp, 'props.type', 'number');
};
this.getProps();
}
get comp() { return this.props.comp; }
render() {
return React.createElement(__chunk_4.VsBaseInput, Object.assign({ value: this.getValue, onChange: this.changeValue }, this.props));
}
getValue(dataProps) {
const numValue = isNull(dataProps.state.value) ? '' : toNumber(dataProps.state.value);
return isNumber(numValue) ? dataProps.state.value : '';
}
}
exports.default = VsNumber;