sccoreui 6.4.83 → 6.4.84

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.
package/dist/App.js CHANGED
@@ -2,9 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
4
  require("./App.scss");
5
- // import FroalaTextEditor from "./components/froala-editor/FroalaEditor";
6
5
  // import Home from "./pages/home";
7
6
  const App = () => {
8
- return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "m-6" }, { children: " " })));
7
+ return ((0, jsx_runtime_1.jsx)("div", { className: "m-6" }));
9
8
  };
10
9
  exports.default = App;
@@ -231,6 +231,9 @@ const autoGroupColumnDef = (isTreeEnable, headerName, groupField, GroupHeaderCom
231
231
  }
232
232
  };
233
233
  exports.autoGroupColumnDef = autoGroupColumnDef;
234
+ const removeDuplicates = (array) => {
235
+ return [...new Map(array.map(item => [item.id, item])).values()];
236
+ };
234
237
  // function to update the records based on checkbox state
235
238
  // This function determines how to update `includedRecords` and `excludedRecords`
236
239
  // depending on whether all checkboxes are checked or not (`allBoxChecked` state)
@@ -242,7 +245,28 @@ const updateRecords = (rowData, featureDetails, gridData) => {
242
245
  // When all checkboxes are checked
243
246
  if (allBoxChecked) {
244
247
  // Update excluded records: add or remove the current rowData
245
- newExcludedRecords = (excludedRecords === null || excludedRecords === void 0 ? void 0 : excludedRecords.includes(rowData))
248
+ if (excludedRecords === null || excludedRecords === void 0 ? void 0 : excludedRecords.some((row) => row.id === rowData.id)) {
249
+ newExcludedRecords = 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));
250
+ newIncludedRecords = removeDuplicates([...includedRecords, rowData]);
251
+ rowData.isSelected = !rowData.isSelected;
252
+ }
253
+ else if (includedRecords === null || includedRecords === void 0 ? void 0 : includedRecords.some((row) => row.id === rowData.id)) {
254
+ newIncludedRecords = includedRecords === null || includedRecords === void 0 ? void 0 : includedRecords.filter((item) => {
255
+ if ((item === null || item === void 0 ? void 0 : item.id) !== (rowData === null || rowData === void 0 ? void 0 : rowData.id)) {
256
+ return true;
257
+ }
258
+ else {
259
+ newExcludedRecords.push(rowData); // Set isSelected to false if removing the row
260
+ newExcludedRecords = removeDuplicates(newExcludedRecords);
261
+ return false; // Exclude this item from the new array
262
+ }
263
+ });
264
+ }
265
+ else {
266
+ newExcludedRecords = [...newExcludedRecords, Object.assign(Object.assign({}, rowData), { isSelected: false })];
267
+ newExcludedRecords = removeDuplicates(newExcludedRecords);
268
+ }
269
+ newExcludedRecords = (excludedRecords === null || excludedRecords === void 0 ? void 0 : excludedRecords.some((row) => row.id === rowData.id))
246
270
  ? 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))
247
271
  : [...excludedRecords, rowData];
248
272
  // Check if all records are excluded; reset if so
@@ -251,7 +275,7 @@ const updateRecords = (rowData, featureDetails, gridData) => {
251
275
  }
252
276
  // Otherwise, update the excluded records and indeterminate state
253
277
  else {
254
- return Object.assign(Object.assign({}, featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection), { excludedRecords: newExcludedRecords, isIndeterminate: (newExcludedRecords === null || newExcludedRecords === void 0 ? void 0 : newExcludedRecords.length) > 0 });
278
+ return Object.assign(Object.assign({}, featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection), { excludedRecords: newExcludedRecords, includedRecords: newIncludedRecords, isIndeterminate: (newExcludedRecords === null || newExcludedRecords === void 0 ? void 0 : newExcludedRecords.length) > 0 });
255
279
  }
256
280
  }
257
281
  // When not all checkboxes are checked
@@ -264,16 +288,23 @@ const updateRecords = (rowData, featureDetails, gridData) => {
264
288
  }
265
289
  else {
266
290
  newExcludedRecords.push(rowData); // Set isSelected to false if removing the row
291
+ newExcludedRecords = removeDuplicates(newExcludedRecords);
267
292
  return false; // Exclude this item from the new array
268
293
  }
269
294
  });
270
295
  }
271
296
  else if (rowData.isSelected) {
272
297
  newExcludedRecords = [...newExcludedRecords, Object.assign(Object.assign({}, rowData), { isSelected: false })];
298
+ newExcludedRecords = removeDuplicates(newExcludedRecords);
299
+ rowData.isSelected = !rowData.isSelected;
300
+ }
301
+ else if (excludedRecords.some((row) => row.id === rowData.id)) {
302
+ newExcludedRecords = [...excludedRecords.filter((y) => y.id !== rowData.id)];
303
+ newIncludedRecords = removeDuplicates([...includedRecords, rowData]);
273
304
  rowData.isSelected = !rowData.isSelected;
274
305
  }
275
306
  else {
276
- newIncludedRecords = [...includedRecords, rowData];
307
+ newIncludedRecords = removeDuplicates([...includedRecords, rowData]);
277
308
  }
278
309
  // Check if all records are included; reset if so
279
310
  if ((newIncludedRecords === null || newIncludedRecords === void 0 ? void 0 : newIncludedRecords.length) === ((_b = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _b === void 0 ? void 0 : _b.length)) {
@@ -587,7 +618,6 @@ const handleCheckboxClick = (e, params, featureDetails, gridData, setFeatureDeta
587
618
  // Update checkbox data and set the updated state
588
619
  const updatedCheckBoxData = yield (0, exports.updateRecords)(rowData, featureDetails, gridData);
589
620
  const checkBoxObject = Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: updatedCheckBoxData });
590
- console.log(updatedCheckBoxData, "updatedCheckBoxData");
591
621
  selectColumns && selectColumns(checkBoxObject);
592
622
  yield setFeatureDetails(checkBoxObject);
593
623
  yield serverSideRowLeveSelection(checkBoxObject);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sccoreui",
3
- "version": "6.4.83",
3
+ "version": "6.4.84",
4
4
  "description": "ui-sccore",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",