sccoreui 6.4.98 → 6.4.99

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.
@@ -159,7 +159,7 @@ function ParentForGrid(props) {
159
159
  setIsDataLoading(true);
160
160
  try {
161
161
  const response = yield (props === null || props === void 0 ? void 0 : props.getRowData(startRow, endRow, currentFeatures, params));
162
- setGridData(Object.assign(Object.assign({}, gridData), { rowData: [] }));
162
+ setGridData(prev => (Object.assign(Object.assign({}, prev), { rowData: [] })));
163
163
  // To identify when to stop the callBack
164
164
  const actualEndRow = (response === null || response === void 0 ? void 0 : response.totalRecords) < constants_1.MAX_RECORDS_TO_LOAD
165
165
  ? response === null || response === void 0 ? void 0 : response.totalRecords
@@ -199,7 +199,7 @@ function ParentForGrid(props) {
199
199
  const result = gridViewData.rowData.length > 0 ? { rowData: gridViewData.rowData, totalRecords: gridViewData.rowData.length } : yield getData(0, 0, currentFeatures);
200
200
  if (((_m = result.rowData) === null || _m === void 0 ? void 0 : _m.length) > 0) {
201
201
  gridViewData.rowData.length > 0 && setGridViewData({ rowData: [], searchText: "" });
202
- setGridData(Object.assign(Object.assign({}, gridData), { rowData: result.rowData }));
202
+ setGridData(prev => (Object.assign(Object.assign({}, prev), { rowData: result.rowData })));
203
203
  gridRef.current && gridRef.current.api.hideOverlay();
204
204
  params && ((_o = params === null || params === void 0 ? void 0 : params.api) === null || _o === void 0 ? void 0 : _o.applyTransaction({ add: result.rowData }));
205
205
  }
@@ -219,7 +219,7 @@ function ParentForGrid(props) {
219
219
  const response = yield getData(startRow, endRow, currentFeatures, params);
220
220
  // simulating real server call with a 500ms delay
221
221
  if (((_q = response.rowData) === null || _q === void 0 ? void 0 : _q.length) > 0) {
222
- setGridData(Object.assign(Object.assign({}, gridData), { rowData: response.rowData }));
222
+ setGridData(prev => (Object.assign(Object.assign({}, prev), { rowData: response.rowData })));
223
223
  gridRef.current.api.hideOverlay();
224
224
  // supply rows for requested block to grid
225
225
  params && params.success({ rowData: response.rowData, rowCount: response.actualEndRow });
@@ -335,7 +335,7 @@ function ParentForGrid(props) {
335
335
  }
336
336
  if (props === null || props === void 0 ? void 0 : props.rowData) {
337
337
  setTotalRecords(props === null || props === void 0 ? void 0 : props.rowData.length);
338
- setGridData(Object.assign(Object.assign({}, gridData), { rowData: props.rowData }));
338
+ setGridData(prev => (Object.assign(Object.assign({}, prev), { rowData: props.rowData })));
339
339
  }
340
340
  if (props === null || props === void 0 ? void 0 : props.enableAdvancedFilter) {
341
341
  (_b = (_a = props === null || props === void 0 ? void 0 : props.getGridRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.api.setGridOption("advancedFilterParent", document.getElementById("advancedFilterParent"));
@@ -440,22 +440,47 @@ function ParentForGrid(props) {
440
440
  }
441
441
  }, [props.updateRowData]);
442
442
  (0, react_1.useEffect)(() => {
443
- var _a, _b;
443
+ var _a, _b, _c;
444
444
  const existingColumns = (gridRef === null || gridRef === void 0 ? void 0 : gridRef.current) && ((_a = gridRef === null || gridRef === void 0 ? void 0 : gridRef.current.api) === null || _a === void 0 ? void 0 : _a.getColumnDefs());
445
445
  if (!(props === null || props === void 0 ? void 0 : props.columnData) || !existingColumns)
446
446
  return;
447
447
  const columnFromProps = (0, helper_1.sortColumns)(props === null || props === void 0 ? void 0 : props.columnData);
448
- const updatedColumnDefs = existingColumns.map((colDef) => {
449
- columnFromProps.find((col) => {
450
- if (col.id === colDef.id) {
451
- colDef.hide = col.hide;
452
- colDef.seq = col === null || col === void 0 ? void 0 : col.seq;
448
+ // Check if column IDs match — if not, this is a full column replacement (e.g. skeleton → real columns)
449
+ const existingIds = new Set(existingColumns.map((col) => col.id));
450
+ const propsIds = new Set(columnFromProps.map((col) => col.id));
451
+ const isStructuralChange = columnFromProps.some((col) => !existingIds.has(col.id)) ||
452
+ existingColumns.some((col) => !propsIds.has(col.id));
453
+ if (isStructuralChange) {
454
+ // Full column replacement — rebuild columnDefs with checkbox/header handling
455
+ const newColumnDefs = columnFromProps.map((column) => {
456
+ var _a, _b;
457
+ if ((column === null || column === void 0 ? void 0 : column.enableChildCheckbox) && (column === null || column === void 0 ? void 0 : column.enableHeaderCheckbox)) {
458
+ 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: {
459
+ initialRenderer: column === null || column === void 0 ? void 0 : column.body,
460
+ cellCheckBoxRenderer: cellCheckBoxRenderer,
461
+ }, headerName: (_a = column === null || column === void 0 ? void 0 : column.headerName) === null || _a === void 0 ? void 0 : _a.toUpperCase() });
462
+ }
463
+ else {
464
+ return Object.assign(Object.assign({}, column), { headerName: (_b = column === null || column === void 0 ? void 0 : column.headerName) === null || _b === void 0 ? void 0 : _b.toUpperCase() });
453
465
  }
454
466
  });
455
- return colDef;
456
- });
457
- const reOrderedColumns = updatedColumnDefs.sort((a, b) => a.seq - b.seq);
458
- (_b = gridRef.current.api) === null || _b === void 0 ? void 0 : _b.setGridOption("columnDefs", reOrderedColumns);
467
+ setGridData((prev) => (Object.assign(Object.assign({}, prev), { columnData: columnFromProps })));
468
+ (_b = gridRef.current.api) === null || _b === void 0 ? void 0 : _b.setGridOption("columnDefs", newColumnDefs);
469
+ }
470
+ else {
471
+ // Same structure — just update hide/seq
472
+ const updatedColumnDefs = existingColumns.map((colDef) => {
473
+ columnFromProps.find((col) => {
474
+ if (col.id === colDef.id) {
475
+ colDef.hide = col.hide;
476
+ colDef.seq = col === null || col === void 0 ? void 0 : col.seq;
477
+ }
478
+ });
479
+ return colDef;
480
+ });
481
+ const reOrderedColumns = updatedColumnDefs.sort((a, b) => a.seq - b.seq);
482
+ (_c = gridRef.current.api) === null || _c === void 0 ? void 0 : _c.setGridOption("columnDefs", reOrderedColumns);
483
+ }
459
484
  }, [props === null || props === void 0 ? void 0 : props.columnData]);
460
485
  (0, react_1.useEffect)(() => {
461
486
  if (props === null || props === void 0 ? void 0 : props.emptyCheckboxStatus) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sccoreui",
3
- "version": "6.4.98",
3
+ "version": "6.4.99",
4
4
  "description": "ui-sccore",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",