qbs-react-grid 1.0.38 → 1.0.40
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 +7 -0
- package/es/qbsTable/QbsTable.js +7 -6
- package/lib/Pagination.js +7 -0
- package/lib/qbsTable/QbsTable.js +7 -6
- package/package.json +1 -1
- package/src/Pagination.tsx +15 -1
- package/src/qbsTable/QbsTable.tsx +8 -5
package/es/Pagination.js
CHANGED
|
@@ -4,7 +4,9 @@ var PageIndex = function PageIndex(_ref) {
|
|
|
4
4
|
var currentIndex = _ref.currentIndex,
|
|
5
5
|
handleFirst = _ref.handleFirst,
|
|
6
6
|
pageCount = _ref.pageCount;
|
|
7
|
+
console.log(currentIndex, 'insdie subfunction');
|
|
7
8
|
var renderPageNumbers = function renderPageNumbers() {
|
|
9
|
+
console.log(currentIndex, 'insdie last function');
|
|
8
10
|
var pageNumbers = [];
|
|
9
11
|
|
|
10
12
|
// Add ellipsis if necessary
|
|
@@ -71,6 +73,9 @@ var Pagination = function Pagination(_ref2) {
|
|
|
71
73
|
setCurrenIndex(value);
|
|
72
74
|
onPagination === null || onPagination === void 0 ? void 0 : onPagination(value, currentIndex);
|
|
73
75
|
};
|
|
76
|
+
useEffect(function () {
|
|
77
|
+
setCurrenIndex(currentIndex);
|
|
78
|
+
}, [currentPage]);
|
|
74
79
|
useEffect(function () {
|
|
75
80
|
var calculatedPageCount = Math.ceil(total / rowsPerPageState);
|
|
76
81
|
setPageCount(calculatedPageCount);
|
|
@@ -83,6 +88,7 @@ var Pagination = function Pagination(_ref2) {
|
|
|
83
88
|
setCurrenIndex(currentIndex + 1);
|
|
84
89
|
onPagination === null || onPagination === void 0 ? void 0 : onPagination(currentIndex + 1, currentIndex);
|
|
85
90
|
};
|
|
91
|
+
console.log(currentIndex, 'outside function');
|
|
86
92
|
return /*#__PURE__*/React.createElement("div", {
|
|
87
93
|
className: 'qbs-table-custom-pagination',
|
|
88
94
|
style: {
|
|
@@ -132,6 +138,7 @@ var Pagination = function Pagination(_ref2) {
|
|
|
132
138
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
133
139
|
className: "block-container"
|
|
134
140
|
}, /*#__PURE__*/React.createElement(PageIndex, {
|
|
141
|
+
key: currentIndex,
|
|
135
142
|
currentIndex: currentIndex,
|
|
136
143
|
handleFirst: handleFirst,
|
|
137
144
|
pageCount: pageCount
|
package/es/qbsTable/QbsTable.js
CHANGED
|
@@ -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
|
-
|
|
109
|
-
|
|
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;
|
|
@@ -364,8 +365,8 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
364
365
|
onChange: handleCheckAll,
|
|
365
366
|
id: "checkbox-all",
|
|
366
367
|
className: "qbs-table-checkbox-input " + classes.tableCheckBoxClass,
|
|
367
|
-
checked: data.every(function (item) {
|
|
368
|
-
return checkedKeys.includes(item.id);
|
|
368
|
+
checked: (data === null || data === void 0 ? void 0 : data.length) > 0 && data.every(function (item) {
|
|
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
|
@@ -10,7 +10,9 @@ var PageIndex = function PageIndex(_ref) {
|
|
|
10
10
|
var currentIndex = _ref.currentIndex,
|
|
11
11
|
handleFirst = _ref.handleFirst,
|
|
12
12
|
pageCount = _ref.pageCount;
|
|
13
|
+
console.log(currentIndex, 'insdie subfunction');
|
|
13
14
|
var renderPageNumbers = function renderPageNumbers() {
|
|
15
|
+
console.log(currentIndex, 'insdie last function');
|
|
14
16
|
var pageNumbers = [];
|
|
15
17
|
|
|
16
18
|
// Add ellipsis if necessary
|
|
@@ -77,6 +79,9 @@ var Pagination = function Pagination(_ref2) {
|
|
|
77
79
|
setCurrenIndex(value);
|
|
78
80
|
onPagination === null || onPagination === void 0 ? void 0 : onPagination(value, currentIndex);
|
|
79
81
|
};
|
|
82
|
+
(0, _react.useEffect)(function () {
|
|
83
|
+
setCurrenIndex(currentIndex);
|
|
84
|
+
}, [currentPage]);
|
|
80
85
|
(0, _react.useEffect)(function () {
|
|
81
86
|
var calculatedPageCount = Math.ceil(total / rowsPerPageState);
|
|
82
87
|
setPageCount(calculatedPageCount);
|
|
@@ -89,6 +94,7 @@ var Pagination = function Pagination(_ref2) {
|
|
|
89
94
|
setCurrenIndex(currentIndex + 1);
|
|
90
95
|
onPagination === null || onPagination === void 0 ? void 0 : onPagination(currentIndex + 1, currentIndex);
|
|
91
96
|
};
|
|
97
|
+
console.log(currentIndex, 'outside function');
|
|
92
98
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
93
99
|
className: 'qbs-table-custom-pagination',
|
|
94
100
|
style: {
|
|
@@ -138,6 +144,7 @@ var Pagination = function Pagination(_ref2) {
|
|
|
138
144
|
}))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
139
145
|
className: "block-container"
|
|
140
146
|
}, /*#__PURE__*/_react["default"].createElement(PageIndex, {
|
|
147
|
+
key: currentIndex,
|
|
141
148
|
currentIndex: currentIndex,
|
|
142
149
|
handleFirst: handleFirst,
|
|
143
150
|
pageCount: pageCount
|
package/lib/qbsTable/QbsTable.js
CHANGED
|
@@ -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
|
-
|
|
116
|
-
|
|
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;
|
|
@@ -371,8 +372,8 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
371
372
|
onChange: handleCheckAll,
|
|
372
373
|
id: "checkbox-all",
|
|
373
374
|
className: "qbs-table-checkbox-input " + classes.tableCheckBoxClass,
|
|
374
|
-
checked: data.every(function (item) {
|
|
375
|
-
return checkedKeys.includes(item.id);
|
|
375
|
+
checked: (data === null || data === void 0 ? void 0 : data.length) > 0 && data.every(function (item) {
|
|
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
package/src/Pagination.tsx
CHANGED
|
@@ -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 = {
|
|
@@ -13,7 +14,10 @@ type PageProps = {
|
|
|
13
14
|
};
|
|
14
15
|
};
|
|
15
16
|
const PageIndex = ({ currentIndex, handleFirst, pageCount }) => {
|
|
17
|
+
console.log(currentIndex, 'insdie subfunction');
|
|
16
18
|
const renderPageNumbers = () => {
|
|
19
|
+
console.log(currentIndex, 'insdie last function');
|
|
20
|
+
|
|
17
21
|
const pageNumbers: any = [];
|
|
18
22
|
|
|
19
23
|
// Add ellipsis if necessary
|
|
@@ -84,6 +88,9 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
84
88
|
setCurrenIndex(value);
|
|
85
89
|
onPagination?.(value, currentIndex);
|
|
86
90
|
};
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
setCurrenIndex(currentIndex);
|
|
93
|
+
}, [currentPage]);
|
|
87
94
|
|
|
88
95
|
useEffect(() => {
|
|
89
96
|
const calculatedPageCount = Math.ceil(total / rowsPerPageState);
|
|
@@ -98,6 +105,8 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
98
105
|
setCurrenIndex(currentIndex + 1);
|
|
99
106
|
onPagination?.(currentIndex + 1, currentIndex);
|
|
100
107
|
};
|
|
108
|
+
console.log(currentIndex, 'outside function');
|
|
109
|
+
|
|
101
110
|
return (
|
|
102
111
|
<div
|
|
103
112
|
className={'qbs-table-custom-pagination'}
|
|
@@ -154,7 +163,12 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
154
163
|
</svg>
|
|
155
164
|
</button>
|
|
156
165
|
<div className="block-container">
|
|
157
|
-
<PageIndex
|
|
166
|
+
<PageIndex
|
|
167
|
+
key={currentIndex}
|
|
168
|
+
currentIndex={currentIndex}
|
|
169
|
+
handleFirst={handleFirst}
|
|
170
|
+
pageCount={pageCount}
|
|
171
|
+
/>
|
|
158
172
|
</div>
|
|
159
173
|
<button
|
|
160
174
|
className="qbs-table-icon-container"
|
|
@@ -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
|
-
|
|
93
|
-
|
|
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
|
|
393
|
+
checked={data?.length > 0 && 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>
|
|
447
|
+
<div>
|
|
448
|
+
{pagination && data?.length > 0 && <Pagination paginationProps={paginationProps} />}
|
|
449
|
+
</div>
|
|
447
450
|
</div>
|
|
448
451
|
</div>
|
|
449
452
|
);
|