qbs-react-grid 2.0.7 → 2.0.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/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/Table.d.ts +0 -2
- package/es/Table.js +2 -7
- package/es/qbsTable/CustomTableCell.js +11 -2
- package/es/qbsTable/QbsTable.js +4 -4
- package/es/qbsTable/TableCardList.js +4 -2
- package/es/qbsTable/commontypes.d.ts +1 -0
- package/es/qbsTable/utilities/CardMenuDropdown.js +1 -3
- package/es/qbsTable/utilities/VerticalDropDownMenu.d.ts +12 -0
- package/es/qbsTable/utilities/VerticalDropDownMenu.js +82 -0
- package/es/utils/useScrollListener.js +0 -2
- package/lib/Table.d.ts +0 -2
- package/lib/Table.js +2 -7
- package/lib/qbsTable/CustomTableCell.js +11 -2
- package/lib/qbsTable/QbsTable.js +4 -4
- package/lib/qbsTable/TableCardList.js +4 -2
- package/lib/qbsTable/commontypes.d.ts +1 -0
- package/lib/qbsTable/utilities/CardMenuDropdown.js +0 -1
- package/lib/qbsTable/utilities/VerticalDropDownMenu.d.ts +12 -0
- package/lib/qbsTable/utilities/VerticalDropDownMenu.js +90 -0
- package/lib/utils/useScrollListener.js +0 -2
- package/package.json +1 -1
- package/src/Table.tsx +6 -42
- package/src/qbsTable/CustomTableCell.tsx +21 -9
- package/src/qbsTable/QbsTable.tsx +3 -4
- package/src/qbsTable/TableCardList.tsx +3 -2
- package/src/qbsTable/commontypes.ts +2 -1
- package/src/qbsTable/utilities/CardMenuDropdown.tsx +1 -4
- package/src/qbsTable/utilities/VerticalDropDownMenu.tsx +103 -0
- package/src/utils/useScrollListener.ts +1 -8
|
@@ -81,7 +81,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
81
81
|
renderEmpty,
|
|
82
82
|
autoHeight,
|
|
83
83
|
emptySubTitle,
|
|
84
|
-
emptyTitle
|
|
84
|
+
emptyTitle,
|
|
85
|
+
dropType = 'horizontal'
|
|
85
86
|
}) => {
|
|
86
87
|
const [loading, setLoading] = useState(false);
|
|
87
88
|
const [columns, setColumns] = useState(propColumn);
|
|
@@ -260,7 +261,6 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
260
261
|
|
|
261
262
|
const handleExpanded = useCallback(
|
|
262
263
|
(rowData: any) => {
|
|
263
|
-
console.log(rowData);
|
|
264
264
|
const keyValue = dataRowKey as string;
|
|
265
265
|
const key = rowData[keyValue];
|
|
266
266
|
|
|
@@ -612,6 +612,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
612
612
|
<ActionCell
|
|
613
613
|
tableBodyRef={tableBodyRef}
|
|
614
614
|
actionProps={actionProps}
|
|
615
|
+
dropType={dropType}
|
|
615
616
|
className={`${classes.cellClass} ${classes.actionCellClass}`}
|
|
616
617
|
handleMenuActions={handleMenuActions}
|
|
617
618
|
dataTheme={dataTheme}
|
|
@@ -140,7 +140,8 @@ export interface QbsTableProps {
|
|
|
140
140
|
fullWidthView?: boolean;
|
|
141
141
|
setTableFullView?: (value: boolean) => void;
|
|
142
142
|
setRowViewToggle?: (value: boolean) => void;
|
|
143
|
-
|
|
143
|
+
dropType?: 'horizondal' | 'vertical'
|
|
144
|
+
}
|
|
144
145
|
|
|
145
146
|
export interface QbsTableToolbarProps {
|
|
146
147
|
title?: string;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
4
2
|
import { ActionProps } from '../commontypes';
|
|
5
3
|
import { ThreeDotIcon } from './icons';
|
|
6
4
|
import TooltipComponent from './ToolTip';
|
|
@@ -46,7 +44,6 @@ const CardMenuDropdown: React.FC<Props> = ({ actionDropDown, handleMenuActions,
|
|
|
46
44
|
const dropdownHeight = 200; // Adjust this if your dropdown height varies
|
|
47
45
|
const spaceBelow = window.innerHeight - buttonRect.bottom;
|
|
48
46
|
const spaceAbove = buttonRect.top;
|
|
49
|
-
console.log(spaceAbove, spaceBelow, dropdownHeight);
|
|
50
47
|
if (spaceBelow < dropdownHeight && spaceAbove > spaceBelow) {
|
|
51
48
|
setMenuPositionStyles({
|
|
52
49
|
bottom: '30px',
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { ActionProps } from '../commontypes';
|
|
3
|
+
import { ThreeDotIcon } from './icons';
|
|
4
|
+
import TooltipComponent from './ToolTip';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
actionDropDown: ActionProps[];
|
|
8
|
+
handleMenuActions?: (slug: ActionProps, rowData?: any) => void;
|
|
9
|
+
rowData?: any;
|
|
10
|
+
dataTheme?: string;
|
|
11
|
+
tableBodyRef: React.RefObject<HTMLDivElement>;
|
|
12
|
+
rowIndex?: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const VerticalMenuDropdown: React.FC<Props> = ({
|
|
16
|
+
actionDropDown,
|
|
17
|
+
handleMenuActions,
|
|
18
|
+
rowData,
|
|
19
|
+
tableBodyRef,
|
|
20
|
+
rowIndex
|
|
21
|
+
}) => {
|
|
22
|
+
const [openMenu, setOpenMenu] = useState(false);
|
|
23
|
+
const menuButtonRef = useRef<HTMLButtonElement | null>(null);
|
|
24
|
+
const menuRef = useRef<HTMLDivElement | null>(null);
|
|
25
|
+
const dropRef = useRef<HTMLDivElement | null>(null);
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
29
|
+
if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
|
|
30
|
+
setOpenMenu(false);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
document.addEventListener('click', handleClickOutside);
|
|
35
|
+
return () => {
|
|
36
|
+
document.removeEventListener('click', handleClickOutside);
|
|
37
|
+
};
|
|
38
|
+
}, []);
|
|
39
|
+
|
|
40
|
+
const handleMenuItemClick = (slug: ActionProps) => {
|
|
41
|
+
handleMenuActions?.(slug, rowData);
|
|
42
|
+
slug.action?.(rowData);
|
|
43
|
+
setOpenMenu(false);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const handleShowHideMenu = () => {
|
|
47
|
+
return (
|
|
48
|
+
actionDropDown?.filter(item => !item.hidden && !item?.hide?.(rowData, rowIndex))?.length ?? 0
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const toggleMenu = () => {
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
setOpenMenu(prev => !prev);
|
|
55
|
+
}, 200);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div className="relative inline-block text-left vertical-menu-dropdown-wrapper" ref={menuRef}>
|
|
60
|
+
{handleShowHideMenu() > 0 && (
|
|
61
|
+
<button
|
|
62
|
+
className="vertical-menu-trigger-button p-2 rounded hover:bg-gray-100 transition-colors"
|
|
63
|
+
onClick={toggleMenu}
|
|
64
|
+
ref={menuButtonRef}
|
|
65
|
+
>
|
|
66
|
+
<ThreeDotIcon />
|
|
67
|
+
</button>
|
|
68
|
+
)}
|
|
69
|
+
|
|
70
|
+
{openMenu && (
|
|
71
|
+
<div
|
|
72
|
+
className="absolute z-10 mt-2 w-48 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none vertical-menu-dropdown-content"
|
|
73
|
+
ref={dropRef}
|
|
74
|
+
>
|
|
75
|
+
<div className="py-1">
|
|
76
|
+
{actionDropDown?.map(item =>
|
|
77
|
+
!item?.hidden && !item?.hide?.(rowData, rowIndex) ? (
|
|
78
|
+
<div
|
|
79
|
+
key={item.title}
|
|
80
|
+
className="vertical-menu-item px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 cursor-pointer flex items-center gap-2 transition-colors"
|
|
81
|
+
onClick={e => {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
item.action?.(item);
|
|
84
|
+
handleMenuItemClick(item);
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
<TooltipComponent title={item.toolTip} tableBodyRef={tableBodyRef}>
|
|
88
|
+
<div className="vertical-menu-icon-title flex items-center gap-2">
|
|
89
|
+
<span className="vertical-menu-icon">{item.icon}</span>
|
|
90
|
+
<span className="vertical-menu-title">{item.title}</span>
|
|
91
|
+
</div>
|
|
92
|
+
</TooltipComponent>
|
|
93
|
+
</div>
|
|
94
|
+
) : null
|
|
95
|
+
)}
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
)}
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default VerticalMenuDropdown;
|
|
@@ -189,13 +189,7 @@ const useScrollListener = (props: ScrollListenerProps) => {
|
|
|
189
189
|
|
|
190
190
|
setScrollX(x);
|
|
191
191
|
setScrollY(y);
|
|
192
|
-
|
|
193
|
-
scrollY.current,
|
|
194
|
-
contentHeight.current,
|
|
195
|
-
nextScrollY,
|
|
196
|
-
minScrollY.current,
|
|
197
|
-
'scrolllistner'
|
|
198
|
-
);
|
|
192
|
+
|
|
199
193
|
if (
|
|
200
194
|
typeof handleInfiniteScroll === 'function' &&
|
|
201
195
|
deltaY !== 0 &&
|
|
@@ -355,7 +349,6 @@ const useScrollListener = (props: ScrollListenerProps) => {
|
|
|
355
349
|
if (!isTouching.current) {
|
|
356
350
|
return;
|
|
357
351
|
}
|
|
358
|
-
console.log('handleTouchEnd');
|
|
359
352
|
isTouching.current = false;
|
|
360
353
|
const touchDuration = new Date().getTime() - momentumStartTime.current;
|
|
361
354
|
const absDeltaY = Math.abs(scrollY.current - momentumStartY.current);
|