UNPKG

@uiw/react-button

Version:

Button component

54 lines (53 loc) 2.92 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"]; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var _react = _interopRequireDefault(require("react")); var _reactIcon = _interopRequireDefault(require("@uiw/react-icon")); var _jsxRuntime = require("react/jsx-runtime"); var _excluded = ["prefixCls", "disabled", "active", "loading", "block", "basic", "htmlType", "type", "size", "icon", "className", "children"]; var _default = exports["default"] = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) { var _props$prefixCls = props.prefixCls, prefixCls = _props$prefixCls === void 0 ? 'w-btn' : _props$prefixCls, _props$disabled = props.disabled, disabled = _props$disabled === void 0 ? false : _props$disabled, _props$active = props.active, active = _props$active === void 0 ? false : _props$active, _props$loading = props.loading, loading = _props$loading === void 0 ? false : _props$loading, _props$block = props.block, block = _props$block === void 0 ? false : _props$block, _props$basic = props.basic, basic = _props$basic === void 0 ? false : _props$basic, _props$htmlType = props.htmlType, htmlType = _props$htmlType === void 0 ? 'button' : _props$htmlType, _props$type = props.type, type = _props$type === void 0 ? 'light' : _props$type, _props$size = props.size, size = _props$size === void 0 ? 'default' : _props$size, icon = props.icon, className = props.className, children = props.children, others = (0, _objectWithoutProperties2["default"])(props, _excluded); var cls = [className, prefixCls, size ? "".concat(prefixCls, "-size-").concat(size) : null, type ? "".concat(prefixCls, "-").concat(type) : null, basic ? "".concat(prefixCls, "-basic") : null, loading ? "".concat(prefixCls, "-loading") : null, disabled || loading ? 'disabled' : null, active ? 'active' : null, block ? 'block' : null].filter(Boolean).join(' ').trim(); return /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, others), {}, { ref: ref, type: htmlType, disabled: disabled || loading, className: cls, children: [icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIcon["default"], { type: icon }), children && _react["default"].Children.map(children, function (child) { if (!child) return child; if ( /*#__PURE__*/_react["default"].isValidElement(child)) return child; return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", { children: child }); })] })); }); module.exports = exports.default;