import React from "react"; import { type ViewStyle } from "react-native"; export interface DataTableColumn { /** Stable identifier for the column; also the default cell value source. */ key: string; /** Header label. */ header: string; /** Fixed width (px). Mutually exclusive with `flex`; `width` wins if both set. */ width?: number; /** Flex grow factor when no fixed `width` is given. Defaults to 1. */ flex?: number; /** Custom cell renderer. Receives the whole row. */ render?: (row: T) => React.ReactNode; /** Cell + header horizontal alignment. Defaults to "left". */ align?: "left" | "center" | "right"; } export interface DataTableProps { columns: DataTableColumn[]; data: T[]; /** Stable key for each row — required by the underlying list. */ keyExtractor: (row: T, index: number) => string; /** Row press handler; when set, rows become pressable. */ onRowPress?: (row: T) => void; /** Replaces the body with skeleton rows while true. */ loading?: boolean; /** Number of skeleton rows to show while loading. Defaults to 5. */ loadingRowCount?: number; /** Rendered when `data` is empty and not loading. */ emptyState?: React.ReactNode; /** Fallback empty message when `emptyState` is not provided. */ emptyMessage?: string; /** * Let the operator drag the boundary between two columns. * * Off by default, because it costs a measured container and per-column * width state — a table that never needs it should not pay for it. On, the * columns start at their `flex` share of the measured width (so the table * still fills its space) and a drag moves width between the pair either * side of the handle rather than growing the table. * * Web-oriented: the handles are 8px targets suited to a pointer. They * render on native too and work, but a phone is not where a column gets * dragged. */ resizable?: boolean; className?: string; } /** * Resolve a column's layout style. `width` (fixed px) takes precedence over * `flex` (grow factor, default 1). Kept pure so layout rules are unit-testable * without a render host. */ export declare function resolveColumnStyle(column: DataTableColumn): ViewStyle; /** Below this a cell shows nothing but its own padding. */ export declare const MIN_COLUMN_WIDTH = 64; /** * Starting widths for a resizable table: the container divided by flex, with * fixed-width columns taken out first. * * Pure so the layout rule is testable without a render host, and so the answer * is the same on the first frame as after a resize — a table that measures * itself and then computes differently is a table that jumps. */ export declare function distributeColumnWidths(columns: DataTableColumn[], totalWidth: number, minWidth?: number): number[]; /** * Apply one drag to a pair of adjacent columns. * * Resizing takes width from the NEIGHBOUR rather than from the table, so the * total stays put and the columns to the right do not crawl sideways as the * handle moves. Both sides clamp at `minWidth`, so a drag past the limit stops * instead of inverting the pair. */ export declare function resizeColumnPair(widths: number[], index: number, delta: number, minWidth?: number): number[]; /** Which body the table renders: skeleton rows, an empty placeholder, or data. */ export type DataTableBodyMode = "loading" | "empty" | "data"; /** * Decide the body mode from the loading flag + row count. Loading wins over * everything; an empty data set (when not loading) shows the empty state. * Pure so the branch logic is unit-testable without a render host. */ export declare function dataTableBodyMode(loading: boolean, rowCount: number): DataTableBodyMode; /** * Generic, typed data table for admin dashboards. Renders a sticky-ish header * row above a virtualised `FlatList` body (react-native's built-in list — the * package does not depend on `@shopify/flash-list`, and adding a runtime dep is * out of scope). Works on RN web (the primary admin target) and native. * * Loading shows skeleton rows; an empty data set shows `emptyState` (or * `emptyMessage`). Columns size by fixed `width` or `flex`, support custom * `render`, and alignment. */ export declare function DataTable({ columns, data, keyExtractor, onRowPress, loading, loadingRowCount, emptyState, emptyMessage, resizable, className, }: DataTableProps): React.JSX.Element; //# sourceMappingURL=data-table.d.ts.map