qbs-react-grid 1.0.38 → 1.0.39

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.
package/es/Pagination.js CHANGED
@@ -71,6 +71,9 @@ var Pagination = function Pagination(_ref2) {
71
71
  setCurrenIndex(value);
72
72
  onPagination === null || onPagination === void 0 ? void 0 : onPagination(value, currentIndex);
73
73
  };
74
+ useEffect(function () {
75
+ setCurrenIndex(currentIndex);
76
+ }, [currentPage]);
74
77
  useEffect(function () {
75
78
  var calculatedPageCount = Math.ceil(total / rowsPerPageState);
76
79
  setPageCount(calculatedPageCount);
@@ -9,9 +9,9 @@ import Table from '../Table';
9
9
  import { ActionCell, CheckCell, CustomTableCell, ExpandCell } from './CustomTableCell';
10
10
  import ToolBar from './Toolbar';
11
11
  import ColumToggle from './utilities/ColumShowHide';
12
+ import debounce from './utilities/debounce';
12
13
  import { SettingsIcon } from './utilities/icons';
13
14
  import '../../dist/css/qbs-react-grid.css';
14
- import debounce from './utilities/debounce';
15
15
  var CHECKBOX_LINE_HEIGHT = '36px';
16
16
  var COLUMN_WIDTH = 250;
17
17
  var QbsTable = function QbsTable(_ref) {
@@ -105,8 +105,9 @@ var QbsTable = function QbsTable(_ref) {
105
105
  var keys = event.target.checked ? data.map(function (item) {
106
106
  return item.id;
107
107
  }) : [];
108
- setCheckedKeys(keys);
109
- handleChecked(keys);
108
+ var updatedKeys = [].concat(checkedKeys, keys);
109
+ setCheckedKeys(updatedKeys);
110
+ handleChecked(updatedKeys);
110
111
  }, [data]);
111
112
  var handleCheck = useCallback(function (event) {
112
113
  var value = event.target.value;
@@ -365,7 +366,7 @@ var QbsTable = function QbsTable(_ref) {
365
366
  id: "checkbox-all",
366
367
  className: "qbs-table-checkbox-input " + classes.tableCheckBoxClass,
367
368
  checked: data.every(function (item) {
368
- return checkedKeys.includes(item.id);
369
+ return checkedKeys === null || checkedKeys === void 0 ? void 0 : checkedKeys.includes(item.id);
369
370
  })
370
371
  }), /*#__PURE__*/React.createElement("label", {
371
372
  htmlFor: "checkbox-all"
@@ -402,7 +403,7 @@ var QbsTable = function QbsTable(_ref) {
402
403
  className: classes.cellClass + " " + classes.actionCellClass,
403
404
  handleMenuActions: handleMenuActions,
404
405
  dataTheme: dataTheme
405
- }))), /*#__PURE__*/React.createElement("div", null, pagination && /*#__PURE__*/React.createElement(Pagination, {
406
+ }))), /*#__PURE__*/React.createElement("div", null, pagination && (data === null || data === void 0 ? void 0 : data.length) > 0 && /*#__PURE__*/React.createElement(Pagination, {
406
407
  paginationProps: paginationProps
407
408
  }))));
408
409
  };
package/lib/Pagination.js CHANGED
@@ -77,6 +77,9 @@ var Pagination = function Pagination(_ref2) {
77
77
  setCurrenIndex(value);
78
78
  onPagination === null || onPagination === void 0 ? void 0 : onPagination(value, currentIndex);
79
79
  };
80
+ (0, _react.useEffect)(function () {
81
+ setCurrenIndex(currentIndex);
82
+ }, [currentPage]);
80
83
  (0, _react.useEffect)(function () {
81
84
  var calculatedPageCount = Math.ceil(total / rowsPerPageState);
82
85
  setPageCount(calculatedPageCount);
@@ -14,9 +14,9 @@ var _Table = _interopRequireDefault(require("../Table"));
14
14
  var _CustomTableCell = require("./CustomTableCell");
15
15
  var _Toolbar = _interopRequireDefault(require("./Toolbar"));
16
16
  var _ColumShowHide = _interopRequireDefault(require("./utilities/ColumShowHide"));
17
+ var _debounce = _interopRequireDefault(require("./utilities/debounce"));
17
18
  var _icons = require("./utilities/icons");
18
19
  require("../../dist/css/qbs-react-grid.css");
19
- var _debounce = _interopRequireDefault(require("./utilities/debounce"));
20
20
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
21
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
22
22
  var CHECKBOX_LINE_HEIGHT = '36px';
@@ -112,8 +112,9 @@ var QbsTable = function QbsTable(_ref) {
112
112
  var keys = event.target.checked ? data.map(function (item) {
113
113
  return item.id;
114
114
  }) : [];
115
- setCheckedKeys(keys);
116
- handleChecked(keys);
115
+ var updatedKeys = [].concat(checkedKeys, keys);
116
+ setCheckedKeys(updatedKeys);
117
+ handleChecked(updatedKeys);
117
118
  }, [data]);
118
119
  var handleCheck = (0, _react.useCallback)(function (event) {
119
120
  var value = event.target.value;
@@ -372,7 +373,7 @@ var QbsTable = function QbsTable(_ref) {
372
373
  id: "checkbox-all",
373
374
  className: "qbs-table-checkbox-input " + classes.tableCheckBoxClass,
374
375
  checked: data.every(function (item) {
375
- return checkedKeys.includes(item.id);
376
+ return checkedKeys === null || checkedKeys === void 0 ? void 0 : checkedKeys.includes(item.id);
376
377
  })
377
378
  }), /*#__PURE__*/_react["default"].createElement("label", {
378
379
  htmlFor: "checkbox-all"
@@ -409,7 +410,7 @@ var QbsTable = function QbsTable(_ref) {
409
410
  className: classes.cellClass + " " + classes.actionCellClass,
410
411
  handleMenuActions: handleMenuActions,
411
412
  dataTheme: dataTheme
412
- }))), /*#__PURE__*/_react["default"].createElement("div", null, pagination && /*#__PURE__*/_react["default"].createElement(_Pagination["default"], {
413
+ }))), /*#__PURE__*/_react["default"].createElement("div", null, pagination && (data === null || data === void 0 ? void 0 : data.length) > 0 && /*#__PURE__*/_react["default"].createElement(_Pagination["default"], {
413
414
  paginationProps: paginationProps
414
415
  }))));
415
416
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qbs-react-grid",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "description": "A React table component",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -1,4 +1,5 @@
1
1
  import React, { FC, useEffect, useState } from 'react';
2
+
2
3
  import { getRowDisplayRange } from './qbsTable/utilities/tablecalc';
3
4
 
4
5
  type PageProps = {
@@ -84,6 +85,9 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
84
85
  setCurrenIndex(value);
85
86
  onPagination?.(value, currentIndex);
86
87
  };
88
+ useEffect(() => {
89
+ setCurrenIndex(currentIndex);
90
+ }, [currentPage]);
87
91
 
88
92
  useEffect(() => {
89
93
  const calculatedPageCount = Math.ceil(total / rowsPerPageState);
@@ -10,10 +10,10 @@ import { QbsColumnProps, QbsTableProps } from './commontypes';
10
10
  import { ActionCell, CheckCell, CustomTableCell, ExpandCell } from './CustomTableCell';
11
11
  import ToolBar from './Toolbar';
12
12
  import ColumToggle from './utilities/ColumShowHide';
13
+ import debounce from './utilities/debounce';
13
14
  import { SettingsIcon } from './utilities/icons';
14
15
 
15
16
  import '../../dist/css/qbs-react-grid.css';
16
- import debounce from './utilities/debounce';
17
17
 
18
18
  const CHECKBOX_LINE_HEIGHT = '36px';
19
19
  const COLUMN_WIDTH = 250;
@@ -89,8 +89,9 @@ const QbsTable: React.FC<QbsTableProps> = ({
89
89
  const handleCheckAll = useCallback(
90
90
  (event: React.ChangeEvent<HTMLInputElement>) => {
91
91
  const keys = event.target.checked ? data.map(item => item.id) : [];
92
- setCheckedKeys(keys);
93
- handleChecked(keys);
92
+ const updatedKeys = [...checkedKeys, ...keys];
93
+ setCheckedKeys(updatedKeys);
94
+ handleChecked(updatedKeys);
94
95
  },
95
96
  [data]
96
97
  );
@@ -389,7 +390,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
389
390
  onChange={handleCheckAll}
390
391
  id={`checkbox-all`}
391
392
  className={`qbs-table-checkbox-input ${classes.tableCheckBoxClass}`}
392
- checked={data.every(item => checkedKeys.includes(item.id))}
393
+ checked={data.every(item => checkedKeys?.includes(item.id))}
393
394
  />
394
395
  <label htmlFor={`checkbox-all`}>
395
396
  <svg
@@ -443,7 +444,9 @@ const QbsTable: React.FC<QbsTableProps> = ({
443
444
  </Column>
444
445
  )}
445
446
  </Table>
446
- <div>{pagination && <Pagination paginationProps={paginationProps} />}</div>
447
+ <div>
448
+ {pagination && data?.length > 0 && <Pagination paginationProps={paginationProps} />}
449
+ </div>
447
450
  </div>
448
451
  </div>
449
452
  );