qbs-react-grid 2.2.16 → 2.2.18
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 +1 -1
- package/dist/css/qbs-react-grid.min.css +1 -1
- package/dist/css/qbs-react-grid.min.css.map +1 -1
- package/es/Cell.js +2 -1
- package/es/Pagination.d.ts +3 -0
- package/es/Pagination.js +8 -3
- package/es/Table.d.ts +3 -0
- package/es/Table.js +18 -12
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/less/pagination.less +9 -9
- package/es/less/qbs-table.less +1 -2
- package/es/qbsTable/QbsTable.js +110 -73
- package/es/qbsTable/TableCardList.js +2 -0
- package/es/qbsTable/Toolbar.js +6 -3
- package/es/qbsTable/commontypes.d.ts +21 -12
- package/es/qbsTable/labels.d.ts +6 -2
- package/es/qbsTable/labels.js +10 -1
- package/es/qbsTable/utilities/CardComponent.d.ts +2 -0
- package/es/qbsTable/utilities/CardComponent.js +7 -3
- package/es/qbsTable/utilities/CardMenuDropdown.d.ts +2 -0
- package/es/qbsTable/utilities/CardMenuDropdown.js +7 -7
- package/es/qbsTable/utilities/SearchInput.d.ts +1 -0
- package/es/qbsTable/utilities/SearchInput.js +3 -1
- package/es/qbsTable/utilities/empty.js +1 -1
- package/es/qbsTable/utilities/tablecalc.d.ts +1 -1
- package/es/qbsTable/utilities/tablecalc.js +7 -2
- package/es/utils/useCellDescriptor.js +0 -1
- package/es/utils/useScrollListener.d.ts +1 -0
- package/es/utils/useScrollListener.js +5 -3
- package/lib/Cell.js +2 -1
- package/lib/Pagination.d.ts +3 -0
- package/lib/Pagination.js +8 -3
- package/lib/Table.d.ts +3 -0
- package/lib/Table.js +18 -12
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -1
- package/lib/less/pagination.less +9 -9
- package/lib/less/qbs-table.less +1 -2
- package/lib/qbsTable/QbsTable.js +110 -73
- package/lib/qbsTable/TableCardList.js +2 -0
- package/lib/qbsTable/Toolbar.js +6 -3
- package/lib/qbsTable/commontypes.d.ts +21 -12
- package/lib/qbsTable/labels.d.ts +6 -2
- package/lib/qbsTable/labels.js +13 -2
- package/lib/qbsTable/utilities/CardComponent.d.ts +2 -0
- package/lib/qbsTable/utilities/CardComponent.js +7 -3
- package/lib/qbsTable/utilities/CardMenuDropdown.d.ts +2 -0
- package/lib/qbsTable/utilities/CardMenuDropdown.js +6 -5
- package/lib/qbsTable/utilities/SearchInput.d.ts +1 -0
- package/lib/qbsTable/utilities/SearchInput.js +3 -1
- package/lib/qbsTable/utilities/empty.js +1 -1
- package/lib/qbsTable/utilities/tablecalc.d.ts +1 -1
- package/lib/qbsTable/utilities/tablecalc.js +7 -2
- package/lib/utils/useCellDescriptor.js +0 -1
- package/lib/utils/useScrollListener.d.ts +1 -0
- package/lib/utils/useScrollListener.js +5 -3
- package/package.json +2 -2
- package/src/Cell.tsx +3 -1
- package/src/HeaderCell.tsx +0 -1
- package/src/Pagination.tsx +10 -3
- package/src/Table.tsx +23 -10
- package/src/customSelect.tsx +88 -88
- package/src/index.ts +2 -0
- package/src/less/pagination.less +9 -9
- package/src/less/qbs-table.less +1 -2
- package/src/qbsTable/QbsTable.tsx +84 -39
- package/src/qbsTable/TableCardList.tsx +2 -0
- package/src/qbsTable/Toolbar.tsx +4 -2
- package/src/qbsTable/commontypes.ts +21 -12
- package/src/qbsTable/labels.ts +9 -2
- package/src/qbsTable/utilities/CardComponent.tsx +7 -2
- package/src/qbsTable/utilities/CardMenuDropdown.tsx +11 -6
- package/src/qbsTable/utilities/SearchInput.tsx +3 -1
- package/src/qbsTable/utilities/empty.tsx +2 -2
- package/src/qbsTable/utilities/tablecalc.ts +8 -2
- package/src/utils/useCellDescriptor.ts +0 -1
- package/src/utils/useScrollListener.ts +13 -3
- package/src/utils/useTableRows.ts +1 -1
|
@@ -7,6 +7,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
7
7
|
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; }
|
|
8
8
|
var SearchInput = function SearchInput(_ref) {
|
|
9
9
|
var placeholder = _ref.placeholder,
|
|
10
|
+
_ref$searchAriaLabel = _ref.searchAriaLabel,
|
|
11
|
+
searchAriaLabel = _ref$searchAriaLabel === void 0 ? 'Search' : _ref$searchAriaLabel,
|
|
10
12
|
handleChange = _ref.handleChange,
|
|
11
13
|
searchValue = _ref.searchValue,
|
|
12
14
|
handleSearch = _ref.handleSearch;
|
|
@@ -30,7 +32,7 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
30
32
|
placeholder: placeholder,
|
|
31
33
|
value: searchValue != null ? searchValue : '',
|
|
32
34
|
onChange: handleInputChange,
|
|
33
|
-
"aria-label":
|
|
35
|
+
"aria-label": searchAriaLabel
|
|
34
36
|
}), /*#__PURE__*/_react["default"].createElement("button", {
|
|
35
37
|
className: "search-button absolute left-1 bottom-1.5 bg-white text-grey-dark",
|
|
36
38
|
onClick: function onClick() {
|
|
@@ -75,7 +75,7 @@ var NoData = function NoData(_ref) {
|
|
|
75
75
|
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
76
76
|
fill: "#797979",
|
|
77
77
|
d: "M47.365 57.417a.926.926 0 00.926-.927v-1.777a.926.926 0 10-1.852 0v1.777c0 .512.415.927.926.927zM104.183 57.417a.926.926 0 00.926-.927v-1.777a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 52.974a.926.926 0 00.926-.927V50.27a.926.926 0 00-1.852 0v1.777c0 .512.415.927.926.927zM104.183 52.974a.926.926 0 00.926-.927V50.27a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 44.088a.926.926 0 00.926-.927v-1.777a.926.926 0 10-1.852 0v1.777c0 .512.415.927.926.927zM104.183 44.088a.926.926 0 00.926-.927v-1.777a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 39.645a.926.926 0 00.926-.927v-1.777a.926.926 0 10-1.852 0v1.777c0 .512.415.927.926.927zM104.183 39.645a.926.926 0 00.926-.927v-1.777a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 35.202a.926.926 0 00.926-.927v-1.777a.926.926 0 10-1.852 0v1.777c0 .512.415.927.926.927zM104.183 35.202a.926.926 0 00.926-.927v-1.777a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 30.758a.926.926 0 00.926-.926v-.888c0-.248.02-.49.057-.726a.926.926 0 00-1.83-.288c-.052.33-.08.67-.08 1.014v.888c0 .512.416.926.927.926zM104.183 30.758a.926.926 0 00.926-.926v-.888c0-.345-.027-.683-.079-1.014a.926.926 0 10-1.83.288c.037.236.057.478.057.726v.888c0 .512.414.926.926.926zM47.881 26.426a.926.926 0 001.294-.204c.286-.394.633-.74 1.026-1.026a.926.926 0 00-1.09-1.498c-.55.4-1.034.884-1.434 1.434a.926.926 0 00.204 1.294zM103.667 26.426a.926.926 0 00.204-1.294 6.509 6.509 0 00-1.434-1.434.926.926 0 00-1.09 1.498c.393.286.74.632 1.026 1.026a.926.926 0 001.294.204zM51.138 23.597c.08.506.554.851 1.059.772a4.67 4.67 0 01.726-.057h.914a.926.926 0 000-1.852h-.914c-.344 0-.683.026-1.014.078a.926.926 0 00-.77 1.06zM100.41 23.597a.927.927 0 00-.771-1.059 6.522 6.522 0 00-1.014-.078h-.914a.926.926 0 100 1.852h.914c.248 0 .49.02.726.057a.926.926 0 001.059-.772zM55.653 23.386c0 .511.415.926.926.926h1.828a.926.926 0 000-1.852H56.58a.926.926 0 00-.926.926zM60.223 23.386c0 .511.415.926.926.926h1.828a.926.926 0 000-1.852H61.15a.926.926 0 00-.926.926zM64.793 23.386c0 .511.415.926.926.926h1.829a.926.926 0 000-1.852h-1.829a.926.926 0 00-.926.926zM69.364 23.386c0 .511.414.926.926.926h1.828a.926.926 0 000-1.852H70.29a.926.926 0 00-.927.926zM73.934 23.386c0 .511.414.926.926.926h1.828a.926.926 0 000-1.852H74.86a.926.926 0 00-.926.926zM78.504 23.386c0 .511.415.926.926.926h1.828a.926.926 0 000-1.852H79.43a.926.926 0 00-.926.926zM83.074 23.386c0 .511.415.926.927.926h1.828a.926.926 0 000-1.852H84a.926.926 0 00-.927.926zM87.644 23.386c0 .511.415.926.927.926h1.828a.926.926 0 000-1.852H88.57a.926.926 0 00-.927.926zM92.215 23.386c0 .511.414.926.926.926h1.828a.926.926 0 000-1.852h-1.828a.926.926 0 00-.926.926zM72.178 36.453a1.39 1.39 0 10-1.965 1.965l3.797 3.797-3.797 3.798a1.39 1.39 0 001.965 1.965l3.797-3.798 3.798 3.798a1.39 1.39 0 001.965-1.965l-3.798-3.798 3.798-3.797a1.39 1.39 0 10-1.965-1.965l-3.798 3.797-3.797-3.797z"
|
|
78
|
-
})),
|
|
78
|
+
})), ' '), /*#__PURE__*/_react["default"].createElement("p", {
|
|
79
79
|
className: "text-center text-common font-bold text-blackAlt nodata-title"
|
|
80
80
|
}, title), /*#__PURE__*/_react["default"].createElement("span", {
|
|
81
81
|
className: "text-xxs font-medium text-grey-medium nodata-sub-title"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getRowDisplayRange(totalRows: number, rowsPerPage: number, pageNumber: number): string;
|
|
1
|
+
export declare function getRowDisplayRange(totalRows: number, rowsPerPage: number, pageNumber: number, formatRange?: (start: number, end: number, total: number) => string): string;
|
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.getRowDisplayRange = getRowDisplayRange;
|
|
5
|
-
function getRowDisplayRange(totalRows, rowsPerPage, pageNumber) {
|
|
5
|
+
function getRowDisplayRange(totalRows, rowsPerPage, pageNumber, formatRange) {
|
|
6
|
+
if (formatRange === void 0) {
|
|
7
|
+
formatRange = function formatRange(start, end, total) {
|
|
8
|
+
return "Showing " + start + " to " + end + " of " + total;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
6
11
|
var start = (pageNumber - 1) * rowsPerPage + 1;
|
|
7
12
|
var end = Math.min(pageNumber * rowsPerPage, totalRows);
|
|
8
|
-
return
|
|
13
|
+
return formatRange(start != null ? start : 0, end != null ? end : 0, totalRows != null ? totalRows : 0);
|
|
9
14
|
}
|
|
@@ -158,7 +158,6 @@ var useCellDescriptor = function useCellDescriptor(props) {
|
|
|
158
158
|
if (treeCol) {
|
|
159
159
|
hasCustomTreeCol = true;
|
|
160
160
|
}
|
|
161
|
-
console.log(columns);
|
|
162
161
|
if ((columnChildren === null || columnChildren === void 0 ? void 0 : columnChildren.length) !== 2) {
|
|
163
162
|
throw new Error("Component <HeaderCell> and <Cell> is required, column index: " + index + " ");
|
|
164
163
|
}
|
|
@@ -31,6 +31,7 @@ interface ScrollListenerProps {
|
|
|
31
31
|
onTouchStart?: (event: React.TouchEvent) => void;
|
|
32
32
|
onTouchMove?: (event: React.TouchEvent) => void;
|
|
33
33
|
onTouchEnd?: (event: React.TouchEvent) => void;
|
|
34
|
+
handleInfiniteScroll?: (value: number) => void;
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* Add scroll, touch, and wheel monitoring events to the table,
|
|
@@ -72,7 +72,8 @@ var useScrollListener = function useScrollListener(props) {
|
|
|
72
72
|
contentHeight = props.contentHeight,
|
|
73
73
|
headerHeight = props.headerHeight,
|
|
74
74
|
rtl = props.rtl,
|
|
75
|
-
tableKey = props.tableKey
|
|
75
|
+
tableKey = props.tableKey,
|
|
76
|
+
handleInfiniteScroll = props.handleInfiniteScroll;
|
|
76
77
|
var wheelListener = (0, _react.useRef)(null);
|
|
77
78
|
var touchStartListener = (0, _react.useRef)(null);
|
|
78
79
|
var touchMoveListener = (0, _react.useRef)(null);
|
|
@@ -134,6 +135,9 @@ var useScrollListener = function useScrollListener(props) {
|
|
|
134
135
|
var x = Math.min(0, nextScrollX < minScrollX.current ? minScrollX.current : nextScrollX);
|
|
135
136
|
setScrollX(x);
|
|
136
137
|
setScrollY(y);
|
|
138
|
+
if (typeof handleInfiniteScroll === 'function' && deltaY !== 0 && !loading && Math.abs(y) + getTableHeight() >= contentHeight.current - 12) {
|
|
139
|
+
handleInfiniteScroll(scrollY.current);
|
|
140
|
+
}
|
|
137
141
|
onScroll === null || onScroll === void 0 ? void 0 : onScroll(Math.abs(x), Math.abs(y));
|
|
138
142
|
if (virtualized) {
|
|
139
143
|
// Add a state to the table during virtualized scrolling.
|
|
@@ -211,7 +215,6 @@ var useScrollListener = function useScrollListener(props) {
|
|
|
211
215
|
if (!isTouching.current) {
|
|
212
216
|
return;
|
|
213
217
|
}
|
|
214
|
-
console.log('handleTouchMove');
|
|
215
218
|
var _event$touches$2 = event.touches[0],
|
|
216
219
|
pageX = _event$touches$2.pageX,
|
|
217
220
|
pageY = _event$touches$2.pageY;
|
|
@@ -245,7 +248,6 @@ var useScrollListener = function useScrollListener(props) {
|
|
|
245
248
|
if (!isTouching.current) {
|
|
246
249
|
return;
|
|
247
250
|
}
|
|
248
|
-
console.log('handleTouchEnd');
|
|
249
251
|
isTouching.current = false;
|
|
250
252
|
var touchDuration = new Date().getTime() - momentumStartTime.current;
|
|
251
253
|
var absDeltaY = Math.abs(scrollY.current - momentumStartY.current);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qbs-react-grid",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.18",
|
|
4
4
|
"description": "A React table component",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"@commitlint/cli": "^13.1.0",
|
|
81
81
|
"@commitlint/config-conventional": "^13.1.0",
|
|
82
82
|
"@faker-js/faker": "^7.6.0",
|
|
83
|
-
"@testing-library/react": "^
|
|
83
|
+
"@testing-library/react": "^16.2.0",
|
|
84
84
|
"@types/lodash": "^4.14.165",
|
|
85
85
|
"@types/prop-types": "^15.7.1",
|
|
86
86
|
"@types/react": "^19.0.11",
|
package/src/Cell.tsx
CHANGED
|
@@ -144,11 +144,13 @@ const Cell = React.forwardRef((props: InnerCellProps, ref: React.Ref<HTMLDivElem
|
|
|
144
144
|
};
|
|
145
145
|
|
|
146
146
|
const paddingKey = rtl ? 'paddingRight' : 'paddingLeft';
|
|
147
|
+
const resolvedAlign =
|
|
148
|
+
rtl && align === 'left' ? 'right' : rtl && align === 'right' ? 'left' : align;
|
|
147
149
|
const contentStyles: React.CSSProperties = {
|
|
148
150
|
...style,
|
|
149
151
|
width: fullText ? width - 1 : width,
|
|
150
152
|
height: nextHeight,
|
|
151
|
-
textAlign:
|
|
153
|
+
textAlign: resolvedAlign,
|
|
152
154
|
[paddingKey]: isTreeCol ? depth * LAYER_WIDTH + 10 : style?.[paddingKey] || style?.padding
|
|
153
155
|
};
|
|
154
156
|
|
package/src/HeaderCell.tsx
CHANGED
|
@@ -97,7 +97,6 @@ const HeaderCell = React.forwardRef((props: HeaderCellProps, ref: React.Ref<HTML
|
|
|
97
97
|
onSortColumn?.(sortKey ?? dataKey);
|
|
98
98
|
}
|
|
99
99
|
}, [dataKey, onSortColumn, sortable, sortKey]);
|
|
100
|
-
|
|
101
100
|
const handleColumnResizeStart = useCallback(() => {
|
|
102
101
|
onColumnResizeStart?.(columnWidth, left, !!fixed);
|
|
103
102
|
}, [columnWidth, fixed, left, onColumnResizeStart]);
|
package/src/Pagination.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { FC, useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import CustomSelect from './customSelect';
|
|
4
|
+
import { mergeLabels, type QbsTableLabels } from './qbsTable/labels';
|
|
4
5
|
import { getRowDisplayRange } from './qbsTable/utilities/tablecalc';
|
|
5
6
|
|
|
6
7
|
// Import the custom select component
|
|
@@ -15,6 +16,8 @@ type PageProps = {
|
|
|
15
16
|
onRowsPerPage?: (row: number, page: number) => void;
|
|
16
17
|
onPagination?: (row: number, page: number) => void;
|
|
17
18
|
};
|
|
19
|
+
labels?: QbsTableLabels;
|
|
20
|
+
dataTheme?: string;
|
|
18
21
|
};
|
|
19
22
|
|
|
20
23
|
const PageIndex = ({ currentPage, handleFirst, pageCount }) => {
|
|
@@ -52,7 +55,8 @@ const PageIndex = ({ currentPage, handleFirst, pageCount }) => {
|
|
|
52
55
|
return <>{renderPageNumbers()}</>;
|
|
53
56
|
};
|
|
54
57
|
|
|
55
|
-
const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
58
|
+
const Pagination: FC<PageProps> = ({ paginationProps, labels: labelsProp, dataTheme }) => {
|
|
59
|
+
const labels = mergeLabels(labelsProp);
|
|
56
60
|
const {
|
|
57
61
|
dropOptions = [10, 20, 50, 100, 200],
|
|
58
62
|
currentPage = 1,
|
|
@@ -96,9 +100,12 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
96
100
|
return (
|
|
97
101
|
<div
|
|
98
102
|
className="qbs-table-custom-pagination"
|
|
103
|
+
data-theme={dataTheme}
|
|
99
104
|
style={{ display: 'flex', justifyContent: 'space-between' }}
|
|
100
105
|
>
|
|
101
|
-
<div className="rows-count">
|
|
106
|
+
<div className="rows-count">
|
|
107
|
+
{getRowDisplayRange(total, rowsPerPageState, currentPage, labels.showingRange)}
|
|
108
|
+
</div>
|
|
102
109
|
<div className="qbs-table-pagination-right-block">
|
|
103
110
|
<button
|
|
104
111
|
className="qbs-table-icon-container"
|
|
@@ -194,7 +201,7 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
194
201
|
</button>
|
|
195
202
|
</div>
|
|
196
203
|
<div className="qbs-table-pagination-flexBox">
|
|
197
|
-
<span className="qbs-table-pagination-text">
|
|
204
|
+
<span className="qbs-table-pagination-text">{labels.itemsPerPage}</span>
|
|
198
205
|
<CustomSelect
|
|
199
206
|
options={dropData}
|
|
200
207
|
selectedValue={rowsPerPageState}
|
package/src/Table.tsx
CHANGED
|
@@ -224,6 +224,7 @@ export interface TableProps<Row, Key> extends Omit<StandardProps, 'onScroll'> {
|
|
|
224
224
|
expanded?: boolean
|
|
225
225
|
) => React.ReactNode;
|
|
226
226
|
tableKey?: string;
|
|
227
|
+
infiniteLoading?: boolean;
|
|
227
228
|
/** Customize what you can do to expand a zone */
|
|
228
229
|
renderRowExpanded?: (rowData?: Row) => React.ReactNode;
|
|
229
230
|
|
|
@@ -259,13 +260,16 @@ export interface TableProps<Row, Key> extends Omit<StandardProps, 'onScroll'> {
|
|
|
259
260
|
|
|
260
261
|
/** Callback for the `touchend` event. */
|
|
261
262
|
onTouchEnd?: (event: React.TouchEvent) => void;
|
|
262
|
-
|
|
263
|
+
handleInfiniteScroll?: (value: number) => void;
|
|
263
264
|
/**
|
|
264
265
|
* Callback after table data update.
|
|
265
266
|
* @deprecated use `shouldUpdateScroll` instead
|
|
266
267
|
**/
|
|
267
268
|
onDataUpdated?: (nextData: Row[], scrollTo: (coord: { x: number; y: number }) => void) => void;
|
|
268
269
|
tableBodyRef: React.RefObject<HTMLDivElement>;
|
|
270
|
+
|
|
271
|
+
wheelWrapperRef: React.RefObject<HTMLDivElement | null>;
|
|
272
|
+
|
|
269
273
|
bodyRef?: (ref: HTMLElement) => void;
|
|
270
274
|
}
|
|
271
275
|
|
|
@@ -302,8 +306,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
302
306
|
loading: 'Loading...'
|
|
303
307
|
},
|
|
304
308
|
showHeader = true,
|
|
305
|
-
|
|
306
|
-
paginationProps = {},
|
|
309
|
+
|
|
307
310
|
sortColumn,
|
|
308
311
|
rowHeight = ROW_HEIGHT,
|
|
309
312
|
sortType: sortTypeProp,
|
|
@@ -335,21 +338,21 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
335
338
|
onTouchStart,
|
|
336
339
|
onTouchMove,
|
|
337
340
|
onTouchEnd,
|
|
338
|
-
dataTheme,
|
|
339
341
|
tableBodyHeight,
|
|
340
342
|
columns,
|
|
341
343
|
tableBodyRef,
|
|
342
344
|
tableKey,
|
|
345
|
+
handleInfiniteScroll,
|
|
346
|
+
infiniteLoading,
|
|
347
|
+
wheelWrapperRef,
|
|
343
348
|
...rest
|
|
344
349
|
} = props;
|
|
345
|
-
|
|
346
350
|
const {
|
|
347
351
|
withClassPrefix,
|
|
348
352
|
merge: mergeCls,
|
|
349
353
|
prefix
|
|
350
354
|
} = useClassNames(classPrefix, typeof classPrefix !== 'undefined');
|
|
351
355
|
const childTableRef = useRef<HTMLDivElement>(null);
|
|
352
|
-
|
|
353
356
|
// Use `forceUpdate` to force the component to re-render after manipulating the DOM.
|
|
354
357
|
const [, forceUpdate] = useReducer(x => x + 1, 0);
|
|
355
358
|
const [expandedRowKeys, setExpandedRowKeys] = useControlled(
|
|
@@ -408,7 +411,6 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
408
411
|
const affixHeaderWrapperRef = useRef<HTMLDivElement>(null);
|
|
409
412
|
const headerWrapperRef = useRef<HTMLDivElement>(null);
|
|
410
413
|
// const tableBodyRef = useRef<HTMLDivElement>(null);
|
|
411
|
-
const wheelWrapperRef = useRef<HTMLDivElement>(null);
|
|
412
414
|
const scrollbarXRef = useRef<ScrollbarInstance>(null);
|
|
413
415
|
const scrollbarYRef = useRef<ScrollbarInstance>(null);
|
|
414
416
|
|
|
@@ -533,7 +535,8 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
533
535
|
onScroll,
|
|
534
536
|
onTouchStart,
|
|
535
537
|
onTouchMove,
|
|
536
|
-
onTouchEnd
|
|
538
|
+
onTouchEnd,
|
|
539
|
+
handleInfiniteScroll
|
|
537
540
|
});
|
|
538
541
|
|
|
539
542
|
const { headerCells, bodyCells, allColumnsWidth, hasCustomTreeCol } = useCellDescriptor({
|
|
@@ -953,7 +956,9 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
953
956
|
tableId={id}
|
|
954
957
|
style={{ width: tableWidth.current }}
|
|
955
958
|
length={tableWidth.current}
|
|
956
|
-
onScroll={
|
|
959
|
+
onScroll={delta => {
|
|
960
|
+
onScrollHorizontal(delta);
|
|
961
|
+
}}
|
|
957
962
|
scrollLength={contentWidth.current}
|
|
958
963
|
ref={scrollbarXRef}
|
|
959
964
|
/>
|
|
@@ -1132,13 +1137,21 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
1132
1137
|
role="rowgroup"
|
|
1133
1138
|
className={prefix('body-row-wrapper')}
|
|
1134
1139
|
style={bodyStyles}
|
|
1135
|
-
onScroll={
|
|
1140
|
+
onScroll={e => {
|
|
1141
|
+
onScrollBody?.(e); // existing handler
|
|
1142
|
+
}}
|
|
1136
1143
|
>
|
|
1137
1144
|
{!loading && (
|
|
1138
1145
|
<div style={wheelStyles} className={prefix('body-wheel-area')} ref={wheelWrapperRef}>
|
|
1139
1146
|
{topHideHeight ? <Row style={topRowStyles} className="virtualized" /> : null}
|
|
1140
1147
|
{visibleRows.current}
|
|
1141
1148
|
{bottomHideHeight ? <Row style={bottomRowStyles} className="virtualized" /> : null}
|
|
1149
|
+
|
|
1150
|
+
{infiniteLoading && (
|
|
1151
|
+
<div style={{ padding: 12, textAlign: 'center' }}>
|
|
1152
|
+
<span>Loading more rows…</span>
|
|
1153
|
+
</div>
|
|
1154
|
+
)}
|
|
1142
1155
|
</div>
|
|
1143
1156
|
)}
|
|
1144
1157
|
|
package/src/customSelect.tsx
CHANGED
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import React, { FC, useState, useEffect, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
type CustomSelectProps = {
|
|
4
|
-
options: number[];
|
|
5
|
-
selectedValue: number;
|
|
6
|
-
onChange: (value: number) => void;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const CustomSelect: FC<CustomSelectProps> = ({ options, selectedValue, onChange }) => {
|
|
10
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
11
|
-
const [dropdownPosition, setDropdownPosition] = useState('bottom');
|
|
12
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
13
|
-
const inputRef = useRef<HTMLDivElement>(null);
|
|
14
|
-
|
|
15
|
-
const adjustDropdownPosition = () => {
|
|
16
|
-
if (inputRef.current) {
|
|
17
|
-
const inputBoxRect = inputRef.current.getBoundingClientRect();
|
|
18
|
-
const viewportHeight = window.innerHeight;
|
|
19
|
-
|
|
20
|
-
const spaceAbove = inputBoxRect.top;
|
|
21
|
-
const spaceBelow = viewportHeight - inputBoxRect.bottom;
|
|
22
|
-
|
|
23
|
-
if (spaceAbove > spaceBelow) {
|
|
24
|
-
setDropdownPosition('top');
|
|
25
|
-
} else {
|
|
26
|
-
setDropdownPosition('bottom');
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const handleToggle = () => {
|
|
32
|
-
setIsOpen(prevIsOpen => !prevIsOpen);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const handleSelect = (value: number) => {
|
|
36
|
-
onChange(value);
|
|
37
|
-
setIsOpen(false);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const handleClickOutside = (event: MouseEvent) => {
|
|
41
|
-
if (ref.current && !ref.current.contains(event.target as Node)) {
|
|
42
|
-
setIsOpen(false);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (isOpen) {
|
|
48
|
-
adjustDropdownPosition();
|
|
49
|
-
window.addEventListener('resize', adjustDropdownPosition);
|
|
50
|
-
} else {
|
|
51
|
-
window.removeEventListener('resize', adjustDropdownPosition);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return () => {
|
|
55
|
-
window.removeEventListener('resize', adjustDropdownPosition);
|
|
56
|
-
};
|
|
57
|
-
}, [isOpen]);
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
61
|
-
return () => {
|
|
62
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
63
|
-
};
|
|
64
|
-
}, []);
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<div className="custom-select" ref={ref}>
|
|
68
|
-
<div className="custom-select-trigger" onClick={handleToggle} ref={inputRef}>
|
|
69
|
-
{selectedValue}
|
|
70
|
-
</div>
|
|
71
|
-
{isOpen && (
|
|
72
|
-
<ul className={`custom-select-options ${dropdownPosition}`}>
|
|
73
|
-
{options.map(option => (
|
|
74
|
-
<li
|
|
75
|
-
key={option}
|
|
76
|
-
className={`custom-select-option ${option === selectedValue ? 'selected' : ''}`}
|
|
77
|
-
onClick={() => handleSelect(option)}
|
|
78
|
-
>
|
|
79
|
-
{option}
|
|
80
|
-
</li>
|
|
81
|
-
))}
|
|
82
|
-
</ul>
|
|
83
|
-
)}
|
|
84
|
-
</div>
|
|
85
|
-
);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export default CustomSelect;
|
|
1
|
+
import React, { FC, useState, useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
type CustomSelectProps = {
|
|
4
|
+
options: number[];
|
|
5
|
+
selectedValue: number;
|
|
6
|
+
onChange: (value: number) => void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const CustomSelect: FC<CustomSelectProps> = ({ options, selectedValue, onChange }) => {
|
|
10
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
11
|
+
const [dropdownPosition, setDropdownPosition] = useState('bottom');
|
|
12
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
13
|
+
const inputRef = useRef<HTMLDivElement>(null);
|
|
14
|
+
|
|
15
|
+
const adjustDropdownPosition = () => {
|
|
16
|
+
if (inputRef.current) {
|
|
17
|
+
const inputBoxRect = inputRef.current.getBoundingClientRect();
|
|
18
|
+
const viewportHeight = window.innerHeight;
|
|
19
|
+
|
|
20
|
+
const spaceAbove = inputBoxRect.top;
|
|
21
|
+
const spaceBelow = viewportHeight - inputBoxRect.bottom;
|
|
22
|
+
|
|
23
|
+
if (spaceAbove > spaceBelow) {
|
|
24
|
+
setDropdownPosition('top');
|
|
25
|
+
} else {
|
|
26
|
+
setDropdownPosition('bottom');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const handleToggle = () => {
|
|
32
|
+
setIsOpen(prevIsOpen => !prevIsOpen);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const handleSelect = (value: number) => {
|
|
36
|
+
onChange(value);
|
|
37
|
+
setIsOpen(false);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
41
|
+
if (ref.current && !ref.current.contains(event.target as Node)) {
|
|
42
|
+
setIsOpen(false);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (isOpen) {
|
|
48
|
+
adjustDropdownPosition();
|
|
49
|
+
window.addEventListener('resize', adjustDropdownPosition);
|
|
50
|
+
} else {
|
|
51
|
+
window.removeEventListener('resize', adjustDropdownPosition);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return () => {
|
|
55
|
+
window.removeEventListener('resize', adjustDropdownPosition);
|
|
56
|
+
};
|
|
57
|
+
}, [isOpen]);
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
61
|
+
return () => {
|
|
62
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
63
|
+
};
|
|
64
|
+
}, []);
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div className="custom-select" ref={ref}>
|
|
68
|
+
<div className="custom-select-trigger" onClick={handleToggle} ref={inputRef}>
|
|
69
|
+
{selectedValue}
|
|
70
|
+
</div>
|
|
71
|
+
{isOpen && (
|
|
72
|
+
<ul className={`custom-select-options ${dropdownPosition}`}>
|
|
73
|
+
{options.map(option => (
|
|
74
|
+
<li
|
|
75
|
+
key={option}
|
|
76
|
+
className={`custom-select-option ${option === selectedValue ? 'selected' : ''}`}
|
|
77
|
+
onClick={() => handleSelect(option)}
|
|
78
|
+
>
|
|
79
|
+
{option}
|
|
80
|
+
</li>
|
|
81
|
+
))}
|
|
82
|
+
</ul>
|
|
83
|
+
)}
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export default CustomSelect;
|
package/src/index.ts
CHANGED
|
@@ -15,7 +15,9 @@ export type { QbsTableProps } from './qbsTable/commontypes';
|
|
|
15
15
|
export type { QbsTableLabels } from './qbsTable/labels';
|
|
16
16
|
export {
|
|
17
17
|
mergeQbsTableLabels,
|
|
18
|
+
mergeLabels,
|
|
18
19
|
defaultQbsTableLabels,
|
|
20
|
+
DEFAULT_QBS_TABLE_LABELS,
|
|
19
21
|
formatSelectedItems,
|
|
20
22
|
} from './qbsTable/labels';
|
|
21
23
|
export type {
|
package/src/less/pagination.less
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
min-height: 40px;
|
|
6
6
|
align-items: center;
|
|
7
7
|
border-radius: 0 0 4px 4px;
|
|
8
|
-
border-top: 1px solid #d6d8dc;
|
|
9
|
-
background: #fff;
|
|
8
|
+
border-top: 1px solid var(--base-gray-border, #d6d8dc);
|
|
9
|
+
background: var(--table-bg, #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 #d6d8dc;
|
|
31
|
-
background: #fff;
|
|
30
|
+
border: 1px solid var(--base-gray-border, #d6d8dc);
|
|
31
|
+
background: var(--gray-light-1, #fff);
|
|
32
32
|
}
|
|
33
33
|
.qbs-table-icon-container {
|
|
34
34
|
padding: 0;
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
font-style: normal;
|
|
110
110
|
font-weight: 500;
|
|
111
111
|
line-height: 20px;
|
|
112
|
-
color: #313131;
|
|
112
|
+
color: var(--gray-dark-3, #313131);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
.custom-select-trigger {
|
|
126
126
|
padding: 2px 8px;
|
|
127
127
|
cursor: pointer;
|
|
128
|
-
border: 1px solid #d6d8dc;
|
|
128
|
+
border: 1px solid var(--base-gray-border, #d6d8dc);
|
|
129
129
|
border-radius: 4px;
|
|
130
130
|
min-width: 65px;
|
|
131
131
|
position: relative;
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
list-style: none;
|
|
141
141
|
margin: 2px 0 0;
|
|
142
142
|
padding: 0;
|
|
143
|
-
background: #fff;
|
|
143
|
+
background: var(--gray-light-1, #fff);
|
|
144
144
|
border-radius: 8px;
|
|
145
145
|
box-shadow: 0 8px 20px 0 #00000026;
|
|
146
146
|
}
|
|
@@ -158,7 +158,7 @@ ul.custom-select-options.top {
|
|
|
158
158
|
|
|
159
159
|
.custom-select-option:hover,
|
|
160
160
|
.custom-select-option.selected {
|
|
161
|
-
background-color: #f0f0f0;
|
|
161
|
+
background-color: var(--table-row-hover-bg, #f0f0f0);
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
.custom-select-trigger:before {
|
|
@@ -167,7 +167,7 @@ ul.custom-select-options.top {
|
|
|
167
167
|
right: 10px;
|
|
168
168
|
top: 6px;
|
|
169
169
|
font-weight: bold;
|
|
170
|
-
border: solid black;
|
|
170
|
+
border: solid var(--gray-dark-3, black);
|
|
171
171
|
border-width: 0 1px 1px 0;
|
|
172
172
|
display: inline-block;
|
|
173
173
|
padding: 3px;
|