UNPKG

@coreui/react

Version:

UI Components Library for React.js

30 lines (27 loc) 1.51 kB
import { __rest, __assign } from '../../node_modules/tslib/tslib.es6.js'; import React, { forwardRef } from 'react'; import PropTypes from 'prop-types'; import classNames from '../../_virtual/index.js'; import { CLink } from '../link/CLink.js'; import { colorPropType } from '../../props.js'; var CButton = forwardRef(function (_a, ref) { var _b; var children = _a.children, _c = _a.as, as = _c === void 0 ? 'button' : _c, className = _a.className, color = _a.color, shape = _a.shape, size = _a.size, _d = _a.type, type = _d === void 0 ? 'button' : _d, variant = _a.variant, rest = __rest(_a, ["children", "as", "className", "color", "shape", "size", "type", "variant"]); return (React.createElement(CLink, __assign({ as: rest.href ? 'a' : as }, (!rest.href && { type: type }), { className: classNames('btn', variant && color ? "btn-".concat(variant, "-").concat(color) : "btn-".concat(variant), (_b = {}, _b["btn-".concat(color)] = color && !variant, _b["btn-".concat(size)] = size, _b), shape, className) }, rest, { ref: ref }), children)); }); CButton.propTypes = { as: PropTypes.elementType, children: PropTypes.node, className: PropTypes.string, color: colorPropType, shape: PropTypes.string, size: PropTypes.oneOf(['sm', 'lg']), type: PropTypes.oneOf(['button', 'submit', 'reset']), variant: PropTypes.oneOf(['outline', 'ghost']), }; CButton.displayName = 'CButton'; export { CButton }; //# sourceMappingURL=CButton.js.map