qbs-react-grid 1.1.15 → 1.1.17
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 +22 -0
- package/dist/css/qbs-react-grid.min.css +1 -1
- package/dist/css/qbs-react-grid.min.css.map +1 -1
- package/es/Row.d.ts +3 -0
- package/es/Row.js +8 -3
- package/es/Table.d.ts +1 -0
- package/es/Table.js +20 -6
- package/es/less/qbs-table.less +24 -0
- package/es/qbsTable/CustomTableCell.d.ts +1 -0
- package/es/qbsTable/CustomTableCell.js +71 -2
- package/es/qbsTable/QbsTable.js +22 -2
- package/es/qbsTable/commontypes.d.ts +9 -0
- package/es/qbsTable/utilities/ToolTip.js +30 -18
- package/lib/Row.d.ts +3 -0
- package/lib/Row.js +8 -3
- package/lib/Table.d.ts +1 -0
- package/lib/Table.js +20 -6
- package/lib/less/qbs-table.less +24 -0
- package/lib/qbsTable/CustomTableCell.d.ts +1 -0
- package/lib/qbsTable/CustomTableCell.js +76 -4
- package/lib/qbsTable/QbsTable.js +21 -1
- package/lib/qbsTable/commontypes.d.ts +9 -0
- package/lib/qbsTable/utilities/ToolTip.js +29 -17
- package/package.json +1 -1
- package/src/Row.tsx +8 -2
- package/src/Table.tsx +44 -8
- package/src/less/qbs-table.less +24 -0
- package/src/qbsTable/CustomTableCell.tsx +60 -1
- package/src/qbsTable/QbsTable.tsx +31 -2
- package/src/qbsTable/commontypes.ts +9 -0
- package/src/qbsTable/utilities/ToolTip.tsx +27 -15
- package/src/qbsTable/utilities/menuDropDown.tsx +1 -0
- package/src/utils/useTableDimension.ts +0 -1
package/lib/Row.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export interface RowProps extends StandardProps {
|
|
|
9
9
|
rowRef?: any;
|
|
10
10
|
rowSpan?: number;
|
|
11
11
|
index?: number;
|
|
12
|
+
dataLength?: number;
|
|
13
|
+
handleParentCallBack?: (index: number) => void;
|
|
14
|
+
zIndexValue?: number;
|
|
12
15
|
}
|
|
13
16
|
declare const Row: React.ForwardRefExoticComponent<RowProps & React.RefAttributes<HTMLDivElement>>;
|
|
14
17
|
export default Row;
|
package/lib/Row.js
CHANGED
|
@@ -9,7 +9,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _utils = require("./utils");
|
|
10
10
|
var _TableContext = _interopRequireDefault(require("./TableContext"));
|
|
11
11
|
var _constants = require("./constants");
|
|
12
|
-
var _excluded = ["classPrefix", "height", "headerHeight", "className", "width", "top", "style", "isHeaderRow", "rowRef", "children", "rowSpan", "index"];
|
|
12
|
+
var _excluded = ["classPrefix", "height", "headerHeight", "className", "width", "top", "style", "isHeaderRow", "rowRef", "children", "rowSpan", "index", "dataLength", "handleParentCallBack", "zIndexValue"];
|
|
13
13
|
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); }
|
|
14
14
|
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; }
|
|
15
15
|
var Row = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
@@ -28,6 +28,9 @@ var Row = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
28
28
|
children = props.children,
|
|
29
29
|
rowSpan = props.rowSpan,
|
|
30
30
|
index = props.index,
|
|
31
|
+
dataLength = props.dataLength,
|
|
32
|
+
handleParentCallBack = props.handleParentCallBack,
|
|
33
|
+
zIndexValue = props.zIndexValue,
|
|
31
34
|
rest = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded);
|
|
32
35
|
var _useContext = (0, _react.useContext)(_TableContext["default"]),
|
|
33
36
|
translateDOMPositionXY = _useContext.translateDOMPositionXY;
|
|
@@ -43,15 +46,17 @@ var Row = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
43
46
|
height: isHeaderRow ? headerHeight : height
|
|
44
47
|
}, style);
|
|
45
48
|
var INDEX = index;
|
|
46
|
-
var styleIndex = 200 - INDEX;
|
|
47
49
|
translateDOMPositionXY === null || translateDOMPositionXY === void 0 ? void 0 : translateDOMPositionXY(styles, 0, top);
|
|
48
50
|
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
|
|
49
51
|
role: "row"
|
|
50
52
|
}, rest, {
|
|
51
53
|
ref: (0, _utils.mergeRefs)(rowRef, ref),
|
|
54
|
+
onMouseEnter: function onMouseEnter() {
|
|
55
|
+
return handleParentCallBack === null || handleParentCallBack === void 0 ? void 0 : handleParentCallBack(INDEX);
|
|
56
|
+
},
|
|
52
57
|
className: classes,
|
|
53
58
|
style: (0, _extends2["default"])({}, styles, {
|
|
54
|
-
zIndex:
|
|
59
|
+
zIndex: zIndexValue
|
|
55
60
|
})
|
|
56
61
|
}), children);
|
|
57
62
|
});
|
package/lib/Table.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export interface TableProps<Row, Key> extends Omit<StandardProps, 'onScroll'> {
|
|
|
36
36
|
height?: number;
|
|
37
37
|
/** The minimum height of the table. The height is maintained even when the content is not stretched. */
|
|
38
38
|
minHeight?: number;
|
|
39
|
+
columns?: any;
|
|
39
40
|
/** The row of the table has a mouseover effect */
|
|
40
41
|
hover?: boolean;
|
|
41
42
|
/** The height of the table header */
|
package/lib/Table.js
CHANGED
|
@@ -20,7 +20,7 @@ var _Row = _interopRequireDefault(require("./Row"));
|
|
|
20
20
|
var _Scrollbar = _interopRequireDefault(require("./Scrollbar"));
|
|
21
21
|
var _TableContext = _interopRequireDefault(require("./TableContext"));
|
|
22
22
|
var _utils = require("./utils");
|
|
23
|
-
var _excluded = ["affixHeader", "children", "classPrefix", "className", "data", "defaultSortType", "width", "expandedRowKeys", "defaultExpandAllRows", "defaultExpandedRowKeys", "style", "id", "isTree", "hover", "bordered", "cellBordered", "wordWrap", "loading", "locale", "showHeader", "pagination", "paginationProps", "sortColumn", "rowHeight", "sortType", "headerHeight", "minHeight", "height", "autoHeight", "fillHeight", "rtl", "translate3d", "rowKey", "virtualized", "rowClassName", "rowExpandedHeight", "disabledScroll", "affixHorizontalScrollbar", "loadAnimation", "shouldUpdateScroll", "renderRow", "renderRowExpanded", "renderLoading", "renderEmpty", "onSortColumn", "onScroll", "renderTreeToggle", "onRowClick", "onRowContextMenu", "onExpandChange", "onTouchStart", "onTouchMove", "onTouchEnd", "dataTheme", "tableBodyHeight"],
|
|
23
|
+
var _excluded = ["affixHeader", "children", "classPrefix", "className", "data", "defaultSortType", "width", "expandedRowKeys", "defaultExpandAllRows", "defaultExpandedRowKeys", "style", "id", "isTree", "hover", "bordered", "cellBordered", "wordWrap", "loading", "locale", "showHeader", "pagination", "paginationProps", "sortColumn", "rowHeight", "sortType", "headerHeight", "minHeight", "height", "autoHeight", "fillHeight", "rtl", "translate3d", "rowKey", "virtualized", "rowClassName", "rowExpandedHeight", "disabledScroll", "affixHorizontalScrollbar", "loadAnimation", "shouldUpdateScroll", "renderRow", "renderRowExpanded", "renderLoading", "renderEmpty", "onSortColumn", "onScroll", "renderTreeToggle", "onRowClick", "onRowContextMenu", "onExpandChange", "onTouchStart", "onTouchMove", "onTouchEnd", "dataTheme", "tableBodyHeight", "columns"],
|
|
24
24
|
_excluded2 = ["depth", "rowIndex"],
|
|
25
25
|
_excluded3 = ["cellHeight"];
|
|
26
26
|
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); }
|
|
@@ -120,6 +120,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
120
120
|
onTouchEnd = props.onTouchEnd,
|
|
121
121
|
dataTheme = props.dataTheme,
|
|
122
122
|
tableBodyHeight = props.tableBodyHeight,
|
|
123
|
+
columns = props.columns,
|
|
123
124
|
rest = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded);
|
|
124
125
|
var _useClassNames = (0, _utils.useClassNames)(classPrefix, typeof classPrefix !== 'undefined'),
|
|
125
126
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
@@ -366,7 +367,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
366
367
|
}));
|
|
367
368
|
var styles = (0, _extends2["default"])({
|
|
368
369
|
width: widthProp || 'auto',
|
|
369
|
-
height:
|
|
370
|
+
height: getTableHeight()
|
|
370
371
|
}, style);
|
|
371
372
|
var renderRowExpanded = (0, _react.useCallback)(function (rowData) {
|
|
372
373
|
var styles = {
|
|
@@ -620,6 +621,16 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
620
621
|
}
|
|
621
622
|
return scrollbars;
|
|
622
623
|
};
|
|
624
|
+
var _useState2 = (0, _react.useState)(Array(data === null || data === void 0 ? void 0 : data.length).fill(1)),
|
|
625
|
+
rowZIndices = _useState2[0],
|
|
626
|
+
setRowZIndices = _useState2[1];
|
|
627
|
+
var handleParentCallBack = function handleParentCallBack(index) {
|
|
628
|
+
setRowZIndices(function (currentZIndices) {
|
|
629
|
+
return currentZIndices.map(function (_, idx) {
|
|
630
|
+
return idx === index ? 10 : 1;
|
|
631
|
+
});
|
|
632
|
+
});
|
|
633
|
+
};
|
|
623
634
|
var renderTableBody = function renderTableBody(bodyCells, rowWidth) {
|
|
624
635
|
var _visibleRows$current;
|
|
625
636
|
var height = getTableHeight();
|
|
@@ -678,7 +689,10 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
678
689
|
depth: _rowData[_constants.TREE_DEPTH],
|
|
679
690
|
height: nextRowHeight,
|
|
680
691
|
cellHeight: cellHeight,
|
|
681
|
-
index: index
|
|
692
|
+
index: index,
|
|
693
|
+
dataLength: data === null || data === void 0 ? void 0 : data.length,
|
|
694
|
+
handleParentCallBack: handleParentCallBack,
|
|
695
|
+
zIndexValue: rowZIndices[index]
|
|
682
696
|
};
|
|
683
697
|
_top += nextRowHeight;
|
|
684
698
|
if (virtualized && !wordWrap) {
|
|
@@ -729,9 +743,9 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
729
743
|
}
|
|
730
744
|
var wheelStyles = {
|
|
731
745
|
position: 'absolute',
|
|
732
|
-
height: contentHeight,
|
|
733
|
-
minHeight:
|
|
734
|
-
maxHeight: tableBodyHeight,
|
|
746
|
+
// height: contentHeight,
|
|
747
|
+
minHeight: contentHeight,
|
|
748
|
+
// maxHeight: tableBodyHeight,
|
|
735
749
|
pointerEvents: isScrolling ? 'none' : undefined
|
|
736
750
|
};
|
|
737
751
|
var topRowStyles = {
|
package/lib/less/qbs-table.less
CHANGED
|
@@ -504,3 +504,27 @@
|
|
|
504
504
|
vertical-align: center !important;
|
|
505
505
|
display: table-cell;
|
|
506
506
|
}
|
|
507
|
+
.row-status:hover .row-status-tooltip {
|
|
508
|
+
display: block;
|
|
509
|
+
}
|
|
510
|
+
.row-status-tooltip {
|
|
511
|
+
display: none;
|
|
512
|
+
// bottom: 40px;
|
|
513
|
+
position: fixed;
|
|
514
|
+
width: auto;
|
|
515
|
+
height: auto;
|
|
516
|
+
max-width: 300px;
|
|
517
|
+
max-height: 200px;
|
|
518
|
+
padding: 10px;
|
|
519
|
+
border-radius: 8px;
|
|
520
|
+
border: 1px solid #d6d8dc;
|
|
521
|
+
background: #fff;
|
|
522
|
+
box-shadow: 0px 2px 4px 0px rgba(58, 58, 58, 0.15);
|
|
523
|
+
}
|
|
524
|
+
.row-status-tooltip.bottom-position {
|
|
525
|
+
top: 100%;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
.row-status-tooltip.top-position {
|
|
529
|
+
bottom: 100%;
|
|
530
|
+
}
|
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.ExpandCell = exports.CustomTableCell = exports.CheckCell = exports.ActionCell = void 0;
|
|
5
|
+
exports.ExpandCell = exports.CustomTableCell = exports.CustomRowStatus = exports.CheckCell = exports.ActionCell = void 0;
|
|
6
6
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
7
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _Cell = _interopRequireDefault(require("../Cell"));
|
|
10
10
|
var _handleFormatCell = require("./utilities/handleFormatCell");
|
|
11
11
|
var _menuDropDown = _interopRequireDefault(require("./utilities/menuDropDown"));
|
|
12
12
|
var _reactRouterDom = require("react-router-dom");
|
|
13
13
|
var _excluded = ["rowData", "onChange", "checkedKeys", "dataKey", "dataTheme"],
|
|
14
14
|
_excluded2 = ["rowData", "dataKey", "expandedRowKeys", "onChange"],
|
|
15
|
-
_excluded3 = ["rowData", "renderCell", "toolTip", "dataKey", "onChange", "rowClick", "type", "path", "link"]
|
|
15
|
+
_excluded3 = ["rowData", "renderCell", "toolTip", "dataKey", "onChange", "rowClick", "type", "path", "link"],
|
|
16
|
+
_excluded4 = ["rowData", "toolTip", "dataKey", "onChange", "rowClick", "getIcon", "path", "link"];
|
|
17
|
+
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); }
|
|
18
|
+
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; }
|
|
16
19
|
var CHECKBOX_LINE_HEIGHT = '36px';
|
|
17
20
|
var CheckCell = /*#__PURE__*/_react["default"].memo(function (_ref) {
|
|
18
21
|
var rowData = _ref.rowData,
|
|
@@ -104,4 +107,73 @@ var CustomTableCell = /*#__PURE__*/_react["default"].memo(function (_ref4) {
|
|
|
104
107
|
className: "qbs-table-row-link"
|
|
105
108
|
}, renderCell ? (_renderCell2 = renderCell(rowData)) === null || _renderCell2 === void 0 ? void 0 : _renderCell2.cell : (0, _handleFormatCell.handleCellFormat)(rowData[dataKey], type)) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, renderCell ? (_renderCell3 = renderCell(rowData)) === null || _renderCell3 === void 0 ? void 0 : _renderCell3.cell : (0, _handleFormatCell.handleCellFormat)(rowData[dataKey], type))));
|
|
106
109
|
});
|
|
107
|
-
exports.CustomTableCell = CustomTableCell;
|
|
110
|
+
exports.CustomTableCell = CustomTableCell;
|
|
111
|
+
var CustomRowStatus = /*#__PURE__*/_react["default"].memo(function (_ref5) {
|
|
112
|
+
var _path2;
|
|
113
|
+
var rowData = _ref5.rowData,
|
|
114
|
+
toolTip = _ref5.toolTip,
|
|
115
|
+
dataKey = _ref5.dataKey,
|
|
116
|
+
onChange = _ref5.onChange,
|
|
117
|
+
rowClick = _ref5.rowClick,
|
|
118
|
+
getIcon = _ref5.getIcon,
|
|
119
|
+
path = _ref5.path,
|
|
120
|
+
link = _ref5.link,
|
|
121
|
+
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref5, _excluded4);
|
|
122
|
+
var _useState = (0, _react.useState)('bottom-position'),
|
|
123
|
+
dropdownPosition = _useState[0],
|
|
124
|
+
setDropdownPosition = _useState[1];
|
|
125
|
+
var dropRef = (0, _react.useRef)(null);
|
|
126
|
+
var menuButtonRef = (0, _react.useRef)(null);
|
|
127
|
+
var adjustDropdownPosition = function adjustDropdownPosition() {
|
|
128
|
+
if (menuButtonRef.current && dropRef.current) {
|
|
129
|
+
var _menuButtonRef$curren;
|
|
130
|
+
var inputBoxRect = (_menuButtonRef$curren = menuButtonRef.current) === null || _menuButtonRef$curren === void 0 ? void 0 : _menuButtonRef$curren.getBoundingClientRect();
|
|
131
|
+
var viewportHeight = window.innerHeight;
|
|
132
|
+
var spaceAbove = inputBoxRect.top;
|
|
133
|
+
var spaceBelow = viewportHeight - inputBoxRect.bottom;
|
|
134
|
+
if (spaceAbove > spaceBelow) {
|
|
135
|
+
setDropdownPosition('top-position');
|
|
136
|
+
} else {
|
|
137
|
+
setDropdownPosition('bottom-position');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Cell["default"], (0, _extends2["default"])({}, props, {
|
|
142
|
+
dataKey: dataKey,
|
|
143
|
+
style: {
|
|
144
|
+
padding: 0,
|
|
145
|
+
display: 'flex',
|
|
146
|
+
justifyContent: 'center',
|
|
147
|
+
alignItems: 'center'
|
|
148
|
+
},
|
|
149
|
+
onMouseEnter: function onMouseEnter() {
|
|
150
|
+
return adjustDropdownPosition();
|
|
151
|
+
}
|
|
152
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
153
|
+
className: "row-status"
|
|
154
|
+
}, !path ? /*#__PURE__*/_react["default"].createElement("span", {
|
|
155
|
+
ref: menuButtonRef,
|
|
156
|
+
style: {
|
|
157
|
+
height: 24,
|
|
158
|
+
width: 24,
|
|
159
|
+
display: 'flex'
|
|
160
|
+
},
|
|
161
|
+
onClick: function onClick() {
|
|
162
|
+
return rowClick === null || rowClick === void 0 ? void 0 : rowClick(rowData);
|
|
163
|
+
}
|
|
164
|
+
}, getIcon === null || getIcon === void 0 ? void 0 : getIcon(rowData)) : /*#__PURE__*/_react["default"].createElement(_reactRouterDom.Link, {
|
|
165
|
+
style: {
|
|
166
|
+
height: 24,
|
|
167
|
+
width: 24
|
|
168
|
+
},
|
|
169
|
+
to: (_path2 = path === null || path === void 0 ? void 0 : path(rowData)) != null ? _path2 : '',
|
|
170
|
+
className: "qbs-table-row-link"
|
|
171
|
+
}, getIcon === null || getIcon === void 0 ? void 0 : getIcon(rowData)), /*#__PURE__*/_react["default"].createElement("div", {
|
|
172
|
+
ref: dropRef,
|
|
173
|
+
className: "row-status-tooltip " + dropdownPosition,
|
|
174
|
+
style: {
|
|
175
|
+
position: 'fixed'
|
|
176
|
+
}
|
|
177
|
+
}, toolTip))));
|
|
178
|
+
});
|
|
179
|
+
exports.CustomRowStatus = CustomRowStatus;
|
package/lib/qbsTable/QbsTable.js
CHANGED
|
@@ -23,6 +23,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
23
23
|
var CHECKBOX_LINE_HEIGHT = '36px';
|
|
24
24
|
var COLUMN_WIDTH = 250;
|
|
25
25
|
var QbsTable = function QbsTable(_ref) {
|
|
26
|
+
var _Object$keys;
|
|
26
27
|
var handleColumnSort = _ref.handleColumnSort,
|
|
27
28
|
data = _ref.data,
|
|
28
29
|
propColumn = _ref.columns,
|
|
@@ -82,7 +83,8 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
82
83
|
selectedRows = _ref.selectedRows,
|
|
83
84
|
_ref$headerHeight = _ref.headerHeight,
|
|
84
85
|
headerHeight = _ref$headerHeight === void 0 ? 40 : _ref$headerHeight,
|
|
85
|
-
tableBodyHeight = _ref.tableBodyHeight
|
|
86
|
+
tableBodyHeight = _ref.tableBodyHeight,
|
|
87
|
+
customRowStatus = _ref.customRowStatus;
|
|
86
88
|
var _useState = (0, _react.useState)(false),
|
|
87
89
|
loading = _useState[0],
|
|
88
90
|
setLoading = _useState[1];
|
|
@@ -394,12 +396,16 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
394
396
|
dataTheme: dataTheme,
|
|
395
397
|
wordWrap: wordWrap,
|
|
396
398
|
sortColumn: sortColumn,
|
|
399
|
+
style: {
|
|
400
|
+
position: 'relative'
|
|
401
|
+
},
|
|
397
402
|
sortType: sortType,
|
|
398
403
|
onSortColumn: handleSortColumn,
|
|
399
404
|
onRowClick: onRowClick,
|
|
400
405
|
tableBodyHeight: tableBodyHeight,
|
|
401
406
|
cellBordered: cellBordered,
|
|
402
407
|
bordered: bordered,
|
|
408
|
+
columns: columns,
|
|
403
409
|
minHeight: minHeight,
|
|
404
410
|
headerHeight: headerHeight,
|
|
405
411
|
loading: isLoading != null ? isLoading : loading,
|
|
@@ -465,6 +471,20 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
465
471
|
className: "" + classes.tableCheckBoxClass,
|
|
466
472
|
onChange: handleCheck,
|
|
467
473
|
dataTheme: dataTheme
|
|
474
|
+
})), customRowStatus && ((_Object$keys = Object.keys(customRowStatus)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length) > 0 && /*#__PURE__*/_react["default"].createElement(_Column["default"], {
|
|
475
|
+
width: 50,
|
|
476
|
+
align: "center",
|
|
477
|
+
fixed: "left"
|
|
478
|
+
}, /*#__PURE__*/_react["default"].createElement(_HeaderCell["default"], {
|
|
479
|
+
verticalAlign: findGrouped() ? 'middle' : undefined,
|
|
480
|
+
className: " " + classes.headerlClass
|
|
481
|
+
}, ' '), /*#__PURE__*/_react["default"].createElement(_CustomTableCell.CustomRowStatus, {
|
|
482
|
+
getIcon: customRowStatus.getIcon,
|
|
483
|
+
dataKey: customRowStatus.field,
|
|
484
|
+
rowClick: customRowStatus.onClick,
|
|
485
|
+
path: customRowStatus.getPath,
|
|
486
|
+
link: customRowStatus.link,
|
|
487
|
+
toolTip: customRowStatus.toolTip
|
|
468
488
|
})), columnsRendered, !actionProps || (actionProps === null || actionProps === void 0 ? void 0 : actionProps.length) === 0 && columnToggle && /*#__PURE__*/_react["default"].createElement(_Column["default"], {
|
|
469
489
|
width: 40,
|
|
470
490
|
fixed: "right"
|
|
@@ -98,6 +98,15 @@ export interface QbsTableProps {
|
|
|
98
98
|
handleResetColumns?: () => void;
|
|
99
99
|
headerHeight?: number;
|
|
100
100
|
tableBodyHeight?: string;
|
|
101
|
+
customRowStatus?: {
|
|
102
|
+
getIcon?: (data: any) => ReactElement;
|
|
103
|
+
onClick?: (rowData: any) => void;
|
|
104
|
+
hidden?: boolean;
|
|
105
|
+
toolTip?: string | ReactElement;
|
|
106
|
+
link?: boolean;
|
|
107
|
+
field?: boolean;
|
|
108
|
+
getPath?: (data: any) => string;
|
|
109
|
+
};
|
|
101
110
|
}
|
|
102
111
|
export interface QbsTableToolbarProps {
|
|
103
112
|
title?: string;
|
|
@@ -8,25 +8,37 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
8
8
|
var TooltipComponent = function TooltipComponent(_ref) {
|
|
9
9
|
var title = _ref.title,
|
|
10
10
|
children = _ref.children;
|
|
11
|
-
var _useState = (0, _react.useState)(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
var _useState = (0, _react.useState)('bottom-position'),
|
|
12
|
+
dropdownPosition = _useState[0],
|
|
13
|
+
setDropdownPosition = _useState[1];
|
|
14
|
+
var dropRef = (0, _react.useRef)(null);
|
|
15
|
+
var menuButtonRef = (0, _react.useRef)(null);
|
|
16
|
+
var adjustDropdownPosition = function adjustDropdownPosition() {
|
|
17
|
+
if (menuButtonRef.current && dropRef.current) {
|
|
18
|
+
var _menuButtonRef$curren;
|
|
19
|
+
var inputBoxRect = (_menuButtonRef$curren = menuButtonRef.current) === null || _menuButtonRef$curren === void 0 ? void 0 : _menuButtonRef$curren.getBoundingClientRect();
|
|
20
|
+
var viewportHeight = window.innerHeight;
|
|
21
|
+
var spaceAbove = inputBoxRect.top;
|
|
22
|
+
var spaceBelow = viewportHeight - inputBoxRect.bottom;
|
|
23
|
+
if (spaceAbove > spaceBelow) {
|
|
24
|
+
setDropdownPosition('top-position');
|
|
25
|
+
} else {
|
|
26
|
+
setDropdownPosition('bottom-position');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
20
29
|
};
|
|
21
|
-
(0, _react.useEffect)(function () {
|
|
22
|
-
window.addEventListener('scroll', handleScroll);
|
|
23
|
-
return function () {
|
|
24
|
-
window.removeEventListener('scroll', handleScroll);
|
|
25
|
-
};
|
|
26
|
-
}, [scrollY]);
|
|
27
30
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
28
|
-
className: "qbs-table-tooltip " + (
|
|
29
|
-
}, /*#__PURE__*/_react["default"].createElement("span",
|
|
31
|
+
className: "qbs-table-tooltip " + (dropdownPosition == 'bottom-position' ? 'down' : 'up') + " "
|
|
32
|
+
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
33
|
+
ref: menuButtonRef,
|
|
34
|
+
style: {
|
|
35
|
+
display: 'flex'
|
|
36
|
+
},
|
|
37
|
+
onMouseEnter: function onMouseEnter() {
|
|
38
|
+
return adjustDropdownPosition();
|
|
39
|
+
}
|
|
40
|
+
}, children), /*#__PURE__*/_react["default"].createElement("span", {
|
|
41
|
+
ref: dropRef,
|
|
30
42
|
className: "tooltiptext"
|
|
31
43
|
}, title));
|
|
32
44
|
};
|
package/package.json
CHANGED
package/src/Row.tsx
CHANGED
|
@@ -13,6 +13,9 @@ export interface RowProps extends StandardProps {
|
|
|
13
13
|
rowRef?: any;
|
|
14
14
|
rowSpan?: number;
|
|
15
15
|
index?: number;
|
|
16
|
+
dataLength?: number;
|
|
17
|
+
handleParentCallBack?: (index: number) => void;
|
|
18
|
+
zIndexValue?: number;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
const Row = React.forwardRef((props: RowProps, ref: React.Ref<HTMLDivElement>) => {
|
|
@@ -29,6 +32,9 @@ const Row = React.forwardRef((props: RowProps, ref: React.Ref<HTMLDivElement>) =
|
|
|
29
32
|
children,
|
|
30
33
|
rowSpan,
|
|
31
34
|
index,
|
|
35
|
+
dataLength,
|
|
36
|
+
handleParentCallBack,
|
|
37
|
+
zIndexValue,
|
|
32
38
|
...rest
|
|
33
39
|
} = props;
|
|
34
40
|
|
|
@@ -42,7 +48,6 @@ const Row = React.forwardRef((props: RowProps, ref: React.Ref<HTMLDivElement>) =
|
|
|
42
48
|
...style
|
|
43
49
|
};
|
|
44
50
|
const INDEX = index as number;
|
|
45
|
-
const styleIndex = 200 - INDEX;
|
|
46
51
|
translateDOMPositionXY?.(styles as CSSStyleDeclaration, 0, top);
|
|
47
52
|
|
|
48
53
|
return (
|
|
@@ -50,8 +55,9 @@ const Row = React.forwardRef((props: RowProps, ref: React.Ref<HTMLDivElement>) =
|
|
|
50
55
|
role="row"
|
|
51
56
|
{...rest}
|
|
52
57
|
ref={mergeRefs(rowRef, ref)}
|
|
58
|
+
onMouseEnter={() => handleParentCallBack?.(INDEX)}
|
|
53
59
|
className={classes}
|
|
54
|
-
style={{ ...styles, zIndex:
|
|
60
|
+
style={{ ...styles, zIndex: zIndexValue }}
|
|
55
61
|
>
|
|
56
62
|
{children}
|
|
57
63
|
</div>
|
package/src/Table.tsx
CHANGED
|
@@ -6,14 +6,40 @@ 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 {
|
|
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';
|
|
10
18
|
import EmptyMessage from './EmptyMessage';
|
|
11
19
|
import Loader from './Loader';
|
|
12
20
|
import MouseArea from './MouseArea';
|
|
13
21
|
import Row, { RowProps } from './Row';
|
|
14
22
|
import Scrollbar, { ScrollbarInstance } from './Scrollbar';
|
|
15
23
|
import TableContext from './TableContext';
|
|
16
|
-
import {
|
|
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';
|
|
17
43
|
|
|
18
44
|
import type {
|
|
19
45
|
StandardProps,
|
|
@@ -101,6 +127,7 @@ export interface TableProps<Row, Key> extends Omit<StandardProps, 'onScroll'> {
|
|
|
101
127
|
/** The minimum height of the table. The height is maintained even when the content is not stretched. */
|
|
102
128
|
minHeight?: number;
|
|
103
129
|
|
|
130
|
+
columns?: any;
|
|
104
131
|
/** The row of the table has a mouseover effect */
|
|
105
132
|
hover?: boolean;
|
|
106
133
|
|
|
@@ -307,6 +334,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
307
334
|
onTouchEnd,
|
|
308
335
|
dataTheme,
|
|
309
336
|
tableBodyHeight,
|
|
337
|
+
columns,
|
|
310
338
|
...rest
|
|
311
339
|
} = props;
|
|
312
340
|
|
|
@@ -567,7 +595,9 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
567
595
|
|
|
568
596
|
const styles = {
|
|
569
597
|
width: widthProp || 'auto',
|
|
570
|
-
height:
|
|
598
|
+
height: getTableHeight(),
|
|
599
|
+
// height: tableBodyHeight ?? getTableHeight(),
|
|
600
|
+
|
|
571
601
|
...style
|
|
572
602
|
};
|
|
573
603
|
|
|
@@ -694,7 +724,6 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
694
724
|
</>
|
|
695
725
|
);
|
|
696
726
|
}
|
|
697
|
-
|
|
698
727
|
return (
|
|
699
728
|
<Row {...restRowProps} data-depth={depth} style={rowStyles}>
|
|
700
729
|
{renderRowProp ? renderRowProp(rowNode, rowData) : rowNode}
|
|
@@ -915,7 +944,11 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
915
944
|
|
|
916
945
|
return scrollbars;
|
|
917
946
|
};
|
|
947
|
+
const [rowZIndices, setRowZIndices] = useState(Array(data?.length).fill(1));
|
|
918
948
|
|
|
949
|
+
const handleParentCallBack = (index: number) => {
|
|
950
|
+
setRowZIndices(currentZIndices => currentZIndices.map((_, idx) => (idx === index ? 10 : 1)));
|
|
951
|
+
};
|
|
919
952
|
const renderTableBody = (bodyCells: any[], rowWidth: number) => {
|
|
920
953
|
const height = getTableHeight();
|
|
921
954
|
const bodyHeight = height - headerHeight;
|
|
@@ -985,7 +1018,10 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
985
1018
|
depth: rowData[TREE_DEPTH],
|
|
986
1019
|
height: nextRowHeight,
|
|
987
1020
|
cellHeight,
|
|
988
|
-
index: index
|
|
1021
|
+
index: index,
|
|
1022
|
+
dataLength: data?.length,
|
|
1023
|
+
handleParentCallBack: handleParentCallBack,
|
|
1024
|
+
zIndexValue: rowZIndices[index]
|
|
989
1025
|
};
|
|
990
1026
|
|
|
991
1027
|
top += nextRowHeight;
|
|
@@ -1045,9 +1081,9 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
1045
1081
|
|
|
1046
1082
|
const wheelStyles: React.CSSProperties = {
|
|
1047
1083
|
position: 'absolute',
|
|
1048
|
-
height: contentHeight,
|
|
1049
|
-
minHeight:
|
|
1050
|
-
maxHeight: tableBodyHeight,
|
|
1084
|
+
// height: contentHeight,
|
|
1085
|
+
minHeight: contentHeight,
|
|
1086
|
+
// maxHeight: tableBodyHeight,
|
|
1051
1087
|
pointerEvents: isScrolling ? 'none' : undefined
|
|
1052
1088
|
};
|
|
1053
1089
|
const topRowStyles = { height: topHideHeight };
|
package/src/less/qbs-table.less
CHANGED
|
@@ -504,3 +504,27 @@
|
|
|
504
504
|
vertical-align: center !important;
|
|
505
505
|
display: table-cell;
|
|
506
506
|
}
|
|
507
|
+
.row-status:hover .row-status-tooltip {
|
|
508
|
+
display: block;
|
|
509
|
+
}
|
|
510
|
+
.row-status-tooltip {
|
|
511
|
+
display: none;
|
|
512
|
+
// bottom: 40px;
|
|
513
|
+
position: fixed;
|
|
514
|
+
width: auto;
|
|
515
|
+
height: auto;
|
|
516
|
+
max-width: 300px;
|
|
517
|
+
max-height: 200px;
|
|
518
|
+
padding: 10px;
|
|
519
|
+
border-radius: 8px;
|
|
520
|
+
border: 1px solid #d6d8dc;
|
|
521
|
+
background: #fff;
|
|
522
|
+
box-shadow: 0px 2px 4px 0px rgba(58, 58, 58, 0.15);
|
|
523
|
+
}
|
|
524
|
+
.row-status-tooltip.bottom-position {
|
|
525
|
+
top: 100%;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
.row-status-tooltip.top-position {
|
|
529
|
+
bottom: 100%;
|
|
530
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import Cell from '../Cell';
|
|
4
4
|
import { handleCellFormat } from './utilities/handleFormatCell';
|
|
@@ -81,3 +81,62 @@ export const CustomTableCell: React.FC<any> = React.memo(
|
|
|
81
81
|
);
|
|
82
82
|
}
|
|
83
83
|
);
|
|
84
|
+
export const CustomRowStatus: React.FC<any> = React.memo(
|
|
85
|
+
({ rowData, toolTip, dataKey, onChange, rowClick, getIcon, path, link, ...props }) => {
|
|
86
|
+
const [dropdownPosition, setDropdownPosition] = useState('bottom-position');
|
|
87
|
+
const dropRef = useRef(null);
|
|
88
|
+
const menuButtonRef = useRef<HTMLElement>(null);
|
|
89
|
+
const adjustDropdownPosition = () => {
|
|
90
|
+
if (menuButtonRef.current && dropRef.current) {
|
|
91
|
+
const inputBoxRect = menuButtonRef.current?.getBoundingClientRect();
|
|
92
|
+
const viewportHeight = window.innerHeight;
|
|
93
|
+
|
|
94
|
+
const spaceAbove = inputBoxRect.top;
|
|
95
|
+
const spaceBelow = viewportHeight - inputBoxRect.bottom;
|
|
96
|
+
if (spaceAbove > spaceBelow) {
|
|
97
|
+
setDropdownPosition('top-position');
|
|
98
|
+
} else {
|
|
99
|
+
setDropdownPosition('bottom-position');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<>
|
|
106
|
+
<Cell
|
|
107
|
+
{...props}
|
|
108
|
+
dataKey={dataKey}
|
|
109
|
+
style={{ padding: 0, display: 'flex', justifyContent: 'center', alignItems: 'center' }}
|
|
110
|
+
onMouseEnter={() => adjustDropdownPosition()}
|
|
111
|
+
>
|
|
112
|
+
<div className="row-status">
|
|
113
|
+
{!path ? (
|
|
114
|
+
<span
|
|
115
|
+
ref={menuButtonRef}
|
|
116
|
+
style={{ height: 24, width: 24, display: 'flex' }}
|
|
117
|
+
onClick={() => rowClick?.(rowData)}
|
|
118
|
+
>
|
|
119
|
+
{getIcon?.(rowData)}
|
|
120
|
+
</span>
|
|
121
|
+
) : (
|
|
122
|
+
<Link
|
|
123
|
+
style={{ height: 24, width: 24 }}
|
|
124
|
+
to={path?.(rowData) ?? ''}
|
|
125
|
+
className="qbs-table-row-link"
|
|
126
|
+
>
|
|
127
|
+
{getIcon?.(rowData)}
|
|
128
|
+
</Link>
|
|
129
|
+
)}
|
|
130
|
+
<div
|
|
131
|
+
ref={dropRef}
|
|
132
|
+
className={`row-status-tooltip ${dropdownPosition}`}
|
|
133
|
+
style={{ position: 'fixed' }}
|
|
134
|
+
>
|
|
135
|
+
{toolTip}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
</Cell>
|
|
139
|
+
</>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
);
|