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
|
@@ -0,0 +1,91 @@
|
|
|
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 _CardMenuDropdown = _interopRequireDefault(require("./CardMenuDropdown"));
|
|
8
|
+
var _SwitchCardColumns = require("./SwitchCardColumns");
|
|
9
|
+
var _handleFormatCell = require("./handleFormatCell");
|
|
10
|
+
var _icons = require("./icons");
|
|
11
|
+
var _store = require("./store");
|
|
12
|
+
var _ToolTip = _interopRequireDefault(require("./ToolTip"));
|
|
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); }
|
|
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; }
|
|
15
|
+
var CardComponent = function CardComponent(_ref) {
|
|
16
|
+
var columns = _ref.columns,
|
|
17
|
+
data = _ref.data,
|
|
18
|
+
tableBodyRef = _ref.tableBodyRef,
|
|
19
|
+
actionProps = _ref.actionProps,
|
|
20
|
+
index = _ref.index,
|
|
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;
|
|
26
|
+
var _useState = (0, _react.useState)(false),
|
|
27
|
+
viewMore = _useState[0],
|
|
28
|
+
setViewMore = _useState[1];
|
|
29
|
+
var initialDisplayCount = cardColumLimit;
|
|
30
|
+
var toggleViewMore = function toggleViewMore() {
|
|
31
|
+
setViewMore(!viewMore);
|
|
32
|
+
};
|
|
33
|
+
var useCardRef = (0, _react.useRef)(null);
|
|
34
|
+
var displayedColumns = viewMore ? columns : columns.slice(0, initialDisplayCount);
|
|
35
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
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"
|
|
40
|
+
}, displayedColumns.map(function (col, index) {
|
|
41
|
+
var _col$colSpan;
|
|
42
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
43
|
+
key: index,
|
|
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' : '') + " "
|
|
45
|
+
}, /*#__PURE__*/_react["default"].createElement("p", {
|
|
46
|
+
className: " text-grey "
|
|
47
|
+
}, col.title), col.customCell || col.link ? /*#__PURE__*/_react["default"].createElement("span", {
|
|
48
|
+
className: "qbs-card-column-content mt-1 " + (!viewMore ? 'line-clamp-1' : '')
|
|
49
|
+
}, /*#__PURE__*/_react["default"].createElement(_SwitchCardColumns.CustomTableCell, {
|
|
50
|
+
dataKey: col.field,
|
|
51
|
+
rowData: data,
|
|
52
|
+
type: col.type,
|
|
53
|
+
path: col.getPath,
|
|
54
|
+
link: col.link,
|
|
55
|
+
viewMore: viewMore,
|
|
56
|
+
rowClick: col.rowClick,
|
|
57
|
+
renderCell: col.renderCell
|
|
58
|
+
})) : /*#__PURE__*/_react["default"].createElement("p", {
|
|
59
|
+
className: "mt-1 qbs-card-column-content " + (!viewMore ? 'line-clamp-1' : ''),
|
|
60
|
+
key: index
|
|
61
|
+
}, (0, _handleFormatCell.handleCellFormat)(data[col.field], col.type)));
|
|
62
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
63
|
+
className: "qbs-card-column-action absolute text-blue-500 mt-2 right-2 " + (columns.length > initialDisplayCount ? 'top-2' : 'top-4') + " text-xs"
|
|
64
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
65
|
+
className: "flex qbs-card-column-action-container\n flex-col items-center gap-y-2\n "
|
|
66
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
67
|
+
className: " text-blue-500 qbs-card-column-action-menu "
|
|
68
|
+
}, /*#__PURE__*/_react["default"].createElement(_CardMenuDropdown["default"], {
|
|
69
|
+
tableBodyRef: tableBodyRef,
|
|
70
|
+
actionDropDown: actionProps,
|
|
71
|
+
rowData: data,
|
|
72
|
+
iconName: "more",
|
|
73
|
+
rowIndex: index,
|
|
74
|
+
handleMenuActions: handleMenuActions
|
|
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", {
|
|
80
|
+
onClick: toggleViewMore,
|
|
81
|
+
className: " qbs-card-column-action-menu-view-more justify-end text-blue-500 text-xs"
|
|
82
|
+
}, /*#__PURE__*/_react["default"].createElement(_icons.ArrowUpIcon, {
|
|
83
|
+
className: (viewMore ? 'rotate-180' : '') + " "
|
|
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));
|
|
89
|
+
};
|
|
90
|
+
var _default = CardComponent;
|
|
91
|
+
exports["default"] = _default;
|
|
@@ -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,100 @@
|
|
|
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 CardMenuDropdown = function CardMenuDropdown(_ref) {
|
|
12
|
+
var actionDropDown = _ref.actionDropDown,
|
|
13
|
+
handleMenuActions = _ref.handleMenuActions,
|
|
14
|
+
rowData = _ref.rowData;
|
|
15
|
+
var _useState = (0, _react.useState)(false),
|
|
16
|
+
openMenu = _useState[0],
|
|
17
|
+
setOpenMenu = _useState[1];
|
|
18
|
+
var _useState2 = (0, _react.useState)({}),
|
|
19
|
+
menuPositionStyles = _useState2[0],
|
|
20
|
+
setMenuPositionStyles = _useState2[1];
|
|
21
|
+
var menuButtonRef = (0, _react.useRef)(null);
|
|
22
|
+
var menuRef = (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 toggleMenu = function toggleMenu() {
|
|
35
|
+
setOpenMenu(function (prevState) {
|
|
36
|
+
if (!prevState && menuButtonRef.current) {
|
|
37
|
+
var buttonRect = menuButtonRef.current.getBoundingClientRect();
|
|
38
|
+
var dropdownHeight = 200; // Adjust this if your dropdown height varies
|
|
39
|
+
var spaceBelow = window.innerHeight - buttonRect.bottom;
|
|
40
|
+
var spaceAbove = buttonRect.top;
|
|
41
|
+
console.log(spaceAbove, spaceBelow, dropdownHeight);
|
|
42
|
+
if (spaceBelow < dropdownHeight && spaceAbove > spaceBelow) {
|
|
43
|
+
setMenuPositionStyles({
|
|
44
|
+
bottom: '30px',
|
|
45
|
+
right: '10px'
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
setMenuPositionStyles({
|
|
49
|
+
top: buttonRect.height + "px",
|
|
50
|
+
right: '10px'
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return !prevState;
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
var handleClose = function handleClose() {
|
|
58
|
+
setOpenMenu(false);
|
|
59
|
+
};
|
|
60
|
+
var handleMenuItemClick = function handleMenuItemClick(item) {
|
|
61
|
+
var _item$action;
|
|
62
|
+
(_item$action = item.action) === null || _item$action === void 0 ? void 0 : _item$action.call(item, item);
|
|
63
|
+
handleMenuActions === null || handleMenuActions === void 0 ? void 0 : handleMenuActions(item, rowData);
|
|
64
|
+
handleClose();
|
|
65
|
+
};
|
|
66
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
67
|
+
className: "dropdown text-black dark:text-white dark:bg-[#424242] bg-white",
|
|
68
|
+
ref: menuRef
|
|
69
|
+
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
70
|
+
className: "dropdown-toggle",
|
|
71
|
+
onClick: toggleMenu,
|
|
72
|
+
ref: menuButtonRef
|
|
73
|
+
}, /*#__PURE__*/_react["default"].createElement(_ToolTip["default"], {
|
|
74
|
+
title: "Actions",
|
|
75
|
+
enabled: false,
|
|
76
|
+
ref: menuButtonRef
|
|
77
|
+
}, /*#__PURE__*/_react["default"].createElement(_icons.ThreeDotIcon, null))), openMenu && /*#__PURE__*/_react["default"].createElement("div", {
|
|
78
|
+
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",
|
|
79
|
+
style: menuPositionStyles
|
|
80
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
81
|
+
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"
|
|
82
|
+
}, actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.map(function (item) {
|
|
83
|
+
return !item.hidden && /*#__PURE__*/_react["default"].createElement("a", {
|
|
84
|
+
key: item.title,
|
|
85
|
+
href: "#/",
|
|
86
|
+
className: 'px-1 hover:bg-background no-underline whitespace-nowrap ',
|
|
87
|
+
onClick: function onClick(e) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
e.stopPropagation();
|
|
90
|
+
handleMenuItemClick(item);
|
|
91
|
+
}
|
|
92
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
93
|
+
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 "
|
|
94
|
+
}, (item === null || item === void 0 ? void 0 : item.icon) && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, item.icon), /*#__PURE__*/_react["default"].createElement("span", {
|
|
95
|
+
className: "pl-1.5 no-underline text-sm "
|
|
96
|
+
}, 'Edit this column')));
|
|
97
|
+
}))));
|
|
98
|
+
};
|
|
99
|
+
var _default = CardMenuDropdown;
|
|
100
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.CustomTableCell = void 0;
|
|
6
|
+
var _react = _interopRequireDefault(require("react"));
|
|
7
|
+
var _reactRouterDom = require("react-router-dom");
|
|
8
|
+
var _handleFormatCell = require("./handleFormatCell");
|
|
9
|
+
var CustomTableCell = /*#__PURE__*/_react["default"].memo(function (_ref) {
|
|
10
|
+
var _renderCell, _path, _renderCell2, _renderCell3;
|
|
11
|
+
var rowData = _ref.rowData,
|
|
12
|
+
renderCell = _ref.renderCell,
|
|
13
|
+
hideLink = _ref.hideLink,
|
|
14
|
+
dataKey = _ref.dataKey,
|
|
15
|
+
rowClick = _ref.rowClick,
|
|
16
|
+
type = _ref.type,
|
|
17
|
+
path = _ref.path,
|
|
18
|
+
link = _ref.link,
|
|
19
|
+
viewMore = _ref.viewMore;
|
|
20
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, link && !path && !(hideLink !== null && hideLink !== void 0 && hideLink(rowData)) ? /*#__PURE__*/_react["default"].createElement("a", {
|
|
21
|
+
onClick: function onClick() {
|
|
22
|
+
return rowClick === null || rowClick === void 0 ? void 0 : rowClick(rowData);
|
|
23
|
+
},
|
|
24
|
+
className: "qbs-table-row-link no-underline " + (!viewMore ? 'line-clamp-1' : '')
|
|
25
|
+
}, renderCell ? (_renderCell = renderCell(rowData)) === null || _renderCell === void 0 ? void 0 : _renderCell.cell : (0, _handleFormatCell.handleCellFormat)(rowData[dataKey], type)) : path && !(hideLink !== null && hideLink !== void 0 && hideLink(rowData)) ? /*#__PURE__*/_react["default"].createElement(_reactRouterDom.Link, {
|
|
26
|
+
to: (_path = path === null || path === void 0 ? void 0 : path(rowData)) != null ? _path : '',
|
|
27
|
+
className: "qbs-table-row-link no-underline " + (!viewMore ? 'line-clamp-1' : '')
|
|
28
|
+
}, renderCell ? (_renderCell2 = renderCell(rowData)) === null || _renderCell2 === void 0 ? void 0 : _renderCell2.cell : (0, _handleFormatCell.handleCellFormat)(rowData[dataKey], type)) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, renderCell ? (_renderCell3 = renderCell(rowData)) === null || _renderCell3 === void 0 ? void 0 : _renderCell3.cell : (0, _handleFormatCell.handleCellFormat)(rowData[dataKey], type)));
|
|
29
|
+
});
|
|
30
|
+
exports.CustomTableCell = CustomTableCell;
|
|
@@ -16,15 +16,12 @@ var TooltipComponent = function TooltipComponent(_ref) {
|
|
|
16
16
|
var menuButtonRef = (0, _react.useRef)(null);
|
|
17
17
|
var adjustDropdownPosition = function adjustDropdownPosition() {
|
|
18
18
|
if (menuButtonRef.current && tableBodyRef !== null && tableBodyRef !== void 0 && tableBodyRef.current) {
|
|
19
|
-
var _menuButtonRef$curren
|
|
19
|
+
var _menuButtonRef$curren;
|
|
20
20
|
var inputBoxRect = (_menuButtonRef$curren = menuButtonRef.current) === null || _menuButtonRef$curren === void 0 ? void 0 : _menuButtonRef$curren.getBoundingClientRect();
|
|
21
|
-
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;
|
|
22
21
|
var tableRect = tableBodyRef.current.getBoundingClientRect();
|
|
23
|
-
|
|
24
22
|
// Calculate positions relative to the table
|
|
25
23
|
var spaceAbove = inputBoxRect.top - tableRect.top;
|
|
26
24
|
var spaceBelow = tableRect.bottom - inputBoxRect.bottom;
|
|
27
|
-
console.log(viewportHeight, spaceAbove, spaceBelow);
|
|
28
25
|
if (spaceAbove > spaceBelow) {
|
|
29
26
|
setDropdownPosition('top-position');
|
|
30
27
|
} else {
|
|
@@ -44,7 +41,7 @@ var TooltipComponent = function TooltipComponent(_ref) {
|
|
|
44
41
|
}
|
|
45
42
|
}, children), /*#__PURE__*/_react["default"].createElement("span", {
|
|
46
43
|
ref: dropRef,
|
|
47
|
-
className:
|
|
44
|
+
className: 'tooltiptext'
|
|
48
45
|
}, title));
|
|
49
46
|
};
|
|
50
47
|
var _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>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.ThreeDotIcon = exports.SettingsIcon = void 0;
|
|
5
|
+
exports.ThreeDotIcon = exports.TableIcon = exports.SettingsIcon = exports.CardIcon = exports.ArrowUpIcon = void 0;
|
|
6
6
|
var _react = _interopRequireDefault(require("react"));
|
|
7
7
|
var ThreeDotIcon = function ThreeDotIcon() {
|
|
8
8
|
return /*#__PURE__*/_react["default"].createElement("svg", {
|
|
@@ -43,4 +43,52 @@ var SettingsIcon = function SettingsIcon() {
|
|
|
43
43
|
strokeLinejoin: "round"
|
|
44
44
|
}));
|
|
45
45
|
};
|
|
46
|
-
exports.SettingsIcon = SettingsIcon;
|
|
46
|
+
exports.SettingsIcon = SettingsIcon;
|
|
47
|
+
var ArrowUpIcon = function ArrowUpIcon(_ref) {
|
|
48
|
+
var className = _ref.className;
|
|
49
|
+
return /*#__PURE__*/_react["default"].createElement("svg", {
|
|
50
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
51
|
+
fill: "none",
|
|
52
|
+
viewBox: "0 0 24 24",
|
|
53
|
+
strokeWidth: "3",
|
|
54
|
+
stroke: "currentColor",
|
|
55
|
+
className: className + " w-4 h-4"
|
|
56
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
57
|
+
strokeLinecap: "round",
|
|
58
|
+
strokeLinejoin: "round",
|
|
59
|
+
d: "m19.5 8.25-7.5 7.5-7.5-7.5"
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
exports.ArrowUpIcon = ArrowUpIcon;
|
|
63
|
+
var TableIcon = function TableIcon(_ref2) {
|
|
64
|
+
var className = _ref2.className;
|
|
65
|
+
return /*#__PURE__*/_react["default"].createElement("svg", {
|
|
66
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
67
|
+
fill: "none",
|
|
68
|
+
viewBox: "0 0 24 24",
|
|
69
|
+
strokeWidth: "1.5",
|
|
70
|
+
stroke: "currentColor",
|
|
71
|
+
className: className + " w-6 h-6"
|
|
72
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
73
|
+
strokeLinecap: "round",
|
|
74
|
+
strokeLinejoin: "round",
|
|
75
|
+
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"
|
|
76
|
+
}));
|
|
77
|
+
};
|
|
78
|
+
exports.TableIcon = TableIcon;
|
|
79
|
+
var CardIcon = function CardIcon(_ref3) {
|
|
80
|
+
var className = _ref3.className;
|
|
81
|
+
return /*#__PURE__*/_react["default"].createElement("svg", {
|
|
82
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
83
|
+
fill: "none",
|
|
84
|
+
viewBox: "0 0 24 24",
|
|
85
|
+
strokeWidth: "1.5",
|
|
86
|
+
stroke: "currentColor",
|
|
87
|
+
className: className + " w-6 h-6"
|
|
88
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
89
|
+
strokeLinecap: "round",
|
|
90
|
+
strokeLinejoin: "round",
|
|
91
|
+
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"
|
|
92
|
+
}));
|
|
93
|
+
};
|
|
94
|
+
exports.CardIcon = CardIcon;
|
|
@@ -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,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.getGridColsClass = exports.getGridColSpanClass = void 0;
|
|
5
|
+
var getGridColsClass = function getGridColsClass(count) {
|
|
6
|
+
switch (count) {
|
|
7
|
+
case 1:
|
|
8
|
+
return 'grid-cols-1';
|
|
9
|
+
case 2:
|
|
10
|
+
return 'grid-cols-2';
|
|
11
|
+
case 3:
|
|
12
|
+
return 'grid-cols-3';
|
|
13
|
+
case 4:
|
|
14
|
+
return 'grid-cols-4';
|
|
15
|
+
case 5:
|
|
16
|
+
return 'grid-cols-5';
|
|
17
|
+
case 6:
|
|
18
|
+
return 'grid-cols-6';
|
|
19
|
+
case 7:
|
|
20
|
+
return 'grid-cols-7';
|
|
21
|
+
case 8:
|
|
22
|
+
return 'grid-cols-8';
|
|
23
|
+
case 9:
|
|
24
|
+
return 'grid-cols-9';
|
|
25
|
+
case 10:
|
|
26
|
+
return 'grid-cols-10';
|
|
27
|
+
case 11:
|
|
28
|
+
return 'grid-cols-11';
|
|
29
|
+
case 12:
|
|
30
|
+
return 'grid-cols-12';
|
|
31
|
+
default:
|
|
32
|
+
return 'grid-cols-1';
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.getGridColsClass = getGridColsClass;
|
|
36
|
+
var getGridColSpanClass = function getGridColSpanClass(count) {
|
|
37
|
+
switch (count) {
|
|
38
|
+
case 1:
|
|
39
|
+
return 'col-span-1';
|
|
40
|
+
case 2:
|
|
41
|
+
return 'col-span-2';
|
|
42
|
+
case 3:
|
|
43
|
+
return 'col-span-3';
|
|
44
|
+
case 4:
|
|
45
|
+
return 'col-span-4';
|
|
46
|
+
case 5:
|
|
47
|
+
return 'col-span-5';
|
|
48
|
+
case 6:
|
|
49
|
+
return 'col-span--6';
|
|
50
|
+
case 7:
|
|
51
|
+
return 'col-span--7';
|
|
52
|
+
case 8:
|
|
53
|
+
return 'col-span--8';
|
|
54
|
+
case 9:
|
|
55
|
+
return 'col-span--9';
|
|
56
|
+
case 10:
|
|
57
|
+
return 'col-span--10';
|
|
58
|
+
case 11:
|
|
59
|
+
return 'col-span--11';
|
|
60
|
+
case 12:
|
|
61
|
+
return 'col-span--12';
|
|
62
|
+
default:
|
|
63
|
+
return 'col-span--1';
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
exports.getGridColSpanClass = getGridColSpanClass;
|
|
@@ -11,7 +11,7 @@ function getTotalByColumns(columns) {
|
|
|
11
11
|
var totalWidth = 0;
|
|
12
12
|
var count = function count(items) {
|
|
13
13
|
Array.from(items).forEach(function (column) {
|
|
14
|
-
if (
|
|
14
|
+
if (/*#__PURE__*/_react["default"].isValidElement(column)) {
|
|
15
15
|
var _getColumnProps = (0, _getColumnProps2["default"])(column),
|
|
16
16
|
flexGrow = _getColumnProps.flexGrow,
|
|
17
17
|
_getColumnProps$width = _getColumnProps.width,
|
package/lib/utils/mergeCells.js
CHANGED
|
@@ -51,7 +51,7 @@ function mergeCells(cells) {
|
|
|
51
51
|
removed: true
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
groupChildren.push(
|
|
54
|
+
groupChildren.push(/*#__PURE__*/_react["default"].createElement(_HeaderCell["default"], {
|
|
55
55
|
key: j,
|
|
56
56
|
left: left,
|
|
57
57
|
align: align,
|
|
@@ -145,11 +145,11 @@ var useCellDescriptor = function useCellDescriptor(props) {
|
|
|
145
145
|
totalFlexGrow = _getTotalByColumns.totalFlexGrow,
|
|
146
146
|
totalWidth = _getTotalByColumns.totalWidth;
|
|
147
147
|
_react["default"].Children.forEach(columns, function (column, index) {
|
|
148
|
-
if (
|
|
148
|
+
if (/*#__PURE__*/_react["default"].isValidElement(column)) {
|
|
149
149
|
var _initialColumnWidths$, _columnWidths$current;
|
|
150
150
|
var columnChildren = column.props.children;
|
|
151
151
|
var columnProps = (0, _getColumnProps["default"])(column);
|
|
152
|
-
var
|
|
152
|
+
var width = columnProps.width,
|
|
153
153
|
resizable = columnProps.resizable,
|
|
154
154
|
flexGrow = columnProps.flexGrow,
|
|
155
155
|
minWidth = columnProps.minWidth,
|
|
@@ -168,23 +168,23 @@ var useCellDescriptor = function useCellDescriptor(props) {
|
|
|
168
168
|
// get column width from cache.
|
|
169
169
|
var initialColumnWidth = (_initialColumnWidths$ = initialColumnWidths.current) === null || _initialColumnWidths$ === void 0 ? void 0 : _initialColumnWidths$[cellWidthId];
|
|
170
170
|
var currentWidth = (_columnWidths$current = columnWidths.current) === null || _columnWidths$current === void 0 ? void 0 : _columnWidths$current[cellWidthId];
|
|
171
|
-
var cellWidth = currentWidth ||
|
|
172
|
-
var isControlled = typeof
|
|
171
|
+
var cellWidth = currentWidth || width || 0;
|
|
172
|
+
var isControlled = typeof width === 'number' && typeof onResize === 'function';
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* in resizable mode,
|
|
176
176
|
* if width !== initialColumnWidth, use current column width and update cache.
|
|
177
177
|
*/
|
|
178
|
-
if (resizable && (initialColumnWidth ||
|
|
178
|
+
if (resizable && (initialColumnWidth || width) && initialColumnWidth !== width) {
|
|
179
179
|
// initial or update initialColumnWidth cache.
|
|
180
|
-
initialColumnWidths.current[cellWidthId] =
|
|
180
|
+
initialColumnWidths.current[cellWidthId] = width;
|
|
181
181
|
/**
|
|
182
182
|
* if currentWidth exist, update columnWidths cache.
|
|
183
183
|
*/
|
|
184
184
|
if (currentWidth) {
|
|
185
|
-
columnWidths.current[cellWidthId] =
|
|
185
|
+
columnWidths.current[cellWidthId] = width;
|
|
186
186
|
// update cellWidth
|
|
187
|
-
cellWidth =
|
|
187
|
+
cellWidth = width;
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
if (tableWidth.current && flexGrow && totalFlexGrow) {
|
|
@@ -200,7 +200,7 @@ var useCellDescriptor = function useCellDescriptor(props) {
|
|
|
200
200
|
left: left,
|
|
201
201
|
headerHeight: headerHeight,
|
|
202
202
|
key: index,
|
|
203
|
-
width: isControlled ?
|
|
203
|
+
width: isControlled ? width : cellWidth,
|
|
204
204
|
height: typeof rowHeight === 'function' ? rowHeight() : rowHeight,
|
|
205
205
|
firstColumn: index === 0,
|
|
206
206
|
lastColumn: index === count - 1
|
|
@@ -227,9 +227,9 @@ var useCellDescriptor = function useCellDescriptor(props) {
|
|
|
227
227
|
onColumnResizeMove: handleColumnResizeMove
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
|
-
headerCells.push(
|
|
230
|
+
headerCells.push(/*#__PURE__*/_react["default"].cloneElement(headerCell, (0, _extends2["default"])({}, cellProps, headerCellProps)));
|
|
231
231
|
}
|
|
232
|
-
bodyCells.push(
|
|
232
|
+
bodyCells.push(/*#__PURE__*/_react["default"].cloneElement(cell, cellProps));
|
|
233
233
|
left += cellWidth;
|
|
234
234
|
}
|
|
235
235
|
});
|
|
@@ -9,7 +9,9 @@ var _prefix = require("./prefix");
|
|
|
9
9
|
var _TableContext = _interopRequireDefault(require("../TableContext"));
|
|
10
10
|
// This is the only way I found to break circular references between ClassArray and ClassValue
|
|
11
11
|
// https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
|
|
12
|
+
|
|
12
13
|
//eslint-disable-line @typescript-eslint/no-empty-interface
|
|
14
|
+
|
|
13
15
|
/**
|
|
14
16
|
* Add a prefix to all classNames.
|
|
15
17
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qbs-react-grid",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "A React table component",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -43,7 +43,9 @@
|
|
|
43
43
|
"@rsuite/icons": "^1.0.0",
|
|
44
44
|
"classnames": "^2.3.1",
|
|
45
45
|
"dom-lib": "^3.1.3",
|
|
46
|
+
"i": "^0.3.7",
|
|
46
47
|
"lodash": "^4.17.21",
|
|
48
|
+
"npm": "^10.8.3",
|
|
47
49
|
"react-is": "^17.0.2",
|
|
48
50
|
"react-router-dom": "^6.21.0"
|
|
49
51
|
},
|
|
@@ -51,8 +53,8 @@
|
|
|
51
53
|
"prop-types": "^15.7.1",
|
|
52
54
|
"react": "^18.2.0",
|
|
53
55
|
"react-dom": "^18.2.0",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
+
"react-router-dom": "^6.21.0",
|
|
57
|
+
"rsuite": "^5.21.0"
|
|
56
58
|
},
|
|
57
59
|
"devDependencies": {
|
|
58
60
|
"@babel/cli": "^7.12.8",
|
|
@@ -77,7 +79,7 @@
|
|
|
77
79
|
"@types/react-dom": "^18.0.6",
|
|
78
80
|
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
|
79
81
|
"@typescript-eslint/parser": "^4.28.2",
|
|
80
|
-
"autoprefixer": "^
|
|
82
|
+
"autoprefixer": "^10.4.20",
|
|
81
83
|
"babel-loader": "^8.2.2",
|
|
82
84
|
"babel-plugin-date-fns": "^0.2.1",
|
|
83
85
|
"babel-plugin-istanbul": "^4.1.4",
|
|
@@ -87,7 +89,7 @@
|
|
|
87
89
|
"coveralls": "^3.1.0",
|
|
88
90
|
"cross-env": "^5.2.1",
|
|
89
91
|
"css-loader": "^0.23.1",
|
|
90
|
-
"cssnano": "^4.1.
|
|
92
|
+
"cssnano": "^4.1.11",
|
|
91
93
|
"cz-conventional-changelog": "^3.3.0",
|
|
92
94
|
"del": "^5.1.0",
|
|
93
95
|
"eslint": "^7.30.0",
|
|
@@ -102,7 +104,7 @@
|
|
|
102
104
|
"gulp": "^4.0.2",
|
|
103
105
|
"gulp-babel": "^8.0.0",
|
|
104
106
|
"gulp-less": "^5.0.0",
|
|
105
|
-
"gulp-postcss": "^
|
|
107
|
+
"gulp-postcss": "^10.0.0",
|
|
106
108
|
"gulp-rename": "^1.2.2",
|
|
107
109
|
"gulp-rtlcss": "^1.4.1",
|
|
108
110
|
"gulp-sourcemaps": "^2.6.4",
|
|
@@ -122,6 +124,8 @@
|
|
|
122
124
|
"less-loader": "^11.0.0",
|
|
123
125
|
"mini-css-extract-plugin": "^2.3.0",
|
|
124
126
|
"mocha": "^9.0.2",
|
|
127
|
+
"postcss": "^8.4.47",
|
|
128
|
+
"postcss-loader": "^8.1.1",
|
|
125
129
|
"prettier": "^2.3.2",
|
|
126
130
|
"prop-types": "^15.8.1",
|
|
127
131
|
"react": "^18.2.0",
|
|
@@ -133,6 +137,7 @@
|
|
|
133
137
|
"sinon": "^11.1.2",
|
|
134
138
|
"sinon-chai": "^3.7.0",
|
|
135
139
|
"style-loader": "^0.13.1",
|
|
140
|
+
"tailwindcss": "^3.4.12",
|
|
136
141
|
"ts-expect": "^1.3.0",
|
|
137
142
|
"typescript": "^4.5.5",
|
|
138
143
|
"url-loader": "^0.5.7",
|