UNPKG

vs-form-mui-4x

Version:

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

80 lines (77 loc) 2.56 kB
import { Component, createElement } from 'react'; import 'lodash/capitalize'; import 'lodash/cloneDeep'; import 'lodash/get'; import 'lodash/has'; import 'lodash/isArray'; import 'lodash/isDate'; import 'lodash/isBoolean'; import 'lodash/isEmpty'; import 'lodash/isFunction'; import 'lodash/isInteger'; import 'lodash/isNull'; import 'lodash/isNumber'; import 'lodash/isObject'; import 'lodash/isPlainObject'; import 'lodash/isRegExp'; import 'lodash/isString'; import isUndefined from 'lodash/isUndefined'; import 'lodash/merge'; import 'lodash/set'; import 'lodash/toInteger'; import 'lodash/toNumber'; import 'lodash/trimEnd'; import 'lodash/uniq'; import 'lodash/debounce'; import 'lodash/throttle'; import { X as Text } from './index-5c5f12ca.js'; import '@material-ui/core/FormControl'; import '@material-ui/core/FormHelperText'; import '@material-ui/core/FormLabel'; import '@material-ui/core/TextField'; import '@material-ui/core/InputAdornment'; import '@material-ui/core/Tooltip'; import '@material-ui/core/styles'; import 'classnames'; import '@material-ui/core/Icon'; import '@material-ui/core/SvgIcon'; import 'date-fns'; import 'events'; import '@material-ui/core/Typography'; import '@material-ui/core/Grid'; import '@material-ui/core/IconButton'; class Form extends Component { constructor(props) { super(props); this.PanelProps = {}; this.HeaderTypographyProps = {}; this.FormTag = ({ children }) => { if (!this.props.schemaManager.componentIsInSubschema(this.comp)) { return createElement("form", Object.assign({}, this.PanelProps), children); } else { return createElement("div", Object.assign({}, this.PanelProps), children); } }; this.initProps(); } get comp() { return this.props.comp; } render() { return (createElement(this.FormTag, null, this.comp.label ? createElement(Text, Object.assign({ text: this.comp.label }, this.HeaderTypographyProps)) : null, this.props.children)); } initProps() { const { HeaderTypographyProps, ...PanelProps } = this.comp.props; if (PanelProps) { this.PanelProps = PanelProps; } if (HeaderTypographyProps) { this.HeaderTypographyProps = HeaderTypographyProps; } if (isUndefined(this.HeaderTypographyProps.variant)) { this.HeaderTypographyProps.variant = 'h6'; } } } export default Form;