@canonical/react-components 2.7.2 → 2.7.3

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.
@@ -70,6 +70,8 @@ const TablePaginationControls = _ref => {
70
70
  const handlePageSizeChange = e => {
71
71
  onPageSizeChange(parseInt(e.target.value));
72
72
  };
73
+ const isInputDisabled = !totalPages || totalPages == 1;
74
+ const maxPageValue = typeof totalPages === "number" ? totalPages : 1;
73
75
  return /*#__PURE__*/_react.default.createElement("div", _extends({
74
76
  className: (0, _classnames.default)("pagination", className)
75
77
  }, divProps, {
@@ -82,7 +84,7 @@ const TablePaginationControls = _ref => {
82
84
  className: "back",
83
85
  appearance: "base",
84
86
  hasIcon: true,
85
- disabled: currentPage === 1,
87
+ disabled: isInputDisabled || currentPage === 1,
86
88
  onClick: () => handleDecrementPage(currentPage)
87
89
  }, previousButtonProps), previousButtonProps !== null && previousButtonProps !== void 0 && previousButtonProps.children ? previousButtonProps.children : /*#__PURE__*/_react.default.createElement(_Icon.default, {
88
90
  name: "chevron-down"
@@ -93,13 +95,16 @@ const TablePaginationControls = _ref => {
93
95
  className: "u-no-margin--bottom pagination-input",
94
96
  onChange: handleInputPageChange,
95
97
  value: currentPage,
96
- type: "number"
98
+ type: "number",
99
+ disabled: isInputDisabled,
100
+ min: 1,
101
+ max: maxPageValue
97
102
  }), " ", typeof totalPages === "number" ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "of\xA0", totalPages) : null) : null, /*#__PURE__*/_react.default.createElement(_Button.default, _extends({
98
103
  "aria-label": Label.NEXT_PAGE,
99
104
  className: "next",
100
105
  appearance: "base",
101
106
  hasIcon: true,
102
- disabled: currentPage === totalPages,
107
+ disabled: isInputDisabled || currentPage === totalPages,
103
108
  onClick: () => handleIncrementPage(currentPage, totalPages)
104
109
  }, nextButtonProps), /*#__PURE__*/_react.default.createElement(_Icon.default, {
105
110
  name: "chevron-down"
@@ -66,6 +66,8 @@ var TablePaginationControls = _ref => {
66
66
  var handlePageSizeChange = e => {
67
67
  onPageSizeChange(parseInt(e.target.value));
68
68
  };
69
+ var isInputDisabled = !totalPages || totalPages == 1;
70
+ var maxPageValue = typeof totalPages === "number" ? totalPages : 1;
69
71
  return /*#__PURE__*/React.createElement("div", _extends({
70
72
  className: classnames("pagination", className)
71
73
  }, divProps, {
@@ -78,7 +80,7 @@ var TablePaginationControls = _ref => {
78
80
  className: "back",
79
81
  appearance: "base",
80
82
  hasIcon: true,
81
- disabled: currentPage === 1,
83
+ disabled: isInputDisabled || currentPage === 1,
82
84
  onClick: () => handleDecrementPage(currentPage)
83
85
  }, previousButtonProps), previousButtonProps !== null && previousButtonProps !== void 0 && previousButtonProps.children ? previousButtonProps.children : /*#__PURE__*/React.createElement(Icon, {
84
86
  name: "chevron-down"
@@ -89,13 +91,16 @@ var TablePaginationControls = _ref => {
89
91
  className: "u-no-margin--bottom pagination-input",
90
92
  onChange: handleInputPageChange,
91
93
  value: currentPage,
92
- type: "number"
94
+ type: "number",
95
+ disabled: isInputDisabled,
96
+ min: 1,
97
+ max: maxPageValue
93
98
  }), " ", typeof totalPages === "number" ? /*#__PURE__*/React.createElement(React.Fragment, null, "of\xA0", totalPages) : null) : null, /*#__PURE__*/React.createElement(Button, _extends({
94
99
  "aria-label": Label.NEXT_PAGE,
95
100
  className: "next",
96
101
  appearance: "base",
97
102
  hasIcon: true,
98
- disabled: currentPage === totalPages,
103
+ disabled: isInputDisabled || currentPage === totalPages,
99
104
  onClick: () => handleIncrementPage(currentPage, totalPages)
100
105
  }, nextButtonProps), /*#__PURE__*/React.createElement(Icon, {
101
106
  name: "chevron-down"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-components",
3
- "version": "2.7.2",
3
+ "version": "2.7.3",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": {