@telsystems/inputs
Version: 
78 lines • 3.77 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
        s = arguments[i];
        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
            t[p] = s[p];
    }
    return t;
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
            t[p[i]] = s[p[i]];
    return t;
};
import * as React from 'react';
import cn from 'classnames';
import { SvgLoader } from '@telsystems/design';
import theme from '@telsystems/design/dist/themes/default/Buttons.scss';
export var BTN_LG_SIZE = 'large';
export var BTN_MD_SIZE = 'medium';
export var BTN_SM_SIZE = 'small';
export var BTN_PRIMARY_TYPE = 'primary';
export var BTN_SECONDARY_TYPE = 'secondary';
export var BTN_PAPER_TYPE = 'paper';
var Button = (function (_super) {
    __extends(Button, _super);
    function Button() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Button.prototype.render = function () {
        var _a = this.props, className = _a.className, size = _a.size, children = _a.children, type = _a.type, disabled = _a.disabled, isWaiting = _a.isWaiting, rest = __rest(_a, ["className", "size", "children", "type", "disabled", "isWaiting"]);
        var waitingClass = isWaiting ? theme['waiting'] : '';
        var themeStyles = cn(theme['button'], theme["btn-" + size], waitingClass);
        if (!disabled) {
            themeStyles = cn(themeStyles, theme["btn-" + type]);
        }
        return (React.createElement("button", __assign({}, rest, { className: cn(className, themeStyles), disabled: disabled }),
            isWaiting
                ? React.createElement("div", { className: cn(theme['icon'], theme['waiting-icon']) },
                    React.createElement(SvgLoader, null))
                : null,
            children));
    };
    Button.defaultProps = {
        size: BTN_MD_SIZE,
        type: BTN_PRIMARY_TYPE,
        isWaiting: false,
        disabled: false
    };
    Button.Large = function (_a) {
        var children = _a.children, onClick = _a.onClick, props = __rest(_a, ["children", "onClick"]);
        return React.createElement(Button, __assign({ onClick: onClick, size: BTN_LG_SIZE, children: children }, props));
    };
    Button.Medium = function (_a) {
        var children = _a.children, onClick = _a.onClick, props = __rest(_a, ["children", "onClick"]);
        return React.createElement(Button, __assign({ onClick: onClick, size: BTN_MD_SIZE, children: children }, props));
    };
    Button.Small = function (_a) {
        var children = _a.children, onClick = _a.onClick, props = __rest(_a, ["children", "onClick"]);
        return React.createElement(Button, __assign({ onClick: onClick, size: BTN_SM_SIZE, children: children }, props));
    };
    return Button;
}(React.Component));
export { Button };
//# sourceMappingURL=Button.js.map