UNPKG

@vs-form/vs-form

Version:

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

82 lines (77 loc) 3.18 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'); var isUndefined = _interopDefault(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'); require('@material-ui/core/Typography'); var __chunk_7 = require('./chunk-819d0a62.js'); var Card = _interopDefault(require('@material-ui/core/Card')); var CardHeader = _interopDefault(require('@material-ui/core/CardHeader')); var CardContent = _interopDefault(require('@material-ui/core/CardContent')); class VsCard extends React.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 (React.createElement(Card, Object.assign({}, this.CardProps), this.comp.label && React.createElement(CardHeader, Object.assign({ title: this.comp.label && React.createElement(__chunk_7.Text, Object.assign({ text: this.comp.label }, this.HeaderTypographyProps)), subheader: this.comp.subheader && React.createElement(__chunk_7.Text, Object.assign({ text: this.comp.subheader }, this.SubHeaderTypographyProps)) }, this.CardHeaderProps)), React.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'; } } } exports.default = VsCard;