@bigcapitalhq/blueprintjs-react-table 0.0.0-stage → 0.3.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.
- package/README.md +456 -2
- package/dist/blueprintjs-react-table.cjs +6 -0
- package/dist/blueprintjs-react-table.cjs.map +1 -0
- package/dist/blueprintjs-react-table.js +2533 -0
- package/dist/blueprintjs-react-table.js.map +1 -0
- package/dist/styles.css +1 -0
- package/dist/types/components/BP_Table.d.ts +219 -0
- package/dist/types/components/body/TableBody.d.ts +29 -0
- package/dist/types/components/body/TableBodyCell.d.ts +18 -0
- package/dist/types/components/body/TableGhostCell.d.ts +20 -0
- package/dist/types/components/body/TableGhostCells.d.ts +33 -0
- package/dist/types/components/body/TableRowHeaderCell.d.ts +19 -0
- package/dist/types/components/body/TableRowHeaders.d.ts +28 -0
- package/dist/types/components/body/TableRowSelectionCell.d.ts +18 -0
- package/dist/types/components/common/LoadableContent.d.ts +19 -0
- package/dist/types/components/common/cell-selection.d.ts +57 -0
- package/dist/types/components/common/cellCoordinates.d.ts +29 -0
- package/dist/types/components/common/classes.d.ts +108 -0
- package/dist/types/components/common/dimensions.d.ts +26 -0
- package/dist/types/components/common/menu-context.d.ts +81 -0
- package/dist/types/components/common/pinning.d.ts +44 -0
- package/dist/types/components/common/region.d.ts +89 -0
- package/dist/types/components/common/table-selection-context.d.ts +3 -0
- package/dist/types/components/container/TableContainer.d.ts +30 -0
- package/dist/types/components/head/TableColumnHeaderMenu.d.ts +9 -0
- package/dist/types/components/head/TableColumnHeaders.d.ts +12 -0
- package/dist/types/components/head/TableHead.d.ts +13 -0
- package/dist/types/components/head/TableHeadCell.d.ts +10 -0
- package/dist/types/components/head/TableMenu.d.ts +6 -0
- package/dist/types/components/head/TableRowSelectionHeaderCell.d.ts +13 -0
- package/dist/types/components/head/table-column-reorder-context.d.ts +3 -0
- package/dist/types/components/layers/TableRegionLayer.d.ts +18 -0
- package/dist/types/components/layers/TableReorderGuides.d.ts +17 -0
- package/dist/types/components/layers/TableResizeGuides.d.ts +24 -0
- package/dist/types/components/pagination/TablePaginationBar.d.ts +30 -0
- package/dist/types/components/pagination/constants.d.ts +4 -0
- package/dist/types/components/pagination/withPagination.d.ts +51 -0
- package/dist/types/components/quadrant/TableQuadrant.d.ts +48 -0
- package/dist/types/components/quadrant/TableQuadrantStack.d.ts +38 -0
- package/dist/types/components/quadrant/quadrant-type.d.ts +10 -0
- package/dist/types/hooks/use-bp-table-instance.d.ts +33 -0
- package/dist/types/hooks/use-cell-selection.d.ts +62 -0
- package/dist/types/hooks/use-column-header-height.d.ts +24 -0
- package/dist/types/hooks/use-column-reorder.d.ts +20 -0
- package/dist/types/hooks/use-freeze-pinning.d.ts +25 -0
- package/dist/types/hooks/use-ghost-cells.d.ts +43 -0
- package/dist/types/hooks/use-row-resizing.d.ts +57 -0
- package/dist/types/hooks/use-row-virtualizer.d.ts +26 -0
- package/dist/types/hooks/use-uncontrolled.d.ts +19 -0
- package/dist/types/index.d.ts +25 -0
- package/dist/types/types.d.ts +76 -0
- package/package.json +83 -4
|
@@ -0,0 +1,108 @@
|
|
|
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_PAGINATION_BAR: string;
|
|
50
|
+
export declare const TABLE_PAGINATION_BAR_CONTROLS: string;
|
|
51
|
+
export declare const TABLE_PAGINATION_BAR_TEXT: string;
|
|
52
|
+
export declare const TABLE_PAGINATION_LAYOUT: string;
|
|
53
|
+
export declare const TABLE_POPOVER_WHITESPACE_NORMAL: string;
|
|
54
|
+
export declare const TABLE_POPOVER_WHITESPACE_PRE: string;
|
|
55
|
+
export declare const TABLE_QUADRANT: string;
|
|
56
|
+
export declare const TABLE_QUADRANT_BODY_CONTAINER: string;
|
|
57
|
+
export declare const TABLE_QUADRANT_LEFT: string;
|
|
58
|
+
export declare const TABLE_QUADRANT_MAIN: string;
|
|
59
|
+
export declare const TABLE_QUADRANT_SCROLL_CONTAINER: string;
|
|
60
|
+
export declare const TABLE_QUADRANT_STACK: string;
|
|
61
|
+
export declare const TABLE_QUADRANT_TOP: string;
|
|
62
|
+
export declare const TABLE_QUADRANT_TOP_LEFT: string;
|
|
63
|
+
export declare const TABLE_REGION: string;
|
|
64
|
+
export declare const TABLE_REORDER_HANDLE: string;
|
|
65
|
+
export declare const TABLE_REORDER_HANDLE_TARGET: string;
|
|
66
|
+
export declare const TABLE_REORDERING: string;
|
|
67
|
+
export declare const TABLE_RESIZE_GUIDES: string;
|
|
68
|
+
export declare const TABLE_RESIZE_HANDLE: string;
|
|
69
|
+
export declare const TABLE_RESIZE_HANDLE_TARGET: string;
|
|
70
|
+
export declare const TABLE_RESIZE_HORIZONTAL: string;
|
|
71
|
+
export declare const TABLE_RESIZE_SENSOR: string;
|
|
72
|
+
export declare const TABLE_RESIZE_SENSOR_EXPAND: string;
|
|
73
|
+
export declare const TABLE_RESIZE_SENSOR_SHRINK: string;
|
|
74
|
+
export declare const TABLE_RESIZE_VERTICAL: string;
|
|
75
|
+
export declare const TABLE_ROUNDED_LAYOUT: string;
|
|
76
|
+
export declare const TABLE_ROW_HEADERS: string;
|
|
77
|
+
export declare const TABLE_ROW_HEADERS_CELLS_CONTAINER: string;
|
|
78
|
+
export declare const TABLE_ROW_NAME: string;
|
|
79
|
+
export declare const TABLE_ROW_NAME_TEXT: string;
|
|
80
|
+
export declare const TABLE_ROW_SELECTED: string;
|
|
81
|
+
export declare const TABLE_ROW_SELECTION_CELL: string;
|
|
82
|
+
export declare const TABLE_ROW_SELECTION_CHECKBOX: string;
|
|
83
|
+
export declare const TABLE_ROW_SELECTION_HEADER_CELL: string;
|
|
84
|
+
export declare const TABLE_SELECTION_ENABLED: string;
|
|
85
|
+
export declare const TABLE_SELECTION_REGION: string;
|
|
86
|
+
export declare const TABLE_TH_MENU: string;
|
|
87
|
+
export declare const TABLE_TH_MENU_CONTAINER: string;
|
|
88
|
+
export declare const TABLE_TH_MENU_CONTAINER_BACKGROUND: string;
|
|
89
|
+
export declare const TABLE_TH_MENU_OPEN: string;
|
|
90
|
+
export declare const TABLE_TH_MENU_SELECT_CELLS: string;
|
|
91
|
+
export declare const TABLE_THEAD: string;
|
|
92
|
+
export declare const TABLE_TOP_CONTAINER: string;
|
|
93
|
+
export declare const TABLE_TRUNCATED_CELL: string;
|
|
94
|
+
export declare const TABLE_TRUNCATED_FORMAT: string;
|
|
95
|
+
export declare const TABLE_TRUNCATED_FORMAT_TEXT: string;
|
|
96
|
+
export declare const TABLE_TRUNCATED_POPOVER: string;
|
|
97
|
+
export declare const TABLE_TRUNCATED_POPOVER_TARGET: string;
|
|
98
|
+
export declare const TABLE_TRUNCATED_TEXT: string;
|
|
99
|
+
export declare const TABLE_TRUNCATED_VALUE: string;
|
|
100
|
+
export declare const TABLE_VERTICAL_GUIDE: string;
|
|
101
|
+
/** Return CSS class for table colummn index, whether or not 'pt-table-col-' prefix is included. */
|
|
102
|
+
export declare function columnIndexClass(columnIndex: string | number): string;
|
|
103
|
+
/** Return CSS class for table row index, whether or not 'pt-table-row-' prefix is included. */
|
|
104
|
+
export declare function rowIndexClass(rowIndex: string | number): string;
|
|
105
|
+
/** Return CSS class for table colummn cell index, whether or not 'pt-table-cell-col-' prefix is included. */
|
|
106
|
+
export declare function columnCellIndexClass(columnIndex: string | number): string;
|
|
107
|
+
/** Return CSS class for table row cell index, whether or not 'pt-table-cell-row-' prefix is included. */
|
|
108
|
+
export declare function rowCellIndexClass(rowIndex: string | number): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
* Default width of the row-selection checkboxes column rendered (when enabled)
|
|
6
|
+
* between the row numbers and the frozen columns.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_ROW_SELECTION_COLUMN_WIDTH = 30;
|
|
9
|
+
/**
|
|
10
|
+
* Width of the empty "ghost" columns rendered when `enableGhostCells` is on.
|
|
11
|
+
* Mirrors Blueprint's `Grid.DEFAULT_GHOST_WIDTH` (which also matches TanStack's
|
|
12
|
+
* default column size of 150).
|
|
13
|
+
*/
|
|
14
|
+
export declare const DEFAULT_GHOST_COLUMN_WIDTH = 150;
|
|
15
|
+
/**
|
|
16
|
+
* Safety caps for the number of ghost columns/rows rendered to fill the
|
|
17
|
+
* viewport. Mirrors Blueprint's `Grid.DEFAULT_MAX_COLUMNS` /
|
|
18
|
+
* `Grid.DEFAULT_MAX_ROWS`, which bound the ghost-cell search the same way.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MAX_GHOST_COLUMN_COUNT = 50;
|
|
21
|
+
export declare const MAX_GHOST_ROW_COUNT = 200;
|
|
22
|
+
export type TableLayout = {
|
|
23
|
+
rowHeight: number;
|
|
24
|
+
rowHeaderWidth: number;
|
|
25
|
+
columnHeaderHeight: number;
|
|
26
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { Cell, Row } from '@tanstack/react-table';
|
|
3
|
+
import type { BP_RowData, BP_TableFeatures, BP_TableInstance } from '../../types.js';
|
|
4
|
+
import { type CellCoordinates, type NonNullRegion, type Region } from './region.js';
|
|
5
|
+
/**
|
|
6
|
+
* Describes the region(s) of interest for a body context menu, mirroring
|
|
7
|
+
* Blueprint's `MenuContext`.
|
|
8
|
+
*/
|
|
9
|
+
export interface BP_MenuContext<TData extends BP_RowData = BP_RowData> {
|
|
10
|
+
/**
|
|
11
|
+
* Returns a region containing the single cell that was right-clicked to
|
|
12
|
+
* launch this context menu.
|
|
13
|
+
*/
|
|
14
|
+
getTarget(): NonNullRegion;
|
|
15
|
+
/**
|
|
16
|
+
* Returns an array of `Region`s that represent the user-intended context of
|
|
17
|
+
* this menu. If the right-click happened inside the current selection, the
|
|
18
|
+
* array contains all selected regions. Otherwise it contains one `Region`
|
|
19
|
+
* that represents the right-clicked cell (the same region from
|
|
20
|
+
* `getTarget`).
|
|
21
|
+
*/
|
|
22
|
+
getRegions(): Region[];
|
|
23
|
+
/**
|
|
24
|
+
* Returns the list of selected `Region`s in the table, regardless of where
|
|
25
|
+
* the user right-clicked to launch the context menu. For the user-intended
|
|
26
|
+
* regions for this context, use `getRegions` instead.
|
|
27
|
+
*/
|
|
28
|
+
getSelectedRegions(): Region[];
|
|
29
|
+
/**
|
|
30
|
+
* Returns an array containing all of the unique, potentially non-contiguous,
|
|
31
|
+
* cells contained in all the regions from `getRegions`. The cell
|
|
32
|
+
* coordinates are sorted by row and then column.
|
|
33
|
+
*/
|
|
34
|
+
getUniqueCells(): CellCoordinates[];
|
|
35
|
+
/**
|
|
36
|
+
* Returns the TanStack row that was right-clicked, or `undefined` when the
|
|
37
|
+
* click did not land on a body cell.
|
|
38
|
+
*/
|
|
39
|
+
getTargetRow(): Row<BP_TableFeatures, TData> | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the TanStack cell that was right-clicked, or `undefined` when the
|
|
42
|
+
* click did not land on a body cell.
|
|
43
|
+
*/
|
|
44
|
+
getTargetCell(): Cell<BP_TableFeatures, TData, unknown> | undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Renders a context menu for the table body, mirroring Blueprint's
|
|
48
|
+
* `bodyContextMenuRenderer`. Return `undefined` (or `null`) to fall back to
|
|
49
|
+
* the browser's native context menu.
|
|
50
|
+
*/
|
|
51
|
+
export type BP_BodyContextMenuRenderer<TData extends BP_RowData = BP_RowData> = (context: BP_MenuContext<TData>) => ReactElement | null | undefined;
|
|
52
|
+
export type BP_MenuContextOptions<TData extends BP_RowData> = {
|
|
53
|
+
table: BP_TableInstance<TData>;
|
|
54
|
+
/** The right-clicked cell, as a single-cell region. */
|
|
55
|
+
target: NonNullRegion;
|
|
56
|
+
/** The table's current selection, unaffected by the right-click itself. */
|
|
57
|
+
selectedRegions: Region[];
|
|
58
|
+
numRows: number;
|
|
59
|
+
numCols: number;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Concrete {@link BP_MenuContext}. The user-intended regions are the current
|
|
63
|
+
* selection when it contains the right-clicked cell, and the cell itself
|
|
64
|
+
* otherwise.
|
|
65
|
+
*/
|
|
66
|
+
export declare class BP_MenuContextImpl<TData extends BP_RowData> implements BP_MenuContext<TData> {
|
|
67
|
+
private readonly target;
|
|
68
|
+
private readonly regions;
|
|
69
|
+
private readonly selectedRegions;
|
|
70
|
+
private readonly numRows;
|
|
71
|
+
private readonly numCols;
|
|
72
|
+
private readonly targetRow;
|
|
73
|
+
private readonly targetCell;
|
|
74
|
+
constructor({ table, target, selectedRegions, numRows, numCols }: BP_MenuContextOptions<TData>);
|
|
75
|
+
getTarget(): NonNullRegion;
|
|
76
|
+
getRegions(): Region[];
|
|
77
|
+
getSelectedRegions(): Region[];
|
|
78
|
+
getUniqueCells(): CellCoordinates[];
|
|
79
|
+
getTargetRow(): Row<BP_TableFeatures, TData> | undefined;
|
|
80
|
+
getTargetCell(): Cell<BP_TableFeatures, TData, unknown> | undefined;
|
|
81
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Column } from '@tanstack/react-table';
|
|
2
|
+
import type { BP_RowData, BP_TableFeatures, BP_TableInstance } from '../../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* A horizontal region of columns: frozen ("start") or scrollable ("center").
|
|
5
|
+
*
|
|
6
|
+
* `BP_Table` renders the frozen ("start") region in the left quadrants and the
|
|
7
|
+
* scrollable ("center") region in the main/top quadrants. Columns pinned to
|
|
8
|
+
* the logical "end" region are not supported and are excluded from both
|
|
9
|
+
* regions, matching Blueprint's left-only frozen columns.
|
|
10
|
+
*/
|
|
11
|
+
export type ColumnRegion = 'start' | 'center';
|
|
12
|
+
/** A vertical region of rows: frozen ("top") or scrollable ("center"). */
|
|
13
|
+
export type RowRegion = 'top' | 'center';
|
|
14
|
+
/** Number of columns frozen to the logical "start" (left) region. */
|
|
15
|
+
export declare function getFrozenColumnCount<TData extends BP_RowData>(table: BP_TableInstance<TData>): number;
|
|
16
|
+
/** Number of rows frozen to the "top" region. */
|
|
17
|
+
export declare function getFrozenRowCount<TData extends BP_RowData>(table: BP_TableInstance<TData>): number;
|
|
18
|
+
/** Total pixel width of the frozen (start-pinned) columns. */
|
|
19
|
+
export declare function getFrozenColumnsWidth<TData extends BP_RowData>(table: BP_TableInstance<TData>): number;
|
|
20
|
+
/** Ordered visible leaf columns of a pinning region. */
|
|
21
|
+
export declare function getRegionColumns<TData extends BP_RowData>(table: BP_TableInstance<TData>, region: ColumnRegion): Array<Column<BP_TableFeatures, TData, unknown>>;
|
|
22
|
+
/** Total pixel width of a pinning region. */
|
|
23
|
+
export declare function getRegionWidth<TData extends BP_RowData>(table: BP_TableInstance<TData>, region: ColumnRegion): number;
|
|
24
|
+
/**
|
|
25
|
+
* Offset of a column's leading edge in the table's display coordinate space,
|
|
26
|
+
* where the frozen ("start") columns come first and the scrollable ("center")
|
|
27
|
+
* columns follow, shifted by the horizontal scroll offset.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getColumnDisplayOffset<TData extends BP_RowData>(table: BP_TableInstance<TData>, column: Column<BP_TableFeatures, TData, unknown>, scrollLeft: number): number;
|
|
30
|
+
/** Pixel height of the frozen ("top") rows. */
|
|
31
|
+
export declare function getFrozenRowsHeight<TData extends BP_RowData>(table: BP_TableInstance<TData>, getRowHeight: (index: number) => number): number;
|
|
32
|
+
/**
|
|
33
|
+
* Natural (visible leaf) index of the column that occupies the given
|
|
34
|
+
* region-local offset, or `undefined` when the offset falls outside the
|
|
35
|
+
* region. Used to map pointer positions back to column coordinates.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getColumnIndexAtRegionOffset<TData extends BP_RowData>(table: BP_TableInstance<TData>, region: ColumnRegion, offset: number): number | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Absolute row index of the row that occupies the given region-local offset,
|
|
40
|
+
* or `undefined` when the offset falls outside the region. Row offsets are
|
|
41
|
+
* resolved through the (possibly variable) row heights, so this stays correct
|
|
42
|
+
* while rows are being resized.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getRowIndexAtRegionOffset<TData extends BP_RowData>(table: BP_TableInstance<TData>, region: RowRegion, offset: number, getRowTop: (index: number) => number, getRowHeight: (index: number) => number): number | undefined;
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
/**
|
|
54
|
+
* Returns the index of the region that wholly contains the supplied
|
|
55
|
+
* region. Returns -1 if no such region is found.
|
|
56
|
+
*/
|
|
57
|
+
static findContainingRegion(regions: Region[] | null | undefined, region: Region): number;
|
|
58
|
+
/**
|
|
59
|
+
* Returns true if the regions fully contain the query region.
|
|
60
|
+
*/
|
|
61
|
+
static containsRegion(regions: Region[], query: Region): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Returns true if the regions at least partially overlap the query region.
|
|
64
|
+
* When `allowPartialOverlap` is false (the default), every interval of the
|
|
65
|
+
* query region must be fully contained in the corresponding interval of a
|
|
66
|
+
* region.
|
|
67
|
+
*/
|
|
68
|
+
static overlapsRegion(regions: Region[], query: Region, allowPartialOverlap?: boolean): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Using the supplied array of potentially non-contiguous `Region`s, returns
|
|
71
|
+
* an ordered array of every unique cell that exists in those regions. The
|
|
72
|
+
* cell coordinates are sorted by row and then column.
|
|
73
|
+
*/
|
|
74
|
+
static enumerateUniqueCells(regions: Region[] | null | undefined, numRows: number, numCols: number): CellCoordinates[];
|
|
75
|
+
static joinStyledRegionGroups(selectedRegions: Region[] | undefined, focusedRegion: FocusedRegion | undefined): StyledRegionGroup[];
|
|
76
|
+
private static regionContains;
|
|
77
|
+
private static intervalContains;
|
|
78
|
+
private static intervalOverlaps;
|
|
79
|
+
private static eachCellInRegion;
|
|
80
|
+
private static clamp;
|
|
81
|
+
private static intervalsEqual;
|
|
82
|
+
private static normalizeInterval;
|
|
83
|
+
}
|
|
84
|
+
export declare function directionToDelta(direction: Direction): {
|
|
85
|
+
rows: number;
|
|
86
|
+
cols: number;
|
|
87
|
+
};
|
|
88
|
+
export declare function moveFocusedCell(focusedCell: FocusedRegion, direction: Direction): FocusedRegion;
|
|
89
|
+
export declare function resizeRegion(region: Region, direction: Direction, focusedRegion?: FocusedRegion): Region;
|
|
@@ -0,0 +1,30 @@
|
|
|
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_BodyContextMenuRenderer } from '../common/menu-context.js';
|
|
4
|
+
import type { BP_RowData, BP_TableInstance, HTMLPropsRef, TableLoading } from '../../types.js';
|
|
5
|
+
import type { TableLayout } from '../common/dimensions.js';
|
|
6
|
+
export type TableContainerProps<TData extends BP_RowData> = HTMLPropsRef<HTMLDivElement> & TableLayout & TableLoading & Pick<RowVirtualizerOptions<TData>, 'enableRowVirtualization' | 'overscanRowCount'> & {
|
|
7
|
+
table: BP_TableInstance<TData>;
|
|
8
|
+
/** Whether to render the row headers (the row-number column) and corner menu. */
|
|
9
|
+
enableRowHeader?: boolean;
|
|
10
|
+
enableColumnReordering?: boolean;
|
|
11
|
+
enableSorting?: boolean;
|
|
12
|
+
enableFocusedCell?: boolean;
|
|
13
|
+
enableGhostCells?: boolean;
|
|
14
|
+
bodyContextMenuRenderer?: BP_BodyContextMenuRenderer<TData>;
|
|
15
|
+
enableBodyContextMenu?: boolean;
|
|
16
|
+
onFocusedCell?: (cell: FocusedCellCoordinates) => void;
|
|
17
|
+
onFocusedRegion?: (region: FocusedRegion) => void;
|
|
18
|
+
selectedRegions?: Region[];
|
|
19
|
+
onSelection?: (regions: Region[]) => void;
|
|
20
|
+
selectionModes?: RegionCardinality[];
|
|
21
|
+
enableRowResizing?: boolean;
|
|
22
|
+
rowHeights?: Array<number | undefined>;
|
|
23
|
+
defaultRowHeights?: Array<number | undefined>;
|
|
24
|
+
onRowHeightChanged?: (index: number, height: number) => void;
|
|
25
|
+
minRowHeight?: number;
|
|
26
|
+
maxRowHeight?: number;
|
|
27
|
+
/** Width of the row-selection checkboxes column; `0` hides the column. */
|
|
28
|
+
selectionColumnWidth?: number;
|
|
29
|
+
};
|
|
30
|
+
export declare function TableContainer<TData extends BP_RowData>({ table, rowHeight, rowHeaderWidth, enableRowHeader, columnHeaderHeight, enableColumnReordering, enableSorting, areCellsLoading, areColumnHeadersLoading, areRowHeadersLoading, enableFocusedCell, enableGhostCells, bodyContextMenuRenderer, enableBodyContextMenu, onFocusedCell, onFocusedRegion, selectedRegions, onSelection, selectionModes, enableRowVirtualization, overscanRowCount, enableRowResizing, rowHeights, defaultRowHeights, onRowHeightChanged, minRowHeight, maxRowHeight, selectionColumnWidth, 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,12 @@
|
|
|
1
|
+
import { type ColumnRegion } from '../common/pinning.js';
|
|
2
|
+
import { type BP_GhostCells } from '../../hooks/use-ghost-cells.js';
|
|
3
|
+
import type { BP_RowData, BP_TableInstance, HTMLPropsRef } from '../../types.js';
|
|
4
|
+
export type TableColumnHeadersProps<TData extends BP_RowData> = HTMLPropsRef<HTMLDivElement> & {
|
|
5
|
+
table: BP_TableInstance<TData>;
|
|
6
|
+
/** Which column region this header renders: frozen ("start") or scrollable ("center"). */
|
|
7
|
+
columnRegion: ColumnRegion;
|
|
8
|
+
enableSorting?: boolean;
|
|
9
|
+
areColumnHeadersLoading: boolean;
|
|
10
|
+
ghosts?: BP_GhostCells;
|
|
11
|
+
};
|
|
12
|
+
export declare function TableColumnHeaders<TData extends BP_RowData>({ table, columnRegion, enableSorting, areColumnHeadersLoading, ghosts, className, ...restProps }: TableColumnHeadersProps<TData>): import("react").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type HeaderGroup } from '@tanstack/react-table';
|
|
2
|
+
import { type ColumnRegion } from '../common/pinning.js';
|
|
3
|
+
import { type BP_GhostCells } from '../../hooks/use-ghost-cells.js';
|
|
4
|
+
import type { BP_RowData, BP_TableFeatures, BP_TableInstance } from '../../types.js';
|
|
5
|
+
export type TableHeadProps<TData extends BP_RowData> = {
|
|
6
|
+
table: BP_TableInstance<TData>;
|
|
7
|
+
headerGroup: HeaderGroup<BP_TableFeatures, TData>;
|
|
8
|
+
columnRegion: ColumnRegion;
|
|
9
|
+
enableSorting?: boolean;
|
|
10
|
+
areColumnHeadersLoading: boolean;
|
|
11
|
+
ghosts?: BP_GhostCells;
|
|
12
|
+
};
|
|
13
|
+
export declare function TableHead<TData extends BP_RowData>({ table, headerGroup, columnRegion, 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,13 @@
|
|
|
1
|
+
import type { BP_RowData, BP_TableInstance } from '../../types.js';
|
|
2
|
+
export type TableRowSelectionHeaderCellProps<TData extends BP_RowData> = {
|
|
3
|
+
table: BP_TableInstance<TData>;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
/** Whether the row headers are currently showing loading placeholders. */
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The header of the row-selection checkboxes column: a select-all checkbox
|
|
11
|
+
* with an indeterminate state, sitting to the right of the corner menu.
|
|
12
|
+
*/
|
|
13
|
+
export declare function TableRowSelectionHeaderCell<TData extends BP_RowData>({ table, width, height, loading, }: TableRowSelectionHeaderCellProps<TData>): 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,18 @@
|
|
|
1
|
+
import { type StyledRegionGroup } from '../common/region.js';
|
|
2
|
+
import { type ColumnRegion, type RowRegion } from '../common/pinning.js';
|
|
3
|
+
import type { BP_RowData, BP_TableInstance } from '../../types.js';
|
|
4
|
+
export type TableRegionLayerProps<TData extends BP_RowData> = {
|
|
5
|
+
table: BP_TableInstance<TData>;
|
|
6
|
+
regionGroups: StyledRegionGroup[];
|
|
7
|
+
columnRegion: ColumnRegion;
|
|
8
|
+
rowRegion: RowRegion;
|
|
9
|
+
getRowTop: (index: number) => number;
|
|
10
|
+
getRowHeight: (index: number) => number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Renders the selection and focus regions clipped to a single quadrant's
|
|
14
|
+
* region. Regions that span the frozen and scrollable areas are drawn as
|
|
15
|
+
* abutting rectangles in each quadrant, so the selection overlay stays pinned
|
|
16
|
+
* to the frozen rows/columns as the scrollable area scrolls under them.
|
|
17
|
+
*/
|
|
18
|
+
export declare function TableRegionLayer<TData extends BP_RowData>({ table, regionGroups, columnRegion, rowRegion, getRowTop, getRowHeight, }: TableRegionLayerProps<TData>): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
/** Current horizontal scroll offset of the main quadrant. */
|
|
8
|
+
scrollLeft: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Preview guide shown while a column is being dragged. `guideIndex` is a
|
|
12
|
+
* boundary in the natural column order (0..numColumns); the guide is drawn at
|
|
13
|
+
* the display offset of that boundary. Boundaries inside the frozen region are
|
|
14
|
+
* fixed, while boundaries in the scrollable region follow the main quadrant's
|
|
15
|
+
* horizontal scroll offset — mirroring Blueprint's quadrant-aware guide.
|
|
16
|
+
*/
|
|
17
|
+
export declare function TableReorderGuides<TData extends BP_RowData>({ table, reorderingColumnId, guideIndex, rowHeaderWidth, scrollLeft, }: TableReorderGuidesProps<TData>): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BP_RowData, BP_TableInstance } from '../../types.js';
|
|
2
|
+
export type TableResizeGuidesProps<TData extends BP_RowData> = {
|
|
3
|
+
table: BP_TableInstance<TData>;
|
|
4
|
+
rowHeaderWidth: number;
|
|
5
|
+
/** Effective height of the column-header area; offsets the horizontal guide into the body's coordinate space. */
|
|
6
|
+
columnHeaderHeight: number;
|
|
7
|
+
/** Current horizontal scroll offset of the main quadrant. */
|
|
8
|
+
scrollLeft: number;
|
|
9
|
+
/** Current vertical scroll offset of the main quadrant. */
|
|
10
|
+
scrollTop: number;
|
|
11
|
+
/** Number of frozen rows; rows before it never scroll vertically. */
|
|
12
|
+
frozenRowCount: number;
|
|
13
|
+
/** Absolute top of the horizontal guide while resizing a row, or `null`. */
|
|
14
|
+
resizingGuideTop?: number | null;
|
|
15
|
+
/** Absolute index of the row being resized, or `null`. */
|
|
16
|
+
resizingRowIndex?: number | null;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Resize guides for the whole table. The layers live at the quadrant-stack
|
|
20
|
+
* level so a guide can span across the frozen and scrollable regions; the
|
|
21
|
+
* display offsets of the columns/rows they track are derived from the main
|
|
22
|
+
* quadrant's scroll offsets.
|
|
23
|
+
*/
|
|
24
|
+
export declare function TableResizeGuides<TData extends BP_RowData>({ table, rowHeaderWidth, columnHeaderHeight, scrollLeft, scrollTop, frozenRowCount, resizingGuideTop, resizingRowIndex, }: TableResizeGuidesProps<TData>): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type TablePaginationBarProps = {
|
|
2
|
+
/** Zero-based index of the current page. */
|
|
3
|
+
pageIndex: number;
|
|
4
|
+
/** Number of rows shown per page. */
|
|
5
|
+
pageSize: number;
|
|
6
|
+
/**
|
|
7
|
+
* Total number of pages. `undefined` means the count is unknown — typical for
|
|
8
|
+
* manual/server-side pagination without a `rowCount` — in which case "last"
|
|
9
|
+
* navigation is disabled and "next" stays enabled.
|
|
10
|
+
*/
|
|
11
|
+
pageCount?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Total number of rows across all pages, used for the "1–10 of 240" summary.
|
|
14
|
+
* When `undefined`, the summary is omitted.
|
|
15
|
+
*/
|
|
16
|
+
rowCount?: number;
|
|
17
|
+
/** Page sizes offered by the rows-per-page select. */
|
|
18
|
+
pageSizeOptions?: readonly number[];
|
|
19
|
+
/** Invoked with the requested page index when a navigation control is used. */
|
|
20
|
+
onPageIndexChange: (pageIndex: number) => void;
|
|
21
|
+
/** Invoked with the requested page size when the rows-per-page select changes. */
|
|
22
|
+
onPageSizeChange: (pageSize: number) => void;
|
|
23
|
+
className?: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Blueprint-styled pagination bar rendered below the table by the
|
|
27
|
+
* `withPagination` HOC. It is presentational: page state and navigation are
|
|
28
|
+
* owned by the caller.
|
|
29
|
+
*/
|
|
30
|
+
export declare function TablePaginationBar({ pageIndex, pageSize, pageCount, rowCount, pageSizeOptions, onPageIndexChange, onPageSizeChange, className, }: TablePaginationBarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type ComponentType } from 'react';
|
|
2
|
+
import type { BP_RowData } from '../../types.js';
|
|
3
|
+
import type { BP_TableProps } from '../BP_Table.js';
|
|
4
|
+
export type BP_PaginationOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* Initial page size for uncontrolled pagination. Ignored when
|
|
7
|
+
* `state.pagination` or `initialState.pagination` is provided.
|
|
8
|
+
*
|
|
9
|
+
* @default 10
|
|
10
|
+
*/
|
|
11
|
+
initialPageSize?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Initial zero-based page index for uncontrolled pagination. Ignored when
|
|
14
|
+
* `state.pagination` or `initialState.pagination` is provided.
|
|
15
|
+
*
|
|
16
|
+
* @default 0
|
|
17
|
+
*/
|
|
18
|
+
initialPageIndex?: number;
|
|
19
|
+
/** Page sizes offered by the pagination bar's rows-per-page select. */
|
|
20
|
+
pageSizeOptions?: readonly number[];
|
|
21
|
+
/**
|
|
22
|
+
* Whether to render the pagination bar below the table. When `false`, the
|
|
23
|
+
* table is still paginated; only the controls are hidden.
|
|
24
|
+
*
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
showPaginationBar?: boolean;
|
|
28
|
+
/** Additional class name(s) for the pagination bar. */
|
|
29
|
+
paginationBarClassName?: string;
|
|
30
|
+
};
|
|
31
|
+
export type BP_PaginatedTableProps<TData extends BP_RowData> = BP_TableProps<TData> & BP_PaginationOptions;
|
|
32
|
+
/**
|
|
33
|
+
* Wraps a table component (usually `BP_Table`) with row pagination and a
|
|
34
|
+
* Blueprint-styled pagination bar, keeping the whole pagination concern — the
|
|
35
|
+
* TanStack feature registration, the page state, and the controls — outside the
|
|
36
|
+
* wrapped component.
|
|
37
|
+
*
|
|
38
|
+
* Pagination is uncontrolled by default (`initialPageIndex` /
|
|
39
|
+
* `initialPageSize`, or `initialState.pagination`). It becomes controlled when
|
|
40
|
+
* `state.pagination` is provided: the HOC defers to it and forwards
|
|
41
|
+
* `onPaginationChange`.
|
|
42
|
+
*
|
|
43
|
+
* Client-side pagination slices `data` automatically. For server-side
|
|
44
|
+
* pagination, pass `manualPagination` plus `pageCount` (or `rowCount`) and
|
|
45
|
+
* provide the current page's rows as `data`.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const PaginatedTable = withPagination(BP_Table);
|
|
49
|
+
* <PaginatedTable data={rows} columns={columns} initialPageSize={20} />
|
|
50
|
+
*/
|
|
51
|
+
export declare function withPagination<TData extends BP_RowData>(TableComponent: ComponentType<BP_TableProps<TData>>): ComponentType<BP_PaginatedTableProps<TData>>;
|