@vs-form/vs-form
Version:
A schema-based form generator component for React using material-ui
66 lines (63 loc) • 2.09 kB
JavaScript
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 '@material-ui/core/Typography';
import { a as Text } from './chunk-4358fb9c.js';
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;