qbs-react-grid 1.1.16 → 1.1.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/lib/Table.js CHANGED
@@ -621,11 +621,20 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
621
621
  }
622
622
  return scrollbars;
623
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
+ };
624
634
  var renderTableBody = function renderTableBody(bodyCells, rowWidth) {
625
635
  var _visibleRows$current;
626
636
  var height = getTableHeight();
627
637
  var bodyHeight = height - headerHeight;
628
- console.log(bodyHeight, height);
629
638
  var bodyStyles = {
630
639
  top: headerHeight,
631
640
  height: bodyHeight,
@@ -680,7 +689,10 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
680
689
  depth: _rowData[_constants.TREE_DEPTH],
681
690
  height: nextRowHeight,
682
691
  cellHeight: cellHeight,
683
- index: index
692
+ index: index,
693
+ dataLength: data === null || data === void 0 ? void 0 : data.length,
694
+ handleParentCallBack: handleParentCallBack,
695
+ zIndexValue: rowZIndices[index]
684
696
  };
685
697
  _top += nextRowHeight;
686
698
  if (virtualized && !wordWrap) {
@@ -723,7 +735,10 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
723
735
  width: rowWidth,
724
736
  height: _nextRowHeight,
725
737
  cellHeight: _nextRowHeight,
726
- index: _index
738
+ index: _index,
739
+ dataLength: data === null || data === void 0 ? void 0 : data.length,
740
+ handleParentCallBack: handleParentCallBack,
741
+ zIndexValue: rowZIndices[_index]
727
742
  };
728
743
  visibleRows.current.push(renderRowData(bodyCells, _rowData2, _rowProps, false));
729
744
  }
@@ -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
+ }
@@ -3,3 +3,4 @@ export declare const CheckCell: React.FC<any>;
3
3
  export declare const ActionCell: React.FC<any>;
4
4
  export declare const ExpandCell: React.FC<any>;
5
5
  export declare const CustomTableCell: React.FC<any>;
6
+ export declare const CustomRowStatus: React.FC<any>;
@@ -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 = _interopRequireDefault(require("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;
@@ -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];
@@ -469,6 +471,20 @@ var QbsTable = function QbsTable(_ref) {
469
471
  className: "" + classes.tableCheckBoxClass,
470
472
  onChange: handleCheck,
471
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
472
488
  })), columnsRendered, !actionProps || (actionProps === null || actionProps === void 0 ? void 0 : actionProps.length) === 0 && columnToggle && /*#__PURE__*/_react["default"].createElement(_Column["default"], {
473
489
  width: 40,
474
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)(0),
12
- scrollY = _useState[0],
13
- setScrollY = _useState[1];
14
- var _useState2 = (0, _react.useState)(true),
15
- isScrollingUp = _useState2[0],
16
- setIsScrollingUp = _useState2[1];
17
- var handleScroll = function handleScroll() {
18
- setIsScrollingUp(window.scrollY < scrollY);
19
- setScrollY(window.scrollY);
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 " + (!isScrollingUp ? 'up' : 'down')
29
- }, /*#__PURE__*/_react["default"].createElement("span", null, children), /*#__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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qbs-react-grid",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "description": "A React table component",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
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: styleIndex }}
60
+ style={{ ...styles, zIndex: zIndexValue }}
55
61
  >
56
62
  {children}
57
63
  </div>
package/src/Table.tsx CHANGED
@@ -724,7 +724,6 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
724
724
  </>
725
725
  );
726
726
  }
727
-
728
727
  return (
729
728
  <Row {...restRowProps} data-depth={depth} style={rowStyles}>
730
729
  {renderRowProp ? renderRowProp(rowNode, rowData) : rowNode}
@@ -852,7 +851,8 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
852
851
  'aria-rowindex': (props.key as number) + 2,
853
852
  rowRef: bindTableRowsRef(props.key as any, rowData),
854
853
  onClick: bindRowClick(rowData),
855
- onContextMenu: bindRowContextMenu(rowData)
854
+ onContextMenu: bindRowContextMenu(rowData),
855
+
856
856
  };
857
857
 
858
858
  const expanded = expandedRowKeys.some(key => rowKey && key === rowData[rowKey]);
@@ -945,11 +945,14 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
945
945
 
946
946
  return scrollbars;
947
947
  };
948
+ const [rowZIndices, setRowZIndices] = useState(Array(data?.length).fill(1));
948
949
 
950
+ const handleParentCallBack = (index: number) => {
951
+ setRowZIndices(currentZIndices => currentZIndices.map((_, idx) => (idx === index ? 10 : 1)));
952
+ };
949
953
  const renderTableBody = (bodyCells: any[], rowWidth: number) => {
950
954
  const height = getTableHeight();
951
955
  const bodyHeight = height - headerHeight;
952
- console.log(bodyHeight, height);
953
956
  const bodyStyles = {
954
957
  top: headerHeight,
955
958
  height: bodyHeight,
@@ -1016,7 +1019,10 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
1016
1019
  depth: rowData[TREE_DEPTH],
1017
1020
  height: nextRowHeight,
1018
1021
  cellHeight,
1019
- index: index
1022
+ index: index,
1023
+ dataLength: data?.length,
1024
+ handleParentCallBack: handleParentCallBack,
1025
+ zIndexValue: rowZIndices[index]
1020
1026
  };
1021
1027
 
1022
1028
  top += nextRowHeight;
@@ -1067,7 +1073,10 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
1067
1073
  width: rowWidth,
1068
1074
  height: nextRowHeight,
1069
1075
  cellHeight: nextRowHeight,
1070
- index: index
1076
+ index: index,
1077
+ dataLength: data?.length,
1078
+ handleParentCallBack: handleParentCallBack,
1079
+ zIndexValue: rowZIndices[index]
1071
1080
  };
1072
1081
  visibleRows.current.push(renderRowData(bodyCells, rowData, rowProps, false));
1073
1082
  }
@@ -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
+ );
@@ -7,7 +7,13 @@ import HeaderCell from '../HeaderCell';
7
7
  import Pagination from '../Pagination';
8
8
  import Table from '../Table';
9
9
  import { QbsColumnProps, QbsTableProps } from './commontypes';
10
- import { ActionCell, CheckCell, CustomTableCell, ExpandCell } from './CustomTableCell';
10
+ import {
11
+ ActionCell,
12
+ CheckCell,
13
+ CustomTableCell,
14
+ ExpandCell,
15
+ CustomRowStatus
16
+ } from './CustomTableCell';
11
17
  import ToolBar from './Toolbar';
12
18
  import ColumToggle from './utilities/ColumShowHide';
13
19
  import debounce from './utilities/debounce';
@@ -63,7 +69,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
63
69
  handleResetColumns,
64
70
  selectedRows,
65
71
  headerHeight = 40,
66
- tableBodyHeight
72
+ tableBodyHeight,
73
+ customRowStatus
67
74
  }) => {
68
75
  const [loading, setLoading] = useState(false);
69
76
  const [columns, setColumns] = useState(propColumn);
@@ -499,6 +506,24 @@ const QbsTable: React.FC<QbsTableProps> = ({
499
506
  />
500
507
  </Column>
501
508
  )}
509
+ {customRowStatus && Object.keys(customRowStatus)?.length > 0 && (
510
+ <Column width={50} align="center" fixed="left">
511
+ <HeaderCell
512
+ verticalAlign={findGrouped() ? 'middle' : undefined}
513
+ className={` ${classes.headerlClass}`}
514
+ >
515
+ {' '}
516
+ </HeaderCell>
517
+ <CustomRowStatus
518
+ getIcon={customRowStatus.getIcon}
519
+ dataKey={customRowStatus.field}
520
+ rowClick={customRowStatus.onClick}
521
+ path={customRowStatus.getPath}
522
+ link={customRowStatus.link}
523
+ toolTip={customRowStatus.toolTip}
524
+ />
525
+ </Column>
526
+ )}
502
527
  {columnsRendered}
503
528
  {!actionProps ||
504
529
  (actionProps?.length === 0 && columnToggle && (
@@ -101,6 +101,15 @@ export interface QbsTableProps {
101
101
  handleResetColumns?: () => void;
102
102
  headerHeight?: number;
103
103
  tableBodyHeight?: string;
104
+ customRowStatus?: {
105
+ getIcon?: (data: any) => ReactElement;
106
+ onClick?: (rowData: any) => void;
107
+ hidden?: boolean;
108
+ toolTip?: string | ReactElement;
109
+ link?: boolean;
110
+ field?: boolean;
111
+ getPath?: (data: any) => string;
112
+ };
104
113
  }
105
114
 
106
115
  export interface QbsTableToolbarProps {
@@ -1,24 +1,36 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React, { useState, useRef } from 'react';
2
2
 
3
3
  const TooltipComponent: React.FC<any> = ({ title, children }) => {
4
- const [scrollY, setScrollY] = useState(0);
5
- const [isScrollingUp, setIsScrollingUp] = useState(true);
4
+ const [dropdownPosition, setDropdownPosition] = useState('bottom-position');
5
+ const dropRef = useRef(null);
6
+ const menuButtonRef = useRef<HTMLElement>(null);
7
+ const adjustDropdownPosition = () => {
8
+ if (menuButtonRef.current && dropRef.current) {
9
+ const inputBoxRect = menuButtonRef.current?.getBoundingClientRect();
10
+ const viewportHeight = window.innerHeight;
6
11
 
7
- const handleScroll = () => {
8
- setIsScrollingUp(window.scrollY < scrollY);
9
- setScrollY(window.scrollY);
12
+ const spaceAbove = inputBoxRect.top;
13
+ const spaceBelow = viewportHeight - inputBoxRect.bottom;
14
+ if (spaceAbove > spaceBelow) {
15
+ setDropdownPosition('top-position');
16
+ } else {
17
+ setDropdownPosition('bottom-position');
18
+ }
19
+ }
10
20
  };
11
21
 
12
- useEffect(() => {
13
- window.addEventListener('scroll', handleScroll);
14
- return () => {
15
- window.removeEventListener('scroll', handleScroll);
16
- };
17
- }, [scrollY]);
18
22
  return (
19
- <div className={`qbs-table-tooltip ${!isScrollingUp ? 'up' : 'down'}`}>
20
- <span>{children}</span>
21
- <span className="tooltiptext">{title}</span>
23
+ <div className={`qbs-table-tooltip ${dropdownPosition == 'bottom-position' ? 'down' : 'up'} `}>
24
+ <span
25
+ ref={menuButtonRef}
26
+ style={{ display: 'flex' }}
27
+ onMouseEnter={() => adjustDropdownPosition()}
28
+ >
29
+ {children}
30
+ </span>
31
+ <span ref={dropRef} className={`tooltiptext`}>
32
+ {title}
33
+ </span>
22
34
  </div>
23
35
  );
24
36
  };
@@ -41,6 +41,7 @@ const MenuDropDown: React.FC<Props> = ({ actionDropDown, handleMenuActions, rowD
41
41
  setOpenMenu(false);
42
42
  };
43
43
 
44
+
44
45
  return (
45
46
  <div className="qbs-table-menu-dropdown" ref={menuRef}>
46
47
  <button className="qbs-table-dropbtn" onClick={toggleMenu} ref={menuButtonRef}>