next-helios-fe 1.8.67 → 1.8.68
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.
package/package.json
CHANGED
@@ -16,10 +16,11 @@ interface TableProps {
|
|
16
16
|
render?: (item: any) => React.ReactNode;
|
17
17
|
}[];
|
18
18
|
data: {
|
19
|
-
id
|
19
|
+
id?: number | string;
|
20
20
|
[key: string]: any;
|
21
21
|
}[];
|
22
22
|
options?: {
|
23
|
+
customDataIdName?: string;
|
23
24
|
toolbar?: {
|
24
25
|
addData?: {
|
25
26
|
show?: boolean;
|
@@ -54,12 +55,12 @@ interface TableProps {
|
|
54
55
|
};
|
55
56
|
checkbox?: {
|
56
57
|
checked: {
|
57
|
-
id
|
58
|
+
id?: number | string;
|
58
59
|
[key: string]: any;
|
59
60
|
}[];
|
60
61
|
onChange: (
|
61
62
|
checked: {
|
62
|
-
id
|
63
|
+
id?: number | string;
|
63
64
|
[key: string]: any;
|
64
65
|
}[]
|
65
66
|
) => void;
|
@@ -90,7 +91,7 @@ export const Table: TableComponentProps = ({
|
|
90
91
|
const [page, setPage] = useState<number>(1);
|
91
92
|
const [selected, setSelected] = useState<
|
92
93
|
{
|
93
|
-
id
|
94
|
+
id?: number | string;
|
94
95
|
[key: string]: any;
|
95
96
|
}[]
|
96
97
|
>([]);
|
@@ -224,7 +225,10 @@ export const Table: TableComponentProps = ({
|
|
224
225
|
} else {
|
225
226
|
return tempData?.sort((a, b): any => {
|
226
227
|
if (sortBy?.column === "") {
|
227
|
-
return a
|
228
|
+
return a?.[options?.customDataIdName ?? "id"] >
|
229
|
+
b?.[options?.customDataIdName ?? "id"]
|
230
|
+
? 1
|
231
|
+
: -1;
|
228
232
|
} else if (sortBy?.order === "asc") {
|
229
233
|
return a[sortBy?.column as keyof typeof a] >
|
230
234
|
b[sortBy?.column as keyof typeof b]
|
@@ -400,28 +404,44 @@ export const Table: TableComponentProps = ({
|
|
400
404
|
: filteredData
|
401
405
|
)?.map((item, index) => {
|
402
406
|
return (
|
403
|
-
<tr key={item
|
407
|
+
<tr key={item?.[options?.customDataIdName ?? "id"]}>
|
404
408
|
{checkbox && (
|
405
409
|
<td className="sticky left-0 w-8 px-4 py-1.5 bg-secondary-bg">
|
406
410
|
<Form.Checkbox
|
407
411
|
options={{ disableHover: true }}
|
408
412
|
checked={
|
409
|
-
selected?.find(
|
413
|
+
selected?.find(
|
414
|
+
(selectedItem) =>
|
415
|
+
selectedItem?.[options?.customDataIdName ?? "id"] ===
|
416
|
+
item?.[options?.customDataIdName ?? "id"]
|
417
|
+
)
|
410
418
|
? true
|
411
419
|
: false
|
412
420
|
}
|
413
421
|
readOnly
|
414
422
|
onClick={(e) => {
|
415
423
|
if (
|
416
|
-
selected?.find(
|
424
|
+
selected?.find(
|
425
|
+
(selectedItem) =>
|
426
|
+
selectedItem?.[options?.customDataIdName ?? "id"] ===
|
427
|
+
item?.[options?.customDataIdName ?? "id"]
|
428
|
+
)
|
417
429
|
) {
|
418
430
|
if (checkbox?.onChange) {
|
419
431
|
checkbox?.onChange(
|
420
|
-
selected?.filter(
|
432
|
+
selected?.filter(
|
433
|
+
(prev) =>
|
434
|
+
prev?.[options?.customDataIdName ?? "id"] !==
|
435
|
+
item?.[options?.customDataIdName ?? "id"]
|
436
|
+
)
|
421
437
|
);
|
422
438
|
} else {
|
423
439
|
setSelected(
|
424
|
-
selected?.filter(
|
440
|
+
selected?.filter(
|
441
|
+
(prev) =>
|
442
|
+
prev?.[options?.customDataIdName ?? "id"] !==
|
443
|
+
item?.[options?.customDataIdName ?? "id"]
|
444
|
+
)
|
425
445
|
);
|
426
446
|
}
|
427
447
|
} else {
|