@canonical/react-components 0.51.7 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,6 +28,14 @@ export type Props = PropsWithSpread<{
28
28
  * Function to perform the action prompted by the modal.
29
29
  */
30
30
  onConfirm: (event: MouseEvent<HTMLElement>) => void;
31
+ /**
32
+ * Whether the confirm button should be in the loading state.
33
+ */
34
+ confirmButtonLoading?: boolean;
35
+ /**
36
+ * Whether the confirm button should be disabled.
37
+ */
38
+ confirmButtonDisabled?: boolean;
31
39
  }, Omit<ModalProps, "buttonRow">>;
32
- export declare const ConfirmationModal: ({ cancelButtonLabel, children, confirmButtonAppearance, confirmButtonLabel, confirmExtra, onConfirm, ...props }: Props) => ReactElement;
40
+ export declare const ConfirmationModal: ({ cancelButtonLabel, children, confirmButtonAppearance, confirmButtonLabel, confirmExtra, onConfirm, confirmButtonLoading, confirmButtonDisabled, ...props }: Props) => ReactElement;
33
41
  export default ConfirmationModal;
@@ -7,6 +7,7 @@ exports.default = exports.ConfirmationModal = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _Button = _interopRequireDefault(require("../Button"));
9
9
  var _Modal = _interopRequireDefault(require("../Modal"));
10
+ var _ActionButton = _interopRequireDefault(require("../ActionButton"));
10
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
12
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
12
13
  const ConfirmationModal = _ref => {
@@ -17,6 +18,8 @@ const ConfirmationModal = _ref => {
17
18
  confirmButtonLabel,
18
19
  confirmExtra,
19
20
  onConfirm,
21
+ confirmButtonLoading,
22
+ confirmButtonDisabled,
20
23
  ...props
21
24
  } = _ref;
22
25
  const handleClick = action => event => {
@@ -31,10 +34,12 @@ const ConfirmationModal = _ref => {
31
34
  buttonRow: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, confirmExtra, /*#__PURE__*/_react.default.createElement(_Button.default, {
32
35
  className: "u-no-margin--bottom",
33
36
  onClick: handleClick(props.close)
34
- }, cancelButtonLabel), /*#__PURE__*/_react.default.createElement(_Button.default, {
37
+ }, cancelButtonLabel), /*#__PURE__*/_react.default.createElement(_ActionButton.default, {
35
38
  appearance: confirmButtonAppearance,
36
39
  className: "u-no-margin--bottom",
37
- onClick: handleClick(onConfirm)
40
+ onClick: handleClick(onConfirm),
41
+ loading: confirmButtonLoading,
42
+ disabled: confirmButtonDisabled
38
43
  }, confirmButtonLabel))
39
44
  }, props), children);
40
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-components",
3
- "version": "0.51.7",
3
+ "version": "0.52.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "Huw Wilkins <huw.wilkins@canonical.com>",