hi-tm 0.11.3 → 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.
|
@@ -1,43 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
5
|
};
|
|
39
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
const react_1 =
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
41
8
|
const react_2 = require("react");
|
|
42
9
|
const image_1 = __importDefault(require("next/image"));
|
|
43
10
|
const SafeImage_1 = __importDefault(require("../../../elements/SafeImage"));
|
|
@@ -333,150 +300,92 @@ pageIndex = 0, // Default to first page (0-indexed)
|
|
|
333
300
|
// }
|
|
334
301
|
// };
|
|
335
302
|
// Function to determine if a row has any descendants selected (not just direct children)
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
// const findRow = (
|
|
339
|
-
// rows: TableRowData[] | undefined,
|
|
340
|
-
// id: number
|
|
341
|
-
// ): TableRowData | null => {
|
|
342
|
-
// if (!rows) return null;
|
|
343
|
-
// for (const row of rows) {
|
|
344
|
-
// if (row.id === id) return row;
|
|
345
|
-
// if (row.hasChildren && row.childRows) {
|
|
346
|
-
// const found = findRow(row.childRows, id);
|
|
347
|
-
// if (found) return found;
|
|
348
|
-
// }
|
|
349
|
-
// }
|
|
350
|
-
// return null;
|
|
351
|
-
// };
|
|
352
|
-
// const row = findRow(rows!, rowId);
|
|
353
|
-
// // If row has no children, it can't be indeterminate
|
|
354
|
-
// if (
|
|
355
|
-
// !row ||
|
|
356
|
-
// !row.hasChildren ||
|
|
357
|
-
// !row.childRows ||
|
|
358
|
-
// row.childRows.length === 0
|
|
359
|
-
// ) {
|
|
360
|
-
// return false;
|
|
361
|
-
// }
|
|
362
|
-
// // Check if the row itself is selected
|
|
363
|
-
// const isRowSelected = selectedRows.includes(rowId);
|
|
364
|
-
// // Recursively check if any descendant is selected
|
|
365
|
-
// const hasSelectedDescendant = (children: TableRowData[]): boolean => {
|
|
366
|
-
// for (const child of children) {
|
|
367
|
-
// // If any child is selected
|
|
368
|
-
// if (selectedRows.includes(child.id)) {
|
|
369
|
-
// return true;
|
|
370
|
-
// }
|
|
371
|
-
// // Check grandchildren if they exist
|
|
372
|
-
// if (
|
|
373
|
-
// child.hasChildren &&
|
|
374
|
-
// child.childRows &&
|
|
375
|
-
// child.childRows.length > 0
|
|
376
|
-
// ) {
|
|
377
|
-
// if (hasSelectedDescendant(child.childRows)) {
|
|
378
|
-
// return true;
|
|
379
|
-
// }
|
|
380
|
-
// }
|
|
381
|
-
// }
|
|
382
|
-
// return false;
|
|
383
|
-
// };
|
|
384
|
-
// // Check if all descendants are selected
|
|
385
|
-
// const areAllDescendantsSelected = (children: TableRowData[]): boolean => {
|
|
386
|
-
// for (const child of children) {
|
|
387
|
-
// // If any child is not selected
|
|
388
|
-
// if (!selectedRows.includes(child.id)) {
|
|
389
|
-
// return false;
|
|
390
|
-
// }
|
|
391
|
-
// // Check grandchildren if they exist
|
|
392
|
-
// if (
|
|
393
|
-
// child.hasChildren &&
|
|
394
|
-
// child.childRows &&
|
|
395
|
-
// child.childRows.length > 0
|
|
396
|
-
// ) {
|
|
397
|
-
// if (!areAllDescendantsSelected(child.childRows)) {
|
|
398
|
-
// return false;
|
|
399
|
-
// }
|
|
400
|
-
// }
|
|
401
|
-
// }
|
|
402
|
-
// return true;
|
|
403
|
-
// };
|
|
404
|
-
// const hasAnySelected = hasSelectedDescendant(row.childRows);
|
|
405
|
-
// const hasAllSelected = areAllDescendantsSelected(row.childRows);
|
|
406
|
-
// // Indeterminate if some but not all descendants are selected
|
|
407
|
-
// // Or if the parent is not selected but some children are
|
|
408
|
-
// return (
|
|
409
|
-
// (hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected)
|
|
410
|
-
// );
|
|
411
|
-
// };
|
|
412
|
-
// در ModernTable
|
|
413
|
-
const selectedRowsSet = (0, react_1.useMemo)(() => new Set(selectedRows), [selectedRows]);
|
|
414
|
-
const isIndeterminate = (0, react_1.useCallback)((rowId) => {
|
|
303
|
+
const isIndeterminate = (rowId) => {
|
|
304
|
+
// Find the row in the data
|
|
415
305
|
const findRow = (rows, id) => {
|
|
416
306
|
if (!rows)
|
|
417
307
|
return null;
|
|
418
|
-
const
|
|
419
|
-
while (stack.length > 0) {
|
|
420
|
-
const row = stack.pop();
|
|
308
|
+
for (const row of rows) {
|
|
421
309
|
if (row.id === id)
|
|
422
310
|
return row;
|
|
423
311
|
if (row.hasChildren && row.childRows) {
|
|
424
|
-
|
|
312
|
+
const found = findRow(row.childRows, id);
|
|
313
|
+
if (found)
|
|
314
|
+
return found;
|
|
425
315
|
}
|
|
426
316
|
}
|
|
427
317
|
return null;
|
|
428
318
|
};
|
|
429
319
|
const row = findRow(rows, rowId);
|
|
320
|
+
// If row has no children, it can't be indeterminate
|
|
430
321
|
if (!row ||
|
|
431
322
|
!row.hasChildren ||
|
|
432
323
|
!row.childRows ||
|
|
433
324
|
row.childRows.length === 0) {
|
|
434
325
|
return false;
|
|
435
326
|
}
|
|
436
|
-
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
327
|
+
// Check if the row itself is selected
|
|
328
|
+
const isRowSelected = selectedRows.includes(rowId);
|
|
329
|
+
// Recursively check if any descendant is selected
|
|
330
|
+
const hasSelectedDescendant = (children) => {
|
|
331
|
+
for (const child of children) {
|
|
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
|
+
}
|
|
449
344
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
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
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return true;
|
|
364
|
+
};
|
|
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
|
|
369
|
+
return ((hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected));
|
|
370
|
+
};
|
|
463
371
|
// Function to check if a row is selected
|
|
464
372
|
const isSelected = (rowId) => {
|
|
465
373
|
return selectedRows.includes(rowId);
|
|
466
374
|
};
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
375
|
+
const handleCheckboxChange = (id) => {
|
|
376
|
+
// Call your existing handleSelectionChange function
|
|
377
|
+
// This will handle the hierarchical selection logic
|
|
378
|
+
if (onSelectionChange) {
|
|
379
|
+
onSelectionChange(id);
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
// Fallback to simple selection if no onSelectionChange is provided
|
|
383
|
+
const updatedSelection = selectedRows.includes(id)
|
|
384
|
+
? selectedRows.filter((rowId) => rowId !== id)
|
|
385
|
+
: [...selectedRows, id];
|
|
386
|
+
setSelectedRows(updatedSelection);
|
|
387
|
+
}
|
|
388
|
+
};
|
|
480
389
|
// Extract title and subtitle from row data
|
|
481
390
|
const extractCardData = (row) => {
|
|
482
391
|
let title = "";
|