@bigcapitalhq/blueprintjs-react-table 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +218 -2
  2. package/dist/types/components/BP_Table.d.ts +106 -0
  3. package/dist/types/components/body/TableBody.d.ts +12 -0
  4. package/dist/types/components/body/TableBodyCell.d.ts +15 -0
  5. package/dist/types/components/body/TableGhostCell.d.ts +20 -0
  6. package/dist/types/components/body/TableGhostCells.d.ts +19 -0
  7. package/dist/types/components/body/TableRowHeaderCell.d.ts +13 -0
  8. package/dist/types/components/body/TableRowHeaders.d.ts +13 -0
  9. package/dist/types/components/body/TableStaticBody.d.ts +10 -0
  10. package/dist/types/components/body/VirtualBody.d.ts +12 -0
  11. package/dist/types/components/common/LoadableContent.d.ts +19 -0
  12. package/dist/types/components/common/cellCoordinates.d.ts +8 -0
  13. package/dist/types/components/common/classes.d.ts +100 -0
  14. package/dist/types/components/common/dimensions.d.ts +21 -0
  15. package/dist/types/components/common/region.d.ts +63 -0
  16. package/dist/types/components/common/table-selection-context.d.ts +3 -0
  17. package/dist/types/components/container/TableContainer.d.ts +24 -0
  18. package/dist/types/components/head/TableColumnHeaderMenu.d.ts +9 -0
  19. package/dist/types/components/head/TableColumnHeaders.d.ts +9 -0
  20. package/dist/types/components/head/TableHead.d.ts +11 -0
  21. package/dist/types/components/head/TableHeadCell.d.ts +10 -0
  22. package/dist/types/components/head/TableMenu.d.ts +6 -0
  23. package/dist/types/components/head/table-column-reorder-context.d.ts +3 -0
  24. package/dist/types/components/layers/TableRegionLayer.d.ts +10 -0
  25. package/dist/types/components/layers/TableReorderGuides.d.ts +8 -0
  26. package/dist/types/components/layers/TableResizeGuides.d.ts +11 -0
  27. package/dist/types/components/quadrant/TableBottomContainer.d.ts +14 -0
  28. package/dist/types/components/quadrant/TableQuadrant.d.ts +17 -0
  29. package/dist/types/components/quadrant/TableTopContainer.d.ts +11 -0
  30. package/dist/types/hooks/use-bp-table-instance.d.ts +2 -0
  31. package/dist/types/hooks/use-cell-focus-selection.d.ts +34 -0
  32. package/dist/types/hooks/use-column-reorder.d.ts +16 -0
  33. package/dist/types/hooks/use-ghost-cells.d.ts +43 -0
  34. package/dist/types/hooks/use-row-resizing.d.ts +57 -0
  35. package/dist/types/hooks/use-row-virtualizer.d.ts +15 -0
  36. package/dist/types/index.d.ts +17 -0
  37. package/dist/types/types.d.ts +65 -0
  38. package/package.json +83 -4
package/README.md CHANGED
@@ -1,3 +1,219 @@
1
- # Temporary Holding Version
1
+ # blueprintjs-react-table
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A Blueprint.js-styled data table for React, built on [TanStack Table v9](https://tanstack.com/table) with row virtualization from [TanStack Virtual](https://tanstack.com/virtual) and the look-and-feel of [Blueprint.js v6](https://blueprintjs.com/).
4
+
5
+ `BP_Table` recreates the classic Blueprint `<Table>` experience — a quadrant layout with frozen column and row headers, drag-to-reorder columns, sort menus, keyboard-driven focus and selection, and drag-to-resize rows — while keeping the full power of TanStack Table's headless API for data, columns, and state management. A Storybook is included to demo every feature.
6
+
7
+ ## Features
8
+
9
+ ### Layout & styling
10
+
11
+ - **Quadrant layout** — frozen column headers, row headers, and a scrollable body, rendered with Blueprint table styles.
12
+ - **Blueprint.js v6 skin** — cells, headers, selection overlays, and resize/reorder guides all use Blueprint colors and classes, so the table fits naturally into existing Blueprint apps.
13
+ - **Grouped column headers** — nested column definitions render on additional header rows; each group spans its child columns.
14
+ - **Ghost cells** — when the content is smaller than the viewport, leftover space is filled with empty cells (body, column headers, and row headers) instead of a blank background, and scrolling is disabled on the filled axes (`enableGhostCells`).
15
+
16
+ ### Interactivity
17
+
18
+ - **Column reordering** — drag column headers to reorder columns (`enableColumnReordering`).
19
+ - **Column resizing** — drag the resize handle on header cells (TanStack's `column.getResizeHandler()`).
20
+ - **Sorting** — hover a column header and use the chevron menu for *Sort Asc* / *Sort Desc* / *Clear Sort* (`enableSorting`); controlled or uncontrolled via `state.sorting` / `onSortingChange`.
21
+ - **Focused cell & keyboard navigation** — click a cell to focus it; arrow keys move focus, Shift+arrows extend the selection, and Cmd/Ctrl+A selects everything (`enableFocusedCell`).
22
+ - **Region selection** — select cells by dragging, or full rows / columns / the whole table from the headers and corner menu; controlled or uncontrolled (`selectedRegions` / `onSelection`, `selectionModes`).
23
+ - **Row resizing** — drag the horizontal handle at the bottom of a row header (`enableRowResizing`); controlled or uncontrolled, with configurable min/max heights.
24
+ - **Column visibility** — hide/show columns via the controlled `columnVisibility` prop or TanStack's standard state/`enableHiding` options.
25
+
26
+ ### Performance & data
27
+
28
+ - **Row virtualization** — only the visible rows (plus an overscan buffer) are rendered, so the table scales to tens of thousands of rows (`enableRowVirtualization`, `overscanRowCount`).
29
+ - **Full TanStack Table v9 option pass-through** — `columns`, `data`, `state`, `on*Change` callbacks, and every other table option are forwarded to `useReactTable`.
30
+ - **Loading skeletons** — render skeleton placeholders in the cells, column headers, and/or row headers (`loadingOptions`).
31
+ - **Column `meta` classnames** — style individual columns' body and header cells via `meta.bodyCellClassName` / `meta.headCellClassName`.
32
+
33
+ ## Requirements
34
+
35
+ - Node.js 18+
36
+ - React 18
37
+
38
+ ## Getting started
39
+
40
+ ```bash
41
+ npm install blueprintjs-react-table
42
+ ```
43
+
44
+ The table renders with Blueprint's visual language, so your app must already
45
+ be styled with Blueprint and have React 18 installed:
46
+
47
+ ```bash
48
+ npm install @blueprintjs/core @blueprintjs/icons react react-dom @tanstack/react-table @tanstack/react-virtual
49
+ ```
50
+
51
+ Import the compiled table styles once, alongside Blueprint's own styles (if
52
+ you don't already import them):
53
+
54
+ ```tsx
55
+ import '@blueprintjs/core/lib/css/blueprint.css';
56
+ import '@blueprintjs/icons/lib/css/blueprint-icons.css';
57
+ import 'blueprintjs-react-table/styles.css';
58
+
59
+ import { BP_Table } from 'blueprintjs-react-table';
60
+ ```
61
+
62
+ ```bash
63
+ # For developing this library:
64
+ npm install
65
+
66
+ # Run the Storybook with live demos of every feature
67
+ npm run storybook
68
+
69
+ # Run the bare Vite dev app
70
+ npm run dev
71
+ ```
72
+
73
+ Storybook is the primary way to explore the component: it contains stories for the basic table, column groups, loading states, ghost cells, focus & selection, sorting (controlled and uncontrolled), virtualization with 10,000 rows, column visibility, row resizing (controlled and uncontrolled), and editable cells.
74
+
75
+ ## Basic usage
76
+
77
+ `BP_Table` is a thin wrapper around TanStack Table: you define columns with `createColumnHelper` and pass `data` + `columns` in, exactly like any TanStack table.
78
+
79
+ ```tsx
80
+ import { BP_Table } from 'blueprintjs-react-table';
81
+ import { createColumnHelper } from '@tanstack/react-table';
82
+ import type { BP_TableFeatures } from 'blueprintjs-react-table';
83
+
84
+ type Person = {
85
+ id: number;
86
+ name: string;
87
+ age: number;
88
+ role: string;
89
+ };
90
+
91
+ const helper = createColumnHelper<BP_TableFeatures, Person>();
92
+
93
+ const columns = helper.columns([
94
+ helper.accessor('id', { header: 'ID' }),
95
+ helper.accessor('name', { header: 'Name' }),
96
+ helper.accessor('age', { header: 'Age' }),
97
+ helper.accessor('role', { header: 'Role' }),
98
+ ]);
99
+
100
+ const data: Person[] = [
101
+ { id: 1, name: 'Ada Lovelace', age: 36, role: 'Mathematician' },
102
+ { id: 2, name: 'Alan Turing', age: 41, role: 'Computer Scientist' },
103
+ { id: 3, name: 'Grace Hopper', age: 85, role: 'Admiral' },
104
+ ];
105
+
106
+ export function PeopleTable() {
107
+ return <BP_Table data={data} columns={columns} />;
108
+ }
109
+ ```
110
+
111
+ Enable Blueprint-style interactions with a few flags:
112
+
113
+ ```tsx
114
+ <BP_Table
115
+ data={data}
116
+ columns={columns}
117
+ enableColumnReordering
118
+ enableSorting
119
+ enableFocusedCell
120
+ enableRowResizing
121
+ />
122
+ ```
123
+
124
+ State can be controlled from outside the table through the standard TanStack props:
125
+
126
+ ```tsx
127
+ const [sorting, setSorting] = useState<SortingState>([]);
128
+
129
+ <BP_Table
130
+ data={data}
131
+ columns={columns}
132
+ enableSorting
133
+ state={{ sorting }}
134
+ onSortingChange={setSorting}
135
+ />;
136
+ ```
137
+
138
+ ## Core props
139
+
140
+ | Prop | Type | Default | Description |
141
+ | --- | --- | --- | --- |
142
+ | `data` / `columns` | TanStack `TableOptions` | — | Table data and column definitions (full TanStack option set is forwarded). |
143
+ | `rowHeight` | `number` | `20` | Height of each body row, in pixels. |
144
+ | `rowHeaderWidth` | `number` | `30` | Width of the frozen row-header column, in pixels. |
145
+ | `columnHeaderHeight` | `number` | `30` | Height of the frozen column-header row(s), in pixels. |
146
+ | `enableColumnReordering` | `boolean` | `false` | Drag column headers to reorder columns. |
147
+ | `enableSorting` | `boolean` | `false` | Chevron sort menu on sortable headers; also enables TanStack sorting. |
148
+ | `enableFocusedCell` | `boolean` | `false` | Focused cell with keyboard navigation and selection. |
149
+ | `enableGhostCells` | `boolean` | `false` | Fill leftover viewport space with empty cells (body, column headers, row headers) when the content doesn't overflow; scrolling is disabled on filled axes. |
150
+ | `focusedCell` / `onFocusedCell` | `FocusedCellCoordinates` / callback | — | Controlled focused cell. |
151
+ | `onFocusedRegion` | `(region) => void` | — | Fires when the focused region changes. |
152
+ | `selectedRegions` / `onSelection` | `Region[]` / callback | — | Controlled region selection. |
153
+ | `selectionModes` | `RegionCardinality[]` | all | Restricts which selection types are allowed (cells, rows, columns, table). |
154
+ | `enableRowVirtualization` | `boolean` | `false` | Render only visible rows (plus overscan) — scales to very large data sets. |
155
+ | `overscanRowCount` | `number` | `5` | Rows rendered above/below the viewport when virtualizing. |
156
+ | `columnVisibility` | `BP_VisibilityState` | — | Controlled column visibility (`true` = visible). Convenience alias for `state.columnVisibility`. |
157
+ | `enableRowResizing` | `boolean` | `false` | Drag the handle on a row header to resize that row. |
158
+ | `rowHeights` / `defaultRowHeights` | `Array<number \| undefined>` | — | Controlled / initial per-row heights; `undefined` falls back to `rowHeight`. |
159
+ | `onRowHeightChanged` | `(index, height) => void` | — | Fires continuously during a row-resize drag (and once when it ends). |
160
+ | `minRowHeight` / `maxRowHeight` | `number` | `6` / `100` | Clamps for row resizing. |
161
+ | `loadingOptions` | `TableLoadingOption[]` | `[]` | Renders skeleton placeholders: `CELLS`, `COLUMN_HEADERS`, `ROW_HEADERS`. |
162
+
163
+ ## Storybook stories
164
+
165
+ | Story | What it demos |
166
+ | --- | --- |
167
+ | `Basic` | Minimal table with column reordering. |
168
+ | `ColumnGroups` | Nested column definitions on a second header row. |
169
+ | `Loading` | Skeleton placeholders in cells, column headers, and row headers. |
170
+ | `GhostCells` | Empty ghost cells fill leftover space when the table is smaller than its viewport. |
171
+ | `FocusSelection` | Click/drag selection, row/column/corner-header selection, arrow-key focus, Shift+arrows, Cmd/Ctrl+A. |
172
+ | `Sorting` | Header chevron menu with Sort Asc / Sort Desc / Clear Sort. |
173
+ | `ControlledSorting` | Sorting state owned by the caller via `state` / `onSortingChange`. |
174
+ | `RowVirtualization` | 10,000 rows with only visible rows rendered. |
175
+ | `ColumnVisibility` | Controlled column visibility with `enableHiding: false` support. |
176
+ | `RowResizing` | Uncontrolled row resizing with `defaultRowHeights`. |
177
+ | `ControlledRowResizing` | Row heights owned by the caller via `rowHeights` / `onRowHeightChanged`. |
178
+ | `EditableCells` | Custom cell renderers (Blueprint `InputGroup`, `Checkbox`, `Tag`) with `meta.bodyCellClassName` styling. |
179
+
180
+ ## Scripts
181
+
182
+ | Command | Description |
183
+ | --- | --- |
184
+ | `npm run dev` | Start the Vite dev server. |
185
+ | `npm run build` | Type-check and build the publishable library (`dist/`: ESM + CJS bundles, `styles.css`, and `.d.ts` types). |
186
+ | `npm run preview` | Preview the production build locally. |
187
+ | `npm run lint` | Run ESLint. |
188
+ | `npm run storybook` | Start Storybook on port 6006. |
189
+ | `npm run build-storybook` | Build a static Storybook site. |
190
+
191
+ Publishing: `npm run build` runs automatically via `prepublishOnly` before
192
+ `npm publish`. The `dist/` directory is the only thing shipped in the npm
193
+ tarball.
194
+
195
+ ## Tech stack & structure
196
+
197
+ - **React 18** + **TypeScript** + **Vite**
198
+ - [**@blueprintjs/core** v6](https://www.npmjs.com/package/@blueprintjs/core) — visual language, skins, and demo controls
199
+ - [**@tanstack/react-table** v9](https://www.npmjs.com/package/@tanstack/react-table) — headless table core
200
+ - [**@tanstack/react-virtual**](https://www.npmjs.com/package/@tanstack/react-virtual) — row virtualization
201
+ - **Storybook 8** — feature demos and development harness
202
+
203
+ ```
204
+ src/
205
+ ├── components/
206
+ │ ├── BP_Table.tsx # Public component & props
207
+ │ ├── container/ # Scroll container and layout
208
+ │ ├── head/ # Column headers, sort menu, reordering
209
+ │ ├── body/ # Body cells, row headers, virtualization
210
+ │ ├── quadrant/ # Quadrant layout plumbing
211
+ │ ├── layers/ # Resize/reorder guides and overlays
212
+ │ └── common/ # Regions, dimensions, classes, contexts
213
+ ├── hooks/ # Focus/selection, reordering, resizing, virtualization
214
+ └── types.ts # Shared types (TableLoadingOption, BP_VisibilityState, …)
215
+ ```
216
+
217
+ > `BP_Table` lives in `src/components/BP_Table.tsx` and is the single source of
218
+ > truth for the public API documented above; `src/index.ts` re-exports it as
219
+ > the package entry point.
@@ -0,0 +1,106 @@
1
+ import type { BP_RowData, BP_TableFeatures, BP_TableOptions, BP_VisibilityState, HTMLPropsRef } from '../types.js';
2
+ import { TableLoadingOption } from '../types.js';
3
+ import type { FocusedCellCoordinates, FocusedRegion, Region, RegionCardinality } from './common/region.js';
4
+ export type BP_TableProps<TData extends BP_RowData> = BP_TableOptions<BP_TableFeatures, TData> & {
5
+ htmlProps?: HTMLPropsRef<HTMLDivElement>;
6
+ rowHeight?: number;
7
+ rowHeaderWidth?: number;
8
+ columnHeaderHeight?: number;
9
+ enableColumnReordering?: boolean;
10
+ loadingOptions?: TableLoadingOption[];
11
+ /**
12
+ * If `true`, a chevron menu appears on each sortable column header (on
13
+ * hover) with "Sort Asc" / "Sort Desc" actions, mirroring Blueprint's
14
+ * sortable table. The value is also forwarded to TanStack's
15
+ * `enableSorting` table option. Disable sorting for a specific column with
16
+ * `enableSorting: false` on its column definition.
17
+ *
18
+ * @default false
19
+ */
20
+ enableSorting?: boolean;
21
+ /**
22
+ * If `true`, a focusable "focused cell" is enabled: clicking a cell moves the
23
+ * focus there and arrow keys navigate between cells (with a blue focus border
24
+ * overlay), mirroring Blueprint's `enableFocusedCell`.
25
+ *
26
+ * @default false
27
+ */
28
+ enableFocusedCell?: boolean;
29
+ /**
30
+ * If `true`, empty space in the table container will be filled with empty
31
+ * cells instead of a blank background. Ghost cells render in the body, the
32
+ * column headers, and the row headers whenever the content is smaller than
33
+ * the viewport, and scrolling is disabled on the axes they fill, mirroring
34
+ * Blueprint's `enableGhostCells`.
35
+ *
36
+ * @default false
37
+ */
38
+ enableGhostCells?: boolean;
39
+ /**
40
+ * A controlled focused cell. When provided, focus state is fully owned by the
41
+ * caller and updated via `onFocusedCell`.
42
+ */
43
+ focusedCell?: FocusedCellCoordinates;
44
+ /** Callback invoked when the focused cell changes (controlled or uncontrolled). */
45
+ onFocusedCell?: (cell: FocusedCellCoordinates) => void;
46
+ /** Callback invoked when the focused region changes. */
47
+ onFocusedRegion?: (region: FocusedRegion) => void;
48
+ /**
49
+ * Controlled selected regions. When provided, selection state is fully owned
50
+ * by the caller and updated via `onSelection`.
51
+ */
52
+ selectedRegions?: Region[];
53
+ /** Callback invoked when the selected regions change. */
54
+ onSelection?: (regions: Region[]) => void;
55
+ /**
56
+ * Which region cardinalities are selectable. Defaults to all of them.
57
+ */
58
+ selectionModes?: RegionCardinality[];
59
+ /**
60
+ * If `true`, only the rows currently visible in the scroll container (plus
61
+ * an overscan buffer) are rendered, allowing the table to scale to very
62
+ * large data sets.
63
+ *
64
+ * @default false
65
+ */
66
+ enableRowVirtualization?: boolean;
67
+ /**
68
+ * Number of rows rendered above and below the visible viewport when
69
+ * `enableRowVirtualization` is enabled.
70
+ *
71
+ * @default 5
72
+ */
73
+ overscanRowCount?: number;
74
+ /**
75
+ * Controlled column visibility, mapping column ids to booleans (`true` =
76
+ * visible, `false` = hidden). Convenience alias for
77
+ * `state.columnVisibility`; when both are provided, this prop wins.
78
+ */
79
+ columnVisibility?: BP_VisibilityState;
80
+ /**
81
+ * If `true`, rows can be resized by dragging the horizontal handle at the
82
+ * bottom of each row header.
83
+ *
84
+ * @default false
85
+ */
86
+ enableRowResizing?: boolean;
87
+ /**
88
+ * Controlled per-row heights, indexed by row index. When provided, row
89
+ * heights are fully owned by the caller and updated via
90
+ * `onRowHeightChanged`. Entries of `undefined` fall back to `rowHeight`.
91
+ */
92
+ rowHeights?: Array<number | undefined>;
93
+ /** Initial per-row heights for the uncontrolled mode. */
94
+ defaultRowHeights?: Array<number | undefined>;
95
+ /**
96
+ * Listener invoked whenever a row's height changes. Fires continuously
97
+ * during a resize drag (and once more when it ends), in both the
98
+ * controlled and uncontrolled modes.
99
+ */
100
+ onRowHeightChanged?: (index: number, height: number) => void;
101
+ /** Minimum height a row can be resized to. @default 6 */
102
+ minRowHeight?: number;
103
+ /** Maximum height a row can be resized to. @default 100 */
104
+ maxRowHeight?: number;
105
+ };
106
+ export declare function BP_Table<TData extends BP_RowData>({ htmlProps, rowHeight, rowHeaderWidth, columnHeaderHeight, enableColumnReordering, enableSorting, loadingOptions, enableFocusedCell, enableGhostCells, focusedCell, onFocusedCell, onFocusedRegion, selectedRegions, onSelection, selectionModes, enableRowVirtualization, overscanRowCount, columnVisibility, enableRowResizing, rowHeights, defaultRowHeights, onRowHeightChanged, minRowHeight, maxRowHeight, ...tableOptions }: BP_TableProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import type { BP_GhostCells } from '../../hooks/use-ghost-cells.js';
2
+ import type { BP_RowVirtualizer } from '../../hooks/use-row-virtualizer.js';
3
+ import type { RowResizingApi } from '../../hooks/use-row-resizing.js';
4
+ import type { BP_RowData, BP_TableInstance, HTMLPropsRef } from '../../types.js';
5
+ export type TableBodyProps<TData extends BP_RowData> = HTMLPropsRef<HTMLDivElement> & {
6
+ table: BP_TableInstance<TData>;
7
+ areCellsLoading: boolean;
8
+ rowVirtualizer?: BP_RowVirtualizer;
9
+ rowResizing: RowResizingApi;
10
+ ghosts?: BP_GhostCells;
11
+ };
12
+ export declare function TableBody<TData extends BP_RowData>({ table, areCellsLoading, rowVirtualizer, rowResizing, ghosts, className, ...restProps }: TableBodyProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { type Cell } from '@tanstack/react-table';
2
+ import type { BP_RowData, BP_TableFeatures, BP_TableInstance } from '../../types.js';
3
+ export type TableBodyCellProps<TData extends BP_RowData> = {
4
+ table: BP_TableInstance<TData>;
5
+ cell: Cell<BP_TableFeatures, TData, unknown>;
6
+ rowIndex: number;
7
+ /** Absolute top offset of the row within the body's virtual client. */
8
+ rowTop: number;
9
+ columnIndex: number;
10
+ rowHeight: number;
11
+ loading: boolean;
12
+ isLastInRow: boolean;
13
+ isLastInColumn: boolean;
14
+ };
15
+ export declare function TableBodyCell<TData extends BP_RowData>({ table, cell, rowIndex, rowTop, columnIndex, rowHeight, loading, isLastInRow, isLastInColumn, }: TableBodyCellProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ export type TableGhostCellProps = {
2
+ /** Absolute column index (data columns first, then ghost columns). */
3
+ columnIndex: number;
4
+ /** Absolute row index (data rows first, then ghost rows). */
5
+ rowIndex: number;
6
+ /** Absolute left offset within the body's virtual client. */
7
+ left: number;
8
+ /** Absolute top offset within the body's virtual client. */
9
+ top: number;
10
+ width: number;
11
+ height: number;
12
+ loading: boolean;
13
+ };
14
+ /**
15
+ * An empty cell rendered beyond the data rows/columns to fill leftover
16
+ * viewport space when ghost cells are enabled (mirroring Blueprint's ghost
17
+ * cells). Ghost cells are not interactive: they render no content and carry no
18
+ * selection handlers, and `getCellFromPoint` ignores points beyond the grid.
19
+ */
20
+ export declare function TableGhostCell({ columnIndex, rowIndex, left, top, width, height, loading, }: TableGhostCellProps): import("react").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import type { BP_GhostCells } from '../../hooks/use-ghost-cells.js';
2
+ import type { RowResizingApi } from '../../hooks/use-row-resizing.js';
3
+ import type { BP_RowData, BP_TableInstance } from '../../types.js';
4
+ export type TableGhostCellsProps<TData extends BP_RowData> = {
5
+ table: BP_TableInstance<TData>;
6
+ ghosts: BP_GhostCells;
7
+ loading: boolean;
8
+ /** Indices of the data rows rendered alongside the ghost cells. */
9
+ rowIndices: number[];
10
+ rowResizing: RowResizingApi;
11
+ };
12
+ /**
13
+ * Renders the ghost-cell "L" region that fills leftover viewport space when
14
+ * ghost cells are enabled: empty columns to the right of the data (for the
15
+ * rendered data rows), empty rows below the data, and the corner block shared
16
+ * by both. Mirrors Blueprint's ghost cells, which use the default row height /
17
+ * column width regardless of the sizes of adjacent rows/columns.
18
+ */
19
+ export declare function TableGhostCells<TData extends BP_RowData>({ table, ghosts, loading, rowIndices, rowResizing, }: TableGhostCellsProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import type { RowResizeStartEvent } from '../../hooks/use-row-resizing.js';
2
+ import type { HTMLPropsRef } from '../../types.js';
3
+ export type TableRowHeaderCellProps = HTMLPropsRef<HTMLDivElement> & {
4
+ rowIndex: number;
5
+ rowHeight: number;
6
+ loading: boolean;
7
+ isLastInColumn: boolean;
8
+ /** Whether this row is currently being resized. */
9
+ isResizing?: boolean;
10
+ /** Handler for the horizontal resize handle; when undefined, the handle is hidden. */
11
+ onResizeStart?: (event: RowResizeStartEvent) => void;
12
+ };
13
+ export declare function TableRowHeaderCell({ rowIndex, rowHeight, loading, isLastInColumn, isResizing, onResizeStart, className, ...restProps }: TableRowHeaderCellProps): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import type { BP_GhostCells } from '../../hooks/use-ghost-cells.js';
2
+ import type { BP_RowVirtualizer } from '../../hooks/use-row-virtualizer.js';
3
+ import type { RowResizingApi } from '../../hooks/use-row-resizing.js';
4
+ import type { BP_RowData, BP_TableInstance, HTMLPropsRef } from '../../types.js';
5
+ export type TableRowHeadersProps<TData extends BP_RowData> = HTMLPropsRef<HTMLDivElement> & {
6
+ table: BP_TableInstance<TData>;
7
+ rowHeaderWidth: number;
8
+ areRowHeadersLoading: boolean;
9
+ rowVirtualizer?: BP_RowVirtualizer;
10
+ rowResizing: RowResizingApi;
11
+ ghosts?: BP_GhostCells;
12
+ };
13
+ export declare function TableRowHeaders<TData extends BP_RowData>({ table, rowHeaderWidth, areRowHeadersLoading, rowVirtualizer, rowResizing, ghosts, className, ...restProps }: TableRowHeadersProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import type { BP_GhostCells } from '../../hooks/use-ghost-cells.js';
2
+ import type { RowResizingApi } from '../../hooks/use-row-resizing.js';
3
+ import type { BP_RowData, BP_TableInstance, HTMLPropsRef } from '../../types.js';
4
+ export type TableStaticBodyProps<TData extends BP_RowData> = HTMLPropsRef<HTMLDivElement> & {
5
+ table: BP_TableInstance<TData>;
6
+ areCellsLoading: boolean;
7
+ rowResizing: RowResizingApi;
8
+ ghosts?: BP_GhostCells;
9
+ };
10
+ export declare function TableStaticBody<TData extends BP_RowData>({ table, areCellsLoading, rowResizing, ghosts, className, ...restProps }: TableStaticBodyProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import type { BP_GhostCells } from '../../hooks/use-ghost-cells.js';
2
+ import type { BP_RowVirtualizer } from '../../hooks/use-row-virtualizer.js';
3
+ import type { RowResizingApi } from '../../hooks/use-row-resizing.js';
4
+ import type { BP_RowData, BP_TableInstance, HTMLPropsRef } from '../../types.js';
5
+ export type VirtualBodyProps<TData extends BP_RowData> = HTMLPropsRef<HTMLDivElement> & {
6
+ table: BP_TableInstance<TData>;
7
+ areCellsLoading: boolean;
8
+ rowVirtualizer: BP_RowVirtualizer;
9
+ rowResizing: RowResizingApi;
10
+ ghosts?: BP_GhostCells;
11
+ };
12
+ export declare function VirtualBody<TData extends BP_RowData>({ table, areCellsLoading, rowVirtualizer, rowResizing, ghosts, className, ...restProps }: VirtualBodyProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import type { ReactNode } from 'react';
2
+ export type LoadableContentProps = {
3
+ children?: ReactNode;
4
+ /**
5
+ * If true, render a skeleton. Otherwise render the child content passed to this component.
6
+ */
7
+ loading: boolean;
8
+ /**
9
+ * If true, show a skeleton of random width (25-75% of the container width) when rendering the
10
+ * loading state.
11
+ *
12
+ * @default false
13
+ */
14
+ variableLength?: boolean;
15
+ };
16
+ /**
17
+ * Renders a skeleton placeholder while `loading` is true, otherwise renders the children.
18
+ */
19
+ export declare function LoadableContent({ loading, variableLength, children, }: LoadableContentProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import type { BP_RowData, BP_TableInstance } from '../../types.js';
2
+ import type { CellCoordinates } from './region.js';
3
+ /**
4
+ * Maps a point (relative to the top-left of the body cell client, where cells
5
+ * are absolutely positioned) to a cell coordinate, or `undefined` when the
6
+ * point falls outside the grid (e.g. on the ghost/empty area).
7
+ */
8
+ export declare function getCellFromPoint<TData extends BP_RowData>(table: BP_TableInstance<TData>, offsetLeft: number, offsetTop: number, getRowTop: (index: number) => number, getRowHeight: (index: number) => number): CellCoordinates | undefined;
@@ -0,0 +1,100 @@
1
+ export declare const TABLE_BODY_CELLS: string;
2
+ export declare const TABLE_BODY_SCROLLING_INDICATOR_OVERLAY: string;
3
+ export declare const TABLE_BODY_IS_SCROLLING_TOP: string;
4
+ export declare const TABLE_BODY_IS_SCROLLING_BOTTOM: string;
5
+ export declare const TABLE_BODY_IS_SCROLLING_RIGHT: string;
6
+ export declare const TABLE_BODY_IS_SCROLLING_LEFT: string;
7
+ export declare const TABLE_BODY_SCROLL_CLIENT: string;
8
+ export declare const TABLE_BODY_VIRTUAL_CLIENT: string;
9
+ export declare const TABLE_BOTTOM_CONTAINER: string;
10
+ export declare const TABLE_CELL: string;
11
+ export declare const TABLE_CELL_CLIENT: string;
12
+ export declare const TABLE_CELL_GHOST: string;
13
+ export declare const TABLE_CELL_INTERACTIVE: string;
14
+ export declare const TABLE_CELL_LEDGER_EVEN: string;
15
+ export declare const TABLE_CELL_LEDGER_ODD: string;
16
+ export declare const TABLE_COLUMN_HEADER_TR: string;
17
+ export declare const TABLE_COLUMN_HEADERS: string;
18
+ export declare const TABLE_COLUMN_HEADER_CELL: string;
19
+ export declare const TABLE_COLUMN_NAME: string;
20
+ export declare const TABLE_COLUMN_NAME_TEXT: string;
21
+ export declare const TABLE_CONTAINER: string;
22
+ export declare const TABLE_DRAGGING: string;
23
+ export declare const TABLE_EDITABLE_NAME: string;
24
+ export declare const TABLE_EDITABLE_TEXT: string;
25
+ export declare const TABLE_CELL_TEXT_PLACEHOLDER: string;
26
+ export declare const TABLE_FOCUS_REGION: string;
27
+ export declare const TABLE_HAS_INTERACTION_BAR: string;
28
+ export declare const TABLE_HAS_REORDER_HANDLE: string;
29
+ export declare const TABLE_HEADER: string;
30
+ export declare const TABLE_HEADER_ACTIVE: string;
31
+ export declare const TABLE_HEADER_CONTENT: string;
32
+ export declare const TABLE_HEADER_REORDERABLE: string;
33
+ export declare const TABLE_HEADER_SELECTED: string;
34
+ export declare const TABLE_HORIZONTAL_CELL_DIVIDER: string;
35
+ export declare const TABLE_HORIZONTAL_GUIDE: string;
36
+ export declare const TABLE_INTERACTION_BAR: string;
37
+ export declare const TABLE_LAST_IN_COLUMN: string;
38
+ export declare const TABLE_LAST_IN_ROW: string;
39
+ export declare const TABLE_MENU: string;
40
+ export declare const TABLE_NO_HORIZONTAL_SCROLL: string;
41
+ export declare const TABLE_NO_LAYOUT: string;
42
+ export declare const TABLE_NO_ROWS: string;
43
+ export declare const TABLE_NO_VERTICAL_SCROLL: string;
44
+ export declare const TABLE_NO_WRAP_TEXT: string;
45
+ export declare const TABLE_NULL: string;
46
+ export declare const TABLE_OVERLAY: string;
47
+ export declare const TABLE_OVERLAY_LAYER: string;
48
+ export declare const TABLE_OVERLAY_REORDERING_CURSOR: string;
49
+ export declare const TABLE_POPOVER_WHITESPACE_NORMAL: string;
50
+ export declare const TABLE_POPOVER_WHITESPACE_PRE: string;
51
+ export declare const TABLE_QUADRANT: string;
52
+ export declare const TABLE_QUADRANT_BODY_CONTAINER: string;
53
+ export declare const TABLE_QUADRANT_LEFT: string;
54
+ export declare const TABLE_QUADRANT_MAIN: string;
55
+ export declare const TABLE_QUADRANT_SCROLL_CONTAINER: string;
56
+ export declare const TABLE_QUADRANT_STACK: string;
57
+ export declare const TABLE_QUADRANT_TOP: string;
58
+ export declare const TABLE_QUADRANT_TOP_LEFT: string;
59
+ export declare const TABLE_REGION: string;
60
+ export declare const TABLE_REORDER_HANDLE: string;
61
+ export declare const TABLE_REORDER_HANDLE_TARGET: string;
62
+ export declare const TABLE_REORDERING: string;
63
+ export declare const TABLE_RESIZE_GUIDES: string;
64
+ export declare const TABLE_RESIZE_HANDLE: string;
65
+ export declare const TABLE_RESIZE_HANDLE_TARGET: string;
66
+ export declare const TABLE_RESIZE_HORIZONTAL: string;
67
+ export declare const TABLE_RESIZE_SENSOR: string;
68
+ export declare const TABLE_RESIZE_SENSOR_EXPAND: string;
69
+ export declare const TABLE_RESIZE_SENSOR_SHRINK: string;
70
+ export declare const TABLE_RESIZE_VERTICAL: string;
71
+ export declare const TABLE_ROUNDED_LAYOUT: string;
72
+ export declare const TABLE_ROW_HEADERS: string;
73
+ export declare const TABLE_ROW_HEADERS_CELLS_CONTAINER: string;
74
+ export declare const TABLE_ROW_NAME: string;
75
+ export declare const TABLE_ROW_NAME_TEXT: string;
76
+ export declare const TABLE_SELECTION_ENABLED: string;
77
+ export declare const TABLE_SELECTION_REGION: string;
78
+ export declare const TABLE_TH_MENU: string;
79
+ export declare const TABLE_TH_MENU_CONTAINER: string;
80
+ export declare const TABLE_TH_MENU_CONTAINER_BACKGROUND: string;
81
+ export declare const TABLE_TH_MENU_OPEN: string;
82
+ export declare const TABLE_TH_MENU_SELECT_CELLS: string;
83
+ export declare const TABLE_THEAD: string;
84
+ export declare const TABLE_TOP_CONTAINER: string;
85
+ export declare const TABLE_TRUNCATED_CELL: string;
86
+ export declare const TABLE_TRUNCATED_FORMAT: string;
87
+ export declare const TABLE_TRUNCATED_FORMAT_TEXT: string;
88
+ export declare const TABLE_TRUNCATED_POPOVER: string;
89
+ export declare const TABLE_TRUNCATED_POPOVER_TARGET: string;
90
+ export declare const TABLE_TRUNCATED_TEXT: string;
91
+ export declare const TABLE_TRUNCATED_VALUE: string;
92
+ export declare const TABLE_VERTICAL_GUIDE: string;
93
+ /** Return CSS class for table colummn index, whether or not 'pt-table-col-' prefix is included. */
94
+ export declare function columnIndexClass(columnIndex: string | number): string;
95
+ /** Return CSS class for table row index, whether or not 'pt-table-row-' prefix is included. */
96
+ export declare function rowIndexClass(rowIndex: string | number): string;
97
+ /** Return CSS class for table colummn cell index, whether or not 'pt-table-cell-col-' prefix is included. */
98
+ export declare function columnCellIndexClass(columnIndex: string | number): string;
99
+ /** Return CSS class for table row cell index, whether or not 'pt-table-cell-row-' prefix is included. */
100
+ export declare function rowCellIndexClass(rowIndex: string | number): string;
@@ -0,0 +1,21 @@
1
+ export declare const DEFAULT_ROW_HEIGHT = 20;
2
+ export declare const DEFAULT_ROW_HEADER_WIDTH = 30;
3
+ export declare const DEFAULT_COLUMN_HEADER_HEIGHT = 30;
4
+ /**
5
+ * Width of the empty "ghost" columns rendered when `enableGhostCells` is on.
6
+ * Mirrors Blueprint's `Grid.DEFAULT_GHOST_WIDTH` (which also matches TanStack's
7
+ * default column size of 150).
8
+ */
9
+ export declare const DEFAULT_GHOST_COLUMN_WIDTH = 150;
10
+ /**
11
+ * Safety caps for the number of ghost columns/rows rendered to fill the
12
+ * viewport. Mirrors Blueprint's `Grid.DEFAULT_MAX_COLUMNS` /
13
+ * `Grid.DEFAULT_MAX_ROWS`, which bound the ghost-cell search the same way.
14
+ */
15
+ export declare const MAX_GHOST_COLUMN_COUNT = 50;
16
+ export declare const MAX_GHOST_ROW_COUNT = 200;
17
+ export type TableLayout = {
18
+ rowHeight: number;
19
+ rowHeaderWidth: number;
20
+ columnHeaderHeight: number;
21
+ };
@@ -0,0 +1,63 @@
1
+ export declare enum RegionCardinality {
2
+ CELLS = "cells",
3
+ FULL_ROWS = "full-rows",
4
+ FULL_COLUMNS = "full-columns",
5
+ FULL_TABLE = "full-table"
6
+ }
7
+ export declare enum FocusMode {
8
+ CELL = "cell"
9
+ }
10
+ export declare enum Direction {
11
+ UP = "up",
12
+ DOWN = "down",
13
+ LEFT = "left",
14
+ RIGHT = "right"
15
+ }
16
+ export type CellInterval = [number, number];
17
+ export type CellCoordinates = {
18
+ row: number;
19
+ col: number;
20
+ };
21
+ export type FocusedCellCoordinates = CellCoordinates;
22
+ export type Region = {
23
+ rows?: CellInterval | null;
24
+ cols?: CellInterval | null;
25
+ };
26
+ export type NonNullRegion = Required<{
27
+ [P in keyof Region]: NonNullable<Region[P]>;
28
+ }>;
29
+ export type FocusedRegion = {
30
+ type: FocusMode.CELL;
31
+ row: number;
32
+ col: number;
33
+ focusSelectionIndex: number;
34
+ };
35
+ export type StyledRegionGroup = {
36
+ className?: string;
37
+ regions: Region[];
38
+ };
39
+ export declare class Regions {
40
+ static getRegionCardinality(region: Region): RegionCardinality;
41
+ static cell(row: number, col: number, row2?: number, col2?: number): NonNullRegion;
42
+ static row(row: number, row2?: number): Region;
43
+ static column(col: number, col2?: number): Region;
44
+ static table(): Region;
45
+ static copy(region: Region): Region;
46
+ static update(regions: Region[], region: Region, index?: number): Region[];
47
+ static clampRegion(region: Region, maxRowIndex: number, maxColumnIndex: number): Region;
48
+ static expandRegion(oldRegion: Region, newRegion: Region): Region;
49
+ static getRegionFromFocusedRegion(focusedRegion: FocusedRegion): Region;
50
+ static getCellRegionFromRegion(region: Region, numRows: number, numCols: number): NonNullRegion;
51
+ static getFocusCellCoordinatesFromRegion(region: Region): CellCoordinates;
52
+ static regionsEqual(regionA: Region, regionB: Region): boolean;
53
+ static joinStyledRegionGroups(selectedRegions: Region[] | undefined, focusedRegion: FocusedRegion | undefined): StyledRegionGroup[];
54
+ private static clamp;
55
+ private static intervalsEqual;
56
+ private static normalizeInterval;
57
+ }
58
+ export declare function directionToDelta(direction: Direction): {
59
+ rows: number;
60
+ cols: number;
61
+ };
62
+ export declare function moveFocusedCell(focusedCell: FocusedRegion, direction: Direction): FocusedRegion;
63
+ export declare function resizeRegion(region: Region, direction: Direction, focusedRegion?: FocusedRegion): Region;
@@ -0,0 +1,3 @@
1
+ import type { CellFocusSelectionApi } from '../../hooks/use-cell-focus-selection.js';
2
+ export declare const TableSelectionContext: import("react").Context<CellFocusSelectionApi | null>;
3
+ export declare function useTableSelection(): CellFocusSelectionApi | null;
@@ -0,0 +1,24 @@
1
+ import { RegionCardinality, type FocusedCellCoordinates, type FocusedRegion, type Region } from '../common/region.js';
2
+ import type { RowVirtualizerOptions } from '../../hooks/use-row-virtualizer.js';
3
+ import type { BP_RowData, BP_TableInstance, HTMLPropsRef, TableLoading } from '../../types.js';
4
+ import type { TableLayout } from '../common/dimensions.js';
5
+ export type TableContainerProps<TData extends BP_RowData> = HTMLPropsRef<HTMLDivElement> & TableLayout & TableLoading & Pick<RowVirtualizerOptions<TData>, 'enableRowVirtualization' | 'overscanRowCount'> & {
6
+ table: BP_TableInstance<TData>;
7
+ enableColumnReordering?: boolean;
8
+ enableSorting?: boolean;
9
+ enableFocusedCell?: boolean;
10
+ enableGhostCells?: boolean;
11
+ focusedCell?: FocusedCellCoordinates;
12
+ onFocusedCell?: (cell: FocusedCellCoordinates) => void;
13
+ onFocusedRegion?: (region: FocusedRegion) => void;
14
+ selectedRegions?: Region[];
15
+ onSelection?: (regions: Region[]) => void;
16
+ selectionModes?: RegionCardinality[];
17
+ enableRowResizing?: boolean;
18
+ rowHeights?: Array<number | undefined>;
19
+ defaultRowHeights?: Array<number | undefined>;
20
+ onRowHeightChanged?: (index: number, height: number) => void;
21
+ minRowHeight?: number;
22
+ maxRowHeight?: number;
23
+ };
24
+ export declare function TableContainer<TData extends BP_RowData>({ table, rowHeight, rowHeaderWidth, columnHeaderHeight, enableColumnReordering, enableSorting, areCellsLoading, areColumnHeadersLoading, areRowHeadersLoading, enableFocusedCell, enableGhostCells, focusedCell, onFocusedCell, onFocusedRegion, selectedRegions, onSelection, selectionModes, enableRowVirtualization, overscanRowCount, enableRowResizing, rowHeights, defaultRowHeights, onRowHeightChanged, minRowHeight, maxRowHeight, className, ...restProps }: TableContainerProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { type Header } from '@tanstack/react-table';
2
+ import type { BP_RowData, BP_TableFeatures, BP_TableInstance } from '../../types.js';
3
+ export type TableColumnHeaderMenuProps<TData extends BP_RowData> = {
4
+ table: BP_TableInstance<TData>;
5
+ header: Header<BP_TableFeatures, TData, unknown>;
6
+ isOpen: boolean;
7
+ onOpenChange: (isOpen: boolean) => void;
8
+ };
9
+ export declare function TableColumnHeaderMenu<TData extends BP_RowData>({ header, isOpen, onOpenChange, }: TableColumnHeaderMenuProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { type BP_GhostCells } from '../../hooks/use-ghost-cells.js';
2
+ import type { BP_RowData, BP_TableInstance, HTMLPropsRef } from '../../types.js';
3
+ export type TableColumnHeadersProps<TData extends BP_RowData> = HTMLPropsRef<HTMLDivElement> & {
4
+ table: BP_TableInstance<TData>;
5
+ enableSorting?: boolean;
6
+ areColumnHeadersLoading: boolean;
7
+ ghosts?: BP_GhostCells;
8
+ };
9
+ export declare function TableColumnHeaders<TData extends BP_RowData>({ table, enableSorting, areColumnHeadersLoading, ghosts, className, ...restProps }: TableColumnHeadersProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { type HeaderGroup } from '@tanstack/react-table';
2
+ import { type BP_GhostCells } from '../../hooks/use-ghost-cells.js';
3
+ import type { BP_RowData, BP_TableFeatures, BP_TableInstance } from '../../types.js';
4
+ export type TableHeadProps<TData extends BP_RowData> = {
5
+ table: BP_TableInstance<TData>;
6
+ headerGroup: HeaderGroup<BP_TableFeatures, TData>;
7
+ enableSorting?: boolean;
8
+ areColumnHeadersLoading: boolean;
9
+ ghosts?: BP_GhostCells;
10
+ };
11
+ export declare function TableHead<TData extends BP_RowData>({ table, headerGroup, enableSorting, areColumnHeadersLoading, ghosts, }: TableHeadProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { type Header } from '@tanstack/react-table';
2
+ import type { BP_RowData, BP_TableFeatures, BP_TableInstance } from '../../types.js';
3
+ export type TableHeadCellProps<TData extends BP_RowData> = {
4
+ table: BP_TableInstance<TData>;
5
+ header: Header<BP_TableFeatures, TData, unknown>;
6
+ isLastInRow: boolean;
7
+ enableSorting?: boolean;
8
+ loading: boolean;
9
+ };
10
+ export declare function TableHeadCell<TData extends BP_RowData>({ table, header, isLastInRow, enableSorting, loading, }: TableHeadCellProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import type { HTMLPropsRef } from '../../types.js';
2
+ export type TableMenuProps = HTMLPropsRef<HTMLDivElement> & {
3
+ width: number;
4
+ height: number;
5
+ };
6
+ export declare function TableMenu({ width, height, className, ...restProps }: TableMenuProps): import("react").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import type { ColumnReorderContextValue } from '../../hooks/use-column-reorder.js';
2
+ export declare const TableColumnReorderContext: import("react").Context<ColumnReorderContextValue | null>;
3
+ export declare function useTableColumnReorder(): ColumnReorderContextValue | null;
@@ -0,0 +1,10 @@
1
+ import { type StyledRegionGroup } from '../common/region.js';
2
+ import type { BP_RowData, BP_TableInstance } from '../../types.js';
3
+ export type TableRegionLayerProps<TData extends BP_RowData> = {
4
+ table: BP_TableInstance<TData>;
5
+ regionGroups: StyledRegionGroup[];
6
+ getRowTop: (index: number) => number;
7
+ getRowHeight: (index: number) => number;
8
+ totalHeight: number;
9
+ };
10
+ export declare function TableRegionLayer<TData extends BP_RowData>({ table, regionGroups, getRowTop, getRowHeight, totalHeight, }: TableRegionLayerProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import type { BP_RowData, BP_TableInstance } from '../../types.js';
2
+ export type TableReorderGuidesProps<TData extends BP_RowData> = {
3
+ table: BP_TableInstance<TData>;
4
+ reorderingColumnId: string | null;
5
+ guideIndex: number | null;
6
+ rowHeaderWidth: number;
7
+ };
8
+ export declare function TableReorderGuides<TData extends BP_RowData>({ table, reorderingColumnId, guideIndex, rowHeaderWidth, }: TableReorderGuidesProps<TData>): import("react").JSX.Element | null;
@@ -0,0 +1,11 @@
1
+ import type { BP_RowData, BP_TableInstance } from '../../types.js';
2
+ export type TableResizeGuidesProps<TData extends BP_RowData> = {
3
+ table: BP_TableInstance<TData>;
4
+ /** Absolute top of the horizontal guide while resizing a row, or `null`. */
5
+ resizingGuideTop?: number | null;
6
+ /** Height of the column-header area; offsets the horizontal guide into the body's coordinate space. */
7
+ columnHeaderHeight?: number;
8
+ /** Width of the row-header/menu area; offsets the vertical guide into the body's coordinate space. */
9
+ rowHeaderWidth?: number;
10
+ };
11
+ export declare function TableResizeGuides<TData extends BP_RowData>({ table, resizingGuideTop, columnHeaderHeight, rowHeaderWidth, }: TableResizeGuidesProps<TData>): import("react").JSX.Element | null;
@@ -0,0 +1,14 @@
1
+ import type { BP_GhostCells } from '../../hooks/use-ghost-cells.js';
2
+ import type { BP_RowVirtualizer } from '../../hooks/use-row-virtualizer.js';
3
+ import type { RowResizingApi } from '../../hooks/use-row-resizing.js';
4
+ import type { BP_RowData, BP_TableInstance, HTMLPropsRef } from '../../types.js';
5
+ export type TableBottomContainerProps<TData extends BP_RowData> = HTMLPropsRef<HTMLDivElement> & {
6
+ table: BP_TableInstance<TData>;
7
+ rowHeaderWidth: number;
8
+ areCellsLoading: boolean;
9
+ areRowHeadersLoading: boolean;
10
+ rowVirtualizer?: BP_RowVirtualizer;
11
+ rowResizing: RowResizingApi;
12
+ ghosts?: BP_GhostCells;
13
+ };
14
+ export declare function TableBottomContainer<TData extends BP_RowData>({ table, rowHeaderWidth, areCellsLoading, areRowHeadersLoading, rowVirtualizer, rowResizing, ghosts, className, ...restProps }: TableBottomContainerProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import type { MutableRefObject } from 'react';
2
+ import type { CellFocusSelectionApi } from '../../hooks/use-cell-focus-selection.js';
3
+ import { type RowVirtualizerOptions } from '../../hooks/use-row-virtualizer.js';
4
+ import type { RowResizingApi } from '../../hooks/use-row-resizing.js';
5
+ import type { BP_GhostCells } from '../../hooks/use-ghost-cells.js';
6
+ import type { BP_RowData, BP_TableInstance, HTMLPropsRef, TableLoading } from '../../types.js';
7
+ import type { TableLayout } from '../common/dimensions.js';
8
+ export type TableQuadrantProps<TData extends BP_RowData> = HTMLPropsRef<HTMLDivElement> & Pick<TableLayout, 'rowHeaderWidth' | 'columnHeaderHeight'> & TableLoading & Pick<RowVirtualizerOptions<TData>, 'enableRowVirtualization' | 'overscanRowCount'> & {
9
+ table: BP_TableInstance<TData>;
10
+ enableColumnReordering?: boolean;
11
+ enableSorting?: boolean;
12
+ selection: CellFocusSelectionApi;
13
+ rowResizing: RowResizingApi;
14
+ ghosts?: BP_GhostCells;
15
+ scrollContainerRef: MutableRefObject<HTMLDivElement | null>;
16
+ };
17
+ export declare function TableQuadrant<TData extends BP_RowData>({ table, rowHeaderWidth, columnHeaderHeight, enableColumnReordering, enableSorting, areCellsLoading, areColumnHeadersLoading, areRowHeadersLoading, selection, scrollContainerRef, enableRowVirtualization, overscanRowCount, rowResizing, ghosts, className, ...restProps }: TableQuadrantProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import type { BP_GhostCells } from '../../hooks/use-ghost-cells.js';
2
+ import type { BP_RowData, BP_TableInstance, HTMLPropsRef } from '../../types.js';
3
+ export type TableTopContainerProps<TData extends BP_RowData> = HTMLPropsRef<HTMLDivElement> & {
4
+ table: BP_TableInstance<TData>;
5
+ rowHeaderWidth: number;
6
+ columnHeaderHeight: number;
7
+ enableSorting?: boolean;
8
+ areColumnHeadersLoading: boolean;
9
+ ghosts?: BP_GhostCells;
10
+ };
11
+ export declare function TableTopContainer<TData extends BP_RowData>({ table, rowHeaderWidth, columnHeaderHeight, enableSorting, areColumnHeadersLoading, ghosts, className, ...restProps }: TableTopContainerProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { BP_RowData, BP_TableFeatures, BP_TableInstance, BP_TableOptions } from '../types.js';
2
+ export declare const useBPTableInstance: <TData extends BP_RowData>(definedTableOptions: BP_TableOptions<BP_TableFeatures, TData>) => BP_TableInstance<TData>;
@@ -0,0 +1,34 @@
1
+ import { type KeyboardEvent as ReactKeyboardEvent, type MouseEvent as ReactMouseEvent, type MutableRefObject, type PointerEvent as ReactPointerEvent } from 'react';
2
+ import type { BP_RowData, BP_TableInstance } from '../types.js';
3
+ import { RegionCardinality, type FocusedCellCoordinates, type FocusedRegion, type Region, type StyledRegionGroup } from '../components/common/region.js';
4
+ export type CellFocusSelectionOptions<TData extends BP_RowData> = {
5
+ table: BP_TableInstance<TData>;
6
+ /** Resolved absolute top offset of the row at the given index. */
7
+ getRowTop: (index: number) => number;
8
+ /** Resolved height of the row at the given index. */
9
+ getRowHeight: (index: number) => number;
10
+ scrollContainerRef: MutableRefObject<HTMLDivElement | null>;
11
+ enableFocusedCell?: boolean;
12
+ focusedCell?: FocusedCellCoordinates | undefined;
13
+ onFocusedCell?: (cell: FocusedCellCoordinates) => void;
14
+ onFocusedRegion?: (region: FocusedRegion) => void;
15
+ selectedRegions?: Region[] | undefined;
16
+ onSelection?: (regions: Region[]) => void;
17
+ enableMultipleSelection?: boolean;
18
+ selectionModes?: RegionCardinality[];
19
+ };
20
+ export type CellFocusSelectionApi = {
21
+ focusedRegion: FocusedRegion | undefined;
22
+ selectedRegions: Region[];
23
+ regionGroups: StyledRegionGroup[];
24
+ isSelectionModeEnabled: (cardinality: RegionCardinality) => boolean;
25
+ handleKeyDown: (event: ReactKeyboardEvent<HTMLDivElement>) => void;
26
+ handleBodyPointerDown: (event: ReactPointerEvent<HTMLDivElement>) => void;
27
+ handleBodyPointerMove: (event: ReactPointerEvent<HTMLDivElement>) => void;
28
+ handleBodyPointerUp: () => void;
29
+ handleBodyPointerCancel: () => void;
30
+ handleColumnHeaderMouseDown: (index: number, event: ReactMouseEvent) => void;
31
+ handleRowHeaderMouseDown: (index: number, event: ReactMouseEvent) => void;
32
+ handleMenuMouseDown: (event: ReactMouseEvent) => void;
33
+ };
34
+ export declare function useCellFocusSelection<TData extends BP_RowData>({ table, getRowTop, getRowHeight, scrollContainerRef, enableFocusedCell, focusedCell, onFocusedCell, onFocusedRegion, selectedRegions: controlledSelectedRegions, onSelection, selectionModes, }: CellFocusSelectionOptions<TData>): CellFocusSelectionApi;
@@ -0,0 +1,16 @@
1
+ import type { MutableRefObject, PointerEvent as ReactPointerEvent } from 'react';
2
+ import type { Column } from '@tanstack/react-table';
3
+ import type { BP_RowData, BP_TableFeatures, BP_TableInstance } from '../types.js';
4
+ export type ColumnReorderStartHandler = <TData extends BP_RowData>(column: Column<BP_TableFeatures, TData>, event: ReactPointerEvent<Element>) => void;
5
+ export type ColumnReorderContextValue = {
6
+ enableColumnReordering: boolean;
7
+ columnsRef: MutableRefObject<HTMLDivElement | null>;
8
+ reorderingColumnId: string | null;
9
+ startReorder: ColumnReorderStartHandler;
10
+ };
11
+ export declare function useColumnReorder<TData extends BP_RowData>(table: BP_TableInstance<TData>, enableColumnReordering: boolean): {
12
+ columnsRef: MutableRefObject<HTMLDivElement | null>;
13
+ contextValue: ColumnReorderContextValue;
14
+ guideIndex: number | null;
15
+ reorderingColumnId: string | null;
16
+ };
@@ -0,0 +1,43 @@
1
+ import type { MutableRefObject } from 'react';
2
+ /**
3
+ * Describes the empty "ghost" cells rendered beyond the table's data rows and
4
+ * columns when `enableGhostCells` is enabled and the content is smaller than
5
+ * the viewport (mirroring Blueprint's `enableGhostCells` table prop).
6
+ */
7
+ export type BP_GhostCells = {
8
+ /** Number of empty columns rendered to the right of the data columns. */
9
+ columnCount: number;
10
+ /** Number of empty rows rendered below the data rows. */
11
+ rowCount: number;
12
+ /** Width of each ghost column, in pixels. */
13
+ columnWidth: number;
14
+ /** Height of each ghost row, in pixels. */
15
+ rowHeight: number;
16
+ };
17
+ export type GhostCellsOptions = {
18
+ /** Whether ghost cells are enabled on the table. */
19
+ enableGhostCells: boolean;
20
+ /** Default row height; ghost rows use this height. */
21
+ rowHeight: number;
22
+ /** Width of the row-header column, subtracted from the viewport width. */
23
+ rowHeaderWidth: number;
24
+ /** Height of the column-header rows, subtracted from the viewport height. */
25
+ columnHeaderHeight: number;
26
+ /** Total width of all visible columns combined. */
27
+ totalWidth: number;
28
+ /** Total height of all rows combined. */
29
+ totalHeight: number;
30
+ /** The table's scroll container, used to measure the visible viewport. */
31
+ scrollContainerRef: MutableRefObject<HTMLDivElement | null>;
32
+ };
33
+ /**
34
+ * Measures the table's scroll container and computes the ghost cells needed to
35
+ * fill leftover viewport space. Returns `undefined` when ghost cells are
36
+ * disabled or when the content overflows (or exactly fits) both axes.
37
+ */
38
+ export declare function useGhostCells({ enableGhostCells, rowHeight, rowHeaderWidth, columnHeaderHeight, totalWidth, totalHeight, scrollContainerRef, }: GhostCellsOptions): BP_GhostCells | undefined;
39
+ /**
40
+ * Total width of the table's column area including ghost columns. Used to size
41
+ * the column-header rows so ghost header cells fit next to the data columns.
42
+ */
43
+ export declare function getGhostedTableWidth(totalWidth: number, ghosts?: BP_GhostCells): number;
@@ -0,0 +1,57 @@
1
+ import type { MouseEvent as ReactMouseEvent, TouchEvent as ReactTouchEvent } from 'react';
2
+ /** Minimum height a row can be resized to (mirrors Blueprint's MIN_ROW_HEIGHT). */
3
+ export declare const DEFAULT_MIN_ROW_HEIGHT = 6;
4
+ /** Maximum height a row can be resized to (mirrors Blueprint's MAX_ROW_HEIGHT). */
5
+ export declare const DEFAULT_MAX_ROW_HEIGHT = 100;
6
+ /** Event types emitted by the row header resize handle. */
7
+ export type RowResizeStartEvent = ReactMouseEvent<Element> | ReactTouchEvent<Element>;
8
+ /** Handler invoked when a resize drag starts from a row header's resize handle. */
9
+ export type RowResizeStartHandler = (index: number, event: RowResizeStartEvent) => void;
10
+ export type RowResizingOptions = {
11
+ /** Default height for rows that don't have an explicit height. */
12
+ rowHeight: number;
13
+ /** Number of rows in the table. */
14
+ rowCount: number;
15
+ /**
16
+ * Controlled per-row heights, indexed by row index. When provided, the
17
+ * table's row heights are fully owned by the caller, who updates them via
18
+ * `onRowHeightChanged`. Entries of `undefined` fall back to `rowHeight`.
19
+ */
20
+ rowHeights?: Array<number | undefined>;
21
+ /** Initial per-row heights for the uncontrolled mode. */
22
+ defaultRowHeights?: Array<number | undefined>;
23
+ /**
24
+ * If `true`, rows can be resized by dragging the horizontal handle at the
25
+ * bottom of each row header.
26
+ *
27
+ * @default false
28
+ */
29
+ enableRowResizing?: boolean;
30
+ /** Minimum height a row can be resized to. @default 6 */
31
+ minRowHeight?: number;
32
+ /** Maximum height a row can be resized to. @default 100 */
33
+ maxRowHeight?: number;
34
+ /**
35
+ * Listener invoked whenever a row's height changes. Fires continuously
36
+ * during a resize drag (and once more when it ends), in both the controlled
37
+ * and uncontrolled modes.
38
+ */
39
+ onRowHeightChanged?: (index: number, height: number) => void;
40
+ };
41
+ export type RowResizingApi = {
42
+ /** Whether row resizing is enabled. */
43
+ enabled: boolean;
44
+ /** Resolved height of the row at `index`. */
45
+ getRowHeight: (index: number) => number;
46
+ /** Resolved absolute top offset of the row at `index` within the body. */
47
+ getRowTop: (index: number) => number;
48
+ /** Total height of all rows combined. */
49
+ totalHeight: number;
50
+ /** Index of the row currently being resized, or `null`. */
51
+ resizingRowIndex: number | null;
52
+ /** Absolute top of the horizontal resize guide while resizing, or `null`. */
53
+ resizingGuideTop: number | null;
54
+ /** Begins resizing the row at `index`. Wire to the row header resize handle. */
55
+ startRowResize: RowResizeStartHandler;
56
+ };
57
+ export declare function useRowResizing({ rowHeight, rowCount, rowHeights, defaultRowHeights, enableRowResizing, minRowHeight, maxRowHeight, onRowHeightChanged, }: RowResizingOptions): RowResizingApi;
@@ -0,0 +1,15 @@
1
+ import { type Virtualizer } from '@tanstack/react-virtual';
2
+ import { type MutableRefObject } from 'react';
3
+ import type { BP_RowData, BP_TableInstance } from '../types.js';
4
+ export declare const DEFAULT_OVERSCAN_ROW_COUNT = 5;
5
+ export type BP_RowVirtualizer = Virtualizer<HTMLDivElement, HTMLDivElement>;
6
+ export type RowVirtualizerOptions<TData extends BP_RowData> = {
7
+ table: BP_TableInstance<TData>;
8
+ columnHeaderHeight: number;
9
+ /** Resolved height of the row at the given index (used to estimate item sizes). */
10
+ getRowHeight: (index: number) => number;
11
+ scrollContainerRef: MutableRefObject<HTMLDivElement | null>;
12
+ enableRowVirtualization: boolean;
13
+ overscanRowCount: number;
14
+ };
15
+ export declare function useRowVirtualizer<TData extends BP_RowData>({ table, columnHeaderHeight, getRowHeight, scrollContainerRef, enableRowVirtualization, overscanRowCount, }: RowVirtualizerOptions<TData>): BP_RowVirtualizer | undefined;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Public entry point for the `blueprintjs-react-table` package.
3
+ *
4
+ * Exports the `BP_Table` component and all public types used in its props,
5
+ * as well as the region / focus / selection types used by the focus and
6
+ * selection APIs.
7
+ *
8
+ * Importing the component does not inject any CSS. Include the compiled
9
+ * stylesheet once in your app:
10
+ *
11
+ * import 'blueprintjs-react-table/styles.css';
12
+ */
13
+
14
+ export { BP_Table } from './components/BP_Table.js';
15
+ export type { BP_TableProps } from './components/BP_Table.js';
16
+ export * from './types.js';
17
+ export * from './components/common/region.js';
@@ -0,0 +1,65 @@
1
+ import { type HTMLProps, type MutableRefObject } from 'react';
2
+ import { ColumnVisibilityState, RowData, TableFeatures, TableOptions, TableState, ReactTable, type CellData } from '@tanstack/react-table';
3
+ declare module '@tanstack/react-table' {
4
+ /**
5
+ * Extra metadata supported on column definitions, applied by `BP_Table` when
6
+ * rendering the table's cells.
7
+ */
8
+ interface ColumnMeta<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
9
+ /**
10
+ * Additional class name(s) applied to this column's body cells, e.g.
11
+ * `meta: { bodyCellClassName: 'my-cell' }`. Useful for styling cell
12
+ * contents (centering editors, removing cell padding, and so on).
13
+ */
14
+ bodyCellClassName?: string;
15
+ /** Additional class name(s) applied to this column's header cells. */
16
+ headCellClassName?: string;
17
+ /**
18
+ * Additional class name(s) applied to this column's footer cells.
19
+ * Reserved for forward compatibility: the table does not render footers
20
+ * yet, so this option currently has no effect.
21
+ */
22
+ footerCellClassName?: string;
23
+ }
24
+ }
25
+ export type LiteralUnion<T extends U, U = string> = (Record<never, never> & U) | T;
26
+ export type Prettify<T> = {
27
+ [K in keyof T]: T[K];
28
+ } & unknown;
29
+ export type Xor<A, B> = Prettify<{
30
+ [k in keyof A]?: never;
31
+ } & B> | Prettify<{
32
+ [k in keyof B]?: never;
33
+ } & A>;
34
+ export type HTMLPropsRef<T extends HTMLElement> = {
35
+ ref?: MutableRefObject<null | T> | null;
36
+ } & Omit<HTMLProps<T>, 'color' | 'data' | 'label' | 'ref' | 'size' | 'style' | 'type'>;
37
+ export type BP_DensityState = 'lg' | 'md' | 'sm' | 'xl' | 'xs';
38
+ export type BP_RowData<T = unknown> = Record<string, T>;
39
+ /**
40
+ * Loading options that can be passed to the table to render skeleton
41
+ * placeholders in the corresponding table regions.
42
+ */
43
+ export declare enum TableLoadingOption {
44
+ CELLS = "cells",
45
+ COLUMN_HEADERS = "column-header",
46
+ ROW_HEADERS = "row-header"
47
+ }
48
+ /** Returns true if the supplied loading option is present in the given array. */
49
+ export declare function hasLoadingOption<T extends string>(loadingOptions: readonly T[], loadingOption: T): boolean;
50
+ /** Which regions of the table are currently showing a loading placeholder. */
51
+ export type TableLoading = {
52
+ areCellsLoading: boolean;
53
+ areColumnHeadersLoading: boolean;
54
+ areRowHeadersLoading: boolean;
55
+ };
56
+ export type BP_CellValue = unknown;
57
+ export type BP_DefinedTableOptions<TFeatures extends TableFeatures, TData extends RowData> = Omit<TableOptions<TFeatures, TData>, 'features'>;
58
+ export type BP_TableOptions<TFeatures extends TableFeatures, TData extends RowData> = BP_DefinedTableOptions<TFeatures, TData> & {
59
+ features?: TableFeatures;
60
+ };
61
+ export type BP_TableFeatures = TableFeatures;
62
+ export type BP_TableState = TableState<BP_TableFeatures>;
63
+ /** Maps column ids to their visibility (`true` = visible, `false` = hidden). */
64
+ export type BP_VisibilityState = ColumnVisibilityState;
65
+ export type BP_TableInstance<TData extends BP_RowData = BP_RowData> = ReactTable<BP_TableFeatures, TData>;
package/package.json CHANGED
@@ -1,6 +1,85 @@
1
1
  {
2
2
  "name": "@bigcapitalhq/blueprintjs-react-table",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "A Blueprint.js-styled data table for React, built on TanStack Table v9 with row virtualization, quadrant layout, and Blueprint-style focus & selection.",
5
+ "type": "module",
6
+ "main": "./dist/blueprintjs-react-table.cjs",
7
+ "module": "./dist/blueprintjs-react-table.js",
8
+ "types": "./dist/types/index.d.ts",
9
+ "private": false,
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/types/index.d.ts",
13
+ "import": "./dist/blueprintjs-react-table.js",
14
+ "require": "./dist/blueprintjs-react-table.cjs"
15
+ },
16
+ "./styles.css": "./dist/styles.css",
17
+ "./package.json": "./package.json"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "sideEffects": [
26
+ "**/*.css"
27
+ ],
28
+ "keywords": [
29
+ "react",
30
+ "table",
31
+ "blueprint",
32
+ "blueprintjs",
33
+ "tanstack-table",
34
+ "datagrid",
35
+ "virtualized",
36
+ "typescript"
37
+ ],
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/bigcapitalhq/blueprintjs-react-table.git"
41
+ },
42
+ "scripts": {
43
+ "dev": "vite",
44
+ "build": "rm -rf dist && tsc -p tsconfig.build.json && vite build --config vite.lib.config.ts --emptyOutDir false && node scripts/fix-dts.mjs",
45
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
46
+ "preview": "vite preview",
47
+ "storybook": "storybook dev -p 6006",
48
+ "build-storybook": "storybook build",
49
+ "prepublishOnly": "npm run build"
50
+ },
51
+ "dependencies": {
52
+ "classnames": "^2.5.1"
53
+ },
54
+ "peerDependencies": {
55
+ "@blueprintjs/core": "^6.18.0",
56
+ "@blueprintjs/icons": "^6.13.0",
57
+ "@tanstack/react-table": "^9.0.0",
58
+ "@tanstack/react-virtual": "^3.14.9",
59
+ "react": "^18.2.0",
60
+ "react-dom": "^18.2.0"
61
+ },
62
+ "devDependencies": {
63
+ "@blueprintjs/core": "^6.18.0",
64
+ "@blueprintjs/icons": "^6.13.0",
65
+ "@storybook/addon-essentials": "^8.6.18",
66
+ "@storybook/react-vite": "^8.6.18",
67
+ "@tanstack/react-table": "^9.0.0",
68
+ "@tanstack/react-virtual": "^3.14.9",
69
+ "@types/react": "^18.2.55",
70
+ "@types/react-dom": "^18.2.19",
71
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
72
+ "@typescript-eslint/parser": "^6.21.0",
73
+ "@vitejs/plugin-react": "^4.2.1",
74
+ "eslint": "^8.56.0",
75
+ "eslint-plugin-react-hooks": "^4.6.0",
76
+ "eslint-plugin-react-refresh": "^0.4.5",
77
+ "eslint-plugin-storybook": "^0.11.6",
78
+ "react": "^18.2.0",
79
+ "react-dom": "^18.2.0",
80
+ "sass": "^1.102.0",
81
+ "storybook": "^8.6.18",
82
+ "typescript": "^5.2.2",
83
+ "vite": "^5.1.0"
84
+ }
85
+ }