hi-tm 0.11.2 → 0.11.3
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,10 +1,43 @@
|
|
|
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
|
+
})();
|
|
3
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
38
|
};
|
|
6
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const react_1 =
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
8
41
|
const react_2 = require("react");
|
|
9
42
|
const image_1 = __importDefault(require("next/image"));
|
|
10
43
|
const SafeImage_1 = __importDefault(require("../../../elements/SafeImage"));
|
|
@@ -376,66 +409,74 @@ pageIndex = 0, // Default to first page (0-indexed)
|
|
|
376
409
|
// (hasAnySelected && !hasAllSelected) || (!isRowSelected && hasAnySelected)
|
|
377
410
|
// );
|
|
378
411
|
// };
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
412
|
+
// در ModernTable
|
|
413
|
+
const selectedRowsSet = (0, react_1.useMemo)(() => new Set(selectedRows), [selectedRows]);
|
|
414
|
+
const isIndeterminate = (0, react_1.useCallback)((rowId) => {
|
|
415
|
+
const findRow = (rows, id) => {
|
|
382
416
|
if (!rows)
|
|
383
|
-
return
|
|
384
|
-
|
|
417
|
+
return null;
|
|
418
|
+
const stack = [...rows];
|
|
419
|
+
while (stack.length > 0) {
|
|
420
|
+
const row = stack.pop();
|
|
385
421
|
if (row.id === id)
|
|
386
|
-
return
|
|
422
|
+
return row;
|
|
387
423
|
if (row.hasChildren && row.childRows) {
|
|
388
|
-
|
|
389
|
-
if (found.row)
|
|
390
|
-
return { row: found.row, path: [row, ...found.path] };
|
|
424
|
+
stack.push(...row.childRows);
|
|
391
425
|
}
|
|
392
426
|
}
|
|
393
|
-
return
|
|
427
|
+
return null;
|
|
394
428
|
};
|
|
395
|
-
const
|
|
429
|
+
const row = findRow(rows, rowId);
|
|
396
430
|
if (!row ||
|
|
397
431
|
!row.hasChildren ||
|
|
398
432
|
!row.childRows ||
|
|
399
433
|
row.childRows.length === 0) {
|
|
400
434
|
return false;
|
|
401
435
|
}
|
|
402
|
-
const isRowSelected =
|
|
403
|
-
|
|
436
|
+
const isRowSelected = selectedRowsSet.has(rowId);
|
|
437
|
+
const stack = [...row.childRows];
|
|
404
438
|
let hasAnySelected = false;
|
|
405
439
|
let hasAllSelected = true;
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}
|
|
440
|
+
while (stack.length > 0) {
|
|
441
|
+
const child = stack.pop();
|
|
442
|
+
const childSelected = selectedRowsSet.has(child.id);
|
|
443
|
+
if (childSelected)
|
|
444
|
+
hasAnySelected = true;
|
|
445
|
+
else
|
|
446
|
+
hasAllSelected = false;
|
|
447
|
+
if (child.hasChildren && child.childRows) {
|
|
448
|
+
stack.push(...child.childRows);
|
|
416
449
|
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
};
|
|
450
|
+
}
|
|
451
|
+
return ((hasAnySelected && !hasAllSelected) ||
|
|
452
|
+
(!isRowSelected && hasAnySelected));
|
|
453
|
+
}, [rows, selectedRowsSet]);
|
|
454
|
+
const handleCheckboxChange = (0, react_1.useCallback)((id) => {
|
|
455
|
+
const updatedSelection = selectedRows.includes(id)
|
|
456
|
+
? selectedRows.filter((rowId) => rowId !== id)
|
|
457
|
+
: [...selectedRows, id];
|
|
458
|
+
setSelectedRows(updatedSelection);
|
|
459
|
+
if (onSelectionChange) {
|
|
460
|
+
onSelectionChange(updatedSelection);
|
|
461
|
+
}
|
|
462
|
+
}, [selectedRows, onSelectionChange]);
|
|
421
463
|
// Function to check if a row is selected
|
|
422
464
|
const isSelected = (rowId) => {
|
|
423
465
|
return selectedRows.includes(rowId);
|
|
424
466
|
};
|
|
425
|
-
const handleCheckboxChange = (id) => {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
};
|
|
467
|
+
// const handleCheckboxChange = (id: number) => {
|
|
468
|
+
// // Call your existing handleSelectionChange function
|
|
469
|
+
// // This will handle the hierarchical selection logic
|
|
470
|
+
// if (onSelectionChange) {
|
|
471
|
+
// onSelectionChange(id);
|
|
472
|
+
// } else {
|
|
473
|
+
// // Fallback to simple selection if no onSelectionChange is provided
|
|
474
|
+
// const updatedSelection = selectedRows.includes(id)
|
|
475
|
+
// ? selectedRows.filter((rowId) => rowId !== id)
|
|
476
|
+
// : [...selectedRows, id];
|
|
477
|
+
// setSelectedRows(updatedSelection);
|
|
478
|
+
// }
|
|
479
|
+
// };
|
|
439
480
|
// Extract title and subtitle from row data
|
|
440
481
|
const extractCardData = (row) => {
|
|
441
482
|
let title = "";
|