UNPKG

@vs-form/vs-form

Version:

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

69 lines (66 loc) 2.09 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/Tooltip'; import classNames from 'classnames'; import '@material-ui/core/Icon'; import '@material-ui/core/SvgIcon'; import { a as BaseIcon } from './chunk-9f5de191.js'; const styles = { iconSize: { fontSize: '1.5em' } }; class VsIcon extends Component { constructor(props) { super(props); this.IconProps = this.comp.props || {}; this.initProps(); } get comp() { return this.props.comp; } render() { if (this.comp.icon) { return createElement(BaseIcon, Object.assign({}, this.IconProps, { icon: this.comp.icon })); } else if (this.comp.svg) { return createElement(BaseIcon, Object.assign({}, this.IconProps, { svg: this.comp.svg })); } else if (this.comp.component) { return createElement(BaseIcon, Object.assign({}, this.IconProps, { component: this.comp.component })); } else { return 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'; } } } export default VsIcon; export { styles };