qbs-react-grid 2.2.4 → 2.2.6

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 +15 -11
  13. package/es/qbsTable/QbsTable.js +48 -124
  14. package/es/qbsTable/TableCardList.js +41 -52
  15. package/es/qbsTable/Toolbar.js +13 -62
  16. package/es/qbsTable/commontypes.d.ts +3 -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/VerticalDropDownMenu.d.ts +7 -9
  28. package/es/qbsTable/utilities/VerticalDropDownMenu.js +71 -63
  29. package/es/qbsTable/utilities/empty.js +1 -1
  30. package/es/qbsTable/utilities/icons.d.ts +0 -3
  31. package/es/qbsTable/utilities/icons.js +1 -65
  32. package/es/qbsTable/utilities/tablecalc.d.ts +1 -1
  33. package/es/qbsTable/utilities/tablecalc.js +2 -7
  34. package/es/utils/useCellDescriptor.js +1 -0
  35. package/es/utils/useScrollListener.d.ts +0 -1
  36. package/es/utils/useScrollListener.js +3 -5
  37. package/lib/Cell.js +1 -2
  38. package/lib/Pagination.d.ts +0 -3
  39. package/lib/Pagination.js +3 -8
  40. package/lib/Table.d.ts +0 -3
  41. package/lib/Table.js +12 -18
  42. package/lib/index.d.ts +1 -1
  43. package/lib/less/pagination.less +9 -9
  44. package/lib/less/qbs-table.less +73 -205
  45. package/lib/qbsTable/CustomTableCell.js +15 -11
  46. package/lib/qbsTable/QbsTable.js +48 -124
  47. package/lib/qbsTable/TableCardList.js +41 -52
  48. package/lib/qbsTable/Toolbar.js +12 -61
  49. package/lib/qbsTable/commontypes.d.ts +3 -30
  50. package/lib/qbsTable/utilities/CardComponent.d.ts +0 -2
  51. package/lib/qbsTable/utilities/CardComponent.js +3 -7
  52. package/lib/qbsTable/utilities/CardMenuDropdown.d.ts +0 -2
  53. package/lib/qbsTable/utilities/CardMenuDropdown.js +5 -6
  54. package/lib/qbsTable/utilities/ColumShowHide.d.ts +0 -4
  55. package/lib/qbsTable/utilities/ColumShowHide.js +6 -9
  56. package/lib/qbsTable/utilities/SearchInput.d.ts +0 -1
  57. package/lib/qbsTable/utilities/SearchInput.js +1 -3
  58. package/lib/qbsTable/utilities/ToolTip.d.ts +1 -8
  59. package/lib/qbsTable/utilities/ToolTip.js +30 -107
  60. package/lib/qbsTable/utilities/VerticalDropDownMenu.d.ts +7 -9
  61. package/lib/qbsTable/utilities/VerticalDropDownMenu.js +71 -63
  62. package/lib/qbsTable/utilities/empty.js +1 -1
  63. package/lib/qbsTable/utilities/icons.d.ts +0 -3
  64. package/lib/qbsTable/utilities/icons.js +3 -70
  65. package/lib/qbsTable/utilities/tablecalc.d.ts +1 -1
  66. package/lib/qbsTable/utilities/tablecalc.js +2 -7
  67. package/lib/utils/useCellDescriptor.js +1 -0
  68. package/lib/utils/useScrollListener.d.ts +0 -1
  69. package/lib/utils/useScrollListener.js +3 -5
  70. package/package.json +10 -2
  71. package/src/Cell.tsx +1 -3
  72. package/src/HeaderCell.tsx +1 -0
  73. package/src/Pagination.tsx +3 -10
  74. package/src/Table.tsx +10 -23
  75. package/src/customSelect.tsx +88 -88
  76. package/src/index.ts +1 -1
  77. package/src/less/pagination.less +9 -9
  78. package/src/less/qbs-table.less +73 -205
  79. package/src/qbsTable/CustomTableCell.tsx +23 -27
  80. package/src/qbsTable/QbsTable.tsx +26 -100
  81. package/src/qbsTable/TableCardList.tsx +20 -34
  82. package/src/qbsTable/Toolbar.tsx +11 -53
  83. package/src/qbsTable/commontypes.ts +2 -32
  84. package/src/qbsTable/utilities/CardComponent.tsx +2 -7
  85. package/src/qbsTable/utilities/CardMenuDropdown.tsx +6 -11
  86. package/src/qbsTable/utilities/ColumShowHide.tsx +6 -33
  87. package/src/qbsTable/utilities/SearchInput.tsx +1 -3
  88. package/src/qbsTable/utilities/ToolTip.tsx +27 -138
  89. package/src/qbsTable/utilities/VerticalDropDownMenu.tsx +89 -74
  90. package/src/qbsTable/utilities/empty.tsx +2 -2
  91. package/src/qbsTable/utilities/icons.tsx +1 -78
  92. package/src/qbsTable/utilities/tablecalc.ts +2 -8
  93. package/src/utils/useCellDescriptor.ts +1 -0
  94. package/src/utils/useScrollListener.ts +3 -13
  95. package/src/utils/useTableRows.ts +1 -1
  96. package/es/qbsTable/labels.d.ts +0 -48
  97. package/es/qbsTable/labels.js +0 -34
  98. package/lib/qbsTable/labels.d.ts +0 -48
  99. package/lib/qbsTable/labels.js +0 -42
  100. package/src/qbsTable/labels.ts +0 -58
@@ -13,6 +13,7 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Sy
13
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
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
15
  var VerticalMenuDropdown = function VerticalMenuDropdown(_ref) {
16
+ var _actionDropDown$filte2, _document$getElementB;
16
17
  var actionDropDown = _ref.actionDropDown,
17
18
  handleMenuActions = _ref.handleMenuActions,
18
19
  rowData = _ref.rowData,
@@ -29,35 +30,74 @@ var VerticalMenuDropdown = function VerticalMenuDropdown(_ref) {
29
30
  setPosition = _useState2[1];
30
31
  var menuButtonRef = (0, _react.useRef)(null);
31
32
  var menuRef = (0, _react.useRef)(null);
33
+ var updateMenuPosition = function updateMenuPosition() {
34
+ var _actionDropDown$filte;
35
+ if (!menuButtonRef.current) return;
36
+ var rect = menuButtonRef.current.getBoundingClientRect();
37
+ var viewportPadding = 8;
38
+ var menuGap = 4;
39
+ var visibleItems = (_actionDropDown$filte = actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.filter(function (item) {
40
+ var _item$hide$call, _item$hide;
41
+ return !item.hidden && !((_item$hide$call = (_item$hide = item.hide) === null || _item$hide === void 0 ? void 0 : _item$hide.call(item, rowData, rowIndex)) != null ? _item$hide$call : false);
42
+ })) != null ? _actionDropDown$filte : [];
43
+ var menuWidth = menuRef.current && menuRef.current.offsetWidth > 0 ? menuRef.current.offsetWidth : Math.max(120, visibleItems.length * 48);
44
+ var menuHeight = visibleItems.length * 40;
45
+ var spaceBelow = window.innerHeight - rect.bottom;
46
+ var openBelow = spaceBelow >= menuHeight + menuGap;
47
+ var left = rect.left;
48
+ if (left + menuWidth > window.innerWidth - viewportPadding) {
49
+ left = Math.max(viewportPadding, rect.right - menuWidth);
50
+ }
51
+ setPosition({
52
+ top: openBelow ? rect.bottom + menuGap : rect.top - menuHeight - menuGap,
53
+ left: left
54
+ });
55
+ };
56
+ (0, _react.useEffect)(function () {
57
+ if (!openMenu) return;
58
+ updateMenuPosition();
59
+ var frame = requestAnimationFrame(function () {
60
+ return updateMenuPosition();
61
+ });
62
+ var resizeObserver = menuRef.current && typeof ResizeObserver !== 'undefined' ? new ResizeObserver(function () {
63
+ return updateMenuPosition();
64
+ }) : null;
65
+ if (resizeObserver && menuRef.current) {
66
+ resizeObserver.observe(menuRef.current);
67
+ }
68
+ return function () {
69
+ cancelAnimationFrame(frame);
70
+ resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
71
+ };
72
+ }, [openMenu]);
32
73
  (0, _react.useEffect)(function () {
74
+ if (!openMenu) return;
33
75
  var handleClickOutside = function handleClickOutside(event) {
34
- if (menuRef.current && !menuRef.current.contains(event.target)) {
35
- setOpenMenu(false);
76
+ var _menuRef$current, _menuButtonRef$curren;
77
+ var target = event.target;
78
+ if ((_menuRef$current = menuRef.current) !== null && _menuRef$current !== void 0 && _menuRef$current.contains(target) || (_menuButtonRef$curren = menuButtonRef.current) !== null && _menuButtonRef$curren !== void 0 && _menuButtonRef$curren.contains(target)) {
79
+ return;
36
80
  }
81
+ setOpenMenu(false);
37
82
  };
38
83
  var handleScroll = function handleScroll() {
39
- setOpenMenu(false);
84
+ return setOpenMenu(false);
40
85
  };
41
86
  document.addEventListener('click', handleClickOutside);
42
87
  window.addEventListener('scroll', handleScroll, true);
43
- // Use capture phase to catch all scrolls
44
-
45
88
  return function () {
46
89
  document.removeEventListener('click', handleClickOutside);
47
90
  window.removeEventListener('scroll', handleScroll, true);
48
91
  };
49
- }, []);
92
+ }, [openMenu]);
50
93
  (0, _react.useEffect)(function () {
51
- var handleStyleChange = function handleStyleChange() {
52
- setOpenMenu(false); // Close the dropdown
53
- };
54
94
  var scrollbarHandle = document.querySelector('.rs-table-scrollbar-handle');
55
95
  if (!scrollbarHandle) return;
56
96
  var observer = new MutationObserver(function (mutations) {
57
97
  for (var _iterator = _createForOfIteratorHelperLoose(mutations), _step; !(_step = _iterator()).done;) {
58
98
  var mutation = _step.value;
59
99
  if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
60
- handleStyleChange();
100
+ setOpenMenu(false);
61
101
  }
62
102
  }
63
103
  });
@@ -66,7 +106,7 @@ var VerticalMenuDropdown = function VerticalMenuDropdown(_ref) {
66
106
  attributeFilter: ['style']
67
107
  });
68
108
  return function () {
69
- observer.disconnect();
109
+ return observer.disconnect();
70
110
  };
71
111
  }, [openMenu]);
72
112
  var handleMenuItemClick = function handleMenuItemClick(slug) {
@@ -75,65 +115,26 @@ var VerticalMenuDropdown = function VerticalMenuDropdown(_ref) {
75
115
  (_slug$action = slug.action) === null || _slug$action === void 0 ? void 0 : _slug$action.call(slug, rowData);
76
116
  setOpenMenu(false);
77
117
  };
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 _actionDropDown$filte3;
88
- var rect = menuButtonRef.current.getBoundingClientRect();
89
- var viewportPadding = 8;
90
- var menuGap = 4;
91
- var dropdownWidth = 200;
92
- var visibleItems = (_actionDropDown$filte3 = actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.filter(function (item) {
93
- var _item$hide2;
94
- return !item.hidden && !(item !== null && item !== void 0 && (_item$hide2 = item.hide) !== null && _item$hide2 !== void 0 && _item$hide2.call(item, rowData, rowIndex));
95
- })) != null ? _actionDropDown$filte3 : [];
96
- var menuHeight = visibleItems.length * 40;
97
- var spaceBelow = window.innerHeight - rect.bottom;
98
- var openBelow = spaceBelow >= menuHeight + menuGap;
99
-
100
- // Anchor to trigger; prefer opening toward inline-start (left in LTR).
101
- var left = rect.right - dropdownWidth;
102
- if (left < viewportPadding) {
103
- left = rect.left;
104
- }
105
- if (left + dropdownWidth > window.innerWidth - viewportPadding) {
106
- left = Math.max(viewportPadding, rect.left - dropdownWidth);
107
- }
108
- if (left + dropdownWidth > window.innerWidth - viewportPadding) {
109
- left = window.innerWidth - viewportPadding - dropdownWidth;
110
- }
111
- setPosition({
112
- top: openBelow ? rect.bottom + menuGap : rect.top - menuHeight - menuGap,
113
- left: left
114
- });
115
- }
116
- setTimeout(function () {
117
- setOpenMenu(function (prev) {
118
- return !prev;
119
- });
120
- }, 200);
121
- };
122
- var portalTarget = document.getElementById('portal-root');
118
+ var visibleCount = (_actionDropDown$filte2 = actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.filter(function (item) {
119
+ var _item$hide$call2, _item$hide2;
120
+ return !item.hidden && !((_item$hide$call2 = (_item$hide2 = item.hide) === null || _item$hide2 === void 0 ? void 0 : _item$hide2.call(item, rowData, rowIndex)) != null ? _item$hide$call2 : false);
121
+ }).length) != null ? _actionDropDown$filte2 : 0;
122
+ var portalTarget = (_document$getElementB = document.getElementById('portal-root')) != null ? _document$getElementB : document.body;
123
123
  var dropdownContent = /*#__PURE__*/_react["default"].createElement("div", {
124
124
  className: "absolute z-[60] min-w-48 rounded-md vertical-menu-dropdown-content",
125
125
  ref: menuRef,
126
126
  style: {
127
- width: 200,
128
127
  top: position.top,
129
128
  left: position.left,
130
- position: 'fixed'
129
+ position: 'fixed',
130
+ minWidth: 120,
131
+ width: 'max-content'
131
132
  }
132
133
  }, /*#__PURE__*/_react["default"].createElement("div", {
133
134
  className: "py-1"
134
135
  }, actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.map(function (item) {
135
- var _item$hide3;
136
- 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", {
136
+ var _item$hide$call3, _item$hide3;
137
+ return !item.hidden && !((_item$hide$call3 = (_item$hide3 = item.hide) === null || _item$hide3 === void 0 ? void 0 : _item$hide3.call(item, rowData, rowIndex)) != null ? _item$hide$call3 : false) ? /*#__PURE__*/_react["default"].createElement("div", {
137
138
  key: item.title,
138
139
  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",
139
140
  onClick: function onClick(e) {
@@ -147,7 +148,7 @@ var VerticalMenuDropdown = function VerticalMenuDropdown(_ref) {
147
148
  tableBodyRef: tableBodyRef
148
149
  }, /*#__PURE__*/_react["default"].createElement("div", {
149
150
  className: "vertical-menu-icon-title flex items-center gap-2"
150
- }, (item === null || item === void 0 ? void 0 : item.icon) && /*#__PURE__*/_react["default"].createElement("span", {
151
+ }, item.icon && /*#__PURE__*/_react["default"].createElement("span", {
151
152
  className: "vertical-menu-icon"
152
153
  }, item.icon), /*#__PURE__*/_react["default"].createElement("span", {
153
154
  className: "vertical-menu-title"
@@ -155,9 +156,16 @@ var VerticalMenuDropdown = function VerticalMenuDropdown(_ref) {
155
156
  })));
156
157
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
157
158
  className: "inline-block vertical-menu-dropdown-wrapper"
158
- }, handleShowHideMenu() > 0 && /*#__PURE__*/_react["default"].createElement("button", {
159
+ }, visibleCount > 0 && /*#__PURE__*/_react["default"].createElement("button", {
160
+ type: "button",
159
161
  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",
160
- onClick: toggleMenu,
162
+ onClick: function onClick(event) {
163
+ event.stopPropagation();
164
+ if (!openMenu) updateMenuPosition();
165
+ setOpenMenu(function (prev) {
166
+ return !prev;
167
+ });
168
+ },
161
169
  ref: menuButtonRef
162
170
  }, /*#__PURE__*/_react["default"].createElement(_icons.ThreeDotIcon, null))), openMenu && portalTarget && /*#__PURE__*/_reactDom["default"].createPortal(dropdownContent, portalTarget));
163
171
  };
@@ -75,7 +75,7 @@ var NoData = function NoData(_ref) {
75
75
  }), /*#__PURE__*/_react["default"].createElement("path", {
76
76
  fill: "#797979",
77
77
  d: "M47.365 57.417a.926.926 0 00.926-.927v-1.777a.926.926 0 10-1.852 0v1.777c0 .512.415.927.926.927zM104.183 57.417a.926.926 0 00.926-.927v-1.777a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 52.974a.926.926 0 00.926-.927V50.27a.926.926 0 00-1.852 0v1.777c0 .512.415.927.926.927zM104.183 52.974a.926.926 0 00.926-.927V50.27a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 44.088a.926.926 0 00.926-.927v-1.777a.926.926 0 10-1.852 0v1.777c0 .512.415.927.926.927zM104.183 44.088a.926.926 0 00.926-.927v-1.777a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 39.645a.926.926 0 00.926-.927v-1.777a.926.926 0 10-1.852 0v1.777c0 .512.415.927.926.927zM104.183 39.645a.926.926 0 00.926-.927v-1.777a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 35.202a.926.926 0 00.926-.927v-1.777a.926.926 0 10-1.852 0v1.777c0 .512.415.927.926.927zM104.183 35.202a.926.926 0 00.926-.927v-1.777a.926.926 0 00-1.852 0v1.777c0 .512.414.927.926.927zM47.365 30.758a.926.926 0 00.926-.926v-.888c0-.248.02-.49.057-.726a.926.926 0 00-1.83-.288c-.052.33-.08.67-.08 1.014v.888c0 .512.416.926.927.926zM104.183 30.758a.926.926 0 00.926-.926v-.888c0-.345-.027-.683-.079-1.014a.926.926 0 10-1.83.288c.037.236.057.478.057.726v.888c0 .512.414.926.926.926zM47.881 26.426a.926.926 0 001.294-.204c.286-.394.633-.74 1.026-1.026a.926.926 0 00-1.09-1.498c-.55.4-1.034.884-1.434 1.434a.926.926 0 00.204 1.294zM103.667 26.426a.926.926 0 00.204-1.294 6.509 6.509 0 00-1.434-1.434.926.926 0 00-1.09 1.498c.393.286.74.632 1.026 1.026a.926.926 0 001.294.204zM51.138 23.597c.08.506.554.851 1.059.772a4.67 4.67 0 01.726-.057h.914a.926.926 0 000-1.852h-.914c-.344 0-.683.026-1.014.078a.926.926 0 00-.77 1.06zM100.41 23.597a.927.927 0 00-.771-1.059 6.522 6.522 0 00-1.014-.078h-.914a.926.926 0 100 1.852h.914c.248 0 .49.02.726.057a.926.926 0 001.059-.772zM55.653 23.386c0 .511.415.926.926.926h1.828a.926.926 0 000-1.852H56.58a.926.926 0 00-.926.926zM60.223 23.386c0 .511.415.926.926.926h1.828a.926.926 0 000-1.852H61.15a.926.926 0 00-.926.926zM64.793 23.386c0 .511.415.926.926.926h1.829a.926.926 0 000-1.852h-1.829a.926.926 0 00-.926.926zM69.364 23.386c0 .511.414.926.926.926h1.828a.926.926 0 000-1.852H70.29a.926.926 0 00-.927.926zM73.934 23.386c0 .511.414.926.926.926h1.828a.926.926 0 000-1.852H74.86a.926.926 0 00-.926.926zM78.504 23.386c0 .511.415.926.926.926h1.828a.926.926 0 000-1.852H79.43a.926.926 0 00-.926.926zM83.074 23.386c0 .511.415.926.927.926h1.828a.926.926 0 000-1.852H84a.926.926 0 00-.927.926zM87.644 23.386c0 .511.415.926.927.926h1.828a.926.926 0 000-1.852H88.57a.926.926 0 00-.927.926zM92.215 23.386c0 .511.414.926.926.926h1.828a.926.926 0 000-1.852h-1.828a.926.926 0 00-.926.926zM72.178 36.453a1.39 1.39 0 10-1.965 1.965l3.797 3.797-3.797 3.798a1.39 1.39 0 001.965 1.965l3.797-3.798 3.798 3.798a1.39 1.39 0 001.965-1.965l-3.798-3.798 3.798-3.797a1.39 1.39 0 10-1.965-1.965l-3.798 3.797-3.797-3.797z"
78
- })), ' '), /*#__PURE__*/_react["default"].createElement("p", {
78
+ })), " ", ' '), /*#__PURE__*/_react["default"].createElement("p", {
79
79
  className: "text-center text-common font-bold text-blackAlt nodata-title"
80
80
  }, title), /*#__PURE__*/_react["default"].createElement("span", {
81
81
  className: "text-xxs font-medium text-grey-medium nodata-sub-title"
@@ -6,6 +6,3 @@ export declare const TableIcon: React.FC<any>;
6
6
  export declare const CardIcon: React.FC<any>;
7
7
  export declare const CardView: React.FC<any>;
8
8
  export declare const TableView: React.FC<any>;
9
- export declare const ExpandIcon: React.FC<any>;
10
- export declare const ContentView: React.FC<any>;
11
- export declare const DefaultView: 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.TableView = exports.TableIcon = exports.SettingsIcon = exports.ExpandIcon = exports.DefaultView = exports.ContentView = exports.CardView = exports.CardIcon = exports.ArrowUpIcon = void 0;
5
+ exports.ThreeDotIcon = exports.TableView = exports.TableIcon = exports.SettingsIcon = exports.CardView = 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", {
@@ -13,7 +13,7 @@ var ThreeDotIcon = function ThreeDotIcon() {
13
13
  xmlns: "http://www.w3.org/2000/svg"
14
14
  }, /*#__PURE__*/_react["default"].createElement("path", {
15
15
  d: "M2 2.16665L2 2.17498M2 7.99998L2 8.00831M2 13.8333L2 13.8416M2 2.99998C1.53976 2.99998 1.16667 2.62688 1.16667 2.16665C1.16667 1.70641 1.53976 1.33331 2 1.33331C2.46024 1.33331 2.83333 1.70641 2.83333 2.16665C2.83333 2.62688 2.46024 2.99998 2 2.99998ZM2 8.83331C1.53976 8.83331 1.16667 8.46022 1.16667 7.99998C1.16667 7.53974 1.53976 7.16665 2 7.16665C2.46024 7.16665 2.83333 7.53974 2.83333 7.99998C2.83333 8.46022 2.46024 8.83331 2 8.83331ZM2 14.6666C1.53976 14.6666 1.16666 14.2935 1.16666 13.8333C1.16666 13.3731 1.53976 13 2 13C2.46024 13 2.83333 13.3731 2.83333 13.8333C2.83333 14.2935 2.46024 14.6666 2 14.6666Z",
16
- stroke: "currentColor",
16
+ stroke: "#313131",
17
17
  strokeWidth: "1.5",
18
18
  strokeLinecap: "round",
19
19
  strokeLinejoin: "round"
@@ -137,71 +137,4 @@ var TableView = function TableView(_ref5) {
137
137
  strokeWidth: "1.5"
138
138
  }));
139
139
  };
140
- exports.TableView = TableView;
141
- var ExpandIcon = function ExpandIcon(_ref6) {
142
- var className = _ref6.className;
143
- return /*#__PURE__*/_react["default"].createElement("svg", {
144
- width: "16",
145
- height: "16",
146
- className: className,
147
- viewBox: "0 0 16 16",
148
- fill: "none",
149
- xmlns: "http://www.w3.org/2000/svg"
150
- }, /*#__PURE__*/_react["default"].createElement("path", {
151
- d: "M2.66797 5.33073V2.66406M2.66797 2.66406H5.33464M2.66797 2.66406L6.0013 5.9974M13.3346 5.33073V2.66406M13.3346 2.66406H10.668M13.3346 2.66406L10.0013 5.9974M2.66797 10.6641V13.3307M2.66797 13.3307H5.33464M2.66797 13.3307L6.0013 9.9974M13.3346 13.3307L10.0013 9.9974M13.3346 13.3307V10.6641M13.3346 13.3307H10.668",
152
- stroke: "#585858",
153
- strokeWidth: "1.5",
154
- strokeLinecap: "round",
155
- strokeLinejoin: "round"
156
- }));
157
- };
158
- exports.ExpandIcon = ExpandIcon;
159
- var ContentView = function ContentView(_ref7) {
160
- var className = _ref7.className;
161
- return /*#__PURE__*/_react["default"].createElement("svg", {
162
- width: "16",
163
- height: "17",
164
- className: className,
165
- viewBox: "0 0 16 17",
166
- fill: "none",
167
- xmlns: "http://www.w3.org/2000/svg"
168
- }, /*#__PURE__*/_react["default"].createElement("path", {
169
- d: "M4.00344 9.48438C3.24485 9.48438 2.94141 9.80804 2.94141 10.6122V12.6553C2.94141 13.4594 3.24485 13.7831 4.00344 13.7831H11.994C12.7526 13.7831 13.056 13.4594 13.056 12.6553V10.6122C13.056 9.80804 12.7526 9.48438 11.994 9.48438H4.00344Z",
170
- stroke: "#585858",
171
- strokeLinecap: "round",
172
- strokeLinejoin: "round"
173
- }), /*#__PURE__*/_react["default"].createElement("path", {
174
- d: "M4.00344 3.66406C3.24485 3.66406 2.94141 3.98773 2.94141 4.79184V6.835C2.94141 7.63911 3.24485 7.96278 4.00344 7.96278H11.994C12.7526 7.96278 13.056 7.63911 13.056 6.835V4.79184C13.056 3.98773 12.7526 3.66406 11.994 3.66406H4.00344Z",
175
- stroke: "#585858",
176
- strokeLinecap: "round",
177
- strokeLinejoin: "round"
178
- }));
179
- };
180
- exports.ContentView = ContentView;
181
- var DefaultView = function DefaultView(_ref8) {
182
- var className = _ref8.className;
183
- return /*#__PURE__*/_react["default"].createElement("svg", {
184
- width: "16",
185
- height: "17",
186
- className: className,
187
- viewBox: "0 0 16 17",
188
- fill: "none",
189
- xmlns: "http://www.w3.org/2000/svg"
190
- }, /*#__PURE__*/_react["default"].createElement("path", {
191
- fillRule: "evenodd",
192
- clipRule: "evenodd",
193
- d: "M2.39844 4.72969C2.39844 4.28786 2.75661 3.92969 3.19844 3.92969H12.7984C13.2403 3.92969 13.5984 4.28786 13.5984 4.72969C13.5984 5.17152 13.2403 5.52969 12.7984 5.52969H3.19844C2.75661 5.52969 2.39844 5.17152 2.39844 4.72969Z",
194
- fill: "#585858"
195
- }), /*#__PURE__*/_react["default"].createElement("path", {
196
- fillRule: "evenodd",
197
- clipRule: "evenodd",
198
- d: "M2.39844 8.72969C2.39844 8.28786 2.75661 7.92969 3.19844 7.92969H12.7984C13.2403 7.92969 13.5984 8.28786 13.5984 8.72969C13.5984 9.17152 13.2403 9.52969 12.7984 9.52969H3.19844C2.75661 9.52969 2.39844 9.17152 2.39844 8.72969Z",
199
- fill: "#585858"
200
- }), /*#__PURE__*/_react["default"].createElement("path", {
201
- fillRule: "evenodd",
202
- clipRule: "evenodd",
203
- d: "M2.39844 12.7297C2.39844 12.2879 2.75661 11.9297 3.19844 11.9297H12.7984C13.2403 11.9297 13.5984 12.2879 13.5984 12.7297C13.5984 13.1715 13.2403 13.5297 12.7984 13.5297H3.19844C2.75661 13.5297 2.39844 13.1715 2.39844 12.7297Z",
204
- fill: "#585858"
205
- }));
206
- };
207
- exports.DefaultView = DefaultView;
140
+ exports.TableView = TableView;
@@ -1 +1 @@
1
- export declare function getRowDisplayRange(totalRows: number, rowsPerPage: number, pageNumber: number, formatRange?: (start: number, end: number, total: number) => string): string;
1
+ export declare function getRowDisplayRange(totalRows: number, rowsPerPage: number, pageNumber: number): string;
@@ -2,13 +2,8 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.getRowDisplayRange = getRowDisplayRange;
5
- function getRowDisplayRange(totalRows, rowsPerPage, pageNumber, formatRange) {
6
- if (formatRange === void 0) {
7
- formatRange = function formatRange(start, end, total) {
8
- return "Showing " + start + " to " + end + " of " + total;
9
- };
10
- }
5
+ function getRowDisplayRange(totalRows, rowsPerPage, pageNumber) {
11
6
  var start = (pageNumber - 1) * rowsPerPage + 1;
12
7
  var end = Math.min(pageNumber * rowsPerPage, totalRows);
13
- return formatRange(start != null ? start : 0, end != null ? end : 0, totalRows != null ? totalRows : 0);
8
+ return "Showing " + (start != null ? start : 0) + " to " + (end != null ? end : 0) + " of " + (totalRows != null ? totalRows : 0);
14
9
  }
@@ -158,6 +158,7 @@ var useCellDescriptor = function useCellDescriptor(props) {
158
158
  if (treeCol) {
159
159
  hasCustomTreeCol = true;
160
160
  }
161
+ console.log(columns);
161
162
  if ((columnChildren === null || columnChildren === void 0 ? void 0 : columnChildren.length) !== 2) {
162
163
  throw new Error("Component <HeaderCell> and <Cell> is required, column index: " + index + " ");
163
164
  }
@@ -31,7 +31,6 @@ interface ScrollListenerProps {
31
31
  onTouchStart?: (event: React.TouchEvent) => void;
32
32
  onTouchMove?: (event: React.TouchEvent) => void;
33
33
  onTouchEnd?: (event: React.TouchEvent) => void;
34
- handleInfiniteScroll?: (value: number) => void;
35
34
  }
36
35
  /**
37
36
  * Add scroll, touch, and wheel monitoring events to the table,
@@ -72,8 +72,7 @@ var useScrollListener = function useScrollListener(props) {
72
72
  contentHeight = props.contentHeight,
73
73
  headerHeight = props.headerHeight,
74
74
  rtl = props.rtl,
75
- tableKey = props.tableKey,
76
- handleInfiniteScroll = props.handleInfiniteScroll;
75
+ tableKey = props.tableKey;
77
76
  var wheelListener = (0, _react.useRef)(null);
78
77
  var touchStartListener = (0, _react.useRef)(null);
79
78
  var touchMoveListener = (0, _react.useRef)(null);
@@ -135,9 +134,6 @@ var useScrollListener = function useScrollListener(props) {
135
134
  var x = Math.min(0, nextScrollX < minScrollX.current ? minScrollX.current : nextScrollX);
136
135
  setScrollX(x);
137
136
  setScrollY(y);
138
- if (typeof handleInfiniteScroll === 'function' && deltaY !== 0 && !loading && Math.abs(y) + getTableHeight() >= contentHeight.current - 12) {
139
- handleInfiniteScroll(scrollY.current);
140
- }
141
137
  onScroll === null || onScroll === void 0 ? void 0 : onScroll(Math.abs(x), Math.abs(y));
142
138
  if (virtualized) {
143
139
  // Add a state to the table during virtualized scrolling.
@@ -215,6 +211,7 @@ var useScrollListener = function useScrollListener(props) {
215
211
  if (!isTouching.current) {
216
212
  return;
217
213
  }
214
+ console.log('handleTouchMove');
218
215
  var _event$touches$2 = event.touches[0],
219
216
  pageX = _event$touches$2.pageX,
220
217
  pageY = _event$touches$2.pageY;
@@ -248,6 +245,7 @@ var useScrollListener = function useScrollListener(props) {
248
245
  if (!isTouching.current) {
249
246
  return;
250
247
  }
248
+ console.log('handleTouchEnd');
251
249
  isTouching.current = false;
252
250
  var touchDuration = new Date().getTime() - momentumStartTime.current;
253
251
  var absDeltaY = Math.abs(scrollY.current - momentumStartY.current);
package/package.json CHANGED
@@ -1,10 +1,18 @@
1
1
  {
2
2
  "name": "qbs-react-grid",
3
- "version": "2.2.4",
3
+ "version": "2.2.6",
4
4
  "description": "A React table component",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "module": "es/index.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./es/index.js",
11
+ "require": "./lib/index.js",
12
+ "default": "./es/index.js"
13
+ },
14
+ "./dist/css/qbs-react-grid.css": "./dist/css/qbs-react-grid.css"
15
+ },
8
16
  "scripts": {
9
17
  "format": "prettier --write \"{src,test}/**/*.{tsx,ts,js}\"",
10
18
  "format:check": "prettier --list-different \"{src,test}/**/*.{tsx,ts,js}\"",
@@ -72,7 +80,7 @@
72
80
  "@commitlint/cli": "^13.1.0",
73
81
  "@commitlint/config-conventional": "^13.1.0",
74
82
  "@faker-js/faker": "^7.6.0",
75
- "@testing-library/react": "^16.2.0",
83
+ "@testing-library/react": "^13.4.0",
76
84
  "@types/lodash": "^4.14.165",
77
85
  "@types/prop-types": "^15.7.1",
78
86
  "@types/react": "^19.0.11",
package/src/Cell.tsx CHANGED
@@ -144,13 +144,11 @@ const Cell = React.forwardRef((props: InnerCellProps, ref: React.Ref<HTMLDivElem
144
144
  };
145
145
 
146
146
  const paddingKey = rtl ? 'paddingRight' : 'paddingLeft';
147
- const resolvedAlign =
148
- rtl && align === 'left' ? 'right' : rtl && align === 'right' ? 'left' : align;
149
147
  const contentStyles: React.CSSProperties = {
150
148
  ...style,
151
149
  width: fullText ? width - 1 : width,
152
150
  height: nextHeight,
153
- textAlign: resolvedAlign,
151
+ textAlign: align,
154
152
  [paddingKey]: isTreeCol ? depth * LAYER_WIDTH + 10 : style?.[paddingKey] || style?.padding
155
153
  };
156
154
 
@@ -97,6 +97,7 @@ const HeaderCell = React.forwardRef((props: HeaderCellProps, ref: React.Ref<HTML
97
97
  onSortColumn?.(sortKey ?? dataKey);
98
98
  }
99
99
  }, [dataKey, onSortColumn, sortable, sortKey]);
100
+
100
101
  const handleColumnResizeStart = useCallback(() => {
101
102
  onColumnResizeStart?.(columnWidth, left, !!fixed);
102
103
  }, [columnWidth, fixed, left, onColumnResizeStart]);
@@ -1,7 +1,6 @@
1
1
  import React, { FC, useEffect, useState } from 'react';
2
2
 
3
3
  import CustomSelect from './customSelect';
4
- import { mergeLabels, type QbsTableLabels } from './qbsTable/labels';
5
4
  import { getRowDisplayRange } from './qbsTable/utilities/tablecalc';
6
5
 
7
6
  // Import the custom select component
@@ -16,8 +15,6 @@ type PageProps = {
16
15
  onRowsPerPage?: (row: number, page: number) => void;
17
16
  onPagination?: (row: number, page: number) => void;
18
17
  };
19
- labels?: QbsTableLabels;
20
- dataTheme?: string;
21
18
  };
22
19
 
23
20
  const PageIndex = ({ currentPage, handleFirst, pageCount }) => {
@@ -55,8 +52,7 @@ const PageIndex = ({ currentPage, handleFirst, pageCount }) => {
55
52
  return <>{renderPageNumbers()}</>;
56
53
  };
57
54
 
58
- const Pagination: FC<PageProps> = ({ paginationProps, labels: labelsProp, dataTheme }) => {
59
- const labels = mergeLabels(labelsProp);
55
+ const Pagination: FC<PageProps> = ({ paginationProps }) => {
60
56
  const {
61
57
  dropOptions = [10, 20, 50, 100, 200],
62
58
  currentPage = 1,
@@ -100,12 +96,9 @@ const Pagination: FC<PageProps> = ({ paginationProps, labels: labelsProp, dataTh
100
96
  return (
101
97
  <div
102
98
  className="qbs-table-custom-pagination"
103
- data-theme={dataTheme}
104
99
  style={{ display: 'flex', justifyContent: 'space-between' }}
105
100
  >
106
- <div className="rows-count">
107
- {getRowDisplayRange(total, rowsPerPageState, currentPage, labels.showingRange)}
108
- </div>
101
+ <div className="rows-count">{getRowDisplayRange(total, rowsPerPageState, currentPage)}</div>
109
102
  <div className="qbs-table-pagination-right-block">
110
103
  <button
111
104
  className="qbs-table-icon-container"
@@ -201,7 +194,7 @@ const Pagination: FC<PageProps> = ({ paginationProps, labels: labelsProp, dataTh
201
194
  </button>
202
195
  </div>
203
196
  <div className="qbs-table-pagination-flexBox">
204
- <span className="qbs-table-pagination-text">{labels.itemsPerPage}</span>
197
+ <span className="qbs-table-pagination-text">Items per page</span>
205
198
  <CustomSelect
206
199
  options={dropData}
207
200
  selectedValue={rowsPerPageState}
package/src/Table.tsx CHANGED
@@ -224,7 +224,6 @@ export interface TableProps<Row, Key> extends Omit<StandardProps, 'onScroll'> {
224
224
  expanded?: boolean
225
225
  ) => React.ReactNode;
226
226
  tableKey?: string;
227
- infiniteLoading?: boolean;
228
227
  /** Customize what you can do to expand a zone */
229
228
  renderRowExpanded?: (rowData?: Row) => React.ReactNode;
230
229
 
@@ -260,16 +259,13 @@ export interface TableProps<Row, Key> extends Omit<StandardProps, 'onScroll'> {
260
259
 
261
260
  /** Callback for the `touchend` event. */
262
261
  onTouchEnd?: (event: React.TouchEvent) => void;
263
- handleInfiniteScroll?: (value: number) => void;
262
+
264
263
  /**
265
264
  * Callback after table data update.
266
265
  * @deprecated use `shouldUpdateScroll` instead
267
266
  **/
268
267
  onDataUpdated?: (nextData: Row[], scrollTo: (coord: { x: number; y: number }) => void) => void;
269
268
  tableBodyRef: React.RefObject<HTMLDivElement>;
270
-
271
- wheelWrapperRef: React.RefObject<HTMLDivElement | null>;
272
-
273
269
  bodyRef?: (ref: HTMLElement) => void;
274
270
  }
275
271
 
@@ -306,7 +302,8 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
306
302
  loading: 'Loading...'
307
303
  },
308
304
  showHeader = true,
309
-
305
+ pagination = true,
306
+ paginationProps = {},
310
307
  sortColumn,
311
308
  rowHeight = ROW_HEIGHT,
312
309
  sortType: sortTypeProp,
@@ -338,21 +335,21 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
338
335
  onTouchStart,
339
336
  onTouchMove,
340
337
  onTouchEnd,
338
+ dataTheme,
341
339
  tableBodyHeight,
342
340
  columns,
343
341
  tableBodyRef,
344
342
  tableKey,
345
- handleInfiniteScroll,
346
- infiniteLoading,
347
- wheelWrapperRef,
348
343
  ...rest
349
344
  } = props;
345
+
350
346
  const {
351
347
  withClassPrefix,
352
348
  merge: mergeCls,
353
349
  prefix
354
350
  } = useClassNames(classPrefix, typeof classPrefix !== 'undefined');
355
351
  const childTableRef = useRef<HTMLDivElement>(null);
352
+
356
353
  // Use `forceUpdate` to force the component to re-render after manipulating the DOM.
357
354
  const [, forceUpdate] = useReducer(x => x + 1, 0);
358
355
  const [expandedRowKeys, setExpandedRowKeys] = useControlled(
@@ -411,6 +408,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
411
408
  const affixHeaderWrapperRef = useRef<HTMLDivElement>(null);
412
409
  const headerWrapperRef = useRef<HTMLDivElement>(null);
413
410
  // const tableBodyRef = useRef<HTMLDivElement>(null);
411
+ const wheelWrapperRef = useRef<HTMLDivElement>(null);
414
412
  const scrollbarXRef = useRef<ScrollbarInstance>(null);
415
413
  const scrollbarYRef = useRef<ScrollbarInstance>(null);
416
414
 
@@ -535,8 +533,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
535
533
  onScroll,
536
534
  onTouchStart,
537
535
  onTouchMove,
538
- onTouchEnd,
539
- handleInfiniteScroll
536
+ onTouchEnd
540
537
  });
541
538
 
542
539
  const { headerCells, bodyCells, allColumnsWidth, hasCustomTreeCol } = useCellDescriptor({
@@ -956,9 +953,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
956
953
  tableId={id}
957
954
  style={{ width: tableWidth.current }}
958
955
  length={tableWidth.current}
959
- onScroll={delta => {
960
- onScrollHorizontal(delta);
961
- }}
956
+ onScroll={onScrollHorizontal}
962
957
  scrollLength={contentWidth.current}
963
958
  ref={scrollbarXRef}
964
959
  />
@@ -1137,21 +1132,13 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
1137
1132
  role="rowgroup"
1138
1133
  className={prefix('body-row-wrapper')}
1139
1134
  style={bodyStyles}
1140
- onScroll={e => {
1141
- onScrollBody?.(e); // existing handler
1142
- }}
1135
+ onScroll={onScrollBody}
1143
1136
  >
1144
1137
  {!loading && (
1145
1138
  <div style={wheelStyles} className={prefix('body-wheel-area')} ref={wheelWrapperRef}>
1146
1139
  {topHideHeight ? <Row style={topRowStyles} className="virtualized" /> : null}
1147
1140
  {visibleRows.current}
1148
1141
  {bottomHideHeight ? <Row style={bottomRowStyles} className="virtualized" /> : null}
1149
-
1150
- {infiniteLoading && (
1151
- <div style={{ padding: 12, textAlign: 'center' }}>
1152
- <span>Loading more rows…</span>
1153
- </div>
1154
- )}
1155
1142
  </div>
1156
1143
  )}
1157
1144