@vs-form/vs-form
Version:
A schema-based form generator component for React using material-ui
87 lines (82 loc) • 3.17 kB
JavaScript
'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');
var __chunk_3 = require('./chunk-7581cbb1.js');
require('classnames');
var __chunk_6 = require('./chunk-2f21f066.js');
require('@material-ui/core/Typography');
var __chunk_7 = require('./chunk-819d0a62.js');
require('./chunk-e28442a5.js');
var Button = _interopDefault(require('@material-ui/core/Button'));
var __chunk_10 = require('./chunk-c3a0ac72.js');
const styles = {
icon: {
fontSize: '1.5em',
height: '1.5em',
}
};
class VsButton extends React.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 (React.createElement(Button, Object.assign({}, this.ButtonProps),
Icon && !iconRight && React.createElement(Icon, Object.assign({ style: { marginRight: 8 } }, this.IconProps)),
this.LabelProps ? (React.createElement(__chunk_7.Text, Object.assign({ text: this.comp.label }, this.LabelProps))) : this.comp.label,
Icon && iconRight && React.createElement(Icon, Object.assign({ style: { marginLeft: 8 } }, this.IconProps))));
};
this.initProps();
}
get comp() { return this.props.comp; }
render() {
return (React.createElement(__chunk_10.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';
}
}
}
__chunk_6.registerComponent(__chunk_3.Component.button, VsButton, styles);
exports.default = VsButton;
exports.styles = styles;