UNPKG

@pantheon-systems/design-toolkit-react

Version:
53 lines (50 loc) 2.44 kB
import _defineProperty from '@babel/runtime/helpers/defineProperty'; import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties'; import { faSpinnerThird } from '@fortawesome/pro-solid-svg-icons'; import PropTypes from 'prop-types'; import { Fragment } from 'react'; import Icon from '../Icons/Icon.js'; import { jsxs, jsx } from 'react/jsx-runtime'; var _excluded = ["children", "className", "disabled", "isLoading", "size"]; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } var sizes = { small: 'button-small', "default": '' }; var ButtonBase = function ButtonBase(_ref) { var children = _ref.children, className = _ref.className, disabled = _ref.disabled, isLoading = _ref.isLoading, size = _ref.size, rest = _objectWithoutProperties(_ref, _excluded); return /*#__PURE__*/jsxs("button", _objectSpread(_objectSpread({ className: "".concat(className, " ").concat(sizes[size] || ''), disabled: disabled || isLoading, type: "submit" }, rest), {}, { children: [isLoading && /*#__PURE__*/jsxs(Fragment, { children: [/*#__PURE__*/jsx(Icon, { icon: faSpinnerThird, spin: true }), ' '] }), children] })); }; ButtonBase.defaultProps = { className: '', disabled: false, isLoading: false, size: 'default' }; ButtonBase.propTypes = { children: PropTypes.node.isRequired, className: PropTypes.string, disabled: PropTypes.bool, isLoading: PropTypes.bool, size: PropTypes.oneOf(['default', 'small']) }; var SubmitButtonBase = ButtonBase; export { SubmitButtonBase as default }; //# sourceMappingURL=SubmitButtonBase.js.map