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.
@@ -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);
@@ -407,6 +414,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
407
414
  ),
408
415
  [columns, dataTheme]
409
416
  );
417
+
410
418
  return (
411
419
  <div className={`qbs-table ${classes.tableContainerClass}`} data-theme={dataTheme}>
412
420
  {toolbar && <ToolBar {...toolbarProps} />}
@@ -417,12 +425,14 @@ const QbsTable: React.FC<QbsTableProps> = ({
417
425
  dataTheme={dataTheme}
418
426
  wordWrap={wordWrap}
419
427
  sortColumn={sortColumn}
428
+ style={{ position: 'relative' }}
420
429
  sortType={sortType}
421
430
  onSortColumn={handleSortColumn}
422
431
  onRowClick={onRowClick}
423
432
  tableBodyHeight={tableBodyHeight}
424
433
  cellBordered={cellBordered}
425
434
  bordered={bordered}
435
+ columns={columns}
426
436
  minHeight={minHeight}
427
437
  headerHeight={headerHeight}
428
438
  loading={isLoading ?? loading}
@@ -496,6 +506,24 @@ const QbsTable: React.FC<QbsTableProps> = ({
496
506
  />
497
507
  </Column>
498
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
+ )}
499
527
  {columnsRendered}
500
528
  {!actionProps ||
501
529
  (actionProps?.length === 0 && columnToggle && (
@@ -546,6 +574,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
546
574
  </Column>
547
575
  )}
548
576
  </Table>
577
+
549
578
  <div>
550
579
  {pagination && data?.length > 0 && <Pagination paginationProps={paginationProps} />}
551
580
  </div>
@@ -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}>
@@ -305,7 +305,6 @@ const useTableDimension = <Row extends RowDataType, Key>(props: TableDimensionPr
305
305
  if (fillHeight) {
306
306
  return tableHeight.current;
307
307
  }
308
-
309
308
  if (data?.length === 0 && autoHeight) {
310
309
  return heightProp;
311
310
  }