qbs-react-grid 1.2.1 → 1.2.2

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 (51) hide show
  1. package/dist/css/qbs-react-grid.css +1 -1095
  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/Table.js +19 -19
  5. package/es/less/index.less +3 -0
  6. package/es/qbsTable/QbsTable.js +34 -7
  7. package/es/qbsTable/TableCardList.d.ts +5 -0
  8. package/es/qbsTable/TableCardList.js +564 -0
  9. package/es/qbsTable/Toolbar.js +16 -2
  10. package/es/qbsTable/commontypes.d.ts +9 -0
  11. package/es/qbsTable/utilities/CardComponent.d.ts +12 -0
  12. package/es/qbsTable/utilities/CardComponent.js +64 -0
  13. package/es/qbsTable/utilities/CardMenuDropdown.d.ts +13 -0
  14. package/es/qbsTable/utilities/CardMenuDropdown.js +89 -0
  15. package/es/qbsTable/utilities/SwitchCardColumns.d.ts +2 -0
  16. package/es/qbsTable/utilities/SwitchCardColumns.js +24 -0
  17. package/es/qbsTable/utilities/icons.d.ts +3 -0
  18. package/es/qbsTable/utilities/icons.js +45 -0
  19. package/es/utils/getTotalByColumns.js +1 -1
  20. package/es/utils/mergeCells.js +1 -1
  21. package/es/utils/useCellDescriptor.js +11 -11
  22. package/es/utils/useClassNames.js +2 -0
  23. package/lib/Table.js +19 -19
  24. package/lib/less/index.less +3 -0
  25. package/lib/qbsTable/QbsTable.js +34 -7
  26. package/lib/qbsTable/TableCardList.d.ts +5 -0
  27. package/lib/qbsTable/TableCardList.js +571 -0
  28. package/lib/qbsTable/Toolbar.js +16 -2
  29. package/lib/qbsTable/commontypes.d.ts +9 -0
  30. package/lib/qbsTable/utilities/CardComponent.d.ts +12 -0
  31. package/lib/qbsTable/utilities/CardComponent.js +72 -0
  32. package/lib/qbsTable/utilities/CardMenuDropdown.d.ts +13 -0
  33. package/lib/qbsTable/utilities/CardMenuDropdown.js +95 -0
  34. package/lib/qbsTable/utilities/SwitchCardColumns.d.ts +2 -0
  35. package/lib/qbsTable/utilities/SwitchCardColumns.js +30 -0
  36. package/lib/qbsTable/utilities/icons.d.ts +3 -0
  37. package/lib/qbsTable/utilities/icons.js +50 -2
  38. package/lib/utils/getTotalByColumns.js +1 -1
  39. package/lib/utils/mergeCells.js +1 -1
  40. package/lib/utils/useCellDescriptor.js +11 -11
  41. package/lib/utils/useClassNames.js +2 -0
  42. package/package.json +11 -6
  43. package/src/less/index.less +3 -0
  44. package/src/qbsTable/QbsTable.tsx +201 -173
  45. package/src/qbsTable/TableCardList.tsx +629 -0
  46. package/src/qbsTable/Toolbar.tsx +22 -2
  47. package/src/qbsTable/commontypes.ts +9 -0
  48. package/src/qbsTable/utilities/CardComponent.tsx +102 -0
  49. package/src/qbsTable/utilities/CardMenuDropdown.tsx +118 -0
  50. package/src/qbsTable/utilities/SwitchCardColumns.tsx +29 -0
  51. package/src/qbsTable/utilities/icons.tsx +51 -0
@@ -0,0 +1,64 @@
1
+ import React, { useState } from 'react';
2
+ import CardMenuDropdown from './CardMenuDropdown';
3
+ import { CustomTableCell } from './SwitchCardColumns';
4
+ import { handleCellFormat } from './handleFormatCell';
5
+ import { ArrowUpIcon } from './icons';
6
+ var CardComponent = function CardComponent(_ref) {
7
+ var columns = _ref.columns,
8
+ data = _ref.data,
9
+ tableBodyRef = _ref.tableBodyRef,
10
+ actionProps = _ref.actionProps,
11
+ index = _ref.index,
12
+ handleMenuActions = _ref.handleMenuActions;
13
+ var _useState = useState(false),
14
+ viewMore = _useState[0],
15
+ setViewMore = _useState[1];
16
+ var initialDisplayCount = 5;
17
+ var toggleViewMore = function toggleViewMore() {
18
+ setViewMore(!viewMore);
19
+ };
20
+ var displayedColumns = viewMore ? columns : columns.slice(0, initialDisplayCount);
21
+ return /*#__PURE__*/React.createElement("div", {
22
+ className: "grid grid-cols-5 p-3 gap-3 border-2 border-grey shadow-sm rounded-lg relative qbs-card-container"
23
+ }, displayedColumns.map(function (col, index) {
24
+ return /*#__PURE__*/React.createElement("div", {
25
+ key: index,
26
+ className: "grid col-span-1 place-content-start text-sm qbs-card-column"
27
+ }, /*#__PURE__*/React.createElement("p", {
28
+ className: " text-grey "
29
+ }, col.title), col.customCell || col.link ? /*#__PURE__*/React.createElement("span", {
30
+ className: "qbs-card-column-content mt-1 font-semibold " + (!viewMore ? 'line-clamp-1' : '')
31
+ }, /*#__PURE__*/React.createElement(CustomTableCell, {
32
+ dataKey: col.field,
33
+ rowData: data,
34
+ type: col.type,
35
+ path: col.getPath,
36
+ link: col.link,
37
+ viewMore: viewMore,
38
+ rowClick: col.rowClick,
39
+ renderCell: col.renderCell
40
+ })) : /*#__PURE__*/React.createElement("p", {
41
+ className: "mt-1 font-semibold qbs-card-column-content " + (!viewMore ? 'line-clamp-1' : ''),
42
+ key: index
43
+ }, handleCellFormat(data[col.field], col.type)));
44
+ }), /*#__PURE__*/React.createElement("div", {
45
+ className: "qbs-card-column-action absolute text-blue-500 mt-2 right-2 " + (columns.length > initialDisplayCount ? 'top-2' : 'top-4') + " text-xs"
46
+ }, /*#__PURE__*/React.createElement("div", {
47
+ className: "flex qbs-card-column-action-container\n flex-col items-center gap-y-2\n "
48
+ }, /*#__PURE__*/React.createElement("div", {
49
+ className: " text-blue-500 qbs-card-column-action-menu "
50
+ }, /*#__PURE__*/React.createElement(CardMenuDropdown, {
51
+ tableBodyRef: tableBodyRef,
52
+ actionDropDown: actionProps,
53
+ rowData: data,
54
+ iconName: "more",
55
+ rowIndex: index,
56
+ handleMenuActions: handleMenuActions
57
+ })), columns.length > initialDisplayCount && /*#__PURE__*/React.createElement("button", {
58
+ onClick: toggleViewMore,
59
+ className: " qbs-card-column-action-menu-view-more justify-end text-blue-500 text-xs"
60
+ }, /*#__PURE__*/React.createElement(ArrowUpIcon, {
61
+ className: (viewMore ? 'rotate-180' : '') + " "
62
+ })))));
63
+ };
64
+ export default CardComponent;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { ActionProps } from '../commontypes';
3
+ type Props = {
4
+ iconName: string;
5
+ actionDropDown: ActionProps[];
6
+ handleMenuActions?: (slug: ActionProps, rowData?: any) => void;
7
+ rowData?: any;
8
+ dataTheme?: string;
9
+ tableBodyRef: React.RefObject<HTMLDivElement>;
10
+ rowIndex?: number;
11
+ };
12
+ declare const CardMenuDropdown: React.FC<Props>;
13
+ export default CardMenuDropdown;
@@ -0,0 +1,89 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import React from 'react';
3
+ import { ThreeDotIcon } from './icons';
4
+ var CardMenuDropdown = function CardMenuDropdown(_ref) {
5
+ var actionDropDown = _ref.actionDropDown,
6
+ handleMenuActions = _ref.handleMenuActions,
7
+ rowData = _ref.rowData;
8
+ var _useState = useState(false),
9
+ openMenu = _useState[0],
10
+ setOpenMenu = _useState[1];
11
+ var _useState2 = useState({}),
12
+ menuPositionStyles = _useState2[0],
13
+ setMenuPositionStyles = _useState2[1];
14
+ var menuButtonRef = useRef(null);
15
+ var menuRef = useRef(null);
16
+ useEffect(function () {
17
+ var handleClickOutside = function handleClickOutside(event) {
18
+ if (menuRef.current && !menuRef.current.contains(event.target)) {
19
+ setOpenMenu(false);
20
+ }
21
+ };
22
+ document.addEventListener('click', handleClickOutside);
23
+ return function () {
24
+ document.removeEventListener('click', handleClickOutside);
25
+ };
26
+ }, []);
27
+ var toggleMenu = function toggleMenu() {
28
+ setOpenMenu(function (prevState) {
29
+ if (!prevState && menuButtonRef.current) {
30
+ var buttonRect = menuButtonRef.current.getBoundingClientRect();
31
+ var dropdownHeight = 200; // Adjust this if your dropdown height varies
32
+ var spaceBelow = window.innerHeight - buttonRect.bottom;
33
+ var spaceAbove = buttonRect.top;
34
+ console.log(spaceAbove, spaceBelow, dropdownHeight);
35
+ if (spaceBelow < dropdownHeight && spaceAbove > spaceBelow) {
36
+ setMenuPositionStyles({
37
+ bottom: '30px',
38
+ right: '10px'
39
+ });
40
+ } else {
41
+ setMenuPositionStyles({
42
+ top: buttonRect.height + "px",
43
+ right: '10px'
44
+ });
45
+ }
46
+ }
47
+ return !prevState;
48
+ });
49
+ };
50
+ var handleClose = function handleClose() {
51
+ setOpenMenu(false);
52
+ };
53
+ var handleMenuItemClick = function handleMenuItemClick(item) {
54
+ var _item$action;
55
+ (_item$action = item.action) === null || _item$action === void 0 ? void 0 : _item$action.call(item, item);
56
+ handleMenuActions === null || handleMenuActions === void 0 ? void 0 : handleMenuActions(item, rowData);
57
+ handleClose();
58
+ };
59
+ console.log(menuPositionStyles);
60
+ return /*#__PURE__*/React.createElement("div", {
61
+ className: "dropdown text-black dark:text-white dark:bg-[#424242] bg-white",
62
+ ref: menuRef
63
+ }, /*#__PURE__*/React.createElement("button", {
64
+ className: "dropdown-toggle",
65
+ onClick: toggleMenu,
66
+ ref: menuButtonRef
67
+ }, /*#__PURE__*/React.createElement(ThreeDotIcon, null)), openMenu && /*#__PURE__*/React.createElement("div", {
68
+ className: " qbs-card-dropdown rounded absolute right-0 mt-2 w-56 z-10 shadow-modalShadow bg-white dark:bg-[#424242] dark:text-white",
69
+ style: menuPositionStyles
70
+ }, /*#__PURE__*/React.createElement("div", {
71
+ className: "qbs-card-dropdown-menu px-2 bg-white rounded w-full border border-grey-border shadow-menudropdown dark:bg-[#424242] dark:text-white"
72
+ }, actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.map(function (item) {
73
+ return !item.hidden && /*#__PURE__*/React.createElement("a", {
74
+ key: item.title,
75
+ href: "#/",
76
+ className: 'px-2 hover:bg-background ',
77
+ onClick: function onClick(e) {
78
+ e.preventDefault();
79
+ e.stopPropagation();
80
+ handleMenuItemClick(item);
81
+ }
82
+ }, /*#__PURE__*/React.createElement("div", {
83
+ 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 "
84
+ }, (item === null || item === void 0 ? void 0 : item.icon) && /*#__PURE__*/React.createElement(React.Fragment, null, item.icon), /*#__PURE__*/React.createElement("span", {
85
+ className: "pl-1.5"
86
+ }, item.title)));
87
+ }))));
88
+ };
89
+ export default CardMenuDropdown;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const CustomTableCell: React.FC<any>;
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { Link } from 'react-router-dom';
3
+ import { handleCellFormat } from './handleFormatCell';
4
+ export var CustomTableCell = /*#__PURE__*/React.memo(function (_ref) {
5
+ var _renderCell, _path, _renderCell2, _renderCell3;
6
+ var rowData = _ref.rowData,
7
+ renderCell = _ref.renderCell,
8
+ hideLink = _ref.hideLink,
9
+ dataKey = _ref.dataKey,
10
+ rowClick = _ref.rowClick,
11
+ type = _ref.type,
12
+ path = _ref.path,
13
+ link = _ref.link,
14
+ viewMore = _ref.viewMore;
15
+ return /*#__PURE__*/React.createElement(React.Fragment, null, link && !path && !(hideLink !== null && hideLink !== void 0 && hideLink(rowData)) ? /*#__PURE__*/React.createElement("a", {
16
+ onClick: function onClick() {
17
+ return rowClick === null || rowClick === void 0 ? void 0 : rowClick(rowData);
18
+ },
19
+ className: "qbs-table-row-link " + (!viewMore ? 'line-clamp-1' : '')
20
+ }, renderCell ? (_renderCell = renderCell(rowData)) === null || _renderCell === void 0 ? void 0 : _renderCell.cell : handleCellFormat(rowData[dataKey], type)) : path && !(hideLink !== null && hideLink !== void 0 && hideLink(rowData)) ? /*#__PURE__*/React.createElement(Link, {
21
+ to: (_path = path === null || path === void 0 ? void 0 : path(rowData)) != null ? _path : '',
22
+ className: "qbs-table-row-link " + (!viewMore ? 'line-clamp-1' : '')
23
+ }, renderCell ? (_renderCell2 = renderCell(rowData)) === null || _renderCell2 === void 0 ? void 0 : _renderCell2.cell : handleCellFormat(rowData[dataKey], type)) : /*#__PURE__*/React.createElement(React.Fragment, null, renderCell ? (_renderCell3 = renderCell(rowData)) === null || _renderCell3 === void 0 ? void 0 : _renderCell3.cell : handleCellFormat(rowData[dataKey], type)));
24
+ });
@@ -1,3 +1,6 @@
1
1
  import React from 'react';
2
2
  export declare const ThreeDotIcon: React.FC<any>;
3
3
  export declare const SettingsIcon: React.FC<any>;
4
+ export declare const ArrowUpIcon: React.FC<any>;
5
+ export declare const TableIcon: React.FC<any>;
6
+ export declare const CardIcon: React.FC<any>;
@@ -36,4 +36,49 @@ export var SettingsIcon = function SettingsIcon() {
36
36
  strokeLinecap: "round",
37
37
  strokeLinejoin: "round"
38
38
  }));
39
+ };
40
+ export var ArrowUpIcon = function ArrowUpIcon(_ref) {
41
+ var className = _ref.className;
42
+ return /*#__PURE__*/React.createElement("svg", {
43
+ xmlns: "http://www.w3.org/2000/svg",
44
+ fill: "none",
45
+ viewBox: "0 0 24 24",
46
+ strokeWidth: "3",
47
+ stroke: "currentColor",
48
+ className: className + " w-4 h-4"
49
+ }, /*#__PURE__*/React.createElement("path", {
50
+ strokeLinecap: "round",
51
+ strokeLinejoin: "round",
52
+ d: "m19.5 8.25-7.5 7.5-7.5-7.5"
53
+ }));
54
+ };
55
+ export var TableIcon = function TableIcon(_ref2) {
56
+ var className = _ref2.className;
57
+ return /*#__PURE__*/React.createElement("svg", {
58
+ xmlns: "http://www.w3.org/2000/svg",
59
+ fill: "none",
60
+ viewBox: "0 0 24 24",
61
+ strokeWidth: "1.5",
62
+ stroke: "currentColor",
63
+ className: className + " w-6 h-6"
64
+ }, /*#__PURE__*/React.createElement("path", {
65
+ strokeLinecap: "round",
66
+ strokeLinejoin: "round",
67
+ d: "M2.25 8.25h19.5M2.25 9h19.5m-16.5 5.25h6m-6 2.25h3m-3.75 3h15a2.25 2.25 0 0 0 2.25-2.25V6.75A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25v10.5A2.25 2.25 0 0 0 4.5 19.5Z"
68
+ }));
69
+ };
70
+ export var CardIcon = function CardIcon(_ref3) {
71
+ var className = _ref3.className;
72
+ return /*#__PURE__*/React.createElement("svg", {
73
+ xmlns: "http://www.w3.org/2000/svg",
74
+ fill: "none",
75
+ viewBox: "0 0 24 24",
76
+ strokeWidth: "1.5",
77
+ stroke: "currentColor",
78
+ className: className + " w-6 h-6"
79
+ }, /*#__PURE__*/React.createElement("path", {
80
+ strokeLinecap: "round",
81
+ strokeLinejoin: "round",
82
+ d: "M3.375 19.5h17.25m-17.25 0a1.125 1.125 0 0 1-1.125-1.125M3.375 19.5h7.5c.621 0 1.125-.504 1.125-1.125m-9.75 0V5.625m0 12.75v-1.5c0-.621.504-1.125 1.125-1.125m18.375 2.625V5.625m0 12.75c0 .621-.504 1.125-1.125 1.125m1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125m0 3.75h-7.5A1.125 1.125 0 0 1 12 18.375m9.75-12.75c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125m19.5 0v1.5c0 .621-.504 1.125-1.125 1.125M2.25 5.625v1.5c0 .621.504 1.125 1.125 1.125m0 0h17.25m-17.25 0h7.5c.621 0 1.125.504 1.125 1.125M3.375 8.25c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125m17.25-3.75h-7.5c-.621 0-1.125.504-1.125 1.125m8.625-1.125c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125m-17.25 0h7.5m-7.5 0c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125M12 10.875v-1.5m0 1.5c0 .621-.504 1.125-1.125 1.125M12 10.875c0 .621.504 1.125 1.125 1.125m-2.25 0c.621 0 1.125.504 1.125 1.125M13.125 12h7.5m-7.5 0c-.621 0-1.125.504-1.125 1.125M20.625 12c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125m-17.25 0h7.5M12 14.625v-1.5m0 1.5c0 .621-.504 1.125-1.125 1.125M12 14.625c0 .621.504 1.125 1.125 1.125m-2.25 0c.621 0 1.125.504 1.125 1.125m0 1.5v-1.5m0 0c0-.621.504-1.125 1.125-1.125m0 0h7.5"
83
+ }));
39
84
  };
@@ -6,7 +6,7 @@ function getTotalByColumns(columns) {
6
6
  var totalWidth = 0;
7
7
  var count = function count(items) {
8
8
  Array.from(items).forEach(function (column) {
9
- if ( /*#__PURE__*/React.isValidElement(column)) {
9
+ if (/*#__PURE__*/React.isValidElement(column)) {
10
10
  var _getColumnProps = getColumnProps(column),
11
11
  flexGrow = _getColumnProps.flexGrow,
12
12
  _getColumnProps$width = _getColumnProps.width,
@@ -46,7 +46,7 @@ function mergeCells(cells) {
46
46
  removed: true
47
47
  });
48
48
  }
49
- groupChildren.push( /*#__PURE__*/React.createElement(HeaderCell, {
49
+ groupChildren.push(/*#__PURE__*/React.createElement(HeaderCell, {
50
50
  key: j,
51
51
  left: left,
52
52
  align: align,
@@ -138,11 +138,11 @@ var useCellDescriptor = function useCellDescriptor(props) {
138
138
  totalFlexGrow = _getTotalByColumns.totalFlexGrow,
139
139
  totalWidth = _getTotalByColumns.totalWidth;
140
140
  React.Children.forEach(columns, function (column, index) {
141
- if ( /*#__PURE__*/React.isValidElement(column)) {
141
+ if (/*#__PURE__*/React.isValidElement(column)) {
142
142
  var _initialColumnWidths$, _columnWidths$current;
143
143
  var columnChildren = column.props.children;
144
144
  var columnProps = getColumnProps(column);
145
- var _width = columnProps.width,
145
+ var width = columnProps.width,
146
146
  resizable = columnProps.resizable,
147
147
  flexGrow = columnProps.flexGrow,
148
148
  minWidth = columnProps.minWidth,
@@ -161,23 +161,23 @@ var useCellDescriptor = function useCellDescriptor(props) {
161
161
  // get column width from cache.
162
162
  var initialColumnWidth = (_initialColumnWidths$ = initialColumnWidths.current) === null || _initialColumnWidths$ === void 0 ? void 0 : _initialColumnWidths$[cellWidthId];
163
163
  var currentWidth = (_columnWidths$current = columnWidths.current) === null || _columnWidths$current === void 0 ? void 0 : _columnWidths$current[cellWidthId];
164
- var cellWidth = currentWidth || _width || 0;
165
- var isControlled = typeof _width === 'number' && typeof onResize === 'function';
164
+ var cellWidth = currentWidth || width || 0;
165
+ var isControlled = typeof width === 'number' && typeof onResize === 'function';
166
166
 
167
167
  /**
168
168
  * in resizable mode,
169
169
  * if width !== initialColumnWidth, use current column width and update cache.
170
170
  */
171
- if (resizable && (initialColumnWidth || _width) && initialColumnWidth !== _width) {
171
+ if (resizable && (initialColumnWidth || width) && initialColumnWidth !== width) {
172
172
  // initial or update initialColumnWidth cache.
173
- initialColumnWidths.current[cellWidthId] = _width;
173
+ initialColumnWidths.current[cellWidthId] = width;
174
174
  /**
175
175
  * if currentWidth exist, update columnWidths cache.
176
176
  */
177
177
  if (currentWidth) {
178
- columnWidths.current[cellWidthId] = _width;
178
+ columnWidths.current[cellWidthId] = width;
179
179
  // update cellWidth
180
- cellWidth = _width;
180
+ cellWidth = width;
181
181
  }
182
182
  }
183
183
  if (tableWidth.current && flexGrow && totalFlexGrow) {
@@ -193,7 +193,7 @@ var useCellDescriptor = function useCellDescriptor(props) {
193
193
  left: left,
194
194
  headerHeight: headerHeight,
195
195
  key: index,
196
- width: isControlled ? _width : cellWidth,
196
+ width: isControlled ? width : cellWidth,
197
197
  height: typeof rowHeight === 'function' ? rowHeight() : rowHeight,
198
198
  firstColumn: index === 0,
199
199
  lastColumn: index === count - 1
@@ -220,9 +220,9 @@ var useCellDescriptor = function useCellDescriptor(props) {
220
220
  onColumnResizeMove: handleColumnResizeMove
221
221
  });
222
222
  }
223
- headerCells.push( /*#__PURE__*/React.cloneElement(headerCell, _extends({}, cellProps, headerCellProps)));
223
+ headerCells.push(/*#__PURE__*/React.cloneElement(headerCell, _extends({}, cellProps, headerCellProps)));
224
224
  }
225
- bodyCells.push( /*#__PURE__*/React.cloneElement(cell, cellProps));
225
+ bodyCells.push(/*#__PURE__*/React.cloneElement(cell, cellProps));
226
226
  left += cellWidth;
227
227
  }
228
228
  });
@@ -5,7 +5,9 @@ import TableContext from '../TableContext';
5
5
 
6
6
  // This is the only way I found to break circular references between ClassArray and ClassValue
7
7
  // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
8
+
8
9
  //eslint-disable-line @typescript-eslint/no-empty-interface
10
+
9
11
  /**
10
12
  * Add a prefix to all classNames.
11
13
  *
package/lib/Table.js CHANGED
@@ -36,13 +36,13 @@ var filterTreeData = function filterTreeData(data, expandedRowKeys, rowKey) {
36
36
  return (0, _utils.flattenData)(data).filter(function (rowData) {
37
37
  if (rowKey) {
38
38
  var parents = (0, _utils.findAllParents)(rowData, rowKey);
39
- var _expanded = (0, _utils.shouldShowRowByExpanded)(expandedRowKeys, parents);
39
+ var expanded = (0, _utils.shouldShowRowByExpanded)(expandedRowKeys, parents);
40
40
 
41
41
  // FIXME This function is supposed to be pure.
42
42
  // Don't mutate rowData in-place!
43
- rowData[_constants.EXPANDED_KEY] = _expanded;
43
+ rowData[_constants.EXPANDED_KEY] = expanded;
44
44
  rowData[_constants.TREE_DEPTH] = parents.length;
45
- return _expanded;
45
+ return expanded;
46
46
  }
47
47
  });
48
48
  };
@@ -593,7 +593,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
593
593
 
594
594
  // Cells marked as deleted when checking for merged cell.
595
595
  var removedCell = (_cell$props4 = cell.props) !== null && _cell$props4 !== void 0 && _cell$props4.rowSpan && !rowSpan && ((_rowSpanState$current2 = rowSpanState.current[_cellKey]) === null || _rowSpanState$current2 === void 0 ? void 0 : _rowSpanState$current2[0]) !== 0 ? true : false;
596
- cells.push( /*#__PURE__*/_react["default"].cloneElement(cell, {
596
+ cells.push(/*#__PURE__*/_react["default"].cloneElement(cell, {
597
597
  hasChildren: hasChildren,
598
598
  rowData: rowData,
599
599
  rowIndex: props.rowIndex,
@@ -617,7 +617,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
617
617
  }
618
618
  var scrollbars = [];
619
619
  if (hasHorizontalScrollbar && !(tableKey === 'parent' && isChildFocused)) {
620
- scrollbars.push( /*#__PURE__*/_react["default"].createElement(_Scrollbar["default"], {
620
+ scrollbars.push(/*#__PURE__*/_react["default"].createElement(_Scrollbar["default"], {
621
621
  key: "scrollbar",
622
622
  tableId: id,
623
623
  style: {
@@ -630,7 +630,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
630
630
  }));
631
631
  }
632
632
  if (hasVerticalScrollbar && !(tableKey === 'parent' && isChildFocused)) {
633
- scrollbars.push( /*#__PURE__*/_react["default"].createElement(_Scrollbar["default"], {
633
+ scrollbars.push(/*#__PURE__*/_react["default"].createElement(_Scrollbar["default"], {
634
634
  vertical: true,
635
635
  key: "vertical-scrollbar",
636
636
  tableId: id,
@@ -673,7 +673,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
673
673
  var bottomHideHeight = 0;
674
674
  visibleRows.current = [];
675
675
  if (data) {
676
- var _top = 0; // Row position
676
+ var top = 0; // Row position
677
677
  var minTop = Math.abs(scrollY.current);
678
678
  var maxTop = minTop + height + rowExpandedHeight;
679
679
  var isCustomRowHeight = typeof rowHeight === 'function';
@@ -690,13 +690,13 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
690
690
  maxTop = maxTop + coveredHeight;
691
691
  }
692
692
  for (var index = 0; index < data.length; index++) {
693
- var _rowData = data[index];
693
+ var rowData = data[index];
694
694
  var maxHeight = tableRowsMaxHeight[index];
695
- var expandedRow = shouldRenderExpandedRow(_rowData);
695
+ var expandedRow = shouldRenderExpandedRow(rowData);
696
696
  var nextRowHeight = 0;
697
697
  var cellHeight = 0;
698
698
  if (typeof rowHeight === 'function') {
699
- nextRowHeight = rowHeight(_rowData);
699
+ nextRowHeight = rowHeight(rowData);
700
700
  cellHeight = nextRowHeight;
701
701
  } else {
702
702
  nextRowHeight = maxHeight ? Math.max(maxHeight + _constants.CELL_PADDING_HEIGHT, rowHeight) : rowHeight;
@@ -709,10 +709,10 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
709
709
  contentHeight += nextRowHeight;
710
710
  var rowProps = {
711
711
  key: index,
712
- top: _top,
712
+ top: top,
713
713
  rowIndex: index,
714
714
  width: rowWidth,
715
- depth: _rowData[_constants.TREE_DEPTH],
715
+ depth: rowData[_constants.TREE_DEPTH],
716
716
  height: nextRowHeight,
717
717
  cellHeight: cellHeight,
718
718
  index: index,
@@ -720,17 +720,17 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
720
720
  handleParentCallBack: handleParentCallBack,
721
721
  zIndexValue: rowZIndices[index]
722
722
  };
723
- _top += nextRowHeight;
723
+ top += nextRowHeight;
724
724
  if (virtualized && !wordWrap) {
725
- if (_top + nextRowHeight < minTop) {
725
+ if (top + nextRowHeight < minTop) {
726
726
  topHideHeight += nextRowHeight;
727
727
  continue;
728
- } else if (_top > maxTop) {
728
+ } else if (top > maxTop) {
729
729
  bottomHideHeight += nextRowHeight;
730
730
  continue;
731
731
  }
732
732
  }
733
- visibleRows.current.push(renderRowData(bodyCells, _rowData, rowProps, expandedRow));
733
+ visibleRows.current.push(renderRowData(bodyCells, rowData, rowProps, expandedRow));
734
734
  }
735
735
  } else {
736
736
  /** virtualized */
@@ -752,11 +752,11 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
752
752
  topHideHeight = startIndex * _nextRowHeight;
753
753
  bottomHideHeight = (data.length - endIndex) * _nextRowHeight;
754
754
  for (var _index = startIndex; _index < endIndex; _index++) {
755
- var _rowData2 = data[_index];
755
+ var _rowData = data[_index];
756
756
  var _rowProps = {
757
757
  key: _index,
758
758
  rowIndex: _index,
759
- depth: _rowData2[_constants.TREE_DEPTH],
759
+ depth: _rowData[_constants.TREE_DEPTH],
760
760
  top: _index * _nextRowHeight,
761
761
  width: rowWidth,
762
762
  height: _nextRowHeight,
@@ -766,7 +766,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
766
766
  handleParentCallBack: handleParentCallBack,
767
767
  zIndexValue: rowZIndices[_index]
768
768
  };
769
- visibleRows.current.push(renderRowData(bodyCells, _rowData2, _rowProps, false));
769
+ visibleRows.current.push(renderRowData(bodyCells, _rowData, _rowProps, false));
770
770
  }
771
771
  }
772
772
  }
@@ -1,3 +1,6 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
1
4
  @import './themes.less';
2
5
 
3
6
  .rs {
@@ -16,9 +16,10 @@ var _Toolbar = _interopRequireDefault(require("./Toolbar"));
16
16
  var _ColumShowHide = _interopRequireDefault(require("./utilities/ColumShowHide"));
17
17
  var _debounce = _interopRequireDefault(require("./utilities/debounce"));
18
18
  var _deepEqual = require("./utilities/deepEqual");
19
+ var _empty = _interopRequireDefault(require("./utilities/empty"));
19
20
  var _icons = require("./utilities/icons");
20
21
  require("../../dist/css/qbs-react-grid.css");
21
- var _empty = _interopRequireDefault(require("./utilities/empty"));
22
+ var _CardComponent = _interopRequireDefault(require("./utilities/CardComponent"));
22
23
  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); }
23
24
  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; }
24
25
  // import 'qbs-react-table/dist/css/qbs-react-grid.css';
@@ -97,7 +98,11 @@ var QbsTable = function QbsTable(_ref) {
97
98
  _renderEmpty = _ref.renderEmpty,
98
99
  autoHeight = _ref.autoHeight,
99
100
  emptySubTitle = _ref.emptySubTitle,
100
- emptyTitle = _ref.emptyTitle;
101
+ emptyTitle = _ref.emptyTitle,
102
+ _ref$tableView = _ref.tableView,
103
+ tableView = _ref$tableView === void 0 ? true : _ref$tableView,
104
+ _ref$enableTableToggl = _ref.enableTableToggle,
105
+ enableTableToggle = _ref$enableTableToggl === void 0 ? false : _ref$enableTableToggl;
101
106
  var _useState = (0, _react.useState)(false),
102
107
  loading = _useState[0],
103
108
  setLoading = _useState[1];
@@ -115,6 +120,9 @@ var QbsTable = function QbsTable(_ref) {
115
120
  isOpen = _useState4[0],
116
121
  setIsOpen = _useState4[1];
117
122
  var prevColumns = (0, _react.useRef)();
123
+ var _useState5 = (0, _react.useState)(tableView),
124
+ tableViewToggle = _useState5[0],
125
+ setTableViewToggle = _useState5[1];
118
126
  var tableBodyRef = (0, _react.useRef)(null);
119
127
  var handleSortColumn = (0, _react.useCallback)(function (sortColumn, sortType) {
120
128
  setLoading(true);
@@ -137,6 +145,10 @@ var QbsTable = function QbsTable(_ref) {
137
145
  var keys = event.target.checked ? data.map(function (item) {
138
146
  return item.id;
139
147
  }) : [];
148
+ // let updatedKeys = [...keys];
149
+ // if (checkedKeys) {
150
+ // updatedKeys = [...checkedKeys, ...updatedKeys];
151
+ // } TODO => previous bug fix removed this section
140
152
  var updatedKeys = [].concat(keys);
141
153
  setCheckedKeys(updatedKeys);
142
154
  handleChecked(updatedKeys);
@@ -233,7 +245,10 @@ var QbsTable = function QbsTable(_ref) {
233
245
  onSelect: handleClear,
234
246
  handleColumnToggle: handleColumnToggle,
235
247
  dataLength: data === null || data === void 0 ? void 0 : data.length,
236
- searchPlaceholder: searchPlaceholder
248
+ searchPlaceholder: searchPlaceholder,
249
+ setTableViewToggle: setTableViewToggle,
250
+ tableViewToggle: tableViewToggle,
251
+ enableTableToggle: enableTableToggle
237
252
  };
238
253
  var themeToggle = (0, _react.useMemo)(function () {
239
254
  return document.getElementById('themeToggle');
@@ -410,7 +425,7 @@ var QbsTable = function QbsTable(_ref) {
410
425
  "data-theme": dataTheme
411
426
  }, toolbar && /*#__PURE__*/_react["default"].createElement(_Toolbar["default"], toolbarProps), /*#__PURE__*/_react["default"].createElement("div", {
412
427
  className: "qbs-table-border-wrap"
413
- }, /*#__PURE__*/_react["default"].createElement(_Table["default"], {
428
+ }, tableViewToggle ? /*#__PURE__*/_react["default"].createElement(_Table["default"], {
414
429
  height: autoHeight ? undefined : height,
415
430
  key: tableKey,
416
431
  tableKey: tableKey,
@@ -482,13 +497,13 @@ var QbsTable = function QbsTable(_ref) {
482
497
  }, /*#__PURE__*/_react["default"].createElement("input", {
483
498
  type: "checkbox",
484
499
  onChange: handleCheckAll,
485
- id: "checkbox-all",
500
+ id: 'checkbox-all',
486
501
  className: "qbs-table-checkbox-input " + classes.tableCheckBoxClass,
487
502
  checked: (data === null || data === void 0 ? void 0 : data.length) > 0 && data.every(function (item) {
488
503
  return checkedKeys === null || checkedKeys === void 0 ? void 0 : checkedKeys.includes(item.id);
489
504
  })
490
505
  }), /*#__PURE__*/_react["default"].createElement("label", {
491
- htmlFor: "checkbox-all"
506
+ htmlFor: 'checkbox-all'
492
507
  }, /*#__PURE__*/_react["default"].createElement("svg", {
493
508
  width: "8",
494
509
  height: "6",
@@ -559,7 +574,19 @@ var QbsTable = function QbsTable(_ref) {
559
574
  className: classes.cellClass + " " + classes.actionCellClass,
560
575
  handleMenuActions: handleMenuActions,
561
576
  dataTheme: dataTheme
562
- }))), /*#__PURE__*/_react["default"].createElement("div", null, pagination && (data === null || data === void 0 ? void 0 : data.length) > 0 && /*#__PURE__*/_react["default"].createElement(_Pagination["default"], {
577
+ }))) : /*#__PURE__*/_react["default"].createElement("div", {
578
+ className: " p-2"
579
+ }, data.map(function (items) {
580
+ return /*#__PURE__*/_react["default"].createElement("div", {
581
+ className: "flex flex-col gap-3 p-2",
582
+ key: items === null || items === void 0 ? void 0 : items.id
583
+ }, /*#__PURE__*/_react["default"].createElement(_CardComponent["default"], {
584
+ data: items,
585
+ columns: columns,
586
+ tableBodyRef: tableBodyRef,
587
+ actionProps: actionProps
588
+ }));
589
+ })), /*#__PURE__*/_react["default"].createElement("div", null, pagination && (data === null || data === void 0 ? void 0 : data.length) > 0 && /*#__PURE__*/_react["default"].createElement(_Pagination["default"], {
563
590
  paginationProps: paginationProps
564
591
  }))));
565
592
  };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { QbsTableProps } from './commontypes';
3
+ import '../../dist/css/qbs-react-grid.css';
4
+ declare const QbsTable: React.FC<QbsTableProps>;
5
+ export default QbsTable;