hi-tm 0.12.5 → 0.12.6

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.
@@ -385,49 +385,55 @@ pageIndex = 0, // Default to first page (0-indexed)
385
385
  // setSelectedRows(updatedSelection);
386
386
  // }
387
387
  // };
388
- const handleCheckboxChange = (id) => {
389
- const findRowById = (rows, targetId) => {
390
- for (const row of rows) {
391
- if (row.id === targetId)
392
- return row;
388
+ const [isProcessing, setIsProcessing] = (0, react_2.useState)(false);
389
+ const handleCheckboxChange = async (id) => {
390
+ setIsProcessing(true);
391
+ try {
392
+ const findRowById = (rows, targetId) => {
393
+ for (const row of rows) {
394
+ if (row.id === targetId)
395
+ return row;
396
+ if (row.hasChildren && row.childRows) {
397
+ const found = findRowById(row.childRows, targetId);
398
+ if (found)
399
+ return found;
400
+ }
401
+ }
402
+ return null;
403
+ };
404
+ const getAllDescendantIds = (row) => {
405
+ let ids = [];
393
406
  if (row.hasChildren && row.childRows) {
394
- const found = findRowById(row.childRows, targetId);
395
- if (found)
396
- return found;
407
+ for (const child of row.childRows) {
408
+ ids.push(child.id);
409
+ ids = [...ids, ...getAllDescendantIds(child)];
410
+ }
397
411
  }
412
+ return ids;
413
+ };
414
+ const updatedSelection = [...selectedRows];
415
+ const row = findRowById(rows, id);
416
+ if (!row)
417
+ return;
418
+ const descendantIds = getAllDescendantIds(row);
419
+ await new Promise((resolve) => setTimeout(resolve, 300));
420
+ if (selectedRows.includes(id)) {
421
+ const idsToRemove = [id, ...descendantIds];
422
+ setSelectedRows(updatedSelection.filter((itemId) => !idsToRemove.includes(itemId)));
398
423
  }
399
- return null;
400
- };
401
- const getAllDescendantIds = (row) => {
402
- let ids = [];
403
- if (row.hasChildren && row.childRows) {
404
- for (const child of row.childRows) {
405
- ids.push(child.id);
406
- ids = [...ids, ...getAllDescendantIds(child)];
407
- }
424
+ else {
425
+ const idsToAdd = [id, ...descendantIds];
426
+ setSelectedRows([
427
+ ...updatedSelection,
428
+ ...idsToAdd.filter((i) => !updatedSelection.includes(i)),
429
+ ]);
430
+ }
431
+ if (onSelectionChange) {
432
+ onSelectionChange(id);
408
433
  }
409
- return ids;
410
- };
411
- const updatedSelection = [...selectedRows];
412
- const row = findRowById(rows, id);
413
- if (!row)
414
- return;
415
- const descendantIds = getAllDescendantIds(row);
416
- if (selectedRows.includes(id)) {
417
- // Remove parent + all descendants
418
- const idsToRemove = [id, ...descendantIds];
419
- setSelectedRows(updatedSelection.filter((itemId) => !idsToRemove.includes(itemId)));
420
- }
421
- else {
422
- // Add parent + all descendants
423
- const idsToAdd = [id, ...descendantIds];
424
- setSelectedRows([
425
- ...updatedSelection,
426
- ...idsToAdd.filter((i) => !updatedSelection.includes(i)),
427
- ]);
428
434
  }
429
- if (onSelectionChange) {
430
- onSelectionChange(id);
435
+ finally {
436
+ setIsProcessing(false);
431
437
  }
432
438
  };
433
439
  // Extract title and subtitle from row data
@@ -717,6 +723,8 @@ pageIndex = 0, // Default to first page (0-indexed)
717
723
  " ")))));
718
724
  }
719
725
  return (react_1.default.createElement(react_1.default.Fragment, null,
726
+ isProcessing && (react_1.default.createElement("div", { className: "fixed inset-0 flex items-center justify-center bg-black bg-opacity-10 z-50" },
727
+ react_1.default.createElement(Loader, null))),
720
728
  mobileCardConfig.enabled && (react_1.default.createElement("div", { className: `lg:hidden grid ${mobileCardConfig.gridLayoutClassName}` }, mobileRows.map((row) => (react_1.default.createElement("div", { key: `mobile-grid-item-${row.id}`, className: `col-span-1 ${row.isChild ? "pl-2" : ""}` }, renderMobileCard(row)))))),
721
729
  react_1.default.createElement("div", { className: `${mobileCardConfig.enabled ? "hidden lg:block" : ""} w-full` }, rows?.map((row, index) => renderTableRow(row, index, index === rows.length - 1)))));
722
730
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hi-tm",
3
- "version": "0.12.5",
3
+ "version": "0.12.6",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {