sccoreui 6.1.87 → 6.1.89

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.
@@ -17,11 +17,12 @@ const ColumnGroup = (props) => {
17
17
  const columnGroupRef = (0, react_1.useRef)(null);
18
18
  const btnRef = (0, react_1.useRef)(null);
19
19
  const [inpVlaue, setInpValue] = (0, react_1.useState)("");
20
- const { gridApi, setGridData, setSelectedGroup, setFeatureDetails, featureDetails, initialCheckBoxData } = (0, react_1.useContext)(context_provider_1.FeatureContext);
20
+ const { gridApi, setGridData, setSelectedGroup, setFeatureDetails, featureDetails, initialCheckBoxData, intialColumns, setIntialColumns, } = (0, react_1.useContext)(context_provider_1.FeatureContext);
21
21
  const [columns, setColumns] = (0, react_1.useState)([]);
22
22
  const [renderColumns, setRenderColumns] = (0, react_1.useState)([]);
23
23
  const [columnsSelectedForGroup, setColumnsSelectedForGroup] = (0, react_1.useState)([]);
24
24
  const [selectedCheckBoxesLength, setSelectedCheckBoxesLength] = (0, react_1.useState)(null);
25
+ console.log("intiallllllllll", intialColumns);
25
26
  // const [featureDetails, setFeatureDetails] = useState<Features>({
26
27
  // searchedText: "",
27
28
  // filterQueries: [],
@@ -54,8 +55,7 @@ const ColumnGroup = (props) => {
54
55
  };
55
56
  const onSelectedCheckbox = (item, e) => {
56
57
  const isChecked = e.checked;
57
- const updatedColumns = renderColumns.map((listItem) => listItem.id === item.id
58
- ? Object.assign(Object.assign({}, listItem), { rowGroup: isChecked }) : listItem);
58
+ const updatedColumns = renderColumns.map((listItem) => listItem.id === item.id ? Object.assign(Object.assign({}, listItem), { rowGroup: isChecked }) : listItem);
59
59
  // Sort columns: checked (true) come before unchecked (false)
60
60
  const sortedColumns = updatedColumns.sort((a, b) => (b.rowGroup ? 1 : 0) - (a.rowGroup ? 1 : 0));
61
61
  // setColumns(sortedColumns);
@@ -63,6 +63,7 @@ const ColumnGroup = (props) => {
63
63
  const lengthOfSelectedCheckBoxes = sortedColumns.filter((col) => col.rowGroup).length;
64
64
  setSelectedCheckBoxesLength(lengthOfSelectedCheckBoxes);
65
65
  };
66
+ console.log("columns innnnnnnn", dataFromProps);
66
67
  const searchResults = (e) => {
67
68
  // console.log
68
69
  setRenderColumns(() => columns.filter((column) => {
@@ -71,7 +72,7 @@ const ColumnGroup = (props) => {
71
72
  }));
72
73
  setInpValue(e.target.value);
73
74
  };
74
- // Save Grouping
75
+ // Save Grouping
75
76
  const saveGrouping = (e) => {
76
77
  var _a, _b;
77
78
  setSelectedGroup([]);
@@ -106,22 +107,25 @@ const ColumnGroup = (props) => {
106
107
  };
107
108
  // Remove grouping
108
109
  const clearListItems = (e) => {
109
- var _a, _b;
110
110
  e.stopPropagation();
111
111
  setSelectedGroup([]);
112
- // Update the grid's column definitions with the modified columns
113
- gridApi && ((_a = gridApi === null || gridApi === void 0 ? void 0 : gridApi.current) === null || _a === void 0 ? void 0 : _a.api.setGridOption("columnDefs", dataFromProps.columData));
114
- gridApi && ((_b = gridApi === null || gridApi === void 0 ? void 0 : gridApi.current) === null || _b === void 0 ? void 0 : _b.columnApi.setRowGroupColumns([])); // Clear row group columns
115
- // Update the grid's data state to reflect the new column configuration
116
- setGridData((prev) => (Object.assign(Object.assign({}, prev), { columnData: dataFromProps.columnData })));
117
- // Reset the state
118
- setColumnsSelectedForGroup([]);
119
- setRenderColumns(dataFromProps.columnData);
120
- setSelectedCheckBoxesLength(0);
121
- // Reset the feature details state
122
- setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: initialCheckBoxData }));
123
- // Hide the column grouping UI element
124
- (columnGroupRef === null || columnGroupRef === void 0 ? void 0 : columnGroupRef.current) && (columnGroupRef === null || columnGroupRef === void 0 ? void 0 : columnGroupRef.current.hide());
112
+ if (gridApi) {
113
+ // Use deep copy of `intialColumns` to ensure no unintended mutation
114
+ const clonedInitialColumns = JSON.parse(JSON.stringify(intialColumns));
115
+ // Update grid's column definitions
116
+ gridApi.current.api.setColumnDefs(clonedInitialColumns);
117
+ gridApi.current.columnApi.setRowGroupColumns([]);
118
+ // Reflect the new column configuration in the state
119
+ setGridData((prev) => (Object.assign(Object.assign({}, prev), { columnData: clonedInitialColumns })));
120
+ // Reset states accordingly
121
+ setColumnsSelectedForGroup([]);
122
+ setRenderColumns(clonedInitialColumns);
123
+ setSelectedCheckBoxesLength(0);
124
+ setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: initialCheckBoxData }));
125
+ if (columnGroupRef === null || columnGroupRef === void 0 ? void 0 : columnGroupRef.current) {
126
+ columnGroupRef.current.hide();
127
+ }
128
+ }
125
129
  };
126
130
  const handleHide = () => {
127
131
  var _a, _b, _c;
@@ -134,16 +138,25 @@ const ColumnGroup = (props) => {
134
138
  };
135
139
  (0, react_1.useEffect)(() => {
136
140
  var _a, _b, _c, _d, _e, _f, _g, _h;
137
- // Get columns from grd
141
+ // Get columns from grid
138
142
  if ((_d = (_c = (_b = (_a = gridApi === null || gridApi === void 0 ? void 0 : gridApi.current) === null || _a === void 0 ? void 0 : _a.api) === null || _b === void 0 ? void 0 : _b.columnModel) === null || _c === void 0 ? void 0 : _c.columnDefs) === null || _d === void 0 ? void 0 : _d.length) {
143
+ // Deep clone columns from the grid to avoid mutation
139
144
  const columnsFromGrid = (_h = (_g = (_f = (_e = gridApi === null || gridApi === void 0 ? void 0 : gridApi.current) === null || _e === void 0 ? void 0 : _e.api) === null || _f === void 0 ? void 0 : _f.columnModel) === null || _g === void 0 ? void 0 : _g.columnDefs) === null || _h === void 0 ? void 0 : _h.map((column) => {
140
- column.rowGroup = false;
141
- return column;
145
+ return Object.assign(Object.assign({}, column), { rowGroup: false }); // Create a shallow copy with `rowGroup` set to false
142
146
  });
147
+ // Update state with the cloned columns
143
148
  setColumns(columnsFromGrid);
144
149
  setRenderColumns(columnsFromGrid);
150
+ // Initialize `intialColumns` only if it hasn't been set yet
151
+ if (!intialColumns) {
152
+ // Perform a deep copy of the columns array using `JSON.parse(JSON.stringify())`
153
+ const deepCopyOfColumns = JSON.parse(JSON.stringify(columnsFromGrid));
154
+ setIntialColumns(deepCopyOfColumns);
155
+ }
145
156
  }
146
157
  }, [(_d = (_c = (_b = (_a = gridApi === null || gridApi === void 0 ? void 0 : gridApi.current) === null || _a === void 0 ? void 0 : _a.api) === null || _b === void 0 ? void 0 : _b.columnModel) === null || _c === void 0 ? void 0 : _c.columnDefs) === null || _d === void 0 ? void 0 : _d.length]);
147
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `${(columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length) > 0 ? "bg-primary-50" : "bg-white"} hover:bg-primary-25 br-8 cursor-pointer pd-9 flex align-items-cente gap-1 zoom_animate`, ref: btnRef, onClick: showColumnOptions }, { children: [(0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "grid-01", size: 18, color: (columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length) > 0 ? "text-primary-400" : "text-gray-500" }), (columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length) > 0 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-primary-400 font-semibold ml-1" }, { children: columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex gap-2 text-primary-400 font-semibold" }, { children: ["Selected", (0, jsx_runtime_1.jsx)(button_1.Button, { onClick: (e) => clearListItems(e), className: "h-auto p-0", text: true, icon: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "x-close", color: "text-primary-400", size: 18 }) })] }))] }))] })), (0, jsx_runtime_1.jsxs)(overlaypanel_1.OverlayPanel, Object.assign({ ref: columnGroupRef, className: "column-group p-1", onHide: handleHide }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "column-header" }, { children: [(0, jsx_runtime_1.jsx)("h3", Object.assign({ className: "my-0" }, { children: "Grouping" })), (0, jsx_runtime_1.jsx)("p", Object.assign({ className: "my-0 mb-4" }, { children: "Select one or two columns for sorting" }))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "column-body" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "p-input-icon-right w-full p-2 bg-gray-50" }, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "p-input-suffix top-0", style: { right: "20px" } }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "search-md" }) })), (0, jsx_runtime_1.jsx)(inputtext_1.InputText, { onChange: (e) => searchResults(e), value: inpVlaue, disabled: false, placeholder: "Enter any column name", className: "text-lg font-normal text-gray-500 hover:text-gray-900 w-full" })] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex flex-column gap-1 mt-1 mr-1 max-h-15rem max-w-30rem overflow-y-auto" }, { children: renderColumns.map((column, index) => ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center gap-2 pl-2" }, { children: [column.rowGroup && ((0, jsx_runtime_1.jsx)("img", { onDragStart: (e) => onDragStart(e, index), onDragOver: onDragOver, onDrop: (e) => onDrop(e, index), src: drag_and_drop_icon_png_1.default, width: 20, height: 20 })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `flex gap-2 ${column.rowGroup && "bg-primary-25"} hover:bg-primary-25 border-round-sm p-3 w-full` }, { children: [(0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, { checked: column.rowGroup, onChange: (e) => onSelectedCheckbox(column, e), disabled: selectedCheckBoxesLength === 2 && !column.rowGroup }), (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "max-w-28rem line-clamp line-clamp-1 inline-block", title: column.headerName }, { children: column.headerName }))] }))] }), column.id))) }))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "column-footer gap-2 border-top-1 border-gray-200 flex align-items-center justify-content-between" }, { children: [(0, jsx_runtime_1.jsx)(button_1.Button, { className: "cursor-pointer", text: true, label: "Remove Grouping", onClick: (e) => clearListItems(e) }), (0, jsx_runtime_1.jsx)(button_1.Button, { className: "cursor-pointer", label: "Save Grouping", onClick: (e) => saveGrouping(e) })] }))] }))] }));
158
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `${(columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length) > 0 ? "bg-primary-50" : "bg-white"} hover:bg-primary-25 br-8 cursor-pointer pd-9 flex align-items-cente gap-1 zoom_animate`, ref: btnRef, onClick: showColumnOptions }, { children: [(0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "grid-01", size: 18, color: (columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length) > 0
159
+ ? "text-primary-400"
160
+ : "text-gray-500" }), (columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length) > 0 && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center justify-content-center" }, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-primary-400 font-semibold ml-1" }, { children: columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center gap-2 text-primary-400 font-semibold" }, { children: [(0, jsx_runtime_1.jsx)("p", Object.assign({ className: "ml-2" }, { children: "Selected" })), (0, jsx_runtime_1.jsx)(button_1.Button, { onClick: (e) => clearListItems(e), className: "h-auto p-0", text: true, icon: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "x-close", color: "text-primary-400", size: 18 }) })] }))] })))] })), (0, jsx_runtime_1.jsxs)(overlaypanel_1.OverlayPanel, Object.assign({ ref: columnGroupRef, className: "column-group p-1", onHide: handleHide }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "column-header" }, { children: [(0, jsx_runtime_1.jsx)("h3", Object.assign({ className: "my-0" }, { children: "Grouping" })), (0, jsx_runtime_1.jsx)("p", Object.assign({ className: "my-0 mb-4" }, { children: "Select one or two columns for sorting" }))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "column-body" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "p-input-icon-right w-full p-2 bg-gray-50" }, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "p-input-suffix top-0", style: { right: "20px" } }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "search-md" }) })), (0, jsx_runtime_1.jsx)(inputtext_1.InputText, { onChange: (e) => searchResults(e), value: inpVlaue, disabled: false, placeholder: "Enter any column name", className: "text-lg font-normal text-gray-500 hover:text-gray-900 w-full" })] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex flex-column gap-1 mt-1 mr-1 max-h-15rem max-w-30rem overflow-y-auto" }, { children: renderColumns.map((column, index) => ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center gap-2 pl-2" }, { children: [column.rowGroup && ((0, jsx_runtime_1.jsx)("img", { onDragStart: (e) => onDragStart(e, index), onDragOver: onDragOver, onDrop: (e) => onDrop(e, index), src: drag_and_drop_icon_png_1.default, width: 20, height: 20 })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `flex gap-2 ${column.rowGroup && "bg-primary-25"} hover:bg-primary-25 border-round-sm p-3 w-full` }, { children: [(0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, { checked: column.rowGroup, onChange: (e) => onSelectedCheckbox(column, e), disabled: selectedCheckBoxesLength === 2 && !column.rowGroup }), (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "max-w-28rem line-clamp line-clamp-1 inline-block", title: column.headerName }, { children: column.headerName }))] }))] }), column.id))) }))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "column-footer gap-2 border-top-1 border-gray-200 flex align-items-center justify-content-between" }, { children: [(0, jsx_runtime_1.jsx)(button_1.Button, { className: "cursor-pointer", text: true, label: "Remove Grouping", onClick: (e) => clearListItems(e) }), (0, jsx_runtime_1.jsx)(button_1.Button, { className: "cursor-pointer", label: "Save Grouping", onClick: (e) => saveGrouping(e) })] }))] }))] }));
148
161
  };
149
162
  exports.default = ColumnGroup;
@@ -6,7 +6,7 @@ const react_1 = require("react");
6
6
  const helper_1 = require("./helper");
7
7
  exports.FeatureContext = (0, react_1.createContext)(null);
8
8
  function MyProvider({ children, value }) {
9
- const { featureDetails, setFeatureDetails, gridData, callGrid, totalRecords, initialFeature, defaultFilters, createView, enableViewCreate, filterModelText, sortModelText, recordDetailModelText, sidePanelText, sortOptions, filterConditions, clearFilters, setGridData, gridApi, updateColumnsForGrid, enableManageColumnsCallback, columnToRender, selectedGroup, setSelectedGroup, initialCheckBoxData } = value;
9
+ const { featureDetails, setFeatureDetails, gridData, callGrid, totalRecords, initialFeature, defaultFilters, createView, enableViewCreate, filterModelText, sortModelText, recordDetailModelText, sidePanelText, sortOptions, filterConditions, clearFilters, setGridData, gridApi, updateColumnsForGrid, enableManageColumnsCallback, columnToRender, selectedGroup, setSelectedGroup, initialCheckBoxData, intialColumns, setIntialColumns } = value;
10
10
  // States for sort
11
11
  const [columnData] = (0, react_1.useState)(gridData === null || gridData === void 0 ? void 0 : gridData.columnData);
12
12
  const [sortValue, setSortValue] = (0, react_1.useState)({});
@@ -95,7 +95,9 @@ function MyProvider({ children, value }) {
95
95
  columnToRender,
96
96
  selectedGroup,
97
97
  setSelectedGroup,
98
- initialCheckBoxData
98
+ initialCheckBoxData,
99
+ intialColumns,
100
+ setIntialColumns
99
101
  } }, { children: children })));
100
102
  }
101
103
  exports.default = MyProvider;
@@ -1,14 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.autoGroupColumnDef = exports.fillOperation = exports.updateCells = exports.getCheckedStatus = exports.sortColumns = exports.parseIfNeeded = exports.applyDefaultFilters = void 0;
3
+ exports.handleCheckboxClick = exports.getGroupIds = exports.handleUncheckedState = exports.handleCheckedState = exports.updateGroupState = exports.determineConditions = exports.updateRecords = exports.autoGroupColumnDef = exports.fillOperation = exports.updateCells = exports.getCheckedStatus = exports.sortColumns = exports.parseIfNeeded = exports.applyDefaultFilters = exports.initialCheckBoxData = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const constants_1 = require("./constants");
6
+ // initial checkbox data
7
+ exports.initialCheckBoxData = {
8
+ allBoxChecked: false,
9
+ isIndeterminate: false,
10
+ includedRecords: [],
11
+ excludedRecords: [],
12
+ headerCheckBoxStatus: constants_1.GRID_CHECKBOX_STATUS.NEUTRAL,
13
+ };
5
14
  const applyDefaultFilters = (defaultFilters) => {
6
15
  const filters = defaultFilters === null || defaultFilters === void 0 ? void 0 : defaultFilters.map((item) => {
7
16
  const obj = {
8
17
  logicalOperator: item === null || item === void 0 ? void 0 : item.logicalOperator,
9
18
  selectedColumn: item === null || item === void 0 ? void 0 : item.columnName,
10
19
  selectedOperation: item === null || item === void 0 ? void 0 : item.condition,
11
- value: item === null || item === void 0 ? void 0 : item.value
20
+ value: item === null || item === void 0 ? void 0 : item.value,
12
21
  };
13
22
  return obj;
14
23
  });
@@ -35,8 +44,8 @@ const parseIfNeeded = (value) => {
35
44
  exports.parseIfNeeded = parseIfNeeded;
36
45
  const sortColumns = (columns) => {
37
46
  const sortedColumns = columns === null || columns === void 0 ? void 0 : columns.sort((a, b) => {
38
- a.body = a.cellRenderer, // Update the rederer key to avoid recursion
39
- b.body = b.cellRenderer; // Update the rederer key to avoid recursion
47
+ (a.body = a.cellRenderer), // Update the rederer key to avoid recursion
48
+ (b.body = b.cellRenderer); // Update the rederer key to avoid recursion
40
49
  if (!a.seq)
41
50
  return 1;
42
51
  if (!b.seq)
@@ -80,12 +89,12 @@ const updateCells = (updatedRowData, setUpdateRowData, api) => {
80
89
  }
81
90
  };
82
91
  exports.updateCells = updateCells;
83
- // Fill data in grid through drag
92
+ // Fill data in grid through drag
84
93
  const fillOperation = (params, api, editedRecords, setEditedRecords) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
85
94
  var _a, _b, _c, _d, _e, _f, _g;
86
95
  const { finalRange } = params;
87
96
  const { startRow, endRow, columns,
88
- // startColumn
97
+ // startColumn
89
98
  } = finalRange;
90
99
  const columnDetails = columns[0].colDef;
91
100
  const parentRowData = (_c = api.getDisplayedRowAtIndex((_b = (_a = params === null || params === void 0 ? void 0 : params.initialRange) === null || _a === void 0 ? void 0 : _a.startRow) === null || _b === void 0 ? void 0 : _b.rowIndex)) === null || _c === void 0 ? void 0 : _c.data;
@@ -99,11 +108,12 @@ const fillOperation = (params, api, editedRecords, setEditedRecords) => tslib_1.
99
108
  continue; // Skip if rowNode is undefined
100
109
  const rowData = rowNode === null || rowNode === void 0 ? void 0 : rowNode.data;
101
110
  // Check if rowData exists and update the field
102
- if (rowData && (rowNode.id != (parentRowData === null || parentRowData === void 0 ? void 0 : parentRowData.id))) {
111
+ if (rowData && rowNode.id != (parentRowData === null || parentRowData === void 0 ? void 0 : parentRowData.id)) {
103
112
  // Skip edit for same values
104
- if ((rowData === null || rowData === void 0 ? void 0 : rowData[columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.field]) === (parentRowData === null || parentRowData === void 0 ? void 0 : parentRowData[columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.field]))
113
+ if ((rowData === null || rowData === void 0 ? void 0 : rowData[columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.field]) ===
114
+ (parentRowData === null || parentRowData === void 0 ? void 0 : parentRowData[columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.field]))
105
115
  continue;
106
- // If Dragged cell is grouped only group headers should edit vice versa to child cells
116
+ // If Dragged cell is grouped only group headers should edit vice versa to child cells
107
117
  if (((_d = rowData === null || rowData === void 0 ? void 0 : rowData.orgHierarchy) === null || _d === void 0 ? void 0 : _d.length) !== ((_e = parentRowData === null || parentRowData === void 0 ? void 0 : parentRowData.orgHierarchy) === null || _e === void 0 ? void 0 : _e.length))
108
118
  continue;
109
119
  // if( rowData?.[columnDetails?.field] == EMPTY_RECORD || rowData?.type !== parentRowData?.type || !rowData?.[columnDetails?.field] ){
@@ -120,7 +130,7 @@ const fillOperation = (params, api, editedRecords, setEditedRecords) => tslib_1.
120
130
  const schemaForEdit = {
121
131
  row: rowData,
122
132
  field: [],
123
- isCustomAttribute: columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.isCustomAttribute
133
+ isCustomAttribute: columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.isCustomAttribute,
124
134
  };
125
135
  if (!((_f = schemaForEdit === null || schemaForEdit === void 0 ? void 0 : schemaForEdit.field) === null || _f === void 0 ? void 0 : _f.includes(columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.field))) {
126
136
  (_g = schemaForEdit === null || schemaForEdit === void 0 ? void 0 : schemaForEdit.field) === null || _g === void 0 ? void 0 : _g.push(columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.field);
@@ -193,13 +203,348 @@ const autoGroupColumnDef = (isTreeEnable, headerName, groupField, GroupHeaderCom
193
203
  return {
194
204
  suppressCount: false,
195
205
  checkbox: false,
196
- innerRenderer: HeaderRendererForGroup
206
+ innerRenderer: HeaderRendererForGroup,
197
207
  };
198
208
  }
199
209
  // Return specific params for group rows to use default rendering
200
- return { suppressCount: typeof (displayGroupCount) === "boolean" ? !displayGroupCount : true };
210
+ return {
211
+ suppressCount: typeof displayGroupCount === "boolean" ? !displayGroupCount : true,
212
+ };
201
213
  },
202
214
  };
203
215
  }
204
216
  };
205
217
  exports.autoGroupColumnDef = autoGroupColumnDef;
218
+ // function to update the records based on checkbox state
219
+ // This function determines how to update `includedRecords` and `excludedRecords`
220
+ // depending on whether all checkboxes are checked or not (`allBoxChecked` state)
221
+ const updateRecords = (rowData, featureDetails, gridData) => {
222
+ var _a, _b, _c, _d;
223
+ const { excludedRecords, includedRecords, allBoxChecked } = featureDetails.checkBoxSelection;
224
+ let newExcludedRecords = [...excludedRecords];
225
+ let newIncludedRecords = [...includedRecords];
226
+ // When all checkboxes are checked
227
+ if (allBoxChecked) {
228
+ // Update excluded records: add or remove the current rowData
229
+ newExcludedRecords = (excludedRecords === null || excludedRecords === void 0 ? void 0 : excludedRecords.includes(rowData))
230
+ ? excludedRecords === null || excludedRecords === void 0 ? void 0 : excludedRecords.filter((item) => (item === null || item === void 0 ? void 0 : item.id) !== (rowData === null || rowData === void 0 ? void 0 : rowData.id))
231
+ : [...excludedRecords, rowData];
232
+ // Check if all records are included; reset if so
233
+ if ((newIncludedRecords === null || newIncludedRecords === void 0 ? void 0 : newIncludedRecords.length) === ((_a = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _a === void 0 ? void 0 : _a.length)) {
234
+ return {
235
+ excludedRecords: [],
236
+ includedRecords: [],
237
+ isIndeterminate: false,
238
+ allBoxChecked: true,
239
+ };
240
+ }
241
+ // Check if all records are excluded; reset if so
242
+ else if ((newExcludedRecords === null || newExcludedRecords === void 0 ? void 0 : newExcludedRecords.length) === ((_b = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _b === void 0 ? void 0 : _b.length)) {
243
+ return exports.initialCheckBoxData;
244
+ }
245
+ // Otherwise, update the excluded records and indeterminate state
246
+ else {
247
+ return Object.assign(Object.assign({}, featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection), { excludedRecords: newExcludedRecords, isIndeterminate: !(excludedRecords === null || excludedRecords === void 0 ? void 0 : excludedRecords.includes(rowData)) });
248
+ }
249
+ }
250
+ // When not all checkboxes are checked
251
+ else {
252
+ // Update included records: add or remove the current rowData
253
+ newIncludedRecords = (includedRecords === null || includedRecords === void 0 ? void 0 : includedRecords.includes(rowData))
254
+ ? includedRecords === null || includedRecords === void 0 ? void 0 : includedRecords.filter((item) => (item === null || item === void 0 ? void 0 : item.id) !== (rowData === null || rowData === void 0 ? void 0 : rowData.id))
255
+ : [...includedRecords, rowData];
256
+ // Check if all records are included; reset if so
257
+ if ((newIncludedRecords === null || newIncludedRecords === void 0 ? void 0 : newIncludedRecords.length) === ((_c = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _c === void 0 ? void 0 : _c.length)) {
258
+ return {
259
+ excludedRecords: [],
260
+ includedRecords: [],
261
+ isIndeterminate: false,
262
+ allBoxChecked: true,
263
+ };
264
+ }
265
+ // Check if all records are excluded; reset if so
266
+ else if ((newExcludedRecords === null || newExcludedRecords === void 0 ? void 0 : newExcludedRecords.length) === ((_d = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _d === void 0 ? void 0 : _d.length)) {
267
+ return exports.initialCheckBoxData;
268
+ }
269
+ // Otherwise, update the included records
270
+ else {
271
+ return Object.assign(Object.assign({}, featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection), { includedRecords: newIncludedRecords });
272
+ }
273
+ }
274
+ };
275
+ exports.updateRecords = updateRecords;
276
+ // Utility function to determine conditions for updating group states
277
+ // Based on various flags and states, determines whether to add or remove group IDs
278
+ const determineConditions = (isChecked, allBoxChecked, isEveryParentGroupInclude, isEveryParentGroupExcluded, isEverySuperParentGroupExcluded) => ({
279
+ addParent: (!allBoxChecked && isChecked && isEveryParentGroupInclude) ||
280
+ (allBoxChecked && isChecked && isEveryParentGroupExcluded),
281
+ addSuperParent: (!allBoxChecked && isChecked && isEveryParentGroupInclude) ||
282
+ (allBoxChecked && isChecked && isEverySuperParentGroupExcluded),
283
+ removeParent: (!allBoxChecked && !isChecked && !isEveryParentGroupInclude) ||
284
+ (allBoxChecked && !isChecked && !isEveryParentGroupExcluded),
285
+ removeSuperParent: (!allBoxChecked && !isChecked && !isEveryParentGroupInclude) ||
286
+ (allBoxChecked && !isChecked && !isEverySuperParentGroupExcluded),
287
+ });
288
+ exports.determineConditions = determineConditions;
289
+ // Function to update the selected groups in the state
290
+ // Takes the group ID and a boolean flag `add` to decide whether to add or remove the group ID
291
+ const updateSelectedGroup = (id, add, setSelectedGroup) => {
292
+ setSelectedGroup((prev) => {
293
+ if (add) {
294
+ // If `add` is true, add the group ID if it does not already exist in the state
295
+ if (!prev.includes(id)) {
296
+ return [...prev, id];
297
+ }
298
+ }
299
+ else {
300
+ // If `add` is false, remove the group ID from the state
301
+ return prev.filter((groupId) => groupId !== id);
302
+ }
303
+ return prev;
304
+ });
305
+ };
306
+ // function to update the selected groups in the state
307
+ // Manages adding or removing group IDs based on the grouping column count and conditions
308
+ const updateGroupState = (groupingColumns, parentId, superParentId, conditions, setSelectedGroup) => {
309
+ const { addParent, addSuperParent, removeParent, removeSuperParent } = conditions;
310
+ // Handle logic when there are 2 grouping columns
311
+ if (groupingColumns === 2) {
312
+ if (addSuperParent)
313
+ updateSelectedGroup(superParentId, true, setSelectedGroup); // Add super parent group ID
314
+ if (addParent) {
315
+ updateSelectedGroup(parentId, true, setSelectedGroup);
316
+ }
317
+ ; // Add parent group ID
318
+ if (removeSuperParent)
319
+ updateSelectedGroup(superParentId, false, setSelectedGroup); // Remove super parent group ID
320
+ if (removeParent)
321
+ updateSelectedGroup(parentId, false, setSelectedGroup); // Remove parent group ID
322
+ }
323
+ // Handle logic when there is 1 grouping column
324
+ else if (groupingColumns === 1) {
325
+ if (addParent)
326
+ updateSelectedGroup(parentId, true, setSelectedGroup); // Add parent group ID
327
+ if (removeParent)
328
+ updateSelectedGroup(parentId, false, setSelectedGroup); // Remove parent group ID
329
+ }
330
+ };
331
+ exports.updateGroupState = updateGroupState;
332
+ // ------------------------------------- group header checkbox -------------------------------------------
333
+ // Utility function to gather all child and parent data for a group
334
+ const gatherGroupData = (params) => {
335
+ var _a, _b, _c, _d;
336
+ const groupData = (_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.allLeafChildren) === null || _b === void 0 ? void 0 : _b.map((childNode) => childNode === null || childNode === void 0 ? void 0 : childNode.data);
337
+ const parentGroupData = (_d = (_c = params === null || params === void 0 ? void 0 : params.node.parent) === null || _c === void 0 ? void 0 : _c.allLeafChildren) === null || _d === void 0 ? void 0 : _d.map((childNode) => childNode === null || childNode === void 0 ? void 0 : childNode.data);
338
+ return { groupData, parentGroupData };
339
+ };
340
+ // Utility function to handle checked state updates
341
+ const handleCheckedState = (params, featureDetails, gridData, setFeatureDetails, setSelectedGroup, groupingColumns) => {
342
+ const { excludedRecords, includedRecords, allBoxChecked } = featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection;
343
+ const { groupData, parentGroupData } = gatherGroupData(params);
344
+ let newExcludedRecords = [...excludedRecords];
345
+ let newIncludedRecords = [...includedRecords];
346
+ // Update records based on the checkbox state
347
+ groupData.forEach((group) => {
348
+ var _a, _b;
349
+ if (allBoxChecked) {
350
+ newExcludedRecords = (newExcludedRecords === null || newExcludedRecords === void 0 ? void 0 : newExcludedRecords.includes(group))
351
+ ? newExcludedRecords.filter((item) => item !== group)
352
+ : [...newExcludedRecords, group];
353
+ }
354
+ else if (!((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.leafGroup) && ((_b = params === null || params === void 0 ? void 0 : params.node) === null || _b === void 0 ? void 0 : _b.level) === 0) {
355
+ newIncludedRecords = newIncludedRecords.includes(group)
356
+ ? newIncludedRecords
357
+ : [...newIncludedRecords, group];
358
+ }
359
+ else {
360
+ newIncludedRecords = newIncludedRecords.includes(group)
361
+ ? newIncludedRecords
362
+ : [...newIncludedRecords, group];
363
+ }
364
+ });
365
+ updateCheckboxData(newIncludedRecords, newExcludedRecords, gridData, featureDetails, setFeatureDetails);
366
+ const isParent = determineParentGroupState(parentGroupData, newIncludedRecords, newExcludedRecords, allBoxChecked);
367
+ handleGroupSelection(params, setSelectedGroup, groupingColumns, isParent);
368
+ };
369
+ exports.handleCheckedState = handleCheckedState;
370
+ // Utility function to handle unchecked state updates
371
+ const handleUncheckedState = (params, featureDetails, gridData, setFeatureDetails, setSelectedGroup, groupingColumns) => {
372
+ const { excludedRecords, includedRecords, allBoxChecked } = featureDetails.checkBoxSelection;
373
+ const { groupData, parentGroupData } = gatherGroupData(params);
374
+ let newExcludedRecords = [...excludedRecords];
375
+ let newIncludedRecords = [...includedRecords];
376
+ // Update records based on the checkbox state
377
+ groupData.forEach((group) => {
378
+ if (allBoxChecked) {
379
+ newExcludedRecords = newExcludedRecords.includes(group)
380
+ ? newExcludedRecords
381
+ : [...newExcludedRecords, group];
382
+ }
383
+ else {
384
+ newIncludedRecords = newIncludedRecords.includes(group)
385
+ ? newIncludedRecords.filter((item) => {
386
+ if (item.id !== group.id)
387
+ group.isSelected = false;
388
+ return item.id !== group.id;
389
+ })
390
+ : [...newIncludedRecords, group];
391
+ }
392
+ });
393
+ updateCheckboxData(newIncludedRecords, newExcludedRecords, gridData, featureDetails, setFeatureDetails);
394
+ const isEveryParentGroupInclude = parentGroupData === null || parentGroupData === void 0 ? void 0 : parentGroupData.every((parent) => newIncludedRecords.some((included) => (included === null || included === void 0 ? void 0 : included.id) === (parent === null || parent === void 0 ? void 0 : parent.id)));
395
+ const isParent = determineParentGroupState(parentGroupData, newIncludedRecords, newExcludedRecords, allBoxChecked);
396
+ handleGroupDeselection(params, setSelectedGroup, groupingColumns, isParent, isEveryParentGroupInclude);
397
+ };
398
+ exports.handleUncheckedState = handleUncheckedState;
399
+ // Utility function to update checkbox data in the state
400
+ const updateCheckboxData = (newIncludedRecords, newExcludedRecords, gridData, featureDetails, setFeatureDetails) => {
401
+ var _a, _b;
402
+ if ((newIncludedRecords === null || newIncludedRecords === void 0 ? void 0 : newIncludedRecords.length) === ((_a = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _a === void 0 ? void 0 : _a.length)) {
403
+ setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { excludedRecords: [], includedRecords: [], isIndeterminate: false, allBoxChecked: true }) }));
404
+ }
405
+ else if ((newExcludedRecords === null || newExcludedRecords === void 0 ? void 0 : newExcludedRecords.length) === ((_b = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _b === void 0 ? void 0 : _b.length)) {
406
+ setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: exports.initialCheckBoxData }));
407
+ }
408
+ else {
409
+ setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { excludedRecords: newExcludedRecords, includedRecords: newIncludedRecords, isIndeterminate: featureDetails.checkBoxSelection.allBoxChecked ? true : featureDetails.checkBoxSelection.isIndeterminate }) }));
410
+ }
411
+ };
412
+ // Utility function to determine parent group inclusion or exclusion states
413
+ const determineParentGroupState = (parentGroupData, newIncludedRecords, newExcludedRecords, allBoxChecked) => {
414
+ const isAnyParentGroupInclude = parentGroupData === null || parentGroupData === void 0 ? void 0 : parentGroupData.every((parent) => newIncludedRecords.some((included) => included.id === parent.id));
415
+ const isAnyParentGroupExcluded = parentGroupData === null || parentGroupData === void 0 ? void 0 : parentGroupData.some((parent) => newExcludedRecords.some((excluded) => excluded.id === parent.id));
416
+ return allBoxChecked ? isAnyParentGroupExcluded : isAnyParentGroupInclude;
417
+ };
418
+ // Utility function to handle group selection logic for checked state
419
+ const handleGroupSelection = (params, setSelectedGroup, groupingColumns, isParent) => {
420
+ var _a, _b, _c, _d, _e, _f, _g, _h;
421
+ if (groupingColumns === 2 && !((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.leafGroup) && ((_b = params === null || params === void 0 ? void 0 : params.node) === null || _b === void 0 ? void 0 : _b.level) === 0) {
422
+ (_d = (_c = params === null || params === void 0 ? void 0 : params.node) === null || _c === void 0 ? void 0 : _c.childrenAfterGroup) === null || _d === void 0 ? void 0 : _d.forEach((childNode) => {
423
+ setSelectedGroup((prev) => prev.includes(childNode.id) ? prev : [...prev, childNode.id]);
424
+ });
425
+ setSelectedGroup((prev) => prev.includes(params.node.id) ? prev : [...prev, params.node.id]);
426
+ }
427
+ else if (((_e = params === null || params === void 0 ? void 0 : params.node) === null || _e === void 0 ? void 0 : _e.leafGroup) && ((_f = params === null || params === void 0 ? void 0 : params.node) === null || _f === void 0 ? void 0 : _f.level) === 1 && isParent) {
428
+ setSelectedGroup((prev) => prev.includes(params.node.id) ? prev : [...prev, params.node.id]);
429
+ setSelectedGroup((prev) => {
430
+ var _a, _b, _c, _d;
431
+ return prev.includes((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id)
432
+ ? prev
433
+ : [...prev, (_d = (_c = params === null || params === void 0 ? void 0 : params.node) === null || _c === void 0 ? void 0 : _c.parent) === null || _d === void 0 ? void 0 : _d.id];
434
+ });
435
+ }
436
+ else if (((_g = params === null || params === void 0 ? void 0 : params.node) === null || _g === void 0 ? void 0 : _g.leafGroup) && ((_h = params === null || params === void 0 ? void 0 : params.node) === null || _h === void 0 ? void 0 : _h.level) === 1 && !isParent) {
437
+ setSelectedGroup((prev) => {
438
+ var _a, _b, _c, _d;
439
+ return prev.includes((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id)
440
+ ? prev
441
+ : [...prev, (_d = (_c = params === null || params === void 0 ? void 0 : params.node) === null || _c === void 0 ? void 0 : _c.parent) === null || _d === void 0 ? void 0 : _d.id];
442
+ });
443
+ setSelectedGroup((prev) => {
444
+ var _a, _b;
445
+ return prev.includes((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.id)
446
+ ? prev
447
+ : [...prev, (_b = params === null || params === void 0 ? void 0 : params.node) === null || _b === void 0 ? void 0 : _b.id];
448
+ });
449
+ }
450
+ else {
451
+ setSelectedGroup((prev) => { var _a; return prev.includes(params.node.id) ? prev : [...prev, (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.id]; });
452
+ }
453
+ };
454
+ // Utility function to handle group deselection logic for unchecked state
455
+ const handleGroupDeselection = (params, setSelectedGroup, groupingColumns, isParent, isEveryParentGroupInclude) => {
456
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
457
+ if (groupingColumns === 2 && !((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.leafGroup) && ((_b = params === null || params === void 0 ? void 0 : params.node) === null || _b === void 0 ? void 0 : _b.level) === 0) {
458
+ (_d = (_c = params === null || params === void 0 ? void 0 : params.node) === null || _c === void 0 ? void 0 : _c.childrenAfterGroup) === null || _d === void 0 ? void 0 : _d.forEach((childNode) => {
459
+ setSelectedGroup((prev) => prev === null || prev === void 0 ? void 0 : prev.filter((id) => id !== (childNode === null || childNode === void 0 ? void 0 : childNode.id)));
460
+ });
461
+ setSelectedGroup((prev) => prev === null || prev === void 0 ? void 0 : prev.filter((id) => { var _a; return id !== ((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.id); }));
462
+ }
463
+ else if (((_e = params === null || params === void 0 ? void 0 : params.node) === null || _e === void 0 ? void 0 : _e.leafGroup) &&
464
+ ((_f = params === null || params === void 0 ? void 0 : params.node) === null || _f === void 0 ? void 0 : _f.level) === 1 &&
465
+ !isEveryParentGroupInclude) {
466
+ // Handle cases where current node is a leaf group at level 1
467
+ setSelectedGroup((prev) => {
468
+ if (prev === null || prev === void 0 ? void 0 : prev.includes(params.node.id)) {
469
+ return prev === null || prev === void 0 ? void 0 : prev.filter((id) => { var _a; return id !== ((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.id); });
470
+ }
471
+ return prev;
472
+ });
473
+ setSelectedGroup((prev) => {
474
+ var _a, _b;
475
+ if (prev === null || prev === void 0 ? void 0 : prev.includes((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id)) {
476
+ return prev === null || prev === void 0 ? void 0 : prev.filter((id) => { var _a, _b; return id !== ((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id); });
477
+ }
478
+ return prev;
479
+ });
480
+ }
481
+ else if (((_g = params === null || params === void 0 ? void 0 : params.node) === null || _g === void 0 ? void 0 : _g.leafGroup) && ((_h = params === null || params === void 0 ? void 0 : params.node) === null || _h === void 0 ? void 0 : _h.level) === 1 && !isParent) {
482
+ setSelectedGroup((prev) => {
483
+ if (prev === null || prev === void 0 ? void 0 : prev.includes(params.node.id)) {
484
+ return prev === null || prev === void 0 ? void 0 : prev.filter((id) => { var _a; return id !== ((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.id); });
485
+ }
486
+ return prev;
487
+ });
488
+ setSelectedGroup((prev) => {
489
+ var _a, _b;
490
+ if (prev === null || prev === void 0 ? void 0 : prev.includes((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id)) {
491
+ return prev === null || prev === void 0 ? void 0 : prev.filter((id) => { var _a, _b; return id !== ((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id); });
492
+ }
493
+ return prev;
494
+ });
495
+ }
496
+ else if (((_j = params === null || params === void 0 ? void 0 : params.node) === null || _j === void 0 ? void 0 : _j.leafGroup) && ((_k = params === null || params === void 0 ? void 0 : params.node) === null || _k === void 0 ? void 0 : _k.level) === 1 && isParent) {
497
+ setSelectedGroup((prev) => {
498
+ var _a, _b;
499
+ if (prev.includes((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id)) {
500
+ return prev.filter((id) => { var _a, _b; return id !== ((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id); });
501
+ }
502
+ return prev;
503
+ });
504
+ }
505
+ else {
506
+ setSelectedGroup((prev) => prev.filter((id) => id !== params.node.id));
507
+ }
508
+ };
509
+ // ------------------------------------- group header checkbox -------------------------------------------
510
+ // iterating over eachnode and return first and second group ids
511
+ const getGroupIds = (gridRef) => {
512
+ var _a, _b;
513
+ const firstGroupIds = [];
514
+ const secondGroupIds = [];
515
+ (_b = (_a = gridRef === null || gridRef === void 0 ? void 0 : gridRef.current) === null || _a === void 0 ? void 0 : _a.api) === null || _b === void 0 ? void 0 : _b.forEachNode((node) => {
516
+ if (node === null || node === void 0 ? void 0 : node.group) {
517
+ if ((node === null || node === void 0 ? void 0 : node.level) === 0) {
518
+ // Store the ID of the first level group
519
+ firstGroupIds === null || firstGroupIds === void 0 ? void 0 : firstGroupIds.push(node === null || node === void 0 ? void 0 : node.id);
520
+ }
521
+ else if ((node === null || node === void 0 ? void 0 : node.level) === 1) {
522
+ // Store the ID of the second level group
523
+ secondGroupIds === null || secondGroupIds === void 0 ? void 0 : secondGroupIds.push(node === null || node === void 0 ? void 0 : node.id);
524
+ }
525
+ }
526
+ });
527
+ return { firstGroupIds, secondGroupIds };
528
+ };
529
+ exports.getGroupIds = getGroupIds;
530
+ const handleCheckboxClick = (e, params, featureDetails, gridData, setFeatureDetails, groupingColumns, setSelectedGroup) => {
531
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
532
+ const isChecked = e.checked;
533
+ const { data: rowData } = params;
534
+ // Update checkbox data and set the updated state
535
+ const updatedCheckBoxData = (0, exports.updateRecords)(rowData, featureDetails, gridData);
536
+ setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: updatedCheckBoxData }));
537
+ // Gather parent and super parent group data for condition checks
538
+ const parentGroupData = (_c = (_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.childrenAfterGroup) === null || _c === void 0 ? void 0 : _c.map((childNode) => childNode === null || childNode === void 0 ? void 0 : childNode.data);
539
+ const superParentData = (_g = (_f = (_e = (_d = params === null || params === void 0 ? void 0 : params.node) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.parent) === null || _f === void 0 ? void 0 : _f.allLeafChildren) === null || _g === void 0 ? void 0 : _g.map((children) => children === null || children === void 0 ? void 0 : children.data);
540
+ // Determine if all or any parent groups are included/excluded
541
+ const isEveryParentGroupInclude = parentGroupData === null || parentGroupData === void 0 ? void 0 : parentGroupData.every((parent) => { var _a; return (_a = updatedCheckBoxData === null || updatedCheckBoxData === void 0 ? void 0 : updatedCheckBoxData.includedRecords) === null || _a === void 0 ? void 0 : _a.some((included) => (included === null || included === void 0 ? void 0 : included.id) === (parent === null || parent === void 0 ? void 0 : parent.id)); });
542
+ const isEveryParentGroupExcluded = parentGroupData === null || parentGroupData === void 0 ? void 0 : parentGroupData.every((parent) => { var _a; return (_a = updatedCheckBoxData === null || updatedCheckBoxData === void 0 ? void 0 : updatedCheckBoxData.excludedRecords) === null || _a === void 0 ? void 0 : _a.some((excluded) => (excluded === null || excluded === void 0 ? void 0 : excluded.id) === (parent === null || parent === void 0 ? void 0 : parent.id)); });
543
+ const isEverySuperParentGroupExcluded = superParentData === null || superParentData === void 0 ? void 0 : superParentData.every((parent) => { var _a; return (_a = updatedCheckBoxData === null || updatedCheckBoxData === void 0 ? void 0 : updatedCheckBoxData.excludedRecords) === null || _a === void 0 ? void 0 : _a.some((excluded) => (excluded === null || excluded === void 0 ? void 0 : excluded.id) === (parent === null || parent === void 0 ? void 0 : parent.id)); });
544
+ // Determine the conditions to update group state
545
+ const conditions = (0, exports.determineConditions)(isChecked, updatedCheckBoxData.allBoxChecked, isEveryParentGroupInclude, isEveryParentGroupExcluded, isEverySuperParentGroupExcluded);
546
+ console.log("conditionsss", conditions);
547
+ // Update group state based on determined conditions
548
+ (0, exports.updateGroupState)(groupingColumns, (_j = (_h = params === null || params === void 0 ? void 0 : params.node) === null || _h === void 0 ? void 0 : _h.parent) === null || _j === void 0 ? void 0 : _j.id, (_m = (_l = (_k = params === null || params === void 0 ? void 0 : params.node) === null || _k === void 0 ? void 0 : _k.parent) === null || _l === void 0 ? void 0 : _l.parent) === null || _m === void 0 ? void 0 : _m.id, conditions, setSelectedGroup);
549
+ };
550
+ exports.handleCheckboxClick = handleCheckboxClick;
@@ -12,17 +12,19 @@ const error_ui_1 = tslib_1.__importDefault(require("./error-ui"));
12
12
  const loading_component_1 = tslib_1.__importDefault(require("./loading-component"));
13
13
  const context_provider_1 = tslib_1.__importDefault(require("./context-provider"));
14
14
  const group_checkbox_1 = tslib_1.__importDefault(require("./group-checkbox"));
15
+ const utilComponents_1 = require("./utilComponents");
15
16
  function ParentForGrid(props) {
16
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
17
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
17
18
  const [gridData, setGridData] = (0, react_1.useState)({
18
19
  rowData: [],
19
- columnData: (0, helper_1.sortColumns)(props === null || props === void 0 ? void 0 : props.columnData)
20
+ columnData: (0, helper_1.sortColumns)(props === null || props === void 0 ? void 0 : props.columnData),
20
21
  });
21
22
  let maxLength = 0;
22
23
  const [style] = (0, react_1.useState)(props.style);
23
24
  const [api, setApi] = (0, react_1.useState)(null);
24
25
  const [totalRecords, setTotalRecords] = (0, react_1.useState)(0);
25
26
  const [gridReadyEvent, setGridReadyEvent] = (0, react_1.useState)();
27
+ const [intialColumns, setIntialColumns] = (0, react_1.useState)(null);
26
28
  const [defaultFilters, setDefaultFilters] = (0, react_1.useState)((props === null || props === void 0 ? void 0 : props.defaultFilters) || []);
27
29
  const [selectedGroup, setSelectedGroup] = (0, react_1.useState)([]);
28
30
  const [emptyResponse] = (0, react_1.useState)({
@@ -62,6 +64,7 @@ function ParentForGrid(props) {
62
64
  });
63
65
  // const [columnToRender,setColumnToRender] = useState<ColumnDef[]>([])
64
66
  const gridRef = (0, react_1.useRef)(null);
67
+ const groupingColumns = (_b = (_a = gridData === null || gridData === void 0 ? void 0 : gridData.columnData) === null || _a === void 0 ? void 0 : _a.filter((colDef) => colDef === null || colDef === void 0 ? void 0 : colDef.rowGroup)) === null || _b === void 0 ? void 0 : _b.length;
65
68
  // Default column specification
66
69
  const defaultColDef = (0, react_1.useMemo)(() => {
67
70
  return {
@@ -72,88 +75,12 @@ function ParentForGrid(props) {
72
75
  sortable: false,
73
76
  };
74
77
  }, []);
75
- const handleCheckboxClick = (rowData) => {
76
- var _a;
77
- console.log("rowData handle click", rowData);
78
- const { excludedRecords, includedRecords, allBoxChecked } = featureDetails.checkBoxSelection;
79
- let isIndeterminate;
80
- let updatedIncludedRecords = includedRecords;
81
- // Helper function to update the checkbox selection state for a single record
82
- const updateCheckboxSelection = (data, excludedRecords) => {
83
- let updatedExcludedRecords = excludedRecords;
84
- // Handle the case where 'allBoxChecked' is true
85
- if (allBoxChecked) {
86
- if (excludedRecords.includes(data)) {
87
- // Remove from excludedRecords if already present
88
- updatedExcludedRecords = excludedRecords.filter((item) => item !== data);
89
- }
90
- else {
91
- // Add to excludedRecords if not present
92
- updatedExcludedRecords = [...excludedRecords, data];
93
- }
94
- // Set isIndeterminate to true if there are any excluded records
95
- isIndeterminate = updatedExcludedRecords.length > 0;
96
- return updatedExcludedRecords;
97
- }
98
- // Handle the case where 'allBoxChecked' is false
99
- if (includedRecords.includes(data)) {
100
- // Remove from includedRecords if already present
101
- updatedIncludedRecords = updatedIncludedRecords.filter((item) => item.id !== data.id);
102
- }
103
- else {
104
- // Add to includedRecords if not present
105
- updatedIncludedRecords = [...updatedIncludedRecords, data];
106
- }
107
- // Set isIndeterminate to true if not all records are included
108
- isIndeterminate =
109
- updatedIncludedRecords.length > 0 &&
110
- updatedIncludedRecords.length < totalRecordsCount;
111
- return updatedExcludedRecords;
112
- };
113
- // Assuming you have access to the total number of records
114
- const totalRecordsCount = (_a = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _a === void 0 ? void 0 : _a.length;
115
- // Check if rowData is an array or a single object
116
- let updatedExcludedRecords = excludedRecords;
117
- console.log("updated excluded records", updatedExcludedRecords, updatedIncludedRecords);
118
- if (Array.isArray(rowData)) {
119
- rowData.forEach((data) => {
120
- updatedExcludedRecords = updateCheckboxSelection(data, updatedExcludedRecords);
121
- });
122
- isIndeterminate = true;
123
- }
124
- else {
125
- updatedExcludedRecords = updateCheckboxSelection(rowData, updatedExcludedRecords);
126
- }
127
- // Update the state with the new excluded records
128
- const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { excludedRecords: updatedExcludedRecords, includedRecords: updatedIncludedRecords, isIndeterminate: isIndeterminate });
129
- setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: checkboxData }));
130
- };
131
- // iterating over eachnode and return first and second group ids
132
- const getGroupIds = () => {
133
- const firstGroupIds = [];
134
- const secondGroupIds = [];
135
- gridRef.current.api.forEachNode((node) => {
136
- if (node.group) {
137
- if (node.level === 0) {
138
- // Store the ID of the first level group
139
- firstGroupIds.push(node.id);
140
- }
141
- else if (node.level === 1) {
142
- // Store the ID of the second level group
143
- secondGroupIds.push(node.id);
144
- }
145
- }
146
- });
147
- return { firstGroupIds, secondGroupIds };
148
- };
78
+ // console.log("propsssssssss", props)
149
79
  // Function to handle header checkbox click event
150
80
  const handleHeaderCheckbox = (props) => {
151
81
  // get the group and subgroupids
152
- const { firstGroupIds, secondGroupIds } = getGroupIds();
153
- console.log("First Group IDs:", firstGroupIds, secondGroupIds);
154
- console.log("Second Group IDs:", secondGroupIds);
82
+ const { firstGroupIds, secondGroupIds } = (0, helper_1.getGroupIds)(gridRef);
155
83
  console.log("header props checkbox", props.node);
156
- console.log("record values in handle", gridRef.current.api);
157
84
  const { allBoxChecked } = featureDetails.checkBoxSelection;
158
85
  const currentStatus = !allBoxChecked;
159
86
  const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { allBoxChecked: currentStatus, isIndeterminate: false, includedRecords: [], excludedRecords: [], headerCheckBoxStatus: currentStatus
@@ -185,13 +112,7 @@ function ParentForGrid(props) {
185
112
  const { data } = params;
186
113
  // const { allBoxChecked, excludedRecords, includedRecords } = featureDetails.checkBoxSelection;
187
114
  const isChecked = (0, helper_1.getCheckedStatus)(data, featureDetails, constants_1.GRID_CHECKBOX_STATUS, setFeatureDetails);
188
- return ((0, jsx_runtime_1.jsx)(grid_checkbox_1.default, { checked: isChecked, onChange: () => handleCheckboxClick(data), isIndeterminate: false, shouldRenderOnRight: (_a = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _a === void 0 ? void 0 : _a.displayCheckboxOnRight }));
189
- };
190
- // Render checkbox as well as initial component/data from props
191
- const dataCellRenderer = (cellRendererParams, column) => {
192
- var _a, _b, _c;
193
- const { initialRenderer, cellCheckBoxRenderer } = cellRendererParams;
194
- return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex w-full" }, { children: ((_a = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _a === void 0 ? void 0 : _a.displayCheckboxOnRight) ? ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "custom_class_name flex w-full justify-content-between" }, { children: [typeof initialRenderer === "function" ? (initialRenderer(cellRendererParams)) : ((0, jsx_runtime_1.jsx)("div", { children: (_b = cellRendererParams === null || cellRendererParams === void 0 ? void 0 : cellRendererParams.data) === null || _b === void 0 ? void 0 : _b[column === null || column === void 0 ? void 0 : column.field] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex align-items-center" }, { children: cellCheckBoxRenderer(cellRendererParams) }))] }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex align-items-center " }, { children: cellCheckBoxRenderer(cellRendererParams) })), typeof initialRenderer === "function" ? (initialRenderer(cellRendererParams)) : ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "px-3" }, { children: (_c = cellRendererParams === null || cellRendererParams === void 0 ? void 0 : cellRendererParams.data) === null || _c === void 0 ? void 0 : _c[column === null || column === void 0 ? void 0 : column.field] })))] })) })));
115
+ return ((0, jsx_runtime_1.jsx)(grid_checkbox_1.default, { checked: isChecked, onChange: (e) => (0, helper_1.handleCheckboxClick)(e, params, featureDetails, gridData, setFeatureDetails, groupingColumns, setSelectedGroup), isIndeterminate: false, shouldRenderOnRight: (_a = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _a === void 0 ? void 0 : _a.displayCheckboxOnRight }));
195
116
  };
196
117
  // Callback to products for getting data
197
118
  const getData = (startRow, endRow, currentFeatures, params) => tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -242,7 +163,7 @@ function ParentForGrid(props) {
242
163
  else if (props.rowModelType === constants_1.ROWMODELTYPE.SERVER_SIDE) {
243
164
  const dataSource = {
244
165
  getRows: (params) => tslib_1.__awaiter(this, void 0, void 0, function* () {
245
- var _k, _l;
166
+ var _m, _o;
246
167
  const startRow = params.request.startRow;
247
168
  const endRow = params.request.endRow;
248
169
  // Scroll should not exit MAX_RECORDS_TO_LOAD
@@ -258,7 +179,7 @@ function ParentForGrid(props) {
258
179
  // get data for request from our fake server
259
180
  const response = yield getData(startRow, endRow, currentFeatures, params);
260
181
  // simulating real server call with a 500ms delay
261
- if (((_k = response.rowData) === null || _k === void 0 ? void 0 : _k.length) > 0) {
182
+ if (((_m = response.rowData) === null || _m === void 0 ? void 0 : _m.length) > 0) {
262
183
  setGridData(Object.assign(Object.assign({}, gridData), { rowData: response.rowData }));
263
184
  gridRef.current.api.hideOverlay();
264
185
  // supply rows for requested block to grid
@@ -268,7 +189,7 @@ function ParentForGrid(props) {
268
189
  else {
269
190
  // params.fail();
270
191
  const gridRows = startRow >= constants_1.BLOCK_SIZE ? gridData.rowData : [];
271
- if (!((_l = params === null || params === void 0 ? void 0 : params.parentNode) === null || _l === void 0 ? void 0 : _l.id))
192
+ if (!((_o = params === null || params === void 0 ? void 0 : params.parentNode) === null || _o === void 0 ? void 0 : _o.id))
272
193
  gridRef.current.api.showNoRowsOverlay();
273
194
  params.success({ rowData: gridRows });
274
195
  return;
@@ -293,19 +214,6 @@ function ParentForGrid(props) {
293
214
  const getDataPath = (0, react_1.useCallback)((data) => {
294
215
  return data.orgHierarchy;
295
216
  }, []);
296
- //Get this compnent from products
297
- const GroupHeader = (params) => {
298
- console.log(params, "params in custom component of group products");
299
- return (0, jsx_runtime_1.jsx)("p", { children: "My Custom Group" });
300
- };
301
- // useEffect(() => {
302
- // // Check if all columns in columnData have rowGroup set to false
303
- // const allFalse = gridData?.columnData?.every(column => !column?.rowGroup);
304
- // // If all are false, set selectedGroup to an empty array
305
- // if (allFalse) {
306
- // setSelectedGroup([]);
307
- // }
308
- // }, [gridData?.columnData]);
309
217
  // Render group child conditionally with/without checkbox
310
218
  const manageColumnGrouping = () => {
311
219
  var _a;
@@ -313,117 +221,24 @@ function ParentForGrid(props) {
313
221
  const GroupHeaderRenderer = (params) => {
314
222
  var _a, _b, _c, _d, _e;
315
223
  const Wrapper = () => {
316
- return (0, jsx_runtime_1.jsx)(GroupHeader, { params: params });
317
- };
318
- // Logic to add and remove the row index from state
319
- const addIndexToSelectedGroup = (params) => {
320
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
321
- const { allBoxChecked } = featureDetails.checkBoxSelection;
322
- console.log("all box checked", allBoxChecked);
323
- let currentIds = selectedGroup || [];
324
- const groupData = (_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.allLeafChildren) === null || _b === void 0 ? void 0 : _b.map((childNode) => childNode === null || childNode === void 0 ? void 0 : childNode.data);
325
- console.log("data to bind for selected group", params, groupData);
326
- console.log("group data render child", groupData);
327
- let updatedIncludedRecords = [
328
- ...(_c = featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection) === null || _c === void 0 ? void 0 : _c.includedRecords,
329
- ];
330
- // Check if the current group is already selected
331
- if (currentIds.includes((_d = params === null || params === void 0 ? void 0 : params.node) === null || _d === void 0 ? void 0 : _d.id)) {
332
- // Remove the group ID and its data from includedRecords
333
- currentIds = currentIds.filter((item) => { var _a; return item !== ((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.id); });
334
- updatedIncludedRecords = updatedIncludedRecords.filter((record) => !groupData.includes(record));
335
- }
336
- else {
337
- // Add the group ID and its data to includedRecords
338
- currentIds.push((_e = params === null || params === void 0 ? void 0 : params.node) === null || _e === void 0 ? void 0 : _e.id);
339
- updatedIncludedRecords.push(...groupData);
340
- }
341
- // Iterate over all child groups (if any) to update their selection state
342
- (_g = (_f = params === null || params === void 0 ? void 0 : params.node) === null || _f === void 0 ? void 0 : _f.childrenAfterGroup) === null || _g === void 0 ? void 0 : _g.forEach((childGroup) => {
343
- var _a, _b, _c, _d;
344
- const childGroupData = (_b = (_a = childGroup === null || childGroup === void 0 ? void 0 : childGroup.parent) === null || _a === void 0 ? void 0 : _a.allLeafChildren) === null || _b === void 0 ? void 0 : _b.map((child) => child === null || child === void 0 ? void 0 : child.data);
345
- if (currentIds.includes(childGroup === null || childGroup === void 0 ? void 0 : childGroup.id)) {
346
- // Remove the childGroup ID if it exists and update includedRecords
347
- currentIds = currentIds.filter((child) => child !== (childGroup === null || childGroup === void 0 ? void 0 : childGroup.id));
348
- updatedIncludedRecords = updatedIncludedRecords.filter((record) => !childGroupData.includes(record));
349
- }
350
- else {
351
- // Add the childGroup ID if it doesn't exist
352
- if (!currentIds.includes(childGroup === null || childGroup === void 0 ? void 0 : childGroup.id)) {
353
- currentIds.push(childGroup === null || childGroup === void 0 ? void 0 : childGroup.id);
354
- }
355
- // Check if each child's data is already included before adding it
356
- const newChildren = (_d = (_c = childGroup === null || childGroup === void 0 ? void 0 : childGroup.parent) === null || _c === void 0 ? void 0 : _c.allLeafChildren) === null || _d === void 0 ? void 0 : _d.filter((child) => !updatedIncludedRecords.some((record) => record.id === (child === null || child === void 0 ? void 0 : child.data.id)));
357
- updatedIncludedRecords.push(...newChildren.map((child) => child === null || child === void 0 ? void 0 : child.data));
358
- }
359
- });
360
- // After processing, ensure the parent group is selected if any of its subgroups are selected
361
- const isAnySubgroupSelected = (_j = (_h = params === null || params === void 0 ? void 0 : params.node) === null || _h === void 0 ? void 0 : _h.childrenAfterGroup) === null || _j === void 0 ? void 0 : _j.some((childGroup) => currentIds.includes(childGroup === null || childGroup === void 0 ? void 0 : childGroup.id));
362
- if (isAnySubgroupSelected && !currentIds.includes((_k = params === null || params === void 0 ? void 0 : params.node) === null || _k === void 0 ? void 0 : _k.id)) {
363
- currentIds.push((_l = params === null || params === void 0 ? void 0 : params.node) === null || _l === void 0 ? void 0 : _l.id);
364
- updatedIncludedRecords.push(...groupData);
365
- }
366
- console.log(currentIds, "current id on selecting group");
367
- console.log("params in addIndex", params);
368
- // Update the state with the modified array
369
- setSelectedGroup(currentIds);
370
- // Update the includedRecords in featureDetails
371
- setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { includedRecords: updatedIncludedRecords }) }));
372
- };
373
- // Update parent checkbox state based on child selection
374
- const updateParentCheckboxState = (params) => {
375
- var _a, _b, _c, _d, _e, _f;
376
- const groupData = (_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.allLeafChildren) === null || _b === void 0 ? void 0 : _b.map((childNode) => childNode === null || childNode === void 0 ? void 0 : childNode.data);
377
- const allChildrenSelected = (_d = (_c = params === null || params === void 0 ? void 0 : params.node) === null || _c === void 0 ? void 0 : _c.allLeafChildren) === null || _d === void 0 ? void 0 : _d.every((childNode) => {
378
- return selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.includes(childNode.id);
379
- });
380
- const parentNodeId = (_f = (_e = params === null || params === void 0 ? void 0 : params.node) === null || _e === void 0 ? void 0 : _e.parent) === null || _f === void 0 ? void 0 : _f.id;
381
- if (allChildrenSelected) {
382
- setSelectedGroup((prev) => [...prev, parentNodeId]);
383
- }
384
- else {
385
- handleCheckboxClick(groupData);
386
- setSelectedGroup((prev) => prev === null || prev === void 0 ? void 0 : prev.filter((id) => id !== parentNodeId));
387
- }
224
+ return (0, jsx_runtime_1.jsx)(utilComponents_1.GroupHeader, { params: params });
388
225
  };
226
+ // Main onChange handler function for group checkbox
389
227
  const onChange = (e, params) => {
390
- var _a, _b, _c, _d;
391
- console.log(params, "params of group check");
392
228
  const isChecked = e.checked;
393
- console.log("selected group row iddddd", selectedGroup, params.node.id);
394
- const groupData = (_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.allLeafChildren) === null || _b === void 0 ? void 0 : _b.map((childNode) => childNode === null || childNode === void 0 ? void 0 : childNode.data);
395
- console.log("group data render child", groupData);
396
229
  if (isChecked) {
397
- addIndexToSelectedGroup(params);
230
+ (0, helper_1.handleCheckedState)(params, featureDetails, gridData, setFeatureDetails, setSelectedGroup, groupingColumns);
398
231
  }
399
232
  else {
400
- // Remove group data from includedRecords when checkbox is unchecked
401
- handleCheckboxClick(groupData);
402
- setSelectedGroup((prev) => prev === null || prev === void 0 ? void 0 : prev.filter((id) => { var _a; return id !== ((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.id); }));
403
- (_d = (_c = params === null || params === void 0 ? void 0 : params.node) === null || _c === void 0 ? void 0 : _c.childrenAfterGroup) === null || _d === void 0 ? void 0 : _d.forEach((childNode) => {
404
- setSelectedGroup((prev) => prev === null || prev === void 0 ? void 0 : prev.filter((id) => id !== (childNode === null || childNode === void 0 ? void 0 : childNode.id)));
405
- });
406
- // setFeatureDetails((prevDetails) => ({
407
- // ...prevDetails,
408
- // checkBoxSelection: {
409
- // ...prevDetails.checkBoxSelection,
410
- // includedRecords:
411
- // prevDetails.checkBoxSelection.includedRecords.filter(
412
- // (record) => !groupData.includes(record)
413
- // ),
414
- // },
415
- // }));
233
+ (0, helper_1.handleUncheckedState)(params, featureDetails, gridData, setFeatureDetails, setSelectedGroup, groupingColumns);
416
234
  }
417
- // Update parent state after any change
418
- updateParentCheckboxState(params);
419
235
  };
420
- console.log("dataaa", params.node);
421
236
  // To display checkbox
422
237
  if ((_a = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _a === void 0 ? void 0 : _a.displayCheckboxForGroups) {
423
238
  // To display checkbox on right
424
239
  return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center justify-content-between" }, { children: [(0, jsx_runtime_1.jsx)(group_checkbox_1.default, { checked: (selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.includes((_b = params === null || params === void 0 ? void 0 : params.node) === null || _b === void 0 ? void 0 : _b.id)) ||
425
240
  (((_c = featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection) === null || _c === void 0 ? void 0 : _c.allBoxChecked) &&
426
- !((_d = featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection) === null || _d === void 0 ? void 0 : _d.isIndeterminate)), onChange: (e) => onChange(e, params), isIndeterminate: false, shouldRenderOnRight: false }), (0, jsx_runtime_1.jsx)("span", { children: (_e = params === null || params === void 0 ? void 0 : params.node) === null || _e === void 0 ? void 0 : _e.key })] })));
241
+ !((_d = featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection) === null || _d === void 0 ? void 0 : _d.isIndeterminate)), onChange: (e) => onChange(e, params), isIndeterminate: false, shouldRenderOnRight: false }), (0, jsx_runtime_1.jsx)("span", { children: (_e = params === null || params === void 0 ? void 0 : params.node) === null || _e === void 0 ? void 0 : _e.id })] })));
427
242
  }
428
243
  return (0, jsx_runtime_1.jsx)(Wrapper, {});
429
244
  };
@@ -463,10 +278,10 @@ function ParentForGrid(props) {
463
278
  };
464
279
  // Options that grid should have
465
280
  const gridOptions = {
466
- columnDefs: (_a = gridData === null || gridData === void 0 ? void 0 : gridData.columnData) === null || _a === void 0 ? void 0 : _a.map((column) => {
281
+ columnDefs: (_c = gridData === null || gridData === void 0 ? void 0 : gridData.columnData) === null || _c === void 0 ? void 0 : _c.map((column) => {
467
282
  var _a, _b;
468
- if (column.enableChildCheckbox && column.enableHeaderCheckbox) {
469
- return Object.assign(Object.assign({}, column), { headerComponent: (params) => headerCheckBoxRenderer(params === null || params === void 0 ? void 0 : params.displayName, column === null || column === void 0 ? void 0 : column.headerComponent), cellRenderer: (params) => dataCellRenderer(params, column), cellRendererParams: {
283
+ if ((column === null || column === void 0 ? void 0 : column.enableChildCheckbox) && (column === null || column === void 0 ? void 0 : column.enableHeaderCheckbox)) {
284
+ return Object.assign(Object.assign({}, column), { headerComponent: (params) => headerCheckBoxRenderer(params === null || params === void 0 ? void 0 : params.displayName, (column === null || column === void 0 ? void 0 : column.headerComponent) && ""), cellRenderer: (params) => (0, utilComponents_1.dataCellRenderer)(params, column, props), cellRendererParams: {
470
285
  initialRenderer: column === null || column === void 0 ? void 0 : column.body,
471
286
  cellCheckBoxRenderer: cellCheckBoxRenderer,
472
287
  }, headerName: (_a = column === null || column === void 0 ? void 0 : column.headerName) === null || _a === void 0 ? void 0 : _a.toUpperCase() });
@@ -494,8 +309,8 @@ function ParentForGrid(props) {
494
309
  suppressCellFocus: true,
495
310
  suppressPropertyNamesCheck: true,
496
311
  suppressServerSideFullWidthLoadingRow: true,
497
- enableRangeSelection: (_b = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _b === void 0 ? void 0 : _b.enableFillHandle,
498
- enableFillHandle: (_c = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _c === void 0 ? void 0 : _c.enableFillHandle,
312
+ enableRangeSelection: (_d = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _d === void 0 ? void 0 : _d.enableFillHandle,
313
+ enableFillHandle: (_e = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _e === void 0 ? void 0 : _e.enableFillHandle,
499
314
  onFillEnd: wrapperToFillOpertation,
500
315
  fillOperation: myOpertaion,
501
316
  getRowId: getRowId,
@@ -567,11 +382,11 @@ function ParentForGrid(props) {
567
382
  initialFeature,
568
383
  defaultFilters,
569
384
  createView: props === null || props === void 0 ? void 0 : props.createView,
570
- enableViewCreate: (_d = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _d === void 0 ? void 0 : _d.enableViewCreate,
571
- filterModelText: (_e = props === null || props === void 0 ? void 0 : props.dynamicText) === null || _e === void 0 ? void 0 : _e.filterModelText,
572
- sortModelText: (_f = props === null || props === void 0 ? void 0 : props.dynamicText) === null || _f === void 0 ? void 0 : _f.sortModelText,
573
- recordDetailModelText: (_g = props === null || props === void 0 ? void 0 : props.dynamicText) === null || _g === void 0 ? void 0 : _g.recordDetailModelText,
574
- sidePanelText: (_h = props === null || props === void 0 ? void 0 : props.dynamicText) === null || _h === void 0 ? void 0 : _h.sidePanelText,
385
+ enableViewCreate: (_f = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _f === void 0 ? void 0 : _f.enableViewCreate,
386
+ filterModelText: (_g = props === null || props === void 0 ? void 0 : props.dynamicText) === null || _g === void 0 ? void 0 : _g.filterModelText,
387
+ sortModelText: (_h = props === null || props === void 0 ? void 0 : props.dynamicText) === null || _h === void 0 ? void 0 : _h.sortModelText,
388
+ recordDetailModelText: (_j = props === null || props === void 0 ? void 0 : props.dynamicText) === null || _j === void 0 ? void 0 : _j.recordDetailModelText,
389
+ sidePanelText: (_k = props === null || props === void 0 ? void 0 : props.dynamicText) === null || _k === void 0 ? void 0 : _k.sidePanelText,
575
390
  sortOptions: (props === null || props === void 0 ? void 0 : props.sortOptions)
576
391
  ? props.sortOptions
577
392
  : constants_1.COLUMN_SORT_OPTIONS,
@@ -584,7 +399,9 @@ function ParentForGrid(props) {
584
399
  columnToRender: gridData.columnData,
585
400
  selectedGroup: selectedGroup,
586
401
  setSelectedGroup: setSelectedGroup,
587
- initialCheckBoxData: initialCheckBoxData
588
- } }, { children: ((_j = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _j === void 0 ? void 0 : _j.displayFeaturesHeader) && ((0, jsx_runtime_1.jsx)(advanced_feature_1.default, { props: props })) })), (0, jsx_runtime_1.jsx)(AgGrid_1.default, { style: style, gridOptions: gridOptions, onGridReady: onGridReady, gridRef: gridRef })] }) })) }) }));
402
+ initialCheckBoxData: initialCheckBoxData,
403
+ intialColumns,
404
+ setIntialColumns
405
+ } }, { children: ((_l = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _l === void 0 ? void 0 : _l.displayFeaturesHeader) && ((0, jsx_runtime_1.jsx)(advanced_feature_1.default, { props: props })) })), (0, jsx_runtime_1.jsx)(AgGrid_1.default, { style: style, gridOptions: gridOptions, onGridReady: onGridReady, gridRef: gridRef })] }) })) }) }));
589
406
  }
590
407
  exports.default = ParentForGrid;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GroupHeader = exports.dataCellRenderer = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ // import Checkbox from "./grid-checkbox";
6
+ // Render checkbox as well as initial component/data from props
7
+ const dataCellRenderer = (cellRendererParams, column, props) => {
8
+ var _a, _b, _c;
9
+ const { initialRenderer, cellCheckBoxRenderer } = cellRendererParams;
10
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex w-full" }, { children: ((_a = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _a === void 0 ? void 0 : _a.displayCheckboxOnRight) ? ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "custom_class_name flex w-full justify-content-between" }, { children: [typeof initialRenderer === "function" ? (initialRenderer(cellRendererParams)) : ((0, jsx_runtime_1.jsx)("div", { children: (_b = cellRendererParams === null || cellRendererParams === void 0 ? void 0 : cellRendererParams.data) === null || _b === void 0 ? void 0 : _b[column === null || column === void 0 ? void 0 : column.field] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex align-items-center" }, { children: cellCheckBoxRenderer(cellRendererParams) }))] }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex align-items-center " }, { children: cellCheckBoxRenderer(cellRendererParams) })), typeof initialRenderer === "function" ? (initialRenderer(cellRendererParams)) : ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "px-3" }, { children: (_c = cellRendererParams === null || cellRendererParams === void 0 ? void 0 : cellRendererParams.data) === null || _c === void 0 ? void 0 : _c[column === null || column === void 0 ? void 0 : column.field] })))] })) })));
11
+ };
12
+ exports.dataCellRenderer = dataCellRenderer;
13
+ //Get this compnent from products
14
+ const GroupHeader = (params) => {
15
+ console.log(params, "params in custom component of group products");
16
+ return (0, jsx_runtime_1.jsx)("p", { children: "My Custom Group" });
17
+ };
18
+ exports.GroupHeader = GroupHeader;
@@ -27,6 +27,8 @@ interface MyProviderProps {
27
27
  setSelectedGroup: (group: string[]) => void;
28
28
  selectedGroup: string[];
29
29
  initialCheckBoxData: CheckBoxSelection;
30
+ intialColumns: ColumnDef[];
31
+ setIntialColumns: React.Dispatch<React.SetStateAction<any>>;
30
32
  };
31
33
  }
32
34
  declare function MyProvider({ children, value }: MyProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  interface CheckboxProps {
3
3
  checked: boolean;
4
- onChange: () => void;
4
+ onChange: (e: any) => void;
5
5
  isIndeterminate: boolean;
6
6
  shouldRenderOnRight: boolean;
7
7
  }
@@ -1,4 +1,6 @@
1
1
  import React from "react";
2
+ import { CheckBoxSelection } from "./Types";
3
+ export declare const initialCheckBoxData: CheckBoxSelection;
2
4
  export declare const applyDefaultFilters: (defaultFilters: any) => any;
3
5
  export declare const parseIfNeeded: (value: any) => any;
4
6
  export declare const sortColumns: (columns: any) => any;
@@ -34,3 +36,18 @@ export declare const autoGroupColumnDef: (isTreeEnable: boolean, headerName: str
34
36
  headerName?: undefined;
35
37
  minWidth?: undefined;
36
38
  };
39
+ export declare const updateRecords: (rowData: any, featureDetails: any, gridData: any) => any;
40
+ export declare const determineConditions: (isChecked: any, allBoxChecked: any, isEveryParentGroupInclude: any, isEveryParentGroupExcluded: any, isEverySuperParentGroupExcluded: any) => {
41
+ addParent: any;
42
+ addSuperParent: any;
43
+ removeParent: boolean;
44
+ removeSuperParent: boolean;
45
+ };
46
+ export declare const updateGroupState: (groupingColumns: any, parentId: any, superParentId: any, conditions: any, setSelectedGroup: any) => void;
47
+ export declare const handleCheckedState: (params: any, featureDetails: any, gridData: any, setFeatureDetails: any, setSelectedGroup: any, groupingColumns: any) => void;
48
+ export declare const handleUncheckedState: (params: any, featureDetails: any, gridData: any, setFeatureDetails: any, setSelectedGroup: any, groupingColumns: any) => void;
49
+ export declare const getGroupIds: (gridRef: any) => {
50
+ firstGroupIds: string[];
51
+ secondGroupIds: string[];
52
+ };
53
+ export declare const handleCheckboxClick: (e: any, params: any, featureDetails: any, gridData: any, setFeatureDetails: any, groupingColumns: any, setSelectedGroup: any) => void;
@@ -0,0 +1,2 @@
1
+ export declare const dataCellRenderer: (cellRendererParams: any, column: any, props: any) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const GroupHeader: (params: any) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sccoreui",
3
- "version": "6.1.87",
3
+ "version": "6.1.89",
4
4
  "description": "ui-sccore",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",