mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-17 01:20:28 +00:00
fix(dashboard): the Card is the only frame around a table (#20181)
* fix(dashboard): the Card is the only frame around a table
Owner decision of 2026-11-14 (item 3): tables inside a Card no longer draw a
frame of their own, and a bordered sub-panel around a table inside a Card
becomes a plain section.
- Cache → Semantic Cache: the Entries sub-panel loses its border and
background (title and spacing kept); CacheEntriesTab drops DataTableShell
for the kit TableLoadingRegion + a borderless Table (search and pagination
kept, search keeps the kit toolbar width).
- Cache → Prompt Cache: same for the "Breakdown by provider" sub-panel.
- Evals → suites: suites are sections of the card split by hairlines (kit
plain accordion pattern) instead of bordered boxes; the cases DataTable
uses framed={false}.
- Provider stats, cost overview (explorer + breakdown tables), resilience
cooldowns and the other kit Tables found inside a Card get
containerClassName="rounded-none border-0", the same borderless container
already used by #20141 and the analytics tables.
The AST guard now also covers Table inside Card, any depth (through
expressions, fragments and .map callbacks), and bordered elements between a
table and its Card. A jsdom test covers the two tables rendered by child
components (semantic cache entries, cooldowns).
Refs #19620
* test(dashboard): single-frame guard reads only static classes; stable translator mock
- The AST guard no longer searches the source text of a dynamic class
expression: only string literals and the literal parts of a template
count, so an inactive conditional branch can neither satisfy the
borderless check nor report a sub-panel (review on #20181). Fixtures added.
- The jsdom test returns one translator for every useTranslations call, so
the CacheEntriesTab fetch effect settles.
Refs #19620
* chore(ui-kit): sync vendored kit to 0.0.116
Upstream keak-ai/cheaper-inference-ui-kit#204 (closes #203): Table and
DataTable take `maxHeight`; the capped container scrolls on both axes,
pins the header row and takes focus while it overflows. No new dependency.
Refs #19620
* fix(dashboard): scroll tall tables through the kit Table maxHeight
Kit 0.0.116 (keak-ai/cheaper-inference-ui-kit#204) caps a Table with
`maxHeight`: the kit container scrolls both axes, pins the header row and
becomes a focusable, named region while it overflows (WCAG 2.1.1). Our own
scroll boxes never took focus, so keyboard users could not scroll them.
- DataTable adapter: the `<div style={{ maxHeight, overflow: "auto" }}>`
wrapper is gone; `maxHeight` goes to the kit Table, `!overflow-visible`
and the sticky/background patch on the header cells are dropped (the kit
pins and paints the header; `whitespace-nowrap` stays). New required
`label` prop names the scroll region; the five call sites pass a
translated string (evals recent runs and suite cases, conductor runners
and tasks, resilience connections).
- Kit Tables that capped themselves with `max-h-* overflow-y-auto` classes
or a capped wrapper now take `maxHeight` + a translated `scrollLabel`,
and lose their `sticky top-0` header patches: reasoning cache entries,
cache trend, import providers from file, OAuth export preview (the kit
container border replaces the wrapper's), proxy bulk import preview,
proxy bulk health check, proxy logger.
Tests: jsdom test for the adapter (capped container is a named tab stop,
no own scroll wrapper, no header patch, borderless when framed={false});
AST guard over the dashboard for class caps, capped wrappers and unnamed
capped tables. design-kit-bridge assertions aligned: the header colour and
the opaque viewport now come from the kit table.
Refs #19620
* test(dashboard): template classes count only when whitespace bounds them
A class written against an interpolation (`border-0${suffix}`) can render
as another class, so the single-frame guard no longer treats it as whole
(review on #20181). Fixtures for interpolations adjacent to `border-0` and
`border` added.
Refs #19620
This commit is contained in:
committed by
GitHub
parent
d286dff670
commit
19197b16c4
2
package-lock.json
generated
2
package-lock.json
generated
@@ -38153,7 +38153,7 @@
|
||||
},
|
||||
"packages/ui-kit": {
|
||||
"name": "@omniroute/ui-kit",
|
||||
"version": "0.0.115",
|
||||
"version": "0.0.116",
|
||||
"license": "UNLICENSED",
|
||||
"peerDependencies": {
|
||||
"lucide-react": ">=0.400.0 <2",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Upstream snapshot — @keak/cheaper-inference-ui-kit
|
||||
|
||||
- repo: https://github.com/keak-ai/cheaper-inference-ui-kit
|
||||
- commit: 940b0d28ea37740018acdf6df7c993663635f3d1
|
||||
- version: 0.0.115
|
||||
- upstream-date: 2026-11-13
|
||||
- synced: 2026-11-13
|
||||
- commit: 33891c6ec1738ec1e4682130c7911c54e67a4b22
|
||||
- version: 0.0.116
|
||||
- upstream-date: 2026-11-14
|
||||
- synced: 2026-11-14
|
||||
- license-authorization: Diego Souza (Keak, dono do repositório), 2026-10-19, por escrito na sessão de planejamento: "a licença está ok e da nossa empresa e livre para esse uso" — kit da própria empresa, autorizado para redistribuição neste repositório MIT.
|
||||
|
||||
Fonte consumida (sem build): `src/` é cópia byte a byte do commit acima, exceto pela única
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@omniroute/ui-kit",
|
||||
"version": "0.0.115",
|
||||
"version": "0.0.116",
|
||||
"private": true,
|
||||
"license": "UNLICENSED",
|
||||
"description": "Vendored snapshot of @keak/cheaper-inference-ui-kit (see UPSTREAM.md). Source is consumed directly; no build.",
|
||||
|
||||
@@ -1423,11 +1423,31 @@
|
||||
outline-offset: calc(-1 * var(--ci-focus-ring-width));
|
||||
}
|
||||
|
||||
/* maxHeight bounds the container, so it scrolls on both axes (and takes focus while it does)
|
||||
with the header row pinned above the rows. The header cells sit above the sticky end cells. */
|
||||
.ci-table-container[data-capped] { max-block-size: var(--ci-table-max-height); overflow: auto; isolation: isolate; }
|
||||
/* The table paints under the container's own outline, so the pinned header cells cannot cover
|
||||
the inset focus outline. Clicks and hover still reach the cells. */
|
||||
.ci-table-container[data-capped] > .ci-table { position: relative; z-index: -1; }
|
||||
.ci-table-container[data-capped] > .ci-table > .ci-table__header .ci-table__head {
|
||||
position: sticky;
|
||||
inset-block-start: 0;
|
||||
z-index: 3;
|
||||
background: var(--ci-color-surface-subtle);
|
||||
box-shadow: inset 0 calc(-1 * var(--ci-border-default)) 0 var(--ci-color-border-subtle);
|
||||
}
|
||||
.ci-table-container[data-capped] > .ci-table > .ci-table__header .ci-table__head--sticky-end {
|
||||
z-index: 4;
|
||||
box-shadow: -1px 0 0 var(--ci-color-border-subtle), inset 0 calc(-1 * var(--ci-border-default)) 0 var(--ci-color-border-subtle);
|
||||
}
|
||||
|
||||
.ci-table-scroll-area { width: 100%; min-width: 0; }
|
||||
.ci-table-scroll-area > .ci-table-container,
|
||||
.ci-table-scroll-area > .ci-table-loading-region > [data-slot="table-loading-content"] > .ci-table-container { scrollbar-width: none; }
|
||||
.ci-table-scroll-area > .ci-table-container::-webkit-scrollbar,
|
||||
.ci-table-scroll-area > .ci-table-loading-region > [data-slot="table-loading-content"] > .ci-table-container::-webkit-scrollbar { display: none; }
|
||||
/* The top scrollbar replaces the native one, except on a capped container: its bottom edge stays
|
||||
in view and its vertical scrollbar has no replacement. */
|
||||
.ci-table-scroll-area > .ci-table-container:not([data-capped]),
|
||||
.ci-table-scroll-area > .ci-table-loading-region > [data-slot="table-loading-content"] > .ci-table-container:not([data-capped]) { scrollbar-width: none; }
|
||||
.ci-table-scroll-area > .ci-table-container:not([data-capped])::-webkit-scrollbar,
|
||||
.ci-table-scroll-area > .ci-table-loading-region > [data-slot="table-loading-content"] > .ci-table-container:not([data-capped])::-webkit-scrollbar { display: none; }
|
||||
.ci-table-scrollbar {
|
||||
position: relative;
|
||||
display: block;
|
||||
|
||||
@@ -43,6 +43,8 @@ export interface DataTableProps<Row> {
|
||||
initialSort?: { id: string; direction: "asc" | "desc" };
|
||||
note?: ReactNode;
|
||||
className?: string;
|
||||
/** Caps the table height so the rows scroll under a pinned header. See `Table`. */
|
||||
maxHeight?: string | number;
|
||||
}
|
||||
|
||||
function compare(a: DataTableValue, b: DataTableValue) {
|
||||
@@ -74,6 +76,7 @@ export function DataTable<Row>({
|
||||
initialSort,
|
||||
note,
|
||||
className,
|
||||
maxHeight,
|
||||
}: DataTableProps<Row>) {
|
||||
const [query, setQuery] = useState("");
|
||||
const [page, setPage] = useState(1);
|
||||
@@ -117,7 +120,7 @@ export function DataTable<Row>({
|
||||
</div>
|
||||
<span className="ci-data-table__count" aria-live="polite">{filtered.length} results</span>
|
||||
</div>
|
||||
<Table aria-label={ariaLabel} loading={loading} loadingLabel={loadingLabel}>
|
||||
<Table aria-label={ariaLabel} loading={loading} loadingLabel={loadingLabel} maxHeight={maxHeight}>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
{columns.map((column) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useId, useState } from "react";
|
||||
import type { ComponentProps } from "react";
|
||||
import type { ComponentProps, CSSProperties } from "react";
|
||||
import { ExternalLink } from "lucide-react";
|
||||
import { cn } from "./lib/utils";
|
||||
import { TableLoadingRegion, type TableLoadingRegionProps } from "./table-loading";
|
||||
@@ -16,8 +16,16 @@ export interface TableProps extends ComponentProps<"table"> {
|
||||
loadingIndicator?: TableLoadingRegionProps["loadingIndicator"];
|
||||
/** Accessible noun phrase used for the persistent horizontal scrollbar. */
|
||||
scrollbarLabel?: string;
|
||||
/** Set false to use the browser's native horizontal scrollbar only. */
|
||||
/**
|
||||
* Set false to use the browser's native horizontal scrollbar only. Defaults to true, or to
|
||||
* false when `maxHeight` is set, because a capped table keeps its native scrollbars in view.
|
||||
*/
|
||||
persistentScrollbars?: boolean;
|
||||
/**
|
||||
* Caps the height of the scroll container (a number is pixels). The rows then scroll inside
|
||||
* it, under a header row that stays in view, and the container takes focus while it overflows.
|
||||
*/
|
||||
maxHeight?: string | number;
|
||||
/**
|
||||
* Accessible name of the scroll container while the table overflows. When omitted, the
|
||||
* container is named by the table caption, then by the table's own `aria-labelledby` or
|
||||
@@ -81,7 +89,8 @@ export function Table({
|
||||
className,
|
||||
containerClassName,
|
||||
scrollbarLabel = "Table",
|
||||
persistentScrollbars = true,
|
||||
maxHeight,
|
||||
persistentScrollbars = maxHeight === undefined,
|
||||
scrollLabel,
|
||||
loading,
|
||||
loadingLabel,
|
||||
@@ -102,12 +111,17 @@ export function Table({
|
||||
? { "aria-label": props["aria-label"] }
|
||||
: undefined;
|
||||
const scrollProps = overflowing ? { tabIndex: 0, ...(name ? { role: "region", ...name } : {}) } : {};
|
||||
const capProps = maxHeight === undefined ? {} : {
|
||||
"data-capped": "",
|
||||
style: { "--ci-table-max-height": typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight } as CSSProperties,
|
||||
};
|
||||
const table = (
|
||||
<div
|
||||
ref={setContainer}
|
||||
data-slot="table-container"
|
||||
data-overflowing={overflowing || undefined}
|
||||
className={cn("ci-table-container", containerClassName)}
|
||||
{...capProps}
|
||||
{...scrollProps}
|
||||
>
|
||||
<table data-slot="table" className={cn("ci-table", className)} {...props} />
|
||||
|
||||
@@ -436,6 +436,7 @@ export default function BatchListTab({
|
||||
className="text-sm"
|
||||
aria-label={t("batchListBatchesTable")}
|
||||
scrollbarLabel={t("batchListBatchesTable")}
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
|
||||
@@ -190,6 +190,7 @@ export default function FilesListTab({
|
||||
className="text-sm"
|
||||
aria-label={t("batchFilesListFilesTable")}
|
||||
scrollbarLabel={t("batchFilesListFilesTable")}
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { DataTableShell } from "@omniroute/ui-kit/data-table-shell";
|
||||
import { TableLoadingRegion } from "@omniroute/ui-kit/table-loading";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -95,28 +95,87 @@ export default function CacheEntriesTab() {
|
||||
return new Date(dateStr).toLocaleString();
|
||||
};
|
||||
|
||||
// The Semantic Cache card is the only frame (#19620): the kit loading region and a
|
||||
// borderless Table, not a DataTableShell, whose own frame would draw a second border.
|
||||
return (
|
||||
<DataTableShell
|
||||
loading={loading}
|
||||
loadingLabel={t("loading")}
|
||||
filters={
|
||||
<div className="flex w-full items-end gap-3">
|
||||
<Input
|
||||
type="text"
|
||||
className="flex-1"
|
||||
aria-label={t("searchEntries")}
|
||||
placeholder={t("searchEntries")}
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && fetchEntries()}
|
||||
/>
|
||||
<Button variant="secondary" size="sm" onClick={() => fetchEntries()}>
|
||||
{t("search")}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
pagination={
|
||||
pagination.totalPages > 1 ? (
|
||||
<div>
|
||||
{/* Same width as the kit toolbar filters (fit-content), so the search keeps its size. */}
|
||||
<div className="mb-3 flex w-fit max-w-full items-end gap-3">
|
||||
<Input
|
||||
type="text"
|
||||
className="flex-1"
|
||||
aria-label={t("searchEntries")}
|
||||
placeholder={t("searchEntries")}
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && fetchEntries()}
|
||||
/>
|
||||
<Button variant="secondary" size="sm" onClick={() => fetchEntries()}>
|
||||
{t("search")}
|
||||
</Button>
|
||||
</div>
|
||||
<TableLoadingRegion loading={loading} loadingLabel={t("loading")}>
|
||||
{error ? (
|
||||
<div className="flex items-center justify-between gap-3 rounded-lg border border-error/30 bg-error-bg px-4 py-3">
|
||||
<div className="text-sm text-error">{error}</div>
|
||||
<Button variant="secondary" size="sm" onClick={() => fetchEntries(pagination.page)}>
|
||||
{t("refresh")}
|
||||
</Button>
|
||||
</div>
|
||||
) : !loading && entries.length === 0 ? (
|
||||
<div className="py-8 text-center text-sm text-text-muted">{t("noEntries")}</div>
|
||||
) : (
|
||||
<Table
|
||||
className="text-sm"
|
||||
scrollbarLabel={t("entries")}
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("signature")}</TableHead>
|
||||
<TableHead>{t("model")}</TableHead>
|
||||
<TableHead>{t("hits")}</TableHead>
|
||||
<TableHead>{t("tokensSaved")}</TableHead>
|
||||
<TableHead>{t("created")}</TableHead>
|
||||
<TableHead>{t("expires")}</TableHead>
|
||||
<TableHead>{t("actions")}</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{entries.map((entry) => (
|
||||
<TableRow key={entry.id}>
|
||||
<TableCell className="font-mono text-xs">
|
||||
{entry.signature.slice(0, 12)}...
|
||||
</TableCell>
|
||||
<TableCell>{entry.model}</TableCell>
|
||||
<TableCell className="tabular-nums">{entry.hit_count}</TableCell>
|
||||
<TableCell className="tabular-nums text-success">
|
||||
{(entry.tokens_saved ?? 0).toLocaleString()}
|
||||
</TableCell>
|
||||
<TableCell className="text-xs text-text-muted">
|
||||
{formatDate(entry.created_at)}
|
||||
</TableCell>
|
||||
<TableCell className="text-xs text-text-muted">
|
||||
{formatDate(entry.expires_at)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Button
|
||||
variant="destructive-ghost"
|
||||
size="icon"
|
||||
icon="delete"
|
||||
aria-label={tc("delete")}
|
||||
title={tc("delete")}
|
||||
onClick={() => handleDelete(entry.signature)}
|
||||
disabled={deleting === entry.signature}
|
||||
loading={deleting === entry.signature}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
)}
|
||||
{pagination.totalPages > 1 ? (
|
||||
<div className="flex items-center justify-center gap-2 py-3">
|
||||
<Button
|
||||
variant="secondary"
|
||||
@@ -138,65 +197,8 @@ export default function CacheEntriesTab() {
|
||||
disabled={pagination.page >= pagination.totalPages}
|
||||
/>
|
||||
</div>
|
||||
) : undefined
|
||||
}
|
||||
>
|
||||
{error ? (
|
||||
<div className="flex items-center justify-between gap-3 rounded-lg border border-error/30 bg-error-bg px-4 py-3">
|
||||
<div className="text-sm text-error">{error}</div>
|
||||
<Button variant="secondary" size="sm" onClick={() => fetchEntries(pagination.page)}>
|
||||
{t("refresh")}
|
||||
</Button>
|
||||
</div>
|
||||
) : !loading && entries.length === 0 ? (
|
||||
<div className="py-8 text-center text-sm text-text-muted">{t("noEntries")}</div>
|
||||
) : (
|
||||
<Table className="text-sm" scrollbarLabel={t("entries")}>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("signature")}</TableHead>
|
||||
<TableHead>{t("model")}</TableHead>
|
||||
<TableHead>{t("hits")}</TableHead>
|
||||
<TableHead>{t("tokensSaved")}</TableHead>
|
||||
<TableHead>{t("created")}</TableHead>
|
||||
<TableHead>{t("expires")}</TableHead>
|
||||
<TableHead>{t("actions")}</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{entries.map((entry) => (
|
||||
<TableRow key={entry.id}>
|
||||
<TableCell className="font-mono text-xs">
|
||||
{entry.signature.slice(0, 12)}...
|
||||
</TableCell>
|
||||
<TableCell>{entry.model}</TableCell>
|
||||
<TableCell className="tabular-nums">{entry.hit_count}</TableCell>
|
||||
<TableCell className="tabular-nums text-success">
|
||||
{(entry.tokens_saved ?? 0).toLocaleString()}
|
||||
</TableCell>
|
||||
<TableCell className="text-xs text-text-muted">
|
||||
{formatDate(entry.created_at)}
|
||||
</TableCell>
|
||||
<TableCell className="text-xs text-text-muted">
|
||||
{formatDate(entry.expires_at)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Button
|
||||
variant="destructive-ghost"
|
||||
size="icon"
|
||||
icon="delete"
|
||||
aria-label={tc("delete")}
|
||||
title={tc("delete")}
|
||||
onClick={() => handleDelete(entry.signature)}
|
||||
disabled={deleting === entry.signature}
|
||||
loading={deleting === entry.signature}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
)}
|
||||
</DataTableShell>
|
||||
) : null}
|
||||
</TableLoadingRegion>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -397,7 +397,8 @@ export default function ReasoningCacheTab() {
|
||||
) : (
|
||||
<Table
|
||||
className="text-sm"
|
||||
containerClassName="max-h-96 overflow-y-auto"
|
||||
maxHeight="24rem"
|
||||
scrollLabel={t("reasoningRecentEntries")}
|
||||
scrollbarLabel={t("reasoningRecentEntries")}
|
||||
>
|
||||
<TableHeader className="sticky top-0 z-10 bg-surface">
|
||||
|
||||
14
src/app/(dashboard)/dashboard/cache/page.tsx
vendored
14
src/app/(dashboard)/dashboard/cache/page.tsx
vendored
@@ -273,10 +273,12 @@ function PromptTrendPanel({
|
||||
|
||||
<Table
|
||||
className="text-sm"
|
||||
containerClassName="mt-5 max-h-80 overflow-y-auto"
|
||||
containerClassName="mt-5"
|
||||
maxHeight="20rem"
|
||||
scrollLabel={title}
|
||||
scrollbarLabel={title}
|
||||
>
|
||||
<TableHeader className="sticky top-0 z-10 bg-surface">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead className="w-[84px]">{hourLabel}</TableHead>
|
||||
<TableHead>{activityLabel}</TableHead>
|
||||
@@ -533,7 +535,8 @@ export default function CachePage() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="w-full rounded-xl border border-border bg-bg-subtle p-5">
|
||||
{/* A plain section: the Card is the only frame around the table (#19620). */}
|
||||
<div className="w-full">
|
||||
<div>
|
||||
<h3 className="text-sm font-medium text-text-main">{t("byProvider")}</h3>
|
||||
<p className="mt-1 text-sm text-text-muted">{t("providerCacheRateDesc")}</p>
|
||||
@@ -542,7 +545,7 @@ export default function CachePage() {
|
||||
{providerEntries.length > 0 ? (
|
||||
<Table
|
||||
className="text-sm"
|
||||
containerClassName="mt-3"
|
||||
containerClassName="mt-3 rounded-none border-0"
|
||||
scrollbarLabel={t("byProvider")}
|
||||
>
|
||||
<TableHeader>
|
||||
@@ -785,7 +788,8 @@ export default function CachePage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="rounded-xl border border-border bg-bg-subtle p-5">
|
||||
{/* A plain section: the Card is the only frame around the entries (#19620). */}
|
||||
<div>
|
||||
<div className="mb-4 flex flex-col gap-1">
|
||||
<h3 className="text-sm font-medium text-text-main">{t("entries")}</h3>
|
||||
<p className="text-sm text-text-muted">{t("semanticEntriesDesc")}</p>
|
||||
|
||||
@@ -139,6 +139,7 @@ export default function ConductorPageClient() {
|
||||
<>
|
||||
<Card title={t("runners")}>
|
||||
<DataTable
|
||||
label={t("runners")}
|
||||
framed={false}
|
||||
columns={[
|
||||
{ key: "name", label: t("colName") },
|
||||
@@ -173,6 +174,7 @@ export default function ConductorPageClient() {
|
||||
|
||||
<Card title={t("tasks")}>
|
||||
<DataTable
|
||||
label={t("tasks")}
|
||||
framed={false}
|
||||
columns={[
|
||||
{ key: "id", label: t("colTask") },
|
||||
|
||||
@@ -1113,7 +1113,11 @@ function CostExplorerCard({
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<Table scrollbarLabel={t("costExplorerTitle")} className="min-w-205">
|
||||
<Table
|
||||
scrollbarLabel={t("costExplorerTitle")}
|
||||
className="min-w-205"
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
{columns.map((column) => (
|
||||
@@ -1263,7 +1267,7 @@ function CostBreakdownTable({
|
||||
<h3 className="text-sm font-semibold text-text-muted uppercase tracking-wide mb-4">
|
||||
{title}
|
||||
</h3>
|
||||
<Table scrollbarLabel={title}>
|
||||
<Table scrollbarLabel={title} containerClassName="rounded-none border-0">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
{columns.map((column) => (
|
||||
|
||||
@@ -445,7 +445,7 @@ export default function A2ADashboardPage() {
|
||||
<p className="text-sm text-text-muted">{t("noTasksForFilters")}</p>
|
||||
) : (
|
||||
<div className="overflow-x-auto">
|
||||
<Table scrollbarLabel={t("taskManagement")}>
|
||||
<Table scrollbarLabel={t("taskManagement")} containerClassName="rounded-none border-0">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("tableTask")}</TableHead>
|
||||
|
||||
@@ -543,7 +543,7 @@ export default function McpDashboardPage() {
|
||||
<Card className="p-5">
|
||||
<h2 className="text-lg font-semibold mb-4">{t("toolsAndScopes")}</h2>
|
||||
<div className="overflow-x-auto">
|
||||
<Table scrollbarLabel={t("toolsAndScopes")}>
|
||||
<Table scrollbarLabel={t("toolsAndScopes")} containerClassName="rounded-none border-0">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("tableTool")}</TableHead>
|
||||
@@ -620,7 +620,7 @@ export default function McpDashboardPage() {
|
||||
<p className="text-sm text-text-muted">{t("noAuditEntriesForFilters")}</p>
|
||||
) : (
|
||||
<div className="overflow-x-auto">
|
||||
<Table scrollbarLabel={t("auditLog")}>
|
||||
<Table scrollbarLabel={t("auditLog")} containerClassName="rounded-none border-0">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("tableTimestamp")}</TableHead>
|
||||
|
||||
@@ -256,7 +256,11 @@ export default function FreeProviderRankingsPage() {
|
||||
{/* Full List */}
|
||||
{displayedRankings.length > 0 && (
|
||||
<Card>
|
||||
<Table className="min-w-0" scrollbarLabel={t("title")}>
|
||||
<Table
|
||||
className="min-w-0"
|
||||
scrollbarLabel={t("title")}
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead className="w-16">{t("colRank")}</TableHead>
|
||||
|
||||
@@ -61,7 +61,11 @@ export default function GamificationAdminPage() {
|
||||
{t("noAnomaliesDetected")}
|
||||
</div>
|
||||
) : (
|
||||
<Table className="min-w-0" scrollbarLabel={t("flaggedAnomalies")}>
|
||||
<Table
|
||||
className="min-w-0"
|
||||
scrollbarLabel={t("flaggedAnomalies")}
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("apiKey")}</TableHead>
|
||||
|
||||
@@ -213,7 +213,11 @@ export default function LeaderboardPage() {
|
||||
{/* Rest of leaderboard table */}
|
||||
{rest.length > 0 && (
|
||||
<Card>
|
||||
<Table className="min-w-0" scrollbarLabel={tg("rank")}>
|
||||
<Table
|
||||
className="min-w-0"
|
||||
scrollbarLabel={tg("rank")}
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead className="w-16">{tg("rank")}</TableHead>
|
||||
|
||||
@@ -458,7 +458,11 @@ export default function MemoriesTab() {
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<Table aria-label={t("memories")} scrollbarLabel={t("memories")}>
|
||||
<Table
|
||||
aria-label={t("memories")}
|
||||
scrollbarLabel={t("memories")}
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("type")}</TableHead>
|
||||
|
||||
@@ -43,7 +43,11 @@ export function OmniExecutionsTab({
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<Table aria-label={t("executionsTab")} scrollbarLabel={t("executionsTab")}>
|
||||
<Table
|
||||
aria-label={t("executionsTab")}
|
||||
scrollbarLabel={t("executionsTab")}
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("skill")}</TableHead>
|
||||
|
||||
@@ -309,7 +309,7 @@ export default function ProviderStatsPage() {
|
||||
}
|
||||
/>
|
||||
|
||||
<Table scrollbarLabel={t("providerBreakdown")}>
|
||||
<Table scrollbarLabel={t("providerBreakdown")} containerClassName="rounded-none border-0">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("provider")}</TableHead>
|
||||
@@ -452,7 +452,7 @@ export default function ProviderStatsPage() {
|
||||
icon="speed"
|
||||
className="p-5"
|
||||
>
|
||||
<Table scrollbarLabel={t("comboMetrics")}>
|
||||
<Table scrollbarLabel={t("comboMetrics")} containerClassName="rounded-none border-0">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("combo")}</TableHead>
|
||||
|
||||
@@ -80,10 +80,11 @@ function EntriesTable({ entries, selected, onToggleRow, onToggleAll, t }: Entrie
|
||||
</div>
|
||||
<Table
|
||||
className="text-xs"
|
||||
containerClassName="max-h-64 overflow-y-auto"
|
||||
maxHeight="16rem"
|
||||
scrollLabel={t("importFromFileTitle")}
|
||||
scrollbarLabel={t("importFromFileTitle")}
|
||||
>
|
||||
<TableHeader className="sticky top-0">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>
|
||||
<Checkbox
|
||||
|
||||
@@ -271,58 +271,52 @@ export function OAuthExportImportModal({
|
||||
<div className="text-xs text-text-muted">
|
||||
{t("oauthExportDetected", { count: preview.length })}
|
||||
</div>
|
||||
<div className="overflow-x-auto max-h-64 overflow-y-auto rounded border border-border">
|
||||
<Table
|
||||
className="text-xs"
|
||||
containerClassName="overflow-visible rounded-none border-0"
|
||||
persistentScrollbars={false}
|
||||
>
|
||||
<TableHeader className="sticky top-0">
|
||||
<TableRow>
|
||||
<TableHead className="h-auto px-2 py-1.5">
|
||||
{/* The kit cap scrolls the preview under a pinned header and makes it a named tab
|
||||
stop (kit 0.0.116); the kit container border is the frame. */}
|
||||
<Table className="text-xs" maxHeight="16rem" scrollLabel={t("oauthExportTitle")}>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead className="h-auto px-2 py-1.5">
|
||||
<Checkbox
|
||||
aria-label={t("oauthExportSelectAll")}
|
||||
disabled={importing}
|
||||
checked={selectedCount === preview.length}
|
||||
onChange={(e) => toggleAll(e.target.checked)}
|
||||
/>
|
||||
</TableHead>
|
||||
<TableHead className="h-auto px-2 py-1.5">{t("oauthExportColEmail")}</TableHead>
|
||||
<TableHead className="h-auto px-2 py-1.5">
|
||||
{t("oauthExportColProvider")}
|
||||
</TableHead>
|
||||
<TableHead className="h-auto px-2 py-1.5">{t("oauthExportColRefresh")}</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{preview.map((row) => (
|
||||
<TableRow key={row.index}>
|
||||
<TableCell className="h-auto px-2 py-1">
|
||||
<Checkbox
|
||||
aria-label={t("oauthExportSelectAll")}
|
||||
aria-label={t("oauthExportSelectAccount", { index: row.index + 1 })}
|
||||
disabled={importing}
|
||||
checked={selectedCount === preview.length}
|
||||
onChange={(e) => toggleAll(e.target.checked)}
|
||||
checked={row.selected}
|
||||
onChange={() => toggleRow(row.index)}
|
||||
/>
|
||||
</TableHead>
|
||||
<TableHead className="h-auto px-2 py-1.5">{t("oauthExportColEmail")}</TableHead>
|
||||
<TableHead className="h-auto px-2 py-1.5">
|
||||
{t("oauthExportColProvider")}
|
||||
</TableHead>
|
||||
<TableHead className="h-auto px-2 py-1.5">
|
||||
{t("oauthExportColRefresh")}
|
||||
</TableHead>
|
||||
</TableCell>
|
||||
<TableCell className="h-auto px-2 py-1 font-medium text-text-main">
|
||||
{row.email || t("oauthExportNoEmail")}
|
||||
</TableCell>
|
||||
<TableCell className="h-auto px-2 py-1 font-mono text-text-muted">
|
||||
{row.provider}
|
||||
</TableCell>
|
||||
<TableCell
|
||||
className={`h-auto px-2 py-1 ${row.hasRefreshToken ? "text-success" : "text-warning"}`}
|
||||
>
|
||||
{row.hasRefreshToken ? t("oauthExportYes") : t("oauthExportNo")}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{preview.map((row) => (
|
||||
<TableRow key={row.index}>
|
||||
<TableCell className="h-auto px-2 py-1">
|
||||
<Checkbox
|
||||
aria-label={t("oauthExportSelectAccount", { index: row.index + 1 })}
|
||||
disabled={importing}
|
||||
checked={row.selected}
|
||||
onChange={() => toggleRow(row.index)}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell className="h-auto px-2 py-1 font-medium text-text-main">
|
||||
{row.email || t("oauthExportNoEmail")}
|
||||
</TableCell>
|
||||
<TableCell className="h-auto px-2 py-1 font-mono text-text-muted">
|
||||
{row.provider}
|
||||
</TableCell>
|
||||
<TableCell
|
||||
className={`h-auto px-2 py-1 ${row.hasRefreshToken ? "text-success" : "text-warning"}`}
|
||||
>
|
||||
{row.hasRefreshToken ? t("oauthExportYes") : t("oauthExportNo")}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</>
|
||||
)}
|
||||
|
||||
|
||||
@@ -235,7 +235,11 @@ export function RadarCatalogTable({ entries, refreshCatalog, onError }: RadarCat
|
||||
return (
|
||||
<>
|
||||
<Card padding="none" className="overflow-hidden">
|
||||
<Table aria-label={t("catalogTab")} scrollbarLabel={t("catalogTab")}>
|
||||
<Table
|
||||
aria-label={t("catalogTab")}
|
||||
scrollbarLabel={t("catalogTab")}
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("colProvider")}</TableHead>
|
||||
|
||||
@@ -171,7 +171,12 @@ export default function RadarIntelPage() {
|
||||
{intel.rankings.length === 0 ? (
|
||||
<p className="py-6 text-center text-text-muted">{t("noRankings")}</p>
|
||||
) : (
|
||||
<Table className="text-sm" aria-label={t("ranking")} scrollbarLabel={t("ranking")}>
|
||||
<Table
|
||||
className="text-sm"
|
||||
aria-label={t("ranking")}
|
||||
scrollbarLabel={t("ranking")}
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
|
||||
@@ -84,6 +84,7 @@ export default function ConnectionsTable({
|
||||
return (
|
||||
<>
|
||||
<DataTable
|
||||
label={t("title")}
|
||||
columns={columns}
|
||||
data={connections as unknown as DataTableRow[]}
|
||||
selectedId={effectiveSelectedId ?? undefined}
|
||||
|
||||
@@ -75,7 +75,7 @@ function ConnectionsTable({
|
||||
}) {
|
||||
const t = useTranslations("resilienceCooldowns");
|
||||
return (
|
||||
<Table scrollbarLabel={t("list.title")}>
|
||||
<Table scrollbarLabel={t("list.title")} containerClassName="rounded-none border-0">
|
||||
<CooldownTableHeader />
|
||||
<TableBody>
|
||||
{connections.map((connection) => (
|
||||
|
||||
@@ -908,7 +908,11 @@ export default function RuntimePageClient() {
|
||||
</div>
|
||||
) : (
|
||||
<div className="mt-2">
|
||||
<Table className="text-sm" scrollbarLabel={t("sessionsTitle")}>
|
||||
<Table
|
||||
className="text-sm"
|
||||
scrollbarLabel={t("sessionsTitle")}
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("tblSession")}</TableHead>
|
||||
|
||||
@@ -256,7 +256,10 @@ export default function AccessTokensTab() {
|
||||
) : tokens.length === 0 ? (
|
||||
<EmptyState icon="key" title={t("accessTokensEmpty")} className="py-6" />
|
||||
) : (
|
||||
<Table scrollbarLabel={t("accessTokensExisting")}>
|
||||
<Table
|
||||
scrollbarLabel={t("accessTokensExisting")}
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("accessTokensColName")}</TableHead>
|
||||
|
||||
@@ -771,7 +771,7 @@ export default function ProxyRegistryManager({
|
||||
) : items.length === 0 ? (
|
||||
<EmptyState icon="dns" title={t("noProxies")} />
|
||||
) : (
|
||||
<Table scrollbarLabel={t("title")}>
|
||||
<Table scrollbarLabel={t("title")} containerClassName="rounded-none border-0">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead className="w-8">
|
||||
@@ -1293,10 +1293,11 @@ export default function ProxyRegistryManager({
|
||||
{bulkImportParsedOnce && bulkImportParsed.length > 0 && (
|
||||
<Table
|
||||
scrollbarLabel={t("bulkImportTitle")}
|
||||
containerClassName="max-h-48 overflow-y-auto"
|
||||
maxHeight="12rem"
|
||||
scrollLabel={t("bulkImportTitle")}
|
||||
className="text-xs"
|
||||
>
|
||||
<TableHeader className="sticky top-0">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("tableName")}</TableHead>
|
||||
<TableHead>{t("labelType")}</TableHead>
|
||||
|
||||
@@ -339,7 +339,9 @@ export default function GlobalConfigTab() {
|
||||
{results && results.length > 0 && (
|
||||
<Table
|
||||
scrollbarLabel={t("bulkHealthcheck")}
|
||||
containerClassName="max-h-64 overflow-y-auto"
|
||||
containerClassName="rounded-none border-0"
|
||||
maxHeight="16rem"
|
||||
scrollLabel={t("bulkHealthcheck")}
|
||||
className="text-xs"
|
||||
>
|
||||
<TableHeader>
|
||||
|
||||
@@ -268,7 +268,11 @@ export default function MonitorTab({ onGoToTranslate }: MonitorTabProps) {
|
||||
</div>
|
||||
) : (
|
||||
<div data-testid="monitor-events-table">
|
||||
<Table scrollbarLabel={t("recentTranslations")} className="text-sm">
|
||||
<Table
|
||||
scrollbarLabel={t("recentTranslations")}
|
||||
className="text-sm"
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("time")}</TableHead>
|
||||
|
||||
@@ -424,6 +424,7 @@ export default function StreamTransformerAccordion({
|
||||
<Table
|
||||
scrollbarLabel={translateOrFallback("eventType", "Event type")}
|
||||
className="text-sm"
|
||||
containerClassName="rounded-none border-0"
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
|
||||
@@ -1263,6 +1263,7 @@ export default function EvalsTab() {
|
||||
</div>
|
||||
|
||||
<DataTable
|
||||
label={t("recentRunsTitle")}
|
||||
framed={false}
|
||||
columns={HISTORY_COLUMNS.map((column) => ({
|
||||
key: column.key,
|
||||
@@ -1408,7 +1409,9 @@ export default function EvalsTab() {
|
||||
{null}
|
||||
</FilterBar>
|
||||
|
||||
<div className="flex flex-col gap-3 mt-4">
|
||||
{/* Suites are sections of this card, split by hairlines like the kit plain accordion:
|
||||
the Card is the only frame (#19620). */}
|
||||
<div className="mt-4 flex flex-col divide-y divide-border">
|
||||
{filteredSuites.map((suite) => {
|
||||
const isExpanded = expanded === suite.id;
|
||||
const isRunning = running === suite.id;
|
||||
@@ -1427,7 +1430,7 @@ export default function EvalsTab() {
|
||||
liveResult?.runs?.[0]?.summary.passRate ?? suiteHistory[0]?.summary.passRate;
|
||||
|
||||
return (
|
||||
<div key={suite.id} className="border border-border/30 rounded-lg overflow-hidden">
|
||||
<div key={suite.id}>
|
||||
<div
|
||||
className="flex flex-wrap items-center justify-between gap-3 px-4 py-3 cursor-pointer hover:bg-surface/30 transition-colors"
|
||||
onClick={() => setExpanded(isExpanded ? null : suite.id)}
|
||||
@@ -1783,6 +1786,8 @@ export default function EvalsTab() {
|
||||
</span>
|
||||
</div>
|
||||
<DataTable
|
||||
label={t("testCasesCount", { count: (suite.cases || []).length })}
|
||||
framed={false}
|
||||
columns={[
|
||||
{ key: "name", label: t("columnCase") },
|
||||
{ key: "model", label: t("columnModel") },
|
||||
|
||||
@@ -37,6 +37,7 @@ function targetsNestedInteractiveElement(
|
||||
*
|
||||
* Usage:
|
||||
* <DataTable
|
||||
* label={t("logsTable")}
|
||||
* columns={visibleColumns}
|
||||
* data={filteredLogs}
|
||||
* renderCell={(row, column) => <span>{row[column.key]}</span>}
|
||||
@@ -60,6 +61,11 @@ export interface DataTableRow {
|
||||
}
|
||||
|
||||
interface DataTableProps {
|
||||
/**
|
||||
* Accessible name of the table's scroll region (a translated string). The kit makes the
|
||||
* capped container a focusable region while it overflows, and this names it.
|
||||
*/
|
||||
label: string;
|
||||
columns?: DataTableColumn[];
|
||||
data?: DataTableRow[];
|
||||
renderCell: (row: DataTableRow, column: DataTableColumn) => React.ReactNode;
|
||||
@@ -67,6 +73,7 @@ interface DataTableProps {
|
||||
onRowClick?: (row: DataTableRow) => void;
|
||||
selectedId?: string | number;
|
||||
loading?: boolean;
|
||||
/** Kit `Table` `maxHeight`: rows scroll under a pinned header, keyboard-focusable. */
|
||||
maxHeight?: string;
|
||||
emptyIcon?: string;
|
||||
emptyMessage?: string;
|
||||
@@ -79,6 +86,7 @@ interface DataTableProps {
|
||||
}
|
||||
|
||||
export default function DataTable({
|
||||
label,
|
||||
columns = [],
|
||||
data = [],
|
||||
renderCell,
|
||||
@@ -105,71 +113,68 @@ export default function DataTable({
|
||||
// Room for the loading overlay before the first rows arrive.
|
||||
<div className="min-h-[12rem]" />
|
||||
) : (
|
||||
// The wrapper is the scroll container (both axes) so the header can stick to it.
|
||||
// Opaque surface so the page background never bleeds through the table.
|
||||
<div style={{ maxHeight, overflow: "auto", background: "var(--color-surface)" }}>
|
||||
{/* min-w-0: narrow tables keep their auto width (the kit floors .ci-table at 40rem). */}
|
||||
<Table
|
||||
className="min-w-0"
|
||||
persistentScrollbars={false}
|
||||
containerClassName={cn("!overflow-visible", !framed && "rounded-none border-0")}
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
{columns.map((col) => (
|
||||
<TableHead
|
||||
key={col.key}
|
||||
className="sticky top-0 z-[1] whitespace-nowrap bg-[var(--table-header-bg)]"
|
||||
>
|
||||
{renderHeader ? renderHeader(col) : col.label}
|
||||
</TableHead>
|
||||
))}
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{data.map((row, idx) => {
|
||||
const selected = selectedId !== undefined && row.id === selectedId;
|
||||
return (
|
||||
<TableRow
|
||||
key={row.id || idx}
|
||||
aria-selected={selected || undefined}
|
||||
data-state={selected ? "selected" : undefined}
|
||||
onClick={(event) => {
|
||||
if (
|
||||
!onRowClick ||
|
||||
targetsNestedInteractiveElement(event.currentTarget, event.target)
|
||||
)
|
||||
return;
|
||||
onRowClick(row);
|
||||
}}
|
||||
onKeyDown={
|
||||
onRowClick
|
||||
? (event) => {
|
||||
if (event.target !== event.currentTarget) return;
|
||||
if (event.key !== "Enter" && event.key !== " ") return;
|
||||
event.preventDefault();
|
||||
onRowClick(row);
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
tabIndex={onRowClick ? 0 : undefined}
|
||||
className={cn(onRowClick && "cursor-pointer")}
|
||||
>
|
||||
{columns.map((col) => (
|
||||
<TableCell
|
||||
key={col.key}
|
||||
className="overflow-hidden text-ellipsis whitespace-nowrap"
|
||||
style={{ maxWidth: col.maxWidth || "200px" }}
|
||||
>
|
||||
{renderCell(row, col)}
|
||||
</TableCell>
|
||||
))}
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
// The kit Table owns the scroll container (maxHeight): it scrolls both axes, pins the
|
||||
// header row and becomes a named tab stop while it overflows (kit 0.0.116). min-w-0:
|
||||
// narrow tables keep their auto width (the kit floors .ci-table at 40rem).
|
||||
<Table
|
||||
className="min-w-0"
|
||||
maxHeight={maxHeight}
|
||||
scrollLabel={label}
|
||||
persistentScrollbars={false}
|
||||
containerClassName={cn(!framed && "rounded-none border-0")}
|
||||
>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
{columns.map((col) => (
|
||||
<TableHead key={col.key} className="whitespace-nowrap">
|
||||
{renderHeader ? renderHeader(col) : col.label}
|
||||
</TableHead>
|
||||
))}
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{data.map((row, idx) => {
|
||||
const selected = selectedId !== undefined && row.id === selectedId;
|
||||
return (
|
||||
<TableRow
|
||||
key={row.id || idx}
|
||||
aria-selected={selected || undefined}
|
||||
data-state={selected ? "selected" : undefined}
|
||||
onClick={(event) => {
|
||||
if (
|
||||
!onRowClick ||
|
||||
targetsNestedInteractiveElement(event.currentTarget, event.target)
|
||||
)
|
||||
return;
|
||||
onRowClick(row);
|
||||
}}
|
||||
onKeyDown={
|
||||
onRowClick
|
||||
? (event) => {
|
||||
if (event.target !== event.currentTarget) return;
|
||||
if (event.key !== "Enter" && event.key !== " ") return;
|
||||
event.preventDefault();
|
||||
onRowClick(row);
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
tabIndex={onRowClick ? 0 : undefined}
|
||||
className={cn(onRowClick && "cursor-pointer")}
|
||||
>
|
||||
{columns.map((col) => (
|
||||
<TableCell
|
||||
key={col.key}
|
||||
className="overflow-hidden text-ellipsis whitespace-nowrap"
|
||||
style={{ maxWidth: col.maxWidth || "200px" }}
|
||||
>
|
||||
{renderCell(row, col)}
|
||||
</TableCell>
|
||||
))}
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
)}
|
||||
</Frame>
|
||||
);
|
||||
|
||||
@@ -516,11 +516,14 @@ export default function ProxyLogger() {
|
||||
) : (
|
||||
<Table
|
||||
scrollbarLabel={t("tableLabel")}
|
||||
// Opaque bg-surface viewport (#4233); it scrolls both axes under a sticky header.
|
||||
containerClassName="max-h-[calc(100vh-320px)] overflow-auto rounded-none border-0 bg-surface"
|
||||
// Opaque bg-surface viewport (#4233); the kit cap scrolls both axes under a pinned
|
||||
// header and makes the viewport a named tab stop (kit 0.0.116).
|
||||
containerClassName="rounded-none border-0 bg-surface"
|
||||
maxHeight="calc(100vh - 320px)"
|
||||
scrollLabel={t("tableLabel")}
|
||||
className="text-left text-xs"
|
||||
>
|
||||
<TableHeader className="sticky top-0 z-10">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
{visibleColumns.status && <TableHead className="px-3">{t("colStatus")}</TableHead>}
|
||||
{visibleColumns.proxy && <TableHead className="px-3">{t("colProxy")}</TableHead>}
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
// #19620 "DataTable inside a Card (double frame)".
|
||||
// #19620 "DataTable inside a Card (double frame)", extended by the owner decision of
|
||||
// 2026-11-14: the Card is the only frame around a table.
|
||||
//
|
||||
// The kit DataTableShell (and the DataTable adapter built on it) draws its own frame.
|
||||
// Rendered as a direct child of a Card, the card border and the shell border stack into a
|
||||
// double frame. This guard parses every dashboard TSX file and fails when a
|
||||
// <DataTable> / <DataTableShell> element's nearest enclosing JSX element is a <Card>,
|
||||
// unless the DataTable opts out of its frame with `framed={false}` (the card is the frame).
|
||||
// The kit DataTableShell (and the DataTable adapter built on it) draws its own frame, and the
|
||||
// kit Table container keeps its own border and radius. Rendered inside a Card, the card border
|
||||
// and the table border stack into a double frame. This guard parses every dashboard TSX file
|
||||
// and, for each <DataTable> / <DataTableShell> / <Table> with a <Card> above it in the same JSX
|
||||
// tree, fails when:
|
||||
// - a <DataTable> does not opt out of its frame with `framed={false}`;
|
||||
// - a <DataTableShell> is used at all (its frame cannot be turned off: use the kit
|
||||
// TableLoadingRegion and a borderless Table instead);
|
||||
// - a <Table> does not zero its container border (`containerClassName` with `border-0`);
|
||||
// - an element between the table and the card draws a full border (`border` class): a
|
||||
// bordered sub-panel inside the card is a frame too, so it becomes a plain section.
|
||||
//
|
||||
// Conditionals and fragments between the two are looked through, because they render no
|
||||
// element. Deeper nesting (a table inside a bordered sub-panel inside a card) is a layout
|
||||
// choice per screen and is not covered here.
|
||||
// Conditionals, fragments and `.map()` callbacks between the two are looked through, because
|
||||
// they render no element. A table rendered by a child component in another file is not seen
|
||||
// here; those are covered by tests/unit/ui/single-frame-tables-in-card-19620.test.tsx.
|
||||
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
@@ -18,7 +25,7 @@ import ts from "typescript";
|
||||
|
||||
const ROOT = path.resolve(import.meta.dirname, "../..");
|
||||
const SCAN_DIRS = ["src/app", "src/shared/components"];
|
||||
const TABLE_TAGS = new Set(["DataTable", "DataTableShell"]);
|
||||
const TABLE_TAGS = new Set(["DataTable", "DataTableShell", "Table"]);
|
||||
const CARD_TAGS = new Set(["Card"]);
|
||||
|
||||
function listTsx(dir: string, out: string[] = []): string[] {
|
||||
@@ -34,38 +41,84 @@ function listTsx(dir: string, out: string[] = []): string[] {
|
||||
return out;
|
||||
}
|
||||
|
||||
function tagName(node: ts.JsxOpeningElement | ts.JsxSelfClosingElement, sf: ts.SourceFile) {
|
||||
type JsxTag = ts.JsxOpeningElement | ts.JsxSelfClosingElement;
|
||||
|
||||
function tagName(node: JsxTag, sf: ts.SourceFile) {
|
||||
return node.tagName.getText(sf);
|
||||
}
|
||||
|
||||
function hasFramedFalse(node: ts.JsxOpeningElement | ts.JsxSelfClosingElement): boolean {
|
||||
return node.attributes.properties.some(
|
||||
(attr) =>
|
||||
ts.isJsxAttribute(attr) &&
|
||||
attr.name.getText() === "framed" &&
|
||||
attr.initializer !== undefined &&
|
||||
ts.isJsxExpression(attr.initializer) &&
|
||||
attr.initializer.expression?.kind === ts.SyntaxKind.FalseKeyword
|
||||
function attribute(node: JsxTag, name: string): ts.JsxAttribute | undefined {
|
||||
return node.attributes.properties.find(
|
||||
(attr): attr is ts.JsxAttribute => ts.isJsxAttribute(attr) && attr.name.getText() === name
|
||||
);
|
||||
}
|
||||
|
||||
/** Nearest enclosing JSX element (not fragment) tag name, looking through expressions. */
|
||||
function nearestElementTag(
|
||||
node: ts.JsxOpeningElement | ts.JsxSelfClosingElement,
|
||||
sf: ts.SourceFile
|
||||
): string | null {
|
||||
function hasFramedFalse(node: JsxTag): boolean {
|
||||
const attr = attribute(node, "framed");
|
||||
return (
|
||||
attr?.initializer !== undefined &&
|
||||
ts.isJsxExpression(attr.initializer) &&
|
||||
attr.initializer.expression?.kind === ts.SyntaxKind.FalseKeyword
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class text a class-like attribute always renders: a string literal, or the literal parts
|
||||
* of a template literal (a class only counts when whitespace or the template edge bounds it). Any other expression (a conditional, `cn(...)`, a variable) is
|
||||
* unresolved and returns null, so an inactive branch can neither satisfy nor trip the guard.
|
||||
*/
|
||||
function staticClassText(node: JsxTag, name: string): string | null {
|
||||
const init = attribute(node, name)?.initializer;
|
||||
if (!init) return "";
|
||||
if (ts.isStringLiteral(init)) return init.text;
|
||||
const expr = ts.isJsxExpression(init) ? init.expression : undefined;
|
||||
if (!expr) return null;
|
||||
if (ts.isStringLiteral(expr) || ts.isNoSubstitutionTemplateLiteral(expr)) return expr.text;
|
||||
if (ts.isTemplateExpression(expr)) {
|
||||
// Each `${...}` becomes a non-space sentinel, so a class written right against an
|
||||
// interpolation (`border-0${suffix}`) is not a whole class: it can render as `border-0-x`.
|
||||
return [expr.head.text, ...expr.templateSpans.map((span) => span.literal.text)].join("\u0000");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const hasClass = (text: string | null, cls: string) =>
|
||||
text !== null && new RegExp(`(^|\\s)${cls}($|\\s)`).test(text);
|
||||
|
||||
function tableDrawsOwnFrame(node: JsxTag, name: string): boolean {
|
||||
if (name === "DataTableShell") return true;
|
||||
if (name === "DataTable") return !hasFramedFalse(node);
|
||||
// Unresolved (dynamic) container classes cannot prove the border is off.
|
||||
return !hasClass(staticClassText(node, "containerClassName"), "border-0");
|
||||
}
|
||||
|
||||
/** A `.map((item) => <El />)` callback inside JSX renders its element as a child. */
|
||||
function isMapCallback(node: ts.Node): boolean {
|
||||
return (
|
||||
(ts.isArrowFunction(node) || ts.isFunctionExpression(node)) &&
|
||||
ts.isCallExpression(node.parent) &&
|
||||
ts.isPropertyAccessExpression(node.parent.expression) &&
|
||||
node.parent.expression.name.text === "map"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Walks up from a table to the nearest enclosing <Card>, looking through expressions,
|
||||
* fragments and `.map()` callbacks. Returns the card and the elements in between, or null
|
||||
* when no card encloses the table in this JSX tree.
|
||||
*/
|
||||
function enclosingCard(node: JsxTag, sf: ts.SourceFile): { between: JsxTag[] } | null {
|
||||
const between: JsxTag[] = [];
|
||||
// An opening element's parent is its own JsxElement wrapper: start above it.
|
||||
let current: ts.Node | undefined = ts.isJsxOpeningElement(node)
|
||||
? node.parent.parent
|
||||
: node.parent;
|
||||
while (current) {
|
||||
if (ts.isJsxElement(current)) return tagName(current.openingElement, sf);
|
||||
if (ts.isJsxFragment(current)) {
|
||||
current = current.parent;
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
ts.isFunctionLike(current) ||
|
||||
if (ts.isJsxElement(current)) {
|
||||
if (CARD_TAGS.has(tagName(current.openingElement, sf))) return { between };
|
||||
between.push(current.openingElement);
|
||||
} else if (
|
||||
(ts.isFunctionLike(current) && !isMapCallback(current)) ||
|
||||
ts.isSourceFile(current) ||
|
||||
ts.isJsxAttribute(current) // a table passed as a prop value is not a child
|
||||
) {
|
||||
@@ -80,17 +133,24 @@ function findTablesFramedInsideCards(files: string[]): string[] {
|
||||
const violations: string[] = [];
|
||||
for (const file of files) {
|
||||
const text = fs.readFileSync(file, "utf8");
|
||||
if (!/<DataTable(Shell)?\b/.test(text)) continue;
|
||||
if (!/<(DataTable(Shell)?|Table)\b/.test(text)) continue;
|
||||
const sf = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
||||
const at = (node: ts.Node) =>
|
||||
`${path.relative(ROOT, file)}:${sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1}`;
|
||||
const visit = (node: ts.Node) => {
|
||||
if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
|
||||
const name = tagName(node, sf);
|
||||
if (TABLE_TAGS.has(name)) {
|
||||
const parentTag = nearestElementTag(node, sf);
|
||||
const optedOut = name === "DataTable" && hasFramedFalse(node);
|
||||
if (parentTag && CARD_TAGS.has(parentTag) && !optedOut) {
|
||||
const { line } = sf.getLineAndCharacterOfPosition(node.getStart(sf));
|
||||
violations.push(`${path.relative(ROOT, file)}:${line + 1} <${name}> inside <Card>`);
|
||||
const card = TABLE_TAGS.has(name) ? enclosingCard(node, sf) : null;
|
||||
if (card) {
|
||||
if (tableDrawsOwnFrame(node, name)) {
|
||||
violations.push(`${at(node)} <${name}> inside <Card>`);
|
||||
}
|
||||
for (const panel of card.between) {
|
||||
if (hasClass(staticClassText(panel, "className"), "border")) {
|
||||
violations.push(
|
||||
`${at(panel)} bordered <${tagName(panel, sf)}> around a table in <Card>`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,34 +158,67 @@ function findTablesFramedInsideCards(files: string[]): string[] {
|
||||
};
|
||||
visit(sf);
|
||||
}
|
||||
return violations;
|
||||
return [...new Set(violations)];
|
||||
}
|
||||
|
||||
test("no DataTable/DataTableShell draws a second frame directly inside a Card", () => {
|
||||
test("no table draws a second frame inside a Card", () => {
|
||||
const files = SCAN_DIRS.flatMap((dir) => listTsx(path.join(ROOT, dir)));
|
||||
assert.ok(files.length > 100, "scan should cover the dashboard sources");
|
||||
assert.deepEqual(findTablesFramedInsideCards(files), []);
|
||||
});
|
||||
|
||||
test("the guard detects a framed table in a card and accepts framed={false}", () => {
|
||||
test("the guard detects framed tables and bordered sub-panels in a card", () => {
|
||||
const tmp = fs.mkdtempSync(path.join(ROOT, "tests/unit/.tmp-datatable-card-"));
|
||||
try {
|
||||
const bad = path.join(tmp, "Bad.tsx");
|
||||
fs.writeFileSync(
|
||||
bad,
|
||||
`export const A = () => <Card title="x">{ok ? <DataTable data={[]} /> : null}</Card>;\n` +
|
||||
`export const B = () => <Card><DataTableShell>{rows}</DataTableShell></Card>;\n`
|
||||
[
|
||||
`export const A = () => <Card title="x">{ok ? <DataTable data={[]} /> : null}</Card>;`,
|
||||
`export const B = () => <Card><DataTableShell>{rows}</DataTableShell></Card>;`,
|
||||
`export const E = () => <Card><div className="p-2"><DataTable data={[]} /></div></Card>;`,
|
||||
`export const F = () => <Card><Table scrollbarLabel="x" /></Card>;`,
|
||||
`export const G = () => <Card><Table containerClassName="mt-3" /></Card>;`,
|
||||
`export const H = () => <Card><div className="rounded-xl border border-border p-5"><Table containerClassName="rounded-none border-0" /></div></Card>;`,
|
||||
`export const I = () => <Card>{items.map((it) => <div key={it} className="border rounded-lg"><DataTable framed={false} /></div>)}</Card>;`,
|
||||
`export const J = () => <Card><>{rows.map((r) => <Table key={r} />)}</></Card>;`,
|
||||
`export const Q = () => <Card><Table containerClassName={flat ? "rounded-none border-0" : ""} /></Card>;`,
|
||||
`export const R = () => <Card><Table containerClassName={\`mt-3 \${extra}\`} /></Card>;`,
|
||||
`export const S = () => <Card><div className={\`border \${tone}\`}><DataTable framed={false} /></div></Card>;`,
|
||||
`export const V = () => <Card><Table containerClassName={\`rounded-none border-0\${suffix}\`} /></Card>;`,
|
||||
"",
|
||||
].join("\n")
|
||||
);
|
||||
const good = path.join(tmp, "Good.tsx");
|
||||
fs.writeFileSync(
|
||||
good,
|
||||
`export const C = () => <Card><DataTable framed={false} data={[]} /></Card>;\n` +
|
||||
`export const D = () => <section><DataTable data={[]} /></section>;\n` +
|
||||
`export const E = () => <Card><div className="p-2"><DataTable data={[]} /></div></Card>;\n`
|
||||
[
|
||||
`export const C = () => <Card><DataTable framed={false} data={[]} /></Card>;`,
|
||||
`export const D = () => <section><DataTable data={[]} /><Table /></section>;`,
|
||||
`export const K = () => <Card><Table containerClassName="rounded-none border-0" /></Card>;`,
|
||||
`export const L = () => <Card><div className="p-2"><Table containerClassName="max-h-64 rounded-none border-0" /></div></Card>;`,
|
||||
`export const M = () => <Card><div className="border-t border-border/20 p-4"><DataTable framed={false} /></div></Card>;`,
|
||||
`export const N = () => <Card><TableLoadingRegion><Table containerClassName={"rounded-none border-0"} /></TableLoadingRegion></Card>;`,
|
||||
`export const O = () => <Card action={<Table />} />;`,
|
||||
`export const P = () => <Card>{() => <Table />}</Card>;`,
|
||||
`export const T = () => <Card><Table containerClassName={\`rounded-none border-0 \${extra}\`} /></Card>;`,
|
||||
`export const U = () => <Card><div className={open ? "border p-2" : "p-2"}><Table containerClassName="rounded-none border-0" /></div></Card>;`,
|
||||
`export const X = () => <Card><div className={\`border\${suffix} p-2\`}><Table containerClassName={\`\${extra} rounded-none border-0\`} /></div></Card>;`,
|
||||
"",
|
||||
].join("\n")
|
||||
);
|
||||
const found = findTablesFramedInsideCards([bad, good]);
|
||||
assert.equal(found.length, 2, found.join("\n"));
|
||||
assert.ok(found.every((v) => v.includes("Bad.tsx")));
|
||||
assert.ok(
|
||||
found.every((v) => v.includes("Bad.tsx")),
|
||||
found.join("\n")
|
||||
);
|
||||
// One violation per bad case. H, I and S are reported for their bordered sub-panel only
|
||||
// (their tables are unframed); Q, R and V because a dynamic container class proves nothing
|
||||
// (V: `border-0${suffix}` can render as `border-0-x`).
|
||||
const lines = found.map((v) => Number(v.split(":")[1].split(" ")[0]));
|
||||
assert.deepEqual(lines, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], found.join("\n"));
|
||||
for (const i of [5, 6, 10]) assert.ok(found[i].includes("bordered <div>"), found[i]);
|
||||
for (const i of [8, 9, 11]) assert.ok(found[i].includes("<Table> inside <Card>"), found[i]);
|
||||
} finally {
|
||||
fs.rmSync(tmp, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
@@ -347,7 +347,13 @@ test("DashboardLayout content shell is fluid up to ~4K before centering", () =>
|
||||
|
||||
test("DataTable is theme-aware via --table-* tokens, no color literal, no dead fallbacks", () => {
|
||||
const dt = read("src/shared/components/DataTable.tsx");
|
||||
assert.ok(dt.includes("var(--table-header-bg)"), "header uses the token");
|
||||
// Kit 0.0.116: the capped kit Table pins and paints the header row itself (kit token), so the
|
||||
// adapter no longer patches the header cells with sticky positioning or a background.
|
||||
assert.ok(dt.includes("maxHeight={maxHeight}"), "the kit Table owns the scroll and the header");
|
||||
assert.ok(
|
||||
!dt.includes("sticky top-0") && !dt.includes("--table-header-bg"),
|
||||
"no adapter-side header patch"
|
||||
);
|
||||
// KEA-7886: rows, borders, hover and selection come from the kit table (ci-ui.css tokens);
|
||||
// the selected row is the kit's data-state="selected" instead of a zebra/selected inline mix.
|
||||
assert.ok(dt.includes('from "@omniroute/ui-kit/table"'), "rows render through the kit table");
|
||||
@@ -444,7 +450,14 @@ test("bg-alt, muted and surface-secondary have @theme entries so their utilities
|
||||
|
||||
test("cn() still dedupes via tailwind-merge and DataTable paints an opaque surface", () => {
|
||||
assert.match(read("src/shared/utils/cn.ts"), /twMerge\(clsx\(/);
|
||||
assert.ok(read("src/shared/components/DataTable.tsx").includes("var(--color-surface)"));
|
||||
// Kit 0.0.116: the kit Table container is the DataTable scroll viewport, and the kit paints it
|
||||
// with the opaque surface; the adapter must not make it transparent.
|
||||
const dt = read("src/shared/components/DataTable.tsx");
|
||||
assert.ok(dt.includes("maxHeight={maxHeight}") && !dt.includes("bg-transparent"));
|
||||
assert.match(
|
||||
read("packages/ui-kit/src/ci-ui.css"),
|
||||
/\.ci-table-container \{[^}]*background: var\(--ci-color-surface\);/
|
||||
);
|
||||
});
|
||||
|
||||
test("text-primary resolves to a readable primary ink; lime stays on bg/border/ring (KEA-7886)", () => {
|
||||
|
||||
149
tests/unit/table-max-height-adoption.test.ts
Normal file
149
tests/unit/table-max-height-adoption.test.ts
Normal file
@@ -0,0 +1,149 @@
|
||||
// #19620 / kit 0.0.116 (keak-ai/cheaper-inference-ui-kit#203): a kit <Table> that scrolls
|
||||
// vertically takes `maxHeight`, so the kit owns the scroll container: it pins the header and
|
||||
// makes the container a focusable, named region while it overflows (WCAG 2.1.1).
|
||||
//
|
||||
// This guard parses the dashboard and shared TSX and fails when a kit <Table>:
|
||||
// - caps its own height through classes (`max-h-*` in `containerClassName`), or sits directly
|
||||
// in an element that caps it (`max-h-*` / inline `maxHeight` plus a vertical overflow);
|
||||
// - takes `maxHeight` without an accessible name for the scroll region (`scrollLabel`,
|
||||
// `aria-label` or `aria-labelledby`).
|
||||
// Whole-panel scroll areas sized by flex (`flex-1 overflow-y-auto`, `h-full overflow-auto`)
|
||||
// are layout, not a table cap, and are not covered.
|
||||
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import ts from "typescript";
|
||||
|
||||
const ROOT = path.resolve(import.meta.dirname, "../..");
|
||||
const SCAN_DIRS = ["src/app", "src/shared/components"];
|
||||
|
||||
type JsxTag = ts.JsxOpeningElement | ts.JsxSelfClosingElement;
|
||||
|
||||
function listTsx(dir: string, out: string[] = []): string[] {
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
if (entry.name === "node_modules" || entry.name === "__tests__") continue;
|
||||
listTsx(full, out);
|
||||
} else if (entry.name.endsWith(".tsx") && !entry.name.endsWith(".test.tsx")) {
|
||||
out.push(full);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
const attr = (node: JsxTag, name: string) =>
|
||||
node.attributes.properties.find(
|
||||
(a): a is ts.JsxAttribute => ts.isJsxAttribute(a) && a.name.getText() === name
|
||||
);
|
||||
|
||||
const attrText = (node: JsxTag, name: string, sf: ts.SourceFile) =>
|
||||
attr(node, name)?.initializer?.getText(sf) ?? "";
|
||||
|
||||
const CAP_CLASS = /(^|[\s"'`])max-h-/;
|
||||
const V_OVERFLOW = /overflow(-y)?-(auto|scroll)|overflow:\s*["'](auto|scroll)|overflowY/;
|
||||
|
||||
function parentElement(node: JsxTag): JsxTag | null {
|
||||
let current: ts.Node | undefined = ts.isJsxOpeningElement(node)
|
||||
? node.parent.parent
|
||||
: node.parent;
|
||||
while (current) {
|
||||
if (ts.isJsxElement(current)) return current.openingElement;
|
||||
if (ts.isFunctionLike(current) || ts.isSourceFile(current) || ts.isJsxAttribute(current)) {
|
||||
return null;
|
||||
}
|
||||
current = current.parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function findViolations(files: string[]): string[] {
|
||||
const out: string[] = [];
|
||||
for (const file of files) {
|
||||
const text = fs.readFileSync(file, "utf8");
|
||||
if (!/<Table\b/.test(text) || !/ui-kit\/table/.test(text)) continue;
|
||||
const sf = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
||||
const at = (n: ts.Node) =>
|
||||
`${path.relative(ROOT, file)}:${sf.getLineAndCharacterOfPosition(n.getStart(sf)).line + 1}`;
|
||||
const visit = (node: ts.Node) => {
|
||||
if (
|
||||
(ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) &&
|
||||
node.tagName.getText(sf) === "Table"
|
||||
) {
|
||||
if (CAP_CLASS.test(attrText(node, "containerClassName", sf))) {
|
||||
out.push(`${at(node)} caps its height with classes: use maxHeight`);
|
||||
}
|
||||
const parent = parentElement(node);
|
||||
if (parent) {
|
||||
const p = `${attrText(parent, "className", sf)} ${attrText(parent, "style", sf)}`;
|
||||
if ((CAP_CLASS.test(p) || /maxHeight/.test(p)) && V_OVERFLOW.test(p)) {
|
||||
out.push(`${at(node)} scrolls inside its own capped wrapper: use maxHeight`);
|
||||
}
|
||||
}
|
||||
if (
|
||||
attr(node, "maxHeight") &&
|
||||
!attr(node, "scrollLabel") &&
|
||||
!attr(node, "aria-label") &&
|
||||
!attr(node, "aria-labelledby")
|
||||
) {
|
||||
out.push(`${at(node)} has maxHeight but no accessible name for its scroll region`);
|
||||
}
|
||||
}
|
||||
ts.forEachChild(node, visit);
|
||||
};
|
||||
visit(sf);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
test("kit tables scroll vertically through maxHeight, with a named scroll region", () => {
|
||||
const files = SCAN_DIRS.flatMap((dir) => listTsx(path.join(ROOT, dir)));
|
||||
assert.ok(files.length > 100, "scan should cover the dashboard sources");
|
||||
assert.deepEqual(findViolations(files), []);
|
||||
});
|
||||
|
||||
test("the guard detects class caps, capped wrappers and unnamed capped tables", () => {
|
||||
const tmp = fs.mkdtempSync(path.join(ROOT, "tests/unit/.tmp-table-max-height-"));
|
||||
try {
|
||||
const imp = `import { Table } from "@omniroute/ui-kit/table";\n`;
|
||||
const bad = path.join(tmp, "Bad.tsx");
|
||||
fs.writeFileSync(
|
||||
bad,
|
||||
imp +
|
||||
[
|
||||
`export const A = () => <Table containerClassName="max-h-64 overflow-y-auto" />;`,
|
||||
`export const B = () => <div className="max-h-64 overflow-y-auto"><Table /></div>;`,
|
||||
`export const C = () => <div style={{ maxHeight: 320, overflow: "auto" }}><Table /></div>;`,
|
||||
`export const D = () => <Table maxHeight="20rem" />;`,
|
||||
"",
|
||||
].join("\n")
|
||||
);
|
||||
const good = path.join(tmp, "Good.tsx");
|
||||
fs.writeFileSync(
|
||||
good,
|
||||
imp +
|
||||
[
|
||||
`export const E = () => <Table maxHeight="20rem" scrollLabel={t("rows")} />;`,
|
||||
`export const F = () => <Table maxHeight={320} aria-label={t("rows")} />;`,
|
||||
`export const G = () => <div className="flex-1 overflow-y-auto"><Table /></div>;`,
|
||||
`export const H = () => <div className="max-h-64"><Table /></div>;`,
|
||||
`export const I = () => <Table containerClassName="mt-3 rounded-none border-0" />;`,
|
||||
"",
|
||||
].join("\n")
|
||||
);
|
||||
const found = findViolations([bad, good]);
|
||||
assert.ok(
|
||||
found.every((v) => v.includes("Bad.tsx")),
|
||||
found.join("\n")
|
||||
);
|
||||
assert.deepEqual(
|
||||
found.map((v) => Number(v.split(":")[1].split(" ")[0])),
|
||||
[2, 3, 4, 5],
|
||||
found.join("\n")
|
||||
);
|
||||
} finally {
|
||||
fs.rmSync(tmp, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
94
tests/unit/ui/adapters/datatable-max-height.test.tsx
Normal file
94
tests/unit/ui/adapters/datatable-max-height.test.tsx
Normal file
@@ -0,0 +1,94 @@
|
||||
// @vitest-environment jsdom
|
||||
/**
|
||||
* #19620 / kit 0.0.116 (keak-ai/cheaper-inference-ui-kit#203): the DataTable adapter used to
|
||||
* scroll rows in its own `<div style={{ maxHeight, overflow: "auto" }}>`. That wrapper never
|
||||
* took focus, so keyboard users could not scroll a tall table (WCAG 2.1.1), and it needed a
|
||||
* sticky-header patch on every header cell. The kit Table now takes `maxHeight`: the capped
|
||||
* container scrolls, pins the header and becomes a named tab stop while it overflows.
|
||||
*/
|
||||
import React from "react";
|
||||
import { cleanup, render, screen } from "@testing-library/react";
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";
|
||||
|
||||
const { default: DataTable } = await import("@/shared/components/DataTable");
|
||||
|
||||
// jsdom does no layout: make every element report content taller than its box, so the kit
|
||||
// sees the capped container as overflowing (as a browser does for a tall table).
|
||||
const restore: Array<() => void> = [];
|
||||
beforeAll(() => {
|
||||
for (const [prop, value] of [
|
||||
["scrollHeight", 2000],
|
||||
["clientHeight", 320],
|
||||
] as const) {
|
||||
const original = Object.getOwnPropertyDescriptor(HTMLElement.prototype, prop);
|
||||
Object.defineProperty(HTMLElement.prototype, prop, { configurable: true, get: () => value });
|
||||
restore.push(() => {
|
||||
if (original) Object.defineProperty(HTMLElement.prototype, prop, original);
|
||||
});
|
||||
}
|
||||
});
|
||||
afterAll(() => restore.forEach((fn) => fn()));
|
||||
afterEach(() => cleanup());
|
||||
|
||||
const columns = [
|
||||
{ key: "name", label: "Name" },
|
||||
{ key: "status", label: "Status" },
|
||||
];
|
||||
const data = Array.from({ length: 40 }, (_, i) => ({ id: i, name: `row-${i}`, status: "ok" }));
|
||||
|
||||
describe("DataTable scrolls vertically through the kit Table maxHeight", () => {
|
||||
it("makes the capped kit container a named tab stop, with no scroll wrapper of its own", () => {
|
||||
const { container } = render(
|
||||
<DataTable
|
||||
label="Recent runs"
|
||||
columns={columns}
|
||||
data={data}
|
||||
renderCell={(r, c) => String(r[c.key])}
|
||||
maxHeight="320px"
|
||||
/>
|
||||
);
|
||||
const scroller = container.querySelector<HTMLElement>("[data-slot=table-container]")!;
|
||||
expect(scroller.hasAttribute("data-capped")).toBe(true);
|
||||
expect(scroller.style.getPropertyValue("--ci-table-max-height")).toBe("320px");
|
||||
expect(scroller.className).not.toContain("overflow-visible");
|
||||
// Focusable while it overflows, and named by the adapter's label.
|
||||
expect(scroller.tabIndex).toBe(0);
|
||||
expect(screen.getByRole("region", { name: "Recent runs" })).toBe(scroller);
|
||||
// No adapter-owned scroll box around the table any more.
|
||||
expect(container.querySelector("[style*='overflow']")).toBeNull();
|
||||
});
|
||||
|
||||
it("leaves pinning the header to the kit (no sticky patch on the header cells)", () => {
|
||||
render(
|
||||
<DataTable
|
||||
label="Runners"
|
||||
columns={columns}
|
||||
data={data}
|
||||
renderCell={(r, c) => String(r[c.key])}
|
||||
/>
|
||||
);
|
||||
for (const head of screen.getAllByRole("columnheader")) {
|
||||
expect(head.className).not.toContain("sticky");
|
||||
expect(head.className).toContain("whitespace-nowrap");
|
||||
}
|
||||
// The default cap still applies.
|
||||
const scroller = screen.getByRole("region", { name: "Runners" });
|
||||
expect(scroller.style.getPropertyValue("--ci-table-max-height")).toBe("calc(100vh - 320px)");
|
||||
});
|
||||
|
||||
it("keeps the borderless container when a Card frames the table", () => {
|
||||
const { container } = render(
|
||||
<DataTable
|
||||
label="Tasks"
|
||||
framed={false}
|
||||
columns={columns}
|
||||
data={data}
|
||||
renderCell={(r, c) => String(r[c.key])}
|
||||
/>
|
||||
);
|
||||
const scroller = container.querySelector<HTMLElement>("[data-slot=table-container]")!;
|
||||
expect(scroller.hasAttribute("data-capped")).toBe(true);
|
||||
expect(scroller.className).toContain("border-0");
|
||||
expect(scroller.className).toContain("rounded-none");
|
||||
});
|
||||
});
|
||||
127
tests/unit/ui/single-frame-tables-in-card-19620.test.tsx
Normal file
127
tests/unit/ui/single-frame-tables-in-card-19620.test.tsx
Normal file
@@ -0,0 +1,127 @@
|
||||
// @vitest-environment jsdom
|
||||
/**
|
||||
* #19620, owner decision 2026-11-14: the Card is the only frame around a table.
|
||||
*
|
||||
* The AST guard (tests/unit/datatable-not-framed-inside-card.test.ts) only sees a table and a
|
||||
* Card written in the same JSX tree. These two components render their table in their own
|
||||
* file and are placed inside a Card by their parent, so they are checked here by rendering:
|
||||
*
|
||||
* - CacheEntriesTab (semantic cache entries, inside the Semantic Cache card) used the kit
|
||||
* DataTableShell, whose `.ci-data-table__frame` draws a border of its own.
|
||||
* - CooldownConnectionsCard (resilience cooldowns) renders a kit Table, whose container keeps
|
||||
* the kit border and radius unless the consumer zeroes them.
|
||||
*/
|
||||
import React from "react";
|
||||
import { cleanup, render, screen, waitFor } from "@testing-library/react";
|
||||
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
||||
|
||||
beforeAll(() => {
|
||||
globalThis.ResizeObserver ??= class {
|
||||
observe() {}
|
||||
unobserve() {}
|
||||
disconnect() {}
|
||||
} as unknown as typeof ResizeObserver;
|
||||
});
|
||||
|
||||
// One translator for every call: CacheEntriesTab lists `t` in its fetch effect's dependencies,
|
||||
// so a new function per render would refetch forever.
|
||||
vi.mock("next-intl", () => {
|
||||
const translate = (key: string) => key;
|
||||
return { useTranslations: () => translate };
|
||||
});
|
||||
|
||||
const { default: CacheEntriesTab } =
|
||||
await import("@/app/(dashboard)/dashboard/cache/components/CacheEntriesTab");
|
||||
const { default: CooldownConnectionsCard } =
|
||||
await import("@/app/(dashboard)/dashboard/resilience/cooldowns/components/CooldownConnectionsCard");
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
function expectBorderlessTable(container: HTMLElement) {
|
||||
expect(container.querySelector("[data-slot=data-table-shell]")).toBeNull();
|
||||
expect(container.querySelector(".ci-data-table__frame")).toBeNull();
|
||||
const tableContainer = container.querySelector("[data-slot=table-container]");
|
||||
expect(tableContainer).not.toBeNull();
|
||||
expect(tableContainer!.className).toContain("border-0");
|
||||
expect(tableContainer!.className).toContain("rounded-none");
|
||||
}
|
||||
|
||||
const entry = (i: number) => ({
|
||||
id: `e${i}`,
|
||||
signature: `sig-${i}-0123456789abcdef`,
|
||||
model: "gpt-4o",
|
||||
hit_count: i,
|
||||
tokens_saved: 100 * i,
|
||||
created_at: "2026-11-13T10:00:00.000Z",
|
||||
expires_at: "2026-11-15T10:00:00.000Z",
|
||||
});
|
||||
|
||||
describe("semantic cache entries: no frame of their own", () => {
|
||||
it("renders the entries as a borderless kit table, with search and pagination kept", async () => {
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn(async () =>
|
||||
Response.json({
|
||||
entries: [entry(1), entry(2)],
|
||||
pagination: { page: 1, limit: 20, total: 45, totalPages: 3 },
|
||||
})
|
||||
)
|
||||
);
|
||||
const { container } = render(<CacheEntriesTab />);
|
||||
await waitFor(() => expect(screen.getAllByRole("row")).toHaveLength(3));
|
||||
|
||||
expectBorderlessTable(container);
|
||||
expect(screen.getByRole("textbox", { name: "searchEntries" })).not.toBeNull();
|
||||
expect(screen.getByRole("button", { name: "search" })).not.toBeNull();
|
||||
expect(screen.getByRole("button", { name: "previousPage" })).not.toBeNull();
|
||||
expect(screen.getByRole("button", { name: "nextPage" })).not.toBeNull();
|
||||
expect(screen.getByText("1 / 3")).not.toBeNull();
|
||||
});
|
||||
|
||||
it("keeps the kit loading overlay while the first page loads", () => {
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn(() => new Promise<Response>(() => {}))
|
||||
);
|
||||
const { container } = render(<CacheEntriesTab />);
|
||||
expect(container.querySelector("[data-slot=table-loading-region]")).not.toBeNull();
|
||||
expect(screen.getByRole("status")).not.toBeNull();
|
||||
expect(container.querySelector(".ci-data-table__frame")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("resilience cooldowns: the Card is the table's only frame", () => {
|
||||
it("renders the connections table without its own container border", () => {
|
||||
const { container } = render(
|
||||
<CooldownConnectionsCard
|
||||
connections={[
|
||||
{
|
||||
id: "c1",
|
||||
provider: "codex",
|
||||
name: "Cooling account",
|
||||
authType: "oauth",
|
||||
priority: 1,
|
||||
isActive: true,
|
||||
status: "cooling_down",
|
||||
testStatus: "unavailable",
|
||||
rateLimitedUntil: null,
|
||||
cooldownRemainingMs: 60_000,
|
||||
backoffLevel: 1,
|
||||
errorCode: "502",
|
||||
lastErrorType: "server_error",
|
||||
lastErrorAt: null,
|
||||
lockouts: [],
|
||||
} as never,
|
||||
]}
|
||||
onClear={async () => {}}
|
||||
onRefresh={() => {}}
|
||||
/>
|
||||
);
|
||||
expect(container.querySelector("[data-slot=card]")).not.toBeNull();
|
||||
expectBorderlessTable(container);
|
||||
expect(screen.getAllByRole("row")).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user