@canonical/react-components 0.51.7 → 0.53.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.
@@ -43,19 +43,15 @@ const Button = _ref => {
43
43
  const classes = (0, _classnames.default)(appearance ? "p-button--".concat(appearance) : "p-button", {
44
44
  "has-icon": hasIcon,
45
45
  "is-dense": dense,
46
- "is-disabled": Component !== "button" && disabled,
46
+ "is-disabled": disabled,
47
47
  "is-inline": inline,
48
48
  "is-small": small
49
49
  }, className);
50
50
  const onClickDisabled = e => e.preventDefault();
51
- const disabledProp = Component === "button" ? {
52
- disabled
53
- } : {
54
- "aria-disabled": disabled
55
- };
56
51
  return /*#__PURE__*/_react.default.createElement(Component, _extends({
57
52
  className: classes,
58
- onClick: disabled ? onClickDisabled : onClick
59
- }, disabledProp, buttonProps), children);
53
+ onClick: disabled ? onClickDisabled : onClick,
54
+ "aria-disabled": disabled || undefined
55
+ }, buttonProps), children);
60
56
  };
61
57
  var _default = exports.default = Button;
@@ -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
  };
@@ -45,7 +45,7 @@ const generateLogo = (logo, generateLink) => {
45
45
  }, icon !== null && icon !== void 0 ? icon : /*#__PURE__*/_react.default.createElement("img", {
46
46
  className: "p-navigation__logo-icon",
47
47
  src: src,
48
- alt: ""
48
+ alt: "Logo"
49
49
  })), /*#__PURE__*/_react.default.createElement("span", {
50
50
  className: "p-navigation__logo-title"
51
51
  }, title));
@@ -2,7 +2,7 @@ import { MutableRefObject, useRef } from "react";
2
2
  /**
3
3
  * Handle clicks outside an element.
4
4
  */
5
- export declare const useOnClickOutside: <E extends HTMLElement>(elementRef: MutableRefObject<E>, onClickOutside: () => void, { isEnabled }?: {
5
+ export declare const useOnClickOutside: <E extends HTMLElement>(elementRef: ReturnType<typeof useRef<E | null>>, onClickOutside: () => void, { isEnabled }?: {
6
6
  isEnabled: boolean;
7
7
  }) => void;
8
8
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-components",
3
- "version": "0.51.7",
3
+ "version": "0.53.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "Huw Wilkins <huw.wilkins@canonical.com>",
@@ -22,80 +22,80 @@
22
22
  },
23
23
  "homepage": "https://canonical.github.io/react-components",
24
24
  "devDependencies": {
25
- "@babel/cli": "7.23.4",
26
- "@babel/eslint-parser": "7.23.3",
27
- "@babel/preset-typescript": "7.23.3",
28
- "@percy/cli": "1.27.6",
29
- "@percy/storybook": "5.0.1",
25
+ "@babel/cli": "7.24.5",
26
+ "@babel/eslint-parser": "7.24.5",
27
+ "@babel/preset-typescript": "7.24.1",
28
+ "@percy/cli": "1.28.5",
29
+ "@percy/storybook": "5.0.3",
30
30
  "@semantic-release/changelog": "6.0.3",
31
31
  "@semantic-release/git": "10.0.1",
32
- "@storybook/addon-a11y": "7.6.7",
33
- "@storybook/addon-essentials": "7.6.7",
34
- "@storybook/addon-interactions": "7.6.7",
35
- "@storybook/addon-links": "7.6.7",
36
- "@storybook/addon-mdx-gfm": "7.6.7",
37
- "@storybook/addon-onboarding": "1.0.10",
38
- "@storybook/blocks": "7.6.7",
39
- "@storybook/react": "7.6.7",
40
- "@storybook/react-webpack5": "7.6.7",
32
+ "@storybook/addon-a11y": "7.6.19",
33
+ "@storybook/addon-essentials": "7.6.19",
34
+ "@storybook/addon-interactions": "7.6.19",
35
+ "@storybook/addon-links": "7.6.19",
36
+ "@storybook/addon-mdx-gfm": "7.6.19",
37
+ "@storybook/addon-onboarding": "1.0.11",
38
+ "@storybook/blocks": "7.6.19",
39
+ "@storybook/react": "7.6.19",
40
+ "@storybook/react-webpack5": "7.6.19",
41
41
  "@testing-library/cypress": "10.0.1",
42
- "@testing-library/dom": "9.3.3",
43
- "@testing-library/jest-dom": "6.2.1",
44
- "@testing-library/react": "14.1.2",
42
+ "@testing-library/dom": "10.1.0",
43
+ "@testing-library/jest-dom": "6.4.5",
44
+ "@testing-library/react": "15.0.7",
45
45
  "@testing-library/user-event": "14.5.2",
46
46
  "@types/lodash.isequal": "4",
47
- "@typescript-eslint/eslint-plugin": "6.19.1",
48
- "@typescript-eslint/parser": "6.19.1",
47
+ "@typescript-eslint/eslint-plugin": "7.8.0",
48
+ "@typescript-eslint/parser": "7.8.0",
49
49
  "babel-jest": "29.7.0",
50
50
  "babel-loader": "9.1.3",
51
- "babel-plugin-module-resolver": "5.0.0",
51
+ "babel-plugin-module-resolver": "5.0.2",
52
52
  "babel-plugin-typescript-to-proptypes": "2.1.0",
53
53
  "concurrently": "8.2.2",
54
- "css-loader": "6.8.1",
55
- "cypress": "13.6.3",
54
+ "css-loader": "7.1.1",
55
+ "cypress": "13.9.0",
56
56
  "deepmerge": "4.3.1",
57
- "eslint": "8.56.0",
57
+ "eslint": "8.57.0",
58
58
  "eslint-config-prettier": "9.1.0",
59
59
  "eslint-config-react-app": "7.0.1",
60
- "eslint-plugin-cypress": "2.15.1",
60
+ "eslint-plugin-cypress": "3.2.0",
61
61
  "eslint-plugin-flowtype": "8.0.3",
62
62
  "eslint-plugin-import": "2.29.1",
63
63
  "eslint-plugin-jsx-a11y": "6.8.0",
64
64
  "eslint-plugin-prettier": "5.1.3",
65
- "eslint-plugin-react": "7.33.2",
66
- "eslint-plugin-react-hooks": "4.6.0",
67
- "eslint-plugin-storybook": "0.6.15",
68
- "eslint-plugin-testing-library": "6.2.0",
69
- "formik": "2.4.5",
65
+ "eslint-plugin-react": "7.34.1",
66
+ "eslint-plugin-react-hooks": "4.6.2",
67
+ "eslint-plugin-storybook": "0.8.0",
68
+ "eslint-plugin-testing-library": "6.2.2",
69
+ "formik": "2.4.6",
70
70
  "jest": "29.7.0",
71
71
  "npm-package-json-lint": "7.1.0",
72
- "prettier": "3.2.4",
73
- "react": "18.2.0",
72
+ "prettier": "3.2.5",
73
+ "react": "18.3.1",
74
74
  "react-docgen-typescript-loader": "3.7.2",
75
- "react-dom": "18.2.0",
76
- "sass": "1.69.7",
77
- "sass-loader": "14.0.0",
78
- "semantic-release": "23.0.0",
79
- "storybook": "7.6.7",
80
- "style-loader": "3.3.3",
81
- "stylelint": "16.2.0",
75
+ "react-dom": "18.3.1",
76
+ "sass": "1.77.0",
77
+ "sass-loader": "14.2.1",
78
+ "semantic-release": "23.0.8",
79
+ "storybook": "7.6.19",
80
+ "style-loader": "4.0.0",
81
+ "stylelint": "16.5.0",
82
82
  "stylelint-config-prettier": "9.0.5",
83
83
  "stylelint-config-recommended-scss": "14.0.0",
84
84
  "stylelint-order": "6.0.4",
85
85
  "stylelint-prettier": "5.0.0",
86
86
  "ts-jest": "29.1.2",
87
87
  "tsc-alias": "1.8.8",
88
- "typescript": "5.3.3",
89
- "vanilla-framework": "4.9.0",
88
+ "typescript": "5.4.5",
89
+ "vanilla-framework": "4.11.0",
90
90
  "wait-on": "7.2.0",
91
- "webpack": "5.89.0"
91
+ "webpack": "5.91.0"
92
92
  },
93
93
  "dependencies": {
94
- "@types/jest": "29.5.11",
95
- "@types/node": "20.8.5",
96
- "@types/react": "18.2.46",
97
- "@types/react-dom": "18.2.18",
98
- "@types/react-table": "7.7.19",
94
+ "@types/jest": "29.5.12",
95
+ "@types/node": "20.12.11",
96
+ "@types/react": "18.3.1",
97
+ "@types/react-dom": "18.3.0",
98
+ "@types/react-table": "7.7.20",
99
99
  "classnames": "2.5.1",
100
100
  "jest-environment-jsdom": "29.7.0",
101
101
  "lodash.isequal": "4.5.0",
@@ -104,10 +104,10 @@
104
104
  "react-useportal": "1.0.19"
105
105
  },
106
106
  "resolutions": {
107
- "@types/react": "18.2.46",
108
- "@types/react-dom": "18.2.18",
107
+ "@types/react": "18.3.1",
108
+ "@types/react-dom": "18.3.0",
109
109
  "postcss": "^8.3.11",
110
- "jackspeak": "2.1.1"
110
+ "jackspeak": "2.3.6"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "@types/react": "^17.0.2 || ^18.0.0",