qbs-react-grid 1.2.1 → 1.2.3
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 -1095
- package/dist/css/qbs-react-grid.min.css +1 -1
- package/dist/css/qbs-react-grid.min.css.map +1 -1
- package/es/Table.js +19 -19
- package/es/less/index.less +3 -0
- package/es/less/qbs-table.less +89 -22
- package/es/qbsTable/QbsTable.js +40 -7
- package/es/qbsTable/TableCardList.d.ts +5 -0
- package/es/qbsTable/TableCardList.js +564 -0
- package/es/qbsTable/Toolbar.js +21 -5
- package/es/qbsTable/commontypes.d.ts +12 -0
- package/es/qbsTable/utilities/CardComponent.d.ts +14 -0
- package/es/qbsTable/utilities/CardComponent.js +83 -0
- package/es/qbsTable/utilities/CardMenuDropdown.d.ts +13 -0
- package/es/qbsTable/utilities/CardMenuDropdown.js +93 -0
- package/es/qbsTable/utilities/SwitchCardColumns.d.ts +2 -0
- package/es/qbsTable/utilities/SwitchCardColumns.js +24 -0
- package/es/qbsTable/utilities/ToolTip.js +2 -5
- package/es/qbsTable/utilities/icons.d.ts +3 -0
- package/es/qbsTable/utilities/icons.js +45 -0
- package/es/qbsTable/utilities/store.d.ts +2 -0
- package/es/qbsTable/utilities/store.js +60 -0
- package/es/utils/getTotalByColumns.js +1 -1
- package/es/utils/mergeCells.js +1 -1
- package/es/utils/useCellDescriptor.js +11 -11
- package/es/utils/useClassNames.js +2 -0
- package/lib/Table.js +19 -19
- package/lib/less/index.less +3 -0
- package/lib/less/qbs-table.less +89 -22
- package/lib/qbsTable/QbsTable.js +40 -7
- package/lib/qbsTable/TableCardList.d.ts +5 -0
- package/lib/qbsTable/TableCardList.js +571 -0
- package/lib/qbsTable/Toolbar.js +20 -4
- package/lib/qbsTable/commontypes.d.ts +12 -0
- package/lib/qbsTable/utilities/CardComponent.d.ts +14 -0
- package/lib/qbsTable/utilities/CardComponent.js +91 -0
- package/lib/qbsTable/utilities/CardMenuDropdown.d.ts +13 -0
- package/lib/qbsTable/utilities/CardMenuDropdown.js +100 -0
- package/lib/qbsTable/utilities/SwitchCardColumns.d.ts +2 -0
- package/lib/qbsTable/utilities/SwitchCardColumns.js +30 -0
- package/lib/qbsTable/utilities/ToolTip.js +2 -5
- package/lib/qbsTable/utilities/icons.d.ts +3 -0
- package/lib/qbsTable/utilities/icons.js +50 -2
- package/lib/qbsTable/utilities/store.d.ts +2 -0
- package/lib/qbsTable/utilities/store.js +66 -0
- package/lib/utils/getTotalByColumns.js +1 -1
- package/lib/utils/mergeCells.js +1 -1
- package/lib/utils/useCellDescriptor.js +11 -11
- package/lib/utils/useClassNames.js +2 -0
- package/package.json +11 -6
- package/src/less/index.less +3 -0
- package/src/less/qbs-table.less +89 -22
- package/src/qbsTable/QbsTable.tsx +205 -173
- package/src/qbsTable/TableCardList.tsx +629 -0
- package/src/qbsTable/Toolbar.tsx +25 -4
- package/src/qbsTable/commontypes.ts +12 -0
- package/src/qbsTable/utilities/CardComponent.tsx +132 -0
- package/src/qbsTable/utilities/CardMenuDropdown.tsx +120 -0
- package/src/qbsTable/utilities/SwitchCardColumns.tsx +29 -0
- package/src/qbsTable/utilities/ToolTip.tsx +1 -4
- package/src/qbsTable/utilities/icons.tsx +51 -0
- package/src/qbsTable/utilities/store.ts +61 -0
package/es/qbsTable/Toolbar.js
CHANGED
|
@@ -1,7 +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';
|
|
6
|
+
import TooltipComponent from './utilities/ToolTip';
|
|
5
7
|
var ToolBar = function ToolBar(_ref) {
|
|
6
8
|
var _paginationProps$tota, _paginationProps$rows, _paginationProps$curr;
|
|
7
9
|
var pagination = _ref.pagination,
|
|
@@ -20,11 +22,16 @@ var ToolBar = function ToolBar(_ref) {
|
|
|
20
22
|
checkedKeys = _ref.checkedKeys,
|
|
21
23
|
onSelect = _ref.onSelect,
|
|
22
24
|
dataLength = _ref.dataLength,
|
|
23
|
-
searchPlaceholder = _ref.searchPlaceholder
|
|
25
|
+
searchPlaceholder = _ref.searchPlaceholder,
|
|
26
|
+
tableViewToggle = _ref.tableViewToggle,
|
|
27
|
+
setTableViewToggle = _ref.setTableViewToggle,
|
|
28
|
+
_ref$enableTableToggl = _ref.enableTableToggle,
|
|
29
|
+
enableTableToggle = _ref$enableTableToggl === void 0 ? false : _ref$enableTableToggl;
|
|
24
30
|
var debouncedOnSearch = useCallback(debounce(onSearch != null ? onSearch : function () {}, 1000), [onSearch]);
|
|
25
31
|
var _useState = useState(searchValue),
|
|
26
32
|
searchParam = _useState[0],
|
|
27
33
|
setSearchParam = _useState[1];
|
|
34
|
+
var toolbarRef = useRef(null);
|
|
28
35
|
var handleSearch = useCallback(function (e) {
|
|
29
36
|
if (debouncedOnSearch) {
|
|
30
37
|
debouncedOnSearch(e);
|
|
@@ -48,7 +55,8 @@ var ToolBar = function ToolBar(_ref) {
|
|
|
48
55
|
}
|
|
49
56
|
};
|
|
50
57
|
return /*#__PURE__*/React.createElement("div", {
|
|
51
|
-
className: "qbs-table-toolbar-container"
|
|
58
|
+
className: "qbs-table-toolbar-container",
|
|
59
|
+
ref: toolbarRef
|
|
52
60
|
}, /*#__PURE__*/React.createElement("div", {
|
|
53
61
|
className: "qbs-table-toolbar " + className
|
|
54
62
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -65,8 +73,16 @@ var ToolBar = function ToolBar(_ref) {
|
|
|
65
73
|
handleSearch: handleSearch,
|
|
66
74
|
searchValue: searchParam
|
|
67
75
|
}), primaryFilter)), /*#__PURE__*/React.createElement("div", {
|
|
68
|
-
className: "end-container"
|
|
69
|
-
}, tableHeaderActions
|
|
76
|
+
className: "end-container flex items-center"
|
|
77
|
+
}, tableHeaderActions, /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: " pr-1 cursor-pointer relative",
|
|
79
|
+
onClick: function onClick() {
|
|
80
|
+
return setTableViewToggle === null || setTableViewToggle === void 0 ? void 0 : setTableViewToggle(!tableViewToggle);
|
|
81
|
+
}
|
|
82
|
+
}, enableTableToggle && /*#__PURE__*/React.createElement(TooltipComponent, {
|
|
83
|
+
tableBodyRef: toolbarRef,
|
|
84
|
+
title: tableViewToggle ? 'Switch to Card View' : 'Switch to Table View'
|
|
85
|
+
}, !tableViewToggle ? /*#__PURE__*/React.createElement(CardIcon, null) : /*#__PURE__*/React.createElement(TableIcon, null))))), advancefilter && /*#__PURE__*/React.createElement("div", {
|
|
70
86
|
className: "sub-qbs-table-toolbar"
|
|
71
87
|
}, advancefilter), (pagination && dataLength > 0 || checkedKeys && (checkedKeys === null || checkedKeys === void 0 ? void 0 : checkedKeys.length) > 0) && /*#__PURE__*/React.createElement("div", {
|
|
72
88
|
className: "qbs-table-toolbar-sub-container " + (checkedKeys && (checkedKeys === null || checkedKeys === void 0 ? void 0 : checkedKeys.length) > 0 ? 'selected-row' : '')
|
|
@@ -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;
|
|
@@ -42,6 +43,9 @@ export interface ActionProps {
|
|
|
42
43
|
toolTip?: string;
|
|
43
44
|
hidden?: boolean;
|
|
44
45
|
hide?: (data: any, index?: number) => boolean;
|
|
46
|
+
isWarning?: boolean;
|
|
47
|
+
label?: string;
|
|
48
|
+
iconName?: string;
|
|
45
49
|
}
|
|
46
50
|
export interface QbsTableProps {
|
|
47
51
|
tableKey?: string;
|
|
@@ -116,6 +120,10 @@ export interface QbsTableProps {
|
|
|
116
120
|
renderEmpty?: (info: React.ReactNode) => React.ReactNode;
|
|
117
121
|
emptySubTitle?: string;
|
|
118
122
|
emptyTitle?: string;
|
|
123
|
+
enableTableToggle?: boolean;
|
|
124
|
+
tableView?: boolean;
|
|
125
|
+
cardColumLimit?: number;
|
|
126
|
+
childDetailHeading?: string;
|
|
119
127
|
}
|
|
120
128
|
export interface QbsTableToolbarProps {
|
|
121
129
|
title?: string;
|
|
@@ -140,6 +148,10 @@ export interface QbsTableToolbarProps {
|
|
|
140
148
|
dataLength: number;
|
|
141
149
|
headerHeight?: number;
|
|
142
150
|
searchPlaceholder?: string;
|
|
151
|
+
tableView?: boolean;
|
|
152
|
+
enableTableToggle?: boolean;
|
|
153
|
+
tableViewToggle?: boolean;
|
|
154
|
+
setTableViewToggle?: (value: boolean) => void;
|
|
143
155
|
selectedRowActions?: {
|
|
144
156
|
actionTitle?: string;
|
|
145
157
|
action: (checked: (number | string)[]) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { QbsColumnProps } from '../commontypes';
|
|
3
|
+
type Props = {
|
|
4
|
+
columns: QbsColumnProps[];
|
|
5
|
+
data: any;
|
|
6
|
+
tableBodyRef: any;
|
|
7
|
+
actionProps?: any;
|
|
8
|
+
index?: number;
|
|
9
|
+
handleMenuActions?: () => void;
|
|
10
|
+
cardColumLimit?: number;
|
|
11
|
+
childDetailHeading?: string;
|
|
12
|
+
};
|
|
13
|
+
declare const CardComponent: React.FC<Props>;
|
|
14
|
+
export default CardComponent;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
|
+
import CardMenuDropdown from './CardMenuDropdown';
|
|
3
|
+
import { CustomTableCell } from './SwitchCardColumns';
|
|
4
|
+
import { handleCellFormat } from './handleFormatCell';
|
|
5
|
+
import { ArrowUpIcon } from './icons';
|
|
6
|
+
import { getGridColsClass, getGridColSpanClass } from './store';
|
|
7
|
+
import TooltipComponent from './ToolTip';
|
|
8
|
+
var CardComponent = function CardComponent(_ref) {
|
|
9
|
+
var columns = _ref.columns,
|
|
10
|
+
data = _ref.data,
|
|
11
|
+
tableBodyRef = _ref.tableBodyRef,
|
|
12
|
+
actionProps = _ref.actionProps,
|
|
13
|
+
index = _ref.index,
|
|
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;
|
|
19
|
+
var _useState = useState(false),
|
|
20
|
+
viewMore = _useState[0],
|
|
21
|
+
setViewMore = _useState[1];
|
|
22
|
+
var initialDisplayCount = cardColumLimit;
|
|
23
|
+
var toggleViewMore = function toggleViewMore() {
|
|
24
|
+
setViewMore(!viewMore);
|
|
25
|
+
};
|
|
26
|
+
var useCardRef = useRef(null);
|
|
27
|
+
var displayedColumns = viewMore ? columns : columns.slice(0, initialDisplayCount);
|
|
28
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
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"
|
|
33
|
+
}, displayedColumns.map(function (col, index) {
|
|
34
|
+
var _col$colSpan;
|
|
35
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
key: index,
|
|
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' : '') + " "
|
|
38
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
39
|
+
className: " text-grey "
|
|
40
|
+
}, col.title), col.customCell || col.link ? /*#__PURE__*/React.createElement("span", {
|
|
41
|
+
className: "qbs-card-column-content mt-1 " + (!viewMore ? 'line-clamp-1' : '')
|
|
42
|
+
}, /*#__PURE__*/React.createElement(CustomTableCell, {
|
|
43
|
+
dataKey: col.field,
|
|
44
|
+
rowData: data,
|
|
45
|
+
type: col.type,
|
|
46
|
+
path: col.getPath,
|
|
47
|
+
link: col.link,
|
|
48
|
+
viewMore: viewMore,
|
|
49
|
+
rowClick: col.rowClick,
|
|
50
|
+
renderCell: col.renderCell
|
|
51
|
+
})) : /*#__PURE__*/React.createElement("p", {
|
|
52
|
+
className: "mt-1 qbs-card-column-content " + (!viewMore ? 'line-clamp-1' : ''),
|
|
53
|
+
key: index
|
|
54
|
+
}, handleCellFormat(data[col.field], col.type)));
|
|
55
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
className: "qbs-card-column-action absolute text-blue-500 mt-2 right-2 " + (columns.length > initialDisplayCount ? 'top-2' : 'top-4') + " text-xs"
|
|
57
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
className: "flex qbs-card-column-action-container\n flex-col items-center gap-y-2\n "
|
|
59
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: " text-blue-500 qbs-card-column-action-menu "
|
|
61
|
+
}, /*#__PURE__*/React.createElement(CardMenuDropdown, {
|
|
62
|
+
tableBodyRef: tableBodyRef,
|
|
63
|
+
actionDropDown: actionProps,
|
|
64
|
+
rowData: data,
|
|
65
|
+
iconName: "more",
|
|
66
|
+
rowIndex: index,
|
|
67
|
+
handleMenuActions: handleMenuActions
|
|
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", {
|
|
73
|
+
onClick: toggleViewMore,
|
|
74
|
+
className: " qbs-card-column-action-menu-view-more justify-end text-blue-500 text-xs"
|
|
75
|
+
}, /*#__PURE__*/React.createElement(ArrowUpIcon, {
|
|
76
|
+
className: (viewMore ? 'rotate-180' : '') + " "
|
|
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));
|
|
82
|
+
};
|
|
83
|
+
export default CardComponent;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ActionProps } from '../commontypes';
|
|
3
|
+
type Props = {
|
|
4
|
+
iconName: string;
|
|
5
|
+
actionDropDown: ActionProps[];
|
|
6
|
+
handleMenuActions?: (slug: ActionProps, rowData?: any) => void;
|
|
7
|
+
rowData?: any;
|
|
8
|
+
dataTheme?: string;
|
|
9
|
+
tableBodyRef: React.RefObject<HTMLDivElement>;
|
|
10
|
+
rowIndex?: number;
|
|
11
|
+
};
|
|
12
|
+
declare const CardMenuDropdown: React.FC<Props>;
|
|
13
|
+
export default CardMenuDropdown;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ThreeDotIcon } from './icons';
|
|
4
|
+
import TooltipComponent from './ToolTip';
|
|
5
|
+
var CardMenuDropdown = function CardMenuDropdown(_ref) {
|
|
6
|
+
var actionDropDown = _ref.actionDropDown,
|
|
7
|
+
handleMenuActions = _ref.handleMenuActions,
|
|
8
|
+
rowData = _ref.rowData;
|
|
9
|
+
var _useState = useState(false),
|
|
10
|
+
openMenu = _useState[0],
|
|
11
|
+
setOpenMenu = _useState[1];
|
|
12
|
+
var _useState2 = useState({}),
|
|
13
|
+
menuPositionStyles = _useState2[0],
|
|
14
|
+
setMenuPositionStyles = _useState2[1];
|
|
15
|
+
var menuButtonRef = useRef(null);
|
|
16
|
+
var menuRef = useRef(null);
|
|
17
|
+
useEffect(function () {
|
|
18
|
+
var handleClickOutside = function handleClickOutside(event) {
|
|
19
|
+
if (menuRef.current && !menuRef.current.contains(event.target)) {
|
|
20
|
+
setOpenMenu(false);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
document.addEventListener('click', handleClickOutside);
|
|
24
|
+
return function () {
|
|
25
|
+
document.removeEventListener('click', handleClickOutside);
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
var toggleMenu = function toggleMenu() {
|
|
29
|
+
setOpenMenu(function (prevState) {
|
|
30
|
+
if (!prevState && menuButtonRef.current) {
|
|
31
|
+
var buttonRect = menuButtonRef.current.getBoundingClientRect();
|
|
32
|
+
var dropdownHeight = 200; // Adjust this if your dropdown height varies
|
|
33
|
+
var spaceBelow = window.innerHeight - buttonRect.bottom;
|
|
34
|
+
var spaceAbove = buttonRect.top;
|
|
35
|
+
console.log(spaceAbove, spaceBelow, dropdownHeight);
|
|
36
|
+
if (spaceBelow < dropdownHeight && spaceAbove > spaceBelow) {
|
|
37
|
+
setMenuPositionStyles({
|
|
38
|
+
bottom: '30px',
|
|
39
|
+
right: '10px'
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
setMenuPositionStyles({
|
|
43
|
+
top: buttonRect.height + "px",
|
|
44
|
+
right: '10px'
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return !prevState;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
var handleClose = function handleClose() {
|
|
52
|
+
setOpenMenu(false);
|
|
53
|
+
};
|
|
54
|
+
var handleMenuItemClick = function handleMenuItemClick(item) {
|
|
55
|
+
var _item$action;
|
|
56
|
+
(_item$action = item.action) === null || _item$action === void 0 ? void 0 : _item$action.call(item, item);
|
|
57
|
+
handleMenuActions === null || handleMenuActions === void 0 ? void 0 : handleMenuActions(item, rowData);
|
|
58
|
+
handleClose();
|
|
59
|
+
};
|
|
60
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
className: "dropdown text-black dark:text-white dark:bg-[#424242] bg-white",
|
|
62
|
+
ref: menuRef
|
|
63
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
64
|
+
className: "dropdown-toggle",
|
|
65
|
+
onClick: toggleMenu,
|
|
66
|
+
ref: menuButtonRef
|
|
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",
|
|
73
|
+
style: menuPositionStyles
|
|
74
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
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"
|
|
76
|
+
}, actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.map(function (item) {
|
|
77
|
+
return !item.hidden && /*#__PURE__*/React.createElement("a", {
|
|
78
|
+
key: item.title,
|
|
79
|
+
href: "#/",
|
|
80
|
+
className: 'px-1 hover:bg-background no-underline whitespace-nowrap ',
|
|
81
|
+
onClick: function onClick(e) {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
e.stopPropagation();
|
|
84
|
+
handleMenuItemClick(item);
|
|
85
|
+
}
|
|
86
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
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 "
|
|
88
|
+
}, (item === null || item === void 0 ? void 0 : item.icon) && /*#__PURE__*/React.createElement(React.Fragment, null, item.icon), /*#__PURE__*/React.createElement("span", {
|
|
89
|
+
className: "pl-1.5 no-underline text-sm "
|
|
90
|
+
}, 'Edit this column')));
|
|
91
|
+
}))));
|
|
92
|
+
};
|
|
93
|
+
export default CardMenuDropdown;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
import { handleCellFormat } from './handleFormatCell';
|
|
4
|
+
export var CustomTableCell = /*#__PURE__*/React.memo(function (_ref) {
|
|
5
|
+
var _renderCell, _path, _renderCell2, _renderCell3;
|
|
6
|
+
var rowData = _ref.rowData,
|
|
7
|
+
renderCell = _ref.renderCell,
|
|
8
|
+
hideLink = _ref.hideLink,
|
|
9
|
+
dataKey = _ref.dataKey,
|
|
10
|
+
rowClick = _ref.rowClick,
|
|
11
|
+
type = _ref.type,
|
|
12
|
+
path = _ref.path,
|
|
13
|
+
link = _ref.link,
|
|
14
|
+
viewMore = _ref.viewMore;
|
|
15
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, link && !path && !(hideLink !== null && hideLink !== void 0 && hideLink(rowData)) ? /*#__PURE__*/React.createElement("a", {
|
|
16
|
+
onClick: function onClick() {
|
|
17
|
+
return rowClick === null || rowClick === void 0 ? void 0 : rowClick(rowData);
|
|
18
|
+
},
|
|
19
|
+
className: "qbs-table-row-link no-underline " + (!viewMore ? 'line-clamp-1' : '')
|
|
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
|
+
to: (_path = path === null || path === void 0 ? void 0 : path(rowData)) != null ? _path : '',
|
|
22
|
+
className: "qbs-table-row-link no-underline " + (!viewMore ? 'line-clamp-1' : '')
|
|
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
|
+
});
|
|
@@ -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;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare const ThreeDotIcon: React.FC<any>;
|
|
3
3
|
export declare const SettingsIcon: React.FC<any>;
|
|
4
|
+
export declare const ArrowUpIcon: React.FC<any>;
|
|
5
|
+
export declare const TableIcon: React.FC<any>;
|
|
6
|
+
export declare const CardIcon: React.FC<any>;
|
|
@@ -36,4 +36,49 @@ export var SettingsIcon = function SettingsIcon() {
|
|
|
36
36
|
strokeLinecap: "round",
|
|
37
37
|
strokeLinejoin: "round"
|
|
38
38
|
}));
|
|
39
|
+
};
|
|
40
|
+
export var ArrowUpIcon = function ArrowUpIcon(_ref) {
|
|
41
|
+
var className = _ref.className;
|
|
42
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
43
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
44
|
+
fill: "none",
|
|
45
|
+
viewBox: "0 0 24 24",
|
|
46
|
+
strokeWidth: "3",
|
|
47
|
+
stroke: "currentColor",
|
|
48
|
+
className: className + " w-4 h-4"
|
|
49
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
50
|
+
strokeLinecap: "round",
|
|
51
|
+
strokeLinejoin: "round",
|
|
52
|
+
d: "m19.5 8.25-7.5 7.5-7.5-7.5"
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
export var TableIcon = function TableIcon(_ref2) {
|
|
56
|
+
var className = _ref2.className;
|
|
57
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
58
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
59
|
+
fill: "none",
|
|
60
|
+
viewBox: "0 0 24 24",
|
|
61
|
+
strokeWidth: "1.5",
|
|
62
|
+
stroke: "currentColor",
|
|
63
|
+
className: className + " w-6 h-6"
|
|
64
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
65
|
+
strokeLinecap: "round",
|
|
66
|
+
strokeLinejoin: "round",
|
|
67
|
+
d: "M2.25 8.25h19.5M2.25 9h19.5m-16.5 5.25h6m-6 2.25h3m-3.75 3h15a2.25 2.25 0 0 0 2.25-2.25V6.75A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25v10.5A2.25 2.25 0 0 0 4.5 19.5Z"
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
export var CardIcon = function CardIcon(_ref3) {
|
|
71
|
+
var className = _ref3.className;
|
|
72
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
73
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
74
|
+
fill: "none",
|
|
75
|
+
viewBox: "0 0 24 24",
|
|
76
|
+
strokeWidth: "1.5",
|
|
77
|
+
stroke: "currentColor",
|
|
78
|
+
className: className + " w-6 h-6"
|
|
79
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
80
|
+
strokeLinecap: "round",
|
|
81
|
+
strokeLinejoin: "round",
|
|
82
|
+
d: "M3.375 19.5h17.25m-17.25 0a1.125 1.125 0 0 1-1.125-1.125M3.375 19.5h7.5c.621 0 1.125-.504 1.125-1.125m-9.75 0V5.625m0 12.75v-1.5c0-.621.504-1.125 1.125-1.125m18.375 2.625V5.625m0 12.75c0 .621-.504 1.125-1.125 1.125m1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125m0 3.75h-7.5A1.125 1.125 0 0 1 12 18.375m9.75-12.75c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125m19.5 0v1.5c0 .621-.504 1.125-1.125 1.125M2.25 5.625v1.5c0 .621.504 1.125 1.125 1.125m0 0h17.25m-17.25 0h7.5c.621 0 1.125.504 1.125 1.125M3.375 8.25c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125m17.25-3.75h-7.5c-.621 0-1.125.504-1.125 1.125m8.625-1.125c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125m-17.25 0h7.5m-7.5 0c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125M12 10.875v-1.5m0 1.5c0 .621-.504 1.125-1.125 1.125M12 10.875c0 .621.504 1.125 1.125 1.125m-2.25 0c.621 0 1.125.504 1.125 1.125M13.125 12h7.5m-7.5 0c-.621 0-1.125.504-1.125 1.125M20.625 12c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125m-17.25 0h7.5M12 14.625v-1.5m0 1.5c0 .621-.504 1.125-1.125 1.125M12 14.625c0 .621.504 1.125 1.125 1.125m-2.25 0c.621 0 1.125.504 1.125 1.125m0 1.5v-1.5m0 0c0-.621.504-1.125 1.125-1.125m0 0h7.5"
|
|
83
|
+
}));
|
|
39
84
|
};
|
|
@@ -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
|
+
};
|
|
@@ -6,7 +6,7 @@ function getTotalByColumns(columns) {
|
|
|
6
6
|
var totalWidth = 0;
|
|
7
7
|
var count = function count(items) {
|
|
8
8
|
Array.from(items).forEach(function (column) {
|
|
9
|
-
if (
|
|
9
|
+
if (/*#__PURE__*/React.isValidElement(column)) {
|
|
10
10
|
var _getColumnProps = getColumnProps(column),
|
|
11
11
|
flexGrow = _getColumnProps.flexGrow,
|
|
12
12
|
_getColumnProps$width = _getColumnProps.width,
|
package/es/utils/mergeCells.js
CHANGED
|
@@ -138,11 +138,11 @@ var useCellDescriptor = function useCellDescriptor(props) {
|
|
|
138
138
|
totalFlexGrow = _getTotalByColumns.totalFlexGrow,
|
|
139
139
|
totalWidth = _getTotalByColumns.totalWidth;
|
|
140
140
|
React.Children.forEach(columns, function (column, index) {
|
|
141
|
-
if (
|
|
141
|
+
if (/*#__PURE__*/React.isValidElement(column)) {
|
|
142
142
|
var _initialColumnWidths$, _columnWidths$current;
|
|
143
143
|
var columnChildren = column.props.children;
|
|
144
144
|
var columnProps = getColumnProps(column);
|
|
145
|
-
var
|
|
145
|
+
var width = columnProps.width,
|
|
146
146
|
resizable = columnProps.resizable,
|
|
147
147
|
flexGrow = columnProps.flexGrow,
|
|
148
148
|
minWidth = columnProps.minWidth,
|
|
@@ -161,23 +161,23 @@ var useCellDescriptor = function useCellDescriptor(props) {
|
|
|
161
161
|
// get column width from cache.
|
|
162
162
|
var initialColumnWidth = (_initialColumnWidths$ = initialColumnWidths.current) === null || _initialColumnWidths$ === void 0 ? void 0 : _initialColumnWidths$[cellWidthId];
|
|
163
163
|
var currentWidth = (_columnWidths$current = columnWidths.current) === null || _columnWidths$current === void 0 ? void 0 : _columnWidths$current[cellWidthId];
|
|
164
|
-
var cellWidth = currentWidth ||
|
|
165
|
-
var isControlled = typeof
|
|
164
|
+
var cellWidth = currentWidth || width || 0;
|
|
165
|
+
var isControlled = typeof width === 'number' && typeof onResize === 'function';
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
168
|
* in resizable mode,
|
|
169
169
|
* if width !== initialColumnWidth, use current column width and update cache.
|
|
170
170
|
*/
|
|
171
|
-
if (resizable && (initialColumnWidth ||
|
|
171
|
+
if (resizable && (initialColumnWidth || width) && initialColumnWidth !== width) {
|
|
172
172
|
// initial or update initialColumnWidth cache.
|
|
173
|
-
initialColumnWidths.current[cellWidthId] =
|
|
173
|
+
initialColumnWidths.current[cellWidthId] = width;
|
|
174
174
|
/**
|
|
175
175
|
* if currentWidth exist, update columnWidths cache.
|
|
176
176
|
*/
|
|
177
177
|
if (currentWidth) {
|
|
178
|
-
columnWidths.current[cellWidthId] =
|
|
178
|
+
columnWidths.current[cellWidthId] = width;
|
|
179
179
|
// update cellWidth
|
|
180
|
-
cellWidth =
|
|
180
|
+
cellWidth = width;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
if (tableWidth.current && flexGrow && totalFlexGrow) {
|
|
@@ -193,7 +193,7 @@ var useCellDescriptor = function useCellDescriptor(props) {
|
|
|
193
193
|
left: left,
|
|
194
194
|
headerHeight: headerHeight,
|
|
195
195
|
key: index,
|
|
196
|
-
width: isControlled ?
|
|
196
|
+
width: isControlled ? width : cellWidth,
|
|
197
197
|
height: typeof rowHeight === 'function' ? rowHeight() : rowHeight,
|
|
198
198
|
firstColumn: index === 0,
|
|
199
199
|
lastColumn: index === count - 1
|
|
@@ -220,9 +220,9 @@ var useCellDescriptor = function useCellDescriptor(props) {
|
|
|
220
220
|
onColumnResizeMove: handleColumnResizeMove
|
|
221
221
|
});
|
|
222
222
|
}
|
|
223
|
-
headerCells.push(
|
|
223
|
+
headerCells.push(/*#__PURE__*/React.cloneElement(headerCell, _extends({}, cellProps, headerCellProps)));
|
|
224
224
|
}
|
|
225
|
-
bodyCells.push(
|
|
225
|
+
bodyCells.push(/*#__PURE__*/React.cloneElement(cell, cellProps));
|
|
226
226
|
left += cellWidth;
|
|
227
227
|
}
|
|
228
228
|
});
|
|
@@ -5,7 +5,9 @@ import TableContext from '../TableContext';
|
|
|
5
5
|
|
|
6
6
|
// This is the only way I found to break circular references between ClassArray and ClassValue
|
|
7
7
|
// https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
|
|
8
|
+
|
|
8
9
|
//eslint-disable-line @typescript-eslint/no-empty-interface
|
|
10
|
+
|
|
9
11
|
/**
|
|
10
12
|
* Add a prefix to all classNames.
|
|
11
13
|
*
|