qbs-react-grid 2.2.3 → 2.2.5

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.
Files changed (100) hide show
  1. package/dist/css/qbs-react-grid.css +1 -1
  2. package/dist/css/qbs-react-grid.min.css +1 -1
  3. package/dist/css/qbs-react-grid.min.css.map +1 -1
  4. package/es/Cell.js +1 -2
  5. package/es/Pagination.d.ts +0 -3
  6. package/es/Pagination.js +3 -8
  7. package/es/Table.d.ts +0 -3
  8. package/es/Table.js +12 -18
  9. package/es/index.d.ts +1 -1
  10. package/es/less/pagination.less +9 -9
  11. package/es/less/qbs-table.less +73 -205
  12. package/es/qbsTable/CustomTableCell.js +2 -13
  13. package/es/qbsTable/QbsTable.js +46 -124
  14. package/es/qbsTable/TableCardList.js +39 -52
  15. package/es/qbsTable/Toolbar.js +13 -62
  16. package/es/qbsTable/commontypes.d.ts +2 -30
  17. package/es/qbsTable/utilities/CardComponent.d.ts +0 -2
  18. package/es/qbsTable/utilities/CardComponent.js +3 -7
  19. package/es/qbsTable/utilities/CardMenuDropdown.d.ts +0 -2
  20. package/es/qbsTable/utilities/CardMenuDropdown.js +7 -7
  21. package/es/qbsTable/utilities/ColumShowHide.d.ts +0 -4
  22. package/es/qbsTable/utilities/ColumShowHide.js +6 -9
  23. package/es/qbsTable/utilities/SearchInput.d.ts +0 -1
  24. package/es/qbsTable/utilities/SearchInput.js +1 -3
  25. package/es/qbsTable/utilities/ToolTip.d.ts +1 -8
  26. package/es/qbsTable/utilities/ToolTip.js +31 -107
  27. package/es/qbsTable/utilities/empty.js +1 -1
  28. package/es/qbsTable/utilities/icons.d.ts +0 -3
  29. package/es/qbsTable/utilities/icons.js +1 -65
  30. package/es/qbsTable/utilities/tablecalc.d.ts +1 -1
  31. package/es/qbsTable/utilities/tablecalc.js +2 -7
  32. package/es/utils/useCellDescriptor.js +1 -0
  33. package/es/utils/useScrollListener.d.ts +0 -1
  34. package/es/utils/useScrollListener.js +3 -5
  35. package/lib/Cell.js +1 -2
  36. package/lib/Pagination.d.ts +0 -3
  37. package/lib/Pagination.js +3 -8
  38. package/lib/Table.d.ts +0 -3
  39. package/lib/Table.js +12 -18
  40. package/lib/index.d.ts +1 -1
  41. package/lib/less/pagination.less +9 -9
  42. package/lib/less/qbs-table.less +73 -205
  43. package/lib/qbsTable/CustomTableCell.js +2 -13
  44. package/lib/qbsTable/QbsTable.js +46 -124
  45. package/lib/qbsTable/TableCardList.js +39 -52
  46. package/lib/qbsTable/Toolbar.js +12 -61
  47. package/lib/qbsTable/commontypes.d.ts +2 -30
  48. package/lib/qbsTable/utilities/CardComponent.d.ts +0 -2
  49. package/lib/qbsTable/utilities/CardComponent.js +3 -7
  50. package/lib/qbsTable/utilities/CardMenuDropdown.d.ts +0 -2
  51. package/lib/qbsTable/utilities/CardMenuDropdown.js +5 -6
  52. package/lib/qbsTable/utilities/ColumShowHide.d.ts +0 -4
  53. package/lib/qbsTable/utilities/ColumShowHide.js +6 -9
  54. package/lib/qbsTable/utilities/SearchInput.d.ts +0 -1
  55. package/lib/qbsTable/utilities/SearchInput.js +1 -3
  56. package/lib/qbsTable/utilities/ToolTip.d.ts +1 -8
  57. package/lib/qbsTable/utilities/ToolTip.js +30 -107
  58. package/lib/qbsTable/utilities/empty.js +1 -1
  59. package/lib/qbsTable/utilities/icons.d.ts +0 -3
  60. package/lib/qbsTable/utilities/icons.js +3 -70
  61. package/lib/qbsTable/utilities/tablecalc.d.ts +1 -1
  62. package/lib/qbsTable/utilities/tablecalc.js +2 -7
  63. package/lib/utils/useCellDescriptor.js +1 -0
  64. package/lib/utils/useScrollListener.d.ts +0 -1
  65. package/lib/utils/useScrollListener.js +3 -5
  66. package/package.json +2 -2
  67. package/src/Cell.tsx +1 -3
  68. package/src/HeaderCell.tsx +1 -0
  69. package/src/Pagination.tsx +3 -10
  70. package/src/Table.tsx +10 -23
  71. package/src/customSelect.tsx +88 -88
  72. package/src/index.ts +1 -1
  73. package/src/less/pagination.less +9 -9
  74. package/src/less/qbs-table.less +73 -205
  75. package/src/qbsTable/CustomTableCell.tsx +9 -31
  76. package/src/qbsTable/QbsTable.tsx +25 -101
  77. package/src/qbsTable/TableCardList.tsx +19 -35
  78. package/src/qbsTable/Toolbar.tsx +11 -53
  79. package/src/qbsTable/commontypes.ts +1 -32
  80. package/src/qbsTable/utilities/CardComponent.tsx +2 -7
  81. package/src/qbsTable/utilities/CardMenuDropdown.tsx +6 -11
  82. package/src/qbsTable/utilities/ColumShowHide.tsx +6 -33
  83. package/src/qbsTable/utilities/SearchInput.tsx +1 -3
  84. package/src/qbsTable/utilities/ToolTip.tsx +27 -138
  85. package/src/qbsTable/utilities/empty.tsx +2 -2
  86. package/src/qbsTable/utilities/icons.tsx +1 -78
  87. package/src/qbsTable/utilities/tablecalc.ts +2 -8
  88. package/src/utils/useCellDescriptor.ts +1 -0
  89. package/src/utils/useScrollListener.ts +3 -13
  90. package/src/utils/useTableRows.ts +1 -1
  91. package/es/qbsTable/labels.d.ts +0 -48
  92. package/es/qbsTable/labels.js +0 -34
  93. package/es/qbsTable/utilities/VerticalDropDownMenu.d.ts +0 -13
  94. package/es/qbsTable/utilities/VerticalDropDownMenu.js +0 -166
  95. package/lib/qbsTable/labels.d.ts +0 -48
  96. package/lib/qbsTable/labels.js +0 -42
  97. package/lib/qbsTable/utilities/VerticalDropDownMenu.d.ts +0 -13
  98. package/lib/qbsTable/utilities/VerticalDropDownMenu.js +0 -174
  99. package/src/qbsTable/labels.ts +0 -58
  100. package/src/qbsTable/utilities/VerticalDropDownMenu.tsx +0 -187
@@ -1,48 +0,0 @@
1
- export interface QbsTableLabels {
2
- search?: string;
3
- searchAriaLabel?: string;
4
- clear?: string;
5
- selectedItems?: string;
6
- switchToDefaultView?: string;
7
- switchToRelaxedView?: string;
8
- switchToFullScreen?: string;
9
- switchToTableView?: string;
10
- switchToCardView?: string;
11
- noDataFound?: string;
12
- showingRange?: (start: number, end: number, total: number) => string;
13
- itemsPerPage?: string;
14
- fixedColumns?: string;
15
- visibleColumns?: string;
16
- availableColumns?: string;
17
- resetToDefault?: string;
18
- save?: string;
19
- viewMore?: string;
20
- viewLess?: string;
21
- actions?: string;
22
- }
23
- export declare const DEFAULT_QBS_TABLE_LABELS: Required<Omit<QbsTableLabels, 'showingRange'>> & {
24
- showingRange: (start: number, end: number, total: number) => string;
25
- };
26
- export declare const mergeLabels: (labels?: QbsTableLabels) => {
27
- showingRange: (start: number, end: number, total: number) => string;
28
- search: string;
29
- searchAriaLabel: string;
30
- clear: string;
31
- selectedItems: string;
32
- switchToDefaultView: string;
33
- switchToRelaxedView: string;
34
- switchToFullScreen: string;
35
- switchToTableView: string;
36
- switchToCardView: string;
37
- noDataFound: string;
38
- itemsPerPage: string;
39
- fixedColumns: string;
40
- visibleColumns: string;
41
- availableColumns: string;
42
- resetToDefault: string;
43
- save: string;
44
- viewMore: string;
45
- viewLess: string;
46
- actions: string;
47
- };
48
- export declare const formatSelectedItems: (selectedItemsLabel: string, count: number) => string;
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- exports.__esModule = true;
5
- exports.mergeLabels = exports.formatSelectedItems = exports.DEFAULT_QBS_TABLE_LABELS = void 0;
6
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
7
- var DEFAULT_QBS_TABLE_LABELS = {
8
- search: 'Search',
9
- searchAriaLabel: 'Search',
10
- clear: 'Clear',
11
- selectedItems: 'Selected Items',
12
- switchToDefaultView: 'Switch to Default View',
13
- switchToRelaxedView: 'Switch to Relaxed View',
14
- switchToFullScreen: 'Switch to Full Screen',
15
- switchToTableView: 'Switch to Table View',
16
- switchToCardView: 'Switch to Card View',
17
- noDataFound: 'No Data Found',
18
- showingRange: function showingRange(start, end, total) {
19
- return "Showing " + start + " to " + end + " of " + total;
20
- },
21
- itemsPerPage: 'Items per page',
22
- fixedColumns: 'FIXED COLUMNS',
23
- visibleColumns: 'VISIBLE COLUMNS',
24
- availableColumns: 'AVAILABLE COLUMNS',
25
- resetToDefault: 'Reset to default',
26
- save: 'Save',
27
- viewMore: 'View More',
28
- viewLess: 'View Less',
29
- actions: 'Actions'
30
- };
31
- exports.DEFAULT_QBS_TABLE_LABELS = DEFAULT_QBS_TABLE_LABELS;
32
- var mergeLabels = function mergeLabels(labels) {
33
- var _labels$showingRange;
34
- return (0, _extends2["default"])({}, DEFAULT_QBS_TABLE_LABELS, labels, {
35
- showingRange: (_labels$showingRange = labels === null || labels === void 0 ? void 0 : labels.showingRange) != null ? _labels$showingRange : DEFAULT_QBS_TABLE_LABELS.showingRange
36
- });
37
- };
38
- exports.mergeLabels = mergeLabels;
39
- var formatSelectedItems = function formatSelectedItems(selectedItemsLabel, count) {
40
- return selectedItemsLabel + "(" + count + ") ";
41
- };
42
- exports.formatSelectedItems = formatSelectedItems;
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { ActionProps } from '../commontypes';
3
- type Props = {
4
- actionDropDown: ActionProps[];
5
- handleMenuActions?: (slug: ActionProps, rowData?: any) => void;
6
- rowData?: any;
7
- dataTheme?: string;
8
- tableBodyRef: React.RefObject<HTMLDivElement>;
9
- rowIndex?: number;
10
- wheelWrapperRef?: React.RefObject<HTMLDivElement>;
11
- };
12
- declare const VerticalMenuDropdown: React.FC<Props>;
13
- export default VerticalMenuDropdown;
@@ -1,174 +0,0 @@
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 _reactDom = _interopRequireDefault(require("react-dom"));
8
- var _icons = require("./icons");
9
- var _ToolTip = _interopRequireDefault(require("./ToolTip"));
10
- 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); }
11
- 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; }
12
- function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
- var VerticalMenuDropdown = function VerticalMenuDropdown(_ref) {
16
- var actionDropDown = _ref.actionDropDown,
17
- handleMenuActions = _ref.handleMenuActions,
18
- rowData = _ref.rowData,
19
- tableBodyRef = _ref.tableBodyRef,
20
- rowIndex = _ref.rowIndex;
21
- var _useState = (0, _react.useState)(false),
22
- openMenu = _useState[0],
23
- setOpenMenu = _useState[1];
24
- var _useState2 = (0, _react.useState)({
25
- top: 0,
26
- left: 0
27
- }),
28
- position = _useState2[0],
29
- setPosition = _useState2[1];
30
- var menuButtonRef = (0, _react.useRef)(null);
31
- var menuRef = (0, _react.useRef)(null);
32
- (0, _react.useEffect)(function () {
33
- var handleClickOutside = function handleClickOutside(event) {
34
- if (menuRef.current && !menuRef.current.contains(event.target)) {
35
- setOpenMenu(false);
36
- }
37
- };
38
- var handleScroll = function handleScroll() {
39
- setOpenMenu(false);
40
- };
41
- document.addEventListener('click', handleClickOutside);
42
- window.addEventListener('scroll', handleScroll, true);
43
- // Use capture phase to catch all scrolls
44
-
45
- return function () {
46
- document.removeEventListener('click', handleClickOutside);
47
- window.removeEventListener('scroll', handleScroll, true);
48
- };
49
- }, []);
50
- (0, _react.useEffect)(function () {
51
- var handleStyleChange = function handleStyleChange() {
52
- setOpenMenu(false); // Close the dropdown
53
- };
54
- var scrollbarHandle = document.querySelector('.rs-table-scrollbar-handle');
55
- if (!scrollbarHandle) return;
56
- var observer = new MutationObserver(function (mutations) {
57
- for (var _iterator = _createForOfIteratorHelperLoose(mutations), _step; !(_step = _iterator()).done;) {
58
- var mutation = _step.value;
59
- if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
60
- handleStyleChange();
61
- }
62
- }
63
- });
64
- observer.observe(scrollbarHandle, {
65
- attributes: true,
66
- attributeFilter: ['style']
67
- });
68
- return function () {
69
- observer.disconnect();
70
- };
71
- }, [openMenu]);
72
- var handleMenuItemClick = function handleMenuItemClick(slug) {
73
- var _slug$action;
74
- handleMenuActions === null || handleMenuActions === void 0 ? void 0 : handleMenuActions(slug, rowData);
75
- (_slug$action = slug.action) === null || _slug$action === void 0 ? void 0 : _slug$action.call(slug, rowData);
76
- setOpenMenu(false);
77
- };
78
- var handleShowHideMenu = function handleShowHideMenu() {
79
- var _actionDropDown$filte, _actionDropDown$filte2;
80
- return (_actionDropDown$filte = actionDropDown === null || actionDropDown === void 0 ? void 0 : (_actionDropDown$filte2 = actionDropDown.filter(function (item) {
81
- var _item$hide;
82
- return !item.hidden && !(item !== null && item !== void 0 && (_item$hide = item.hide) !== null && _item$hide !== void 0 && _item$hide.call(item, rowData, rowIndex));
83
- })) === null || _actionDropDown$filte2 === void 0 ? void 0 : _actionDropDown$filte2.length) != null ? _actionDropDown$filte : 0;
84
- };
85
- var toggleMenu = function toggleMenu() {
86
- if (!openMenu && menuButtonRef.current) {
87
- var _tableBodyRef$current;
88
- var rect = menuButtonRef.current.getBoundingClientRect();
89
- var windowHeight = window.innerHeight;
90
- var menuHeight = (actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.filter(function (item) {
91
- var _item$hide2;
92
- return !item.hidden && !(item !== null && item !== void 0 && (_item$hide2 = item.hide) !== null && _item$hide2 !== void 0 && _item$hide2.call(item, rowData, rowIndex));
93
- }).length) * 40; // 40px per menu item
94
-
95
- // Get table boundaries for RTL positioning
96
- var tableRect = (_tableBodyRef$current = tableBodyRef.current) === null || _tableBodyRef$current === void 0 ? void 0 : _tableBodyRef$current.getBoundingClientRect();
97
- var dropdownWidth = 200;
98
-
99
- // Check if there's enough space below
100
- var spaceBelow = windowHeight - rect.bottom;
101
- var leftPosition = rect.left - dropdownWidth;
102
-
103
- // For RTL, adjust positioning to stay within table bounds
104
- if (document.documentElement.dir === 'rtl' && tableRect) {
105
- // Calculate the right edge position for RTL
106
- var rightEdge = rect.right;
107
- leftPosition = Math.min(rightEdge, tableRect.right - dropdownWidth);
108
- // Ensure it doesn't go beyond the left edge of the table
109
- leftPosition = Math.max(leftPosition, tableRect.left);
110
- }
111
- if (spaceBelow >= menuHeight) {
112
- // Open below
113
- setPosition({
114
- top: rect.bottom + window.scrollY - rect.height,
115
- left: leftPosition
116
- });
117
- } else {
118
- // Open above
119
- setPosition({
120
- top: rect.top + window.scrollY - menuHeight,
121
- left: leftPosition
122
- });
123
- }
124
- }
125
- setTimeout(function () {
126
- setOpenMenu(function (prev) {
127
- return !prev;
128
- });
129
- }, 200);
130
- };
131
- var portalTarget = document.getElementById('portal-root');
132
- var dropdownContent = /*#__PURE__*/_react["default"].createElement("div", {
133
- className: "absolute z-[60] min-w-48 rounded-md vertical-menu-dropdown-content",
134
- ref: menuRef,
135
- style: {
136
- width: 200,
137
- top: position.top,
138
- left: position.left,
139
- position: 'absolute'
140
- }
141
- }, /*#__PURE__*/_react["default"].createElement("div", {
142
- className: "py-1"
143
- }, actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.map(function (item) {
144
- var _item$hide3;
145
- return !(item !== null && item !== void 0 && item.hidden) && !(item !== null && item !== void 0 && (_item$hide3 = item.hide) !== null && _item$hide3 !== void 0 && _item$hide3.call(item, rowData, rowIndex)) ? /*#__PURE__*/_react["default"].createElement("div", {
146
- key: item.title,
147
- className: "vertical-menu-item px-4 py-2 text-sm text-base-black hover:bg-gray-light-1 cursor-pointer flex items-center gap-2 transition-colors",
148
- onClick: function onClick(e) {
149
- var _item$action;
150
- e.preventDefault();
151
- (_item$action = item.action) === null || _item$action === void 0 ? void 0 : _item$action.call(item, item);
152
- handleMenuItemClick(item);
153
- }
154
- }, /*#__PURE__*/_react["default"].createElement(_ToolTip["default"], {
155
- title: item.toolTip,
156
- tableBodyRef: tableBodyRef
157
- }, /*#__PURE__*/_react["default"].createElement("div", {
158
- className: "vertical-menu-icon-title flex items-center gap-2"
159
- }, (item === null || item === void 0 ? void 0 : item.icon) && /*#__PURE__*/_react["default"].createElement("span", {
160
- className: "vertical-menu-icon"
161
- }, item.icon), /*#__PURE__*/_react["default"].createElement("span", {
162
- className: "vertical-menu-title"
163
- }, item.title)))) : null;
164
- })));
165
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
166
- className: "inline-block vertical-menu-dropdown-wrapper"
167
- }, handleShowHideMenu() > 0 && /*#__PURE__*/_react["default"].createElement("button", {
168
- className: "vertical-menu-trigger-button p-2 rounded text-base-gray hover:bg-gray-light-1 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",
169
- onClick: toggleMenu,
170
- ref: menuButtonRef
171
- }, /*#__PURE__*/_react["default"].createElement(_icons.ThreeDotIcon, null))), openMenu && portalTarget && /*#__PURE__*/_reactDom["default"].createPortal(dropdownContent, portalTarget));
172
- };
173
- var _default = VerticalMenuDropdown;
174
- exports["default"] = _default;
@@ -1,58 +0,0 @@
1
- export interface QbsTableLabels {
2
- search?: string;
3
- searchAriaLabel?: string;
4
- clear?: string;
5
- selectedItems?: string;
6
- switchToDefaultView?: string;
7
- switchToRelaxedView?: string;
8
- switchToFullScreen?: string;
9
- switchToTableView?: string;
10
- switchToCardView?: string;
11
- noDataFound?: string;
12
- showingRange?: (start: number, end: number, total: number) => string;
13
- itemsPerPage?: string;
14
- fixedColumns?: string;
15
- visibleColumns?: string;
16
- availableColumns?: string;
17
- resetToDefault?: string;
18
- save?: string;
19
- viewMore?: string;
20
- viewLess?: string;
21
- actions?: string;
22
- }
23
-
24
- export const DEFAULT_QBS_TABLE_LABELS: Required<
25
- Omit<QbsTableLabels, 'showingRange'>
26
- > & {
27
- showingRange: (start: number, end: number, total: number) => string;
28
- } = {
29
- search: 'Search',
30
- searchAriaLabel: 'Search',
31
- clear: 'Clear',
32
- selectedItems: 'Selected Items',
33
- switchToDefaultView: 'Switch to Default View',
34
- switchToRelaxedView: 'Switch to Relaxed View',
35
- switchToFullScreen: 'Switch to Full Screen',
36
- switchToTableView: 'Switch to Table View',
37
- switchToCardView: 'Switch to Card View',
38
- noDataFound: 'No Data Found',
39
- showingRange: (start, end, total) => `Showing ${start} to ${end} of ${total}`,
40
- itemsPerPage: 'Items per page',
41
- fixedColumns: 'FIXED COLUMNS',
42
- visibleColumns: 'VISIBLE COLUMNS',
43
- availableColumns: 'AVAILABLE COLUMNS',
44
- resetToDefault: 'Reset to default',
45
- save: 'Save',
46
- viewMore: 'View More',
47
- viewLess: 'View Less',
48
- actions: 'Actions'
49
- };
50
-
51
- export const mergeLabels = (labels?: QbsTableLabels) => ({
52
- ...DEFAULT_QBS_TABLE_LABELS,
53
- ...labels,
54
- showingRange: labels?.showingRange ?? DEFAULT_QBS_TABLE_LABELS.showingRange
55
- });
56
-
57
- export const formatSelectedItems = (selectedItemsLabel: string, count: number) =>
58
- `${selectedItemsLabel}(${count}) `;
@@ -1,187 +0,0 @@
1
- import React, { useEffect, useRef, useState } from 'react';
2
- import ReactDOM from 'react-dom';
3
-
4
- import { ActionProps } from '../commontypes';
5
- import { ThreeDotIcon } from './icons';
6
- import TooltipComponent from './ToolTip';
7
-
8
- type Props = {
9
- actionDropDown: ActionProps[];
10
- handleMenuActions?: (slug: ActionProps, rowData?: any) => void;
11
- rowData?: any;
12
- dataTheme?: string;
13
- tableBodyRef: React.RefObject<HTMLDivElement>;
14
- rowIndex?: number;
15
- wheelWrapperRef?: React.RefObject<HTMLDivElement>;
16
- };
17
-
18
- const VerticalMenuDropdown: React.FC<Props> = ({
19
- actionDropDown,
20
- handleMenuActions,
21
- rowData,
22
- tableBodyRef,
23
- rowIndex
24
- }) => {
25
- const [openMenu, setOpenMenu] = useState(false);
26
- const [position, setPosition] = useState({ top: 0, left: 0 });
27
- const menuButtonRef = useRef<HTMLButtonElement | null>(null);
28
- const menuRef = useRef<HTMLDivElement | null>(null);
29
-
30
- useEffect(() => {
31
- const handleClickOutside = (event: MouseEvent) => {
32
- if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
33
- setOpenMenu(false);
34
- }
35
- };
36
- const handleScroll = () => {
37
- setOpenMenu(false);
38
- };
39
-
40
- document.addEventListener('click', handleClickOutside);
41
- window.addEventListener('scroll', handleScroll, true);
42
- // Use capture phase to catch all scrolls
43
-
44
- return () => {
45
- document.removeEventListener('click', handleClickOutside);
46
- window.removeEventListener('scroll', handleScroll, true);
47
- };
48
- }, []);
49
- useEffect(() => {
50
- const handleStyleChange = () => {
51
- setOpenMenu(false); // Close the dropdown
52
- };
53
-
54
- const scrollbarHandle = document.querySelector('.rs-table-scrollbar-handle');
55
- if (!scrollbarHandle) return;
56
-
57
- const observer = new MutationObserver(mutations => {
58
- for (const mutation of mutations) {
59
- if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
60
- handleStyleChange();
61
- }
62
- }
63
- });
64
-
65
- observer.observe(scrollbarHandle, {
66
- attributes: true,
67
- attributeFilter: ['style']
68
- });
69
-
70
- return () => {
71
- observer.disconnect();
72
- };
73
- }, [openMenu]);
74
-
75
- const handleMenuItemClick = (slug: ActionProps) => {
76
- handleMenuActions?.(slug, rowData);
77
- slug.action?.(rowData);
78
- setOpenMenu(false);
79
- };
80
-
81
- const handleShowHideMenu = () => {
82
- return (
83
- actionDropDown?.filter(item => !item.hidden && !item?.hide?.(rowData, rowIndex))?.length ?? 0
84
- );
85
- };
86
-
87
- const toggleMenu = () => {
88
- if (!openMenu && menuButtonRef.current) {
89
- const rect = menuButtonRef.current.getBoundingClientRect();
90
- const windowHeight = window.innerHeight;
91
- const menuHeight =
92
- actionDropDown?.filter(item => !item.hidden && !item?.hide?.(rowData, rowIndex)).length *
93
- 40; // 40px per menu item
94
-
95
- // Get table boundaries for RTL positioning
96
- const tableRect = tableBodyRef.current?.getBoundingClientRect();
97
- const dropdownWidth = 200;
98
-
99
- // Check if there's enough space below
100
- const spaceBelow = windowHeight - rect.bottom;
101
-
102
- let leftPosition = rect.left - dropdownWidth;
103
-
104
- // For RTL, adjust positioning to stay within table bounds
105
- if (document.documentElement.dir === 'rtl' && tableRect) {
106
- // Calculate the right edge position for RTL
107
- const rightEdge = rect.right;
108
- leftPosition = Math.min(rightEdge, tableRect.right - dropdownWidth);
109
- // Ensure it doesn't go beyond the left edge of the table
110
- leftPosition = Math.max(leftPosition, tableRect.left);
111
- }
112
-
113
- if (spaceBelow >= menuHeight) {
114
- // Open below
115
- setPosition({
116
- top: rect.bottom + window.scrollY - rect.height,
117
- left: leftPosition
118
- });
119
- } else {
120
- // Open above
121
- setPosition({
122
- top: rect.top + window.scrollY - menuHeight,
123
- left: leftPosition
124
- });
125
- }
126
- }
127
- setTimeout(() => {
128
- setOpenMenu(prev => !prev);
129
- }, 200);
130
- };
131
-
132
- const portalTarget = document.getElementById('portal-root');
133
- const dropdownContent = (
134
- <div
135
- className="absolute z-[60] min-w-48 rounded-md vertical-menu-dropdown-content"
136
- ref={menuRef}
137
- style={{
138
- width: 200,
139
- top: position.top,
140
- left: position.left,
141
- position: 'absolute'
142
- }}
143
- >
144
- <div className="py-1">
145
- {actionDropDown?.map(item =>
146
- !item?.hidden && !item?.hide?.(rowData, rowIndex) ? (
147
- <div
148
- key={item.title}
149
- className="vertical-menu-item px-4 py-2 text-sm text-base-black hover:bg-gray-light-1 cursor-pointer flex items-center gap-2 transition-colors"
150
- onClick={e => {
151
- e.preventDefault();
152
- item.action?.(item);
153
- handleMenuItemClick(item);
154
- }}
155
- >
156
- <TooltipComponent title={item.toolTip} tableBodyRef={tableBodyRef}>
157
- <div className="vertical-menu-icon-title flex items-center gap-2">
158
- {item?.icon && <span className="vertical-menu-icon">{item.icon}</span>}
159
- <span className="vertical-menu-title">{item.title}</span>
160
- </div>
161
- </TooltipComponent>
162
- </div>
163
- ) : null
164
- )}
165
- </div>
166
- </div>
167
- );
168
-
169
- return (
170
- <>
171
- <div className="inline-block vertical-menu-dropdown-wrapper">
172
- {handleShowHideMenu() > 0 && (
173
- <button
174
- className="vertical-menu-trigger-button p-2 rounded text-base-gray hover:bg-gray-light-1 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
175
- onClick={toggleMenu}
176
- ref={menuButtonRef}
177
- >
178
- <ThreeDotIcon />
179
- </button>
180
- )}
181
- </div>
182
- {openMenu && portalTarget && ReactDOM.createPortal(dropdownContent, portalTarget)}
183
- </>
184
- );
185
- };
186
-
187
- export default VerticalMenuDropdown;