qbs-react-grid 1.2.2 → 1.2.4
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/less/qbs-table.less +89 -22
- package/es/qbsTable/QbsTable.js +7 -1
- package/es/qbsTable/Toolbar.js +9 -7
- package/es/qbsTable/commontypes.d.ts +3 -0
- package/es/qbsTable/utilities/CardComponent.d.ts +2 -0
- package/es/qbsTable/utilities/CardComponent.js +28 -9
- package/es/qbsTable/utilities/CardMenuDropdown.js +11 -7
- package/es/qbsTable/utilities/SwitchCardColumns.js +2 -2
- package/es/qbsTable/utilities/ToolTip.js +2 -5
- package/es/qbsTable/utilities/store.d.ts +2 -0
- package/es/qbsTable/utilities/store.js +60 -0
- package/lib/less/qbs-table.less +89 -22
- package/lib/qbsTable/QbsTable.js +7 -1
- package/lib/qbsTable/Toolbar.js +8 -6
- package/lib/qbsTable/commontypes.d.ts +3 -0
- package/lib/qbsTable/utilities/CardComponent.d.ts +2 -0
- package/lib/qbsTable/utilities/CardComponent.js +27 -8
- package/lib/qbsTable/utilities/CardMenuDropdown.js +12 -7
- package/lib/qbsTable/utilities/SwitchCardColumns.js +2 -2
- package/lib/qbsTable/utilities/ToolTip.js +2 -5
- package/lib/qbsTable/utilities/store.d.ts +2 -0
- package/lib/qbsTable/utilities/store.js +66 -0
- package/package.json +1 -1
- package/src/less/qbs-table.less +89 -22
- package/src/qbsTable/QbsTable.tsx +6 -2
- package/src/qbsTable/Toolbar.tsx +8 -7
- package/src/qbsTable/commontypes.ts +3 -0
- package/src/qbsTable/utilities/CardComponent.tsx +91 -61
- package/src/qbsTable/utilities/CardMenuDropdown.tsx +10 -8
- package/src/qbsTable/utilities/SwitchCardColumns.tsx +2 -2
- package/src/qbsTable/utilities/ToolTip.tsx +1 -4
- package/src/qbsTable/utilities/store.ts +61 -0
package/es/qbsTable/Toolbar.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
2
2
|
import debounce from './utilities/debounce';
|
|
3
|
+
import { CardIcon, TableIcon } from './utilities/icons';
|
|
3
4
|
import SearchInput from './utilities/SearchInput';
|
|
4
5
|
import { getRowDisplayRange } from './utilities/tablecalc';
|
|
5
6
|
import TooltipComponent from './utilities/ToolTip';
|
|
6
|
-
import { CardIcon, TableIcon } from './utilities/icons';
|
|
7
7
|
var ToolBar = function ToolBar(_ref) {
|
|
8
8
|
var _paginationProps$tota, _paginationProps$rows, _paginationProps$curr;
|
|
9
9
|
var pagination = _ref.pagination,
|
|
@@ -31,6 +31,7 @@ var ToolBar = function ToolBar(_ref) {
|
|
|
31
31
|
var _useState = useState(searchValue),
|
|
32
32
|
searchParam = _useState[0],
|
|
33
33
|
setSearchParam = _useState[1];
|
|
34
|
+
var toolbarRef = useRef(null);
|
|
34
35
|
var handleSearch = useCallback(function (e) {
|
|
35
36
|
if (debouncedOnSearch) {
|
|
36
37
|
debouncedOnSearch(e);
|
|
@@ -54,7 +55,8 @@ var ToolBar = function ToolBar(_ref) {
|
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
57
|
return /*#__PURE__*/React.createElement("div", {
|
|
57
|
-
className: "qbs-table-toolbar-container"
|
|
58
|
+
className: "qbs-table-toolbar-container",
|
|
59
|
+
ref: toolbarRef
|
|
58
60
|
}, /*#__PURE__*/React.createElement("div", {
|
|
59
61
|
className: "qbs-table-toolbar " + className
|
|
60
62
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -71,14 +73,14 @@ var ToolBar = function ToolBar(_ref) {
|
|
|
71
73
|
handleSearch: handleSearch,
|
|
72
74
|
searchValue: searchParam
|
|
73
75
|
}), primaryFilter)), /*#__PURE__*/React.createElement("div", {
|
|
74
|
-
className: "end-container"
|
|
76
|
+
className: "end-container flex items-center"
|
|
75
77
|
}, tableHeaderActions, /*#__PURE__*/React.createElement("div", {
|
|
76
|
-
className: " pr-1 cursor-pointer",
|
|
78
|
+
className: " pr-1 cursor-pointer relative",
|
|
77
79
|
onClick: function onClick() {
|
|
78
80
|
return setTableViewToggle === null || setTableViewToggle === void 0 ? void 0 : setTableViewToggle(!tableViewToggle);
|
|
79
81
|
}
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
+
}, enableTableToggle && /*#__PURE__*/React.createElement(TooltipComponent, {
|
|
83
|
+
tableBodyRef: toolbarRef,
|
|
82
84
|
title: tableViewToggle ? 'Switch to Card View' : 'Switch to Table View'
|
|
83
85
|
}, !tableViewToggle ? /*#__PURE__*/React.createElement(CardIcon, null) : /*#__PURE__*/React.createElement(TableIcon, null))))), advancefilter && /*#__PURE__*/React.createElement("div", {
|
|
84
86
|
className: "sub-qbs-table-toolbar"
|
|
@@ -8,6 +8,7 @@ export interface ColumnBase {
|
|
|
8
8
|
field: string;
|
|
9
9
|
sortable?: boolean;
|
|
10
10
|
resizable?: boolean;
|
|
11
|
+
colSpan?: number;
|
|
11
12
|
fixed?: boolean;
|
|
12
13
|
align?: 'left' | 'right' | 'center';
|
|
13
14
|
colWidth?: number;
|
|
@@ -121,6 +122,8 @@ export interface QbsTableProps {
|
|
|
121
122
|
emptyTitle?: string;
|
|
122
123
|
enableTableToggle?: boolean;
|
|
123
124
|
tableView?: boolean;
|
|
125
|
+
cardColumLimit?: number;
|
|
126
|
+
childDetailHeading?: string;
|
|
124
127
|
}
|
|
125
128
|
export interface QbsTableToolbarProps {
|
|
126
129
|
title?: string;
|
|
@@ -1,33 +1,44 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
2
|
import CardMenuDropdown from './CardMenuDropdown';
|
|
3
3
|
import { CustomTableCell } from './SwitchCardColumns';
|
|
4
4
|
import { handleCellFormat } from './handleFormatCell';
|
|
5
5
|
import { ArrowUpIcon } from './icons';
|
|
6
|
+
import { getGridColsClass, getGridColSpanClass } from './store';
|
|
7
|
+
import TooltipComponent from './ToolTip';
|
|
6
8
|
var CardComponent = function CardComponent(_ref) {
|
|
7
9
|
var columns = _ref.columns,
|
|
8
10
|
data = _ref.data,
|
|
9
11
|
tableBodyRef = _ref.tableBodyRef,
|
|
10
12
|
actionProps = _ref.actionProps,
|
|
11
13
|
index = _ref.index,
|
|
12
|
-
|
|
14
|
+
_ref$cardColumLimit = _ref.cardColumLimit,
|
|
15
|
+
cardColumLimit = _ref$cardColumLimit === void 0 ? 5 : _ref$cardColumLimit,
|
|
16
|
+
handleMenuActions = _ref.handleMenuActions,
|
|
17
|
+
_ref$childDetailHeadi = _ref.childDetailHeading,
|
|
18
|
+
childDetailHeading = _ref$childDetailHeadi === void 0 ? '' : _ref$childDetailHeadi;
|
|
13
19
|
var _useState = useState(false),
|
|
14
20
|
viewMore = _useState[0],
|
|
15
21
|
setViewMore = _useState[1];
|
|
16
|
-
var initialDisplayCount =
|
|
22
|
+
var initialDisplayCount = cardColumLimit;
|
|
17
23
|
var toggleViewMore = function toggleViewMore() {
|
|
18
24
|
setViewMore(!viewMore);
|
|
19
25
|
};
|
|
26
|
+
var useCardRef = useRef(null);
|
|
20
27
|
var displayedColumns = viewMore ? columns : columns.slice(0, initialDisplayCount);
|
|
21
28
|
return /*#__PURE__*/React.createElement("div", {
|
|
22
|
-
|
|
29
|
+
ref: useCardRef,
|
|
30
|
+
className: "p-3 gap-3 border-2 border-grey shadow-sm rounded-lg relative qbs-card-container"
|
|
31
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
className: "grid " + getGridColsClass(initialDisplayCount) + " qbs-card-columns"
|
|
23
33
|
}, displayedColumns.map(function (col, index) {
|
|
34
|
+
var _col$colSpan;
|
|
24
35
|
return /*#__PURE__*/React.createElement("div", {
|
|
25
36
|
key: index,
|
|
26
|
-
className: "grid col
|
|
37
|
+
className: "grid " + getGridColSpanClass((_col$colSpan = col.colSpan) != null ? _col$colSpan : 1) + " place-content-start text-sm qbs-card-column " + (index === initialDisplayCount - 1 ? 'mr-4' : '') + " "
|
|
27
38
|
}, /*#__PURE__*/React.createElement("p", {
|
|
28
39
|
className: " text-grey "
|
|
29
40
|
}, col.title), col.customCell || col.link ? /*#__PURE__*/React.createElement("span", {
|
|
30
|
-
className: "qbs-card-column-content mt-1
|
|
41
|
+
className: "qbs-card-column-content mt-1 " + (!viewMore ? 'line-clamp-1' : '')
|
|
31
42
|
}, /*#__PURE__*/React.createElement(CustomTableCell, {
|
|
32
43
|
dataKey: col.field,
|
|
33
44
|
rowData: data,
|
|
@@ -38,7 +49,7 @@ var CardComponent = function CardComponent(_ref) {
|
|
|
38
49
|
rowClick: col.rowClick,
|
|
39
50
|
renderCell: col.renderCell
|
|
40
51
|
})) : /*#__PURE__*/React.createElement("p", {
|
|
41
|
-
className: "mt-1
|
|
52
|
+
className: "mt-1 qbs-card-column-content " + (!viewMore ? 'line-clamp-1' : ''),
|
|
42
53
|
key: index
|
|
43
54
|
}, handleCellFormat(data[col.field], col.type)));
|
|
44
55
|
}), /*#__PURE__*/React.createElement("div", {
|
|
@@ -54,11 +65,19 @@ var CardComponent = function CardComponent(_ref) {
|
|
|
54
65
|
iconName: "more",
|
|
55
66
|
rowIndex: index,
|
|
56
67
|
handleMenuActions: handleMenuActions
|
|
57
|
-
})), columns.length > initialDisplayCount && /*#__PURE__*/React.createElement(
|
|
68
|
+
})), columns.length > initialDisplayCount && /*#__PURE__*/React.createElement(TooltipComponent, {
|
|
69
|
+
tableBodyRef: useCardRef,
|
|
70
|
+
title: viewMore ? ' View Less' : 'View More',
|
|
71
|
+
enabled: false
|
|
72
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
58
73
|
onClick: toggleViewMore,
|
|
59
74
|
className: " qbs-card-column-action-menu-view-more justify-end text-blue-500 text-xs"
|
|
60
75
|
}, /*#__PURE__*/React.createElement(ArrowUpIcon, {
|
|
61
76
|
className: (viewMore ? 'rotate-180' : '') + " "
|
|
62
|
-
})))))
|
|
77
|
+
})))))), viewMore && (data === null || data === void 0 ? void 0 : data.childDetail) && /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: "mt-4 p-3 border-t border-grey qbs-card-child-detail-container"
|
|
79
|
+
}, childDetailHeading && /*#__PURE__*/React.createElement("p", {
|
|
80
|
+
className: " text-lg qbs-card-child-detail-head font-semibold "
|
|
81
|
+
}, childDetailHeading), data === null || data === void 0 ? void 0 : data.childDetail));
|
|
63
82
|
};
|
|
64
83
|
export default CardComponent;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ThreeDotIcon } from './icons';
|
|
4
|
+
import TooltipComponent from './ToolTip';
|
|
4
5
|
var CardMenuDropdown = function CardMenuDropdown(_ref) {
|
|
5
6
|
var actionDropDown = _ref.actionDropDown,
|
|
6
7
|
handleMenuActions = _ref.handleMenuActions,
|
|
@@ -56,7 +57,6 @@ var CardMenuDropdown = function CardMenuDropdown(_ref) {
|
|
|
56
57
|
handleMenuActions === null || handleMenuActions === void 0 ? void 0 : handleMenuActions(item, rowData);
|
|
57
58
|
handleClose();
|
|
58
59
|
};
|
|
59
|
-
console.log(menuPositionStyles);
|
|
60
60
|
return /*#__PURE__*/React.createElement("div", {
|
|
61
61
|
className: "dropdown text-black dark:text-white dark:bg-[#424242] bg-white",
|
|
62
62
|
ref: menuRef
|
|
@@ -64,25 +64,29 @@ var CardMenuDropdown = function CardMenuDropdown(_ref) {
|
|
|
64
64
|
className: "dropdown-toggle",
|
|
65
65
|
onClick: toggleMenu,
|
|
66
66
|
ref: menuButtonRef
|
|
67
|
-
}, /*#__PURE__*/React.createElement(
|
|
68
|
-
|
|
67
|
+
}, /*#__PURE__*/React.createElement(TooltipComponent, {
|
|
68
|
+
title: "Actions",
|
|
69
|
+
enabled: false,
|
|
70
|
+
ref: menuButtonRef
|
|
71
|
+
}, /*#__PURE__*/React.createElement(ThreeDotIcon, null))), openMenu && /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
className: " qbs-card-dropdown rounded absolute right-0 mt-2 w-auto min-w-11 z-10 shadow-modalShadow bg-white dark:bg-[#424242] dark:text-white",
|
|
69
73
|
style: menuPositionStyles
|
|
70
74
|
}, /*#__PURE__*/React.createElement("div", {
|
|
71
|
-
className: "qbs-card-dropdown-menu px-2 bg-white rounded w-full border border-grey-border shadow-menudropdown dark:bg-[#424242] dark:text-white"
|
|
75
|
+
className: "qbs-card-dropdown-menu px-2 bg-white rounded w-full border border-grey-border shadow-lg shadow-menudropdown dark:bg-[#424242] dark:text-white"
|
|
72
76
|
}, actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.map(function (item) {
|
|
73
77
|
return !item.hidden && /*#__PURE__*/React.createElement("a", {
|
|
74
78
|
key: item.title,
|
|
75
79
|
href: "#/",
|
|
76
|
-
className: 'px-
|
|
80
|
+
className: 'px-1 hover:bg-background no-underline whitespace-nowrap ',
|
|
77
81
|
onClick: function onClick(e) {
|
|
78
82
|
e.preventDefault();
|
|
79
83
|
e.stopPropagation();
|
|
80
84
|
handleMenuItemClick(item);
|
|
81
85
|
}
|
|
82
86
|
}, /*#__PURE__*/React.createElement("div", {
|
|
83
|
-
className: " qbs-card-dropdown-menu-item " + (item.isWarning ? 'text-error-light' : 'text-black
|
|
87
|
+
className: " qbs-card-dropdown-menu-item no-underline " + (item.isWarning ? 'text-error-light' : ' text-black/70 dark:text-white') + " text-xxs flex items-center w-full tracking-[0.24px] font-medium "
|
|
84
88
|
}, (item === null || item === void 0 ? void 0 : item.icon) && /*#__PURE__*/React.createElement(React.Fragment, null, item.icon), /*#__PURE__*/React.createElement("span", {
|
|
85
|
-
className: "pl-1.5"
|
|
89
|
+
className: "pl-1.5 no-underline text-sm "
|
|
86
90
|
}, item.title)));
|
|
87
91
|
}))));
|
|
88
92
|
};
|
|
@@ -16,9 +16,9 @@ export var CustomTableCell = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
16
16
|
onClick: function onClick() {
|
|
17
17
|
return rowClick === null || rowClick === void 0 ? void 0 : rowClick(rowData);
|
|
18
18
|
},
|
|
19
|
-
className: "qbs-table-row-link " + (!viewMore ? 'line-clamp-1' : '')
|
|
19
|
+
className: "qbs-table-row-link no-underline " + (!viewMore ? 'line-clamp-1' : '')
|
|
20
20
|
}, renderCell ? (_renderCell = renderCell(rowData)) === null || _renderCell === void 0 ? void 0 : _renderCell.cell : handleCellFormat(rowData[dataKey], type)) : path && !(hideLink !== null && hideLink !== void 0 && hideLink(rowData)) ? /*#__PURE__*/React.createElement(Link, {
|
|
21
21
|
to: (_path = path === null || path === void 0 ? void 0 : path(rowData)) != null ? _path : '',
|
|
22
|
-
className: "qbs-table-row-link " + (!viewMore ? 'line-clamp-1' : '')
|
|
22
|
+
className: "qbs-table-row-link no-underline " + (!viewMore ? 'line-clamp-1' : '')
|
|
23
23
|
}, renderCell ? (_renderCell2 = renderCell(rowData)) === null || _renderCell2 === void 0 ? void 0 : _renderCell2.cell : handleCellFormat(rowData[dataKey], type)) : /*#__PURE__*/React.createElement(React.Fragment, null, renderCell ? (_renderCell3 = renderCell(rowData)) === null || _renderCell3 === void 0 ? void 0 : _renderCell3.cell : handleCellFormat(rowData[dataKey], type)));
|
|
24
24
|
});
|
|
@@ -10,15 +10,12 @@ var TooltipComponent = function TooltipComponent(_ref) {
|
|
|
10
10
|
var menuButtonRef = useRef(null);
|
|
11
11
|
var adjustDropdownPosition = function adjustDropdownPosition() {
|
|
12
12
|
if (menuButtonRef.current && tableBodyRef !== null && tableBodyRef !== void 0 && tableBodyRef.current) {
|
|
13
|
-
var _menuButtonRef$curren
|
|
13
|
+
var _menuButtonRef$curren;
|
|
14
14
|
var inputBoxRect = (_menuButtonRef$curren = menuButtonRef.current) === null || _menuButtonRef$curren === void 0 ? void 0 : _menuButtonRef$curren.getBoundingClientRect();
|
|
15
|
-
var viewportHeight = (_tableBodyRef$current = tableBodyRef === null || tableBodyRef === void 0 ? void 0 : (_tableBodyRef$current2 = tableBodyRef.current) === null || _tableBodyRef$current2 === void 0 ? void 0 : _tableBodyRef$current2.offsetHeight) != null ? _tableBodyRef$current : window.innerHeight;
|
|
16
15
|
var tableRect = tableBodyRef.current.getBoundingClientRect();
|
|
17
|
-
|
|
18
16
|
// Calculate positions relative to the table
|
|
19
17
|
var spaceAbove = inputBoxRect.top - tableRect.top;
|
|
20
18
|
var spaceBelow = tableRect.bottom - inputBoxRect.bottom;
|
|
21
|
-
console.log(viewportHeight, spaceAbove, spaceBelow);
|
|
22
19
|
if (spaceAbove > spaceBelow) {
|
|
23
20
|
setDropdownPosition('top-position');
|
|
24
21
|
} else {
|
|
@@ -38,7 +35,7 @@ var TooltipComponent = function TooltipComponent(_ref) {
|
|
|
38
35
|
}
|
|
39
36
|
}, children), /*#__PURE__*/React.createElement("span", {
|
|
40
37
|
ref: dropRef,
|
|
41
|
-
className:
|
|
38
|
+
className: 'tooltiptext'
|
|
42
39
|
}, title));
|
|
43
40
|
};
|
|
44
41
|
export default TooltipComponent;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const getGridColsClass: (count: number) => "grid-cols-1" | "grid-cols-2" | "grid-cols-3" | "grid-cols-4" | "grid-cols-5" | "grid-cols-6" | "grid-cols-7" | "grid-cols-8" | "grid-cols-9" | "grid-cols-10" | "grid-cols-11" | "grid-cols-12";
|
|
2
|
+
export declare const getGridColSpanClass: (count: number) => "col-span-1" | "col-span-2" | "col-span-3" | "col-span-4" | "col-span-5" | "col-span--6" | "col-span--7" | "col-span--8" | "col-span--9" | "col-span--10" | "col-span--11" | "col-span--12" | "col-span--1";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export var getGridColsClass = function getGridColsClass(count) {
|
|
2
|
+
switch (count) {
|
|
3
|
+
case 1:
|
|
4
|
+
return 'grid-cols-1';
|
|
5
|
+
case 2:
|
|
6
|
+
return 'grid-cols-2';
|
|
7
|
+
case 3:
|
|
8
|
+
return 'grid-cols-3';
|
|
9
|
+
case 4:
|
|
10
|
+
return 'grid-cols-4';
|
|
11
|
+
case 5:
|
|
12
|
+
return 'grid-cols-5';
|
|
13
|
+
case 6:
|
|
14
|
+
return 'grid-cols-6';
|
|
15
|
+
case 7:
|
|
16
|
+
return 'grid-cols-7';
|
|
17
|
+
case 8:
|
|
18
|
+
return 'grid-cols-8';
|
|
19
|
+
case 9:
|
|
20
|
+
return 'grid-cols-9';
|
|
21
|
+
case 10:
|
|
22
|
+
return 'grid-cols-10';
|
|
23
|
+
case 11:
|
|
24
|
+
return 'grid-cols-11';
|
|
25
|
+
case 12:
|
|
26
|
+
return 'grid-cols-12';
|
|
27
|
+
default:
|
|
28
|
+
return 'grid-cols-1';
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export var getGridColSpanClass = function getGridColSpanClass(count) {
|
|
32
|
+
switch (count) {
|
|
33
|
+
case 1:
|
|
34
|
+
return 'col-span-1';
|
|
35
|
+
case 2:
|
|
36
|
+
return 'col-span-2';
|
|
37
|
+
case 3:
|
|
38
|
+
return 'col-span-3';
|
|
39
|
+
case 4:
|
|
40
|
+
return 'col-span-4';
|
|
41
|
+
case 5:
|
|
42
|
+
return 'col-span-5';
|
|
43
|
+
case 6:
|
|
44
|
+
return 'col-span--6';
|
|
45
|
+
case 7:
|
|
46
|
+
return 'col-span--7';
|
|
47
|
+
case 8:
|
|
48
|
+
return 'col-span--8';
|
|
49
|
+
case 9:
|
|
50
|
+
return 'col-span--9';
|
|
51
|
+
case 10:
|
|
52
|
+
return 'col-span--10';
|
|
53
|
+
case 11:
|
|
54
|
+
return 'col-span--11';
|
|
55
|
+
case 12:
|
|
56
|
+
return 'col-span--12';
|
|
57
|
+
default:
|
|
58
|
+
return 'col-span--1';
|
|
59
|
+
}
|
|
60
|
+
};
|
package/lib/less/qbs-table.less
CHANGED
|
@@ -180,16 +180,77 @@
|
|
|
180
180
|
transition: all 0.2s ease;
|
|
181
181
|
}
|
|
182
182
|
/* Tooltip container */
|
|
183
|
+
// .qbs-table-tooltip {
|
|
184
|
+
// position: relative;
|
|
185
|
+
// display: contents;
|
|
186
|
+
// cursor: pointer;
|
|
187
|
+
// }
|
|
188
|
+
|
|
189
|
+
// .qbs-table-tooltip .tooltiptext {
|
|
190
|
+
// visibility: hidden;
|
|
191
|
+
// background-color: #000;
|
|
192
|
+
// color: #fff;
|
|
193
|
+
// text-align: center;
|
|
194
|
+
// padding: 6px;
|
|
195
|
+
// border-radius: 4px;
|
|
196
|
+
// position: absolute;
|
|
197
|
+
// z-index: 9999;
|
|
198
|
+
// opacity: 0;
|
|
199
|
+
// transition: opacity 0.3s;
|
|
200
|
+
// font-size: 12px;
|
|
201
|
+
// font-style: normal;
|
|
202
|
+
// font-weight: 400;
|
|
203
|
+
// line-height: 16px;
|
|
204
|
+
// width: 100px;
|
|
205
|
+
// }
|
|
206
|
+
|
|
207
|
+
// .qbs-table-tooltip.up .tooltiptext {
|
|
208
|
+
// bottom: 125%;
|
|
209
|
+
// left: 0%;
|
|
210
|
+
// }
|
|
211
|
+
|
|
212
|
+
// .qbs-table-tooltip.down .tooltiptext {
|
|
213
|
+
// top: 125%;
|
|
214
|
+
// right: 0px;
|
|
215
|
+
// left: auto;
|
|
216
|
+
// }
|
|
217
|
+
|
|
218
|
+
// .qbs-table-tooltip:hover .tooltiptext {
|
|
219
|
+
// visibility: visible;
|
|
220
|
+
// opacity: 1;
|
|
221
|
+
// }
|
|
222
|
+
|
|
223
|
+
// .qbs-table-tooltip .tooltiptext::after {
|
|
224
|
+
// content: '';
|
|
225
|
+
// position: absolute;
|
|
226
|
+
// border-width: 5px;
|
|
227
|
+
// border-style: solid;
|
|
228
|
+
// }
|
|
229
|
+
|
|
230
|
+
// .qbs-table-tooltip.up .tooltiptext::after {
|
|
231
|
+
// top: 100%;
|
|
232
|
+
// left: 50%;
|
|
233
|
+
// margin-left: -5px;
|
|
234
|
+
// border-color: #000 transparent transparent transparent;
|
|
235
|
+
// }
|
|
236
|
+
|
|
237
|
+
// .qbs-table-tooltip.down .tooltiptext::after {
|
|
238
|
+
// bottom: 100%;
|
|
239
|
+
// left: 50%;
|
|
240
|
+
// margin-left: -5px;
|
|
241
|
+
// border-color: transparent transparent #000 transparent;
|
|
242
|
+
// }
|
|
183
243
|
.qbs-table-tooltip {
|
|
184
|
-
position: relative;
|
|
185
|
-
display: contents;
|
|
186
244
|
cursor: pointer;
|
|
245
|
+
position: relative;
|
|
246
|
+
width: auto;
|
|
247
|
+
display: flex;
|
|
187
248
|
}
|
|
188
249
|
|
|
189
250
|
.qbs-table-tooltip .tooltiptext {
|
|
190
251
|
visibility: hidden;
|
|
191
|
-
background-color:
|
|
192
|
-
color:
|
|
252
|
+
background-color: black;
|
|
253
|
+
color: white;
|
|
193
254
|
text-align: center;
|
|
194
255
|
padding: 6px;
|
|
195
256
|
border-radius: 4px;
|
|
@@ -205,20 +266,20 @@
|
|
|
205
266
|
}
|
|
206
267
|
|
|
207
268
|
.qbs-table-tooltip.up .tooltiptext {
|
|
208
|
-
bottom:
|
|
209
|
-
|
|
269
|
+
bottom: calc(100% + 10px);
|
|
270
|
+
right: -8px;
|
|
271
|
+
left: unset;
|
|
210
272
|
}
|
|
211
273
|
|
|
212
274
|
.qbs-table-tooltip.down .tooltiptext {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
left: auto;
|
|
275
|
+
right: -10px;
|
|
276
|
+
top: calc(100% + 8px);
|
|
216
277
|
}
|
|
217
278
|
|
|
218
|
-
.qbs-table-tooltip:hover .tooltiptext {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
279
|
+
// .qbs-table-tooltip:hover .tooltiptext {
|
|
280
|
+
// visibility: visible;
|
|
281
|
+
// opacity: 1;
|
|
282
|
+
// }
|
|
222
283
|
|
|
223
284
|
.qbs-table-tooltip .tooltiptext::after {
|
|
224
285
|
content: '';
|
|
@@ -228,19 +289,25 @@
|
|
|
228
289
|
}
|
|
229
290
|
|
|
230
291
|
.qbs-table-tooltip.up .tooltiptext::after {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
margin-left: -5px;
|
|
234
|
-
|
|
292
|
+
border-color: black transparent transparent !important;
|
|
293
|
+
right: 12px !important;
|
|
294
|
+
margin-left: -5px !important;
|
|
295
|
+
top: 100% !important;
|
|
296
|
+
left: unset !important;
|
|
235
297
|
}
|
|
236
298
|
|
|
237
299
|
.qbs-table-tooltip.down .tooltiptext::after {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
300
|
+
border-color: transparent transparent black;
|
|
301
|
+
bottom: 100% !important;
|
|
302
|
+
right: 12px !important;
|
|
303
|
+
margin-left: -5px !important;
|
|
304
|
+
left: unset !important;
|
|
305
|
+
}
|
|
306
|
+
.qbs-table-tooltip.down .tooltiptext {
|
|
307
|
+
top: 145% !important;
|
|
308
|
+
right: -10px !important;
|
|
309
|
+
left: auto !important;
|
|
242
310
|
}
|
|
243
|
-
|
|
244
311
|
.rs-table-row {
|
|
245
312
|
overflow: visible !important;
|
|
246
313
|
}
|
package/lib/qbsTable/QbsTable.js
CHANGED
|
@@ -102,7 +102,11 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
102
102
|
_ref$tableView = _ref.tableView,
|
|
103
103
|
tableView = _ref$tableView === void 0 ? true : _ref$tableView,
|
|
104
104
|
_ref$enableTableToggl = _ref.enableTableToggle,
|
|
105
|
-
enableTableToggle = _ref$enableTableToggl === void 0 ? false : _ref$enableTableToggl
|
|
105
|
+
enableTableToggle = _ref$enableTableToggl === void 0 ? false : _ref$enableTableToggl,
|
|
106
|
+
_ref$cardColumLimit = _ref.cardColumLimit,
|
|
107
|
+
cardColumLimit = _ref$cardColumLimit === void 0 ? 5 : _ref$cardColumLimit,
|
|
108
|
+
_ref$childDetailHeadi = _ref.childDetailHeading,
|
|
109
|
+
childDetailHeading = _ref$childDetailHeadi === void 0 ? '' : _ref$childDetailHeadi;
|
|
106
110
|
var _useState = (0, _react.useState)(false),
|
|
107
111
|
loading = _useState[0],
|
|
108
112
|
setLoading = _useState[1];
|
|
@@ -582,6 +586,8 @@ var QbsTable = function QbsTable(_ref) {
|
|
|
582
586
|
key: items === null || items === void 0 ? void 0 : items.id
|
|
583
587
|
}, /*#__PURE__*/_react["default"].createElement(_CardComponent["default"], {
|
|
584
588
|
data: items,
|
|
589
|
+
cardColumLimit: cardColumLimit,
|
|
590
|
+
childDetailHeading: childDetailHeading,
|
|
585
591
|
columns: columns,
|
|
586
592
|
tableBodyRef: tableBodyRef,
|
|
587
593
|
actionProps: actionProps
|
package/lib/qbsTable/Toolbar.js
CHANGED
|
@@ -5,10 +5,10 @@ exports.__esModule = true;
|
|
|
5
5
|
exports["default"] = void 0;
|
|
6
6
|
var _react = _interopRequireWildcard(require("react"));
|
|
7
7
|
var _debounce = _interopRequireDefault(require("./utilities/debounce"));
|
|
8
|
+
var _icons = require("./utilities/icons");
|
|
8
9
|
var _SearchInput = _interopRequireDefault(require("./utilities/SearchInput"));
|
|
9
10
|
var _tablecalc = require("./utilities/tablecalc");
|
|
10
11
|
var _ToolTip = _interopRequireDefault(require("./utilities/ToolTip"));
|
|
11
|
-
var _icons = require("./utilities/icons");
|
|
12
12
|
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); }
|
|
13
13
|
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; }
|
|
14
14
|
var ToolBar = function ToolBar(_ref) {
|
|
@@ -38,6 +38,7 @@ var ToolBar = function ToolBar(_ref) {
|
|
|
38
38
|
var _useState = (0, _react.useState)(searchValue),
|
|
39
39
|
searchParam = _useState[0],
|
|
40
40
|
setSearchParam = _useState[1];
|
|
41
|
+
var toolbarRef = (0, _react.useRef)(null);
|
|
41
42
|
var handleSearch = (0, _react.useCallback)(function (e) {
|
|
42
43
|
if (debouncedOnSearch) {
|
|
43
44
|
debouncedOnSearch(e);
|
|
@@ -61,7 +62,8 @@ var ToolBar = function ToolBar(_ref) {
|
|
|
61
62
|
}
|
|
62
63
|
};
|
|
63
64
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
64
|
-
className: "qbs-table-toolbar-container"
|
|
65
|
+
className: "qbs-table-toolbar-container",
|
|
66
|
+
ref: toolbarRef
|
|
65
67
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
66
68
|
className: "qbs-table-toolbar " + className
|
|
67
69
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -78,14 +80,14 @@ var ToolBar = function ToolBar(_ref) {
|
|
|
78
80
|
handleSearch: handleSearch,
|
|
79
81
|
searchValue: searchParam
|
|
80
82
|
}), primaryFilter)), /*#__PURE__*/_react["default"].createElement("div", {
|
|
81
|
-
className: "end-container"
|
|
83
|
+
className: "end-container flex items-center"
|
|
82
84
|
}, tableHeaderActions, /*#__PURE__*/_react["default"].createElement("div", {
|
|
83
|
-
className: " pr-1 cursor-pointer",
|
|
85
|
+
className: " pr-1 cursor-pointer relative",
|
|
84
86
|
onClick: function onClick() {
|
|
85
87
|
return setTableViewToggle === null || setTableViewToggle === void 0 ? void 0 : setTableViewToggle(!tableViewToggle);
|
|
86
88
|
}
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
+
}, enableTableToggle && /*#__PURE__*/_react["default"].createElement(_ToolTip["default"], {
|
|
90
|
+
tableBodyRef: toolbarRef,
|
|
89
91
|
title: tableViewToggle ? 'Switch to Card View' : 'Switch to Table View'
|
|
90
92
|
}, !tableViewToggle ? /*#__PURE__*/_react["default"].createElement(_icons.CardIcon, null) : /*#__PURE__*/_react["default"].createElement(_icons.TableIcon, null))))), advancefilter && /*#__PURE__*/_react["default"].createElement("div", {
|
|
91
93
|
className: "sub-qbs-table-toolbar"
|
|
@@ -8,6 +8,7 @@ export interface ColumnBase {
|
|
|
8
8
|
field: string;
|
|
9
9
|
sortable?: boolean;
|
|
10
10
|
resizable?: boolean;
|
|
11
|
+
colSpan?: number;
|
|
11
12
|
fixed?: boolean;
|
|
12
13
|
align?: 'left' | 'right' | 'center';
|
|
13
14
|
colWidth?: number;
|
|
@@ -121,6 +122,8 @@ export interface QbsTableProps {
|
|
|
121
122
|
emptyTitle?: string;
|
|
122
123
|
enableTableToggle?: boolean;
|
|
123
124
|
tableView?: boolean;
|
|
125
|
+
cardColumLimit?: number;
|
|
126
|
+
childDetailHeading?: string;
|
|
124
127
|
}
|
|
125
128
|
export interface QbsTableToolbarProps {
|
|
126
129
|
title?: string;
|
|
@@ -8,6 +8,8 @@ var _CardMenuDropdown = _interopRequireDefault(require("./CardMenuDropdown"));
|
|
|
8
8
|
var _SwitchCardColumns = require("./SwitchCardColumns");
|
|
9
9
|
var _handleFormatCell = require("./handleFormatCell");
|
|
10
10
|
var _icons = require("./icons");
|
|
11
|
+
var _store = require("./store");
|
|
12
|
+
var _ToolTip = _interopRequireDefault(require("./ToolTip"));
|
|
11
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); }
|
|
12
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; }
|
|
13
15
|
var CardComponent = function CardComponent(_ref) {
|
|
@@ -16,25 +18,34 @@ var CardComponent = function CardComponent(_ref) {
|
|
|
16
18
|
tableBodyRef = _ref.tableBodyRef,
|
|
17
19
|
actionProps = _ref.actionProps,
|
|
18
20
|
index = _ref.index,
|
|
19
|
-
|
|
21
|
+
_ref$cardColumLimit = _ref.cardColumLimit,
|
|
22
|
+
cardColumLimit = _ref$cardColumLimit === void 0 ? 5 : _ref$cardColumLimit,
|
|
23
|
+
handleMenuActions = _ref.handleMenuActions,
|
|
24
|
+
_ref$childDetailHeadi = _ref.childDetailHeading,
|
|
25
|
+
childDetailHeading = _ref$childDetailHeadi === void 0 ? '' : _ref$childDetailHeadi;
|
|
20
26
|
var _useState = (0, _react.useState)(false),
|
|
21
27
|
viewMore = _useState[0],
|
|
22
28
|
setViewMore = _useState[1];
|
|
23
|
-
var initialDisplayCount =
|
|
29
|
+
var initialDisplayCount = cardColumLimit;
|
|
24
30
|
var toggleViewMore = function toggleViewMore() {
|
|
25
31
|
setViewMore(!viewMore);
|
|
26
32
|
};
|
|
33
|
+
var useCardRef = (0, _react.useRef)(null);
|
|
27
34
|
var displayedColumns = viewMore ? columns : columns.slice(0, initialDisplayCount);
|
|
28
35
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
29
|
-
|
|
36
|
+
ref: useCardRef,
|
|
37
|
+
className: "p-3 gap-3 border-2 border-grey shadow-sm rounded-lg relative qbs-card-container"
|
|
38
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
39
|
+
className: "grid " + (0, _store.getGridColsClass)(initialDisplayCount) + " qbs-card-columns"
|
|
30
40
|
}, displayedColumns.map(function (col, index) {
|
|
41
|
+
var _col$colSpan;
|
|
31
42
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
32
43
|
key: index,
|
|
33
|
-
className: "grid col
|
|
44
|
+
className: "grid " + (0, _store.getGridColSpanClass)((_col$colSpan = col.colSpan) != null ? _col$colSpan : 1) + " place-content-start text-sm qbs-card-column " + (index === initialDisplayCount - 1 ? 'mr-4' : '') + " "
|
|
34
45
|
}, /*#__PURE__*/_react["default"].createElement("p", {
|
|
35
46
|
className: " text-grey "
|
|
36
47
|
}, col.title), col.customCell || col.link ? /*#__PURE__*/_react["default"].createElement("span", {
|
|
37
|
-
className: "qbs-card-column-content mt-1
|
|
48
|
+
className: "qbs-card-column-content mt-1 " + (!viewMore ? 'line-clamp-1' : '')
|
|
38
49
|
}, /*#__PURE__*/_react["default"].createElement(_SwitchCardColumns.CustomTableCell, {
|
|
39
50
|
dataKey: col.field,
|
|
40
51
|
rowData: data,
|
|
@@ -45,7 +56,7 @@ var CardComponent = function CardComponent(_ref) {
|
|
|
45
56
|
rowClick: col.rowClick,
|
|
46
57
|
renderCell: col.renderCell
|
|
47
58
|
})) : /*#__PURE__*/_react["default"].createElement("p", {
|
|
48
|
-
className: "mt-1
|
|
59
|
+
className: "mt-1 qbs-card-column-content " + (!viewMore ? 'line-clamp-1' : ''),
|
|
49
60
|
key: index
|
|
50
61
|
}, (0, _handleFormatCell.handleCellFormat)(data[col.field], col.type)));
|
|
51
62
|
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -61,12 +72,20 @@ var CardComponent = function CardComponent(_ref) {
|
|
|
61
72
|
iconName: "more",
|
|
62
73
|
rowIndex: index,
|
|
63
74
|
handleMenuActions: handleMenuActions
|
|
64
|
-
})), columns.length > initialDisplayCount && /*#__PURE__*/_react["default"].createElement("
|
|
75
|
+
})), columns.length > initialDisplayCount && /*#__PURE__*/_react["default"].createElement(_ToolTip["default"], {
|
|
76
|
+
tableBodyRef: useCardRef,
|
|
77
|
+
title: viewMore ? ' View Less' : 'View More',
|
|
78
|
+
enabled: false
|
|
79
|
+
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
65
80
|
onClick: toggleViewMore,
|
|
66
81
|
className: " qbs-card-column-action-menu-view-more justify-end text-blue-500 text-xs"
|
|
67
82
|
}, /*#__PURE__*/_react["default"].createElement(_icons.ArrowUpIcon, {
|
|
68
83
|
className: (viewMore ? 'rotate-180' : '') + " "
|
|
69
|
-
})))))
|
|
84
|
+
})))))), viewMore && (data === null || data === void 0 ? void 0 : data.childDetail) && /*#__PURE__*/_react["default"].createElement("div", {
|
|
85
|
+
className: "mt-4 p-3 border-t border-grey qbs-card-child-detail-container"
|
|
86
|
+
}, childDetailHeading && /*#__PURE__*/_react["default"].createElement("p", {
|
|
87
|
+
className: " text-lg qbs-card-child-detail-head font-semibold "
|
|
88
|
+
}, childDetailHeading), data === null || data === void 0 ? void 0 : data.childDetail));
|
|
70
89
|
};
|
|
71
90
|
var _default = CardComponent;
|
|
72
91
|
exports["default"] = _default;
|