qbs-react-grid 1.1.7 → 1.1.9
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/Table.js +8 -5
- package/es/utils/useTableDimension.d.ts +1 -1
- package/es/utils/useTableDimension.js +5 -6
- package/lib/Table.js +8 -5
- package/lib/utils/useTableDimension.d.ts +1 -1
- package/lib/utils/useTableDimension.js +5 -6
- package/package.json +1 -1
- package/src/Table.tsx +12 -34
- package/src/utils/useTableDimension.ts +7 -7
package/es/Table.js
CHANGED
|
@@ -359,7 +359,7 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
359
359
|
}));
|
|
360
360
|
var styles = _extends({
|
|
361
361
|
width: widthProp || 'auto',
|
|
362
|
-
height: tableBodyHeight ?
|
|
362
|
+
height: tableBodyHeight != null ? tableBodyHeight : getTableHeight()
|
|
363
363
|
}, style);
|
|
364
364
|
var renderRowExpanded = useCallback(function (rowData) {
|
|
365
365
|
var styles = {
|
|
@@ -619,7 +619,9 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
619
619
|
var bodyHeight = height - headerHeight;
|
|
620
620
|
var bodyStyles = {
|
|
621
621
|
top: headerHeight,
|
|
622
|
-
|
|
622
|
+
height: bodyHeight,
|
|
623
|
+
//height: tableBodyHeight
|
|
624
|
+
// maxHeight: tableBodyHeight,
|
|
623
625
|
minHeight: tableBodyHeight
|
|
624
626
|
};
|
|
625
627
|
var contentHeight = 0;
|
|
@@ -721,7 +723,8 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
721
723
|
var wheelStyles = {
|
|
722
724
|
position: 'absolute',
|
|
723
725
|
height: contentHeight,
|
|
724
|
-
minHeight:
|
|
726
|
+
minHeight: tableBodyHeight,
|
|
727
|
+
maxHeight: tableBodyHeight,
|
|
725
728
|
pointerEvents: isScrolling ? 'none' : undefined
|
|
726
729
|
};
|
|
727
730
|
var topRowStyles = {
|
|
@@ -751,7 +754,7 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
751
754
|
renderEmpty: renderEmpty,
|
|
752
755
|
addPrefix: prefix,
|
|
753
756
|
loading: !!((_visibleRows$current = visibleRows.current) !== null && _visibleRows$current !== void 0 && _visibleRows$current.length) || loading
|
|
754
|
-
}),
|
|
757
|
+
}), /*#__PURE__*/React.createElement(Loader, {
|
|
755
758
|
locale: locale,
|
|
756
759
|
loadAnimation: loadAnimation,
|
|
757
760
|
loading: loading,
|
|
@@ -782,7 +785,7 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
782
785
|
className: classes,
|
|
783
786
|
style: styles,
|
|
784
787
|
ref: tableRef
|
|
785
|
-
}), showHeader && renderTableHeader(headerCells, rowWidth), children && renderTableBody(bodyCells, rowWidth), showHeader && /*#__PURE__*/React.createElement(MouseArea, {
|
|
788
|
+
}), showHeader && renderTableHeader(headerCells, rowWidth), children && renderTableBody(bodyCells, rowWidth), renderScrollbar(), showHeader && /*#__PURE__*/React.createElement(MouseArea, {
|
|
786
789
|
ref: mouseAreaRef,
|
|
787
790
|
addPrefix: prefix,
|
|
788
791
|
headerHeight: headerHeight,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ElementOffset, RowDataType } from '../@types/common';
|
|
3
3
|
interface TableDimensionProps<Row, Key> {
|
|
4
4
|
data?: readonly Row[];
|
|
5
5
|
rowHeight: number | ((rowData?: Row) => number);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import getWidth from 'dom-lib/getWidth';
|
|
1
|
+
import { ResizeObserver } from '@juggle/resize-observer';
|
|
3
2
|
import getHeight from 'dom-lib/getHeight';
|
|
4
3
|
import getOffset from 'dom-lib/getOffset';
|
|
4
|
+
import getWidth from 'dom-lib/getWidth';
|
|
5
|
+
import debounce from 'lodash/debounce';
|
|
6
|
+
import { useCallback, useRef } from 'react';
|
|
5
7
|
import { SCROLLBAR_WIDTH } from '../constants';
|
|
6
|
-
import
|
|
8
|
+
import isNumberOrTrue from './isNumberOrTrue';
|
|
7
9
|
import useMount from './useMount';
|
|
8
10
|
import useUpdateLayoutEffect from './useUpdateLayoutEffect';
|
|
9
|
-
import isNumberOrTrue from './isNumberOrTrue';
|
|
10
|
-
import debounce from 'lodash/debounce';
|
|
11
11
|
/**
|
|
12
12
|
* The dimension information of the table,
|
|
13
13
|
* including the height, width, scrollable distance and the coordinates of the scroll handle, etc.
|
|
@@ -218,7 +218,6 @@ var useTableDimension = function useTableDimension(props) {
|
|
|
218
218
|
if ((data === null || data === void 0 ? void 0 : data.length) === 0 && autoHeight) {
|
|
219
219
|
return heightProp;
|
|
220
220
|
}
|
|
221
|
-
console.log(heightProp, headerHeight, contentHeight.current, tableHeight.current);
|
|
222
221
|
return autoHeight ? Math.max(headerHeight + contentHeight.current, minHeight) : heightProp;
|
|
223
222
|
};
|
|
224
223
|
return {
|
package/lib/Table.js
CHANGED
|
@@ -366,7 +366,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
366
366
|
}));
|
|
367
367
|
var styles = (0, _extends2["default"])({
|
|
368
368
|
width: widthProp || 'auto',
|
|
369
|
-
height: tableBodyHeight ?
|
|
369
|
+
height: tableBodyHeight != null ? tableBodyHeight : getTableHeight()
|
|
370
370
|
}, style);
|
|
371
371
|
var renderRowExpanded = (0, _react.useCallback)(function (rowData) {
|
|
372
372
|
var styles = {
|
|
@@ -626,7 +626,9 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
626
626
|
var bodyHeight = height - headerHeight;
|
|
627
627
|
var bodyStyles = {
|
|
628
628
|
top: headerHeight,
|
|
629
|
-
|
|
629
|
+
height: bodyHeight,
|
|
630
|
+
//height: tableBodyHeight
|
|
631
|
+
// maxHeight: tableBodyHeight,
|
|
630
632
|
minHeight: tableBodyHeight
|
|
631
633
|
};
|
|
632
634
|
var contentHeight = 0;
|
|
@@ -728,7 +730,8 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
728
730
|
var wheelStyles = {
|
|
729
731
|
position: 'absolute',
|
|
730
732
|
height: contentHeight,
|
|
731
|
-
minHeight:
|
|
733
|
+
minHeight: tableBodyHeight,
|
|
734
|
+
maxHeight: tableBodyHeight,
|
|
732
735
|
pointerEvents: isScrolling ? 'none' : undefined
|
|
733
736
|
};
|
|
734
737
|
var topRowStyles = {
|
|
@@ -758,7 +761,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
758
761
|
renderEmpty: renderEmpty,
|
|
759
762
|
addPrefix: prefix,
|
|
760
763
|
loading: !!((_visibleRows$current = visibleRows.current) !== null && _visibleRows$current !== void 0 && _visibleRows$current.length) || loading
|
|
761
|
-
}),
|
|
764
|
+
}), /*#__PURE__*/_react["default"].createElement(_Loader["default"], {
|
|
762
765
|
locale: locale,
|
|
763
766
|
loadAnimation: loadAnimation,
|
|
764
767
|
loading: loading,
|
|
@@ -789,7 +792,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
789
792
|
className: classes,
|
|
790
793
|
style: styles,
|
|
791
794
|
ref: tableRef
|
|
792
|
-
}), showHeader && renderTableHeader(headerCells, rowWidth), children && renderTableBody(bodyCells, rowWidth), showHeader && /*#__PURE__*/_react["default"].createElement(_MouseArea["default"], {
|
|
795
|
+
}), showHeader && renderTableHeader(headerCells, rowWidth), children && renderTableBody(bodyCells, rowWidth), renderScrollbar(), showHeader && /*#__PURE__*/_react["default"].createElement(_MouseArea["default"], {
|
|
793
796
|
ref: mouseAreaRef,
|
|
794
797
|
addPrefix: prefix,
|
|
795
798
|
headerHeight: headerHeight,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ElementOffset, RowDataType } from '../@types/common';
|
|
3
3
|
interface TableDimensionProps<Row, Key> {
|
|
4
4
|
data?: readonly Row[];
|
|
5
5
|
rowHeight: number | ((rowData?: Row) => number);
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports["default"] = void 0;
|
|
6
|
-
var
|
|
7
|
-
var _getWidth = _interopRequireDefault(require("dom-lib/getWidth"));
|
|
6
|
+
var _resizeObserver = require("@juggle/resize-observer");
|
|
8
7
|
var _getHeight = _interopRequireDefault(require("dom-lib/getHeight"));
|
|
9
8
|
var _getOffset = _interopRequireDefault(require("dom-lib/getOffset"));
|
|
9
|
+
var _getWidth = _interopRequireDefault(require("dom-lib/getWidth"));
|
|
10
|
+
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
11
|
+
var _react = require("react");
|
|
10
12
|
var _constants = require("../constants");
|
|
11
|
-
var
|
|
13
|
+
var _isNumberOrTrue = _interopRequireDefault(require("./isNumberOrTrue"));
|
|
12
14
|
var _useMount = _interopRequireDefault(require("./useMount"));
|
|
13
15
|
var _useUpdateLayoutEffect = _interopRequireDefault(require("./useUpdateLayoutEffect"));
|
|
14
|
-
var _isNumberOrTrue = _interopRequireDefault(require("./isNumberOrTrue"));
|
|
15
|
-
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
16
16
|
/**
|
|
17
17
|
* The dimension information of the table,
|
|
18
18
|
* including the height, width, scrollable distance and the coordinates of the scroll handle, etc.
|
|
@@ -223,7 +223,6 @@ var useTableDimension = function useTableDimension(props) {
|
|
|
223
223
|
if ((data === null || data === void 0 ? void 0 : data.length) === 0 && autoHeight) {
|
|
224
224
|
return heightProp;
|
|
225
225
|
}
|
|
226
|
-
console.log(heightProp, headerHeight, contentHeight.current, tableHeight.current);
|
|
227
226
|
return autoHeight ? Math.max(headerHeight + contentHeight.current, minHeight) : heightProp;
|
|
228
227
|
};
|
|
229
228
|
return {
|
package/package.json
CHANGED
package/src/Table.tsx
CHANGED
|
@@ -6,40 +6,14 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import React, { useCallback, useImperativeHandle, useReducer, useRef, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import CellGroup from './CellGroup';
|
|
9
|
-
import {
|
|
10
|
-
CELL_PADDING_HEIGHT,
|
|
11
|
-
EXPANDED_KEY,
|
|
12
|
-
ROW_HEADER_HEIGHT,
|
|
13
|
-
ROW_HEIGHT,
|
|
14
|
-
SCROLLBAR_WIDTH,
|
|
15
|
-
SORT_TYPE,
|
|
16
|
-
TREE_DEPTH
|
|
17
|
-
} from './constants';
|
|
9
|
+
import { CELL_PADDING_HEIGHT, EXPANDED_KEY, ROW_HEADER_HEIGHT, ROW_HEIGHT, SCROLLBAR_WIDTH, SORT_TYPE, TREE_DEPTH } from './constants';
|
|
18
10
|
import EmptyMessage from './EmptyMessage';
|
|
19
11
|
import Loader from './Loader';
|
|
20
12
|
import MouseArea from './MouseArea';
|
|
21
13
|
import Row, { RowProps } from './Row';
|
|
22
14
|
import Scrollbar, { ScrollbarInstance } from './Scrollbar';
|
|
23
15
|
import TableContext from './TableContext';
|
|
24
|
-
import {
|
|
25
|
-
findAllParents,
|
|
26
|
-
findRowKeys,
|
|
27
|
-
flattenData,
|
|
28
|
-
isRTL,
|
|
29
|
-
isSupportTouchEvent,
|
|
30
|
-
mergeCells,
|
|
31
|
-
resetLeftForCells,
|
|
32
|
-
shouldShowRowByExpanded,
|
|
33
|
-
useAffix,
|
|
34
|
-
useCellDescriptor,
|
|
35
|
-
useClassNames,
|
|
36
|
-
useControlled,
|
|
37
|
-
usePosition,
|
|
38
|
-
useScrollListener,
|
|
39
|
-
useTableDimension,
|
|
40
|
-
useTableRows,
|
|
41
|
-
useUpdateEffect
|
|
42
|
-
} from './utils';
|
|
16
|
+
import { findAllParents, findRowKeys, flattenData, isRTL, isSupportTouchEvent, mergeCells, resetLeftForCells, shouldShowRowByExpanded, useAffix, useCellDescriptor, useClassNames, useControlled, usePosition, useScrollListener, useTableDimension, useTableRows, useUpdateEffect } from './utils';
|
|
43
17
|
|
|
44
18
|
import type {
|
|
45
19
|
StandardProps,
|
|
@@ -593,7 +567,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
593
567
|
|
|
594
568
|
const styles = {
|
|
595
569
|
width: widthProp || 'auto',
|
|
596
|
-
height: tableBodyHeight
|
|
570
|
+
height: tableBodyHeight ?? getTableHeight(),
|
|
597
571
|
...style
|
|
598
572
|
};
|
|
599
573
|
|
|
@@ -947,7 +921,10 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
947
921
|
const bodyHeight = height - headerHeight;
|
|
948
922
|
const bodyStyles = {
|
|
949
923
|
top: headerHeight,
|
|
950
|
-
|
|
924
|
+
height: bodyHeight,
|
|
925
|
+
|
|
926
|
+
//height: tableBodyHeight
|
|
927
|
+
// maxHeight: tableBodyHeight,
|
|
951
928
|
minHeight: tableBodyHeight
|
|
952
929
|
};
|
|
953
930
|
|
|
@@ -1069,12 +1046,12 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
1069
1046
|
const wheelStyles: React.CSSProperties = {
|
|
1070
1047
|
position: 'absolute',
|
|
1071
1048
|
height: contentHeight,
|
|
1072
|
-
minHeight:
|
|
1049
|
+
minHeight: tableBodyHeight,
|
|
1050
|
+
maxHeight: tableBodyHeight,
|
|
1073
1051
|
pointerEvents: isScrolling ? 'none' : undefined
|
|
1074
1052
|
};
|
|
1075
1053
|
const topRowStyles = { height: topHideHeight };
|
|
1076
1054
|
const bottomRowStyles = { height: bottomHideHeight };
|
|
1077
|
-
|
|
1078
1055
|
return (
|
|
1079
1056
|
<div
|
|
1080
1057
|
ref={tableBodyRef}
|
|
@@ -1095,7 +1072,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
1095
1072
|
addPrefix={prefix}
|
|
1096
1073
|
loading={!!visibleRows.current?.length || loading}
|
|
1097
1074
|
/>
|
|
1098
|
-
|
|
1075
|
+
|
|
1099
1076
|
<Loader
|
|
1100
1077
|
locale={locale}
|
|
1101
1078
|
loadAnimation={loadAnimation}
|
|
@@ -1134,6 +1111,8 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
1134
1111
|
>
|
|
1135
1112
|
{showHeader && renderTableHeader(headerCells, rowWidth)}
|
|
1136
1113
|
{children && renderTableBody(bodyCells, rowWidth)}
|
|
1114
|
+
{renderScrollbar()}
|
|
1115
|
+
|
|
1137
1116
|
{showHeader && (
|
|
1138
1117
|
<MouseArea
|
|
1139
1118
|
ref={mouseAreaRef}
|
|
@@ -1143,7 +1122,6 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
1143
1122
|
/>
|
|
1144
1123
|
)}
|
|
1145
1124
|
</div>
|
|
1146
|
-
{/* {pagination && <Pagination paginationProps={paginationProps} />} */}
|
|
1147
1125
|
</TableContext.Provider>
|
|
1148
1126
|
);
|
|
1149
1127
|
});
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import getWidth from 'dom-lib/getWidth';
|
|
1
|
+
import { ResizeObserver } from '@juggle/resize-observer';
|
|
3
2
|
import getHeight from 'dom-lib/getHeight';
|
|
4
3
|
import getOffset from 'dom-lib/getOffset';
|
|
4
|
+
import getWidth from 'dom-lib/getWidth';
|
|
5
|
+
import debounce from 'lodash/debounce';
|
|
6
|
+
import React, { useCallback, useRef } from 'react';
|
|
7
|
+
|
|
8
|
+
import { ElementOffset, RowDataType } from '../@types/common';
|
|
5
9
|
import { SCROLLBAR_WIDTH } from '../constants';
|
|
6
|
-
import
|
|
10
|
+
import isNumberOrTrue from './isNumberOrTrue';
|
|
7
11
|
import useMount from './useMount';
|
|
8
12
|
import useUpdateLayoutEffect from './useUpdateLayoutEffect';
|
|
9
|
-
import isNumberOrTrue from './isNumberOrTrue';
|
|
10
|
-
import { RowDataType, ElementOffset } from '../@types/common';
|
|
11
|
-
import debounce from 'lodash/debounce';
|
|
12
13
|
|
|
13
14
|
interface TableDimensionProps<Row, Key> {
|
|
14
15
|
data?: readonly Row[];
|
|
@@ -308,7 +309,6 @@ const useTableDimension = <Row extends RowDataType, Key>(props: TableDimensionPr
|
|
|
308
309
|
if (data?.length === 0 && autoHeight) {
|
|
309
310
|
return heightProp;
|
|
310
311
|
}
|
|
311
|
-
console.log(heightProp, headerHeight, contentHeight.current, tableHeight.current);
|
|
312
312
|
|
|
313
313
|
return autoHeight ? Math.max(headerHeight + contentHeight.current, minHeight) : heightProp;
|
|
314
314
|
};
|