UNPKG

@vs-form/vs-form

Version:

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

77 lines (74 loc) 2.84 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 '@material-ui/core/Typography'; import { a as Text } from './chunk-4358fb9c.js'; import Card from '@material-ui/core/Card'; import CardHeader from '@material-ui/core/CardHeader'; import CardContent from '@material-ui/core/CardContent'; class VsCard extends Component { constructor(props) { super(props); this.CardProps = {}; this.CardHeaderProps = {}; this.CardContentProps = {}; this.HeaderTypographyProps = {}; this.SubHeaderTypographyProps = {}; this.initProps(); } get comp() { return this.props.comp; } render() { return (createElement(Card, Object.assign({}, this.CardProps), this.comp.label && createElement(CardHeader, Object.assign({ title: this.comp.label && createElement(Text, Object.assign({ text: this.comp.label }, this.HeaderTypographyProps)), subheader: this.comp.subheader && createElement(Text, Object.assign({ text: this.comp.subheader }, this.SubHeaderTypographyProps)) }, this.CardHeaderProps)), createElement(CardContent, Object.assign({}, this.CardContentProps), this.props.children))); } initProps() { const { CardHeaderProps, CardContentProps, HeaderTypographyProps, SubHeaderTypographyProps, ...CardProps } = this.comp.props; if (CardProps) { this.CardProps = CardProps; } if (CardHeaderProps) { this.CardHeaderProps = CardHeaderProps; } if (CardContentProps) { this.CardContentProps = CardContentProps; } if (HeaderTypographyProps) { this.HeaderTypographyProps = HeaderTypographyProps; } if (SubHeaderTypographyProps) { this.SubHeaderTypographyProps = SubHeaderTypographyProps; } if (isUndefined(this.HeaderTypographyProps.variant)) { this.HeaderTypographyProps.variant = 'h6'; } if (isUndefined(this.SubHeaderTypographyProps.variant)) { this.SubHeaderTypographyProps.variant = 'subtitle1'; } } } export default VsCard;