plot-plan-designer
Version:
Design Editor Tools with React.js + ant.design + fabric.js
82 lines (81 loc) • 4.73 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importStar(require("react"));
const prop_types_1 = __importDefault(require("prop-types"));
const antd_1 = require("antd");
const Icon_1 = __importDefault(require("../icon/Icon"));
class CommonButton extends react_1.Component {
render() {
return this.props.visible ? (react_1.default.createElement(antd_1.Tooltip, { title: this.props.tooltipTitle, placement: this.props.tooltipPlacement }, this.props.wrapperClassName || this.props.wrapperStyle ? (react_1.default.createElement("span", { style: this.props.wrapperStyle, className: this.props.wrapperClassName },
react_1.default.createElement(antd_1.Button, { id: this.props.id, className: this.props.className, name: this.props.name, style: this.props.style, shape: this.props.shape, size: this.props.size, onClick: this.props.onClick, type: this.props.type, disabled: this.props.disabled, loading: this.props.loading },
this.props.icon ? (this.props.iconAnimation ? (react_1.default.createElement(Icon_1.default, { name: this.props.icon, style: this.props.iconStyle, className: this.props.iconClassName, animation: this.props.iconAnimation })) : (react_1.default.createElement(Icon_1.default, { name: this.props.icon, style: this.props.iconStyle, className: this.props.iconClassName }))) : null,
this.props.children))) : (react_1.default.createElement(antd_1.Button, { id: this.props.id, className: this.props.className, name: this.props.name, style: this.props.style, shape: this.props.shape, size: this.props.size, onClick: this.props.onClick, type: this.props.type, disabled: this.props.disabled, loading: this.props.loading },
this.props.icon ? (this.props.iconAnimation ? (react_1.default.createElement(Icon_1.default, { name: this.props.icon, style: this.props.iconStyle, className: this.props.iconClassName, animation: this.props.iconAnimation })) : (react_1.default.createElement(Icon_1.default, { name: this.props.icon, style: this.props.iconStyle, className: this.props.iconClassName }))) : null,
this.props.children)))) : null;
}
}
CommonButton.propTypes = {
name: prop_types_1.default.string,
id: prop_types_1.default.string,
style: prop_types_1.default.object,
wrapperStyle: prop_types_1.default.object,
wrapperClassName: prop_types_1.default.string,
tooltipTitle: prop_types_1.default.string,
tooltipPlacement: prop_types_1.default.string,
className: prop_types_1.default.string,
icon: prop_types_1.default.string,
iconStyle: prop_types_1.default.object,
iconClassName: prop_types_1.default.string,
iconAnimation: prop_types_1.default.string,
visible: prop_types_1.default.bool,
shape: prop_types_1.default.string,
disabled: prop_types_1.default.bool,
loading: prop_types_1.default.bool,
type: prop_types_1.default.string,
size: prop_types_1.default.oneOf(['small', 'middle', 'large']),
onClick: prop_types_1.default.func,
children: prop_types_1.default.node,
};
CommonButton.defaultProps = {
type: 'default',
visible: true,
disabled: false,
loading: false,
};
exports.default = CommonButton;