@devslab/dds-table-react

中文文档
0.33.0发布于 2026/11/12SEE LICENSE IN LICENSETypeScriptES Module构建来源已验证近 30 天下载 2544

DDS themed Community AG Grid for React

原始使用文档

@devslab/dds-table-react

DDS styling and an SSR-safe React boundary for AG Grid Community 36.2.0. This package is independent of @devslab/dds-react; importing React primitives does not import AG Grid. React and React DOM 18.3 or 19 are peers.

import { useRef } from "react";
import { DataTable, type DataTableRef } from "@devslab/dds-table-react";
import type { ColDef, ICellRendererParams } from "ag-grid-community";
import "@devslab/dds-tokens/tokens.css";
import "@devslab/dds-css/dds.css";
import "@devslab/dds-table-react/styles.css";

type Order = { id: string; amount: number };
const columns: ColDef<Order>[] = [
  { field: "id", filter: true },
  { field: "amount", editable: true,
    cellRenderer: ({ value }: ICellRendererParams<Order, number>) => <strong>{value}</strong> },
];
export function Orders({ rows }: { rows: readonly Order[] }) {
  const gridRef = useRef<DataTableRef<Order>>(null);
  return <DataTable rows={rows} columns={columns} label="Orders"
    placeholder="Preparing orders" gridRef={gridRef}
    gridProps={{ getRowId: ({ data }) => data.id, rowSelection: { mode: "multiRow" },
      onGridReady: ({ api }) => console.log(api.getDisplayedRowCount()),
      localeText: { noRowsToShow: "No orders" } }} />;
}

rows accepts immutable array references and copies the array for AG Grid. Replace the array when data changes; keep columns and native configuration stable when practical. columns is native ColDef<T>[], including React cell renderers. label is required and names both the enclosing region and the mounted grid. All copy and translations belong to the caller; pass localeText for AG Grid's built-in UI.

gridProps is the exported DataTableGridProps<T> alias for native AgGridReactProps<T>, excluding rowData and columnDefs. It accepts AG callbacks, editing/selection/filter options, custom renderers, gridOptions, modules, and themes. DDS defaults are local AllCommunityModule, sortable/resizable columns with minWidth: 120, and ddsGridTheme. Direct native properties override equivalent gridOptions values. Custom module sets must include modules required for their features and RenderApiModule for the required accessible label. DDS does not globally register modules or add selection/filtering/editing beyond native options.

gridRef is a normal React ref to AgGridReact<T>; access gridRef.current.api after onGridReady. It supports object refs and callback refs, including React 19 ref cleanup. The component's ref points to its enclosing HTMLDivElement. DOM props (id, className, style, event handlers) apply to that region.

density defaults to "comfortable" (40px rows, 44px headers); "dense" uses 32px rows and 36px headers. Explicit native rowHeight/headerHeight override density. Default height is 480px; use style={{ height: 640 }} to change it. The grid fills available width and retains minimum column widths, using AG Grid's horizontal scrolling on narrow screens. Choose native domLayout and container dimensions together if changing its layout.

The exported ddsGridTheme maps semantic DDS CSS variables to AG Grid's supported theme parameters. It follows the closest DDS token scope, including [data-theme="dark"]. Override with gridProps.theme, gridProps.gridOptions.theme, or ddsGridTheme.withParams(...). AG Grid generates its own theme CSS; do not load legacy AG Grid CSS alongside this default theme. AG Grid theme parameters support CSS variable color expressions.

SSR and worker imports are browser-global safe. Server rendering and the first hydration render emit the same named role="region" placeholder with aria-busy="true", a stable height, and optional caller-provided placeholder. A React effect then mounts AG Grid. Server markup contains no rendered grid rows or HTML table; provide a separate server summary if the page requires one. Native loading marks the mounted region busy and drives AG Grid's loading overlay. Empty arrays use AG Grid's native empty state. In React Server Component frameworks, use this component within a client component.

Community sorting, filtering, resizing, editing, selection, virtualization, and the infinite row model remain AG Grid behavior. The default client-side row model processes only the supplied rows: it cannot sort/filter an entire remote result when rows is one loaded page. For remote data, choose the Community infinite row model with a datasource and implement remote sorting/filtering in its getRows handler. Pass rows={[]} and configure the native datasource; rows/columns remain DDS-owned inputs. The Enterprise server-side row model, grouping, pivoting, and other commercial features are not bundled. Consumers who separately install/register Enterprise modules own their license and integration. AG Grid row models documents these boundaries.

Published ESM, declarations, and the explicit CSS export contain no Solid runtime dependency. DDS's source-available license is in LICENSE; AG Grid Community has its own MIT license.

版本与发布记录

@devslab/dds-table-react 共发布 23 个版本,首次发布于 2026/10/11;过去 12 个月发布了 23 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.33.0latest2026/11/12今天
0.32.22026/11/111 天前
0.32.12026/11/102 天前
0.32.02026/11/102 天前
0.31.02026/11/092 天前
0.30.02026/11/084 天前

关于 @devslab/dds-table-react 的常见问题

@devslab/dds-table-react 是什么?

DDS themed Community AG Grid for React

如何安装 @devslab/dds-table-react?

在项目目录运行 npm install @devslab/dds-table-react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.3.0 || ^19.0.0)、react-dom(^18.3.0 || ^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@devslab/dds-table-react 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@devslab/dds-table-react 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@devslab/dds-table-react 可以商用吗?

@devslab/dds-table-react 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@devslab/dds-table-react 的下载量有多少?

根据 npm 官方下载统计,@devslab/dds-table-react 在 2026/10/12 – 2026/11/10 这 30 天内被下载 2,544 次,日均约 85 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@devslab/dds-table-react 还在维护吗?

最新版本 0.33.0 发布于 2026/11/12(今天);至今共发布 23 个版本,其中过去 12 个月发布了 23 个;首次发布于 2026/10/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。