@brotskyllc/react-data-table

中文文档
0.1.0发布于 2026/10/06MITTypeScriptES Module近 30 天下载 6.8万

Controlled React data table rendering with selection, expansion, sorting, resizing and lazy drag support.

原始使用文档
文档目录3 节
  1. Usage
  2. Styling and customization
  3. Development and distribution

React Data Table

A controlled React 19 table renderer extracted from AEGIS's shared table. The host owns data fetching, search, filtering, pagination, selection state, preferences, business actions, and exports. No network or storage access is performed by this package.

MIT licensed. Source is public. The public npm package name is @brotskyllc/react-data-table; after its first release, install with npm install --save-exact @brotskyllc/[email protected]. Use npm view @brotskyllc/react-data-table version to check registry availability. A checksum-verified npm pack artifact is also supported. Preserve LICENSE and THIRD_PARTY_NOTICES.md when redistributing.

Usage

'use client';
import { DataTableCore, type TableColumn } from '@brotskyllc/react-data-table';

type Item = { id: string; name: string; count: number };
const columns: TableColumn<Item>[] = [
  { key: 'name', header: 'Name' },
  { key: 'count', header: 'Count', className: 'text-right' },
  { key: 'actions', header: 'Actions', render: (_value, row) => <button onClick={() => console.log(row.id)}>Open</button> },
];
export function Example({ rows }: { rows: Item[] }) {
  return <DataTableCore data={rows} columns={columns} scrollAreaLabel="Items"
    onSort={() => {}} onSelectAll={() => {}} onRowSelect={() => {}} />;
}

Use stable unique string id values for selection, expansion, dragging, and inline pickers. The index fallback is only suitable for static, non-interactive rows.

Styling and customization

The package uses Tailwind utilities and semantic tokens (background, foreground, muted, border, ring, primary, popover). Include its published source in the host's Tailwind scan. For Tailwind 4, add a path relative to the stylesheet:

@source "../../../node_modules/@brotskyllc/react-data-table/src";

For Tailwind 3 include ./node_modules/@brotskyllc/react-data-table/src/**/*.{ts,tsx} in content. Supply your existing light/dark theme and animation utilities.

  • columns: nested keys, custom cell rendering, widths, alignment, header tooltips, headerClassName and cell classes.
  • sort + onSort: controlled indicator and callback. The renderer never rearranges rows. sortRowsByColumn is an optional immutable client-sort helper.
  • selection, allSelected, hasSelectableRows, onSelectAll, onRowSelect: host-controlled state and eligibility. The host defines selection scope and keeps off-page selections.
  • expandableRows: controlled or local expansion with accessible toggle labels and panel IDs.
  • columnResize: a structural ColumnResizeApi adapter. The host owns measurement, bounds, storage and persistence. Controls support pointer dragging, arrows (Shift for larger steps), Home and double-click reset.
  • draggable: opt-in lazy drag-and-drop body and host onDragEnd; requires stable IDs. React Suspense replaces the original Next-specific loader.
  • rowClassName, row hover/click callbacks, test IDs, footer, emptyState, isTableLoading, and loadingRowCount cover presentation customization.
  • useDataTableRowPickerOpen: preserves inline picker state through row refreshes. Import this hook from the same package as the renderer so context identity stays shared.

Keep authentication, GraphQL types, application IDs, export auditing, saved views, responsive facet chrome, pagination and retry UI in the host. Business actions remain cell render functions supplied by the app.

Development and distribution

npm ci
npm run build
bun test
npm pack --dry-run
npm run check:package
npm run test:consumer

TypeScript emits ESM and declarations. React remains a peer dependency; third-party code is installed as dependencies rather than bundled. The client entry preserves use client; relative imports use .js for native ESM compatibility.

The build clears old output before compiling. The package audit inspects the real tarball, checks its allowlist, export targets, client boundaries and React peers, and scans for credential patterns, private imports and workstation paths. The consumer check installs that tarball into a temporary application, resolves both entries in native ESM, checks declarations with strict TypeScript settings, server-renders synthetic rows, and generates Tailwind 3 styles from the published source. It uses network access to install public dependencies and removes its temporary files on completion. Neither check publishes anything.

The initial adapters should be reviewed before expanding migration to other tables. No registry publish automation is configured. Registry publication requires owner approval, verified npm organization access and a final pack audit. Publish an approved tarball with npm publish <tarball> --access public --registry=https://registry.npmjs.org/. Never commit registry credentials.

版本与发布记录

@brotskyllc/react-data-table 共发布 2 个版本,首次发布于 2026/10/06;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.1.0latest2026/10/061 个月前
0.0.0-stage2026/10/061 个月前

关于 @brotskyllc/react-data-table 的常见问题

@brotskyllc/react-data-table 是什么?

Controlled React data table rendering with selection, expansion, sorting, resizing and lazy drag support.

如何安装 @brotskyllc/react-data-table?

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

@brotskyllc/react-data-table 支持 TypeScript 吗?

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

@brotskyllc/react-data-table 支持 ESM 还是 CommonJS?

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

@brotskyllc/react-data-table 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@brotskyllc/react-data-table 可以商用吗?

@brotskyllc/react-data-table 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@brotskyllc/react-data-table 的下载量有多少?

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

@brotskyllc/react-data-table 还在维护吗?

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