hi-tm 0.11.2 → 0.11.4
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.
|
@@ -300,122 +300,72 @@ pageIndex = 0, // Default to first page (0-indexed)
|
|
|
300
300
|
// }
|
|
301
301
|
// };
|
|
302
302
|
// Function to determine if a row has any descendants selected (not just direct children)
|
|
303
|
-
// const isIndeterminate = (rowId: number): boolean => {
|
|
304
|
-
// // Find the row in the data
|
|
305
|
-
// const findRow = (
|
|
306
|
-
// rows: TableRowData[] | undefined,
|
|
307
|
-
// id: number
|
|
308
|
-
// ): TableRowData | null => {
|
|
309
|
-
// if (!rows) return null;
|
|
310
|
-
// for (const row of rows) {
|
|
311
|
-
// if (row.id === id) return row;
|
|
312
|
-
// if (row.hasChildren && row.childRows) {
|
|
313
|
-
// const found = findRow(row.childRows, id);
|
|
314
|
-
// if (found) return found;
|
|
315
|
-
// }
|
|
316
|
-
// }
|
|
317
|
-
// return null;
|
|
318
|
-
// };
|
|
319
|
-
// const row = findRow(rows!, rowId);
|
|
320
|
-
// // If row has no children, it can't be indeterminate
|
|
321
|
-
// if (
|
|
322
|
-
// !row ||
|
|
323
|
-
// !row.hasChildren ||
|
|
324
|
-
// !row.childRows ||
|
|
325
|
-
// row.childRows.length === 0
|
|
326
|
-
// ) {
|
|
327
|
-
// return false;
|
|
328
|
-
// }
|
|
329
|
-
// // Check if the row itself is selected
|
|
330
|
-
// const isRowSelected = selectedRows.includes(rowId);
|
|
331
|
-
// // Recursively check if any descendant is selected
|
|
332
|
-
// const hasSelectedDescendant = (children: TableRowData[]): boolean => {
|
|
333
|
-
// for (const child of children) {
|
|
334
|
-
// // If any child is selected
|
|
335
|
-
// if (selectedRows.includes(child.id)) {
|
|
336
|
-
// return true;
|
|
337
|
-
// }
|
|
338
|
-
// // Check grandchildren if they exist
|
|
339
|
-
// if (
|
|
340
|
-
// child.hasChildren &&
|
|
341
|
-
// child.childRows &&
|
|
342
|
-
// child.childRows.length > 0
|
|
343
|
-
// ) {
|
|
344
|
-
// if (hasSelectedDescendant(child.childRows)) {
|
|
345
|
-
// return true;
|
|
346
|
-
// }
|
|
347
|
-
// }
|
|
348
|
-
// }
|
|
349
|
-
// return false;
|
|
350
|
-
// };
|
|
351
|
-
// // Check if all descendants are selected
|
|
352
|
-
// const areAllDescendantsSelected = (children: TableRowData[]): boolean => {
|
|
353
|
-
// for (const child of children) {
|
|
354
|
-
// // If any child is not selected
|
|
355
|
-
// if (!selectedRows.includes(child.id)) {
|
|
356
|
-
// return false;
|
|
357
|
-
// }
|
|
358
|
-
// // Check grandchildren if they exist
|
|
359
|
-
// if (
|
|
360
|
-
// child.hasChildren &&
|
|
361
|
-
// child.childRows &&
|
|
362
|
-
// child.childRows.length > 0
|
|
363
|
-
// ) {
|
|
364
|
-
// if (!areAllDescendantsSelected(child.childRows)) {
|
|
365
|
-
// return false;
|
|
366
|
-
// }
|
|
367
|
-
// }
|
|
368
|
-
// }
|
|
369
|
-
// return true;
|
|
370
|
-
// };
|
|
371
|
-
// const hasAnySelected = hasSelectedDescendant(row.childRows);
|
|
372
|
-
// const hasAllSelected = areAllDescendantsSelected(row.childRows);
|
|
373
|
-
// // Indeterminate if some but not all descendants are selected
|
|
374
|
-
// // Or if the parent is not selected but some children are
|
|
375
|
-
// return (
|
|
376
|
-
// (hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected)
|
|
377
|
-
// );
|
|
378
|
-
// };
|
|
379
303
|
const isIndeterminate = (rowId) => {
|
|
380
|
-
//
|
|
381
|
-
const
|
|
304
|
+
// Find the row in the data
|
|
305
|
+
const findRow = (rows, id) => {
|
|
382
306
|
if (!rows)
|
|
383
|
-
return
|
|
307
|
+
return null;
|
|
384
308
|
for (const row of rows) {
|
|
385
309
|
if (row.id === id)
|
|
386
|
-
return
|
|
310
|
+
return row;
|
|
387
311
|
if (row.hasChildren && row.childRows) {
|
|
388
|
-
const found =
|
|
389
|
-
if (found
|
|
390
|
-
return
|
|
312
|
+
const found = findRow(row.childRows, id);
|
|
313
|
+
if (found)
|
|
314
|
+
return found;
|
|
391
315
|
}
|
|
392
316
|
}
|
|
393
|
-
return
|
|
317
|
+
return null;
|
|
394
318
|
};
|
|
395
|
-
const
|
|
319
|
+
const row = findRow(rows, rowId);
|
|
320
|
+
// If row has no children, it can't be indeterminate
|
|
396
321
|
if (!row ||
|
|
397
322
|
!row.hasChildren ||
|
|
398
323
|
!row.childRows ||
|
|
399
324
|
row.childRows.length === 0) {
|
|
400
325
|
return false;
|
|
401
326
|
}
|
|
327
|
+
// Check if the row itself is selected
|
|
402
328
|
const isRowSelected = selectedRows.includes(rowId);
|
|
403
|
-
//
|
|
404
|
-
|
|
405
|
-
let hasAllSelected = true;
|
|
406
|
-
const checkDescendants = (children) => {
|
|
329
|
+
// Recursively check if any descendant is selected
|
|
330
|
+
const hasSelectedDescendant = (children) => {
|
|
407
331
|
for (const child of children) {
|
|
408
|
-
|
|
409
|
-
if (
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
if (child.hasChildren &&
|
|
414
|
-
|
|
332
|
+
// If any child is selected
|
|
333
|
+
if (selectedRows.includes(child.id)) {
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
// Check grandchildren if they exist
|
|
337
|
+
if (child.hasChildren &&
|
|
338
|
+
child.childRows &&
|
|
339
|
+
child.childRows.length > 0) {
|
|
340
|
+
if (hasSelectedDescendant(child.childRows)) {
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return false;
|
|
346
|
+
};
|
|
347
|
+
// Check if all descendants are selected
|
|
348
|
+
const areAllDescendantsSelected = (children) => {
|
|
349
|
+
for (const child of children) {
|
|
350
|
+
// If any child is not selected
|
|
351
|
+
if (!selectedRows.includes(child.id)) {
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
// Check grandchildren if they exist
|
|
355
|
+
if (child.hasChildren &&
|
|
356
|
+
child.childRows &&
|
|
357
|
+
child.childRows.length > 0) {
|
|
358
|
+
if (!areAllDescendantsSelected(child.childRows)) {
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
415
361
|
}
|
|
416
362
|
}
|
|
363
|
+
return true;
|
|
417
364
|
};
|
|
418
|
-
|
|
365
|
+
const hasAnySelected = hasSelectedDescendant(row.childRows);
|
|
366
|
+
const hasAllSelected = areAllDescendantsSelected(row.childRows);
|
|
367
|
+
// Indeterminate if some but not all descendants are selected
|
|
368
|
+
// Or if the parent is not selected but some children are
|
|
419
369
|
return ((hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected));
|
|
420
370
|
};
|
|
421
371
|
// Function to check if a row is selected
|