qbs-react-grid 1.0.46 → 1.0.47
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/dist/css/qbs-react-grid.css +11 -11
- package/dist/css/qbs-react-grid.min.css +1 -1
- package/dist/css/qbs-react-grid.min.css.map +1 -1
- package/es/Pagination.js +15 -23
- package/es/less/pagination.less +12 -12
- package/es/qbsTable/CustomTableCell.js +14 -12
- package/es/qbsTable/QbsTable.js +30 -9
- package/es/qbsTable/commontypes.d.ts +1 -0
- package/es/qbsTable/utilities/deepEqual.d.ts +1 -0
- package/es/qbsTable/utilities/deepEqual.js +38 -0
- package/lib/Pagination.js +15 -23
- package/lib/less/pagination.less +12 -12
- package/lib/qbsTable/CustomTableCell.js +14 -12
- package/lib/qbsTable/QbsTable.js +29 -8
- package/lib/qbsTable/commontypes.d.ts +1 -0
- package/lib/qbsTable/utilities/deepEqual.d.ts +1 -0
- package/lib/qbsTable/utilities/deepEqual.js +42 -0
- package/package.json +1 -1
- package/src/Pagination.tsx +15 -22
- package/src/less/pagination.less +12 -12
- package/src/qbsTable/CustomTableCell.tsx +11 -12
- package/src/qbsTable/QbsTable.tsx +26 -9
- package/src/qbsTable/commontypes.ts +1 -0
- package/src/qbsTable/utilities/deepEqual.ts +37 -0
package/lib/Pagination.js
CHANGED
|
@@ -48,7 +48,7 @@ var Pagination = function Pagination(_ref2) {
|
|
|
48
48
|
_paginationProps$curr = paginationProps.currentPage,
|
|
49
49
|
currentPage = _paginationProps$curr === void 0 ? 1 : _paginationProps$curr,
|
|
50
50
|
_paginationProps$tota = paginationProps.total,
|
|
51
|
-
total = _paginationProps$tota === void 0 ?
|
|
51
|
+
total = _paginationProps$tota === void 0 ? 0 : _paginationProps$tota,
|
|
52
52
|
onRowsPerPage = paginationProps.onRowsPerPage,
|
|
53
53
|
_paginationProps$rows = paginationProps.rowsPerPage,
|
|
54
54
|
rowsPerPage = _paginationProps$rows === void 0 ? 10 : _paginationProps$rows,
|
|
@@ -66,28 +66,20 @@ var Pagination = function Pagination(_ref2) {
|
|
|
66
66
|
onRowsPerPage === null || onRowsPerPage === void 0 ? void 0 : onRowsPerPage(value, currentPage);
|
|
67
67
|
};
|
|
68
68
|
var handleFirst = function handleFirst(index) {
|
|
69
|
-
// setCurrenIndex(index);
|
|
70
69
|
onPagination === null || onPagination === void 0 ? void 0 : onPagination(index, currentPage);
|
|
71
70
|
};
|
|
72
71
|
var handleLast = function handleLast() {
|
|
73
72
|
var value = pageCount != null ? pageCount : 0;
|
|
74
|
-
// setCurrenIndex(value);
|
|
75
73
|
onPagination === null || onPagination === void 0 ? void 0 : onPagination(value, currentPage);
|
|
76
74
|
};
|
|
77
|
-
// useEffect(() => {
|
|
78
|
-
// setCurrenIndex(currentPage);
|
|
79
|
-
// }, [currentPage]);
|
|
80
|
-
|
|
81
75
|
(0, _react.useEffect)(function () {
|
|
82
76
|
var calculatedPageCount = Math.ceil(total / rowsPerPageState);
|
|
83
77
|
setPageCount(calculatedPageCount);
|
|
84
78
|
}, [total, rowsPerPageState]);
|
|
85
79
|
var handlePrevious = function handlePrevious() {
|
|
86
|
-
// setCurrenIndex(currentPage - 1);
|
|
87
80
|
onPagination === null || onPagination === void 0 ? void 0 : onPagination(currentPage - 1, currentPage);
|
|
88
81
|
};
|
|
89
82
|
var handleNext = function handleNext() {
|
|
90
|
-
// setCurrenIndex(currentPage + 1);
|
|
91
83
|
onPagination === null || onPagination === void 0 ? void 0 : onPagination(currentPage + 1, currentPage);
|
|
92
84
|
};
|
|
93
85
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -115,9 +107,9 @@ var Pagination = function Pagination(_ref2) {
|
|
|
115
107
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
116
108
|
d: "M9.16667 15.8333L3.33334 9.99996L9.16667 4.16663M15.8333 15.8333L10 9.99996L15.8333 4.16663",
|
|
117
109
|
stroke: "#313131",
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
110
|
+
strokeWidth: "1.5",
|
|
111
|
+
strokeLinecap: "round",
|
|
112
|
+
strokeLinejoin: "round"
|
|
121
113
|
}))), /*#__PURE__*/_react["default"].createElement("button", {
|
|
122
114
|
className: "qbs-table-icon-container",
|
|
123
115
|
disabled: currentPage < 2,
|
|
@@ -133,9 +125,9 @@ var Pagination = function Pagination(_ref2) {
|
|
|
133
125
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
134
126
|
d: "M12.5 15.8334L6.66666 10L12.5 4.16669",
|
|
135
127
|
stroke: "#313131",
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
128
|
+
strokeWidth: "1.5",
|
|
129
|
+
strokeLinecap: "round",
|
|
130
|
+
strokeLinejoin: "round"
|
|
139
131
|
}))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
140
132
|
className: "block-container"
|
|
141
133
|
}, /*#__PURE__*/_react["default"].createElement(PageIndex, {
|
|
@@ -145,7 +137,7 @@ var Pagination = function Pagination(_ref2) {
|
|
|
145
137
|
pageCount: pageCount
|
|
146
138
|
})), /*#__PURE__*/_react["default"].createElement("button", {
|
|
147
139
|
className: "qbs-table-icon-container",
|
|
148
|
-
disabled: currentPage
|
|
140
|
+
disabled: currentPage === pageCount || pageCount === 0,
|
|
149
141
|
onClick: function onClick() {
|
|
150
142
|
return handleNext();
|
|
151
143
|
}
|
|
@@ -158,12 +150,12 @@ var Pagination = function Pagination(_ref2) {
|
|
|
158
150
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
159
151
|
d: "M7.5 4.16669L13.3333 10L7.5 15.8334",
|
|
160
152
|
stroke: "#313131",
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
153
|
+
strokeWidth: "1.5",
|
|
154
|
+
strokeLinecap: "round",
|
|
155
|
+
strokeLinejoin: "round"
|
|
164
156
|
}))), /*#__PURE__*/_react["default"].createElement("button", {
|
|
165
157
|
className: "qbs-table-icon-container",
|
|
166
|
-
disabled: currentPage == pageCount,
|
|
158
|
+
disabled: currentPage == pageCount || pageCount === 0,
|
|
167
159
|
onClick: function onClick() {
|
|
168
160
|
return handleLast();
|
|
169
161
|
}
|
|
@@ -176,9 +168,9 @@ var Pagination = function Pagination(_ref2) {
|
|
|
176
168
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
177
169
|
d: "M10.8333 4.16663L16.6667 9.99996L10.8333 15.8333M4.16666 4.16663L10 9.99996L4.16666 15.8333",
|
|
178
170
|
stroke: "#313131",
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
171
|
+
strokeWidth: "1.5",
|
|
172
|
+
strokeLinecap: "round",
|
|
173
|
+
strokeLinejoin: "round"
|
|
182
174
|
})))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
183
175
|
className: "qbs-table-pagination-flexBox"
|
|
184
176
|
}, /*#__PURE__*/_react["default"].createElement("span", {
|
package/lib/less/pagination.less
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
min-height: 40px;
|
|
6
6
|
align-items: center;
|
|
7
7
|
border-radius: 4px;
|
|
8
|
-
border-top: 1px solid #
|
|
9
|
-
background: #
|
|
8
|
+
border-top: 1px solid #d6d8dc;
|
|
9
|
+
background: #fff;
|
|
10
10
|
&-header {
|
|
11
11
|
border-bottom: 1px solid #eee;
|
|
12
12
|
position: absolute;
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
font-weight: 500;
|
|
28
28
|
line-height: 20px;
|
|
29
29
|
border-radius: 6px;
|
|
30
|
-
border: 1px solid #
|
|
31
|
-
background: #
|
|
30
|
+
border: 1px solid #d6d8dc;
|
|
31
|
+
background: #fff;
|
|
32
32
|
}
|
|
33
33
|
.qbs-table-icon-container {
|
|
34
34
|
padding: 0;
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
justify-items: center;
|
|
38
38
|
align-items: center;
|
|
39
39
|
color: black;
|
|
40
|
-
height: 100%;
|
|
41
40
|
background-color: transparent;
|
|
42
41
|
width: 24px;
|
|
43
42
|
height: 24px;
|
|
@@ -48,6 +47,7 @@
|
|
|
48
47
|
}
|
|
49
48
|
&:disabled {
|
|
50
49
|
color: grey;
|
|
50
|
+
cursor: not-allowed;
|
|
51
51
|
}
|
|
52
52
|
svg {
|
|
53
53
|
width: 16px;
|
|
@@ -80,19 +80,19 @@
|
|
|
80
80
|
border: 1px solid transparent;
|
|
81
81
|
transition: all 0.2s ease;
|
|
82
82
|
&:hover {
|
|
83
|
-
border-color: #
|
|
84
|
-
color: #
|
|
83
|
+
border-color: #e76458;
|
|
84
|
+
color: #e76458;
|
|
85
85
|
transition: all 0.2s ease;
|
|
86
86
|
}
|
|
87
87
|
&:active {
|
|
88
|
-
border-color: #
|
|
89
|
-
color: #
|
|
88
|
+
border-color: #e76458;
|
|
89
|
+
color: #e76458;
|
|
90
90
|
transition: all 0.2s ease;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
.selected {
|
|
94
|
-
color: #
|
|
95
|
-
border: 1px solid #
|
|
94
|
+
color: #e76458;
|
|
95
|
+
border: 1px solid #e76458;
|
|
96
96
|
transition: all 0.2s ease;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -115,4 +115,4 @@
|
|
|
115
115
|
|
|
116
116
|
.qbs-table-custom-pagination .qbs-table-pagination-dropdown:focus {
|
|
117
117
|
outline: none;
|
|
118
|
-
}
|
|
118
|
+
}
|
|
@@ -8,7 +8,6 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _Cell = _interopRequireDefault(require("../Cell"));
|
|
10
10
|
var _menuDropDown = _interopRequireDefault(require("./utilities/menuDropDown"));
|
|
11
|
-
var _ToolTip = _interopRequireDefault(require("./utilities/ToolTip"));
|
|
12
11
|
var _excluded = ["rowData", "onChange", "checkedKeys", "dataKey", "dataTheme"],
|
|
13
12
|
_excluded2 = ["rowData", "dataKey", "expandedRowKeys", "onChange"],
|
|
14
13
|
_excluded3 = ["rowData", "renderCell", "toolTip", "dataKey", "onChange", "rowClick", "link"];
|
|
@@ -80,7 +79,7 @@ var ExpandCell = /*#__PURE__*/_react["default"].memo(function (_ref3) {
|
|
|
80
79
|
});
|
|
81
80
|
exports.ExpandCell = ExpandCell;
|
|
82
81
|
var CustomTableCell = /*#__PURE__*/_react["default"].memo(function (_ref4) {
|
|
83
|
-
var _renderCell, _renderCell2
|
|
82
|
+
var _renderCell, _renderCell2;
|
|
84
83
|
var rowData = _ref4.rowData,
|
|
85
84
|
renderCell = _ref4.renderCell,
|
|
86
85
|
toolTip = _ref4.toolTip,
|
|
@@ -89,15 +88,18 @@ var CustomTableCell = /*#__PURE__*/_react["default"].memo(function (_ref4) {
|
|
|
89
88
|
rowClick = _ref4.rowClick,
|
|
90
89
|
link = _ref4.link,
|
|
91
90
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref4, _excluded3);
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
91
|
+
return (
|
|
92
|
+
/*#__PURE__*/
|
|
93
|
+
// <TooltipComponent title={renderCell ? renderCell(rowData)?.toolTip : toolTip}>
|
|
94
|
+
_react["default"].createElement(_Cell["default"], (0, _extends2["default"])({}, props, {
|
|
95
|
+
dataKey: dataKey
|
|
96
|
+
}), link ? /*#__PURE__*/_react["default"].createElement("a", {
|
|
97
|
+
onClick: function onClick() {
|
|
98
|
+
return rowClick === null || rowClick === void 0 ? void 0 : rowClick(rowData);
|
|
99
|
+
},
|
|
100
|
+
className: "qbs-table-row-link"
|
|
101
|
+
}, renderCell ? (_renderCell = renderCell(rowData)) === null || _renderCell === void 0 ? void 0 : _renderCell.cell : rowData[dataKey]) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (_renderCell2 = renderCell(rowData)) === null || _renderCell2 === void 0 ? void 0 : _renderCell2.cell))
|
|
102
|
+
// </TooltipComponent>
|
|
103
|
+
);
|
|
102
104
|
});
|
|
103
105
|
exports.CustomTableCell = CustomTableCell;
|
package/lib/qbsTable/QbsTable.js
CHANGED
|
@@ -17,6 +17,7 @@ var _ColumShowHide = _interopRequireDefault(require("./utilities/ColumShowHide")
|
|
|
17
17
|
var _debounce = _interopRequireDefault(require("./utilities/debounce"));
|
|
18
18
|
var _icons = require("./utilities/icons");
|
|
19
19
|
require("../../dist/css/qbs-react-grid.css");
|
|
20
|
+
var _deepEqual = require("./utilities/deepEqual");
|
|
20
21
|
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
22
|
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
23
|
var CHECKBOX_LINE_HEIGHT = '36px';
|
|
@@ -95,6 +96,7 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
95
96
|
var _useState4 = (0, _react.useState)(false),
|
|
96
97
|
isOpen = _useState4[0],
|
|
97
98
|
setIsOpen = _useState4[1];
|
|
99
|
+
var prevColumns = (0, _react.useRef)();
|
|
98
100
|
var handleSortColumn = (0, _react.useCallback)(function (sortColumn, sortType) {
|
|
99
101
|
setLoading(true);
|
|
100
102
|
setTimeout(function () {
|
|
@@ -116,10 +118,7 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
116
118
|
var keys = event.target.checked ? data.map(function (item) {
|
|
117
119
|
return item.id;
|
|
118
120
|
}) : [];
|
|
119
|
-
var updatedKeys = [].concat(keys);
|
|
120
|
-
if (checkedKeys) {
|
|
121
|
-
updatedKeys = [].concat(checkedKeys, updatedKeys);
|
|
122
|
-
}
|
|
121
|
+
var updatedKeys = [].concat(checkedKeys, keys);
|
|
123
122
|
setCheckedKeys(updatedKeys);
|
|
124
123
|
handleChecked(updatedKeys);
|
|
125
124
|
}, [data]);
|
|
@@ -166,9 +165,10 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
166
165
|
var onReorder = (0, _react.useCallback)(function (columns) {
|
|
167
166
|
setColumns(columns);
|
|
168
167
|
}, []);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}, [columns]);
|
|
168
|
+
|
|
169
|
+
// useEffect(() => {
|
|
170
|
+
// }, [columns]);
|
|
171
|
+
|
|
172
172
|
var handleClear = function handleClear(_ref2) {
|
|
173
173
|
setCheckedKeys([]);
|
|
174
174
|
handleChecked([]);
|
|
@@ -192,7 +192,8 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
192
192
|
checkedKeys: checkedKeys,
|
|
193
193
|
tableHeaderActions: tableHeaderActions,
|
|
194
194
|
selectedRowActions: selectedRowActions,
|
|
195
|
-
onSelect: handleClear
|
|
195
|
+
onSelect: handleClear,
|
|
196
|
+
handleColumnToggle: handleColumnToggle
|
|
196
197
|
};
|
|
197
198
|
var themeToggle = (0, _react.useMemo)(function () {
|
|
198
199
|
return document.getElementById('themeToggle');
|
|
@@ -250,6 +251,26 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
250
251
|
});
|
|
251
252
|
return largestCellLength;
|
|
252
253
|
}
|
|
254
|
+
var handleColumnsResizable = (0, _react.useCallback)(function () {
|
|
255
|
+
var _filteredColumns$leng;
|
|
256
|
+
var filteredColumns = columns === null || columns === void 0 ? void 0 : columns.filter(function (item) {
|
|
257
|
+
return item.isVisible;
|
|
258
|
+
});
|
|
259
|
+
var length = (_filteredColumns$leng = filteredColumns === null || filteredColumns === void 0 ? void 0 : filteredColumns.length) != null ? _filteredColumns$leng : 0;
|
|
260
|
+
var lastVisibleColumn = filteredColumns[length - 1];
|
|
261
|
+
var reColumns = columns === null || columns === void 0 ? void 0 : columns.map(function (item) {
|
|
262
|
+
return (item === null || item === void 0 ? void 0 : item.field) === (lastVisibleColumn === null || lastVisibleColumn === void 0 ? void 0 : lastVisibleColumn.field) ? (0, _extends2["default"])({}, item, {
|
|
263
|
+
resizable: false
|
|
264
|
+
}) : item;
|
|
265
|
+
});
|
|
266
|
+
setColumns(reColumns);
|
|
267
|
+
}, [columns]);
|
|
268
|
+
(0, _react.useEffect)(function () {
|
|
269
|
+
if (!(0, _deepEqual.deepEqual)(columns, prevColumns.current)) {
|
|
270
|
+
handleColumnsResizable();
|
|
271
|
+
}
|
|
272
|
+
prevColumns.current = columns;
|
|
273
|
+
}, [columns, handleColumnsResizable]);
|
|
253
274
|
var columnsRendered = (0, _react.useMemo)(function () {
|
|
254
275
|
return (columns != null ? columns : []).map(function (_ref3) {
|
|
255
276
|
var title = _ref3.title,
|
|
@@ -117,6 +117,7 @@ export interface QbsTableToolbarProps {
|
|
|
117
117
|
checkedKeys?: (number | string)[];
|
|
118
118
|
tableHeaderActions?: ReactElement | ReactNode;
|
|
119
119
|
onSelect?: (keys: any[]) => void;
|
|
120
|
+
handleColumnToggle?: (columns: QbsColumnProps[]) => void;
|
|
120
121
|
selectedRowActions?: {
|
|
121
122
|
actionTitle?: string;
|
|
122
123
|
action: (checked: (number | string)[]) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deepEqual(value1: any, value2: any): boolean;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.deepEqual = deepEqual;
|
|
5
|
+
function deepEqual(value1, value2) {
|
|
6
|
+
if (value1 === value2) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
if (typeof value1 !== typeof value2) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (value1 === null || value2 === null) {
|
|
13
|
+
return value1 === value2;
|
|
14
|
+
}
|
|
15
|
+
if (typeof value1 === 'object' && typeof value2 === 'object') {
|
|
16
|
+
if (Array.isArray(value1) && Array.isArray(value2)) {
|
|
17
|
+
if (value1.length !== value2.length) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
for (var i = 0; i < value1.length; i++) {
|
|
21
|
+
if (!deepEqual(value1[i], value2[i])) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
} else if (!Array.isArray(value1) && !Array.isArray(value2)) {
|
|
27
|
+
var keys1 = Object.keys(value1);
|
|
28
|
+
var keys2 = Object.keys(value2);
|
|
29
|
+
if (keys1.length !== keys2.length) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
for (var _i = 0, _keys = keys1; _i < _keys.length; _i++) {
|
|
33
|
+
var key = _keys[_i];
|
|
34
|
+
if (!keys2.includes(key) || !deepEqual(value1[key], value2[key])) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
package/package.json
CHANGED
package/src/Pagination.tsx
CHANGED
|
@@ -59,7 +59,7 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
59
59
|
const {
|
|
60
60
|
dropOptions = [10, 20, 50, 100, 200],
|
|
61
61
|
currentPage = 1,
|
|
62
|
-
total =
|
|
62
|
+
total = 0,
|
|
63
63
|
onRowsPerPage,
|
|
64
64
|
rowsPerPage = 10,
|
|
65
65
|
onPagination
|
|
@@ -75,18 +75,13 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
75
75
|
onRowsPerPage?.(value, currentPage);
|
|
76
76
|
};
|
|
77
77
|
const handleFirst = (index: number) => {
|
|
78
|
-
// setCurrenIndex(index);
|
|
79
78
|
onPagination?.(index, currentPage);
|
|
80
79
|
};
|
|
81
80
|
|
|
82
81
|
const handleLast = () => {
|
|
83
82
|
const value = pageCount ?? 0;
|
|
84
|
-
// setCurrenIndex(value);
|
|
85
83
|
onPagination?.(value, currentPage);
|
|
86
84
|
};
|
|
87
|
-
// useEffect(() => {
|
|
88
|
-
// setCurrenIndex(currentPage);
|
|
89
|
-
// }, [currentPage]);
|
|
90
85
|
|
|
91
86
|
useEffect(() => {
|
|
92
87
|
const calculatedPageCount = Math.ceil(total / rowsPerPageState);
|
|
@@ -94,11 +89,9 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
94
89
|
}, [total, rowsPerPageState]);
|
|
95
90
|
|
|
96
91
|
const handlePrevious = () => {
|
|
97
|
-
// setCurrenIndex(currentPage - 1);
|
|
98
92
|
onPagination?.(currentPage - 1, currentPage);
|
|
99
93
|
};
|
|
100
94
|
const handleNext = () => {
|
|
101
|
-
// setCurrenIndex(currentPage + 1);
|
|
102
95
|
onPagination?.(currentPage + 1, currentPage);
|
|
103
96
|
};
|
|
104
97
|
|
|
@@ -130,9 +123,9 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
130
123
|
<path
|
|
131
124
|
d="M9.16667 15.8333L3.33334 9.99996L9.16667 4.16663M15.8333 15.8333L10 9.99996L15.8333 4.16663"
|
|
132
125
|
stroke="#313131"
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
126
|
+
strokeWidth="1.5"
|
|
127
|
+
strokeLinecap="round"
|
|
128
|
+
strokeLinejoin="round"
|
|
136
129
|
/>
|
|
137
130
|
</svg>
|
|
138
131
|
</button>
|
|
@@ -151,9 +144,9 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
151
144
|
<path
|
|
152
145
|
d="M12.5 15.8334L6.66666 10L12.5 4.16669"
|
|
153
146
|
stroke="#313131"
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
147
|
+
strokeWidth="1.5"
|
|
148
|
+
strokeLinecap="round"
|
|
149
|
+
strokeLinejoin="round"
|
|
157
150
|
/>
|
|
158
151
|
</svg>
|
|
159
152
|
</button>
|
|
@@ -167,7 +160,7 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
167
160
|
</div>
|
|
168
161
|
<button
|
|
169
162
|
className="qbs-table-icon-container"
|
|
170
|
-
disabled={currentPage
|
|
163
|
+
disabled={currentPage === pageCount || pageCount === 0}
|
|
171
164
|
onClick={() => handleNext()}
|
|
172
165
|
>
|
|
173
166
|
<svg
|
|
@@ -180,15 +173,15 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
180
173
|
<path
|
|
181
174
|
d="M7.5 4.16669L13.3333 10L7.5 15.8334"
|
|
182
175
|
stroke="#313131"
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
176
|
+
strokeWidth="1.5"
|
|
177
|
+
strokeLinecap="round"
|
|
178
|
+
strokeLinejoin="round"
|
|
186
179
|
/>
|
|
187
180
|
</svg>
|
|
188
181
|
</button>
|
|
189
182
|
<button
|
|
190
183
|
className="qbs-table-icon-container"
|
|
191
|
-
disabled={currentPage == pageCount}
|
|
184
|
+
disabled={currentPage == pageCount || pageCount === 0}
|
|
192
185
|
onClick={() => handleLast()}
|
|
193
186
|
>
|
|
194
187
|
<svg
|
|
@@ -201,9 +194,9 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
201
194
|
<path
|
|
202
195
|
d="M10.8333 4.16663L16.6667 9.99996L10.8333 15.8333M4.16666 4.16663L10 9.99996L4.16666 15.8333"
|
|
203
196
|
stroke="#313131"
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
197
|
+
strokeWidth="1.5"
|
|
198
|
+
strokeLinecap="round"
|
|
199
|
+
strokeLinejoin="round"
|
|
207
200
|
/>
|
|
208
201
|
</svg>
|
|
209
202
|
</button>
|
package/src/less/pagination.less
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
min-height: 40px;
|
|
6
6
|
align-items: center;
|
|
7
7
|
border-radius: 4px;
|
|
8
|
-
border-top: 1px solid #
|
|
9
|
-
background: #
|
|
8
|
+
border-top: 1px solid #d6d8dc;
|
|
9
|
+
background: #fff;
|
|
10
10
|
&-header {
|
|
11
11
|
border-bottom: 1px solid #eee;
|
|
12
12
|
position: absolute;
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
font-weight: 500;
|
|
28
28
|
line-height: 20px;
|
|
29
29
|
border-radius: 6px;
|
|
30
|
-
border: 1px solid #
|
|
31
|
-
background: #
|
|
30
|
+
border: 1px solid #d6d8dc;
|
|
31
|
+
background: #fff;
|
|
32
32
|
}
|
|
33
33
|
.qbs-table-icon-container {
|
|
34
34
|
padding: 0;
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
justify-items: center;
|
|
38
38
|
align-items: center;
|
|
39
39
|
color: black;
|
|
40
|
-
height: 100%;
|
|
41
40
|
background-color: transparent;
|
|
42
41
|
width: 24px;
|
|
43
42
|
height: 24px;
|
|
@@ -48,6 +47,7 @@
|
|
|
48
47
|
}
|
|
49
48
|
&:disabled {
|
|
50
49
|
color: grey;
|
|
50
|
+
cursor: not-allowed;
|
|
51
51
|
}
|
|
52
52
|
svg {
|
|
53
53
|
width: 16px;
|
|
@@ -80,19 +80,19 @@
|
|
|
80
80
|
border: 1px solid transparent;
|
|
81
81
|
transition: all 0.2s ease;
|
|
82
82
|
&:hover {
|
|
83
|
-
border-color: #
|
|
84
|
-
color: #
|
|
83
|
+
border-color: #e76458;
|
|
84
|
+
color: #e76458;
|
|
85
85
|
transition: all 0.2s ease;
|
|
86
86
|
}
|
|
87
87
|
&:active {
|
|
88
|
-
border-color: #
|
|
89
|
-
color: #
|
|
88
|
+
border-color: #e76458;
|
|
89
|
+
color: #e76458;
|
|
90
90
|
transition: all 0.2s ease;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
.selected {
|
|
94
|
-
color: #
|
|
95
|
-
border: 1px solid #
|
|
94
|
+
color: #e76458;
|
|
95
|
+
border: 1px solid #e76458;
|
|
96
96
|
transition: all 0.2s ease;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -115,4 +115,4 @@
|
|
|
115
115
|
|
|
116
116
|
.qbs-table-custom-pagination .qbs-table-pagination-dropdown:focus {
|
|
117
117
|
outline: none;
|
|
118
|
-
}
|
|
118
|
+
}
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import Cell from '../Cell';
|
|
4
4
|
import MenuDropDown from './utilities/menuDropDown';
|
|
5
|
-
import TooltipComponent from './utilities/ToolTip';
|
|
6
5
|
|
|
7
6
|
const CHECKBOX_LINE_HEIGHT = '36px';
|
|
8
7
|
|
|
@@ -64,17 +63,17 @@ export const ExpandCell: React.FC<any> = React.memo(
|
|
|
64
63
|
export const CustomTableCell: React.FC<any> = React.memo(
|
|
65
64
|
({ rowData, renderCell, toolTip, dataKey, onChange, rowClick, link, ...props }) => {
|
|
66
65
|
return (
|
|
67
|
-
<TooltipComponent title={renderCell ? renderCell(rowData)?.toolTip : toolTip}>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
</TooltipComponent>
|
|
66
|
+
// <TooltipComponent title={renderCell ? renderCell(rowData)?.toolTip : toolTip}>
|
|
67
|
+
<Cell {...props} dataKey={dataKey}>
|
|
68
|
+
{link ? (
|
|
69
|
+
<a onClick={() => rowClick?.(rowData)} className="qbs-table-row-link">
|
|
70
|
+
{renderCell ? renderCell(rowData)?.cell : rowData[dataKey]}
|
|
71
|
+
</a>
|
|
72
|
+
) : (
|
|
73
|
+
<>{renderCell(rowData)?.cell}</>
|
|
74
|
+
)}
|
|
75
|
+
</Cell>
|
|
76
|
+
// </TooltipComponent>
|
|
78
77
|
);
|
|
79
78
|
}
|
|
80
79
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState, useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import Cell from '../Cell';
|
|
4
4
|
import Column from '../Column';
|
|
@@ -14,6 +14,7 @@ import debounce from './utilities/debounce';
|
|
|
14
14
|
import { SettingsIcon } from './utilities/icons';
|
|
15
15
|
|
|
16
16
|
import '../../dist/css/qbs-react-grid.css';
|
|
17
|
+
import { deepEqual } from './utilities/deepEqual';
|
|
17
18
|
|
|
18
19
|
const CHECKBOX_LINE_HEIGHT = '36px';
|
|
19
20
|
const COLUMN_WIDTH = 250;
|
|
@@ -67,6 +68,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
67
68
|
const [checkedKeys, setCheckedKeys] = useState<(number | string)[]>([]);
|
|
68
69
|
const dataTheme = useMemo(() => localStorage.getItem('theme') ?? theme, [theme]);
|
|
69
70
|
const [isOpen, setIsOpen] = useState(false);
|
|
71
|
+
const prevColumns = useRef<any | null>();
|
|
70
72
|
|
|
71
73
|
const handleSortColumn = useCallback(
|
|
72
74
|
(sortColumn: any, sortType: any) => {
|
|
@@ -93,10 +95,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
93
95
|
const handleCheckAll = useCallback(
|
|
94
96
|
(event: React.ChangeEvent<HTMLInputElement>) => {
|
|
95
97
|
const keys = event.target.checked ? data.map(item => item.id) : [];
|
|
96
|
-
let updatedKeys = [...keys];
|
|
97
|
-
if (checkedKeys) {
|
|
98
|
-
updatedKeys = [...checkedKeys, ...updatedKeys];
|
|
99
|
-
}
|
|
98
|
+
let updatedKeys = [...checkedKeys, ...keys];
|
|
100
99
|
setCheckedKeys(updatedKeys);
|
|
101
100
|
handleChecked(updatedKeys);
|
|
102
101
|
},
|
|
@@ -146,9 +145,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
146
145
|
setColumns(columns);
|
|
147
146
|
}, []);
|
|
148
147
|
|
|
149
|
-
useEffect(() => {
|
|
150
|
-
|
|
151
|
-
}, [columns]);
|
|
148
|
+
// useEffect(() => {
|
|
149
|
+
// }, [columns]);
|
|
152
150
|
|
|
153
151
|
const handleClear = ([]) => {
|
|
154
152
|
setCheckedKeys([]);
|
|
@@ -173,9 +171,11 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
173
171
|
checkedKeys: checkedKeys,
|
|
174
172
|
tableHeaderActions: tableHeaderActions,
|
|
175
173
|
selectedRowActions: selectedRowActions,
|
|
176
|
-
onSelect: handleClear
|
|
174
|
+
onSelect: handleClear,
|
|
175
|
+
handleColumnToggle: handleColumnToggle
|
|
177
176
|
};
|
|
178
177
|
const themeToggle = useMemo(() => document.getElementById('themeToggle') as HTMLInputElement, []);
|
|
178
|
+
|
|
179
179
|
useEffect(() => {
|
|
180
180
|
const handleThemeToggle = () => {
|
|
181
181
|
if (themeToggle?.checked) {
|
|
@@ -236,6 +236,23 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
236
236
|
|
|
237
237
|
return largestCellLength;
|
|
238
238
|
}
|
|
239
|
+
const handleColumnsResizable = useCallback(() => {
|
|
240
|
+
const filteredColumns = columns?.filter(item => item.isVisible);
|
|
241
|
+
const length = filteredColumns?.length ?? 0;
|
|
242
|
+
const lastVisibleColumn = filteredColumns[length - 1];
|
|
243
|
+
const reColumns = columns?.map(item =>
|
|
244
|
+
item?.field === lastVisibleColumn?.field ? { ...item, resizable: false } : item
|
|
245
|
+
);
|
|
246
|
+
setColumns(reColumns);
|
|
247
|
+
}, [columns]);
|
|
248
|
+
|
|
249
|
+
useEffect(() => {
|
|
250
|
+
if (!deepEqual(columns, prevColumns.current)) {
|
|
251
|
+
handleColumnsResizable();
|
|
252
|
+
}
|
|
253
|
+
prevColumns.current = columns;
|
|
254
|
+
}, [columns, handleColumnsResizable]);
|
|
255
|
+
|
|
239
256
|
const columnsRendered: React.ReactElement[] = useMemo(
|
|
240
257
|
() =>
|
|
241
258
|
(columns ?? []).map(
|
|
@@ -121,6 +121,7 @@ export interface QbsTableToolbarProps {
|
|
|
121
121
|
checkedKeys?: (number | string)[];
|
|
122
122
|
tableHeaderActions?: ReactElement | ReactNode;
|
|
123
123
|
onSelect?: (keys: any[]) => void;
|
|
124
|
+
handleColumnToggle?: (columns: QbsColumnProps[]) => void;
|
|
124
125
|
selectedRowActions?: {
|
|
125
126
|
actionTitle?: string;
|
|
126
127
|
action: (checked: (number | string)[]) => void;
|