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
|
@@ -91,7 +91,9 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
91
91
|
_renderEmpty = _ref.renderEmpty,
|
|
92
92
|
autoHeight = _ref.autoHeight,
|
|
93
93
|
emptySubTitle = _ref.emptySubTitle,
|
|
94
|
-
emptyTitle = _ref.emptyTitle
|
|
94
|
+
emptyTitle = _ref.emptyTitle,
|
|
95
|
+
_ref$dropType = _ref.dropType,
|
|
96
|
+
dropType = _ref$dropType === void 0 ? 'horizontal' : _ref$dropType;
|
|
95
97
|
var _useState = useState(false),
|
|
96
98
|
loading = _useState[0],
|
|
97
99
|
setLoading = _useState[1];
|
|
@@ -261,7 +263,6 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
261
263
|
};
|
|
262
264
|
}, [themeToggle]);
|
|
263
265
|
var handleExpanded = useCallback(function (rowData) {
|
|
264
|
-
console.log(rowData);
|
|
265
266
|
var keyValue = dataRowKey;
|
|
266
267
|
var key = rowData[keyValue];
|
|
267
268
|
var nextExpandedRowKeys = new Set(expandedRowKeys);
|
|
@@ -556,6 +557,7 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
556
557
|
})), /*#__PURE__*/React.createElement(ActionCell, {
|
|
557
558
|
tableBodyRef: tableBodyRef,
|
|
558
559
|
actionProps: actionProps,
|
|
560
|
+
dropType: dropType,
|
|
559
561
|
className: classes.cellClass + " " + classes.actionCellClass,
|
|
560
562
|
handleMenuActions: handleMenuActions,
|
|
561
563
|
dataTheme: dataTheme
|
|
@@ -137,6 +137,7 @@ export interface QbsTableProps {
|
|
|
137
137
|
fullWidthView?: boolean;
|
|
138
138
|
setTableFullView?: (value: boolean) => void;
|
|
139
139
|
setRowViewToggle?: (value: boolean) => void;
|
|
140
|
+
dropType?: 'horizondal' | 'vertical';
|
|
140
141
|
}
|
|
141
142
|
export interface QbsTableToolbarProps {
|
|
142
143
|
title?: string;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
2
|
import { ThreeDotIcon } from './icons';
|
|
4
3
|
import TooltipComponent from './ToolTip';
|
|
5
4
|
var CardMenuDropdown = function CardMenuDropdown(_ref) {
|
|
@@ -32,7 +31,6 @@ var CardMenuDropdown = function CardMenuDropdown(_ref) {
|
|
|
32
31
|
var dropdownHeight = 200; // Adjust this if your dropdown height varies
|
|
33
32
|
var spaceBelow = window.innerHeight - buttonRect.bottom;
|
|
34
33
|
var spaceAbove = buttonRect.top;
|
|
35
|
-
console.log(spaceAbove, spaceBelow, dropdownHeight);
|
|
36
34
|
if (spaceBelow < dropdownHeight && spaceAbove > spaceBelow) {
|
|
37
35
|
setMenuPositionStyles({
|
|
38
36
|
bottom: '30px',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ActionProps } from '../commontypes';
|
|
3
|
+
type Props = {
|
|
4
|
+
actionDropDown: ActionProps[];
|
|
5
|
+
handleMenuActions?: (slug: ActionProps, rowData?: any) => void;
|
|
6
|
+
rowData?: any;
|
|
7
|
+
dataTheme?: string;
|
|
8
|
+
tableBodyRef: React.RefObject<HTMLDivElement>;
|
|
9
|
+
rowIndex?: number;
|
|
10
|
+
};
|
|
11
|
+
declare const VerticalMenuDropdown: React.FC<Props>;
|
|
12
|
+
export default VerticalMenuDropdown;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { ThreeDotIcon } from './icons';
|
|
3
|
+
import TooltipComponent from './ToolTip';
|
|
4
|
+
var VerticalMenuDropdown = function VerticalMenuDropdown(_ref) {
|
|
5
|
+
var actionDropDown = _ref.actionDropDown,
|
|
6
|
+
handleMenuActions = _ref.handleMenuActions,
|
|
7
|
+
rowData = _ref.rowData,
|
|
8
|
+
tableBodyRef = _ref.tableBodyRef,
|
|
9
|
+
rowIndex = _ref.rowIndex;
|
|
10
|
+
var _useState = useState(false),
|
|
11
|
+
openMenu = _useState[0],
|
|
12
|
+
setOpenMenu = _useState[1];
|
|
13
|
+
var menuButtonRef = useRef(null);
|
|
14
|
+
var menuRef = useRef(null);
|
|
15
|
+
var dropRef = useRef(null);
|
|
16
|
+
useEffect(function () {
|
|
17
|
+
var handleClickOutside = function handleClickOutside(event) {
|
|
18
|
+
if (menuRef.current && !menuRef.current.contains(event.target)) {
|
|
19
|
+
setOpenMenu(false);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
document.addEventListener('click', handleClickOutside);
|
|
23
|
+
return function () {
|
|
24
|
+
document.removeEventListener('click', handleClickOutside);
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
var handleMenuItemClick = function handleMenuItemClick(slug) {
|
|
28
|
+
var _slug$action;
|
|
29
|
+
handleMenuActions === null || handleMenuActions === void 0 ? void 0 : handleMenuActions(slug, rowData);
|
|
30
|
+
(_slug$action = slug.action) === null || _slug$action === void 0 ? void 0 : _slug$action.call(slug, rowData);
|
|
31
|
+
setOpenMenu(false);
|
|
32
|
+
};
|
|
33
|
+
var handleShowHideMenu = function handleShowHideMenu() {
|
|
34
|
+
var _actionDropDown$filte, _actionDropDown$filte2;
|
|
35
|
+
return (_actionDropDown$filte = actionDropDown === null || actionDropDown === void 0 ? void 0 : (_actionDropDown$filte2 = actionDropDown.filter(function (item) {
|
|
36
|
+
var _item$hide;
|
|
37
|
+
return !item.hidden && !(item !== null && item !== void 0 && (_item$hide = item.hide) !== null && _item$hide !== void 0 && _item$hide.call(item, rowData, rowIndex));
|
|
38
|
+
})) === null || _actionDropDown$filte2 === void 0 ? void 0 : _actionDropDown$filte2.length) != null ? _actionDropDown$filte : 0;
|
|
39
|
+
};
|
|
40
|
+
var toggleMenu = function toggleMenu() {
|
|
41
|
+
setTimeout(function () {
|
|
42
|
+
setOpenMenu(function (prev) {
|
|
43
|
+
return !prev;
|
|
44
|
+
});
|
|
45
|
+
}, 200);
|
|
46
|
+
};
|
|
47
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: "relative inline-block text-left vertical-menu-dropdown-wrapper",
|
|
49
|
+
ref: menuRef
|
|
50
|
+
}, handleShowHideMenu() > 0 && /*#__PURE__*/React.createElement("button", {
|
|
51
|
+
className: "vertical-menu-trigger-button p-2 rounded hover:bg-gray-100 transition-colors",
|
|
52
|
+
onClick: toggleMenu,
|
|
53
|
+
ref: menuButtonRef
|
|
54
|
+
}, /*#__PURE__*/React.createElement(ThreeDotIcon, null)), openMenu && /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
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",
|
|
56
|
+
ref: dropRef
|
|
57
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
className: "py-1"
|
|
59
|
+
}, actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.map(function (item) {
|
|
60
|
+
var _item$hide2;
|
|
61
|
+
return !(item !== null && item !== void 0 && item.hidden) && !(item !== null && item !== void 0 && (_item$hide2 = item.hide) !== null && _item$hide2 !== void 0 && _item$hide2.call(item, rowData, rowIndex)) ? /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
key: item.title,
|
|
63
|
+
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",
|
|
64
|
+
onClick: function onClick(e) {
|
|
65
|
+
var _item$action;
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
(_item$action = item.action) === null || _item$action === void 0 ? void 0 : _item$action.call(item, item);
|
|
68
|
+
handleMenuItemClick(item);
|
|
69
|
+
}
|
|
70
|
+
}, /*#__PURE__*/React.createElement(TooltipComponent, {
|
|
71
|
+
title: item.toolTip,
|
|
72
|
+
tableBodyRef: tableBodyRef
|
|
73
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
74
|
+
className: "vertical-menu-icon-title flex items-center gap-2"
|
|
75
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
76
|
+
className: "vertical-menu-icon"
|
|
77
|
+
}, item.icon), /*#__PURE__*/React.createElement("span", {
|
|
78
|
+
className: "vertical-menu-title"
|
|
79
|
+
}, item.title)))) : null;
|
|
80
|
+
}))));
|
|
81
|
+
};
|
|
82
|
+
export default VerticalMenuDropdown;
|
|
@@ -131,7 +131,6 @@ var useScrollListener = function useScrollListener(props) {
|
|
|
131
131
|
var x = Math.min(0, nextScrollX < minScrollX.current ? minScrollX.current : nextScrollX);
|
|
132
132
|
setScrollX(x);
|
|
133
133
|
setScrollY(y);
|
|
134
|
-
console.log(scrollY.current, contentHeight.current, nextScrollY, minScrollY.current, 'scrolllistner');
|
|
135
134
|
if (typeof handleInfiniteScroll === 'function' && deltaY !== 0 && !loading && Math.abs(y) + getTableHeight() >= contentHeight.current - 12) {
|
|
136
135
|
handleInfiniteScroll(scrollY.current);
|
|
137
136
|
}
|
|
@@ -245,7 +244,6 @@ var useScrollListener = function useScrollListener(props) {
|
|
|
245
244
|
if (!isTouching.current) {
|
|
246
245
|
return;
|
|
247
246
|
}
|
|
248
|
-
console.log('handleTouchEnd');
|
|
249
247
|
isTouching.current = false;
|
|
250
248
|
var touchDuration = new Date().getTime() - momentumStartTime.current;
|
|
251
249
|
var absDeltaY = Math.abs(scrollY.current - momentumStartY.current);
|
package/lib/Table.d.ts
CHANGED
|
@@ -96,8 +96,6 @@ export interface TableProps<Row, Key> extends Omit<StandardProps, 'onScroll'> {
|
|
|
96
96
|
virtualized?: boolean;
|
|
97
97
|
/**Theme Change */
|
|
98
98
|
dataTheme?: string;
|
|
99
|
-
/** Refresh Row */
|
|
100
|
-
refreshRow?: number;
|
|
101
99
|
/** Tree table, the callback function in the expanded node */
|
|
102
100
|
renderTreeToggle?: (expandButton: React.ReactNode, rowData?: Row, expanded?: boolean) => React.ReactNode;
|
|
103
101
|
tableKey?: string;
|
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", "
|
|
23
|
+
var _excluded = ["affixHeader", "children", "classPrefix", "className", "data", "defaultSortType", "width", "expandedRowKeys", "defaultExpandAllRows", "defaultExpandedRowKeys", "style", "id", "isTree", "hover", "bordered", "cellBordered", "wordWrap", "loading", "locale", "showHeader", "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", "tableBodyHeight", "columns", "tableBodyRef", "tableKey", "handleInfiniteScroll", "infiniteLoading", "wheelWrapperRef"],
|
|
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); }
|
|
@@ -77,10 +77,6 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
77
77
|
} : _props$locale,
|
|
78
78
|
_props$showHeader = props.showHeader,
|
|
79
79
|
showHeader = _props$showHeader === void 0 ? true : _props$showHeader,
|
|
80
|
-
_props$pagination = props.pagination,
|
|
81
|
-
pagination = _props$pagination === void 0 ? true : _props$pagination,
|
|
82
|
-
_props$paginationProp = props.paginationProps,
|
|
83
|
-
paginationProps = _props$paginationProp === void 0 ? {} : _props$paginationProp,
|
|
84
80
|
sortColumn = props.sortColumn,
|
|
85
81
|
_props$rowHeight = props.rowHeight,
|
|
86
82
|
rowHeight = _props$rowHeight === void 0 ? _constants.ROW_HEIGHT : _props$rowHeight,
|
|
@@ -118,7 +114,6 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
118
114
|
onTouchStart = props.onTouchStart,
|
|
119
115
|
onTouchMove = props.onTouchMove,
|
|
120
116
|
onTouchEnd = props.onTouchEnd,
|
|
121
|
-
dataTheme = props.dataTheme,
|
|
122
117
|
tableBodyHeight = props.tableBodyHeight,
|
|
123
118
|
columns = props.columns,
|
|
124
119
|
tableBodyRef = props.tableBodyRef,
|
|
@@ -627,7 +622,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
627
622
|
},
|
|
628
623
|
length: tableWidth.current,
|
|
629
624
|
onScroll: function onScroll(delta) {
|
|
630
|
-
onScrollHorizontal(delta)
|
|
625
|
+
onScrollHorizontal(delta);
|
|
631
626
|
},
|
|
632
627
|
scrollLength: contentWidth.current,
|
|
633
628
|
ref: scrollbarXRef
|
|
@@ -10,6 +10,7 @@ var _reactRouterDom = require("react-router-dom");
|
|
|
10
10
|
var _Cell = _interopRequireDefault(require("../Cell"));
|
|
11
11
|
var _handleFormatCell = require("./utilities/handleFormatCell");
|
|
12
12
|
var _menuDropDown = _interopRequireDefault(require("./utilities/menuDropDown"));
|
|
13
|
+
var _VerticalDropDownMenu = _interopRequireDefault(require("./utilities/VerticalDropDownMenu"));
|
|
13
14
|
var _excluded = ["rowData", "onChange", "checkedKeys", "dataKey", "dataTheme"],
|
|
14
15
|
_excluded2 = ["rowData", "dataKey", "expandedRowKeys", "onChange"],
|
|
15
16
|
_excluded3 = ["rowData", "renderCell", "toolTip", "hideLink", "dataKey", "onChange", "rowClick", "type", "path", "link"],
|
|
@@ -61,8 +62,16 @@ var ActionCell = /*#__PURE__*/_react["default"].memo(function (_ref2) {
|
|
|
61
62
|
dataTheme = _ref2.dataTheme,
|
|
62
63
|
actionProps = _ref2.actionProps,
|
|
63
64
|
tableBodyRef = _ref2.tableBodyRef,
|
|
64
|
-
rowIndex = _ref2.rowIndex
|
|
65
|
-
|
|
65
|
+
rowIndex = _ref2.rowIndex,
|
|
66
|
+
dropType = _ref2.dropType;
|
|
67
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, dropType == 'vertical' ? /*#__PURE__*/_react["default"].createElement(_VerticalDropDownMenu["default"], {
|
|
68
|
+
tableBodyRef: tableBodyRef,
|
|
69
|
+
actionDropDown: actionProps,
|
|
70
|
+
rowData: rowData,
|
|
71
|
+
dataTheme: dataTheme,
|
|
72
|
+
rowIndex: rowIndex,
|
|
73
|
+
handleMenuActions: handleMenuActions
|
|
74
|
+
}) : /*#__PURE__*/_react["default"].createElement(_menuDropDown["default"], {
|
|
66
75
|
tableBodyRef: tableBodyRef,
|
|
67
76
|
actionDropDown: actionProps,
|
|
68
77
|
rowData: rowData,
|
package/lib/qbsTable/QbsTable.js
CHANGED
|
@@ -127,7 +127,9 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
127
127
|
_ref$fullWidthView = _ref.fullWidthView,
|
|
128
128
|
fullWidthView = _ref$fullWidthView === void 0 ? false : _ref$fullWidthView,
|
|
129
129
|
setTableFullView = _ref.setTableFullView,
|
|
130
|
-
setRowViewToggle = _ref.setRowViewToggle
|
|
130
|
+
setRowViewToggle = _ref.setRowViewToggle,
|
|
131
|
+
_ref$dropType = _ref.dropType,
|
|
132
|
+
dropType = _ref$dropType === void 0 ? 'horizondal' : _ref$dropType;
|
|
131
133
|
var _useState = (0, _react.useState)(false),
|
|
132
134
|
loading = _useState[0],
|
|
133
135
|
setLoading = _useState[1];
|
|
@@ -260,7 +262,6 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
260
262
|
|
|
261
263
|
// useEffect(() => {
|
|
262
264
|
// }, [columns]);
|
|
263
|
-
console.log(viewMode);
|
|
264
265
|
var handleClear = function handleClear(_ref2) {
|
|
265
266
|
setCheckedKeys([]);
|
|
266
267
|
handleChecked([]);
|
|
@@ -324,7 +325,6 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
324
325
|
};
|
|
325
326
|
}, [themeToggle]);
|
|
326
327
|
var handleExpanded = (0, _react.useCallback)(function (rowData) {
|
|
327
|
-
console.log(rowData);
|
|
328
328
|
var keyValue = dataRowKey;
|
|
329
329
|
var key = rowData[keyValue];
|
|
330
330
|
var nextExpandedRowKeys = new Set(expandedRowKeys);
|
|
@@ -609,7 +609,6 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
609
609
|
key: tableKey + REFRESH_KEY,
|
|
610
610
|
tableKey: tableKey,
|
|
611
611
|
data: data,
|
|
612
|
-
refreshRow: REFRESH_KEY,
|
|
613
612
|
tableBodyRef: tableBodyRef,
|
|
614
613
|
dataTheme: dataTheme,
|
|
615
614
|
wordWrap: wordWrap,
|
|
@@ -757,6 +756,7 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
757
756
|
handleColumnToggle: handleColumnToggle
|
|
758
757
|
})), /*#__PURE__*/_react["default"].createElement(_CustomTableCell.ActionCell, {
|
|
759
758
|
tableBodyRef: tableBodyRef,
|
|
759
|
+
dropType: dropType,
|
|
760
760
|
actionProps: actionProps,
|
|
761
761
|
className: classes.cellClass + " " + classes.actionCellClass,
|
|
762
762
|
handleMenuActions: handleMenuActions,
|
|
@@ -97,7 +97,9 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
97
97
|
_renderEmpty = _ref.renderEmpty,
|
|
98
98
|
autoHeight = _ref.autoHeight,
|
|
99
99
|
emptySubTitle = _ref.emptySubTitle,
|
|
100
|
-
emptyTitle = _ref.emptyTitle
|
|
100
|
+
emptyTitle = _ref.emptyTitle,
|
|
101
|
+
_ref$dropType = _ref.dropType,
|
|
102
|
+
dropType = _ref$dropType === void 0 ? 'horizontal' : _ref$dropType;
|
|
101
103
|
var _useState = (0, _react.useState)(false),
|
|
102
104
|
loading = _useState[0],
|
|
103
105
|
setLoading = _useState[1];
|
|
@@ -267,7 +269,6 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
267
269
|
};
|
|
268
270
|
}, [themeToggle]);
|
|
269
271
|
var handleExpanded = (0, _react.useCallback)(function (rowData) {
|
|
270
|
-
console.log(rowData);
|
|
271
272
|
var keyValue = dataRowKey;
|
|
272
273
|
var key = rowData[keyValue];
|
|
273
274
|
var nextExpandedRowKeys = new Set(expandedRowKeys);
|
|
@@ -562,6 +563,7 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
562
563
|
})), /*#__PURE__*/_react["default"].createElement(_CustomTableCell.ActionCell, {
|
|
563
564
|
tableBodyRef: tableBodyRef,
|
|
564
565
|
actionProps: actionProps,
|
|
566
|
+
dropType: dropType,
|
|
565
567
|
className: classes.cellClass + " " + classes.actionCellClass,
|
|
566
568
|
handleMenuActions: handleMenuActions,
|
|
567
569
|
dataTheme: dataTheme
|
|
@@ -137,6 +137,7 @@ export interface QbsTableProps {
|
|
|
137
137
|
fullWidthView?: boolean;
|
|
138
138
|
setTableFullView?: (value: boolean) => void;
|
|
139
139
|
setRowViewToggle?: (value: boolean) => void;
|
|
140
|
+
dropType?: 'horizondal' | 'vertical';
|
|
140
141
|
}
|
|
141
142
|
export interface QbsTableToolbarProps {
|
|
142
143
|
title?: string;
|
|
@@ -38,7 +38,6 @@ var CardMenuDropdown = function CardMenuDropdown(_ref) {
|
|
|
38
38
|
var dropdownHeight = 200; // Adjust this if your dropdown height varies
|
|
39
39
|
var spaceBelow = window.innerHeight - buttonRect.bottom;
|
|
40
40
|
var spaceAbove = buttonRect.top;
|
|
41
|
-
console.log(spaceAbove, spaceBelow, dropdownHeight);
|
|
42
41
|
if (spaceBelow < dropdownHeight && spaceAbove > spaceBelow) {
|
|
43
42
|
setMenuPositionStyles({
|
|
44
43
|
bottom: '30px',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ActionProps } from '../commontypes';
|
|
3
|
+
type Props = {
|
|
4
|
+
actionDropDown: ActionProps[];
|
|
5
|
+
handleMenuActions?: (slug: ActionProps, rowData?: any) => void;
|
|
6
|
+
rowData?: any;
|
|
7
|
+
dataTheme?: string;
|
|
8
|
+
tableBodyRef: React.RefObject<HTMLDivElement>;
|
|
9
|
+
rowIndex?: number;
|
|
10
|
+
};
|
|
11
|
+
declare const VerticalMenuDropdown: React.FC<Props>;
|
|
12
|
+
export default VerticalMenuDropdown;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports["default"] = void 0;
|
|
6
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
7
|
+
var _icons = require("./icons");
|
|
8
|
+
var _ToolTip = _interopRequireDefault(require("./ToolTip"));
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
var VerticalMenuDropdown = function VerticalMenuDropdown(_ref) {
|
|
12
|
+
var actionDropDown = _ref.actionDropDown,
|
|
13
|
+
handleMenuActions = _ref.handleMenuActions,
|
|
14
|
+
rowData = _ref.rowData,
|
|
15
|
+
tableBodyRef = _ref.tableBodyRef,
|
|
16
|
+
rowIndex = _ref.rowIndex;
|
|
17
|
+
var _useState = (0, _react.useState)(false),
|
|
18
|
+
openMenu = _useState[0],
|
|
19
|
+
setOpenMenu = _useState[1];
|
|
20
|
+
var menuButtonRef = (0, _react.useRef)(null);
|
|
21
|
+
var menuRef = (0, _react.useRef)(null);
|
|
22
|
+
var dropRef = (0, _react.useRef)(null);
|
|
23
|
+
(0, _react.useEffect)(function () {
|
|
24
|
+
var handleClickOutside = function handleClickOutside(event) {
|
|
25
|
+
if (menuRef.current && !menuRef.current.contains(event.target)) {
|
|
26
|
+
setOpenMenu(false);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
document.addEventListener('click', handleClickOutside);
|
|
30
|
+
return function () {
|
|
31
|
+
document.removeEventListener('click', handleClickOutside);
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
var handleMenuItemClick = function handleMenuItemClick(slug) {
|
|
35
|
+
var _slug$action;
|
|
36
|
+
handleMenuActions === null || handleMenuActions === void 0 ? void 0 : handleMenuActions(slug, rowData);
|
|
37
|
+
(_slug$action = slug.action) === null || _slug$action === void 0 ? void 0 : _slug$action.call(slug, rowData);
|
|
38
|
+
setOpenMenu(false);
|
|
39
|
+
};
|
|
40
|
+
var handleShowHideMenu = function handleShowHideMenu() {
|
|
41
|
+
var _actionDropDown$filte, _actionDropDown$filte2;
|
|
42
|
+
return (_actionDropDown$filte = actionDropDown === null || actionDropDown === void 0 ? void 0 : (_actionDropDown$filte2 = actionDropDown.filter(function (item) {
|
|
43
|
+
var _item$hide;
|
|
44
|
+
return !item.hidden && !(item !== null && item !== void 0 && (_item$hide = item.hide) !== null && _item$hide !== void 0 && _item$hide.call(item, rowData, rowIndex));
|
|
45
|
+
})) === null || _actionDropDown$filte2 === void 0 ? void 0 : _actionDropDown$filte2.length) != null ? _actionDropDown$filte : 0;
|
|
46
|
+
};
|
|
47
|
+
var toggleMenu = function toggleMenu() {
|
|
48
|
+
setTimeout(function () {
|
|
49
|
+
setOpenMenu(function (prev) {
|
|
50
|
+
return !prev;
|
|
51
|
+
});
|
|
52
|
+
}, 200);
|
|
53
|
+
};
|
|
54
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
55
|
+
className: "relative inline-block text-left vertical-menu-dropdown-wrapper",
|
|
56
|
+
ref: menuRef
|
|
57
|
+
}, handleShowHideMenu() > 0 && /*#__PURE__*/_react["default"].createElement("button", {
|
|
58
|
+
className: "vertical-menu-trigger-button p-2 rounded hover:bg-gray-100 transition-colors",
|
|
59
|
+
onClick: toggleMenu,
|
|
60
|
+
ref: menuButtonRef
|
|
61
|
+
}, /*#__PURE__*/_react["default"].createElement(_icons.ThreeDotIcon, null)), openMenu && /*#__PURE__*/_react["default"].createElement("div", {
|
|
62
|
+
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",
|
|
63
|
+
ref: dropRef
|
|
64
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
65
|
+
className: "py-1"
|
|
66
|
+
}, actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.map(function (item) {
|
|
67
|
+
var _item$hide2;
|
|
68
|
+
return !(item !== null && item !== void 0 && item.hidden) && !(item !== null && item !== void 0 && (_item$hide2 = item.hide) !== null && _item$hide2 !== void 0 && _item$hide2.call(item, rowData, rowIndex)) ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
69
|
+
key: item.title,
|
|
70
|
+
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",
|
|
71
|
+
onClick: function onClick(e) {
|
|
72
|
+
var _item$action;
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
(_item$action = item.action) === null || _item$action === void 0 ? void 0 : _item$action.call(item, item);
|
|
75
|
+
handleMenuItemClick(item);
|
|
76
|
+
}
|
|
77
|
+
}, /*#__PURE__*/_react["default"].createElement(_ToolTip["default"], {
|
|
78
|
+
title: item.toolTip,
|
|
79
|
+
tableBodyRef: tableBodyRef
|
|
80
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
81
|
+
className: "vertical-menu-icon-title flex items-center gap-2"
|
|
82
|
+
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
83
|
+
className: "vertical-menu-icon"
|
|
84
|
+
}, item.icon), /*#__PURE__*/_react["default"].createElement("span", {
|
|
85
|
+
className: "vertical-menu-title"
|
|
86
|
+
}, item.title)))) : null;
|
|
87
|
+
}))));
|
|
88
|
+
};
|
|
89
|
+
var _default = VerticalMenuDropdown;
|
|
90
|
+
exports["default"] = _default;
|
|
@@ -135,7 +135,6 @@ var useScrollListener = function useScrollListener(props) {
|
|
|
135
135
|
var x = Math.min(0, nextScrollX < minScrollX.current ? minScrollX.current : nextScrollX);
|
|
136
136
|
setScrollX(x);
|
|
137
137
|
setScrollY(y);
|
|
138
|
-
console.log(scrollY.current, contentHeight.current, nextScrollY, minScrollY.current, 'scrolllistner');
|
|
139
138
|
if (typeof handleInfiniteScroll === 'function' && deltaY !== 0 && !loading && Math.abs(y) + getTableHeight() >= contentHeight.current - 12) {
|
|
140
139
|
handleInfiniteScroll(scrollY.current);
|
|
141
140
|
}
|
|
@@ -249,7 +248,6 @@ var useScrollListener = function useScrollListener(props) {
|
|
|
249
248
|
if (!isTouching.current) {
|
|
250
249
|
return;
|
|
251
250
|
}
|
|
252
|
-
console.log('handleTouchEnd');
|
|
253
251
|
isTouching.current = false;
|
|
254
252
|
var touchDuration = new Date().getTime() - momentumStartTime.current;
|
|
255
253
|
var absDeltaY = Math.abs(scrollY.current - momentumStartY.current);
|
package/package.json
CHANGED
package/src/Table.tsx
CHANGED
|
@@ -3,50 +3,17 @@ import debounce from 'lodash/debounce';
|
|
|
3
3
|
import flatten from 'lodash/flatten';
|
|
4
4
|
import isFunction from 'lodash/isFunction';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import React, {
|
|
7
|
-
useCallback,
|
|
8
|
-
useEffect,
|
|
9
|
-
useImperativeHandle,
|
|
10
|
-
useReducer,
|
|
11
|
-
useRef,
|
|
12
|
-
useState
|
|
13
|
-
} from 'react';
|
|
6
|
+
import React, { useCallback, useEffect, useImperativeHandle, useReducer, useRef, useState } from 'react';
|
|
14
7
|
|
|
15
8
|
import CellGroup from './CellGroup';
|
|
16
|
-
import {
|
|
17
|
-
CELL_PADDING_HEIGHT,
|
|
18
|
-
EXPANDED_KEY,
|
|
19
|
-
ROW_HEADER_HEIGHT,
|
|
20
|
-
ROW_HEIGHT,
|
|
21
|
-
SCROLLBAR_WIDTH,
|
|
22
|
-
SORT_TYPE,
|
|
23
|
-
TREE_DEPTH
|
|
24
|
-
} from './constants';
|
|
9
|
+
import { CELL_PADDING_HEIGHT, EXPANDED_KEY, ROW_HEADER_HEIGHT, ROW_HEIGHT, SCROLLBAR_WIDTH, SORT_TYPE, TREE_DEPTH } from './constants';
|
|
25
10
|
import EmptyMessage from './EmptyMessage';
|
|
26
11
|
import Loader from './Loader';
|
|
27
12
|
import MouseArea from './MouseArea';
|
|
28
13
|
import Row, { RowProps } from './Row';
|
|
29
14
|
import Scrollbar, { ScrollbarInstance } from './Scrollbar';
|
|
30
15
|
import TableContext from './TableContext';
|
|
31
|
-
import {
|
|
32
|
-
findAllParents,
|
|
33
|
-
findRowKeys,
|
|
34
|
-
flattenData,
|
|
35
|
-
isRTL,
|
|
36
|
-
isSupportTouchEvent,
|
|
37
|
-
mergeCells,
|
|
38
|
-
resetLeftForCells,
|
|
39
|
-
shouldShowRowByExpanded,
|
|
40
|
-
useAffix,
|
|
41
|
-
useCellDescriptor,
|
|
42
|
-
useClassNames,
|
|
43
|
-
useControlled,
|
|
44
|
-
usePosition,
|
|
45
|
-
useScrollListener,
|
|
46
|
-
useTableDimension,
|
|
47
|
-
useTableRows,
|
|
48
|
-
useUpdateEffect
|
|
49
|
-
} from './utils';
|
|
16
|
+
import { findAllParents, findRowKeys, flattenData, isRTL, isSupportTouchEvent, mergeCells, resetLeftForCells, shouldShowRowByExpanded, useAffix, useCellDescriptor, useClassNames, useControlled, usePosition, useScrollListener, useTableDimension, useTableRows, useUpdateEffect } from './utils';
|
|
50
17
|
|
|
51
18
|
import type {
|
|
52
19
|
RowDataType,
|
|
@@ -216,8 +183,7 @@ export interface TableProps<Row, Key> extends Omit<StandardProps, 'onScroll'> {
|
|
|
216
183
|
|
|
217
184
|
/**Theme Change */
|
|
218
185
|
dataTheme?: string;
|
|
219
|
-
|
|
220
|
-
refreshRow?: number;
|
|
186
|
+
|
|
221
187
|
/** Tree table, the callback function in the expanded node */
|
|
222
188
|
renderTreeToggle?: (
|
|
223
189
|
expandButton: React.ReactNode,
|
|
@@ -307,8 +273,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
307
273
|
loading: 'Loading...'
|
|
308
274
|
},
|
|
309
275
|
showHeader = true,
|
|
310
|
-
|
|
311
|
-
paginationProps = {},
|
|
276
|
+
|
|
312
277
|
sortColumn,
|
|
313
278
|
rowHeight = ROW_HEIGHT,
|
|
314
279
|
sortType: sortTypeProp,
|
|
@@ -340,7 +305,6 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
340
305
|
onTouchStart,
|
|
341
306
|
onTouchMove,
|
|
342
307
|
onTouchEnd,
|
|
343
|
-
dataTheme,
|
|
344
308
|
tableBodyHeight,
|
|
345
309
|
columns,
|
|
346
310
|
tableBodyRef,
|
|
@@ -961,7 +925,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
|
|
|
961
925
|
style={{ width: tableWidth.current }}
|
|
962
926
|
length={tableWidth.current}
|
|
963
927
|
onScroll={delta => {
|
|
964
|
-
onScrollHorizontal(delta)
|
|
928
|
+
onScrollHorizontal(delta);
|
|
965
929
|
}}
|
|
966
930
|
scrollLength={contentWidth.current}
|
|
967
931
|
ref={scrollbarXRef}
|
|
@@ -4,6 +4,7 @@ import { Link } from 'react-router-dom';
|
|
|
4
4
|
import Cell from '../Cell';
|
|
5
5
|
import { handleCellFormat } from './utilities/handleFormatCell';
|
|
6
6
|
import MenuDropDown from './utilities/menuDropDown';
|
|
7
|
+
import VerticalMenuDropdown from './utilities/VerticalDropDownMenu';
|
|
7
8
|
|
|
8
9
|
const CHECKBOX_LINE_HEIGHT = '36px';
|
|
9
10
|
export const CheckCell: React.FC<any> = React.memo(
|
|
@@ -37,17 +38,28 @@ export const CheckCell: React.FC<any> = React.memo(
|
|
|
37
38
|
)
|
|
38
39
|
);
|
|
39
40
|
export const ActionCell: React.FC<any> = React.memo(
|
|
40
|
-
({ rowData, handleMenuActions, dataTheme, actionProps, tableBodyRef, rowIndex }) => {
|
|
41
|
+
({ rowData, handleMenuActions, dataTheme, actionProps, tableBodyRef, rowIndex, dropType }) => {
|
|
41
42
|
return (
|
|
42
43
|
<div>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
{dropType == 'vertical' ? (
|
|
45
|
+
<VerticalMenuDropdown
|
|
46
|
+
tableBodyRef={tableBodyRef}
|
|
47
|
+
actionDropDown={actionProps}
|
|
48
|
+
rowData={rowData}
|
|
49
|
+
dataTheme={dataTheme}
|
|
50
|
+
rowIndex={rowIndex}
|
|
51
|
+
handleMenuActions={handleMenuActions}
|
|
52
|
+
/>
|
|
53
|
+
) : (
|
|
54
|
+
<MenuDropDown
|
|
55
|
+
tableBodyRef={tableBodyRef}
|
|
56
|
+
actionDropDown={actionProps}
|
|
57
|
+
rowData={rowData}
|
|
58
|
+
dataTheme={dataTheme}
|
|
59
|
+
rowIndex={rowIndex}
|
|
60
|
+
handleMenuActions={handleMenuActions}
|
|
61
|
+
/>
|
|
62
|
+
)}
|
|
51
63
|
</div>
|
|
52
64
|
);
|
|
53
65
|
}
|
|
@@ -102,7 +102,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
102
102
|
defaultRowView = true,
|
|
103
103
|
fullWidthView = false,
|
|
104
104
|
setTableFullView,
|
|
105
|
-
setRowViewToggle
|
|
105
|
+
setRowViewToggle,
|
|
106
|
+
dropType='horizondal'
|
|
106
107
|
}) => {
|
|
107
108
|
const [loading, setLoading] = useState(false);
|
|
108
109
|
const [columns, setColumns] = useState(propColumn);
|
|
@@ -234,7 +235,6 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
234
235
|
|
|
235
236
|
// useEffect(() => {
|
|
236
237
|
// }, [columns]);
|
|
237
|
-
console.log(viewMode);
|
|
238
238
|
const handleClear = ([]) => {
|
|
239
239
|
setCheckedKeys([]);
|
|
240
240
|
handleChecked([]);
|
|
@@ -302,7 +302,6 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
302
302
|
|
|
303
303
|
const handleExpanded = useCallback(
|
|
304
304
|
(rowData: any) => {
|
|
305
|
-
console.log(rowData);
|
|
306
305
|
const keyValue = dataRowKey as string;
|
|
307
306
|
const key = rowData[keyValue];
|
|
308
307
|
|
|
@@ -616,7 +615,6 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
616
615
|
key={tableKey + REFRESH_KEY}
|
|
617
616
|
tableKey={tableKey}
|
|
618
617
|
data={data}
|
|
619
|
-
refreshRow={REFRESH_KEY}
|
|
620
618
|
tableBodyRef={tableBodyRef as React.RefObject<HTMLDivElement>}
|
|
621
619
|
dataTheme={dataTheme}
|
|
622
620
|
wordWrap={wordWrap}
|
|
@@ -790,6 +788,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
790
788
|
</HeaderCell>
|
|
791
789
|
<ActionCell
|
|
792
790
|
tableBodyRef={tableBodyRef}
|
|
791
|
+
dropType={dropType}
|
|
793
792
|
actionProps={actionProps}
|
|
794
793
|
className={`${classes.cellClass} ${classes.actionCellClass}`}
|
|
795
794
|
handleMenuActions={handleMenuActions}
|