UNPKG

@vs-form/vs-form

Version:

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

74 lines (69 loc) 2.41 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/Tooltip'); var classNames = _interopDefault(require('classnames')); require('@material-ui/core/Icon'); require('@material-ui/core/SvgIcon'); var __chunk_5 = require('./chunk-41ea4037.js'); const styles = { iconSize: { fontSize: '1.5em' } }; class VsIcon extends React.Component { constructor(props) { super(props); this.IconProps = this.comp.props || {}; this.initProps(); } get comp() { return this.props.comp; } render() { if (this.comp.icon) { return React.createElement(__chunk_5.BaseIcon, Object.assign({}, this.IconProps, { icon: this.comp.icon })); } else if (this.comp.svg) { return React.createElement(__chunk_5.BaseIcon, Object.assign({}, this.IconProps, { svg: this.comp.svg })); } else if (this.comp.component) { return React.createElement(__chunk_5.BaseIcon, Object.assign({}, this.IconProps, { component: this.comp.component })); } else { return React.createElement("div", null, "Icon: either property icon, svg or component must be provided"); } } initProps() { this.IconProps.className = classNames(this.props.classes.iconSize, this.IconProps.className); if (isUndefined(this.IconProps.color)) { this.IconProps.color = 'primary'; } } } exports.default = VsIcon; exports.styles = styles;