import * as React from "react"; import { flexRender, type ColumnVisibilityState, type OnChangeFn, type PaginationState } from "@tanstack/react-table"; import type { BreakpointProp, ColumnDefProp, DensityProp, LabelProp, OnColumnFilterChangeProp, OnRowProp, RowToneProp, SortDirectionProp, SortStateProp, TableExpandableProp, TablePaginationProp, TablePresetProp, TableRowSelectionProp, TableScrollProp, TableStickyProp, TableSummaryProp } from "../../props/vocabulary/index.js"; export type Density = DensityProp; /** * Lean column definition — the simple, common-case column API. `render` shapes a cell; `sortable` * opts the column into the sort cycle; `align` / `width` / `pin` / `hideBelow` / `hiddenOnMobile` / * `priority` tune layout; `enableHiding` (default true) lists the column in DataTable.ViewOptions. */ export type ColumnDef = ColumnDefProp; /** Same resolution DataTable stamps as `data-hide-below` — `hiddenOnMobile: true` → `md`. */ export declare function resolveColumnHideBelow(col: Pick, "hideBelow" | "hiddenOnMobile">): BreakpointProp | undefined; interface DataTableProps { data: T[]; columns: ColumnDef[]; /** Required when `selectable` is true. Default: assume row.id (typed as any). */ getRowId?: (row: T) => string; /** * Human name of a row, announced by its selection checkbox or radio as "Select row {label}". * Default: the text of the `priority: "primary"` column, else of the first column, when that * value is a string or number; the row id only as a last resort — an id is a KEY, and announced * it reads a UUID aloud. `rowSelection.getCheckboxProps` `aria-label` still overrides a row. */ getRowLabel?: (row: T) => string; selectable?: boolean; selected?: Set; onSelectChange?: (next: Set) => void; onRowClick?: (row: T) => void; density?: Density; onDensityChange?: (d: Density) => void; /** Active sort state (lean surface). Pair with onSortChange for server sort. */ sort?: SortStateProp; onSortChange?: (sort: SortStateProp | undefined) => void; /** Global search term, surfaced by DataTable.Search. */ globalFilter?: string; onGlobalFilterChange?: (next: string) => void; /** * Numbered-pagination state, surfaced by DataTable.Pagination. THREE shapes, all accepted: * the TanStack `{ pageIndex, pageSize }` this prop has always taken; antd's * `TablePaginationConfig` object (`{ current, pageSize, total, pageSizeOptions, * showSizeChanger, showTotal, position, onChange }`, 1-based like antd); and `false`, which * hides the pager entirely (antd `pagination={false}`). The config object with NO composed * `` renders the table's own antd footer — the real `Pagination` with * total + page numbers at `position` (default `bottomEnd`), `size="sm"` on a compact table. * Server paging: `pagination={{ total, current, pageSize, onChange }}` with `data` = that page. */ pagination?: PaginationState | TablePaginationProp | false; onPaginationChange?: OnChangeFn; /** Total server row count (manual pagination) — drives the page count. */ rowCount?: number; /** Column show/hide state, surfaced by DataTable.ViewOptions. */ columnVisibility?: ColumnVisibilityState; onColumnVisibilityChange?: OnChangeFn; /** * Manual (server) flags. Default `false` so the simple `data`+`columns` case sorts / filters * in-browser with no extra wiring. */ manualSorting?: boolean; manualFiltering?: boolean; manualPagination?: boolean; /** Show a loading row instead of data. */ loading?: boolean; /** Custom empty content when `data` is empty; defaults to a built-in EmptyState. */ empty?: React.ReactNode; /** * `true` renders the built-in localized error message; any other node REPLACES it (e.g. an * `Alert` carrying an error code + request id). Pass `undefined`/`false` when the read * succeeded. */ error?: React.ReactNode; /** * `true` renders the built-in localized "no access" message; any other node replaces it. * Distinct from `error` so a 403 never offers a pointless retry. */ denied?: React.ReactNode; /** Retry handler for the built-in `error` state; omit to hide the retry action. */ onRetry?: () => void; /** * Zebra-stripe the body rows by LOGICAL record (an expanded detail row takes its record's stripe; * frozen columns wear it too). Omit to inherit the theme default `--table-row-striped-alpha`; * `true` / `false` override it for this table. */ striped?: boolean; /** Highlight a row on hover even when it is not clickable (no `onRowClick`). */ hoverable?: boolean; /** Pin the header to the top while the body scrolls. Default true. */ stickyHeader?: boolean; /** * `"default"` (the default) emits no attribute and matches no selector: an existing DataTable is * byte-identical. Mark each column with `priority` on its `ColumnDef`; DataTable stamps it on * the `` AND the `` for you. */ preset?: TablePresetProp; /** Default `"sm"`. Ignored while `preset` is `"default"`. */ collapseBelow?: BreakpointProp; /** * Accessible name for the horizontal-scroll REGION (the `tabindex="0"` wrapper a keyboard user * lands on), not for the ``. Optional: left out, the region takes the localized * `dataTable.scrollRegion` default, so no consumer has to invent a name for every list. The * region is announced only while it HAS overflow to reach. Same contract as `Table label`. * (gh#817) */ label?: LabelProp; /** * Per-row className for state-based row tinting (e.g. flag an invalid or empty record). Returned * classes are appended last, so they win over the built-in hover/selected fills. */ rowClassName?: (row: T) => string | undefined; /** * Per-row STATE, drawn as a leading-edge rail plus a wash — the same six tone names `Card accent` * carries, so a row that needs attention and a card that needs attention read as one vocabulary. * Return `undefined` for an ordinary row. * * This is the token-driven answer to what `rowClassName` could only do with utilities, and * `ui-audit` blocks those in a consumer: `rowClassName` matches the gate's `class`-name suffix * rule, so every colour and spacing rule scans the arrow body — a leading-edge border utility * plus a raw palette fill in there is two errors, not zero. Consumers fell back to a badge in a * cell instead. * * It is never the ONLY signal: colour alone cannot carry meaning (WCAG 1.4.1), so keep the * reason in a cell — a Badge, a status column — and let the rail make that cell findable in a * long table. */ rowTone?: RowToneProp; /** * Full row-selection configuration (antd `rowSelection`). Supersedes — and can be mixed with — * `selectable` / `selected` / `onSelectChange`, which drive the same state. */ rowSelection?: TableRowSelectionProp; /** Expandable detail rows (antd `expandable`). */ expandable?: TableExpandableProp; /** Footer totals row (antd `summary`) — rendered in a real `` so it survives sorting. */ summary?: TableSummaryProp; /** Scroll envelope (antd `scroll`) — `x` a minimum inline size, `y` a maximum body block size. */ scroll?: TableScrollProp; /** * Sticky header (antd `sticky`). Supersedes `stickyHeader` when given; the object form carries * the `offsetHeader` a page-level fixed topbar needs. */ sticky?: TableStickyProp; /** Per-row DOM props merged onto the `` (antd `onRow`). */ onRow?: OnRowProp; /** Draw the outer frame and the vertical rules between columns (antd `bordered`). */ bordered?: boolean; /** Explain the next sort step in a tooltip on every sortable header (antd `showSorterTooltip`). */ showSorterTooltip?: boolean; /** Table-wide sort cycle (antd `sortDirections`); a column's own value wins. */ sortDirections?: SortDirectionProp[]; /** * Column filters changed (antd hands the same map to `onChange`). Pair it with a column's * `filteredValue` to drive filtering from a server query. */ onFilterChange?: OnColumnFilterChangeProp; className?: string; children?: React.ReactNode; } export declare function DataTable({ data, columns, getRowId, getRowLabel, selectable, selected: controlledSelected, onSelectChange, onRowClick, density: controlledDensity, onDensityChange, sort, onSortChange, globalFilter: controlledGlobalFilter, onGlobalFilterChange, pagination: paginationProp, onPaginationChange, rowCount, columnVisibility: controlledVisibility, onColumnVisibilityChange, manualSorting, manualFiltering, manualPagination, loading, empty, error, denied, onRetry, striped, hoverable, stickyHeader, preset, collapseBelow, label, rowClassName, rowTone, rowSelection, expandable, summary, scroll, sticky, onRow, bordered, showSorterTooltip, sortDirections, onFilterChange, className, children, }: DataTableProps): React.JSX.Element; export declare namespace DataTable { export var Toolbar: ({ children, className, }: { children?: React.ReactNode; className?: string; }) => React.JSX.Element; export var Search: ({ placeholder, className, }: { placeholder?: string; className?: string; }) => React.JSX.Element; export var ViewOptions: ({ className, label, }: { className?: string; /** * Overrides the button's text. The default ("View") is the shortest thing * that fits a dense toolbar, but a product whose users know the control by a * longer name — "View Options", "表示項目" — needs to say that, and hiding a * bare text node from the outside is not something CSS can do. */ label?: React.ReactNode; }) => React.JSX.Element | null; export var SelectAll: () => React.JSX.Element | null; export var BulkActions: ({ count, children, className, }: BulkActionsProps) => React.JSX.Element | null; export var DensityToggle: () => React.JSX.Element; export var Content: () => React.JSX.Element; var _a: (props: PaginationProps) => React.JSX.Element; export { _a as Pagination }; export var RowActions: ({ ariaLabel, children }: RowActionsProps) => React.JSX.Element; } interface BulkActionsProps { count?: number; /** * Render-prop form receives the selected count; plain ReactNode children read * the count from selection state and render the built-in "N selected" status. */ children?: React.ReactNode | ((count: number) => React.ReactNode); className?: string; } interface CursorPaginationProps { cursor?: string; hasMore: boolean; onChange: (cursor: string | undefined) => void; className?: string; pageSizeOptions?: never; } interface NumberedPaginationProps { pageSizeOptions?: number[]; className?: string; cursor?: never; hasMore?: never; onChange?: never; } type PaginationProps = CursorPaginationProps | NumberedPaginationProps; interface RowActionsProps { ariaLabel?: string; children: React.ReactNode; } export { flexRender };