hi-tm 0.11.7 → 0.11.8
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,50 +385,54 @@ pageIndex = 0, // Default to first page (0-indexed)
|
|
|
385
385
|
// setSelectedRows(updatedSelection);
|
|
386
386
|
// }
|
|
387
387
|
// };
|
|
388
|
+
const [isProcessingSelection, setIsProcessingSelection] = (0, react_2.useState)(false);
|
|
388
389
|
const handleCheckboxChange = (id) => {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
390
|
+
setIsProcessingSelection(true); // شروع پردازش
|
|
391
|
+
setTimeout(() => {
|
|
392
|
+
// شبیهسازی پردازش سنگین یا async
|
|
393
|
+
const findRowById = (rows, targetId) => {
|
|
394
|
+
for (const row of rows) {
|
|
395
|
+
if (row.id === targetId)
|
|
396
|
+
return row;
|
|
397
|
+
if (row.hasChildren && row.childRows) {
|
|
398
|
+
const found = findRowById(row.childRows, targetId);
|
|
399
|
+
if (found)
|
|
400
|
+
return found;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return null;
|
|
404
|
+
};
|
|
405
|
+
const getAllDescendantIds = (row) => {
|
|
406
|
+
let ids = [];
|
|
393
407
|
if (row.hasChildren && row.childRows) {
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
408
|
+
for (const child of row.childRows) {
|
|
409
|
+
ids.push(child.id);
|
|
410
|
+
ids = [...ids, ...getAllDescendantIds(child)];
|
|
411
|
+
}
|
|
397
412
|
}
|
|
413
|
+
return ids;
|
|
414
|
+
};
|
|
415
|
+
const updatedSelection = [...selectedRows];
|
|
416
|
+
const row = findRowById(rows, id);
|
|
417
|
+
if (!row)
|
|
418
|
+
return;
|
|
419
|
+
const descendantIds = getAllDescendantIds(row);
|
|
420
|
+
if (selectedRows.includes(id)) {
|
|
421
|
+
const idsToRemove = [id, ...descendantIds];
|
|
422
|
+
setSelectedRows(updatedSelection.filter((itemId) => !idsToRemove.includes(itemId)));
|
|
398
423
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
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
|
+
]);
|
|
408
430
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
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
|
-
}
|
|
429
|
-
if (onSelectionChange) {
|
|
430
|
-
onSelectionChange(id);
|
|
431
|
-
}
|
|
431
|
+
if (onSelectionChange) {
|
|
432
|
+
onSelectionChange(id);
|
|
433
|
+
}
|
|
434
|
+
setIsProcessingSelection(false); // پایان پردازش
|
|
435
|
+
}, 50); // مقدار کوتاه برای شبیهسازی async
|
|
432
436
|
};
|
|
433
437
|
// Extract title and subtitle from row data
|
|
434
438
|
const extractCardData = (row) => {
|
|
@@ -542,6 +546,8 @@ pageIndex = 0, // Default to first page (0-indexed)
|
|
|
542
546
|
el.indeterminate = isIndeterminate(row.id);
|
|
543
547
|
}
|
|
544
548
|
} })))),
|
|
549
|
+
isProcessingSelection && (react_1.default.createElement("div", { className: "absolute inset-0 flex items-center justify-center bg-white/50 z-50" },
|
|
550
|
+
react_1.default.createElement(Loader, null))),
|
|
545
551
|
react_1.default.createElement("div", { className: "flex-1 min-w-0" },
|
|
546
552
|
react_1.default.createElement("div", { className: "flex items-start justify-between" },
|
|
547
553
|
react_1.default.createElement("div", { className: "overflow-hidden" },
|