qbs-react-grid 1.1.53 → 1.2.0

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.
@@ -132,8 +132,8 @@ var ColumnToggle = function ColumnToggle(_ref) {
132
132
  fill: "none",
133
133
  xmlns: "http://www.w3.org/2000/svg"
134
134
  }, /*#__PURE__*/React.createElement("path", {
135
- "fill-rule": "evenodd",
136
- "clip-rule": "evenodd",
135
+ fillRule: "evenodd",
136
+ clipRule: "evenodd",
137
137
  d: "M5.20898 2.05047C4.74187 2.22322 4.43921 2.6138 4.39879 3.09588C4.33861 3.81357 4.96751 4.44246 5.68519 4.38229C6.18026 4.3408 6.59243 4.00921 6.74267 3.53164C6.82103 3.2825 6.79574 2.93719 6.68125 2.6925C6.55895 2.43113 6.37419 2.24233 6.11569 2.11459C5.92365 2.01969 5.88078 2.00965 5.63395 2.00196C5.41672 1.99517 5.3325 2.00481 5.20898 2.05047ZM10.0416 2.04376C9.7 2.16569 9.46445 2.37622 9.31379 2.69422C9.23042 2.87016 9.22458 2.90286 9.22458 3.19315C9.22458 3.4899 9.22889 3.51259 9.32123 3.70051C9.69541 4.46214 10.6879 4.6208 11.2645 4.01115C11.8315 3.4116 11.6604 2.47093 10.918 2.10616C10.7441 2.02073 10.6936 2.0094 10.4529 2.00182C10.2481 1.99536 10.1488 2.00548 10.0416 2.04376ZM5.34893 6.82474C5.11292 6.87601 4.92872 6.97801 4.74901 7.15697C4.27637 7.62757 4.27637 8.36852 4.74901 8.8401C5.21569 9.30575 5.93107 9.31874 6.40536 8.87018C6.66595 8.62374 6.78644 8.34805 6.78644 7.99837C6.78644 7.651 6.66578 7.37282 6.41027 7.13118C6.22719 6.95803 6.07668 6.87885 5.83216 6.82702C5.61146 6.78023 5.55503 6.77998 5.34893 6.82474ZM10.1516 6.82829C9.9209 6.87849 9.7661 6.96147 9.58667 7.13118C9.33115 7.37282 9.21049 7.651 9.21049 7.99837C9.21049 8.34805 9.33098 8.62374 9.59157 8.87018C10.0659 9.31877 10.7812 9.30577 11.2479 8.8401C11.7206 8.36852 11.7206 7.62822 11.2479 7.15663C11.0647 6.97379 10.8553 6.86282 10.6076 6.81715C10.4048 6.77981 10.3707 6.78062 10.1516 6.82829ZM5.28951 11.6453C4.97314 11.737 4.66594 11.9881 4.52416 12.271C4.19001 12.9376 4.53174 13.7326 5.24943 13.9583C5.37001 13.9962 5.47168 14.0058 5.65873 13.9969C5.87526 13.9865 5.93484 13.9715 6.11704 13.8815C6.52155 13.6816 6.75995 13.3194 6.78131 12.8724C6.79558 12.5741 6.74746 12.3902 6.59238 12.1502C6.46455 11.9525 6.23962 11.7698 6.02016 11.6857C5.83188 11.6135 5.46864 11.5934 5.28951 11.6453ZM10.0849 11.6514C9.75841 11.7392 9.47967 11.9748 9.32098 12.2972C9.22892 12.4841 9.22458 12.5069 9.22458 12.8036C9.22458 13.0943 9.23033 13.1264 9.31435 13.3037C9.43911 13.5671 9.62317 13.7546 9.88296 13.883C10.0896 13.9851 10.1041 13.988 10.4075 13.988C10.706 13.988 10.7283 13.9838 10.9164 13.8914C11.6598 13.5261 11.8321 12.5858 11.2655 11.9867C10.9589 11.6624 10.5141 11.5361 10.0849 11.6514Z",
138
138
  fill: "#999696"
139
139
  }))));
@@ -9,9 +9,9 @@ export var ThreeDotIcon = function ThreeDotIcon() {
9
9
  }, /*#__PURE__*/React.createElement("path", {
10
10
  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",
11
11
  stroke: "#313131",
12
- "stroke-width": "1.5",
13
- "stroke-linecap": "round",
14
- "stroke-linejoin": "round"
12
+ strokeWidth: "1.5",
13
+ strokeLinecap: "round",
14
+ strokeLinejoin: "round"
15
15
  }));
16
16
  };
17
17
  export var SettingsIcon = function SettingsIcon() {
@@ -22,18 +22,18 @@ export var SettingsIcon = function SettingsIcon() {
22
22
  fill: "none",
23
23
  xmlns: "http://www.w3.org/2000/svg"
24
24
  }, /*#__PURE__*/React.createElement("path", {
25
- "fill-rule": "evenodd",
26
- "clip-rule": "evenodd",
25
+ fillRule: "evenodd",
26
+ clipRule: "evenodd",
27
27
  d: "M10 12.5C8.61929 12.5 7.5 11.3807 7.5 10C7.5 8.61929 8.61929 7.5 10 7.5C11.3807 7.5 12.5 8.61929 12.5 10C12.5 11.3807 11.3807 12.5 10 12.5Z",
28
28
  stroke: "#313131",
29
- "stroke-width": "1.5",
30
- "stroke-linecap": "round",
31
- "stroke-linejoin": "round"
29
+ strokeWidth: "1.5",
30
+ strokeLinecap: "round",
31
+ strokeLinejoin: "round"
32
32
  }), /*#__PURE__*/React.createElement("path", {
33
33
  d: "M1.66797 9.26718C1.66797 8.40052 2.3763 7.68385 3.2513 7.68385C4.75964 7.68385 5.3763 6.61718 4.61797 5.30885C4.18464 4.55885 4.44297 3.58385 5.2013 3.15052L6.64297 2.32552C7.3013 1.93385 8.1513 2.16718 8.54297 2.82552L8.63463 2.98385C9.38463 4.29218 10.618 4.29218 11.3763 2.98385L11.468 2.82552C11.8596 2.16718 12.7096 1.93385 13.368 2.32552L14.8096 3.15052C15.568 3.58385 15.8263 4.55885 15.393 5.30885C14.6346 6.61718 15.2513 7.68385 16.7596 7.68385C17.6263 7.68385 18.343 8.39218 18.343 9.26718V10.7338C18.343 11.6005 17.6346 12.3172 16.7596 12.3172C15.2513 12.3172 14.6346 13.3838 15.393 14.6922C15.8263 15.4505 15.568 16.4172 14.8096 16.8505L13.368 17.6755C12.7096 18.0672 11.8596 17.8339 11.468 17.1755L11.3763 17.0172C10.6263 15.7089 9.39297 15.7089 8.63463 17.0172L8.54297 17.1755C8.1513 17.8339 7.3013 18.0672 6.64297 17.6755L5.2013 16.8505C4.44297 16.4172 4.18464 15.4422 4.61797 14.6922C5.3763 13.3838 4.75964 12.3172 3.2513 12.3172C2.3763 12.3172 1.66797 11.6005 1.66797 10.7338V9.26718Z",
34
34
  stroke: "#313131",
35
- "stroke-width": "1.5",
36
- "stroke-linecap": "round",
37
- "stroke-linejoin": "round"
35
+ strokeWidth: "1.5",
36
+ strokeLinecap: "round",
37
+ strokeLinejoin: "round"
38
38
  }));
39
39
  };
@@ -0,0 +1,8 @@
1
+ import { FC } from 'react';
2
+ type CustomSelectProps = {
3
+ options: number[];
4
+ selectedValue: number;
5
+ onChange: (value: number) => void;
6
+ };
7
+ declare const CustomSelect: FC<CustomSelectProps>;
8
+ export default CustomSelect;
package/lib/Pagination.js CHANGED
@@ -1,47 +1,46 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  exports.__esModule = true;
4
5
  exports["default"] = void 0;
5
6
  var _react = _interopRequireWildcard(require("react"));
6
7
  var _tablecalc = require("./qbsTable/utilities/tablecalc");
8
+ var _CustomSelect = _interopRequireDefault(require("./CustomSelect"));
7
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); }
8
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
+ // Import the custom select component
12
+
9
13
  var PageIndex = function PageIndex(_ref) {
10
14
  var currentPage = _ref.currentPage,
11
15
  handleFirst = _ref.handleFirst,
12
16
  pageCount = _ref.pageCount;
13
17
  var renderPageNumbers = function renderPageNumbers() {
14
18
  var pageNumbers = [];
15
-
16
- // Add ellipsis if necessary
17
19
  if (currentPage > 3) {
18
20
  pageNumbers.push('...');
19
21
  }
20
22
  for (var i = Math.max(1, currentPage - 2); i <= Math.min(pageCount, currentPage + 2); i++) {
21
23
  pageNumbers.push(i);
22
24
  }
23
-
24
- // Add ellipsis if necessary
25
25
  if (currentPage < pageCount - 2) {
26
26
  pageNumbers.push('...');
27
27
  }
28
28
  return pageNumbers.map(function (pageNumber) {
29
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, pageNumber !== '...' ? /*#__PURE__*/_react["default"].createElement("span", {
30
- key: pageNumber,
29
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
30
+ key: pageNumber
31
+ }, pageNumber !== '...' ? /*#__PURE__*/_react["default"].createElement("span", {
31
32
  onClick: function onClick() {
32
33
  return handleFirst(pageNumber);
33
34
  },
34
35
  className: "block-item " + (pageNumber === currentPage ? 'selected' : '')
35
36
  }, pageNumber) : /*#__PURE__*/_react["default"].createElement("span", {
36
- key: pageNumber,
37
- className: "block-item " + (pageNumber === currentPage ? 'selected' : '')
37
+ className: "block-item"
38
38
  }, pageNumber));
39
39
  });
40
40
  };
41
41
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, renderPageNumbers());
42
42
  };
43
43
  var Pagination = function Pagination(_ref2) {
44
- var _paginationProps$tota2, _paginationProps$rows2, _paginationProps$curr2;
45
44
  var paginationProps = _ref2.paginationProps;
46
45
  var _paginationProps$drop = paginationProps.dropOptions,
47
46
  dropOptions = _paginationProps$drop === void 0 ? [10, 20, 50, 100, 200] : _paginationProps$drop,
@@ -60,8 +59,7 @@ var Pagination = function Pagination(_ref2) {
60
59
  var _useState2 = (0, _react.useState)(1),
61
60
  pageCount = _useState2[0],
62
61
  setPageCount = _useState2[1];
63
- var handleRowsPerPage = function handleRowsPerPage(e) {
64
- var value = parseInt(e.target.value);
62
+ var handleRowsPerPage = function handleRowsPerPage(value) {
65
63
  setRowsPerPageState(value);
66
64
  onRowsPerPage === null || onRowsPerPage === void 0 ? void 0 : onRowsPerPage(value, currentPage);
67
65
  };
@@ -83,18 +81,18 @@ var Pagination = function Pagination(_ref2) {
83
81
  onPagination === null || onPagination === void 0 ? void 0 : onPagination(currentPage + 1, currentPage);
84
82
  };
85
83
  return /*#__PURE__*/_react["default"].createElement("div", {
86
- className: 'qbs-table-custom-pagination',
84
+ className: "qbs-table-custom-pagination",
87
85
  style: {
88
86
  display: 'flex',
89
87
  justifyContent: 'space-between'
90
88
  }
91
89
  }, /*#__PURE__*/_react["default"].createElement("div", {
92
90
  className: "rows-count"
93
- }, (0, _tablecalc.getRowDisplayRange)((_paginationProps$tota2 = paginationProps.total) != null ? _paginationProps$tota2 : 0, (_paginationProps$rows2 = paginationProps.rowsPerPage) != null ? _paginationProps$rows2 : 0, (_paginationProps$curr2 = paginationProps.currentPage) != null ? _paginationProps$curr2 : 0)), /*#__PURE__*/_react["default"].createElement("div", {
91
+ }, (0, _tablecalc.getRowDisplayRange)(total, rowsPerPageState, currentPage)), /*#__PURE__*/_react["default"].createElement("div", {
94
92
  className: "qbs-table-pagination-right-block"
95
93
  }, /*#__PURE__*/_react["default"].createElement("button", {
96
94
  className: "qbs-table-icon-container",
97
- disabled: currentPage == 1,
95
+ disabled: currentPage === 1,
98
96
  onClick: function onClick() {
99
97
  return handleFirst(1);
100
98
  }
@@ -113,9 +111,7 @@ var Pagination = function Pagination(_ref2) {
113
111
  }))), /*#__PURE__*/_react["default"].createElement("button", {
114
112
  className: "qbs-table-icon-container",
115
113
  disabled: currentPage < 2,
116
- onClick: function onClick() {
117
- return handlePrevious();
118
- }
114
+ onClick: handlePrevious
119
115
  }, /*#__PURE__*/_react["default"].createElement("svg", {
120
116
  width: "20",
121
117
  height: "20",
@@ -138,9 +134,7 @@ var Pagination = function Pagination(_ref2) {
138
134
  })), /*#__PURE__*/_react["default"].createElement("button", {
139
135
  className: "qbs-table-icon-container",
140
136
  disabled: currentPage === pageCount || pageCount === 0,
141
- onClick: function onClick() {
142
- return handleNext();
143
- }
137
+ onClick: handleNext
144
138
  }, /*#__PURE__*/_react["default"].createElement("svg", {
145
139
  width: "20",
146
140
  height: "20",
@@ -155,10 +149,8 @@ var Pagination = function Pagination(_ref2) {
155
149
  strokeLinejoin: "round"
156
150
  }))), /*#__PURE__*/_react["default"].createElement("button", {
157
151
  className: "qbs-table-icon-container",
158
- disabled: currentPage == pageCount || pageCount === 0,
159
- onClick: function onClick() {
160
- return handleLast();
161
- }
152
+ disabled: currentPage === pageCount || pageCount === 0,
153
+ onClick: handleLast
162
154
  }, /*#__PURE__*/_react["default"].createElement("svg", {
163
155
  width: "20",
164
156
  height: "20",
@@ -175,18 +167,11 @@ var Pagination = function Pagination(_ref2) {
175
167
  className: "qbs-table-pagination-flexBox"
176
168
  }, /*#__PURE__*/_react["default"].createElement("span", {
177
169
  className: "qbs-table-pagination-text"
178
- }, "Items per page"), /*#__PURE__*/_react["default"].createElement("select", {
179
- onChange: function onChange(e) {
180
- return handleRowsPerPage(e);
181
- },
182
- className: "qbs-table-pagination-dropdown",
183
- value: rowsPerPageState
184
- }, dropData === null || dropData === void 0 ? void 0 : dropData.map(function (item) {
185
- return /*#__PURE__*/_react["default"].createElement("option", {
186
- value: item,
187
- key: item
188
- }, item);
189
- }))));
170
+ }, "Items per page"), /*#__PURE__*/_react["default"].createElement(_CustomSelect["default"], {
171
+ options: dropData,
172
+ selectedValue: rowsPerPageState,
173
+ onChange: handleRowsPerPage
174
+ })));
190
175
  };
191
176
  var _default = Pagination;
192
177
  exports["default"] = _default;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = void 0;
5
+ var _react = _interopRequireWildcard(require("react"));
6
+ 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); }
7
+ 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; }
8
+ var CustomSelect = function CustomSelect(_ref) {
9
+ var options = _ref.options,
10
+ selectedValue = _ref.selectedValue,
11
+ onChange = _ref.onChange;
12
+ var _useState = (0, _react.useState)(false),
13
+ isOpen = _useState[0],
14
+ setIsOpen = _useState[1];
15
+ var _useState2 = (0, _react.useState)('bottom'),
16
+ dropdownPosition = _useState2[0],
17
+ setDropdownPosition = _useState2[1];
18
+ var ref = (0, _react.useRef)(null);
19
+ var inputRef = (0, _react.useRef)(null);
20
+ var adjustDropdownPosition = function adjustDropdownPosition() {
21
+ if (inputRef.current) {
22
+ var inputBoxRect = inputRef.current.getBoundingClientRect();
23
+ var viewportHeight = window.innerHeight;
24
+ var spaceAbove = inputBoxRect.top;
25
+ var spaceBelow = viewportHeight - inputBoxRect.bottom;
26
+ if (spaceAbove > spaceBelow) {
27
+ setDropdownPosition('top');
28
+ } else {
29
+ setDropdownPosition('bottom');
30
+ }
31
+ }
32
+ };
33
+ var handleToggle = function handleToggle() {
34
+ setIsOpen(function (prevIsOpen) {
35
+ return !prevIsOpen;
36
+ });
37
+ };
38
+ var handleSelect = function handleSelect(value) {
39
+ onChange(value);
40
+ setIsOpen(false);
41
+ };
42
+ var handleClickOutside = function handleClickOutside(event) {
43
+ if (ref.current && !ref.current.contains(event.target)) {
44
+ setIsOpen(false);
45
+ }
46
+ };
47
+ (0, _react.useEffect)(function () {
48
+ if (isOpen) {
49
+ adjustDropdownPosition();
50
+ window.addEventListener('resize', adjustDropdownPosition);
51
+ } else {
52
+ window.removeEventListener('resize', adjustDropdownPosition);
53
+ }
54
+ return function () {
55
+ window.removeEventListener('resize', adjustDropdownPosition);
56
+ };
57
+ }, [isOpen]);
58
+ (0, _react.useEffect)(function () {
59
+ document.addEventListener('mousedown', handleClickOutside);
60
+ return function () {
61
+ document.removeEventListener('mousedown', handleClickOutside);
62
+ };
63
+ }, []);
64
+ return /*#__PURE__*/_react["default"].createElement("div", {
65
+ className: "custom-select",
66
+ ref: ref
67
+ }, /*#__PURE__*/_react["default"].createElement("div", {
68
+ className: "custom-select-trigger",
69
+ onClick: handleToggle,
70
+ ref: inputRef
71
+ }, selectedValue), isOpen && /*#__PURE__*/_react["default"].createElement("ul", {
72
+ className: "custom-select-options " + dropdownPosition
73
+ }, options.map(function (option) {
74
+ return /*#__PURE__*/_react["default"].createElement("li", {
75
+ key: option,
76
+ className: "custom-select-option " + (option === selectedValue ? 'selected' : ''),
77
+ onClick: function onClick() {
78
+ return handleSelect(option);
79
+ }
80
+ }, option);
81
+ })));
82
+ };
83
+ var _default = CustomSelect;
84
+ exports["default"] = _default;
@@ -17,8 +17,8 @@
17
17
  }
18
18
  }
19
19
  .qbs-table-pagination-dropdown {
20
- width: auto;
21
- height: 24px;
20
+ width: 65px;
21
+ height: 26px;
22
22
  display: flex;
23
23
  align-items: center;
24
24
  justify-content: center;
@@ -116,3 +116,62 @@
116
116
  .qbs-table-custom-pagination .qbs-table-pagination-dropdown:focus {
117
117
  outline: none;
118
118
  }
119
+
120
+ .custom-select {
121
+ position: relative;
122
+ display: inline-block;
123
+ }
124
+
125
+ .custom-select-trigger {
126
+ padding: 2px 8px;
127
+ cursor: pointer;
128
+ border: 1px solid #d6d8dc;
129
+ border-radius: 4px;
130
+ min-width: 65px;
131
+ position: relative;
132
+ font-size: 14px;
133
+ font-weight: 500;
134
+ }
135
+
136
+ .custom-select-options {
137
+ position: absolute;
138
+ width: 100%;
139
+ z-index: 1000;
140
+ list-style: none;
141
+ margin: 2px 0 0;
142
+ padding: 0;
143
+ background: #fff;
144
+ border-radius: 8px;
145
+ box-shadow: 0 8px 20px 0 #00000026;
146
+ }
147
+
148
+ ul.custom-select-options.top {
149
+ bottom: 100%;
150
+ }
151
+
152
+ .custom-select-option {
153
+ padding: 6px 8px;
154
+ cursor: pointer;
155
+ font-weight: 500;
156
+ font-size: 14px;
157
+ }
158
+
159
+ .custom-select-option:hover,
160
+ .custom-select-option.selected {
161
+ background-color: #f0f0f0;
162
+ }
163
+
164
+ .custom-select-trigger:before {
165
+ content: "";
166
+ position: absolute;
167
+ right: 10px;
168
+ top: 6px;
169
+ font-weight: bold;
170
+ border: solid black;
171
+ border-width: 0 1px 1px 0;
172
+ display: inline-block;
173
+ padding: 3px;
174
+ vertical-align: middle;
175
+ transform: rotate(45deg);
176
+ -webkit-transform: rotate(45deg);
177
+ }
@@ -84,7 +84,29 @@ var ExpandCell = /*#__PURE__*/_react["default"].memo(function (_ref3) {
84
84
  }
85
85
  }, expandedRowKeys.some(function (key) {
86
86
  return key === rowData[dataKey];
87
- }) ? '-' : '+'));
87
+ }) ? /*#__PURE__*/_react["default"].createElement("svg", {
88
+ width: "11",
89
+ height: "6",
90
+ viewBox: "0 0 11 6",
91
+ fill: "none",
92
+ xmlns: "http://www.w3.org/2000/svg"
93
+ }, /*#__PURE__*/_react["default"].createElement("path", {
94
+ fillRule: "evenodd",
95
+ clipRule: "evenodd",
96
+ d: "M0.792893 0.292893C1.18342 -0.097631 1.81658 -0.097631 2.20711 0.292893L5.5 3.58579L8.79289 0.292893C9.18342 -0.0976311 9.81658 -0.0976311 10.2071 0.292893C10.5976 0.683417 10.5976 1.31658 10.2071 1.70711L6.20711 5.70711C5.81658 6.09763 5.18342 6.09763 4.79289 5.70711L0.792893 1.70711C0.402369 1.31658 0.402369 0.683417 0.792893 0.292893Z",
97
+ fill: "#313131"
98
+ })) : /*#__PURE__*/_react["default"].createElement("svg", {
99
+ width: "7",
100
+ height: "10",
101
+ viewBox: "0 0 7 10",
102
+ fill: "none",
103
+ xmlns: "http://www.w3.org/2000/svg"
104
+ }, /*#__PURE__*/_react["default"].createElement("path", {
105
+ fillRule: "evenodd",
106
+ clipRule: "evenodd",
107
+ d: "M0.792894 9.70711C0.402369 9.31658 0.402369 8.68342 0.792894 8.29289L4.08579 5L0.792893 1.70711C0.402369 1.31658 0.402369 0.683418 0.792893 0.292894C1.18342 -0.0976312 1.81658 -0.0976312 2.20711 0.292894L6.20711 4.29289C6.59763 4.68342 6.59763 5.31658 6.20711 5.70711L2.20711 9.70711C1.81658 10.0976 1.18342 10.0976 0.792894 9.70711Z",
108
+ fill: "#313131"
109
+ }))));
88
110
  });
89
111
  exports.ExpandCell = ExpandCell;
90
112
  var CustomTableCell = /*#__PURE__*/_react["default"].memo(function (_ref4) {
@@ -138,8 +138,8 @@ var ColumnToggle = function ColumnToggle(_ref) {
138
138
  fill: "none",
139
139
  xmlns: "http://www.w3.org/2000/svg"
140
140
  }, /*#__PURE__*/_react["default"].createElement("path", {
141
- "fill-rule": "evenodd",
142
- "clip-rule": "evenodd",
141
+ fillRule: "evenodd",
142
+ clipRule: "evenodd",
143
143
  d: "M5.20898 2.05047C4.74187 2.22322 4.43921 2.6138 4.39879 3.09588C4.33861 3.81357 4.96751 4.44246 5.68519 4.38229C6.18026 4.3408 6.59243 4.00921 6.74267 3.53164C6.82103 3.2825 6.79574 2.93719 6.68125 2.6925C6.55895 2.43113 6.37419 2.24233 6.11569 2.11459C5.92365 2.01969 5.88078 2.00965 5.63395 2.00196C5.41672 1.99517 5.3325 2.00481 5.20898 2.05047ZM10.0416 2.04376C9.7 2.16569 9.46445 2.37622 9.31379 2.69422C9.23042 2.87016 9.22458 2.90286 9.22458 3.19315C9.22458 3.4899 9.22889 3.51259 9.32123 3.70051C9.69541 4.46214 10.6879 4.6208 11.2645 4.01115C11.8315 3.4116 11.6604 2.47093 10.918 2.10616C10.7441 2.02073 10.6936 2.0094 10.4529 2.00182C10.2481 1.99536 10.1488 2.00548 10.0416 2.04376ZM5.34893 6.82474C5.11292 6.87601 4.92872 6.97801 4.74901 7.15697C4.27637 7.62757 4.27637 8.36852 4.74901 8.8401C5.21569 9.30575 5.93107 9.31874 6.40536 8.87018C6.66595 8.62374 6.78644 8.34805 6.78644 7.99837C6.78644 7.651 6.66578 7.37282 6.41027 7.13118C6.22719 6.95803 6.07668 6.87885 5.83216 6.82702C5.61146 6.78023 5.55503 6.77998 5.34893 6.82474ZM10.1516 6.82829C9.9209 6.87849 9.7661 6.96147 9.58667 7.13118C9.33115 7.37282 9.21049 7.651 9.21049 7.99837C9.21049 8.34805 9.33098 8.62374 9.59157 8.87018C10.0659 9.31877 10.7812 9.30577 11.2479 8.8401C11.7206 8.36852 11.7206 7.62822 11.2479 7.15663C11.0647 6.97379 10.8553 6.86282 10.6076 6.81715C10.4048 6.77981 10.3707 6.78062 10.1516 6.82829ZM5.28951 11.6453C4.97314 11.737 4.66594 11.9881 4.52416 12.271C4.19001 12.9376 4.53174 13.7326 5.24943 13.9583C5.37001 13.9962 5.47168 14.0058 5.65873 13.9969C5.87526 13.9865 5.93484 13.9715 6.11704 13.8815C6.52155 13.6816 6.75995 13.3194 6.78131 12.8724C6.79558 12.5741 6.74746 12.3902 6.59238 12.1502C6.46455 11.9525 6.23962 11.7698 6.02016 11.6857C5.83188 11.6135 5.46864 11.5934 5.28951 11.6453ZM10.0849 11.6514C9.75841 11.7392 9.47967 11.9748 9.32098 12.2972C9.22892 12.4841 9.22458 12.5069 9.22458 12.8036C9.22458 13.0943 9.23033 13.1264 9.31435 13.3037C9.43911 13.5671 9.62317 13.7546 9.88296 13.883C10.0896 13.9851 10.1041 13.988 10.4075 13.988C10.706 13.988 10.7283 13.9838 10.9164 13.8914C11.6598 13.5261 11.8321 12.5858 11.2655 11.9867C10.9589 11.6624 10.5141 11.5361 10.0849 11.6514Z",
144
144
  fill: "#999696"
145
145
  }))));
@@ -14,9 +14,9 @@ var ThreeDotIcon = function ThreeDotIcon() {
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
16
  stroke: "#313131",
17
- "stroke-width": "1.5",
18
- "stroke-linecap": "round",
19
- "stroke-linejoin": "round"
17
+ strokeWidth: "1.5",
18
+ strokeLinecap: "round",
19
+ strokeLinejoin: "round"
20
20
  }));
21
21
  };
22
22
  exports.ThreeDotIcon = ThreeDotIcon;
@@ -28,19 +28,19 @@ var SettingsIcon = function SettingsIcon() {
28
28
  fill: "none",
29
29
  xmlns: "http://www.w3.org/2000/svg"
30
30
  }, /*#__PURE__*/_react["default"].createElement("path", {
31
- "fill-rule": "evenodd",
32
- "clip-rule": "evenodd",
31
+ fillRule: "evenodd",
32
+ clipRule: "evenodd",
33
33
  d: "M10 12.5C8.61929 12.5 7.5 11.3807 7.5 10C7.5 8.61929 8.61929 7.5 10 7.5C11.3807 7.5 12.5 8.61929 12.5 10C12.5 11.3807 11.3807 12.5 10 12.5Z",
34
34
  stroke: "#313131",
35
- "stroke-width": "1.5",
36
- "stroke-linecap": "round",
37
- "stroke-linejoin": "round"
35
+ strokeWidth: "1.5",
36
+ strokeLinecap: "round",
37
+ strokeLinejoin: "round"
38
38
  }), /*#__PURE__*/_react["default"].createElement("path", {
39
39
  d: "M1.66797 9.26718C1.66797 8.40052 2.3763 7.68385 3.2513 7.68385C4.75964 7.68385 5.3763 6.61718 4.61797 5.30885C4.18464 4.55885 4.44297 3.58385 5.2013 3.15052L6.64297 2.32552C7.3013 1.93385 8.1513 2.16718 8.54297 2.82552L8.63463 2.98385C9.38463 4.29218 10.618 4.29218 11.3763 2.98385L11.468 2.82552C11.8596 2.16718 12.7096 1.93385 13.368 2.32552L14.8096 3.15052C15.568 3.58385 15.8263 4.55885 15.393 5.30885C14.6346 6.61718 15.2513 7.68385 16.7596 7.68385C17.6263 7.68385 18.343 8.39218 18.343 9.26718V10.7338C18.343 11.6005 17.6346 12.3172 16.7596 12.3172C15.2513 12.3172 14.6346 13.3838 15.393 14.6922C15.8263 15.4505 15.568 16.4172 14.8096 16.8505L13.368 17.6755C12.7096 18.0672 11.8596 17.8339 11.468 17.1755L11.3763 17.0172C10.6263 15.7089 9.39297 15.7089 8.63463 17.0172L8.54297 17.1755C8.1513 17.8339 7.3013 18.0672 6.64297 17.6755L5.2013 16.8505C4.44297 16.4172 4.18464 15.4422 4.61797 14.6922C5.3763 13.3838 4.75964 12.3172 3.2513 12.3172C2.3763 12.3172 1.66797 11.6005 1.66797 10.7338V9.26718Z",
40
40
  stroke: "#313131",
41
- "stroke-width": "1.5",
42
- "stroke-linecap": "round",
43
- "stroke-linejoin": "round"
41
+ strokeWidth: "1.5",
42
+ strokeLinecap: "round",
43
+ strokeLinejoin: "round"
44
44
  }));
45
45
  };
46
46
  exports.SettingsIcon = SettingsIcon;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qbs-react-grid",
3
- "version": "1.1.53",
3
+ "version": "1.2.0",
4
4
  "description": "A React table component",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -1,6 +1,6 @@
1
1
  import React, { FC, useEffect, useState } from 'react';
2
-
3
2
  import { getRowDisplayRange } from './qbsTable/utilities/tablecalc';
3
+ import CustomSelect from './CustomSelect'; // Import the custom select component
4
4
 
5
5
  type PageProps = {
6
6
  paginationProps: {
@@ -13,11 +13,11 @@ type PageProps = {
13
13
  onPagination?: (row: number, page: number) => void;
14
14
  };
15
15
  };
16
+
16
17
  const PageIndex = ({ currentPage, handleFirst, pageCount }) => {
17
18
  const renderPageNumbers = () => {
18
19
  const pageNumbers: any = [];
19
20
 
20
- // Add ellipsis if necessary
21
21
  if (currentPage > 3) {
22
22
  pageNumbers.push('...');
23
23
  }
@@ -26,35 +26,29 @@ const PageIndex = ({ currentPage, handleFirst, pageCount }) => {
26
26
  pageNumbers.push(i);
27
27
  }
28
28
 
29
- // Add ellipsis if necessary
30
29
  if (currentPage < pageCount - 2) {
31
30
  pageNumbers.push('...');
32
31
  }
33
32
 
34
33
  return pageNumbers.map((pageNumber: any) => (
35
- <>
34
+ <React.Fragment key={pageNumber}>
36
35
  {pageNumber !== '...' ? (
37
36
  <span
38
- key={pageNumber}
39
37
  onClick={() => handleFirst(pageNumber)}
40
38
  className={`block-item ${pageNumber === currentPage ? 'selected' : ''}`}
41
39
  >
42
40
  {pageNumber}
43
41
  </span>
44
42
  ) : (
45
- <span
46
- key={pageNumber}
47
- className={`block-item ${pageNumber === currentPage ? 'selected' : ''}`}
48
- >
49
- {pageNumber}
50
- </span>
43
+ <span className="block-item">{pageNumber}</span>
51
44
  )}
52
- </>
45
+ </React.Fragment>
53
46
  ));
54
47
  };
55
48
 
56
49
  return <>{renderPageNumbers()}</>;
57
50
  };
51
+
58
52
  const Pagination: FC<PageProps> = ({ paginationProps }) => {
59
53
  const {
60
54
  dropOptions = [10, 20, 50, 100, 200],
@@ -66,14 +60,14 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
66
60
  } = paginationProps;
67
61
 
68
62
  const [rowsPerPageState, setRowsPerPageState] = useState(rowsPerPage);
69
-
70
63
  const dropData = dropOptions ?? [10, 20, 50, 100, 200];
71
64
  const [pageCount, setPageCount] = useState(1);
72
- const handleRowsPerPage = (e: React.ChangeEvent<HTMLSelectElement>) => {
73
- const value = parseInt(e.target.value);
65
+
66
+ const handleRowsPerPage = (value: number) => {
74
67
  setRowsPerPageState(value);
75
68
  onRowsPerPage?.(value, currentPage);
76
69
  };
70
+
77
71
  const handleFirst = (index: number) => {
78
72
  onPagination?.(index, currentPage);
79
73
  };
@@ -91,26 +85,21 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
91
85
  const handlePrevious = () => {
92
86
  onPagination?.(currentPage - 1, currentPage);
93
87
  };
88
+
94
89
  const handleNext = () => {
95
90
  onPagination?.(currentPage + 1, currentPage);
96
91
  };
97
92
 
98
93
  return (
99
94
  <div
100
- className={'qbs-table-custom-pagination'}
95
+ className="qbs-table-custom-pagination"
101
96
  style={{ display: 'flex', justifyContent: 'space-between' }}
102
97
  >
103
- <div className="rows-count">
104
- {getRowDisplayRange(
105
- paginationProps.total ?? 0,
106
- paginationProps.rowsPerPage ?? 0,
107
- paginationProps.currentPage ?? 0
108
- )}
109
- </div>
98
+ <div className="rows-count">{getRowDisplayRange(total, rowsPerPageState, currentPage)}</div>
110
99
  <div className="qbs-table-pagination-right-block">
111
100
  <button
112
101
  className="qbs-table-icon-container"
113
- disabled={currentPage == 1}
102
+ disabled={currentPage === 1}
114
103
  onClick={() => handleFirst(1)}
115
104
  >
116
105
  <svg
@@ -132,7 +121,7 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
132
121
  <button
133
122
  className="qbs-table-icon-container"
134
123
  disabled={currentPage < 2}
135
- onClick={() => handlePrevious()}
124
+ onClick={handlePrevious}
136
125
  >
137
126
  <svg
138
127
  width="20"
@@ -161,7 +150,7 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
161
150
  <button
162
151
  className="qbs-table-icon-container"
163
152
  disabled={currentPage === pageCount || pageCount === 0}
164
- onClick={() => handleNext()}
153
+ onClick={handleNext}
165
154
  >
166
155
  <svg
167
156
  width="20"
@@ -181,8 +170,8 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
181
170
  </button>
182
171
  <button
183
172
  className="qbs-table-icon-container"
184
- disabled={currentPage == pageCount || pageCount === 0}
185
- onClick={() => handleLast()}
173
+ disabled={currentPage === pageCount || pageCount === 0}
174
+ onClick={handleLast}
186
175
  >
187
176
  <svg
188
177
  width="20"
@@ -203,19 +192,14 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
203
192
  </div>
204
193
  <div className="qbs-table-pagination-flexBox">
205
194
  <span className="qbs-table-pagination-text">Items per page</span>
206
- <select
207
- onChange={e => handleRowsPerPage(e)}
208
- className="qbs-table-pagination-dropdown"
209
- value={rowsPerPageState}
210
- >
211
- {dropData?.map(item => (
212
- <option value={item} key={item}>
213
- {item}
214
- </option>
215
- ))}
216
- </select>
195
+ <CustomSelect
196
+ options={dropData}
197
+ selectedValue={rowsPerPageState}
198
+ onChange={handleRowsPerPage}
199
+ />
217
200
  </div>
218
201
  </div>
219
202
  );
220
203
  };
204
+
221
205
  export default Pagination;