qbs-react-grid 1.0.50 → 1.1.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.
@@ -2,10 +2,11 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  var _excluded = ["rowData", "onChange", "checkedKeys", "dataKey", "dataTheme"],
4
4
  _excluded2 = ["rowData", "dataKey", "expandedRowKeys", "onChange"],
5
- _excluded3 = ["rowData", "renderCell", "toolTip", "dataKey", "onChange", "rowClick", "link"];
5
+ _excluded3 = ["rowData", "renderCell", "toolTip", "dataKey", "onChange", "rowClick", "type", "link"];
6
6
  import React from 'react';
7
7
  import Cell from '../Cell';
8
8
  import MenuDropDown from './utilities/menuDropDown';
9
+ import { handleCellFormat } from './utilities/handleFormatCell';
9
10
  var CHECKBOX_LINE_HEIGHT = '36px';
10
11
  export var CheckCell = /*#__PURE__*/React.memo(function (_ref) {
11
12
  var rowData = _ref.rowData,
@@ -78,6 +79,7 @@ export var CustomTableCell = /*#__PURE__*/React.memo(function (_ref4) {
78
79
  dataKey = _ref4.dataKey,
79
80
  onChange = _ref4.onChange,
80
81
  rowClick = _ref4.rowClick,
82
+ type = _ref4.type,
81
83
  link = _ref4.link,
82
84
  props = _objectWithoutPropertiesLoose(_ref4, _excluded3);
83
85
  return /*#__PURE__*/React.createElement(Cell, _extends({}, props, {
@@ -87,5 +89,5 @@ export var CustomTableCell = /*#__PURE__*/React.memo(function (_ref4) {
87
89
  return rowClick === null || rowClick === void 0 ? void 0 : rowClick(rowData);
88
90
  },
89
91
  className: "qbs-table-row-link"
90
- }, renderCell ? (_renderCell = renderCell(rowData)) === null || _renderCell === void 0 ? void 0 : _renderCell.cell : rowData[dataKey]) : /*#__PURE__*/React.createElement(React.Fragment, null, (_renderCell2 = renderCell(rowData)) === null || _renderCell2 === void 0 ? void 0 : _renderCell2.cell));
92
+ }, renderCell ? (_renderCell = renderCell(rowData)) === null || _renderCell === void 0 ? void 0 : _renderCell.cell : handleCellFormat(rowData[dataKey], type)) : /*#__PURE__*/React.createElement(React.Fragment, null, renderCell ? (_renderCell2 = renderCell(rowData)) === null || _renderCell2 === void 0 ? void 0 : _renderCell2.cell : handleCellFormat(rowData[dataKey], type)));
91
93
  });
@@ -186,7 +186,8 @@ var QbsTable = function QbsTable(_ref) {
186
186
  tableHeaderActions: tableHeaderActions,
187
187
  selectedRowActions: selectedRowActions,
188
188
  onSelect: handleClear,
189
- handleColumnToggle: handleColumnToggle
189
+ handleColumnToggle: handleColumnToggle,
190
+ dataLength: data === null || data === void 0 ? void 0 : data.length
190
191
  };
191
192
  var themeToggle = useMemo(function () {
192
193
  return document.getElementById('themeToggle');
@@ -284,7 +285,8 @@ var QbsTable = function QbsTable(_ref) {
284
285
  isVisible = _ref3.isVisible,
285
286
  link = _ref3.link,
286
287
  rowClick = _ref3.rowClick,
287
- sortKey = _ref3.sortKey;
288
+ sortKey = _ref3.sortKey,
289
+ type = _ref3.type;
288
290
  return /*#__PURE__*/React.createElement(React.Fragment, null, isVisible && /*#__PURE__*/React.createElement(React.Fragment, null, grouped ? /*#__PURE__*/React.createElement(ColumnGroup, {
289
291
  header: groupheader,
290
292
  fixed: fixed,
@@ -309,6 +311,7 @@ var QbsTable = function QbsTable(_ref) {
309
311
  renderCell: child.renderCell,
310
312
  dataKey: child.field,
311
313
  dataTheme: dataTheme,
314
+ type: child.type,
312
315
  link: child.link
313
316
  }) : /*#__PURE__*/React.createElement(Cell, {
314
317
  className: " " + classes.cellClass,
@@ -331,6 +334,7 @@ var QbsTable = function QbsTable(_ref) {
331
334
  renderCell: renderCell,
332
335
  dataKey: field,
333
336
  rowClick: rowClick,
337
+ type: type,
334
338
  dataTheme: dataTheme,
335
339
  link: link
336
340
  }) : /*#__PURE__*/React.createElement(Cell, {
@@ -18,7 +18,8 @@ var ToolBar = function ToolBar(_ref) {
18
18
  tableHeaderActions = _ref.tableHeaderActions,
19
19
  selectedRowActions = _ref.selectedRowActions,
20
20
  checkedKeys = _ref.checkedKeys,
21
- onSelect = _ref.onSelect;
21
+ onSelect = _ref.onSelect,
22
+ dataLength = _ref.dataLength;
22
23
  var debouncedOnSearch = useCallback(debounce(onSearch != null ? onSearch : function () {}, 1000), [onSearch]);
23
24
  var handleSearch = useCallback(function (e) {
24
25
  if (debouncedOnSearch) {
@@ -84,7 +85,7 @@ var ToolBar = function ToolBar(_ref) {
84
85
  return actions === null || actions === void 0 ? void 0 : actions.action(checkedKeys);
85
86
  }
86
87
  }, actions.actionTitle));
87
- }))) : /*#__PURE__*/React.createElement("div", null, pagination && paginationProps && /*#__PURE__*/React.createElement("div", {
88
+ }))) : /*#__PURE__*/React.createElement("div", null, pagination && paginationProps && dataLength > 0 && /*#__PURE__*/React.createElement("div", {
88
89
  className: "rows-count"
89
90
  }, getRowDisplayRange((_paginationProps$tota = paginationProps.total) != null ? _paginationProps$tota : 0, (_paginationProps$rows = paginationProps.rowsPerPage) != null ? _paginationProps$rows : 0, (_paginationProps$curr = paginationProps.currentPage) != null ? _paginationProps$curr : 0)))));
90
91
  };
@@ -17,6 +17,7 @@ export interface ColumnBase {
17
17
  link?: boolean;
18
18
  rowClick?: (rowData: any) => void;
19
19
  sortKey?: string;
20
+ type?: string;
20
21
  }
21
22
  export interface QbsColumnProps extends ColumnBase {
22
23
  grouped?: boolean;
@@ -38,6 +39,7 @@ export interface ActionProps {
38
39
  icon: React.ReactNode;
39
40
  toolTip?: string;
40
41
  hidden?: boolean;
42
+ hide?: (data: any) => boolean;
41
43
  }
42
44
  export interface QbsTableProps {
43
45
  isLoading?: boolean;
@@ -114,6 +116,7 @@ export interface QbsTableToolbarProps {
114
116
  tableHeaderActions?: ReactElement | ReactNode;
115
117
  onSelect?: (keys: any[]) => void;
116
118
  handleColumnToggle?: (columns: QbsColumnProps[]) => void;
119
+ dataLength: number;
117
120
  selectedRowActions?: {
118
121
  actionTitle?: string;
119
122
  action: (checked: (number | string)[]) => void;
@@ -1,4 +1,4 @@
1
- import React, { useCallback, memo } from 'react';
1
+ import React, { memo, useCallback } from 'react';
2
2
  var SearchInput = function SearchInput(_ref) {
3
3
  var placeholder = _ref.placeholder,
4
4
  handleChange = _ref.handleChange,
@@ -0,0 +1 @@
1
+ export declare const handleCellFormat: (data: any, type: string) => any;
@@ -0,0 +1,46 @@
1
+ var convertDateFormat = function convertDateFormat(input, type) {
2
+ // Splitting the string by space to separate date and time
3
+ if (input && input !== null) {
4
+ var parts = input.split(' ');
5
+ var datePart = parts[0];
6
+ var timePart = parts.length > 1 ? " " + parts[1] : '';
7
+
8
+ // Splitting the date into [month, day, year]
9
+ var separator = datePart.includes('-') ? '-' : '/';
10
+ var dateComponents = datePart.split(separator);
11
+ if (dateComponents.length !== 3) {
12
+ // Invalid date format
13
+ return input;
14
+ }
15
+ var day, month, year;
16
+ if (dateComponents.length === 3) {
17
+ if (dateComponents[0].length === 4) {
18
+ // Format: yyyy/mm/dd
19
+ year = dateComponents[0];
20
+ month = dateComponents[1];
21
+ day = dateComponents[2];
22
+ } else {
23
+ // Format: mm/dd/yyyy
24
+ month = dateComponents[0];
25
+ day = dateComponents[1];
26
+ year = dateComponents[2];
27
+ }
28
+ } else {
29
+ return input; // Invalid date format
30
+ }
31
+
32
+ // Rearranging to day/month/year format
33
+ return type === 'dateTime' ? day + "-" + month + "-" + year + " " + timePart : day + "-" + month + "-" + year;
34
+ } else {
35
+ return '';
36
+ }
37
+ };
38
+ export var handleCellFormat = function handleCellFormat(data, type) {
39
+ switch (type) {
40
+ case 'date':
41
+ case 'dateTime':
42
+ return convertDateFormat(data, type);
43
+ default:
44
+ return data;
45
+ }
46
+ };
@@ -41,7 +41,8 @@ var MenuDropDown = function MenuDropDown(_ref) {
41
41
  }, /*#__PURE__*/React.createElement(ThreeDotIcon, null)), openMenu && /*#__PURE__*/React.createElement("div", {
42
42
  className: 'qbs-table-qbs-table-menu-dropdown-content'
43
43
  }, actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.map(function (item) {
44
- return /*#__PURE__*/React.createElement(React.Fragment, null, !item.hidden && /*#__PURE__*/React.createElement("a", {
44
+ var _item$hide;
45
+ return /*#__PURE__*/React.createElement(React.Fragment, null, !(item !== null && item !== void 0 && item.hidden) && !(item !== null && item !== void 0 && (_item$hide = item.hide) !== null && _item$hide !== void 0 && _item$hide.call(item, rowData)) && /*#__PURE__*/React.createElement("a", {
45
46
  key: item.title,
46
47
  className: "p-2 leading-7 hover:bg-background ",
47
48
  onClick: function onClick(e) {
@@ -8,9 +8,10 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _Cell = _interopRequireDefault(require("../Cell"));
10
10
  var _menuDropDown = _interopRequireDefault(require("./utilities/menuDropDown"));
11
+ var _handleFormatCell = require("./utilities/handleFormatCell");
11
12
  var _excluded = ["rowData", "onChange", "checkedKeys", "dataKey", "dataTheme"],
12
13
  _excluded2 = ["rowData", "dataKey", "expandedRowKeys", "onChange"],
13
- _excluded3 = ["rowData", "renderCell", "toolTip", "dataKey", "onChange", "rowClick", "link"];
14
+ _excluded3 = ["rowData", "renderCell", "toolTip", "dataKey", "onChange", "rowClick", "type", "link"];
14
15
  var CHECKBOX_LINE_HEIGHT = '36px';
15
16
  var CheckCell = /*#__PURE__*/_react["default"].memo(function (_ref) {
16
17
  var rowData = _ref.rowData,
@@ -86,6 +87,7 @@ var CustomTableCell = /*#__PURE__*/_react["default"].memo(function (_ref4) {
86
87
  dataKey = _ref4.dataKey,
87
88
  onChange = _ref4.onChange,
88
89
  rowClick = _ref4.rowClick,
90
+ type = _ref4.type,
89
91
  link = _ref4.link,
90
92
  props = (0, _objectWithoutPropertiesLoose2["default"])(_ref4, _excluded3);
91
93
  return /*#__PURE__*/_react["default"].createElement(_Cell["default"], (0, _extends2["default"])({}, props, {
@@ -95,6 +97,6 @@ var CustomTableCell = /*#__PURE__*/_react["default"].memo(function (_ref4) {
95
97
  return rowClick === null || rowClick === void 0 ? void 0 : rowClick(rowData);
96
98
  },
97
99
  className: "qbs-table-row-link"
98
- }, renderCell ? (_renderCell = renderCell(rowData)) === null || _renderCell === void 0 ? void 0 : _renderCell.cell : rowData[dataKey]) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (_renderCell2 = renderCell(rowData)) === null || _renderCell2 === void 0 ? void 0 : _renderCell2.cell));
100
+ }, renderCell ? (_renderCell = renderCell(rowData)) === null || _renderCell === void 0 ? void 0 : _renderCell.cell : (0, _handleFormatCell.handleCellFormat)(rowData[dataKey], type)) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, renderCell ? (_renderCell2 = renderCell(rowData)) === null || _renderCell2 === void 0 ? void 0 : _renderCell2.cell : (0, _handleFormatCell.handleCellFormat)(rowData[dataKey], type)));
99
101
  });
100
102
  exports.CustomTableCell = CustomTableCell;
@@ -193,7 +193,8 @@ var QbsTable = function QbsTable(_ref) {
193
193
  tableHeaderActions: tableHeaderActions,
194
194
  selectedRowActions: selectedRowActions,
195
195
  onSelect: handleClear,
196
- handleColumnToggle: handleColumnToggle
196
+ handleColumnToggle: handleColumnToggle,
197
+ dataLength: data === null || data === void 0 ? void 0 : data.length
197
198
  };
198
199
  var themeToggle = (0, _react.useMemo)(function () {
199
200
  return document.getElementById('themeToggle');
@@ -291,7 +292,8 @@ var QbsTable = function QbsTable(_ref) {
291
292
  isVisible = _ref3.isVisible,
292
293
  link = _ref3.link,
293
294
  rowClick = _ref3.rowClick,
294
- sortKey = _ref3.sortKey;
295
+ sortKey = _ref3.sortKey,
296
+ type = _ref3.type;
295
297
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, isVisible && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, grouped ? /*#__PURE__*/_react["default"].createElement(_ColumnGroup["default"], {
296
298
  header: groupheader,
297
299
  fixed: fixed,
@@ -316,6 +318,7 @@ var QbsTable = function QbsTable(_ref) {
316
318
  renderCell: child.renderCell,
317
319
  dataKey: child.field,
318
320
  dataTheme: dataTheme,
321
+ type: child.type,
319
322
  link: child.link
320
323
  }) : /*#__PURE__*/_react["default"].createElement(_Cell["default"], {
321
324
  className: " " + classes.cellClass,
@@ -338,6 +341,7 @@ var QbsTable = function QbsTable(_ref) {
338
341
  renderCell: renderCell,
339
342
  dataKey: field,
340
343
  rowClick: rowClick,
344
+ type: type,
341
345
  dataTheme: dataTheme,
342
346
  link: link
343
347
  }) : /*#__PURE__*/_react["default"].createElement(_Cell["default"], {
@@ -25,7 +25,8 @@ var ToolBar = function ToolBar(_ref) {
25
25
  tableHeaderActions = _ref.tableHeaderActions,
26
26
  selectedRowActions = _ref.selectedRowActions,
27
27
  checkedKeys = _ref.checkedKeys,
28
- onSelect = _ref.onSelect;
28
+ onSelect = _ref.onSelect,
29
+ dataLength = _ref.dataLength;
29
30
  var debouncedOnSearch = (0, _react.useCallback)((0, _debounce["default"])(onSearch != null ? onSearch : function () {}, 1000), [onSearch]);
30
31
  var handleSearch = (0, _react.useCallback)(function (e) {
31
32
  if (debouncedOnSearch) {
@@ -91,7 +92,7 @@ var ToolBar = function ToolBar(_ref) {
91
92
  return actions === null || actions === void 0 ? void 0 : actions.action(checkedKeys);
92
93
  }
93
94
  }, actions.actionTitle));
94
- }))) : /*#__PURE__*/_react["default"].createElement("div", null, pagination && paginationProps && /*#__PURE__*/_react["default"].createElement("div", {
95
+ }))) : /*#__PURE__*/_react["default"].createElement("div", null, pagination && paginationProps && dataLength > 0 && /*#__PURE__*/_react["default"].createElement("div", {
95
96
  className: "rows-count"
96
97
  }, (0, _tablecalc.getRowDisplayRange)((_paginationProps$tota = paginationProps.total) != null ? _paginationProps$tota : 0, (_paginationProps$rows = paginationProps.rowsPerPage) != null ? _paginationProps$rows : 0, (_paginationProps$curr = paginationProps.currentPage) != null ? _paginationProps$curr : 0)))));
97
98
  };
@@ -17,6 +17,7 @@ export interface ColumnBase {
17
17
  link?: boolean;
18
18
  rowClick?: (rowData: any) => void;
19
19
  sortKey?: string;
20
+ type?: string;
20
21
  }
21
22
  export interface QbsColumnProps extends ColumnBase {
22
23
  grouped?: boolean;
@@ -38,6 +39,7 @@ export interface ActionProps {
38
39
  icon: React.ReactNode;
39
40
  toolTip?: string;
40
41
  hidden?: boolean;
42
+ hide?: (data: any) => boolean;
41
43
  }
42
44
  export interface QbsTableProps {
43
45
  isLoading?: boolean;
@@ -114,6 +116,7 @@ export interface QbsTableToolbarProps {
114
116
  tableHeaderActions?: ReactElement | ReactNode;
115
117
  onSelect?: (keys: any[]) => void;
116
118
  handleColumnToggle?: (columns: QbsColumnProps[]) => void;
119
+ dataLength: number;
117
120
  selectedRowActions?: {
118
121
  actionTitle?: string;
119
122
  action: (checked: (number | string)[]) => void;
@@ -0,0 +1 @@
1
+ export declare const handleCellFormat: (data: any, type: string) => any;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.handleCellFormat = void 0;
5
+ var convertDateFormat = function convertDateFormat(input, type) {
6
+ // Splitting the string by space to separate date and time
7
+ if (input && input !== null) {
8
+ var parts = input.split(' ');
9
+ var datePart = parts[0];
10
+ var timePart = parts.length > 1 ? " " + parts[1] : '';
11
+
12
+ // Splitting the date into [month, day, year]
13
+ var separator = datePart.includes('-') ? '-' : '/';
14
+ var dateComponents = datePart.split(separator);
15
+ if (dateComponents.length !== 3) {
16
+ // Invalid date format
17
+ return input;
18
+ }
19
+ var day, month, year;
20
+ if (dateComponents.length === 3) {
21
+ if (dateComponents[0].length === 4) {
22
+ // Format: yyyy/mm/dd
23
+ year = dateComponents[0];
24
+ month = dateComponents[1];
25
+ day = dateComponents[2];
26
+ } else {
27
+ // Format: mm/dd/yyyy
28
+ month = dateComponents[0];
29
+ day = dateComponents[1];
30
+ year = dateComponents[2];
31
+ }
32
+ } else {
33
+ return input; // Invalid date format
34
+ }
35
+
36
+ // Rearranging to day/month/year format
37
+ return type === 'dateTime' ? day + "-" + month + "-" + year + " " + timePart : day + "-" + month + "-" + year;
38
+ } else {
39
+ return '';
40
+ }
41
+ };
42
+ var handleCellFormat = function handleCellFormat(data, type) {
43
+ switch (type) {
44
+ case 'date':
45
+ case 'dateTime':
46
+ return convertDateFormat(data, type);
47
+ default:
48
+ return data;
49
+ }
50
+ };
51
+ exports.handleCellFormat = handleCellFormat;
@@ -47,7 +47,8 @@ var MenuDropDown = function MenuDropDown(_ref) {
47
47
  }, /*#__PURE__*/_react["default"].createElement(_icons.ThreeDotIcon, null)), openMenu && /*#__PURE__*/_react["default"].createElement("div", {
48
48
  className: 'qbs-table-qbs-table-menu-dropdown-content'
49
49
  }, actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.map(function (item) {
50
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, !item.hidden && /*#__PURE__*/_react["default"].createElement("a", {
50
+ var _item$hide;
51
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, !(item !== null && item !== void 0 && item.hidden) && !(item !== null && item !== void 0 && (_item$hide = item.hide) !== null && _item$hide !== void 0 && _item$hide.call(item, rowData)) && /*#__PURE__*/_react["default"].createElement("a", {
51
52
  key: item.title,
52
53
  className: "p-2 leading-7 hover:bg-background ",
53
54
  onClick: function onClick(e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qbs-react-grid",
3
- "version": "1.0.50",
3
+ "version": "1.1.0",
4
4
  "description": "A React table component",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -2,6 +2,7 @@ import React from 'react';
2
2
 
3
3
  import Cell from '../Cell';
4
4
  import MenuDropDown from './utilities/menuDropDown';
5
+ import { handleCellFormat } from './utilities/handleFormatCell';
5
6
 
6
7
  const CHECKBOX_LINE_HEIGHT = '36px';
7
8
 
@@ -61,15 +62,15 @@ export const ExpandCell: React.FC<any> = React.memo(
61
62
  )
62
63
  );
63
64
  export const CustomTableCell: React.FC<any> = React.memo(
64
- ({ rowData, renderCell, toolTip, dataKey, onChange, rowClick, link, ...props }) => {
65
+ ({ rowData, renderCell, toolTip, dataKey, onChange, rowClick, type, link, ...props }) => {
65
66
  return (
66
67
  <Cell {...props} dataKey={dataKey}>
67
68
  {link ? (
68
69
  <a onClick={() => rowClick?.(rowData)} className="qbs-table-row-link">
69
- {renderCell ? renderCell(rowData)?.cell : rowData[dataKey]}
70
+ {renderCell ? renderCell(rowData)?.cell : handleCellFormat(rowData[dataKey], type)}
70
71
  </a>
71
72
  ) : (
72
- <>{renderCell(rowData)?.cell}</>
73
+ <>{renderCell ? renderCell(rowData)?.cell : handleCellFormat(rowData[dataKey], type)}</>
73
74
  )}
74
75
  </Cell>
75
76
  );
@@ -172,7 +172,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
172
172
  tableHeaderActions: tableHeaderActions,
173
173
  selectedRowActions: selectedRowActions,
174
174
  onSelect: handleClear,
175
- handleColumnToggle: handleColumnToggle
175
+ handleColumnToggle: handleColumnToggle,
176
+ dataLength: data?.length
176
177
  };
177
178
  const themeToggle = useMemo(() => document.getElementById('themeToggle') as HTMLInputElement, []);
178
179
 
@@ -276,7 +277,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
276
277
  isVisible,
277
278
  link,
278
279
  rowClick,
279
- sortKey
280
+ sortKey,
281
+ type
280
282
  }) => (
281
283
  <>
282
284
  {isVisible && (
@@ -312,6 +314,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
312
314
  renderCell={child.renderCell}
313
315
  dataKey={child.field}
314
316
  dataTheme={dataTheme}
317
+ type={child.type}
315
318
  link={child.link}
316
319
  />
317
320
  ) : (
@@ -347,6 +350,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
347
350
  renderCell={renderCell}
348
351
  dataKey={field}
349
352
  rowClick={rowClick}
353
+ type={type}
350
354
  dataTheme={dataTheme}
351
355
  link={link}
352
356
  />
@@ -19,7 +19,8 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
19
19
  tableHeaderActions,
20
20
  selectedRowActions,
21
21
  checkedKeys,
22
- onSelect
22
+ onSelect,
23
+ dataLength
23
24
  }) => {
24
25
  const debouncedOnSearch = useCallback(debounce(onSearch ?? (() => {}), 1000), [onSearch]);
25
26
 
@@ -99,7 +100,7 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
99
100
  </div>
100
101
  ) : (
101
102
  <div>
102
- {pagination && paginationProps && (
103
+ {pagination && paginationProps && dataLength > 0 && (
103
104
  <div className="rows-count">
104
105
  {getRowDisplayRange(
105
106
  paginationProps.total ?? 0,
@@ -18,6 +18,7 @@ export interface ColumnBase {
18
18
  link?: boolean;
19
19
  rowClick?: (rowData: any) => void;
20
20
  sortKey?: string;
21
+ type?: string;
21
22
  }
22
23
 
23
24
  export interface QbsColumnProps extends ColumnBase {
@@ -42,6 +43,7 @@ export interface ActionProps {
42
43
  icon: React.ReactNode;
43
44
  toolTip?: string;
44
45
  hidden?: boolean;
46
+ hide?: (data: any) => boolean;
45
47
  }
46
48
 
47
49
  export interface QbsTableProps {
@@ -118,6 +120,7 @@ export interface QbsTableToolbarProps {
118
120
  tableHeaderActions?: ReactElement | ReactNode;
119
121
  onSelect?: (keys: any[]) => void;
120
122
  handleColumnToggle?: (columns: QbsColumnProps[]) => void;
123
+ dataLength: number;
121
124
  selectedRowActions?: {
122
125
  actionTitle?: string;
123
126
  action: (checked: (number | string)[]) => void;
@@ -1,4 +1,5 @@
1
- import React, { useCallback, memo } from 'react';
1
+ import React, { memo, useCallback } from 'react';
2
+
2
3
  export interface SearchProps {
3
4
  placeholder: string;
4
5
  handleChange: (value: string) => void;
@@ -0,0 +1,45 @@
1
+ const convertDateFormat = (input: string, type?: string): string => {
2
+ // Splitting the string by space to separate date and time
3
+ if (input && input !== null) {
4
+ const parts = input.split(' ');
5
+ const datePart = parts[0];
6
+ const timePart = parts.length > 1 ? ` ${parts[1]}` : '';
7
+
8
+ // Splitting the date into [month, day, year]
9
+ const separator = datePart.includes('-') ? '-' : '/';
10
+
11
+ const dateComponents = datePart.split(separator);
12
+
13
+ if (dateComponents.length !== 3) {
14
+ // Invalid date format
15
+ return input;
16
+ }
17
+ let day, month, year;
18
+ if (dateComponents.length === 3) {
19
+ if (dateComponents[0].length === 4) {
20
+ // Format: yyyy/mm/dd
21
+ [year, month, day] = dateComponents;
22
+ } else {
23
+ // Format: mm/dd/yyyy
24
+ [month, day, year] = dateComponents;
25
+ }
26
+ } else {
27
+ return input; // Invalid date format
28
+ }
29
+
30
+ // Rearranging to day/month/year format
31
+ return type === 'dateTime' ? `${day}-${month}-${year} ${timePart}` : `${day}-${month}-${year}`;
32
+ } else {
33
+ return '';
34
+ }
35
+ };
36
+
37
+ export const handleCellFormat = (data: any, type: string) => {
38
+ switch (type) {
39
+ case 'date':
40
+ case 'dateTime':
41
+ return convertDateFormat(data, type);
42
+ default:
43
+ return data;
44
+ }
45
+ };
@@ -50,7 +50,7 @@ const MenuDropDown: React.FC<Props> = ({ actionDropDown, handleMenuActions, rowD
50
50
  <div className={'qbs-table-qbs-table-menu-dropdown-content'}>
51
51
  {actionDropDown?.map(item => (
52
52
  <>
53
- {!item.hidden && (
53
+ {!item?.hidden && !item?.hide?.(rowData) && (
54
54
  <a
55
55
  key={item.title}
56
56
  className={`p-2 leading-7 hover:bg-background `}