@codezee/sixtify-brahma 0.2.188 → 0.2.190

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 (114) hide show
  1. package/package.json +2 -1
  2. package/packages/shared-components/dist/FormFields/Autocomplete/Autocomplete.d.ts +2 -2
  3. package/packages/shared-components/dist/FormFields/Autocomplete/Autocomplete.d.ts.map +1 -1
  4. package/packages/shared-components/dist/FormFields/Autocomplete/Skeleton.d.ts +2 -1
  5. package/packages/shared-components/dist/FormFields/Autocomplete/Skeleton.d.ts.map +1 -1
  6. package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.d.ts +2 -1
  7. package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.d.ts.map +1 -1
  8. package/packages/shared-components/dist/FormFields/DatePicker/Skeleton.d.ts +2 -1
  9. package/packages/shared-components/dist/FormFields/DatePicker/Skeleton.d.ts.map +1 -1
  10. package/packages/shared-components/dist/FormFields/DateTimePicker/DateTimePicker.d.ts +2 -1
  11. package/packages/shared-components/dist/FormFields/DateTimePicker/DateTimePicker.d.ts.map +1 -1
  12. package/packages/shared-components/dist/FormFields/DateTimePicker/Skeleton.d.ts +2 -1
  13. package/packages/shared-components/dist/FormFields/DateTimePicker/Skeleton.d.ts.map +1 -1
  14. package/packages/shared-components/dist/FormFields/DecimalTextField/DecimalTextField.d.ts +2 -1
  15. package/packages/shared-components/dist/FormFields/DecimalTextField/DecimalTextField.d.ts.map +1 -1
  16. package/packages/shared-components/dist/FormFields/FileUpload/FileNames.d.ts.map +1 -1
  17. package/packages/shared-components/dist/FormFields/FileUpload/FileNames.js +2 -1
  18. package/packages/shared-components/dist/FormFields/ImageUpload/ImageUpload.d.ts.map +1 -1
  19. package/packages/shared-components/dist/FormFields/ImageUpload/ImageUpload.js +24 -6
  20. package/packages/shared-components/dist/FormFields/ImageUpload/ImageUpload.styled.d.ts.map +1 -1
  21. package/packages/shared-components/dist/FormFields/ImageUpload/ImageUpload.styled.js +3 -2
  22. package/packages/shared-components/dist/FormFields/PhoneInputField/PhoneInputField.d.ts +3 -1
  23. package/packages/shared-components/dist/FormFields/PhoneInputField/PhoneInputField.d.ts.map +1 -1
  24. package/packages/shared-components/dist/FormFields/PhoneInputField/PhoneInputField.js +5 -30
  25. package/packages/shared-components/dist/FormFields/PhoneInputField/PhoneInputField.styled.d.ts +10 -0
  26. package/packages/shared-components/dist/FormFields/PhoneInputField/PhoneInputField.styled.d.ts.map +1 -0
  27. package/packages/shared-components/dist/FormFields/PhoneInputField/PhoneInputField.styled.js +214 -0
  28. package/packages/shared-components/dist/FormFields/PhoneInputField/Skeleton.d.ts +3 -1
  29. package/packages/shared-components/dist/FormFields/PhoneInputField/Skeleton.d.ts.map +1 -1
  30. package/packages/shared-components/dist/FormFields/PhoneInputField/Skeleton.js +2 -2
  31. package/packages/shared-components/dist/FormFields/RadioGroupField/RadioGroupField.d.ts +2 -1
  32. package/packages/shared-components/dist/FormFields/RadioGroupField/RadioGroupField.d.ts.map +1 -1
  33. package/packages/shared-components/dist/FormFields/RadioGroupField/RadioGroupField.js +24 -16
  34. package/packages/shared-components/dist/FormFields/Select/Select.d.ts +2 -2
  35. package/packages/shared-components/dist/FormFields/Select/Select.d.ts.map +1 -1
  36. package/packages/shared-components/dist/FormFields/Select/Select.styled.js +1 -1
  37. package/packages/shared-components/dist/FormFields/TextField/Skeleton.d.ts +2 -1
  38. package/packages/shared-components/dist/FormFields/TextField/Skeleton.d.ts.map +1 -1
  39. package/packages/shared-components/dist/FormFields/TextField/TextField.d.ts +2 -1
  40. package/packages/shared-components/dist/FormFields/TextField/TextField.d.ts.map +1 -1
  41. package/packages/shared-components/dist/FormFields/TimeField/Skeleton.d.ts +2 -1
  42. package/packages/shared-components/dist/FormFields/TimeField/Skeleton.d.ts.map +1 -1
  43. package/packages/shared-components/dist/FormFields/TimeField/TimeField.d.ts +2 -1
  44. package/packages/shared-components/dist/FormFields/TimeField/TimeField.d.ts.map +1 -1
  45. package/packages/shared-components/dist/FormFields/TimePicker/Skeleton.d.ts +2 -1
  46. package/packages/shared-components/dist/FormFields/TimePicker/Skeleton.d.ts.map +1 -1
  47. package/packages/shared-components/dist/FormFields/TimePicker/TimePicker.d.ts +2 -1
  48. package/packages/shared-components/dist/FormFields/TimePicker/TimePicker.d.ts.map +1 -1
  49. package/packages/shared-components/dist/SmartGrid/Components/CellRenderer.d.ts +2 -1
  50. package/packages/shared-components/dist/SmartGrid/Components/CellRenderer.d.ts.map +1 -1
  51. package/packages/shared-components/dist/SmartGrid/Components/CellRenderer.js +12 -11
  52. package/packages/shared-components/dist/SmartGrid/Components/FacetedFilter/FacetedFilter.d.ts.map +1 -1
  53. package/packages/shared-components/dist/SmartGrid/Components/FacetedFilter/FacetedFilter.js +17 -34
  54. package/packages/shared-components/dist/SmartGrid/Components/FacetedFilter/VirtualCheckboxList.d.ts +2 -2
  55. package/packages/shared-components/dist/SmartGrid/Components/FacetedFilter/VirtualCheckboxList.d.ts.map +1 -1
  56. package/packages/shared-components/dist/SmartGrid/Components/FacetedFilter/VirtualCheckboxList.js +21 -5
  57. package/packages/shared-components/dist/SmartGrid/Components/FilterStatusPanel.d.ts.map +1 -1
  58. package/packages/shared-components/dist/SmartGrid/Components/FilterStatusPanel.js +13 -6
  59. package/packages/shared-components/dist/SmartGrid/Components/Grouped/GroupAreaOverlay.d.ts +10 -0
  60. package/packages/shared-components/dist/SmartGrid/Components/Grouped/GroupAreaOverlay.d.ts.map +1 -0
  61. package/packages/shared-components/dist/SmartGrid/Components/Grouped/GroupAreaOverlay.js +82 -0
  62. package/packages/shared-components/dist/SmartGrid/Components/Grouped/GroupChip.d.ts +10 -0
  63. package/packages/shared-components/dist/SmartGrid/Components/Grouped/GroupChip.d.ts.map +1 -0
  64. package/packages/shared-components/dist/SmartGrid/Components/Grouped/GroupChip.js +73 -0
  65. package/packages/shared-components/dist/SmartGrid/Components/Grouped/GroupedColumn.d.ts +8 -0
  66. package/packages/shared-components/dist/SmartGrid/Components/Grouped/GroupedColumn.d.ts.map +1 -0
  67. package/packages/shared-components/dist/SmartGrid/Components/Grouped/GroupedColumn.js +64 -0
  68. package/packages/shared-components/dist/SmartGrid/Components/Grouped/GroupedPanel.d.ts +10 -0
  69. package/packages/shared-components/dist/SmartGrid/Components/Grouped/GroupedPanel.d.ts.map +1 -0
  70. package/packages/shared-components/dist/SmartGrid/Components/Grouped/GroupedPanel.js +53 -0
  71. package/packages/shared-components/dist/SmartGrid/Components/HeaderCells/DraggableHeaderCell.d.ts +2 -1
  72. package/packages/shared-components/dist/SmartGrid/Components/HeaderCells/DraggableHeaderCell.d.ts.map +1 -1
  73. package/packages/shared-components/dist/SmartGrid/Components/HeaderCells/DraggableHeaderCell.js +2 -2
  74. package/packages/shared-components/dist/SmartGrid/Components/HeaderCells/DraggableHeaderGroupRows.d.ts.map +1 -1
  75. package/packages/shared-components/dist/SmartGrid/Components/HeaderCells/DraggableHeaderGroupRows.js +12 -8
  76. package/packages/shared-components/dist/SmartGrid/Components/HeaderCells/HeaderCell.d.ts +1 -1
  77. package/packages/shared-components/dist/SmartGrid/Components/HeaderCells/HeaderCell.d.ts.map +1 -1
  78. package/packages/shared-components/dist/SmartGrid/Components/HeaderCells/HeaderCell.js +47 -27
  79. package/packages/shared-components/dist/SmartGrid/Components/SearchFilterRow/DateRangeInput/DateRangeInput.d.ts.map +1 -1
  80. package/packages/shared-components/dist/SmartGrid/Components/SearchFilterRow/DateRangeInput/DateRangeInput.js +1 -1
  81. package/packages/shared-components/dist/SmartGrid/Components/SearchFilterRow/DateRangeInput/StyleDateRangeWrapper.js +1 -1
  82. package/packages/shared-components/dist/SmartGrid/Components/SearchFilterRow/GetRenderInputs.d.ts.map +1 -1
  83. package/packages/shared-components/dist/SmartGrid/Components/SearchFilterRow/SearchFilterRow.d.ts.map +1 -1
  84. package/packages/shared-components/dist/SmartGrid/Components/TableFooterComponent/TableFooterComponent.d.ts.map +1 -1
  85. package/packages/shared-components/dist/SmartGrid/Components/TableRowComponent.d.ts +3 -2
  86. package/packages/shared-components/dist/SmartGrid/Components/TableRowComponent.d.ts.map +1 -1
  87. package/packages/shared-components/dist/SmartGrid/Components/TableRowComponent.js +75 -57
  88. package/packages/shared-components/dist/SmartGrid/SmartGrid.d.ts.map +1 -1
  89. package/packages/shared-components/dist/SmartGrid/SmartGrid.js +103 -47
  90. package/packages/shared-components/dist/SmartGrid/hooks/useGetColumnWidth.d.ts.map +1 -1
  91. package/packages/shared-components/dist/SmartGrid/hooks/useGetFacetedFilter.d.ts.map +1 -1
  92. package/packages/shared-components/dist/SmartGrid/hooks/useGetGroupedColumn.d.ts +18 -6
  93. package/packages/shared-components/dist/SmartGrid/hooks/useGetGroupedColumn.d.ts.map +1 -1
  94. package/packages/shared-components/dist/SmartGrid/hooks/useGetGroupedColumn.js +160 -6
  95. package/packages/shared-components/dist/SmartGrid/hooks/useGetPinningColumns.d.ts.map +1 -1
  96. package/packages/shared-components/dist/SmartGrid/hooks/useGetRowSelection.d.ts.map +1 -1
  97. package/packages/shared-components/dist/SmartGrid/hooks/useGetSortedColumn.d.ts +1 -1
  98. package/packages/shared-components/dist/SmartGrid/hooks/useGetSortedColumn.d.ts.map +1 -1
  99. package/packages/shared-components/dist/SmartGrid/hooks/useGetSortedColumn.js +1 -2
  100. package/packages/shared-components/dist/SmartGrid/hooks/useProcessColumnsForGroupDisplay.d.ts +11 -0
  101. package/packages/shared-components/dist/SmartGrid/hooks/useProcessColumnsForGroupDisplay.d.ts.map +1 -0
  102. package/packages/shared-components/dist/SmartGrid/hooks/useProcessColumnsForGroupDisplay.js +30 -0
  103. package/packages/shared-components/dist/SmartGrid/hooks/useTableState.d.ts.map +1 -1
  104. package/packages/shared-components/dist/SmartGrid/hooks/useTableState.js +51 -4
  105. package/packages/shared-components/dist/SmartGrid/utils/helper.d.ts +1 -0
  106. package/packages/shared-components/dist/SmartGrid/utils/helper.d.ts.map +1 -1
  107. package/packages/shared-components/dist/SmartGrid/utils/helper.js +7 -5
  108. package/packages/shared-components/dist/TabBar/Tab.d.ts.map +1 -1
  109. package/packages/shared-components/dist/TabBar/Tab.js +1 -1
  110. package/packages/shared-components/dist/UserProfileMenu/UserProfileMenu.styled.d.ts.map +1 -1
  111. package/packages/shared-components/dist/UserProfileMenu/UserProfileMenu.styled.js +2 -1
  112. package/packages/shared-components/dist/utils/theme/colorPalette.js +3 -3
  113. package/packages/shared-components/dist/utils/types.d.ts +1 -0
  114. package/packages/shared-components/dist/utils/types.d.ts.map +1 -1
@@ -8,7 +8,7 @@ const Button_1 = require("../../Button");
8
8
  const CellSelectionContext_1 = require("../context/CellSelectionContext");
9
9
  const useGetPinStyle_1 = require("../hooks/useGetPinStyle");
10
10
  const CellRenderer_1 = require("./CellRenderer");
11
- const TableRowComponent = ({ columnWidths, exportActions, exportData, index, isSummaryRow = false, row, rowHeight, summaryData, virtualRow, }) => {
11
+ const TableRowComponent = ({ columnWidths, exportActions, exportData, grouping = [], index, isSummaryRow = false, row, rowHeight, summaryData, virtualRow, }) => {
12
12
  const theme = (0, material_1.useTheme)();
13
13
  const { butterflyBlue, iron, mirage, slate } = theme.palette.app.color;
14
14
  const cellSelectionContext = (0, CellSelectionContext_1.useCellSelectionContext)();
@@ -65,7 +65,7 @@ const TableRowComponent = ({ columnWidths, exportActions, exportData, index, isS
65
65
  }
66
66
  }, [activePopupRowId]);
67
67
  const isPopupOpen = activePopupRowId === row.id;
68
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("tr", { className: "sg-tbody-tr-row", ref: trRef, style: {
68
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("tr", { ref: trRef, style: {
69
69
  backgroundColor: getRowBackgroundColor(),
70
70
  borderTop: `1px solid ${iron[700]}`,
71
71
  display: "flex",
@@ -82,62 +82,80 @@ const TableRowComponent = ({ columnWidths, exportActions, exportData, index, isS
82
82
  if (!isSummaryRow) {
83
83
  setIsRowHovered(false);
84
84
  }
85
- }, onContextMenu: handleContextMenu, children: row.getVisibleCells().map((cell, cellIndex, allCells) => {
86
- const width = columnWidths[cellIndex] ?? cell.column.getSize();
87
- const pinStyle = getPinStyle(cell, cellIndex, allCells);
88
- const isSelected = isCellSelected(row.id, cell.column.id);
89
- const handleMouseDown = (event) => {
90
- if (cellSelectionEnabled && !isSummaryRow) {
91
- const isShiftClick = event.shiftKey;
92
- startCellSelection(row.id, cell.column.id, isShiftClick);
93
- }
94
- };
95
- const handleMouseEnter = () => {
96
- if (cellSelectionEnabled && !isSummaryRow) {
97
- updateCellSelection(row.id, cell.column.id);
98
- }
99
- };
100
- // Apply copy flash animation when cell is selected and flash is active
101
- const cellBackgroundColor = isSelected && !isCopyFlashing ? butterflyBlue[600] : undefined;
102
- const cellAnimation = isSelected && isCopyFlashing
103
- ? "copyFlash 0.5s ease-in-out"
104
- : undefined;
105
- // Check if this cell is pinned
106
- const isPinned = cell.column.getIsPinned();
107
- const finalBackgroundColor = isPinned
108
- ? // eslint-disable-next-line sonarjs/no-nested-conditional
109
- isSelected && !isCopyFlashing
110
- ? butterflyBlue[600]
111
- : getRowBackgroundColor()
112
- : cellBackgroundColor;
113
- return ((0, jsx_runtime_1.jsx)("td", { onMouseDown: handleMouseDown, onMouseEnter: handleMouseEnter, style: {
114
- animation: cellAnimation,
115
- backgroundColor: finalBackgroundColor,
116
- boxSizing: "border-box",
117
- cursor: cellSelectionEnabled ? "cell" : "default",
118
- lineHeight: "21px",
119
- maxWidth: width,
120
- minWidth: width,
121
- overflow: "hidden",
122
- padding: "0px 8px",
123
- position: "relative",
124
- textOverflow: "ellipsis",
125
- textWrap: "nowrap",
126
- userSelect: cellSelectionEnabled ? "none" : "auto",
127
- width,
128
- ...pinStyle,
129
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
130
- alignItems: "center",
131
- color: iron[400],
132
- display: "flex",
133
- fontFamily: "Poppins",
134
- fontSize: "13px",
135
- fontWeight: isSummaryRow ? "500" : 400,
136
- height: rowHeight,
85
+ }, onContextMenu: handleContextMenu, children: (() => {
86
+ const visibleCells = row.getVisibleCells();
87
+ // Filter out grouping columns (except the group column) when grouping is enabled
88
+ const cellsToRender = grouping.length > 0
89
+ ? visibleCells.filter((cell) => {
90
+ // Keep the group column
91
+ if (cell.column.id === "grouped_by") {
92
+ return true;
93
+ }
94
+ // Filter out grouping columns - check both if cell is grouped AND if column ID is in grouping array
95
+ const columnId = cell.column.id;
96
+ const accessorKey = cell.column.columnDef?.accessorKey;
97
+ const isGroupingColumn = grouping.includes(columnId) ||
98
+ (accessorKey && grouping.includes(accessorKey));
99
+ return !isGroupingColumn && !cell.getIsGrouped();
100
+ })
101
+ : visibleCells;
102
+ return cellsToRender.map((cell, cellIndex, allCells) => {
103
+ const width = columnWidths[cellIndex] ?? cell.column.getSize();
104
+ const pinStyle = getPinStyle(cell, cellIndex, allCells);
105
+ const isSelected = isCellSelected(row.id, cell.column.id);
106
+ const handleMouseDown = (event) => {
107
+ if (cellSelectionEnabled && !isSummaryRow) {
108
+ const isShiftClick = event.shiftKey;
109
+ startCellSelection(row.id, cell.column.id, isShiftClick);
110
+ }
111
+ };
112
+ const handleMouseEnter = () => {
113
+ if (cellSelectionEnabled && !isSummaryRow) {
114
+ updateCellSelection(row.id, cell.column.id);
115
+ }
116
+ };
117
+ // Apply copy flash animation when cell is selected and flash is active
118
+ const cellBackgroundColor = isSelected && !isCopyFlashing ? butterflyBlue[600] : undefined;
119
+ const cellAnimation = isSelected && isCopyFlashing
120
+ ? "copyFlash 0.5s ease-in-out"
121
+ : undefined;
122
+ // Check if this cell is pinned
123
+ const isPinned = cell.column.getIsPinned();
124
+ const finalBackgroundColor = isPinned
125
+ ? // eslint-disable-next-line sonarjs/no-nested-conditional
126
+ isSelected && !isCopyFlashing
127
+ ? butterflyBlue[600]
128
+ : getRowBackgroundColor()
129
+ : cellBackgroundColor;
130
+ return ((0, jsx_runtime_1.jsx)("td", { onMouseDown: handleMouseDown, onMouseEnter: handleMouseEnter, style: {
131
+ animation: cellAnimation,
132
+ backgroundColor: finalBackgroundColor,
133
+ boxSizing: "border-box",
134
+ cursor: cellSelectionEnabled ? "cell" : "default",
135
+ lineHeight: "21px",
136
+ maxWidth: width,
137
+ minWidth: width,
137
138
  overflow: "hidden",
139
+ padding: "0px 8px",
140
+ position: "relative",
138
141
  textOverflow: "ellipsis",
139
- }, children: (0, jsx_runtime_1.jsx)(CellRenderer_1.CellRenderer, { cell: cell, row: row, isSummaryRow: isSummaryRow, summaryData: summaryData }) }) }, cell.id));
140
- }) }, `table-row-${index}${isSummaryRow ? "-summary" : ""}`), isPopupOpen && exportData && ((0, jsx_runtime_1.jsx)("div", { ref: popupRef, style: {
142
+ textWrap: "nowrap",
143
+ userSelect: cellSelectionEnabled ? "none" : "auto",
144
+ width,
145
+ ...pinStyle,
146
+ }, children: (0, jsx_runtime_1.jsx)("div", { style: {
147
+ alignItems: "center",
148
+ color: iron[400],
149
+ display: "flex",
150
+ fontFamily: "Poppins",
151
+ fontSize: "14px",
152
+ fontWeight: isSummaryRow ? "500" : 400,
153
+ height: rowHeight,
154
+ overflow: "hidden",
155
+ textOverflow: "ellipsis",
156
+ }, children: (0, jsx_runtime_1.jsx)(CellRenderer_1.CellRenderer, { cell: cell, row: row, isSummaryRow: isSummaryRow, summaryData: summaryData, isGroupColumn: cell.column.id === "grouped_by" }) }) }, cell.id));
157
+ });
158
+ })() }, `table-row-${index}${isSummaryRow ? "-summary" : ""}`), isPopupOpen && exportData && ((0, jsx_runtime_1.jsx)("div", { ref: popupRef, style: {
141
159
  backgroundColor: iron[600],
142
160
  borderRadius: "6px",
143
161
  boxShadow: `0 0 20px ${mirage[50]}`,
@@ -153,7 +171,7 @@ const TableRowComponent = ({ columnWidths, exportActions, exportData, index, isS
153
171
  }, children: exportActions?.map((item) => {
154
172
  return ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: item.onClick, variant: "text", style: {
155
173
  borderBottom: `1px solid ${iron[700]}`,
156
- fontSize: "13px",
174
+ fontSize: "14px",
157
175
  padding: 0,
158
176
  }, disableRipple: true, children: item.label }, item.label));
159
177
  }) }))] }));
@@ -1 +1 @@
1
- {"version":3,"file":"SmartGrid.d.ts","sourceRoot":"","sources":["../../src/SmartGrid/SmartGrid.tsx"],"names":[],"mappings":"AAKA,OAAO,KAQN,MAAM,OAAO,CAAC;AAiBf,OAAO,KAAK,EAEV,cAAc,EAGf,MAAM,SAAS,CAAC;AA6BjB,KAAK,aAAa,GAAG,KAAK,CAAC,yBAAyB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,GAC3E,CAAC,CAAC,WAAW,EAAE,KAAK,EAAE,cAAc,CAAC,WAAW,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,CAAC;AAErE,eAAO,MAAM,SAAS,EA4YjB,aAAa,CAAC"}
1
+ {"version":3,"file":"SmartGrid.d.ts","sourceRoot":"","sources":["../../src/SmartGrid/SmartGrid.tsx"],"names":[],"mappings":"AAKA,OAAO,KAQN,MAAM,OAAO,CAAC;AAiBf,OAAO,KAAK,EAEV,cAAc,EAGf,MAAM,SAAS,CAAC;AAkCjB,KAAK,aAAa,GAAG,KAAK,CAAC,yBAAyB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,GAC3E,CAAC,CAAC,WAAW,EAAE,KAAK,EAAE,cAAc,CAAC,WAAW,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,CAAC;AAErE,eAAO,MAAM,SAAS,EA8gBjB,aAAa,CAAC"}
@@ -22,6 +22,11 @@ const useGetDragMethods_1 = require("./hooks/useGetDragMethods");
22
22
  const useGetRowSelection_1 = require("./hooks/useGetRowSelection");
23
23
  const useTableState_1 = require("./hooks/useTableState");
24
24
  const summaryCalculations_1 = require("./utils/summaryCalculations");
25
+ const useGetGroupedColumn_1 = require("./hooks/useGetGroupedColumn");
26
+ const GroupedPanel_1 = require("./Components/Grouped/GroupedPanel");
27
+ const DraggableHeaderCell_1 = require("./Components/HeaderCells/DraggableHeaderCell");
28
+ const GroupAreaOverlay_1 = require("./Components/Grouped/GroupAreaOverlay");
29
+ const sortable_1 = require("@dnd-kit/sortable");
25
30
  const calculateGroupSummary = (groupRow, globalSummary, dynamicSummaryConfig) => {
26
31
  const { subRows } = groupRow;
27
32
  if (dynamicSummaryConfig && subRows) {
@@ -34,6 +39,8 @@ exports.SmartGrid = (0, react_1.forwardRef)(({ defaultGrouping = [], dynamicRowS
34
39
  const theme = (0, material_1.useTheme)();
35
40
  const { butterflyBlue } = theme.palette.app.color;
36
41
  const [resetAllFilters, setResetAllFilters] = (0, react_1.useState)(false);
42
+ const [activeDragId, setActiveDragId] = (0, react_1.useState)(null);
43
+ const [activeDragOver, setActiveDragOver] = (0, react_1.useState)(null);
37
44
  const containerRef = (0, react_1.useRef)(null);
38
45
  const headerRef = (0, react_1.useRef)(null);
39
46
  const { columns: propsColumns, data, dynamicSummaryConfig, summary, } = props;
@@ -50,11 +57,12 @@ exports.SmartGrid = (0, react_1.forwardRef)(({ defaultGrouping = [], dynamicRowS
50
57
  loading,
51
58
  totalCount,
52
59
  });
53
- const { getHeaderGroups, getRowModel, getSelectedRowModel } = table;
60
+ const { getHeaderGroups, getRowModel, getSelectedRowModel, getState } = table;
54
61
  const rows = getRowModel().rows;
62
+ const currentGrouping = getState().grouping;
55
63
  const notifyParentRef = (0, react_1.useRef)(null);
56
- // Drag and drop Methoda
57
- const { handleDragEnd, isHeaderReorderable, sensors } = (0, useGetDragMethods_1.useGetDragMethods)({
64
+ // Drag and drop Methods
65
+ const { handleDragEnd: handleColumnReorder, isHeaderReorderable, sensors, } = (0, useGetDragMethods_1.useGetDragMethods)({
58
66
  swipeableColumns,
59
67
  table,
60
68
  });
@@ -144,6 +152,35 @@ exports.SmartGrid = (0, react_1.forwardRef)(({ defaultGrouping = [], dynamicRowS
144
152
  }, 100);
145
153
  };
146
154
  const headerGroups = getHeaderGroups();
155
+ // Helper function to filter headers - hide grouping columns when grouping is enabled
156
+ const filterHeaders = (headers, grouping) => {
157
+ if (grouping.length === 0) {
158
+ return headers;
159
+ }
160
+ return headers.filter((header) => {
161
+ // Keep the group column
162
+ if (header.column.id === "grouped_by") {
163
+ return true;
164
+ }
165
+ // Filter out grouping columns
166
+ const columnId = header.column.id;
167
+ const accessorKey = header.column.columnDef?.accessorKey;
168
+ const isGroupingColumn = grouping.includes(columnId) ||
169
+ (accessorKey && grouping.includes(accessorKey));
170
+ return !isGroupingColumn;
171
+ });
172
+ };
173
+ const { handleDragEnd, handleDragStart, handleRemoveGroup, allDraggableIds, customCollisionDetection, hasGroupableColumns, } = (0, useGetGroupedColumn_1.useGetGroupedColumn)({
174
+ table,
175
+ swipeableColumns,
176
+ setActiveDragId,
177
+ currentGrouping,
178
+ handleColumnReorder,
179
+ filterHeaders,
180
+ isHeaderReorderable,
181
+ propsColumns,
182
+ defaultGrouping,
183
+ });
147
184
  return ((0, jsx_runtime_1.jsxs)(CellSelectionContext_1.CellSelectionProvider, { value: {
148
185
  ...cellSelection,
149
186
  enabled: enableCellSelection,
@@ -159,50 +196,69 @@ exports.SmartGrid = (0, react_1.forwardRef)(({ defaultGrouping = [], dynamicRowS
159
196
  background-color: ${butterflyBlue[700]};
160
197
  }
161
198
  }
162
- ` }), (0, jsx_runtime_1.jsxs)("div", { style: {
163
- display: "flex",
164
- flexDirection: "column",
165
- height: height || "calc(100vh - 100px)",
166
- position: "relative",
167
- }, onMouseUp: endCellSelection, children: [(0, jsx_runtime_1.jsx)("div", { ref: containerRef, style: {
168
- border: `1px solid ${theme.palette.divider}`,
169
- flexGrow: 1,
170
- height: "100%",
171
- overflow: "auto",
172
- position: "relative",
173
- }, children: (0, jsx_runtime_1.jsxs)("table", { style: {
174
- borderCollapse: "separate",
175
- borderSpacing: 0,
176
- fontFamily: "arial, sans-serif",
177
- minHeight: "100%",
178
- tableLayout: "fixed",
179
- width: "100%",
180
- }, children: [(0, jsx_runtime_1.jsx)("thead", { ref: headerRef, style: {
181
- position: "sticky",
182
- top: 0,
183
- zIndex: 10,
184
- }, children: swipeableColumns ? ((0, jsx_runtime_1.jsx)(core_1.DndContext, { sensors: sensors, collisionDetection: core_1.closestCenter, onDragEnd: handleDragEnd, children: headerGroups.map((headerGroup) => {
185
- return ((0, jsx_runtime_1.jsx)(DraggableHeaderGroupRows_1.DraggableHeaderGroupRows, { defaultGrouping: defaultGrouping, enableSecondRowFilter: enableSecondRowFilter, headerGroup: headerGroup, isHeaderReorderable: isHeaderReorderable, loading: loading, resetAllFilters: resetAllFilters, swipeableColumns: swipeableColumns }, headerGroup.id));
186
- }) })) : (headerGroups.map((headerGroup) => {
187
- const leftPinnedHeaders = headerGroup.headers.filter((h) => h.column.getIsPinned() === "left");
188
- const centerHeaders = headerGroup.headers.filter((h) => !h.column.getIsPinned());
189
- const rightPinnedHeaders = headerGroup.headers.filter((h) => h.column.getIsPinned() === "right");
190
- const headerRow = ((0, jsx_runtime_1.jsxs)("tr", { children: [leftPinnedHeaders.map((header) => ((0, jsx_runtime_1.jsx)(HeaderCell_1.HeaderCell, { defaultGrouping: defaultGrouping, header: header, loading: loading, resetAllFilters: resetAllFilters }, header.id))), centerHeaders.map((header) => {
191
- return ((0, jsx_runtime_1.jsx)(HeaderCell_1.HeaderCell, { defaultGrouping: defaultGrouping, header: header, loading: loading, resetAllFilters: resetAllFilters }, header.id));
192
- }), rightPinnedHeaders.map((header) => ((0, jsx_runtime_1.jsx)(HeaderCell_1.HeaderCell, { defaultGrouping: defaultGrouping, header: header, loading: loading, resetAllFilters: resetAllFilters }, header.id)))] }, `${headerGroup.id}-row`));
193
- return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [headerRow, enableSecondRowFilter && !loading && ((0, jsx_runtime_1.jsx)("tr", { children: headerGroup.headers.map((header) => ((0, jsx_runtime_1.jsx)(SearchFilterRow_1.SearchFilterRow, { header: header, resetAllFilters: resetAllFilters }, header.id))) }))] }, headerGroup.id));
194
- })) }), (0, jsx_runtime_1.jsx)("tbody", { style: {
195
- filter: loading ? "blur(2px)" : "none",
196
- height: `${rowVirtualizer.getTotalSize()}px`,
199
+ ` }), (0, jsx_runtime_1.jsxs)(core_1.DndContext, { sensors: sensors, collisionDetection: customCollisionDetection, onDragStart: handleDragStart, onDragEnd: handleDragEnd, onDragOver: (event) => {
200
+ setActiveDragOver(event.over ? String(event.over.id) : null);
201
+ }, onDragCancel: () => {
202
+ setActiveDragOver(null);
203
+ setActiveDragId(null);
204
+ }, children: [(0, jsx_runtime_1.jsx)(sortable_1.SortableContext, { items: allDraggableIds, children: (0, jsx_runtime_1.jsxs)("div", { style: {
205
+ display: "flex",
206
+ flexDirection: "column",
207
+ height: height || "calc(100vh - 100px)",
208
+ position: "relative",
209
+ }, onMouseUp: endCellSelection, children: [hasGroupableColumns && ((0, jsx_runtime_1.jsx)(GroupedPanel_1.GroupedPanel, { groupedColumns: currentGrouping, onRemoveGroup: handleRemoveGroup, table: table, defaultGrouping: defaultGrouping })), (0, jsx_runtime_1.jsx)("div", { ref: containerRef, style: {
210
+ border: `1px solid ${theme.palette.divider}`,
211
+ flexGrow: 1,
212
+ height: "100%",
213
+ overflow: "auto",
197
214
  position: "relative",
198
- transition: "filter 0.2s ease-in-out",
199
- }, children: rowVirtualizer.getVirtualItems().map((virtualRow) => {
200
- const enhancedRow = enhancedRows[virtualRow.index];
201
- if (!enhancedRow) {
202
- return null;
203
- }
204
- const { groupId, isSummary, row, summaryData } = enhancedRow;
205
- return ((0, jsx_runtime_1.jsx)(TableRowComponent_1.TableRowComponent, { columnWidths: columnWidths, row: row, index: virtualRow.index, virtualRow: virtualRow, rowHeight: rowHeight, isSummaryRow: isSummary, summaryData: summaryData, exportData: exportData, exportActions: exportActions }, `table-row-${virtualRow.index}-${isSummary ? "summary" : "normal"}-${groupId}`));
206
- }) }), !loading && summary && ((0, jsx_runtime_1.jsx)(TableFooterComponent_1.TableFooterComponent, { table: table, summary: summary }))] }) }), rowSelection && getSelectedRowModel().rows.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { style: { fontSize: "13px" }, children: ["Selected Rows: ", getSelectedRowModel().rows.length] })), (0, jsx_runtime_1.jsx)(FilterStatusPanel_1.FilterStatusPanel, { table: table, clearAllFilters: clearAllFilters }), loading && (0, jsx_runtime_1.jsx)(CircularLoader_1.CircularLoader, {}), !rows.length && !loading && (0, jsx_runtime_1.jsx)(DataNotFound_1.DataNotFound, { message: emptyMessage })] })] }));
215
+ }, children: (0, jsx_runtime_1.jsxs)("table", { style: {
216
+ borderCollapse: "separate",
217
+ borderSpacing: 0,
218
+ fontFamily: "arial, sans-serif",
219
+ minHeight: "100%",
220
+ tableLayout: "fixed",
221
+ width: "100%",
222
+ }, children: [(0, jsx_runtime_1.jsx)("thead", { ref: headerRef, style: {
223
+ position: "sticky",
224
+ top: 0,
225
+ zIndex: 10,
226
+ }, children: swipeableColumns ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: headerGroups.map((headerGroup) => {
227
+ const filteredHeaderGroup = {
228
+ ...headerGroup,
229
+ headers: filterHeaders(headerGroup.headers, currentGrouping),
230
+ };
231
+ return ((0, jsx_runtime_1.jsx)(DraggableHeaderGroupRows_1.DraggableHeaderGroupRows, { defaultGrouping: defaultGrouping, enableSecondRowFilter: enableSecondRowFilter, headerGroup: filteredHeaderGroup, isHeaderReorderable: isHeaderReorderable, loading: loading, resetAllFilters: resetAllFilters, swipeableColumns: swipeableColumns }, headerGroup.id));
232
+ }) })) : (headerGroups.map((headerGroup) => {
233
+ const allHeaders = filterHeaders(headerGroup.headers, currentGrouping);
234
+ const leftPinnedHeaders = allHeaders.filter((h) => h.column.getIsPinned() === "left");
235
+ const centerHeaders = allHeaders.filter((h) => !h.column.getIsPinned());
236
+ const rightPinnedHeaders = allHeaders.filter((h) => h.column.getIsPinned() === "right");
237
+ // Helper to check if header can be grouped and should be draggable
238
+ // Only columns with enableGrouping: true should be draggable to group area
239
+ const isGroupable = (header) => {
240
+ const columnDef = header.column
241
+ .columnDef;
242
+ return columnDef.enableGrouping === true;
243
+ };
244
+ const headerRow = ((0, jsx_runtime_1.jsxs)("tr", { children: [leftPinnedHeaders.map((header) => ((0, jsx_runtime_1.jsx)(HeaderCell_1.HeaderCell, { defaultGrouping: defaultGrouping, header: header, loading: loading, resetAllFilters: resetAllFilters }, header.id))), centerHeaders.map((header) => {
245
+ // Make groupable headers draggable so they can be dragged to grouping panel
246
+ const canGroup = isGroupable(header);
247
+ return canGroup ? ((0, jsx_runtime_1.jsx)(DraggableHeaderCell_1.DraggableHeaderCell, { defaultGrouping: defaultGrouping, header: header, loading: loading, resetAllFilters: resetAllFilters }, header.id)) : ((0, jsx_runtime_1.jsx)(HeaderCell_1.HeaderCell, { defaultGrouping: defaultGrouping, header: header, loading: loading, resetAllFilters: resetAllFilters }, header.id));
248
+ }), rightPinnedHeaders.map((header) => ((0, jsx_runtime_1.jsx)(HeaderCell_1.HeaderCell, { defaultGrouping: defaultGrouping, header: header, loading: loading, resetAllFilters: resetAllFilters }, header.id)))] }, `${headerGroup.id}-row`));
249
+ return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [headerRow, enableSecondRowFilter && !loading && ((0, jsx_runtime_1.jsx)("tr", { children: allHeaders.map((header) => ((0, jsx_runtime_1.jsx)(SearchFilterRow_1.SearchFilterRow, { header: header, resetAllFilters: resetAllFilters }, header.id))) }))] }, headerGroup.id));
250
+ })) }), (0, jsx_runtime_1.jsx)("tbody", { style: {
251
+ filter: loading ? "blur(2px)" : "none",
252
+ height: `${rowVirtualizer.getTotalSize()}px`,
253
+ position: "relative",
254
+ transition: "filter 0.2s ease-in-out",
255
+ }, children: rowVirtualizer.getVirtualItems().map((virtualRow) => {
256
+ const enhancedRow = enhancedRows[virtualRow.index];
257
+ if (!enhancedRow) {
258
+ return null;
259
+ }
260
+ const { groupId, isSummary, row, summaryData } = enhancedRow;
261
+ return ((0, jsx_runtime_1.jsx)(TableRowComponent_1.TableRowComponent, { columnWidths: columnWidths, row: row, index: virtualRow.index, virtualRow: virtualRow, rowHeight: rowHeight, isSummaryRow: isSummary, summaryData: summaryData, exportData: exportData, exportActions: exportActions, grouping: currentGrouping }, `table-row-${virtualRow.index}-${isSummary ? "summary" : "normal"}-${groupId}`));
262
+ }) }), !loading && summary && ((0, jsx_runtime_1.jsx)(TableFooterComponent_1.TableFooterComponent, { table: table, summary: summary }))] }) }), rowSelection && getSelectedRowModel().rows.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { style: { fontSize: "14px" }, children: ["Selected Rows: ", getSelectedRowModel().rows.length] })), (0, jsx_runtime_1.jsx)(FilterStatusPanel_1.FilterStatusPanel, { table: table, clearAllFilters: clearAllFilters }), loading && (0, jsx_runtime_1.jsx)(CircularLoader_1.CircularLoader, {}), !rows.length && !loading && ((0, jsx_runtime_1.jsx)(DataNotFound_1.DataNotFound, { message: emptyMessage }))] }) }), (0, jsx_runtime_1.jsx)(GroupAreaOverlay_1.GroupAreaOverlay, { activeDragId: activeDragId, activeDragOver: activeDragOver, table: table, defaultGrouping: defaultGrouping })] })] }));
207
263
  });
208
264
  exports.SmartGrid.displayName = "SmartGrid";
@@ -1 +1 @@
1
- {"version":3,"file":"useGetColumnWidth.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/hooks/useGetColumnWidth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,KAAK,sBAAsB,CAAC,CAAC,IAAI;IAC/B,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC;IACpD,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAE,gCAIlC,sBAAsB,CAAC,CAAC,CAAC;;CA4E3B,CAAC"}
1
+ {"version":3,"file":"useGetColumnWidth.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/hooks/useGetColumnWidth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,KAAK,sBAAsB,CAAC,CAAC,IAAI;IAC/B,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC;IACpD,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAE,gCAIlC,sBAAsB,CAAC,CAAC,CAAC;;CA4E3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useGetFacetedFilter.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/hooks/useGetFacetedFilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAItD,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,UAAU,CAAC;AAE7D,KAAK,wBAAwB,CAAC,CAAC,IAAI;IACjC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,CAAC,EAAE,cAEpC,wBAAwB,CAAC,CAAC,CAAC;;;;;CAiK7B,CAAC"}
1
+ {"version":3,"file":"useGetFacetedFilter.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/hooks/useGetFacetedFilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,UAAU,CAAC;AAE7D,KAAK,wBAAwB,CAAC,CAAC,IAAI;IACjC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,CAAC,EAAE,cAEpC,wBAAwB,CAAC,CAAC,CAAC;;;;;CAiK7B,CAAC"}
@@ -1,11 +1,23 @@
1
- import type { Header } from "@tanstack/react-table";
1
+ import type { CollisionDetection, DragStartEvent, DragEndEvent } from "@dnd-kit/core";
2
+ import type { ColumnDef, Header, Table } from "@tanstack/react-table";
2
3
  type UseGetGroupedColumnProps<T> = {
3
- header: Header<T, unknown>;
4
+ table: Table<T>;
5
+ swipeableColumns: boolean;
6
+ setActiveDragId: (id: string | null) => void;
7
+ currentGrouping: string[];
8
+ handleColumnReorder: (event: DragEndEvent) => void;
9
+ filterHeaders: (headers: Header<T, unknown>[], grouping: string[]) => Header<T, unknown>[];
10
+ isHeaderReorderable: (header: Header<T, unknown>, swipeableColumns: boolean) => boolean;
11
+ propsColumns: ColumnDef<T>[];
12
+ defaultGrouping: Array<keyof T>;
4
13
  };
5
- export declare const useGetGroupedColumn: <T>({ header, }: UseGetGroupedColumnProps<T>) => {
6
- groupedIndex: number;
7
- isGroupable: boolean;
8
- isGrouped: boolean;
14
+ export declare const useGetGroupedColumn: <T>({ table, swipeableColumns, setActiveDragId, currentGrouping, handleColumnReorder, filterHeaders, isHeaderReorderable, propsColumns, defaultGrouping, }: UseGetGroupedColumnProps<T>) => {
15
+ handleDragEnd: (event: DragEndEvent) => void;
16
+ handleDragStart: (event: DragStartEvent) => void;
17
+ handleRemoveGroup: (columnId: string) => void;
18
+ allDraggableIds: string[];
19
+ hasGroupableColumns: boolean;
20
+ customCollisionDetection: CollisionDetection;
9
21
  };
10
22
  export {};
11
23
  //# sourceMappingURL=useGetGroupedColumn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useGetGroupedColumn.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/hooks/useGetGroupedColumn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,KAAK,wBAAwB,CAAC,CAAC,IAAI;IACjC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,CAAC,EAAE,aAEpC,wBAAwB,CAAC,CAAC,CAAC;;;;CAU7B,CAAC"}
1
+ {"version":3,"file":"useGetGroupedColumn.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/hooks/useGetGroupedColumn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,YAAY,EACb,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAItE,KAAK,wBAAwB,CAAC,CAAC,IAAI;IACjC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7C,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,mBAAmB,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACnD,aAAa,EAAE,CACb,OAAO,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,EAC7B,QAAQ,EAAE,MAAM,EAAE,KACf,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC;IAC1B,mBAAmB,EAAE,CACnB,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,EAC1B,gBAAgB,EAAE,OAAO,KACtB,OAAO,CAAC;IACb,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7B,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,CAAC,EAAE,wJAUpC,wBAAwB,CAAC,CAAC,CAAC;2BA6ElB,YAAY;6BANsB,cAAc;kCAhE7C,MAAM;;;;CA2OpB,CAAC"}
@@ -1,11 +1,165 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useGetGroupedColumn = void 0;
4
- const useGetGroupedColumn = ({ header, }) => {
5
- const { getCanGroup, getGroupedIndex, getIsGrouped } = header.column;
6
- const isGroupable = getCanGroup();
7
- const isGrouped = getIsGrouped();
8
- const groupedIndex = getGroupedIndex();
9
- return { groupedIndex, isGroupable, isGrouped };
4
+ const core_1 = require("@dnd-kit/core");
5
+ const sortable_1 = require("@dnd-kit/sortable");
6
+ const react_1 = require("react");
7
+ const useGetGroupedColumn = ({ table, swipeableColumns, setActiveDragId, currentGrouping, handleColumnReorder, filterHeaders, isHeaderReorderable, propsColumns, defaultGrouping, }) => {
8
+ const { getColumn, getHeaderGroups, setGrouping } = table;
9
+ const headerGroups = getHeaderGroups();
10
+ // Handler to remove column from grouping
11
+ const handleRemoveGroup = (0, react_1.useCallback)((columnId) => {
12
+ const currentGroupingArray = currentGrouping;
13
+ const newGrouping = currentGroupingArray.filter((id) => id !== columnId);
14
+ setGrouping(newGrouping);
15
+ }, [currentGrouping, table]);
16
+ // Helper: Reorder chips within grouping panel
17
+ const handleChipReorder = (0, react_1.useCallback)((activeId, overId, groupingArray) => {
18
+ const oldIndex = groupingArray.indexOf(activeId);
19
+ const newIndex = groupingArray.indexOf(overId);
20
+ const newGrouping = (0, sortable_1.arrayMove)(groupingArray, oldIndex, newIndex);
21
+ setGrouping(newGrouping);
22
+ }, [table]);
23
+ // Helper: Add column to grouping
24
+ const handleAddToGrouping = (0, react_1.useCallback)((activeId, groupingArray) => {
25
+ const column = getColumn(activeId);
26
+ if (!column) {
27
+ return false;
28
+ }
29
+ const columnDef = column.columnDef;
30
+ // If defaultGrouping exists and enableGrouping is true, prohibit adding to grouping
31
+ if (defaultGrouping.length > 0 && columnDef.enableGrouping === true) {
32
+ return false;
33
+ }
34
+ if (columnDef.enableGrouping !== true) {
35
+ return false;
36
+ }
37
+ const accessorKey = columnDef.accessorKey;
38
+ const isAlreadyGrouped = groupingArray.includes(activeId) ||
39
+ (accessorKey && groupingArray.includes(accessorKey));
40
+ if (isAlreadyGrouped) {
41
+ return false;
42
+ }
43
+ const groupingId = accessorKey ?? activeId;
44
+ setGrouping([...groupingArray, groupingId]);
45
+ return true;
46
+ }, [table, defaultGrouping]);
47
+ // Handle drag start
48
+ const handleDragStart = (0, react_1.useCallback)((event) => {
49
+ setActiveDragId(String(event.active.id));
50
+ }, []);
51
+ // Main drag end handler
52
+ const handleDragEnd = (0, react_1.useCallback)((event) => {
53
+ setActiveDragId(null);
54
+ const { active, over } = event;
55
+ if (!over) {
56
+ return;
57
+ }
58
+ const activeId = String(active.id);
59
+ const overId = String(over.id);
60
+ const groupingArray = currentGrouping;
61
+ const isActiveGrouped = groupingArray.includes(activeId);
62
+ // Case 1: Reordering chips within grouping panel
63
+ if (isActiveGrouped && groupingArray.includes(overId)) {
64
+ handleChipReorder(activeId, overId, groupingArray);
65
+ return;
66
+ }
67
+ // Case 2: Dragging grouped chip over panel (no-op)
68
+ if (isActiveGrouped && overId === "grouping-panel") {
69
+ return;
70
+ }
71
+ // Case 3: Dragging header to grouping panel
72
+ if (overId === "grouping-panel") {
73
+ handleAddToGrouping(activeId, groupingArray);
74
+ return;
75
+ }
76
+ // Case 4: Column reordering (when swipeableColumns is enabled)
77
+ if (swipeableColumns) {
78
+ handleColumnReorder(event);
79
+ }
80
+ }, [
81
+ currentGrouping,
82
+ swipeableColumns,
83
+ handleColumnReorder,
84
+ handleChipReorder,
85
+ handleAddToGrouping,
86
+ ]);
87
+ // Get ALL draggable column IDs for unified SortableContext
88
+ // This includes: groupable headers, reorderable headers, and grouped chips
89
+ const allDraggableIds = (0, react_1.useMemo)(() => {
90
+ const ids = new Set();
91
+ // Add all visible center headers that are either groupable or reorderable
92
+ headerGroups.forEach((headerGroup) => {
93
+ const filteredHeaders = filterHeaders(headerGroup.headers, currentGrouping);
94
+ filteredHeaders.forEach((header) => {
95
+ // Skip pinned columns and group column
96
+ if (header.column.getIsPinned() || header.column.id === "grouped_by") {
97
+ return;
98
+ }
99
+ const columnDef = header.column.columnDef;
100
+ const isGroupable = columnDef.enableGrouping === true;
101
+ const isReorderable = swipeableColumns && isHeaderReorderable(header, true);
102
+ if (isGroupable || isReorderable) {
103
+ ids.add(header.column.id);
104
+ }
105
+ });
106
+ });
107
+ // Add already grouped columns (for reordering chips in the panel)
108
+ currentGrouping.forEach((groupId) => {
109
+ ids.add(groupId);
110
+ });
111
+ return Array.from(ids);
112
+ }, [
113
+ headerGroups,
114
+ currentGrouping,
115
+ filterHeaders,
116
+ swipeableColumns,
117
+ isHeaderReorderable,
118
+ ]);
119
+ const customCollisionDetection = (0, react_1.useCallback)((args) => {
120
+ const { active } = args;
121
+ const activeId = String(active.id);
122
+ const groupingArray = currentGrouping;
123
+ const isDraggingChip = groupingArray.includes(activeId);
124
+ // Get all collisions using rectIntersection
125
+ const rectCollisions = (0, core_1.rectIntersection)(args);
126
+ // If dragging a chip (reordering within panel)
127
+ if (isDraggingChip) {
128
+ // Find collisions with other chips (not the panel itself)
129
+ const chipCollisions = rectCollisions.filter((collision) => groupingArray.includes(String(collision.id)) &&
130
+ String(collision.id) !== activeId);
131
+ // If hovering over another chip, prioritize chip-to-chip collision
132
+ if (chipCollisions.length > 0) {
133
+ return chipCollisions;
134
+ }
135
+ // Otherwise return panel collision if over panel
136
+ const panelCollision = rectCollisions.find((collision) => collision.id === "grouping-panel");
137
+ return panelCollision ? [panelCollision] : rectCollisions;
138
+ }
139
+ // If dragging a header (adding to grouping)
140
+ // Check if pointer is within the grouping panel
141
+ const pointerCollisions = (0, core_1.pointerWithin)(args);
142
+ const groupingPanelCollision = pointerCollisions.find((collision) => collision.id === "grouping-panel");
143
+ // If pointer is over the grouping panel, prioritize it
144
+ if (groupingPanelCollision) {
145
+ return [groupingPanelCollision];
146
+ }
147
+ // Otherwise use rectIntersection for column swapping
148
+ return rectCollisions;
149
+ }, [currentGrouping]);
150
+ const hasGroupableColumns = (0, react_1.useMemo)(() => {
151
+ return propsColumns.some((column) => {
152
+ const columnDef = column;
153
+ return columnDef.enableGrouping === true || !!defaultGrouping.length;
154
+ });
155
+ }, [propsColumns, defaultGrouping]);
156
+ return {
157
+ handleDragEnd,
158
+ handleDragStart,
159
+ handleRemoveGroup,
160
+ allDraggableIds,
161
+ hasGroupableColumns,
162
+ customCollisionDetection,
163
+ };
10
164
  };
11
165
  exports.useGetGroupedColumn = useGetGroupedColumn;
@@ -1 +1 @@
1
- {"version":3,"file":"useGetPinningColumns.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/hooks/useGetPinningColumns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,KAAK,yBAAyB,CAAC,CAAC,IAAI;IAClC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAE,cAErC,yBAAyB,CAAC,CAAC,CAAC;;;CA0B9B,CAAC"}
1
+ {"version":3,"file":"useGetPinningColumns.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/hooks/useGetPinningColumns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,KAAK,yBAAyB,CAAC,CAAC,IAAI;IAClC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAE,cAErC,yBAAyB,CAAC,CAAC,CAAC;;;CA0B9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useGetRowSelection.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/hooks/useGetRowSelection.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,KAAK,uBAAuB,CAAC,CAAC,IAAI;IAChC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACjC,mBAAmB,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,CAAC;IAC9C,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAG,uDAIpC,uBAAuB,CAAC,CAAC,CAAC;;CAkI5B,CAAC"}
1
+ {"version":3,"file":"useGetRowSelection.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/hooks/useGetRowSelection.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,KAAK,uBAAuB,CAAC,CAAC,IAAI;IAChC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACjC,mBAAmB,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,CAAC;IAC9C,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAG,uDAIpC,uBAAuB,CAAC,CAAC,CAAC;;CAkI5B,CAAC"}
@@ -5,7 +5,7 @@ type UseGetSortedColumnProps<T> = {
5
5
  export declare const useGetSortedColumn: <T>({ header, }: UseGetSortedColumnProps<T>) => {
6
6
  isSortable: boolean;
7
7
  mutipleSortCounts: number;
8
- sortableIcon: import("react/jsx-runtime").JSX.Element;
8
+ sortableIcon: import("react/jsx-runtime").JSX.Element | null;
9
9
  };
10
10
  export {};
11
11
  //# sourceMappingURL=useGetSortedColumn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useGetSortedColumn.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/hooks/useGetSortedColumn.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AASpD,KAAK,uBAAuB,CAAC,CAAC,IAAI;IAChC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAG,aAEpC,uBAAuB,CAAC,CAAC,CAAC;;;;CAgB5B,CAAC"}
1
+ {"version":3,"file":"useGetSortedColumn.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/hooks/useGetSortedColumn.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAQpD,KAAK,uBAAuB,CAAC,CAAC,IAAI;IAChC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAG,aAEpC,uBAAuB,CAAC,CAAC,CAAC;;;;CAgB5B,CAAC"}