UNPKG

@vs-form/vs-form

Version:

A schema-based form generator component for React using material-ui

70 lines (65 loc) 2.61 kB
'use strict'; 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'); require('lodash/isNull'); require('lodash/isNumber'); require('lodash/isObject'); require('lodash/isPlainObject'); require('lodash/isRegExp'); require('lodash/isString'); require('lodash/isUndefined'); require('lodash/merge'); require('lodash/set'); require('lodash/toInteger'); require('lodash/toNumber'); require('lodash/trimEnd'); require('lodash/uniq'); require('lodash/debounce'); require('lodash/throttle'); var __chunk_2 = require('./chunk-e8808437.js'); require('@material-ui/core/FormControl'); require('@material-ui/core/FormHelperText'); require('@material-ui/core/FormLabel'); var Checkbox = _interopDefault(require('@material-ui/core/Checkbox')); var FormControlLabel = _interopDefault(require('@material-ui/core/FormControlLabel')); class VsCheckbox extends React.Component { constructor(props) { super(props); this.CheckboxProps = {}; this.FormControlLabelProps = {}; this.renderComp = (dataProps) => { return (React.createElement(FormControlLabel, Object.assign({ control: React.createElement(Checkbox, Object.assign({ checked: dataProps.state.value, onChange: this.changeValue(dataProps) }, this.CheckboxProps)), label: this.comp.label, inputRef: this.inputRef }, this.FormControlLabelProps))); }; this.changeValue = (dataProps) => (_evt, checked) => { dataProps.updateValue(checked); }; this.initProps(); this.inputRef = React.createRef(); props.schemaManager.addInputRef(props.comp, this.inputRef); } get comp() { return this.props.comp; } render() { return (React.createElement(__chunk_2.VsBaseFormControl, Object.assign({}, this.props), this.renderComp)); } initProps() { const { FormControlProps, FormHelperTextProps, FormLabelProps, FormControlLabelProps, ...CheckboxProps } = this.comp.props; if (CheckboxProps) { this.CheckboxProps = CheckboxProps; } if (FormControlLabelProps) { this.FormControlLabelProps = FormControlLabelProps; } } } exports.default = VsCheckbox;