@pindoba/astro-table 0.0.0-alpha-20260426220647

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/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ Copyright 2025 Eduardo Lopes
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
8
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
9
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
10
+ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
11
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
12
+ DEALINGS IN THE SOFTWARE.
package/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ // Do not write code directly here, instead use the `src` folder!
2
+ // Then, use this file to export everything you want your user to access.
3
+
4
+ import Component from "./src/table.astro";
5
+ export * from "./src/table.astro";
6
+
7
+ export default Component;
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@pindoba/astro-table",
3
+ "version": "0.0.0-alpha-20260426220647",
4
+ "homepage": "https://github.com/EduardoLopes/pindoba/tree/main/packages/ui/astro/table#README.md",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/EduardoLopes/pindoba.git",
8
+ "directory": "packages/ui/astro/table"
9
+ },
10
+ "sideEffects": false,
11
+ "license": "MIT",
12
+ "type": "module",
13
+ "exports": {
14
+ ".": "./index.ts",
15
+ "./demos": "./src/demos/index.ts",
16
+ "./demos/default": "./src/demos/default.astro",
17
+ "./demos/sortable": "./src/demos/sortable.astro",
18
+ "./demos/pagination": "./src/demos/pagination.astro",
19
+ "./demos/filterable": "./src/demos/filterable.astro",
20
+ "./demos/custom-cell": "./src/demos/custom-cell.astro",
21
+ "./demos/selectable": "./src/demos/selectable.astro",
22
+ "./demos/column-visibility": "./src/demos/column-visibility.astro",
23
+ "./demos/expandable": "./src/demos/expandable.astro",
24
+ "./demos/grouped": "./src/demos/grouped.astro",
25
+ "./demos/server-side": "./src/demos/server-side.astro",
26
+ "./demos/headless": "./src/demos/headless.astro"
27
+ },
28
+ "files": [
29
+ "src",
30
+ "index.ts"
31
+ ],
32
+ "keywords": [
33
+ "astro-component"
34
+ ],
35
+ "devDependencies": {
36
+ "@astrojs/check": "^0.9.8",
37
+ "astro": "^6.1.9",
38
+ "typescript": "^6.0.3"
39
+ },
40
+ "peerDependencies": {
41
+ "astro": "^4.0.0"
42
+ },
43
+ "dependencies": {
44
+ "@iconify-json/lucide": "^1.2.103",
45
+ "@tanstack/table-core": "^8.21.3",
46
+ "astro-icon": "^1.1.5",
47
+ "@pindoba/astro-avatar": "0.0.0-alpha-20260426220647",
48
+ "@pindoba/astro-badge": "0.0.0-alpha-20260426220647",
49
+ "@pindoba/astro-button": "0.0.0-alpha-20260426220647",
50
+ "@pindoba/astro-select": "0.0.0-alpha-20260426220647",
51
+ "@pindoba/core-table": "0.0.0-alpha-20260426220647",
52
+ "@pindoba/astro-input": "0.0.0-alpha-20260426220647",
53
+ "@pindoba/styled-system": "0.0.0-alpha-20260426220647",
54
+ "@pindoba/styles-table": "0.0.0-alpha-20260426220647",
55
+ "@pindoba/utils": "0.0.0-alpha-20260426220647"
56
+ },
57
+ "scripts": {
58
+ "lint": "TIMING=1 eslint . --max-warnings 0",
59
+ "lint:fix": "TIMING=1 eslint . --fix --max-warnings 0",
60
+ "format": "prettier --write .",
61
+ "format:fix": "prettier --write .",
62
+ "check": "astro check",
63
+ "dev": "astro check --watch",
64
+ "clean": "rm -rf .astro && rm -rf node_modules && rm -rf .turbo"
65
+ }
66
+ }
@@ -0,0 +1,81 @@
1
+ ---
2
+ import Table from "../table.astro";
3
+ import type { ColumnDef } from "@tanstack/table-core";
4
+
5
+ interface Metric {
6
+ name: string;
7
+ value: number;
8
+ change: number;
9
+ updated: string;
10
+ owner: string;
11
+ }
12
+
13
+ const data: Metric[] = [
14
+ {
15
+ name: "Revenue",
16
+ value: 128_000,
17
+ change: 5.4,
18
+ updated: "2h ago",
19
+ owner: "Finance",
20
+ },
21
+ {
22
+ name: "Active users",
23
+ value: 42_100,
24
+ change: -1.2,
25
+ updated: "5m ago",
26
+ owner: "Growth",
27
+ },
28
+ {
29
+ name: "Conversion",
30
+ value: 3.8,
31
+ change: 0.3,
32
+ updated: "1h ago",
33
+ owner: "Product",
34
+ },
35
+ {
36
+ name: "Churn",
37
+ value: 2.1,
38
+ change: -0.4,
39
+ updated: "3h ago",
40
+ owner: "Retention",
41
+ },
42
+ ];
43
+
44
+ const columns: ColumnDef<Metric>[] = [
45
+ { accessorKey: "name", header: "Metric" },
46
+ { accessorKey: "value", header: "Value" },
47
+ { accessorKey: "change", header: "Change" },
48
+ { accessorKey: "updated", header: "Updated" },
49
+ { accessorKey: "owner", header: "Owner" },
50
+ ];
51
+
52
+ // The toolbar lives inside the table root (via the `toolbar` slot) so
53
+ // mountTable's delegated `[data-table-column-toggle]` change handler picks
54
+ // up these checkboxes automatically.
55
+ const toggleableColumns = ["name", "value", "change", "updated", "owner"];
56
+ ---
57
+
58
+ <Table
59
+ data={data}
60
+ columns={columns}
61
+ enableColumnVisibility
62
+ enablePagination={false}
63
+ caption="Toggle columns on and off"
64
+ >
65
+ <Fragment slot="toolbar">
66
+ <strong style="font-size: 0.875rem;">Toggle columns:</strong>
67
+ {
68
+ toggleableColumns.map((id) => (
69
+ <label style="display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.875rem;">
70
+ <input
71
+ type="checkbox"
72
+ checked
73
+ data-table-column-toggle={id}
74
+ aria-label={`Toggle ${id}`}
75
+ />
76
+ {id}
77
+ </label>
78
+ ))
79
+ }
80
+ </Fragment>
81
+ </Table>
@@ -0,0 +1,193 @@
1
+ ---
2
+ import Table from "../table.astro";
3
+ import Avatar from "@pindoba/astro-avatar";
4
+ import Badge from "@pindoba/astro-badge";
5
+ import type { ColumnDef } from "@tanstack/table-core";
6
+
7
+ interface Task {
8
+ id: string;
9
+ title: string;
10
+ assignee: string;
11
+ // First letter of `assignee`; baked into the data so the Astro `<Avatar>`
12
+ // template can render it declaratively (`data-table-bind` can't call a
13
+ // function per row). Svelte uses the same field for strict parity.
14
+ assigneeInitial: string;
15
+ priority: "low" | "medium" | "high";
16
+ // Numeric rank so Priority sorts semantically (high > medium > low) via
17
+ // the `meta.sortByField` convention — a string `sortingFn` that survives
18
+ // Astro's SSR→client boundary.
19
+ priorityRank: 1 | 2 | 3;
20
+ progress: number;
21
+ }
22
+
23
+ const data: Task[] = [
24
+ {
25
+ id: "T-1",
26
+ title: "Design review",
27
+ assignee: "Ada",
28
+ assigneeInitial: "A",
29
+ priority: "high",
30
+ priorityRank: 3,
31
+ progress: 80,
32
+ },
33
+ {
34
+ id: "T-2",
35
+ title: "Write tests",
36
+ assignee: "Grace",
37
+ assigneeInitial: "G",
38
+ priority: "medium",
39
+ priorityRank: 2,
40
+ progress: 45,
41
+ },
42
+ {
43
+ id: "T-3",
44
+ title: "Update docs",
45
+ assignee: "Alan",
46
+ assigneeInitial: "A",
47
+ priority: "low",
48
+ priorityRank: 1,
49
+ progress: 100,
50
+ },
51
+ ];
52
+
53
+ const columns: ColumnDef<Task>[] = [
54
+ { accessorKey: "id", header: "ID" },
55
+ { accessorKey: "title", header: "Task" },
56
+ { accessorKey: "assignee", header: "Assignee" },
57
+ {
58
+ accessorKey: "priority",
59
+ header: "Priority",
60
+ // `meta.sortByField` makes createTableOptions synthesize a sortingFn that
61
+ // compares numeric `priorityRank` instead of alphabetical "priority".
62
+ meta: { sortByField: "priorityRank" },
63
+ },
64
+ { accessorKey: "progress", header: "Progress" },
65
+ ];
66
+ ---
67
+
68
+ <Table
69
+ data={data}
70
+ columns={columns}
71
+ caption="Per-column slots compose Pindoba components with row-scoped bindings"
72
+ enablePagination={false}
73
+ >
74
+ {/* Title cell: bold title with the row id underneath. */}
75
+ <template data-table-cell-template="title">
76
+ <strong data-table-bind="value"></strong>
77
+ <small style="display: block; opacity: 0.6;">
78
+ row <span data-table-bind="row.id"></span>
79
+ </small>
80
+ </template>
81
+
82
+ {
83
+ /* Assignee cell: Pindoba Avatar + name side by side. The Avatar's fallback
84
+ slot receives the per-row initial via `data-table-bind`. */
85
+ }
86
+ <template data-table-cell-template="assignee">
87
+ <span style="display: inline-flex; align-items: center; gap: 0.5rem;">
88
+ <Avatar size="sm">
89
+ <span slot="fallback" data-table-bind="row.assigneeInitial"></span>
90
+ </Avatar>
91
+ <span data-table-bind="value"></span>
92
+ </span>
93
+ </template>
94
+
95
+ {
96
+ /* Priority cell: one `<Badge>` per variant, mount-table's `data-table-show-if`
97
+ hides the non-matching ones per row. `data-table-bind="value"` fills the
98
+ label text. */
99
+ }
100
+ <template data-table-cell-template="priority">
101
+ <Badge feedback="danger" data-table-show-if="row.priority=high">
102
+ <span data-table-bind="value"></span>
103
+ </Badge>
104
+ <Badge feedback="warning" data-table-show-if="row.priority=medium">
105
+ <span data-table-bind="value"></span>
106
+ </Badge>
107
+ <Badge feedback="success" data-table-show-if="row.priority=low">
108
+ <span data-table-bind="value"></span>
109
+ </Badge>
110
+ </template>
111
+
112
+ {
113
+ /* Progress cell: hand-rolled bar (no Pindoba Progress component yet). The
114
+ `data-progress` attribute drives the filled-bar width via CSS calc. */
115
+ }
116
+ <template data-table-cell-template="progress">
117
+ <span class="progress-cell">
118
+ <span class="progress-track">
119
+ <span class="progress-fill" data-table-bind="row.progress"></span>
120
+ </span>
121
+ <span class="progress-value" data-table-bind="row.progress"></span>
122
+ </span>
123
+ </template>
124
+ </Table>
125
+
126
+ <style>
127
+ .progress-cell {
128
+ display: flex;
129
+ align-items: center;
130
+ gap: 0.5rem;
131
+ }
132
+ .progress-track {
133
+ flex: 1;
134
+ min-width: 60px;
135
+ height: 6px;
136
+ border-radius: 9999px;
137
+ background: rgba(127, 127, 127, 0.2);
138
+ overflow: hidden;
139
+ }
140
+ .progress-fill {
141
+ display: block;
142
+ height: 100%;
143
+ background: var(--colors-primary-solid, #6366f1);
144
+ /* `data-table-bind` injects the numeric progress as textContent — that's
145
+ our signal for the width below. Hide it visually so the bar shows no
146
+ text. Keeping the text prevents a MutationObserver feedback loop
147
+ (clearing text would re-fire the observer, read "" back as 0, reset
148
+ the width). */
149
+ font-size: 0;
150
+ line-height: 0;
151
+ }
152
+ .progress-value {
153
+ font-variant-numeric: tabular-nums;
154
+ font-size: 0.75rem;
155
+ }
156
+ .progress-value::after {
157
+ content: "%";
158
+ }
159
+ </style>
160
+
161
+ <script>
162
+ /* `data-table-bind` sets the fill span's textContent to the numeric progress.
163
+ Turn that text into a `width` (and a 100%-complete green) so the visual
164
+ matches the Svelte demo. Runs on every mutation inside `tbody`.
165
+ We never clear the textContent: doing so would re-fire the MutationObserver
166
+ and read "" back as 0%, making the bar vanish after the first sort. */
167
+ function applyProgress(root: Element) {
168
+ root.querySelectorAll<HTMLElement>(".progress-fill").forEach((el) => {
169
+ const pct = Number(el.textContent ?? 0);
170
+ el.style.width = `${pct}%`;
171
+ el.style.background =
172
+ pct >= 100
173
+ ? "var(--colors-green-solid, #10b981)"
174
+ : "var(--colors-primary-solid, #6366f1)";
175
+ });
176
+ }
177
+
178
+ function init() {
179
+ document
180
+ .querySelectorAll<HTMLElement>('[data-table-cell-template="progress"]')
181
+ .forEach((tpl) => {
182
+ const root = tpl.closest<HTMLElement>('[data-component="table"]');
183
+ if (!root) return;
184
+ applyProgress(root);
185
+ const tbody = root.querySelector("tbody");
186
+ if (!tbody) return;
187
+ const mo = new MutationObserver(() => applyProgress(root));
188
+ mo.observe(tbody, { childList: true, subtree: true });
189
+ });
190
+ }
191
+ init();
192
+ document.addEventListener("astro:page-load", init);
193
+ </script>
@@ -0,0 +1,112 @@
1
+ ---
2
+ import Table from "../table.astro";
3
+ import type { ColumnDef } from "@tanstack/table-core";
4
+
5
+ interface Person {
6
+ name: string;
7
+ role: string;
8
+ location: string;
9
+ joined: string;
10
+ }
11
+
12
+ const data: Person[] = [
13
+ {
14
+ name: "Ada Lovelace",
15
+ role: "Engineer",
16
+ location: "London",
17
+ joined: "1843",
18
+ },
19
+ {
20
+ name: "Alan Turing",
21
+ role: "Mathematician",
22
+ location: "Manchester",
23
+ joined: "1936",
24
+ },
25
+ {
26
+ name: "Grace Hopper",
27
+ role: "Admiral",
28
+ location: "New York",
29
+ joined: "1944",
30
+ },
31
+ {
32
+ name: "Katherine Johnson",
33
+ role: "Mathematician",
34
+ location: "Hampton",
35
+ joined: "1953",
36
+ },
37
+ { name: "Hedy Lamarr", role: "Inventor", location: "Vienna", joined: "1942" },
38
+ {
39
+ name: "Claude Shannon",
40
+ role: "Engineer",
41
+ location: "Michigan",
42
+ joined: "1948",
43
+ },
44
+ {
45
+ name: "John von Neumann",
46
+ role: "Mathematician",
47
+ location: "Budapest",
48
+ joined: "1945",
49
+ },
50
+ {
51
+ name: "Margaret Hamilton",
52
+ role: "Engineer",
53
+ location: "Boston",
54
+ joined: "1961",
55
+ },
56
+ {
57
+ name: "Dennis Ritchie",
58
+ role: "Engineer",
59
+ location: "New Jersey",
60
+ joined: "1972",
61
+ },
62
+ {
63
+ name: "Barbara Liskov",
64
+ role: "Researcher",
65
+ location: "California",
66
+ joined: "1968",
67
+ },
68
+ {
69
+ name: "Donald Knuth",
70
+ role: "Author",
71
+ location: "Stanford",
72
+ joined: "1968",
73
+ },
74
+ {
75
+ name: "Linus Torvalds",
76
+ role: "Engineer",
77
+ location: "Helsinki",
78
+ joined: "1991",
79
+ },
80
+ {
81
+ name: "Radia Perlman",
82
+ role: "Engineer",
83
+ location: "Virginia",
84
+ joined: "1985",
85
+ },
86
+ {
87
+ name: "Tim Berners-Lee",
88
+ role: "Engineer",
89
+ location: "Geneva",
90
+ joined: "1989",
91
+ },
92
+ {
93
+ name: "Anita Borg",
94
+ role: "Researcher",
95
+ location: "California",
96
+ joined: "1986",
97
+ },
98
+ ];
99
+
100
+ const columns: ColumnDef<Person>[] = [
101
+ { accessorKey: "name", header: "Name" },
102
+ { accessorKey: "role", header: "Role" },
103
+ { accessorKey: "location", header: "Location" },
104
+ { accessorKey: "joined", header: "Joined" },
105
+ ];
106
+ ---
107
+
108
+ <Table
109
+ data={data}
110
+ columns={columns}
111
+ caption="Pioneers — sorting and pagination on by default"
112
+ />
@@ -0,0 +1,99 @@
1
+ ---
2
+ import Table from "../table.astro";
3
+ import Button from "@pindoba/astro-button";
4
+ import type { ColumnDef } from "@tanstack/table-core";
5
+
6
+ interface Folder {
7
+ name: string;
8
+ size: string;
9
+ type: string;
10
+ children?: Folder[];
11
+ }
12
+
13
+ const raw: Folder[] = [
14
+ {
15
+ name: "src",
16
+ size: "—",
17
+ type: "folder",
18
+ children: [
19
+ {
20
+ name: "components",
21
+ size: "—",
22
+ type: "folder",
23
+ children: [
24
+ { name: "button.tsx", size: "2.1 KB", type: "file" },
25
+ { name: "table.tsx", size: "8.4 KB", type: "file" },
26
+ ],
27
+ },
28
+ { name: "index.ts", size: "340 B", type: "file" },
29
+ ],
30
+ },
31
+ {
32
+ name: "docs",
33
+ size: "—",
34
+ type: "folder",
35
+ children: [
36
+ { name: "README.md", size: "4.2 KB", type: "file" },
37
+ { name: "CHANGELOG.md", size: "1.8 KB", type: "file" },
38
+ ],
39
+ },
40
+ { name: "package.json", size: "1.1 KB", type: "file" },
41
+ ];
42
+
43
+ // Precompute the icon into `name` so the declarative `data-table-bind`
44
+ // template picks it up — `applyRowBindings` doesn't do conditional rendering.
45
+ function withIcons(rows: Folder[]): Folder[] {
46
+ return rows.map((row) => ({
47
+ ...row,
48
+ name: `${row.type === "folder" ? "📁" : "📄"} ${row.name}`,
49
+ children: row.children ? withIcons(row.children) : undefined,
50
+ }));
51
+ }
52
+
53
+ const data = withIcons(raw);
54
+
55
+ const columns: ColumnDef<Folder>[] = [
56
+ { id: "expand", header: "", cell: () => "", enableSorting: false },
57
+ { accessorKey: "name", header: "Name" },
58
+ { accessorKey: "size", header: "Size" },
59
+ { accessorKey: "type", header: "Type" },
60
+ ];
61
+ ---
62
+
63
+ <Table
64
+ data={data}
65
+ columns={columns}
66
+ enableExpanding
67
+ enablePagination={false}
68
+ getSubRows={(row) => row.children}
69
+ caption="Click › to expand folders"
70
+ >
71
+ <template data-table-cell-template="expand">
72
+ <span data-table-indent>
73
+ <Button
74
+ type="button"
75
+ size="xs"
76
+ emphasis="ghost"
77
+ shape="square"
78
+ aria-label="Toggle"
79
+ passThrough={{ root: { props: { "data-table-expand": "" } } }}
80
+ >
81
+ <svg
82
+ xmlns="http://www.w3.org/2000/svg"
83
+ viewBox="0 0 24 24"
84
+ fill="none"
85
+ stroke="currentColor"
86
+ stroke-width="2"
87
+ stroke-linecap="round"
88
+ stroke-linejoin="round"
89
+ aria-hidden="true"
90
+ >
91
+ <path d="m9 18 6-6-6-6"></path>
92
+ </svg>
93
+ </Button>
94
+ </span>
95
+ </template>
96
+ <template data-table-cell-template="name">
97
+ <span data-table-bind="row.name"></span>
98
+ </template>
99
+ </Table>
@@ -0,0 +1,46 @@
1
+ ---
2
+ import Table from "../table.astro";
3
+ import type { ColumnDef } from "@tanstack/table-core";
4
+
5
+ interface Package {
6
+ name: string;
7
+ version: string;
8
+ downloads: number;
9
+ downloadsFormatted: string;
10
+ license: string;
11
+ }
12
+
13
+ const raw = [
14
+ { name: "react", version: "19.0.0", downloads: 28_500_000, license: "MIT" },
15
+ { name: "vue", version: "3.5.0", downloads: 5_900_000, license: "MIT" },
16
+ { name: "svelte", version: "5.0.0", downloads: 1_200_000, license: "MIT" },
17
+ { name: "angular", version: "18.0.0", downloads: 3_400_000, license: "MIT" },
18
+ { name: "solid-js", version: "1.8.0", downloads: 180_000, license: "MIT" },
19
+ { name: "preact", version: "10.22.0", downloads: 950_000, license: "MIT" },
20
+ { name: "qwik", version: "1.6.0", downloads: 45_000, license: "MIT" },
21
+ { name: "lit", version: "3.1.0", downloads: 720_000, license: "BSD-3" },
22
+ { name: "ember", version: "5.10.0", downloads: 95_000, license: "MIT" },
23
+ { name: "alpine", version: "3.14.0", downloads: 120_000, license: "MIT" },
24
+ ];
25
+
26
+ const data: Package[] = raw.map((p) => ({
27
+ ...p,
28
+ downloadsFormatted: p.downloads.toLocaleString("en-US"),
29
+ }));
30
+
31
+ const columns: ColumnDef<Package>[] = [
32
+ { accessorKey: "name", header: "Package" },
33
+ { accessorKey: "version", header: "Version" },
34
+ { accessorKey: "downloadsFormatted", header: "Weekly Downloads" },
35
+ { accessorKey: "license", header: "License" },
36
+ ];
37
+ ---
38
+
39
+ <Table
40
+ data={data}
41
+ columns={columns}
42
+ caption="Type in the search box to filter rows across all columns"
43
+ showGlobalFilter
44
+ globalFilterPlaceholder="Search packages…"
45
+ pageSize={5}
46
+ />
@@ -0,0 +1,45 @@
1
+ ---
2
+ import Table from "../table.astro";
3
+ import type { ColumnDef } from "@tanstack/table-core";
4
+
5
+ interface Sale {
6
+ region: string;
7
+ product: string;
8
+ quantity: number;
9
+ revenue: number;
10
+ }
11
+
12
+ const data: Sale[] = [
13
+ { region: "North", product: "Widget", quantity: 12, revenue: 240 },
14
+ { region: "North", product: "Gizmo", quantity: 8, revenue: 320 },
15
+ { region: "North", product: "Sprocket", quantity: 5, revenue: 150 },
16
+ { region: "South", product: "Widget", quantity: 20, revenue: 400 },
17
+ { region: "South", product: "Gizmo", quantity: 14, revenue: 560 },
18
+ { region: "East", product: "Widget", quantity: 9, revenue: 180 },
19
+ { region: "East", product: "Sprocket", quantity: 11, revenue: 330 },
20
+ { region: "West", product: "Gizmo", quantity: 16, revenue: 640 },
21
+ { region: "West", product: "Sprocket", quantity: 7, revenue: 210 },
22
+ ];
23
+
24
+ // `cell` and `aggregationFn` functions can't cross the SSR → mountTable
25
+ // boundary; the hydrator strips them. mountTable still renders grouped /
26
+ // aggregated cells natively (folder-style expand toggle for grouped, `<em>`
27
+ // wrap for aggregated values), so the table works without explicit slots.
28
+ const columns: ColumnDef<Sale>[] = [
29
+ { accessorKey: "region", header: "Region", enableGrouping: true },
30
+ { accessorKey: "product", header: "Product" },
31
+ { accessorKey: "quantity", header: "Qty", aggregationFn: "sum" },
32
+ { accessorKey: "revenue", header: "Revenue", aggregationFn: "sum" },
33
+ ];
34
+ ---
35
+
36
+ <Table
37
+ data={data}
38
+ columns={columns}
39
+ enableGrouping
40
+ enableExpanding
41
+ enablePagination={false}
42
+ initialState={{ grouping: ["region"], expanded: true }}
43
+ caption="Sales grouped by region (click › to collapse)"
44
+ bordered
45
+ />