UNPKG

@vs-form/vs-form

Version:

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

82 lines (79 loc) 2.86 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 { b as Component$1 } from './chunk-68362596.js'; import 'classnames'; import { c as registerComponent } from './chunk-3774fd4c.js'; import '@material-ui/core/Typography'; import { a as Text } from './chunk-4358fb9c.js'; import './chunk-7293e165.js'; import Button from '@material-ui/core/Button'; import { a as VsButtonBase } from './chunk-177890aa.js'; const styles = { icon: { fontSize: '1.5em', height: '1.5em', } }; class VsButton extends Component { constructor(props) { super(props); this.ButtonProps = {}; this.LabelProps = {}; this.IconProps = {}; this.renderComp = (_p) => { const iconRight = !!this.comp.iconRight; const Icon = this.comp.iconComp; return (createElement(Button, Object.assign({}, this.ButtonProps), Icon && !iconRight && createElement(Icon, Object.assign({ style: { marginRight: 8 } }, this.IconProps)), this.LabelProps ? (createElement(Text, Object.assign({ text: this.comp.label }, this.LabelProps))) : this.comp.label, Icon && iconRight && createElement(Icon, Object.assign({ style: { marginLeft: 8 } }, this.IconProps)))); }; this.initProps(); } get comp() { return this.props.comp; } render() { return (createElement(VsButtonBase, { comp: this.comp, schemaManager: this.props.schemaManager, buttonProps: this.ButtonProps, IconProps: this.IconProps, classes: this.props.classes, designMode: this.props.designMode }, this.renderComp)); } initProps() { const { LabelProps, IconProps, ...buttonProps } = this.comp.props; if (buttonProps) { this.ButtonProps = buttonProps; } if (IconProps) { this.IconProps = IconProps; } if (LabelProps) { this.LabelProps = LabelProps; } if (isUndefined(this.ButtonProps.variant)) { this.ButtonProps.variant = 'outlined'; } } } registerComponent(Component$1.button, VsButton, styles); export default VsButton; export { styles };