@bigcapitalhq/blueprintjs-react-table 0.1.0 → 0.3.1
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 +331 -7
- package/dist/blueprintjs-react-table.cjs +6 -0
- package/dist/blueprintjs-react-table.cjs.map +1 -0
- package/dist/blueprintjs-react-table.js +2681 -0
- package/dist/blueprintjs-react-table.js.map +1 -0
- package/dist/styles.css +1 -0
- package/dist/types/components/BP_Table.d.ts +130 -7
- package/dist/types/components/body/TableBody.d.ts +21 -3
- package/dist/types/components/body/TableBodyCell.d.ts +10 -5
- package/dist/types/components/body/TableGhostCells.d.ts +18 -4
- package/dist/types/components/body/TableRowExpander.d.ts +8 -0
- package/dist/types/components/body/TableRowHeaderCell.d.ts +10 -3
- package/dist/types/components/body/TableRowHeaders.d.ts +16 -1
- package/dist/types/components/body/TableRowSelectionCell.d.ts +19 -0
- package/dist/types/components/common/cell-selection.d.ts +57 -0
- package/dist/types/components/common/cellCoordinates.d.ts +25 -4
- package/dist/types/components/common/classes.d.ts +11 -0
- package/dist/types/components/common/dimensions.d.ts +5 -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 +26 -0
- package/dist/types/components/common/table-selection-context.d.ts +3 -3
- package/dist/types/components/container/TableContainer.d.ts +12 -4
- package/dist/types/components/head/TableColumnHeaders.d.ts +4 -1
- package/dist/types/components/head/TableHead.d.ts +3 -1
- package/dist/types/components/head/TableRowSelectionHeaderCell.d.ts +13 -0
- package/dist/types/components/layers/TableRegionLayer.d.ts +10 -2
- package/dist/types/components/layers/TableReorderGuides.d.ts +10 -1
- package/dist/types/components/layers/TableResizeGuides.d.ts +18 -5
- 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/pagination-row-count-context.d.ts +2 -0
- package/dist/types/components/pagination/withPagination.d.ts +51 -0
- package/dist/types/components/quadrant/TableQuadrant.d.ts +42 -10
- package/dist/types/components/quadrant/TableQuadrantStack.d.ts +39 -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 +7 -3
- package/dist/types/hooks/use-freeze-pinning.d.ts +25 -0
- package/dist/types/hooks/use-row-resizing.d.ts +5 -1
- package/dist/types/hooks/use-row-virtualizer.d.ts +13 -2
- package/dist/types/hooks/use-uncontrolled.d.ts +20 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/types.d.ts +33 -2
- package/package.json +2 -2
- package/dist/types/components/body/TableStaticBody.d.ts +0 -10
- package/dist/types/components/body/VirtualBody.d.ts +0 -12
- package/dist/types/components/quadrant/TableBottomContainer.d.ts +0 -14
- package/dist/types/components/quadrant/TableTopContainer.d.ts +0 -11
- package/dist/types/hooks/use-cell-focus-selection.d.ts +0 -34
|
@@ -12,6 +12,8 @@ export type RowResizingOptions = {
|
|
|
12
12
|
rowHeight: number;
|
|
13
13
|
/** Number of rows in the table. */
|
|
14
14
|
rowCount: number;
|
|
15
|
+
/** Extra space below the row cells for an expanded detail panel. */
|
|
16
|
+
getDetailHeight?: (index: number) => number;
|
|
15
17
|
/**
|
|
16
18
|
* Controlled per-row heights, indexed by row index. When provided, the
|
|
17
19
|
* table's row heights are fully owned by the caller, who updates them via
|
|
@@ -43,6 +45,8 @@ export type RowResizingApi = {
|
|
|
43
45
|
enabled: boolean;
|
|
44
46
|
/** Resolved height of the row at `index`. */
|
|
45
47
|
getRowHeight: (index: number) => number;
|
|
48
|
+
/** Height occupied by both the row and its detail panel. */
|
|
49
|
+
getRowSpanHeight: (index: number) => number;
|
|
46
50
|
/** Resolved absolute top offset of the row at `index` within the body. */
|
|
47
51
|
getRowTop: (index: number) => number;
|
|
48
52
|
/** Total height of all rows combined. */
|
|
@@ -54,4 +58,4 @@ export type RowResizingApi = {
|
|
|
54
58
|
/** Begins resizing the row at `index`. Wire to the row header resize handle. */
|
|
55
59
|
startRowResize: RowResizeStartHandler;
|
|
56
60
|
};
|
|
57
|
-
export declare function useRowResizing({ rowHeight, rowCount, rowHeights, defaultRowHeights, enableRowResizing, minRowHeight, maxRowHeight, onRowHeightChanged, }: RowResizingOptions): RowResizingApi;
|
|
61
|
+
export declare function useRowResizing({ rowHeight, rowCount, getDetailHeight, rowHeights, defaultRowHeights, enableRowResizing, minRowHeight, maxRowHeight, onRowHeightChanged, }: RowResizingOptions): RowResizingApi;
|
|
@@ -5,11 +5,22 @@ export declare const DEFAULT_OVERSCAN_ROW_COUNT = 5;
|
|
|
5
5
|
export type BP_RowVirtualizer = Virtualizer<HTMLDivElement, HTMLDivElement>;
|
|
6
6
|
export type RowVirtualizerOptions<TData extends BP_RowData> = {
|
|
7
7
|
table: BP_TableInstance<TData>;
|
|
8
|
+
/** Effective height of the column-header area above the scrollable body. */
|
|
8
9
|
columnHeaderHeight: number;
|
|
9
|
-
/**
|
|
10
|
+
/** Number of frozen rows rendered above the scrollable body. */
|
|
11
|
+
frozenRowCount: number;
|
|
12
|
+
/** Resolved height of the frozen rows rendered above the scrollable body. */
|
|
13
|
+
frozenRowsHeight: number;
|
|
14
|
+
/** Resolved height of the row at the given absolute index (used to estimate item sizes). */
|
|
10
15
|
getRowHeight: (index: number) => number;
|
|
11
16
|
scrollContainerRef: MutableRefObject<HTMLDivElement | null>;
|
|
12
17
|
enableRowVirtualization: boolean;
|
|
13
18
|
overscanRowCount: number;
|
|
14
19
|
};
|
|
15
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Virtualizes the scrollable ("center") rows only. Frozen rows are always
|
|
22
|
+
* rendered (they are expected to be few) and are excluded from the virtualizer,
|
|
23
|
+
* so virtual item indices are offsets into the center rows; callers map them to
|
|
24
|
+
* absolute row indices with `getFrozenRowCount`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useRowVirtualizer<TData extends BP_RowData>({ table, columnHeaderHeight, frozenRowCount, frozenRowsHeight, getRowHeight, scrollContainerRef, enableRowVirtualization, overscanRowCount, }: RowVirtualizerOptions<TData>): BP_RowVirtualizer | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type SetStateAction } from 'react';
|
|
2
|
+
export type UseUncontrolledInput<T> = {
|
|
3
|
+
/** Value for controlled state. */
|
|
4
|
+
value?: T;
|
|
5
|
+
/** Initial value for uncontrolled state. */
|
|
6
|
+
initialValue?: T;
|
|
7
|
+
/** Final value for uncontrolled state when value and initialValue are not provided. */
|
|
8
|
+
finalValue?: T;
|
|
9
|
+
/** Controlled state onChange handler. */
|
|
10
|
+
onChange?: (value: T) => void;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Owns a piece of state that can be driven either by the caller (controlled) or
|
|
14
|
+
* by the component itself (uncontrolled), mirroring the common React
|
|
15
|
+
* controlled/uncontrolled convention.
|
|
16
|
+
*
|
|
17
|
+
* Returns the resolved value, a setter that notifies `onChange` in both modes,
|
|
18
|
+
* and whether the state is currently controlled (`value` was provided).
|
|
19
|
+
*/
|
|
20
|
+
export declare function useUncontrolled<T>({ value, initialValue, finalValue, onChange, }: UseUncontrolledInput<T>): [T, (update: SetStateAction<T>) => void, boolean];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Public entry point for the `blueprintjs-react-table` package.
|
|
3
3
|
*
|
|
4
4
|
* Exports the `BP_Table` component and all public types used in its props,
|
|
5
|
+
* the `withPagination` HOC that layers row pagination on top of `BP_Table`,
|
|
5
6
|
* as well as the region / focus / selection types used by the focus and
|
|
6
7
|
* selection APIs.
|
|
7
8
|
*
|
|
@@ -13,5 +14,12 @@
|
|
|
13
14
|
|
|
14
15
|
export { BP_Table } from './components/BP_Table.js';
|
|
15
16
|
export type { BP_TableProps } from './components/BP_Table.js';
|
|
17
|
+
export { withPagination } from './components/pagination/withPagination.js';
|
|
18
|
+
export type { BP_PaginatedTableProps, BP_PaginationOptions, } from './components/pagination/withPagination.js';
|
|
19
|
+
export { TablePaginationBar } from './components/pagination/TablePaginationBar.js';
|
|
20
|
+
export type { TablePaginationBarProps } from './components/pagination/TablePaginationBar.js';
|
|
21
|
+
export { DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, } from './components/pagination/constants.js';
|
|
22
|
+
export { DEFAULT_BP_TABLE_FEATURES } from './hooks/use-bp-table-instance.js';
|
|
23
|
+
export type { BP_BodyContextMenuRenderer, BP_MenuContext, } from './components/common/menu-context.js';
|
|
16
24
|
export * from './types.js';
|
|
17
25
|
export * from './components/common/region.js';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type { IconProps } from '@blueprintjs/core';
|
|
2
|
+
import { type ButtonHTMLAttributes, type HTMLAttributes, type HTMLProps, type ReactNode, type MutableRefObject } from 'react';
|
|
3
|
+
import { ColumnPinningState, ColumnVisibilityState, type Cell, type ExpandedState, type Row, RowData, RowPinningState, RowSelectionState, TableFeatures, TableOptions, TableState, ReactTable, type CellData } from '@tanstack/react-table';
|
|
3
4
|
declare module '@tanstack/react-table' {
|
|
4
5
|
/**
|
|
5
6
|
* Extra metadata supported on column definitions, applied by `BP_Table` when
|
|
@@ -31,6 +32,11 @@ export type Xor<A, B> = Prettify<{
|
|
|
31
32
|
} & B> | Prettify<{
|
|
32
33
|
[k in keyof B]?: never;
|
|
33
34
|
} & A>;
|
|
35
|
+
/**
|
|
36
|
+
* Standard HTML attributes accepted for the table's outer container element:
|
|
37
|
+
* React's `HTMLProps`, minus a handful of attributes reserved by the table API,
|
|
38
|
+
* plus a `ref` to the container element.
|
|
39
|
+
*/
|
|
34
40
|
export type HTMLPropsRef<T extends HTMLElement> = {
|
|
35
41
|
ref?: MutableRefObject<null | T> | null;
|
|
36
42
|
} & Omit<HTMLProps<T>, 'color' | 'data' | 'label' | 'ref' | 'size' | 'style' | 'type'>;
|
|
@@ -62,4 +68,29 @@ export type BP_TableFeatures = TableFeatures;
|
|
|
62
68
|
export type BP_TableState = TableState<BP_TableFeatures>;
|
|
63
69
|
/** Maps column ids to their visibility (`true` = visible, `false` = hidden). */
|
|
64
70
|
export type BP_VisibilityState = ColumnVisibilityState;
|
|
71
|
+
/** Maps frozen ("start") and right-pinned ("end") column ids. */
|
|
72
|
+
export type BP_ColumnPinningState = ColumnPinningState;
|
|
73
|
+
/** Maps frozen ("top") and bottom-pinned ("bottom") row ids. */
|
|
74
|
+
export type BP_RowPinningState = RowPinningState;
|
|
75
|
+
/** Maps row ids to their selection (`true` = selected), driven by the row-selection checkboxes. */
|
|
76
|
+
export type BP_RowSelectionState = RowSelectionState;
|
|
77
|
+
/** Expanded row IDs, or `true` to expand every eligible row. */
|
|
78
|
+
export type BP_ExpandedRowsState = ExpandedState;
|
|
79
|
+
export type BP_RowDetailRenderer<TData extends BP_RowData> = (row: Row<BP_TableFeatures, TData>) => ReactNode;
|
|
80
|
+
/** HTML attributes for a rendered data cell. The table owns its contents. */
|
|
81
|
+
export type BP_BodyElementProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'dangerouslySetInnerHTML'> & {
|
|
82
|
+
[attribute: `data-${string}`]: string | number | boolean | undefined;
|
|
83
|
+
};
|
|
84
|
+
export type BP_BodyPropsOptions<TData extends BP_RowData> = {
|
|
85
|
+
/** Attributes and event handlers for the entire data cell, including its padding. */
|
|
86
|
+
getCellProps?: (cell: Cell<BP_TableFeatures, TData, unknown>) => BP_BodyElementProps | undefined;
|
|
87
|
+
};
|
|
88
|
+
type RowExpanderPropsValue<TData extends BP_RowData, TProps> = TProps | ((row: Row<BP_TableFeatures, TData>) => TProps);
|
|
89
|
+
export type BP_RowExpanderOptions<TData extends BP_RowData> = {
|
|
90
|
+
/** Native props for the row's disclosure button, or a function of the row. */
|
|
91
|
+
rowExpanderButtonProps?: RowExpanderPropsValue<TData, Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'dangerouslySetInnerHTML'>>;
|
|
92
|
+
/** Blueprint Icon props, or a function of the row for state-dependent icons. */
|
|
93
|
+
rowExpanderIconProps?: RowExpanderPropsValue<TData, Partial<IconProps>>;
|
|
94
|
+
};
|
|
65
95
|
export type BP_TableInstance<TData extends BP_RowData = BP_RowData> = ReactTable<BP_TableFeatures, TData>;
|
|
96
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigcapitalhq/blueprintjs-react-table",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.3.1",
|
|
4
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
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/blueprintjs-react-table.cjs",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
],
|
|
38
38
|
"repository": {
|
|
39
39
|
"type": "git",
|
|
40
|
-
"url": "git+https://github.com/bigcapitalhq/blueprintjs-
|
|
40
|
+
"url": "git+https://github.com/bigcapitalhq/blueprintjs-tanstack-table.git"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"dev": "vite",
|
|
@@ -1,10 +0,0 @@
|
|
|
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;
|
|
@@ -1,12 +0,0 @@
|
|
|
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;
|
|
@@ -1,14 +0,0 @@
|
|
|
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;
|
|
@@ -1,11 +0,0 @@
|
|
|
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;
|
|
@@ -1,34 +0,0 @@
|
|
|
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;
|