Skip to content

Commit 8aa686d

Browse files
committed
feat(ui): replaced tanstack table
1 parent 7ca644f commit 8aa686d

14 files changed

Lines changed: 288 additions & 776 deletions

bun.lock

Lines changed: 5 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/components/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"@rollup/plugin-commonjs": "^28.0.3",
3636
"@rollup/plugin-node-resolve": "^16.0.1",
3737
"@rollup/plugin-typescript": "^12.1.2",
38-
"@tanstack/react-table": "^8.21.3",
3938
"@types/react": "^19.0.10",
4039
"dayjs": "*",
4140
"echarts": "*",
@@ -54,14 +53,12 @@
5453
"typescript": "^5.8.2"
5554
},
5655
"peerDependencies": {
57-
"@dnd-kit/core": "^6.3.1",
58-
"@dnd-kit/sortable": "^10.0.0",
59-
"@dnd-kit/utilities": "^3.2.2",
6056
"dayjs": "^1.11.13",
6157
"echarts": "^5.6.0",
6258
"echarts-for-react": "^3.0.2",
6359
"ol": "^10.5.0",
6460
"react": "^19.1.0",
61+
"react-data-table-component": "^7.7.0",
6562
"react-dom": "^19.1.0",
6663
"react-error-boundary": "^6.0.0",
6764
"react-grid-layout": "^2.2.2",

packages/components/src/components/dataTable/ColumnVisibilityPanel.tsx

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
1-
import type { Table } from "@tanstack/react-table";
21
import React from "react";
32

4-
type TableRecord = Record<string, unknown>;
5-
63
type ColumnVisibilityPanelProps = {
7-
table: Table<TableRecord>;
84
isOpen: boolean;
95
onClose: () => void;
106
title: string;
117
closeAriaLabel: string;
8+
headers: string[];
9+
visibleColumns: Set<string>;
10+
onToggleColumn: (colName: string) => void;
1211
};
1312

1413
export function ColumnVisibilityPanel({
15-
table,
1614
isOpen,
1715
onClose,
1816
title,
1917
closeAriaLabel,
18+
headers,
19+
visibleColumns,
20+
onToggleColumn,
2021
}: ColumnVisibilityPanelProps) {
2122
if (!isOpen) return null;
22-
23-
const columns = table
24-
.getAllLeafColumns()
25-
// Solo colonne che possono essere nascoste
26-
.filter(
27-
(column) => (column.getCanHide?.() ?? true) && column.id !== "_dummy"
28-
);
29-
30-
if (!columns.length) return null;
23+
if (!headers.length) return null;
3124

3225
return (
3326
<div className="mid-table-filter-panel">
@@ -43,26 +36,17 @@ export function ColumnVisibilityPanel({
4336
</button>
4437
</div>
4538
<div className="mid-table-filter-body">
46-
{columns.map((column) => {
47-
const headerLabel =
48-
typeof column.columnDef.header === "string" ||
49-
typeof column.columnDef.header === "number"
50-
? String(column.columnDef.header)
51-
: column.id;
52-
39+
{headers.map((colName) => {
40+
const id = `mid-col-filter-${colName}`;
5341
return (
54-
<label
55-
key={column.id}
56-
className="mid-table-filter-item"
57-
htmlFor={`mid-col-filter-${column.id}`}
58-
>
42+
<label key={colName} className="mid-table-filter-item" htmlFor={id}>
5943
<input
60-
id={`mid-col-filter-${column.id}`}
44+
id={id}
6145
type="checkbox"
62-
checked={column.getIsVisible()}
63-
onChange={(e) => column.toggleVisibility(e.target.checked)}
46+
checked={visibleColumns.has(colName)}
47+
onChange={() => onToggleColumn(colName)}
6448
/>
65-
<span className="mid-table-filter-label">{headerLabel}</span>
49+
<span className="mid-table-filter-label">{colName}</span>
6650
</label>
6751
);
6852
})}

0 commit comments

Comments
 (0)