Skip to content

Commit 6f41542

Browse files
authored
perf(web): improve frontend table rendering and pinned columns/UI table (#5405)
* refactor(web): centralize data table implementation - route all TanStack table setup through a shared data-table hook to remove repeated state and row model wiring. - move table rendering, static table wrappers, empty states, and primitive exports behind the data-table module. - update feature tables and configuration editors to share the same table UX while preserving their existing workflows. * refactor(web): trim data table public API - remove unused data-table exports and dead static table helper types. - keep internal table header, skeleton, empty state, and faceted filter helpers private to the data-table module. - route feature imports through the data-table barrel to avoid subpath coupling. * refactor(web): unify table rendering components - centralize static table headers, bodies, empty states, and shared class names behind the data-table package. - migrate settings, pricing, channel, key, subscription, and model tables to the shared table APIs. - remove data-table exports for low-level table primitives so feature code uses one supported abstraction. * perf(web): keep list tables fixed within page content - make shared data table pages fill available height and scroll row data inside the table body. - add a fixed content layout mode so selected list pages avoid page-level scrolling. - apply the fixed table behavior to keys, logs, channels, models, users, redemptions, and subscriptions. * perf(web): refine table pagination controls - show total row counts instead of redundant page range text. - tighten visible page buttons so pagination fits constrained table widths. - align pagination controls and tune text hierarchy for clearer scanning. * perf(web): stabilize model pricing table columns - keep model pricing columns at fixed widths so headers do not collapse in narrow layouts. - truncate long model names and pricing summaries within their cells instead of squeezing adjacent columns. * refactor(web): simplify data table rendering internals - split table body rendering into focused helpers for loading, empty, and row states. - extract static table row and cell class resolution to reduce branching in the main component. - reuse a single pagination page-size option list to avoid duplicated constants. * perf(pricing): reduce dynamic pricing table render work - reuse dynamic pricing field metadata instead of rebuilding it inside table columns. - precompute formatted dynamic prices per tier and group to avoid repeated entry mapping for each cell. - simplify select option construction in related dialogs while preserving the same choices. * refactor(web): streamline pricing table rendering - reuse translated endpoint select options between trigger data and menu items. - precompute dynamic pricing maps per group so table cells only resolve formatted values. - add local dynamic pricing type aliases to keep helper signatures readable. * refactor(web): merge pricing table imports * refactor(web): merge upstream ratio table imports * refactor(web): merge channel selector table imports * refactor(web): simplify tiered pricing select items * refactor(web): reuse model ratio row state * refactor(web): rely on table view row defaults * refactor(web): reuse pagination state values * refactor(web): hoist pagination size select items * refactor(web): clarify static table body rows * refactor(web): extract table page pagination rendering * fix(web): remove direct hast type dependency - rely on Shiki transformer contextual typing for line nodes. - allow frontend typecheck to pass without an undeclared hast package. * refactor(web): trim data table hook return API - return only the TanStack table instance from useDataTable. - keep internal state handling private because callers do not consume it directly. * refactor(web): keep static table empty row private - stop exporting the internal StaticDataTableEmptyRow helper. - keep the public static table API focused on the table component and column type. * refactor(web): hide data table view props from barrel * refactor(web): remove stale long text lint override * fix(web): keep pinned table columns opaque - apply pinned column background classes after custom column classes. - use an opaque hover background so scrolled content cannot show through fixed cells. * refactor(data-table): organize shared table components - group table primitives, page composition, toolbar controls, static tables, and hooks by responsibility. - split shared view types, row rendering, header rendering, and pinned-column styling out of the main table view. - keep the public data-table barrel stable while documenting the new ownership boundaries. * fix(web): stabilize split table column sizing - derive default colgroup widths from visible columns when split headers or header sizing are enabled. - apply a fixed table layout with computed minimum width so header and body columns stay aligned. - keep split-header containers from leaking horizontal overflow and avoid extra pinned-column borders. * fix(web): set stable table utility column widths - assign fixed widths to selection columns so shared colgroup sizing keeps checkbox cells compact. - size id columns in redemption and user tables to keep split headers aligned with body rows. * fix(web): align model metadata icon cells - render compact provider avatars in the metadata icon column instead of wide wordmarks. - position icons in a fixed-size wrapper so they line up with the existing icon header alignment. * fix(status-badge): hide status dot by default * fix(web): prevent user invite info overlap - give the invite info and created-at columns explicit widths so table sizing reserves enough space. - allow invite badges to wrap within the cell instead of spilling into adjacent columns. * perf(data-table): cache pinned column class resolution - reuse the pinned column lookup while table props stay stable to reduce repeated per-render work. - share the resolved column class handler across unified and split-header table layouts. - localize page-number screen reader labels so pagination remains accessible in every locale. * refactor(data-table): tighten static table modes - make StaticDataTable distinguish data-driven and children-only usage through explicit prop shapes. - remove unsupported columns-without-data fallback after confirming no repository callers rely on it. - default manual table modes away from unused local row models to reduce repeated table work. * fix(data-table): make pinned edit column opaque - use an opaque muted background for the active action column so sticky cells do not reveal scrolled content underneath. * fix(data-table): prevent narrow column overlap - apply stable header sizing to remaining desktop data table pages so constrained layouts scroll instead of compressing cells. - add explicit widths for key, quota, badge, and timestamp columns that contain fixed-format content. - constrain masked values and timestamp cells with truncation to keep content inside its assigned column. * fix(table): align table cell content with headers - remove extra inline padding from masked table text buttons so values start at the cell edge. - tag status badges and offset leading badges inside table cells to match header text alignment. * fix(table): prevent admin list column overflow - widen redemption and subscription table columns so masked codes, timestamps, and localized headers fit. - localize subscription ID headers and add Received amount translations across supported locales. * fix(provider-badge): unify provider icon spacing - add a shared provider badge component for icon and status label layout. - reuse it in channel type and model vendor columns so OpenAI icons align consistently.
1 parent 59a93cf commit 6f41542

97 files changed

Lines changed: 3963 additions & 3312 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

web/default/src/components/ai-elements/code-block.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
useEffect,
2828
useState,
2929
} from 'react'
30-
import type { Element } from 'hast'
3130
import { CheckIcon, CopyIcon } from 'lucide-react'
3231
import {
3332
type BundledLanguage,
@@ -53,7 +52,7 @@ const CodeBlockContext = createContext<CodeBlockContextType>({
5352

5453
const lineNumberTransformer: ShikiTransformer = {
5554
name: 'line-numbers',
56-
line(node: Element, line: number) {
55+
line(node, line) {
5756
node.children.unshift({
5857
type: 'element',
5958
tagName: 'span',
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Data Table Components
2+
3+
This package keeps a stable public API through `index.ts`; feature code should
4+
continue importing from `@/components/data-table`.
5+
6+
- `core/`: TanStack table rendering primitives, headers, rows, pagination,
7+
loading, empty states, and pinned-column behavior.
8+
- `layout/`: responsive page-level composition that combines toolbar, desktop
9+
table, mobile list, bulk actions, and pagination placement.
10+
- `toolbar/`: filter/search/view-option controls and selection action toolbar.
11+
- `static/`: lightweight table rendering for local/static arrays that do not
12+
need TanStack state.
13+
- `hooks/`: table state and filter hooks.
14+
15+
Keep feature-specific columns, actions, and dialogs inside their feature
16+
folders. Shared table code belongs here only when it is reusable across more
17+
than one feature.

web/default/src/components/data-table/column-header.tsx renamed to web/default/src/components/data-table/core/column-header.tsx

File renamed without changes.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
Copyright (C) 2023-2026 QuantumNous
3+
4+
This program is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU Affero General Public License as
6+
published by the Free Software Foundation, either version 3 of the
7+
License, or (at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU Affero General Public License for more details.
13+
14+
You should have received a copy of the GNU Affero General Public License
15+
along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
For commercial licensing, please contact support@quantumnous.com
18+
*/
19+
import { cn } from '@/lib/utils'
20+
import type { DataTableColumnClassName, DataTablePinnedColumn } from './types'
21+
22+
export function getResolvedColumnClassName(
23+
getColumnClassName?: DataTableColumnClassName,
24+
pinnedColumns?: DataTablePinnedColumn[]
25+
): DataTableColumnClassName {
26+
return getResolvedColumnClassNameFromMap(
27+
getColumnClassName,
28+
getPinnedColumnMap(pinnedColumns)
29+
)
30+
}
31+
32+
export function getResolvedColumnClassNameFromMap(
33+
getColumnClassName?: DataTableColumnClassName,
34+
pinnedColumnById?: Map<string, DataTablePinnedColumn>
35+
): DataTableColumnClassName {
36+
return (columnId, kind) => {
37+
const customClassName = getColumnClassName?.(columnId, kind)
38+
const pinnedColumn = pinnedColumnById?.get(columnId)
39+
40+
if (!pinnedColumn) return customClassName
41+
42+
return cn(customClassName, getPinnedColumnClassName(pinnedColumn, kind))
43+
}
44+
}
45+
46+
export function getPinnedColumnMap(pinnedColumns?: DataTablePinnedColumn[]) {
47+
if (!pinnedColumns?.length) return undefined
48+
49+
return new Map(pinnedColumns.map((column) => [column.columnId, column]))
50+
}
51+
52+
function getPinnedColumnClassName(
53+
pinnedColumn: DataTablePinnedColumn,
54+
kind: 'header' | 'cell'
55+
) {
56+
const edgeClassName =
57+
pinnedColumn.side === 'left'
58+
? 'shadow-[8px_0_10px_-10px_hsl(var(--foreground))]'
59+
: 'shadow-[-8px_0_10px_-10px_hsl(var(--foreground))]'
60+
61+
return cn(
62+
'sticky whitespace-nowrap',
63+
pinnedColumn.side === 'left' ? 'left-0' : 'right-0',
64+
edgeClassName,
65+
kind === 'header'
66+
? 'bg-background z-30'
67+
: 'bg-background z-10 group-hover:bg-muted group-data-[state=selected]:bg-muted',
68+
pinnedColumn.className,
69+
kind === 'header'
70+
? pinnedColumn.headerClassName
71+
: pinnedColumn.cellClassName
72+
)
73+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright (C) 2023-2026 QuantumNous
3+
4+
This program is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU Affero General Public License as
6+
published by the Free Software Foundation, either version 3 of the
7+
License, or (at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU Affero General Public License for more details.
13+
14+
You should have received a copy of the GNU Affero General Public License
15+
along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
For commercial licensing, please contact support@quantumnous.com
18+
*/
19+
import type { Table as TanstackTable } from '@tanstack/react-table'
20+
21+
export function DataTableColgroup<TData>({
22+
table,
23+
}: {
24+
table: TanstackTable<TData>
25+
}) {
26+
return (
27+
<colgroup>
28+
{table.getVisibleLeafColumns().map((column) => (
29+
<col key={column.id} style={{ width: column.getSize() }} />
30+
))}
31+
</colgroup>
32+
)
33+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Copyright (C) 2023-2026 QuantumNous
3+
4+
This program is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU Affero General Public License as
6+
published by the Free Software Foundation, either version 3 of the
7+
License, or (at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU Affero General Public License for more details.
13+
14+
You should have received a copy of the GNU Affero General Public License
15+
along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
For commercial licensing, please contact support@quantumnous.com
18+
*/
19+
import { flexRender, type Table as TanstackTable } from '@tanstack/react-table'
20+
import { TableHead, TableHeader, TableRow } from '@/components/ui/table'
21+
import type { DataTableColumnClassName } from './types'
22+
23+
type DataTableHeaderProps<TData> = {
24+
table: TanstackTable<TData>
25+
applyHeaderSize?: boolean
26+
className?: string
27+
rowClassName?: string
28+
getColumnClassName?: DataTableColumnClassName
29+
}
30+
31+
export function DataTableHeader<TData>({
32+
table,
33+
applyHeaderSize,
34+
className,
35+
rowClassName,
36+
getColumnClassName,
37+
}: DataTableHeaderProps<TData>) {
38+
return (
39+
<TableHeader className={className}>
40+
{table.getHeaderGroups().map((headerGroup) => (
41+
<TableRow key={headerGroup.id} className={rowClassName}>
42+
{headerGroup.headers.map((header) => (
43+
<TableHead
44+
key={header.id}
45+
colSpan={header.colSpan}
46+
className={getColumnClassName?.(header.column.id, 'header')}
47+
style={applyHeaderSize ? { width: header.getSize() } : undefined}
48+
>
49+
{header.isPlaceholder
50+
? null
51+
: flexRender(
52+
header.column.columnDef.header,
53+
header.getContext()
54+
)}
55+
</TableHead>
56+
))}
57+
</TableRow>
58+
))}
59+
</TableHeader>
60+
)
61+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Copyright (C) 2023-2026 QuantumNous
3+
4+
This program is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU Affero General Public License as
6+
published by the Free Software Foundation, either version 3 of the
7+
License, or (at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU Affero General Public License for more details.
13+
14+
You should have received a copy of the GNU Affero General Public License
15+
along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
For commercial licensing, please contact support@quantumnous.com
18+
*/
19+
import type * as React from 'react'
20+
import { flexRender, type Row } from '@tanstack/react-table'
21+
import { TableCell, TableRow } from '@/components/ui/table'
22+
import type { DataTableColumnClassName } from './types'
23+
24+
type DataTableRowProps<TData> = {
25+
row: Row<TData>
26+
className?: string
27+
getColumnClassName?: DataTableColumnClassName
28+
} & Omit<React.ComponentProps<typeof TableRow>, 'children'>
29+
30+
export function DataTableRow<TData>({
31+
row,
32+
className,
33+
getColumnClassName,
34+
...rowProps
35+
}: DataTableRowProps<TData>) {
36+
return (
37+
<TableRow
38+
data-state={row.getIsSelected() ? 'selected' : undefined}
39+
className={className}
40+
{...rowProps}
41+
>
42+
{row.getVisibleCells().map((cell) => (
43+
<TableCell
44+
key={cell.id}
45+
className={getColumnClassName?.(cell.column.id, 'cell')}
46+
>
47+
{flexRender(cell.column.columnDef.cell, cell.getContext())}
48+
</TableCell>
49+
))}
50+
</TableRow>
51+
)
52+
}

0 commit comments

Comments
 (0)