qbs-react-grid 1.2.2 → 1.2.4

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 (35) 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/less/qbs-table.less +89 -22
  5. package/es/qbsTable/QbsTable.js +7 -1
  6. package/es/qbsTable/Toolbar.js +9 -7
  7. package/es/qbsTable/commontypes.d.ts +3 -0
  8. package/es/qbsTable/utilities/CardComponent.d.ts +2 -0
  9. package/es/qbsTable/utilities/CardComponent.js +28 -9
  10. package/es/qbsTable/utilities/CardMenuDropdown.js +11 -7
  11. package/es/qbsTable/utilities/SwitchCardColumns.js +2 -2
  12. package/es/qbsTable/utilities/ToolTip.js +2 -5
  13. package/es/qbsTable/utilities/store.d.ts +2 -0
  14. package/es/qbsTable/utilities/store.js +60 -0
  15. package/lib/less/qbs-table.less +89 -22
  16. package/lib/qbsTable/QbsTable.js +7 -1
  17. package/lib/qbsTable/Toolbar.js +8 -6
  18. package/lib/qbsTable/commontypes.d.ts +3 -0
  19. package/lib/qbsTable/utilities/CardComponent.d.ts +2 -0
  20. package/lib/qbsTable/utilities/CardComponent.js +27 -8
  21. package/lib/qbsTable/utilities/CardMenuDropdown.js +12 -7
  22. package/lib/qbsTable/utilities/SwitchCardColumns.js +2 -2
  23. package/lib/qbsTable/utilities/ToolTip.js +2 -5
  24. package/lib/qbsTable/utilities/store.d.ts +2 -0
  25. package/lib/qbsTable/utilities/store.js +66 -0
  26. package/package.json +1 -1
  27. package/src/less/qbs-table.less +89 -22
  28. package/src/qbsTable/QbsTable.tsx +6 -2
  29. package/src/qbsTable/Toolbar.tsx +8 -7
  30. package/src/qbsTable/commontypes.ts +3 -0
  31. package/src/qbsTable/utilities/CardComponent.tsx +91 -61
  32. package/src/qbsTable/utilities/CardMenuDropdown.tsx +10 -8
  33. package/src/qbsTable/utilities/SwitchCardColumns.tsx +2 -2
  34. package/src/qbsTable/utilities/ToolTip.tsx +1 -4
  35. package/src/qbsTable/utilities/store.ts +61 -0
@@ -1,9 +1,11 @@
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 _icons = require("./icons");
8
+ var _ToolTip = _interopRequireDefault(require("./ToolTip"));
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; }
9
11
  var CardMenuDropdown = function CardMenuDropdown(_ref) {
@@ -61,7 +63,6 @@ var CardMenuDropdown = function CardMenuDropdown(_ref) {
61
63
  handleMenuActions === null || handleMenuActions === void 0 ? void 0 : handleMenuActions(item, rowData);
62
64
  handleClose();
63
65
  };
64
- console.log(menuPositionStyles);
65
66
  return /*#__PURE__*/_react["default"].createElement("div", {
66
67
  className: "dropdown text-black dark:text-white dark:bg-[#424242] bg-white",
67
68
  ref: menuRef
@@ -69,25 +70,29 @@ var CardMenuDropdown = function CardMenuDropdown(_ref) {
69
70
  className: "dropdown-toggle",
70
71
  onClick: toggleMenu,
71
72
  ref: menuButtonRef
72
- }, /*#__PURE__*/_react["default"].createElement(_icons.ThreeDotIcon, null)), openMenu && /*#__PURE__*/_react["default"].createElement("div", {
73
- className: " qbs-card-dropdown rounded absolute right-0 mt-2 w-56 z-10 shadow-modalShadow bg-white dark:bg-[#424242] dark:text-white",
73
+ }, /*#__PURE__*/_react["default"].createElement(_ToolTip["default"], {
74
+ title: "Actions",
75
+ enabled: false,
76
+ ref: menuButtonRef
77
+ }, /*#__PURE__*/_react["default"].createElement(_icons.ThreeDotIcon, null))), openMenu && /*#__PURE__*/_react["default"].createElement("div", {
78
+ className: " qbs-card-dropdown rounded absolute right-0 mt-2 w-auto min-w-11 z-10 shadow-modalShadow bg-white dark:bg-[#424242] dark:text-white",
74
79
  style: menuPositionStyles
75
80
  }, /*#__PURE__*/_react["default"].createElement("div", {
76
- className: "qbs-card-dropdown-menu px-2 bg-white rounded w-full border border-grey-border shadow-menudropdown dark:bg-[#424242] dark:text-white"
81
+ className: "qbs-card-dropdown-menu px-2 bg-white rounded w-full border border-grey-border shadow-lg shadow-menudropdown dark:bg-[#424242] dark:text-white"
77
82
  }, actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.map(function (item) {
78
83
  return !item.hidden && /*#__PURE__*/_react["default"].createElement("a", {
79
84
  key: item.title,
80
85
  href: "#/",
81
- className: 'px-2 hover:bg-background ',
86
+ className: 'px-1 hover:bg-background no-underline whitespace-nowrap ',
82
87
  onClick: function onClick(e) {
83
88
  e.preventDefault();
84
89
  e.stopPropagation();
85
90
  handleMenuItemClick(item);
86
91
  }
87
92
  }, /*#__PURE__*/_react["default"].createElement("div", {
88
- className: " qbs-card-dropdown-menu-item " + (item.isWarning ? 'text-error-light' : 'text-black dark:text-white') + " text-xxs flex items-center w-full tracking-[0.24px] font-medium "
93
+ className: " qbs-card-dropdown-menu-item no-underline " + (item.isWarning ? 'text-error-light' : ' text-black/70 dark:text-white') + " text-xxs flex items-center w-full tracking-[0.24px] font-medium "
89
94
  }, (item === null || item === void 0 ? void 0 : item.icon) && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, item.icon), /*#__PURE__*/_react["default"].createElement("span", {
90
- className: "pl-1.5"
95
+ className: "pl-1.5 no-underline text-sm "
91
96
  }, item.title)));
92
97
  }))));
93
98
  };
@@ -21,10 +21,10 @@ var CustomTableCell = /*#__PURE__*/_react["default"].memo(function (_ref) {
21
21
  onClick: function onClick() {
22
22
  return rowClick === null || rowClick === void 0 ? void 0 : rowClick(rowData);
23
23
  },
24
- className: "qbs-table-row-link " + (!viewMore ? 'line-clamp-1' : '')
24
+ className: "qbs-table-row-link no-underline " + (!viewMore ? 'line-clamp-1' : '')
25
25
  }, renderCell ? (_renderCell = renderCell(rowData)) === null || _renderCell === void 0 ? void 0 : _renderCell.cell : (0, _handleFormatCell.handleCellFormat)(rowData[dataKey], type)) : path && !(hideLink !== null && hideLink !== void 0 && hideLink(rowData)) ? /*#__PURE__*/_react["default"].createElement(_reactRouterDom.Link, {
26
26
  to: (_path = path === null || path === void 0 ? void 0 : path(rowData)) != null ? _path : '',
27
- className: "qbs-table-row-link " + (!viewMore ? 'line-clamp-1' : '')
27
+ className: "qbs-table-row-link no-underline " + (!viewMore ? 'line-clamp-1' : '')
28
28
  }, renderCell ? (_renderCell2 = renderCell(rowData)) === null || _renderCell2 === void 0 ? void 0 : _renderCell2.cell : (0, _handleFormatCell.handleCellFormat)(rowData[dataKey], type)) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, renderCell ? (_renderCell3 = renderCell(rowData)) === null || _renderCell3 === void 0 ? void 0 : _renderCell3.cell : (0, _handleFormatCell.handleCellFormat)(rowData[dataKey], type)));
29
29
  });
30
30
  exports.CustomTableCell = CustomTableCell;
@@ -16,15 +16,12 @@ var TooltipComponent = function TooltipComponent(_ref) {
16
16
  var menuButtonRef = (0, _react.useRef)(null);
17
17
  var adjustDropdownPosition = function adjustDropdownPosition() {
18
18
  if (menuButtonRef.current && tableBodyRef !== null && tableBodyRef !== void 0 && tableBodyRef.current) {
19
- var _menuButtonRef$curren, _tableBodyRef$current, _tableBodyRef$current2;
19
+ var _menuButtonRef$curren;
20
20
  var inputBoxRect = (_menuButtonRef$curren = menuButtonRef.current) === null || _menuButtonRef$curren === void 0 ? void 0 : _menuButtonRef$curren.getBoundingClientRect();
21
- var viewportHeight = (_tableBodyRef$current = tableBodyRef === null || tableBodyRef === void 0 ? void 0 : (_tableBodyRef$current2 = tableBodyRef.current) === null || _tableBodyRef$current2 === void 0 ? void 0 : _tableBodyRef$current2.offsetHeight) != null ? _tableBodyRef$current : window.innerHeight;
22
21
  var tableRect = tableBodyRef.current.getBoundingClientRect();
23
-
24
22
  // Calculate positions relative to the table
25
23
  var spaceAbove = inputBoxRect.top - tableRect.top;
26
24
  var spaceBelow = tableRect.bottom - inputBoxRect.bottom;
27
- console.log(viewportHeight, spaceAbove, spaceBelow);
28
25
  if (spaceAbove > spaceBelow) {
29
26
  setDropdownPosition('top-position');
30
27
  } else {
@@ -44,7 +41,7 @@ var TooltipComponent = function TooltipComponent(_ref) {
44
41
  }
45
42
  }, children), /*#__PURE__*/_react["default"].createElement("span", {
46
43
  ref: dropRef,
47
- className: "tooltiptext "
44
+ className: 'tooltiptext'
48
45
  }, title));
49
46
  };
50
47
  var _default = TooltipComponent;
@@ -0,0 +1,2 @@
1
+ export declare const getGridColsClass: (count: number) => "grid-cols-1" | "grid-cols-2" | "grid-cols-3" | "grid-cols-4" | "grid-cols-5" | "grid-cols-6" | "grid-cols-7" | "grid-cols-8" | "grid-cols-9" | "grid-cols-10" | "grid-cols-11" | "grid-cols-12";
2
+ export declare const getGridColSpanClass: (count: number) => "col-span-1" | "col-span-2" | "col-span-3" | "col-span-4" | "col-span-5" | "col-span--6" | "col-span--7" | "col-span--8" | "col-span--9" | "col-span--10" | "col-span--11" | "col-span--12" | "col-span--1";
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.getGridColsClass = exports.getGridColSpanClass = void 0;
5
+ var getGridColsClass = function getGridColsClass(count) {
6
+ switch (count) {
7
+ case 1:
8
+ return 'grid-cols-1';
9
+ case 2:
10
+ return 'grid-cols-2';
11
+ case 3:
12
+ return 'grid-cols-3';
13
+ case 4:
14
+ return 'grid-cols-4';
15
+ case 5:
16
+ return 'grid-cols-5';
17
+ case 6:
18
+ return 'grid-cols-6';
19
+ case 7:
20
+ return 'grid-cols-7';
21
+ case 8:
22
+ return 'grid-cols-8';
23
+ case 9:
24
+ return 'grid-cols-9';
25
+ case 10:
26
+ return 'grid-cols-10';
27
+ case 11:
28
+ return 'grid-cols-11';
29
+ case 12:
30
+ return 'grid-cols-12';
31
+ default:
32
+ return 'grid-cols-1';
33
+ }
34
+ };
35
+ exports.getGridColsClass = getGridColsClass;
36
+ var getGridColSpanClass = function getGridColSpanClass(count) {
37
+ switch (count) {
38
+ case 1:
39
+ return 'col-span-1';
40
+ case 2:
41
+ return 'col-span-2';
42
+ case 3:
43
+ return 'col-span-3';
44
+ case 4:
45
+ return 'col-span-4';
46
+ case 5:
47
+ return 'col-span-5';
48
+ case 6:
49
+ return 'col-span--6';
50
+ case 7:
51
+ return 'col-span--7';
52
+ case 8:
53
+ return 'col-span--8';
54
+ case 9:
55
+ return 'col-span--9';
56
+ case 10:
57
+ return 'col-span--10';
58
+ case 11:
59
+ return 'col-span--11';
60
+ case 12:
61
+ return 'col-span--12';
62
+ default:
63
+ return 'col-span--1';
64
+ }
65
+ };
66
+ exports.getGridColSpanClass = getGridColSpanClass;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qbs-react-grid",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "A React table component",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -180,16 +180,77 @@
180
180
  transition: all 0.2s ease;
181
181
  }
182
182
  /* Tooltip container */
183
+ // .qbs-table-tooltip {
184
+ // position: relative;
185
+ // display: contents;
186
+ // cursor: pointer;
187
+ // }
188
+
189
+ // .qbs-table-tooltip .tooltiptext {
190
+ // visibility: hidden;
191
+ // background-color: #000;
192
+ // color: #fff;
193
+ // text-align: center;
194
+ // padding: 6px;
195
+ // border-radius: 4px;
196
+ // position: absolute;
197
+ // z-index: 9999;
198
+ // opacity: 0;
199
+ // transition: opacity 0.3s;
200
+ // font-size: 12px;
201
+ // font-style: normal;
202
+ // font-weight: 400;
203
+ // line-height: 16px;
204
+ // width: 100px;
205
+ // }
206
+
207
+ // .qbs-table-tooltip.up .tooltiptext {
208
+ // bottom: 125%;
209
+ // left: 0%;
210
+ // }
211
+
212
+ // .qbs-table-tooltip.down .tooltiptext {
213
+ // top: 125%;
214
+ // right: 0px;
215
+ // left: auto;
216
+ // }
217
+
218
+ // .qbs-table-tooltip:hover .tooltiptext {
219
+ // visibility: visible;
220
+ // opacity: 1;
221
+ // }
222
+
223
+ // .qbs-table-tooltip .tooltiptext::after {
224
+ // content: '';
225
+ // position: absolute;
226
+ // border-width: 5px;
227
+ // border-style: solid;
228
+ // }
229
+
230
+ // .qbs-table-tooltip.up .tooltiptext::after {
231
+ // top: 100%;
232
+ // left: 50%;
233
+ // margin-left: -5px;
234
+ // border-color: #000 transparent transparent transparent;
235
+ // }
236
+
237
+ // .qbs-table-tooltip.down .tooltiptext::after {
238
+ // bottom: 100%;
239
+ // left: 50%;
240
+ // margin-left: -5px;
241
+ // border-color: transparent transparent #000 transparent;
242
+ // }
183
243
  .qbs-table-tooltip {
184
- position: relative;
185
- display: contents;
186
244
  cursor: pointer;
245
+ position: relative;
246
+ width: auto;
247
+ display: flex;
187
248
  }
188
249
 
189
250
  .qbs-table-tooltip .tooltiptext {
190
251
  visibility: hidden;
191
- background-color: #000;
192
- color: #fff;
252
+ background-color: black;
253
+ color: white;
193
254
  text-align: center;
194
255
  padding: 6px;
195
256
  border-radius: 4px;
@@ -205,20 +266,20 @@
205
266
  }
206
267
 
207
268
  .qbs-table-tooltip.up .tooltiptext {
208
- bottom: 125%;
209
- left: 0%;
269
+ bottom: calc(100% + 10px);
270
+ right: -8px;
271
+ left: unset;
210
272
  }
211
273
 
212
274
  .qbs-table-tooltip.down .tooltiptext {
213
- top: 125%;
214
- right: 0px;
215
- left: auto;
275
+ right: -10px;
276
+ top: calc(100% + 8px);
216
277
  }
217
278
 
218
- .qbs-table-tooltip:hover .tooltiptext {
219
- visibility: visible;
220
- opacity: 1;
221
- }
279
+ // .qbs-table-tooltip:hover .tooltiptext {
280
+ // visibility: visible;
281
+ // opacity: 1;
282
+ // }
222
283
 
223
284
  .qbs-table-tooltip .tooltiptext::after {
224
285
  content: '';
@@ -228,19 +289,25 @@
228
289
  }
229
290
 
230
291
  .qbs-table-tooltip.up .tooltiptext::after {
231
- top: 100%;
232
- left: 50%;
233
- margin-left: -5px;
234
- border-color: #000 transparent transparent transparent;
292
+ border-color: black transparent transparent !important;
293
+ right: 12px !important;
294
+ margin-left: -5px !important;
295
+ top: 100% !important;
296
+ left: unset !important;
235
297
  }
236
298
 
237
299
  .qbs-table-tooltip.down .tooltiptext::after {
238
- bottom: 100%;
239
- left: 50%;
240
- margin-left: -5px;
241
- border-color: transparent transparent #000 transparent;
300
+ border-color: transparent transparent black;
301
+ bottom: 100% !important;
302
+ right: 12px !important;
303
+ margin-left: -5px !important;
304
+ left: unset !important;
305
+ }
306
+ .qbs-table-tooltip.down .tooltiptext {
307
+ top: 145% !important;
308
+ right: -10px !important;
309
+ left: auto !important;
242
310
  }
243
-
244
311
  .rs-table-row {
245
312
  overflow: visible !important;
246
313
  }
@@ -84,7 +84,9 @@ const QbsTable: React.FC<QbsTableProps> = ({
84
84
  emptySubTitle,
85
85
  emptyTitle,
86
86
  tableView = true,
87
- enableTableToggle = false
87
+ enableTableToggle = false,
88
+ cardColumLimit = 5,
89
+ childDetailHeading = ''
88
90
  }) => {
89
91
  const [loading, setLoading] = useState(false);
90
92
  const [columns, setColumns] = useState(propColumn);
@@ -234,7 +236,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
234
236
  searchPlaceholder: searchPlaceholder,
235
237
  setTableViewToggle: setTableViewToggle,
236
238
  tableViewToggle: tableViewToggle,
237
- enableTableToggle : enableTableToggle
239
+ enableTableToggle: enableTableToggle
238
240
  };
239
241
  const themeToggle = useMemo(() => document.getElementById('themeToggle') as HTMLInputElement, []);
240
242
 
@@ -634,6 +636,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
634
636
  <div className="flex flex-col gap-3 p-2" key={items?.id}>
635
637
  <CardComponent
636
638
  data={items}
639
+ cardColumLimit={cardColumLimit}
640
+ childDetailHeading={childDetailHeading}
637
641
  columns={columns}
638
642
  tableBodyRef={tableBodyRef}
639
643
  actionProps={actionProps}
@@ -1,11 +1,11 @@
1
- import React, { useCallback, useState } from 'react';
1
+ import React, { useCallback, useRef, useState } from 'react';
2
2
 
3
3
  import { QbsTableToolbarProps } from './commontypes';
4
4
  import debounce from './utilities/debounce';
5
+ import { CardIcon, TableIcon } from './utilities/icons';
5
6
  import SearchInput from './utilities/SearchInput';
6
7
  import { getRowDisplayRange } from './utilities/tablecalc';
7
8
  import TooltipComponent from './utilities/ToolTip';
8
- import { CardIcon, TableIcon } from './utilities/icons';
9
9
 
10
10
  const ToolBar: React.FC<QbsTableToolbarProps> = ({
11
11
  pagination,
@@ -30,6 +30,7 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
30
30
  }) => {
31
31
  const debouncedOnSearch = useCallback(debounce(onSearch ?? (() => {}), 1000), [onSearch]);
32
32
  const [searchParam, setSearchParam] = useState<string | undefined>(searchValue);
33
+ const toolbarRef = useRef<HTMLDivElement>(null);
33
34
  const handleSearch = useCallback(
34
35
  (e?: string) => {
35
36
  if (debouncedOnSearch) {
@@ -60,7 +61,7 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
60
61
  }
61
62
  };
62
63
  return (
63
- <div className="qbs-table-toolbar-container">
64
+ <div className="qbs-table-toolbar-container" ref={toolbarRef}>
64
65
  <div className={`qbs-table-toolbar ${className}`}>
65
66
  <div className="start-container" style={{ display: 'flex', justifyContent: 'flex-end' }}>
66
67
  <div className="qbs-table-primary-filter">
@@ -76,15 +77,15 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
76
77
  </div>
77
78
  </div>
78
79
 
79
- <div className="end-container">
80
+ <div className="end-container flex items-center">
80
81
  {tableHeaderActions}
81
82
  <div
82
- className=" pr-1 cursor-pointer"
83
+ className=" pr-1 cursor-pointer relative"
83
84
  onClick={() => setTableViewToggle?.(!tableViewToggle)}
84
85
  >
85
- {!enableTableToggle && (
86
+ {enableTableToggle && (
86
87
  <TooltipComponent
87
- enabled
88
+ tableBodyRef={toolbarRef}
88
89
  title={tableViewToggle ? 'Switch to Card View' : 'Switch to Table View'}
89
90
  >
90
91
  {!tableViewToggle ? <CardIcon /> : <TableIcon />}
@@ -9,6 +9,7 @@ export interface ColumnBase {
9
9
  field: string;
10
10
  sortable?: boolean;
11
11
  resizable?: boolean;
12
+ colSpan?: number;
12
13
  fixed?: boolean;
13
14
  align?: 'left' | 'right' | 'center';
14
15
  colWidth?: number;
@@ -124,6 +125,8 @@ export interface QbsTableProps {
124
125
  emptyTitle?: string;
125
126
  enableTableToggle?: boolean;
126
127
  tableView?: boolean;
128
+ cardColumLimit?: number;
129
+ childDetailHeading?: string;
127
130
  }
128
131
 
129
132
  export interface QbsTableToolbarProps {
@@ -1,9 +1,11 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useRef } from 'react';
2
2
  import { QbsColumnProps } from '../commontypes';
3
3
  import CardMenuDropdown from './CardMenuDropdown';
4
4
  import { CustomTableCell } from './SwitchCardColumns';
5
5
  import { handleCellFormat } from './handleFormatCell';
6
6
  import { ArrowUpIcon } from './icons';
7
+ import { getGridColsClass, getGridColSpanClass } from './store';
8
+ import TooltipComponent from './ToolTip';
7
9
 
8
10
  type Props = {
9
11
  columns: QbsColumnProps[];
@@ -12,6 +14,8 @@ type Props = {
12
14
  actionProps?: any;
13
15
  index?: number;
14
16
  handleMenuActions?: () => void;
17
+ cardColumLimit?: number;
18
+ childDetailHeading?: string;
15
19
  };
16
20
 
17
21
  const CardComponent: React.FC<Props> = ({
@@ -20,81 +24,107 @@ const CardComponent: React.FC<Props> = ({
20
24
  tableBodyRef,
21
25
  actionProps,
22
26
  index,
23
- handleMenuActions
27
+ cardColumLimit = 5,
28
+ handleMenuActions,
29
+ childDetailHeading = ''
24
30
  }) => {
25
31
  const [viewMore, setViewMore] = useState(false);
26
- const initialDisplayCount = 5;
32
+ const initialDisplayCount = cardColumLimit;
27
33
 
28
34
  const toggleViewMore = () => {
29
35
  setViewMore(!viewMore);
30
36
  };
31
-
37
+ const useCardRef = useRef<HTMLDivElement>(null);
32
38
  const displayedColumns = viewMore ? columns : columns.slice(0, initialDisplayCount);
33
39
 
34
40
  return (
35
- <div className="grid grid-cols-5 p-3 gap-3 border-2 border-grey shadow-sm rounded-lg relative qbs-card-container">
36
- {displayedColumns.map((col: QbsColumnProps, index: number) => (
37
- <div key={index} className="grid col-span-1 place-content-start text-sm qbs-card-column">
38
- <p className=" text-grey ">{col.title}</p>
39
- {col.customCell || col.link ? (
40
- <span
41
- className={`qbs-card-column-content mt-1 font-semibold ${
42
- !viewMore ? 'line-clamp-1' : ''
43
- }`}
44
- >
45
- <CustomTableCell
46
- dataKey={col.field}
47
- rowData={data}
48
- type={col.type}
49
- path={col.getPath}
50
- link={col.link}
51
- viewMore={viewMore}
52
- rowClick={col.rowClick}
53
- renderCell={col.renderCell}
54
- />
55
- </span>
56
- ) : (
57
- <p
58
- className={`mt-1 font-semibold qbs-card-column-content ${
59
- !viewMore ? 'line-clamp-1' : ''
60
- }`}
61
- key={index}
62
- >
63
- {handleCellFormat(data[col.field], col.type as string)}
64
- </p>
65
- )}
66
- </div>
67
- ))}
68
- <div
69
- className={`qbs-card-column-action absolute text-blue-500 mt-2 right-2 ${
70
- columns.length > initialDisplayCount ? 'top-2' : 'top-4'
71
- } text-xs`}
72
- >
41
+ <div
42
+ ref={useCardRef}
43
+ className="p-3 gap-3 border-2 border-grey shadow-sm rounded-lg relative qbs-card-container"
44
+ >
45
+ <div className={`grid ${getGridColsClass(initialDisplayCount)} qbs-card-columns`}>
46
+ {displayedColumns.map((col: QbsColumnProps, index: number) => (
47
+ <div
48
+ key={index}
49
+ className={`grid ${getGridColSpanClass(
50
+ col.colSpan ?? 1
51
+ )} place-content-start text-sm qbs-card-column ${
52
+ index === initialDisplayCount - 1 ? 'mr-4' : ''
53
+ } `}
54
+ >
55
+ <p className=" text-grey ">{col.title}</p>
56
+ {col.customCell || col.link ? (
57
+ <span className={`qbs-card-column-content mt-1 ${!viewMore ? 'line-clamp-1' : ''}`}>
58
+ <CustomTableCell
59
+ dataKey={col.field}
60
+ rowData={data}
61
+ type={col.type}
62
+ path={col.getPath}
63
+ link={col.link}
64
+ viewMore={viewMore}
65
+ rowClick={col.rowClick}
66
+ renderCell={col.renderCell}
67
+ />
68
+ </span>
69
+ ) : (
70
+ <p
71
+ className={`mt-1 qbs-card-column-content ${!viewMore ? 'line-clamp-1' : ''}`}
72
+ key={index}
73
+ >
74
+ {handleCellFormat(data[col.field], col.type as string)}
75
+ </p>
76
+ )}
77
+ </div>
78
+ ))}
79
+
73
80
  <div
74
- className={`flex qbs-card-column-action-container
81
+ className={`qbs-card-column-action absolute text-blue-500 mt-2 right-2 ${
82
+ columns.length > initialDisplayCount ? 'top-2' : 'top-4'
83
+ } text-xs`}
84
+ >
85
+ <div
86
+ className={`flex qbs-card-column-action-container
75
87
  flex-col items-center gap-y-2
76
88
  `}
77
- >
78
- <div className=" text-blue-500 qbs-card-column-action-menu ">
79
- <CardMenuDropdown
80
- tableBodyRef={tableBodyRef}
81
- actionDropDown={actionProps}
82
- rowData={data}
83
- iconName="more"
84
- rowIndex={index}
85
- handleMenuActions={handleMenuActions}
86
- />
89
+ >
90
+ <div className=" text-blue-500 qbs-card-column-action-menu ">
91
+ <CardMenuDropdown
92
+ tableBodyRef={tableBodyRef}
93
+ actionDropDown={actionProps}
94
+ rowData={data}
95
+ iconName="more"
96
+ rowIndex={index}
97
+ handleMenuActions={handleMenuActions}
98
+ />
99
+ </div>
100
+
101
+ {columns.length > initialDisplayCount && (
102
+ <TooltipComponent
103
+ tableBodyRef={useCardRef}
104
+ title={viewMore ? ' View Less' : 'View More'}
105
+ enabled={false}
106
+ >
107
+ <button
108
+ onClick={toggleViewMore}
109
+ className=" qbs-card-column-action-menu-view-more justify-end text-blue-500 text-xs"
110
+ >
111
+ <ArrowUpIcon className={`${viewMore ? 'rotate-180' : ''} `} />
112
+ </button>
113
+ </TooltipComponent>
114
+ )}
87
115
  </div>
88
- {columns.length > initialDisplayCount && (
89
- <button
90
- onClick={toggleViewMore}
91
- className=" qbs-card-column-action-menu-view-more justify-end text-blue-500 text-xs"
92
- >
93
- <ArrowUpIcon className={`${viewMore ? 'rotate-180' : ''} `} />
94
- </button>
95
- )}
96
116
  </div>
97
117
  </div>
118
+ {viewMore && data?.childDetail && (
119
+ <div className="mt-4 p-3 border-t border-grey qbs-card-child-detail-container">
120
+ {childDetailHeading && (
121
+ <p className=" text-lg qbs-card-child-detail-head font-semibold ">
122
+ {childDetailHeading}
123
+ </p>
124
+ )}
125
+ {data?.childDetail}
126
+ </div>
127
+ )}
98
128
  </div>
99
129
  );
100
130
  };