@canonical/react-components 0.47.0 → 0.47.1

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.
@@ -45,7 +45,13 @@ var Modal = function Modal(_ref) {
45
45
  }
46
46
  };
47
47
  var handleEscKey = function handleEscKey(e) {
48
- e.nativeEvent.stopImmediatePropagation();
48
+ if ("nativeEvent" in e && e.nativeEvent.stopImmediatePropagation) {
49
+ e.nativeEvent.stopImmediatePropagation();
50
+ } else if ("stopImmediatePropagation" in e) {
51
+ e.stopImmediatePropagation();
52
+ } else if (e.stopPropagation) {
53
+ e.stopPropagation();
54
+ }
49
55
  close();
50
56
  };
51
57
  var keyListenersMap = new Map([["Escape", handleEscKey], ["Tab", handleTabKey]]);
@@ -61,7 +67,7 @@ var Modal = function Modal(_ref) {
61
67
  focusIndex = 1;
62
68
  }
63
69
  (_focusableModalElemen = focusableModalElements.current[focusIndex]) === null || _focusableModalElemen === void 0 ? void 0 : _focusableModalElemen.focus();
64
- }, []);
70
+ }, [close]);
65
71
  (0, _react.useEffect)(function () {
66
72
  var keyDown = function keyDown(e) {
67
73
  var listener = keyListenersMap.get(e.code);
@@ -27,16 +27,16 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
27
27
  // on page 1, also show pages 2, 3 and 4
28
28
  if (currentPage === 1) {
29
29
  start = 1;
30
- end = currentPage + 3;
30
+ end = Math.min(lastPage - 1, currentPage + 3);
31
31
  }
32
32
  // on page 2, show page 1, and also pages 3, and 4
33
33
  if (currentPage === 2) {
34
34
  start = 1;
35
- end = currentPage + 2;
35
+ end = Math.min(lastPage - 1, currentPage + 3);
36
36
  }
37
37
  // on the last page and page before last, also show the 3 previous pages
38
38
  if (currentPage === lastPage || currentPage === lastPage - 1) {
39
- start = lastPage - 4;
39
+ start = Math.max(1, lastPage - 4);
40
40
  end = lastPage - 1;
41
41
  }
42
42
  visiblePages = pageNumbers.slice(start, end);
@@ -54,7 +54,7 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
54
54
  return changePage(1);
55
55
  }
56
56
  }));
57
- if (![1, 2, 3].includes(currentPage)) {
57
+ if (!visiblePages.includes(2)) {
58
58
  items.push( /*#__PURE__*/_react.default.createElement(PaginationItemSeparator, {
59
59
  key: "sep1"
60
60
  }));
@@ -72,7 +72,7 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
72
72
  }));
73
73
  if (truncated) {
74
74
  // render last in sequence
75
- if (![lastPage, lastPage - 1, lastPage - 2].includes(currentPage)) {
75
+ if (!visiblePages.includes(lastPage - 1)) {
76
76
  items.push( /*#__PURE__*/_react.default.createElement(PaginationItemSeparator, {
77
77
  key: "sep2"
78
78
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-components",
3
- "version": "0.47.0",
3
+ "version": "0.47.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "Huw Wilkins <huw.wilkins@canonical.com>",
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "homepage": "https://canonical.github.io/react-components",
24
24
  "devDependencies": {
25
- "@babel/cli": "7.22.5",
26
- "@babel/eslint-parser": "7.22.5",
27
- "@babel/preset-typescript": "7.22.5",
28
- "@percy/cli": "1.26.1",
29
- "@percy/storybook": "4.3.6",
25
+ "@babel/cli": "7.23.0",
26
+ "@babel/eslint-parser": "7.22.15",
27
+ "@babel/preset-typescript": "7.23.2",
28
+ "@percy/cli": "1.27.3",
29
+ "@percy/storybook": "4.3.7",
30
30
  "@storybook/addon-a11y": "6.5.16",
31
31
  "@storybook/addon-controls": "6.5.16",
32
32
  "@storybook/addon-docs": "6.5.16",
@@ -36,69 +36,69 @@
36
36
  "@storybook/react": "6.5.16",
37
37
  "@storybook/theming": "6.5.16",
38
38
  "@testing-library/cypress": "9.0.0",
39
- "@testing-library/dom": "9.3.1",
40
- "@testing-library/jest-dom": "5.16.5",
39
+ "@testing-library/dom": "9.3.3",
40
+ "@testing-library/jest-dom": "5.17.0",
41
41
  "@testing-library/react": "14.0.0",
42
- "@testing-library/user-event": "14.4.3",
42
+ "@testing-library/user-event": "14.5.1",
43
43
  "@types/react-router-dom": "5.3.3",
44
- "@typescript-eslint/eslint-plugin": "5.60.1",
45
- "@typescript-eslint/parser": "5.60.1",
44
+ "@typescript-eslint/eslint-plugin": "5.62.0",
45
+ "@typescript-eslint/parser": "5.62.0",
46
46
  "babel-jest": "27.5.1",
47
- "babel-loader": "9.1.2",
47
+ "babel-loader": "9.1.3",
48
48
  "babel-plugin-module-resolver": "5.0.0",
49
49
  "babel-plugin-typescript-to-proptypes": "2.1.0",
50
- "concurrently": "8.2.0",
50
+ "concurrently": "8.2.1",
51
51
  "css-loader": "6.8.1",
52
- "cypress": "12.16.0",
52
+ "cypress": "12.17.4",
53
53
  "deepmerge": "4.3.1",
54
- "eslint": "8.43.0",
55
- "eslint-config-prettier": "8.8.0",
54
+ "eslint": "8.51.0",
55
+ "eslint-config-prettier": "8.10.0",
56
56
  "eslint-config-react-app": "7.0.1",
57
- "eslint-plugin-cypress": "2.13.3",
57
+ "eslint-plugin-cypress": "2.15.1",
58
58
  "eslint-plugin-flowtype": "8.0.3",
59
- "eslint-plugin-import": "2.27.5",
59
+ "eslint-plugin-import": "2.28.1",
60
60
  "eslint-plugin-jsx-a11y": "6.7.1",
61
61
  "eslint-plugin-prettier": "4.2.1",
62
- "eslint-plugin-react": "7.32.2",
62
+ "eslint-plugin-react": "7.33.2",
63
63
  "eslint-plugin-react-hooks": "4.6.0",
64
- "eslint-plugin-testing-library": "5.11.0",
64
+ "eslint-plugin-testing-library": "5.11.1",
65
65
  "jest": "27.5.1",
66
66
  "npm-package-json-lint": "5.4.2",
67
67
  "prettier": "2.8.8",
68
68
  "react": "18.2.0",
69
69
  "react-docgen-typescript-loader": "3.7.2",
70
70
  "react-dom": "18.2.0",
71
- "sass": "1.63.6",
71
+ "sass": "1.69.3",
72
72
  "sass-loader": "10.4.1",
73
73
  "style-loader": "3.3.3",
74
- "stylelint": "15.10.1",
74
+ "stylelint": "15.11.0",
75
75
  "stylelint-config-prettier": "9.0.5",
76
76
  "stylelint-config-recommended-scss": "5.0.2",
77
77
  "stylelint-order": "5.0.0",
78
78
  "stylelint-prettier": "2.0.0",
79
79
  "ts-jest": "27.1.5",
80
- "tsc-alias": "1.8.6",
80
+ "tsc-alias": "1.8.8",
81
81
  "typescript": "4.9.5",
82
- "vanilla-framework": "4.2.0",
82
+ "vanilla-framework": "4.5.0",
83
83
  "wait-on": "5.3.0",
84
- "webpack": "5.88.0"
84
+ "webpack": "5.89.0"
85
85
  },
86
86
  "dependencies": {
87
87
  "@types/jest": "27.5.2",
88
- "@types/node": "18.16.18",
89
- "@types/react": "18.2.14",
90
- "@types/react-dom": "18.2.6",
91
- "@types/react-table": "7.7.14",
88
+ "@types/node": "18.18.5",
89
+ "@types/react": "18.2.28",
90
+ "@types/react-dom": "18.2.13",
91
+ "@types/react-table": "7.7.16",
92
92
  "classnames": "2.3.2",
93
93
  "nanoid": "3.3.6",
94
94
  "prop-types": "15.8.1",
95
- "react-router-dom": "6.6.1",
95
+ "react-router-dom": "6.17.0",
96
96
  "react-table": "7.8.0",
97
97
  "react-useportal": "1.0.18"
98
98
  },
99
99
  "resolutions": {
100
- "@types/react": "18.2.14",
101
- "@types/react-dom": "18.2.6",
100
+ "@types/react": "18.2.28",
101
+ "@types/react-dom": "18.2.13",
102
102
  "postcss": "^8.3.11"
103
103
  },
104
104
  "peerDependencies": {