UNPKG

leo-design-ui

Version:

React Design Library

43 lines (42 loc) 1.88 kB
var __assign = (this && this.__assign) || function () { __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; }; return __assign.apply(this, arguments); }; 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 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { jsx as _jsx } from "react/jsx-runtime"; import classNames from "classnames"; export var Button = function (_a) { var _b; var _c = _a.btnType, btnType = _c === void 0 ? 'default' : _c, size = _a.size, _d = _a.disabled, disabled = _d === void 0 ? false : _d, href = _a.href, children = _a.children, className = _a.className, restProps = __rest(_a, ["btnType", "size", "disabled", "href", "children", "className"]); // 收集class var classes = classNames('btn', className, (_b = {}, _b["btn-".concat(btnType)] = btnType, _b["btn-".concat(size)] = size, _b['disabled'] = (btnType === 'link') && disabled, _b)); // 区分类型 if (btnType === 'link' && href) { return (_jsx("a", __assign({}, restProps, { className: classes, href: href, children: children }))); } else { return (_jsx("button", __assign({}, restProps, { className: classes, disabled: disabled, children: children }))); } }; export default Button;