UNPKG

2.4 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = Object.setPrototypeOf ||
4 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6 return function (d, b) {
7 extendStatics(d, b);
8 function __() { this.constructor = d; }
9 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10 };
11})();
12Object.defineProperty(exports, "__esModule", { value: true });
13var React = require("react");
14var Type;
15(function (Type) {
16 Type["Primary"] = "primary";
17 Type["Secondary"] = "secondary";
18 Type["Tertiary"] = "tertiary";
19 Type["Danger"] = "danger";
20 Type["Warning"] = "warning";
21 Type["Info"] = "info";
22 Type["Success"] = "success";
23})(Type = exports.Type || (exports.Type = {}));
24var HKButton = /** @class */ (function (_super) {
25 __extends(HKButton, _super);
26 function HKButton() {
27 var _this = _super !== null && _super.apply(this, arguments) || this;
28 _this.handleClick = function (e) {
29 if (_this.props.onClick) {
30 _this.props.onClick(e);
31 }
32 };
33 return _this;
34 }
35 HKButton.prototype.render = function () {
36 var _a = this.props, async = _a.async, disabled = _a.disabled, small = _a.small, type = _a.type, children = _a.children, className = _a.className, title = _a.title, value = _a.value;
37 var buttonClass = 'hk-button';
38 if (async) {
39 buttonClass += '--async';
40 }
41 else {
42 var disabledClass = disabled ? 'disabled-' : '';
43 var smallClass = small ? '-sm' : '';
44 buttonClass += smallClass + "--" + disabledClass + type;
45 }
46 if (className) {
47 buttonClass += " " + className;
48 }
49 return (React.createElement("button", { type: 'button', className: buttonClass, disabled: disabled, onClick: this.handleClick, title: title, value: value || title },
50 " ",
51 children,
52 " "));
53 };
54 HKButton.defaultProps = {
55 async: false,
56 className: '',
57 disabled: false,
58 small: false,
59 type: 'secondary',
60 };
61 return HKButton;
62}(React.Component));
63exports.default = HKButton;
64//# sourceMappingURL=HKButton.js.map
\No newline at end of file