@vuu-ui/vuu-datatable 0.6.10-debug → 0.6.11
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/package.json +5 -3
- package/types/ColumnBasedTable.d.ts +3 -0
- package/types/ColumnResizer.d.ts +8 -0
- package/types/DataTable.d.ts +4 -0
- package/types/DragVisualizer.d.ts +8 -0
- package/types/KeySet.d.ts +12 -0
- package/types/RowBasedTable.d.ts +3 -0
- package/types/SortIndicator.d.ts +7 -0
- package/types/TableCell.d.ts +9 -0
- package/types/TableGroupCell.d.ts +7 -0
- package/types/TableGroupHeaderCell.d.ts +13 -0
- package/types/TableHeaderCell.d.ts +11 -0
- package/types/TableRow.d.ts +14 -0
- package/types/context-menu/buildContextMenuDescriptors.d.ts +4 -0
- package/types/context-menu/index.d.ts +2 -0
- package/types/context-menu/useContextMenu.d.ts +16 -0
- package/types/dataTableTypes.d.ts +67 -0
- package/types/filter-indicator.d.ts +13 -0
- package/types/index.d.ts +3 -0
- package/types/keyUtils.d.ts +19 -0
- package/types/useDataSource.d.ts +40 -0
- package/types/useDataTable.d.ts +63 -0
- package/types/useDraggableColumn.d.ts +12 -0
- package/types/useKeyboardNavigation.d.ts +22 -0
- package/types/useMeasuredContainer.d.ts +25 -0
- package/types/useMeasuredSize.d.ts +26 -0
- package/types/useResizeObserver.d.ts +15 -0
- package/types/useSelection.d.ts +7 -0
- package/types/useTableColumnResize.d.ts +17 -0
- package/types/useTableModel.d.ts +66 -0
- package/types/useTableScroll.d.ts +31 -0
- package/types/useTableViewport.d.ts +39 -0
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"@salt-ds/core": "1.0.0",
|
|
7
7
|
"@salt-ds/icons": "1.0.0",
|
|
8
8
|
"@heswell/salt-lab": "1.0.0-alpha.0-vuu.1",
|
|
9
|
-
"@vuu-ui/vuu-utils": "0.6.
|
|
9
|
+
"@vuu-ui/vuu-utils": "0.6.11",
|
|
10
10
|
"classnames": "^2.2.6",
|
|
11
11
|
"react": "^17.0.2",
|
|
12
12
|
"react-dom": "^17.0.2"
|
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
"index.css",
|
|
17
17
|
"index.js.map",
|
|
18
18
|
"index.css.map",
|
|
19
|
-
"/src"
|
|
19
|
+
"/src",
|
|
20
|
+
"/types"
|
|
20
21
|
],
|
|
21
22
|
"module": "esm/index.js",
|
|
22
23
|
"main": "cjs/index.js",
|
|
23
|
-
"version": "0.6.
|
|
24
|
+
"version": "0.6.11",
|
|
25
|
+
"types": "types/index.d.ts"
|
|
24
26
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import "./ColumnResizer.css";
|
|
3
|
+
export interface TableColumnResizerProps {
|
|
4
|
+
onDrag: (evt: MouseEvent, moveBy: number) => void;
|
|
5
|
+
onDragEnd: (evt: MouseEvent) => void;
|
|
6
|
+
onDragStart: (evt: React.MouseEvent) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const ColumnResizer: ({ onDrag, onDragEnd, onDragStart, }: TableColumnResizerProps) => JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TableProps } from "./dataTableTypes";
|
|
3
|
+
import "./DataTable.css";
|
|
4
|
+
export declare const DataTable: ({ allowConfigEditing: showSettings, className, config, dataSource, headerHeight, height, id: idProp, onConfigChange, onFeatureEnabled, onFeatureInvocation, onSelectionChange, onShowConfigEditor: onShowSettings, renderBufferSize, rowHeight, selectionModel, style: styleProp, tableLayout: tableLayoutProp, width, ...props }: TableProps) => JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import "./DragVisualizer.css";
|
|
3
|
+
export declare const useListViz: () => unknown;
|
|
4
|
+
export interface DragVisualizerProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
orientation?: "vertical" | "horizontal";
|
|
7
|
+
}
|
|
8
|
+
export declare const DragVisualizer: React.FC<DragVisualizerProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DataSourceRow } from "@vuu-ui/vuu-data";
|
|
2
|
+
import { VuuRange } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
export declare class KeySet {
|
|
4
|
+
private keys;
|
|
5
|
+
private free;
|
|
6
|
+
private nextKeyValue;
|
|
7
|
+
constructor(range: VuuRange);
|
|
8
|
+
next(): number;
|
|
9
|
+
reset({ from, to }: VuuRange): void;
|
|
10
|
+
keyFor(rowIndex: number): number;
|
|
11
|
+
withKeys(data: DataSourceRow[]): DataSourceRow[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TableImplementationProps } from "./dataTableTypes";
|
|
3
|
+
export declare const RowBasedTable: ({ columns, data, headings, onColumnResize, onHeaderCellDragStart, onContextMenu, onRemoveColumnFromGroupBy, onRowClick, onSort, onToggleGroup, rowCount, rowHeight, }: TableImplementationProps) => JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ColumnSort } from "@vuu-ui/vuu-datagrid-types";
|
|
3
|
+
import "./SortIndicator.css";
|
|
4
|
+
export interface SortIndicatorProps {
|
|
5
|
+
sorted?: ColumnSort;
|
|
6
|
+
}
|
|
7
|
+
export declare const SortIndicator: ({ sorted }: SortIndicatorProps) => JSX.Element | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataSourceRow } from "@vuu-ui/vuu-data";
|
|
2
|
+
import { KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
|
|
3
|
+
import { HTMLAttributes } from "react";
|
|
4
|
+
import "./TableCell.css";
|
|
5
|
+
export interface TableCellProps extends HTMLAttributes<HTMLTableCellElement> {
|
|
6
|
+
column: KeyedColumnDescriptor;
|
|
7
|
+
row: DataSourceRow;
|
|
8
|
+
}
|
|
9
|
+
export declare const TableCell: import("react").MemoExoticComponent<({ className: classNameProp, column, row }: TableCellProps) => JSX.Element>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DataSourceRow } from "@vuu-ui/vuu-data";
|
|
3
|
+
import { KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
|
|
4
|
+
import { TableCellProps } from "./TableCell";
|
|
5
|
+
import "./TableGroupCell.css";
|
|
6
|
+
export declare const getGroupValueAndOffset: (columns: KeyedColumnDescriptor[], row: DataSourceRow) => [unknown, number];
|
|
7
|
+
export declare const TableGroupCell: ({ column, onClick, row, }: TableCellProps) => JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
import { TableHeaderCellProps } from "./TableHeaderCell";
|
|
3
|
+
import "./TableGroupHeaderCell.css";
|
|
4
|
+
import { GroupColumnDescriptor, KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
|
|
5
|
+
export interface ColHeaderProps extends Omit<HTMLAttributes<HTMLDivElement>, "onClick"> {
|
|
6
|
+
column: KeyedColumnDescriptor;
|
|
7
|
+
onRemoveColumn?: (column: KeyedColumnDescriptor) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface TableGroupHeaderCellProps extends Omit<TableHeaderCellProps, "onDragStart" | "onDrag" | "onDragEnd"> {
|
|
10
|
+
column: GroupColumnDescriptor;
|
|
11
|
+
onRemoveColumn?: (column: KeyedColumnDescriptor) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const TableGroupHeaderCell: ({ column, className: classNameProp, onRemoveColumn, onResize, ...props }: TableGroupHeaderCellProps) => JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
|
|
2
|
+
import { HTMLAttributes, MouseEvent } from "react";
|
|
3
|
+
import { TableColumnResizeHandler } from "./dataTableTypes";
|
|
4
|
+
import "./TableHeaderCell.css";
|
|
5
|
+
export interface TableHeaderCellProps extends HTMLAttributes<HTMLTableCellElement> {
|
|
6
|
+
column: KeyedColumnDescriptor;
|
|
7
|
+
debugString?: string;
|
|
8
|
+
onDragStart?: (evt: MouseEvent) => void;
|
|
9
|
+
onResize?: TableColumnResizeHandler;
|
|
10
|
+
}
|
|
11
|
+
export declare const TableHeaderCell: ({ column, className: classNameProp, onClick, onDragStart, onResize, ...props }: TableHeaderCellProps) => JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DataSourceRow } from "@vuu-ui/vuu-data";
|
|
2
|
+
import { KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
|
|
3
|
+
import { HTMLAttributes } from "react";
|
|
4
|
+
import { RowClickHandler } from "./dataTableTypes";
|
|
5
|
+
import "./TableRow.css";
|
|
6
|
+
export interface RowProps extends Omit<HTMLAttributes<HTMLDivElement>, "children" | "onClick"> {
|
|
7
|
+
columns: KeyedColumnDescriptor[];
|
|
8
|
+
height: number;
|
|
9
|
+
index: number;
|
|
10
|
+
onClick?: RowClickHandler;
|
|
11
|
+
onToggleGroup?: (row: DataSourceRow) => void;
|
|
12
|
+
row: DataSourceRow;
|
|
13
|
+
}
|
|
14
|
+
export declare const TableRow: import("react").NamedExoticComponent<RowProps>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DataSource } from "@vuu-ui/vuu-data";
|
|
2
|
+
import { KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
|
|
3
|
+
import { Filter } from "@vuu-ui/vuu-filter-types";
|
|
4
|
+
import { MenuActionHandler } from "@vuu-ui/vuu-popups";
|
|
5
|
+
import { VuuFilter } from "@vuu-ui/vuu-protocol-types";
|
|
6
|
+
import { PersistentColumnAction } from "../useTableModel";
|
|
7
|
+
export interface ContextMenuOptions {
|
|
8
|
+
column?: KeyedColumnDescriptor;
|
|
9
|
+
filter?: Filter;
|
|
10
|
+
sort?: VuuFilter;
|
|
11
|
+
}
|
|
12
|
+
export interface ContextMenuHookProps {
|
|
13
|
+
dataSource?: DataSource;
|
|
14
|
+
onPersistentColumnOperation: (action: PersistentColumnAction) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const useContextMenu: ({ dataSource, onPersistentColumnOperation, }: ContextMenuHookProps) => MenuActionHandler;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DataSource, DataSourceRow, VuuFeatureInvocationMessage, VuuFeatureMessage } from "@vuu-ui/vuu-data";
|
|
2
|
+
import { KeyedColumnDescriptor, GridConfig, TableHeadings, SelectionChangeHandler, TableSelectionModel } from "@vuu-ui/vuu-datagrid-types";
|
|
3
|
+
import { HTMLAttributes, MouseEvent } from "react";
|
|
4
|
+
export type tableLayoutType = "row" | "column";
|
|
5
|
+
export interface TableProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
allowConfigEditing?: boolean;
|
|
7
|
+
config: Omit<GridConfig, "headings">;
|
|
8
|
+
dataSource: DataSource;
|
|
9
|
+
headerHeight?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
onConfigChange?: (config: Omit<GridConfig, "headings">) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Features like context menu actions and visual links are enabled by the Vuu server.
|
|
14
|
+
* This callback allows us to receive a notification when such a feature is available.
|
|
15
|
+
* The options provided must then be used to configure appropriate UI affordances.
|
|
16
|
+
*/
|
|
17
|
+
onFeatureEnabled?: (message: VuuFeatureMessage) => void;
|
|
18
|
+
/**
|
|
19
|
+
* When a Vuu feature e.g. context menu action, has been invoked, the Vuu server
|
|
20
|
+
* response must be handled. This callback provides that response.
|
|
21
|
+
*/
|
|
22
|
+
onFeatureInvocation?: (message: VuuFeatureInvocationMessage) => void;
|
|
23
|
+
onShowConfigEditor?: () => void;
|
|
24
|
+
onSelectionChange?: SelectionChangeHandler;
|
|
25
|
+
renderBufferSize?: number;
|
|
26
|
+
rowHeight?: number;
|
|
27
|
+
selectionModel?: TableSelectionModel;
|
|
28
|
+
tableLayout?: tableLayoutType;
|
|
29
|
+
width?: number;
|
|
30
|
+
}
|
|
31
|
+
export type TableColumnResizeHandler = (phase: "begin" | "resize" | "end", columnName: string, width?: number) => void;
|
|
32
|
+
export interface TableImplementationProps {
|
|
33
|
+
columns: KeyedColumnDescriptor[];
|
|
34
|
+
data: DataSourceRow[];
|
|
35
|
+
headerHeight: number;
|
|
36
|
+
headings: TableHeadings;
|
|
37
|
+
onColumnResize?: TableColumnResizeHandler;
|
|
38
|
+
onHeaderCellDragEnd?: () => void;
|
|
39
|
+
onHeaderCellDragStart?: (evt: MouseEvent) => void;
|
|
40
|
+
onContextMenu?: (evt: MouseEvent<HTMLElement>) => void;
|
|
41
|
+
onRemoveColumnFromGroupBy?: (column: KeyedColumnDescriptor) => void;
|
|
42
|
+
onRowClick?: RowClickHandler;
|
|
43
|
+
onSort: (column: KeyedColumnDescriptor, isAdditive: boolean) => void;
|
|
44
|
+
onToggleGroup?: (row: DataSourceRow) => void;
|
|
45
|
+
rowCount: number;
|
|
46
|
+
rowHeight: number;
|
|
47
|
+
}
|
|
48
|
+
type MeasureStatus = "unmeasured" | "measured";
|
|
49
|
+
export interface TableMeasurements {
|
|
50
|
+
contentHeight: number;
|
|
51
|
+
left: number;
|
|
52
|
+
right: number;
|
|
53
|
+
scrollbarSize: number;
|
|
54
|
+
scrollContentHeight: number;
|
|
55
|
+
status: MeasureStatus;
|
|
56
|
+
top: number;
|
|
57
|
+
}
|
|
58
|
+
export interface Viewport {
|
|
59
|
+
fillerHeight: number;
|
|
60
|
+
maxScrollContainerScrollHorizontal: number;
|
|
61
|
+
maxScrollContainerScrollVertical: number;
|
|
62
|
+
pinnedWidthLeft: number;
|
|
63
|
+
rowCount: number;
|
|
64
|
+
scrollContentWidth: number;
|
|
65
|
+
}
|
|
66
|
+
export type RowClickHandler = (row: DataSourceRow, rangeSelect: boolean, keepExistingSelection: boolean) => void;
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
|
|
2
|
+
import { Filter } from "@vuu-ui/vuu-filter-types";
|
|
3
|
+
import { HTMLAttributes } from "react";
|
|
4
|
+
import "./filter-indicator.css";
|
|
5
|
+
export declare const Direction: {
|
|
6
|
+
ASC: string;
|
|
7
|
+
DSC: string;
|
|
8
|
+
};
|
|
9
|
+
export interface FilterIndicatorProps extends HTMLAttributes<HTMLDivElement> {
|
|
10
|
+
column: KeyedColumnDescriptor;
|
|
11
|
+
filter?: Filter;
|
|
12
|
+
}
|
|
13
|
+
export declare const FilterIndicator: ({ column, filter }: FilterIndicatorProps) => JSX.Element | null;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const ArrowUp = "ArrowUp";
|
|
3
|
+
export declare const ArrowDown = "ArrowDown";
|
|
4
|
+
export declare const ArrowLeft = "ArrowLeft";
|
|
5
|
+
export declare const ArrowRight = "ArrowRight";
|
|
6
|
+
export declare const Enter = "Enter";
|
|
7
|
+
export declare const Escape = "Escape";
|
|
8
|
+
export declare const Home = "Home";
|
|
9
|
+
export declare const End = "End";
|
|
10
|
+
export declare const PageUp = "PageUp";
|
|
11
|
+
export declare const PageDown = "PageDown";
|
|
12
|
+
export declare const Space = " ";
|
|
13
|
+
export declare const Tab = "Tab";
|
|
14
|
+
export declare const isCharacterKey: (evt: React.KeyboardEvent) => boolean;
|
|
15
|
+
export type ArrowKey = "ArrowUp" | "ArrowDown" | "ArrowLeft" | "ArrowRight";
|
|
16
|
+
export type PageKey = "Home" | "End" | "PageUp" | "PageDown";
|
|
17
|
+
export type NavigationKey = PageKey | ArrowKey;
|
|
18
|
+
export declare const isPagingKey: (key: string) => key is PageKey;
|
|
19
|
+
export declare const isNavigationKey: (key: string) => key is NavigationKey;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DataSource, DataSourceConfigMessage, DataSourceRow, DataSourceSubscribedMessage, VuuFeatureMessage, VuuFeatureInvocationMessage } from "@vuu-ui/vuu-data";
|
|
2
|
+
import { VuuRange, VuuSortCol } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
export type SubscriptionDetails = {
|
|
4
|
+
columnNames?: string[];
|
|
5
|
+
range: {
|
|
6
|
+
from: number;
|
|
7
|
+
to: number;
|
|
8
|
+
};
|
|
9
|
+
sort?: VuuSortCol[];
|
|
10
|
+
};
|
|
11
|
+
export interface DataSourceHookProps {
|
|
12
|
+
dataSource: DataSource;
|
|
13
|
+
onConfigChange?: (message: DataSourceConfigMessage) => void;
|
|
14
|
+
onFeatureEnabled?: (message: VuuFeatureMessage) => void;
|
|
15
|
+
onFeatureInvocation?: (message: VuuFeatureInvocationMessage) => void;
|
|
16
|
+
onSizeChange: (size: number) => void;
|
|
17
|
+
onSubscribed: (subscription: DataSourceSubscribedMessage) => void;
|
|
18
|
+
range?: VuuRange;
|
|
19
|
+
renderBufferSize?: number;
|
|
20
|
+
viewportRowCount: number;
|
|
21
|
+
}
|
|
22
|
+
export declare function useDataSource({ dataSource, onConfigChange, onFeatureEnabled, onFeatureInvocation, onSizeChange, onSubscribed, range, renderBufferSize, viewportRowCount, }: DataSourceHookProps): {
|
|
23
|
+
data: DataSourceRow[];
|
|
24
|
+
getSelectedRows: () => DataSourceRow[];
|
|
25
|
+
range: VuuRange;
|
|
26
|
+
setRange: (range: VuuRange) => void;
|
|
27
|
+
dataSource: DataSource;
|
|
28
|
+
};
|
|
29
|
+
export declare class MovingWindow {
|
|
30
|
+
data: DataSourceRow[];
|
|
31
|
+
rowCount: number;
|
|
32
|
+
private range;
|
|
33
|
+
constructor({ from, to }: VuuRange);
|
|
34
|
+
setRowCount: (rowCount: number) => void;
|
|
35
|
+
add(data: DataSourceRow): void;
|
|
36
|
+
getAtIndex(index: number): DataSourceRow | undefined;
|
|
37
|
+
isWithinRange(index: number): boolean;
|
|
38
|
+
setRange({ from, to }: VuuRange): void;
|
|
39
|
+
getSelectedRows(): DataSourceRow[];
|
|
40
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DataSource, DataSourceRow, VuuFeatureInvocationMessage, VuuFeatureMessage } from "@vuu-ui/vuu-data";
|
|
2
|
+
import { GridConfig, KeyedColumnDescriptor, SelectionChangeHandler, TableSelectionModel } from "@vuu-ui/vuu-datagrid-types";
|
|
3
|
+
import { VuuSortType } from "@vuu-ui/vuu-protocol-types";
|
|
4
|
+
import { MouseEvent } from "react";
|
|
5
|
+
import { TableColumnResizeHandler, tableLayoutType } from "./dataTableTypes";
|
|
6
|
+
import { MeasuredProps } from "./useMeasuredContainer";
|
|
7
|
+
export interface DataTableHookProps extends MeasuredProps {
|
|
8
|
+
config: Omit<GridConfig, "headings">;
|
|
9
|
+
dataSource: DataSource;
|
|
10
|
+
headerHeight: number;
|
|
11
|
+
onConfigChange?: (config: Omit<GridConfig, "headings">) => void;
|
|
12
|
+
onFeatureEnabled?: (message: VuuFeatureMessage) => void;
|
|
13
|
+
onFeatureInvocation?: (message: VuuFeatureInvocationMessage) => void;
|
|
14
|
+
renderBufferSize?: number;
|
|
15
|
+
rowHeight: number;
|
|
16
|
+
onSelectionChange?: SelectionChangeHandler;
|
|
17
|
+
selectionModel: TableSelectionModel;
|
|
18
|
+
tableLayout: tableLayoutType;
|
|
19
|
+
}
|
|
20
|
+
export declare const useDataTable: ({ config, dataSource, headerHeight, onConfigChange, onFeatureEnabled, onFeatureInvocation, onSelectionChange, renderBufferSize, rowHeight, selectionModel, tableLayout, ...measuredProps }: DataTableHookProps) => {
|
|
21
|
+
draggable: JSX.Element | undefined;
|
|
22
|
+
draggedItemIndex: number | undefined;
|
|
23
|
+
tableLayout: "row" | "column";
|
|
24
|
+
onHeaderCellDragStart: ((evt: MouseEvent<Element, globalThis.MouseEvent>) => void) | undefined;
|
|
25
|
+
containerMeasurements: import("./useMeasuredContainer").MeasuredContainerHookResult;
|
|
26
|
+
containerProps: {
|
|
27
|
+
onClick: (evt: MouseEvent<Element, globalThis.MouseEvent>) => void;
|
|
28
|
+
onFocus: () => void;
|
|
29
|
+
onKeyDown: (e: import("react").KeyboardEvent<Element>) => void;
|
|
30
|
+
};
|
|
31
|
+
columns: KeyedColumnDescriptor[];
|
|
32
|
+
data: DataSourceRow[];
|
|
33
|
+
dispatchColumnAction: import("react").Dispatch<import("./useTableModel").GridModelAction>;
|
|
34
|
+
handleContextMenuAction: import("@vuu-ui/vuu-popups").MenuActionHandler;
|
|
35
|
+
headings: import("@vuu-ui/vuu-datagrid-types").TableHeadings;
|
|
36
|
+
onColumnResize: TableColumnResizeHandler;
|
|
37
|
+
onContextMenu: (evt: MouseEvent<HTMLElement>) => void;
|
|
38
|
+
onRemoveColumnFromGroupBy: (column: KeyedColumnDescriptor) => void;
|
|
39
|
+
onRowClick: import("./dataTableTypes").RowClickHandler;
|
|
40
|
+
onSort: (column: KeyedColumnDescriptor, extendSort?: any, sortType?: VuuSortType) => void;
|
|
41
|
+
onToggleGroup: (row: DataSourceRow) => void;
|
|
42
|
+
scrollProps: {
|
|
43
|
+
onScrollbarContainerScroll: () => void;
|
|
44
|
+
onContentContainerScroll: () => void;
|
|
45
|
+
onTableContainerScroll: () => void;
|
|
46
|
+
contentContainerRef: import("react").RefObject<HTMLDivElement>;
|
|
47
|
+
scrollbarContainerRef: import("react").RefObject<HTMLDivElement>;
|
|
48
|
+
tableContainerRef: import("react").RefObject<HTMLDivElement>;
|
|
49
|
+
};
|
|
50
|
+
rowCount: number;
|
|
51
|
+
viewportMeasurements: {
|
|
52
|
+
fillerHeight: number;
|
|
53
|
+
maxScrollContainerScrollHorizontal: number;
|
|
54
|
+
maxScrollContainerScrollVertical: number;
|
|
55
|
+
pinnedWidthLeft: number;
|
|
56
|
+
pinnedWidthRight: number;
|
|
57
|
+
rowCount: number;
|
|
58
|
+
scrollContentHeight: number;
|
|
59
|
+
scrollbarSize: number;
|
|
60
|
+
scrollContentWidth: number;
|
|
61
|
+
totalHeaderHeight: number;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MouseEvent, RefObject } from "react";
|
|
2
|
+
export interface DraggableColumnHookProps {
|
|
3
|
+
onDrop: (fromIndex: number, toIndex: number) => void;
|
|
4
|
+
tableContainerRef: RefObject<HTMLDivElement>;
|
|
5
|
+
tableLayout: "column" | "row";
|
|
6
|
+
}
|
|
7
|
+
export declare const useDraggableColumn: ({ onDrop, tableContainerRef, tableLayout: tableLayoutProp, }: DraggableColumnHookProps) => {
|
|
8
|
+
draggable: JSX.Element | undefined;
|
|
9
|
+
draggedItemIndex: number | undefined;
|
|
10
|
+
tableLayout: "row" | "column";
|
|
11
|
+
onHeaderCellDragStart: ((evt: MouseEvent) => void) | undefined;
|
|
12
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DataSourceRow } from "@vuu-ui/vuu-data";
|
|
2
|
+
import { VuuRange } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
import { KeyboardEvent, MouseEvent, RefObject } from "react";
|
|
4
|
+
import { ScrollRequestHandler } from "./useTableScroll";
|
|
5
|
+
export type CellPos = [number, number];
|
|
6
|
+
export interface NavigationHookProps {
|
|
7
|
+
containerRef: RefObject<HTMLElement>;
|
|
8
|
+
columnCount?: number;
|
|
9
|
+
data: DataSourceRow[];
|
|
10
|
+
disableHighlightOnFocus?: boolean;
|
|
11
|
+
label?: string;
|
|
12
|
+
viewportRange: VuuRange;
|
|
13
|
+
requestScroll?: ScrollRequestHandler;
|
|
14
|
+
restoreLastFocus?: boolean;
|
|
15
|
+
rowCount?: number;
|
|
16
|
+
selected?: unknown;
|
|
17
|
+
}
|
|
18
|
+
export declare const useKeyboardNavigation: ({ columnCount, containerRef, disableHighlightOnFocus, data, requestScroll, rowCount, viewportRange, }: NavigationHookProps) => {
|
|
19
|
+
onClick: (evt: MouseEvent) => void;
|
|
20
|
+
onFocus: () => void;
|
|
21
|
+
onKeyDown: (e: KeyboardEvent) => void;
|
|
22
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
export interface ClientSize {
|
|
3
|
+
clientHeight: number;
|
|
4
|
+
clientWidth: number;
|
|
5
|
+
}
|
|
6
|
+
export interface MeasuredProps {
|
|
7
|
+
defaultHeight?: number;
|
|
8
|
+
defaultWidth?: number;
|
|
9
|
+
height?: number;
|
|
10
|
+
width?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface Size {
|
|
13
|
+
height: number | "100%";
|
|
14
|
+
width: number | "100%";
|
|
15
|
+
}
|
|
16
|
+
export interface MeasuredSize {
|
|
17
|
+
height: number;
|
|
18
|
+
width: number;
|
|
19
|
+
}
|
|
20
|
+
export interface MeasuredContainerHookResult {
|
|
21
|
+
containerRef: RefObject<HTMLDivElement>;
|
|
22
|
+
outerSize: Size;
|
|
23
|
+
innerSize?: MeasuredSize;
|
|
24
|
+
}
|
|
25
|
+
export declare const useMeasuredContainer: ({ defaultHeight, defaultWidth, height, width, }: MeasuredProps) => MeasuredContainerHookResult;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
export type Size = {
|
|
3
|
+
pixelHeight: number;
|
|
4
|
+
pixelWidth: number;
|
|
5
|
+
clientHeight?: number;
|
|
6
|
+
clientWidth?: number;
|
|
7
|
+
height: number | "100%";
|
|
8
|
+
width: number | "100%";
|
|
9
|
+
};
|
|
10
|
+
export type FullSize = {
|
|
11
|
+
clientHeight?: number;
|
|
12
|
+
clientWidth?: number;
|
|
13
|
+
height: "100%";
|
|
14
|
+
width: "100%";
|
|
15
|
+
};
|
|
16
|
+
export type ClientSize = {
|
|
17
|
+
clientHeight: number;
|
|
18
|
+
clientWidth: number;
|
|
19
|
+
};
|
|
20
|
+
export type MeasuredSize = ClientSize & {
|
|
21
|
+
height: number | "100%";
|
|
22
|
+
width: number | "100%";
|
|
23
|
+
};
|
|
24
|
+
export declare const isMeasured: (size: Size | MeasuredSize) => size is MeasuredSize;
|
|
25
|
+
export declare const isFullSize: (size: Size | MeasuredSize | FullSize) => size is FullSize;
|
|
26
|
+
export declare const useMeasuredSize: (containerRef: RefObject<HTMLDivElement>, height?: number | "100%", width?: number | "100%") => Size;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
export declare const WidthHeight: string[];
|
|
3
|
+
export declare const WidthOnly: string[];
|
|
4
|
+
export type measurements<T = string | number> = {
|
|
5
|
+
height?: T;
|
|
6
|
+
clientHeight?: number;
|
|
7
|
+
clientWidth?: number;
|
|
8
|
+
contentHeight?: number;
|
|
9
|
+
contentWidth?: number;
|
|
10
|
+
scrollHeight?: number;
|
|
11
|
+
scrollWidth?: number;
|
|
12
|
+
width?: T;
|
|
13
|
+
};
|
|
14
|
+
export type ResizeHandler = (measurements: measurements<number>) => void;
|
|
15
|
+
export declare function useResizeObserver(ref: RefObject<Element | HTMLElement | null>, dimensions: string[], onResize: ResizeHandler, reportInitialSize?: boolean): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SelectionChangeHandler, TableSelectionModel } from "@vuu-ui/vuu-datagrid-types";
|
|
2
|
+
import { RowClickHandler } from "./dataTableTypes";
|
|
3
|
+
export interface SelectionHookProps {
|
|
4
|
+
selectionModel: TableSelectionModel;
|
|
5
|
+
onSelectionChange: SelectionChangeHandler;
|
|
6
|
+
}
|
|
7
|
+
export declare const useSelection: ({ selectionModel, onSelectionChange, }: SelectionHookProps) => RowClickHandler;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Heading, KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
|
|
2
|
+
import { RefObject } from "react";
|
|
3
|
+
export type ResizeHandler = (evt: MouseEvent, moveBy: number) => void;
|
|
4
|
+
export interface CellResizeHookProps {
|
|
5
|
+
column: KeyedColumnDescriptor | Heading;
|
|
6
|
+
onResize?: (phase: resizePhase, columnName: string, width?: number) => void;
|
|
7
|
+
rootRef: RefObject<HTMLDivElement>;
|
|
8
|
+
}
|
|
9
|
+
type resizePhase = "begin" | "resize" | "end";
|
|
10
|
+
export interface CellResizeHookResult {
|
|
11
|
+
isResizing: boolean;
|
|
12
|
+
onDrag: (evt: MouseEvent, moveBy: number) => void;
|
|
13
|
+
onDragStart: (evt: React.MouseEvent) => void;
|
|
14
|
+
onDragEnd: (evt: MouseEvent) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const useTableColumnResize: ({ column, onResize, rootRef, }: CellResizeHookProps) => CellResizeHookResult;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ColumnDescriptor, GridConfig, KeyedColumnDescriptor, PinLocation } from "@vuu-ui/vuu-datagrid-types";
|
|
2
|
+
import { Reducer } from "react";
|
|
3
|
+
import { VuuColumnDataType } from "@vuu-ui/vuu-protocol-types";
|
|
4
|
+
import { DataSourceConfig } from "@vuu-ui/vuu-data";
|
|
5
|
+
export interface GridModel extends Omit<GridConfig, "columns"> {
|
|
6
|
+
columns: KeyedColumnDescriptor[];
|
|
7
|
+
}
|
|
8
|
+
export interface ColumnActionInit {
|
|
9
|
+
type: "init";
|
|
10
|
+
tableConfig: Omit<GridConfig, "headings">;
|
|
11
|
+
dataSourceConfig?: DataSourceConfig;
|
|
12
|
+
}
|
|
13
|
+
export interface ColumnActionHide {
|
|
14
|
+
type: "hideColumn";
|
|
15
|
+
column: KeyedColumnDescriptor;
|
|
16
|
+
}
|
|
17
|
+
export interface ColumnActionMove {
|
|
18
|
+
type: "moveColumn";
|
|
19
|
+
column: KeyedColumnDescriptor;
|
|
20
|
+
moveBy?: 1 | -1;
|
|
21
|
+
moveTo?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface ColumnActionPin {
|
|
24
|
+
type: "pinColumn";
|
|
25
|
+
column: ColumnDescriptor;
|
|
26
|
+
pin?: PinLocation;
|
|
27
|
+
}
|
|
28
|
+
export interface ColumnActionResize {
|
|
29
|
+
type: "resizeColumn";
|
|
30
|
+
column: KeyedColumnDescriptor;
|
|
31
|
+
phase: "begin" | "resize" | "end";
|
|
32
|
+
width?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface ColumnActionSetTypes {
|
|
35
|
+
type: "setTypes";
|
|
36
|
+
columnNames: string[];
|
|
37
|
+
serverDataTypes: VuuColumnDataType[];
|
|
38
|
+
}
|
|
39
|
+
export interface ColumnActionUpdate {
|
|
40
|
+
type: "updateColumn";
|
|
41
|
+
column: ColumnDescriptor;
|
|
42
|
+
}
|
|
43
|
+
export interface ColumnActionUpdateProp {
|
|
44
|
+
align?: ColumnDescriptor["align"];
|
|
45
|
+
column: KeyedColumnDescriptor;
|
|
46
|
+
hidden?: ColumnDescriptor["hidden"];
|
|
47
|
+
label?: ColumnDescriptor["label"];
|
|
48
|
+
resizing?: KeyedColumnDescriptor["resizing"];
|
|
49
|
+
type: "updateColumnProp";
|
|
50
|
+
width?: ColumnDescriptor["width"];
|
|
51
|
+
}
|
|
52
|
+
export interface ColumnActionTableConfig extends DataSourceConfig {
|
|
53
|
+
type: "tableConfig";
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* PersistentColumnActions are those actions that require us to persist user changes across sessions
|
|
57
|
+
*/
|
|
58
|
+
export type PersistentColumnAction = ColumnActionPin | ColumnActionHide;
|
|
59
|
+
export type GridModelAction = ColumnActionHide | ColumnActionInit | ColumnActionMove | ColumnActionPin | ColumnActionResize | ColumnActionSetTypes | ColumnActionUpdate | ColumnActionUpdateProp | ColumnActionTableConfig;
|
|
60
|
+
export type GridModelReducer = Reducer<GridModel, GridModelAction>;
|
|
61
|
+
export type ColumnActionDispatch = (action: GridModelAction) => void;
|
|
62
|
+
export declare const useTableModel: (tableConfig: Omit<GridConfig, "headings">, dataSourceConfig?: DataSourceConfig) => {
|
|
63
|
+
columns: KeyedColumnDescriptor[];
|
|
64
|
+
dispatchColumnAction: import("react").Dispatch<GridModelAction>;
|
|
65
|
+
headings: import("@vuu-ui/vuu-datagrid-types").TableHeadings;
|
|
66
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Viewport } from "./dataTableTypes";
|
|
3
|
+
export interface ScrollRequestEnd {
|
|
4
|
+
type: "scroll-end";
|
|
5
|
+
direction: "home" | "end";
|
|
6
|
+
}
|
|
7
|
+
export interface ScrollRequestPage {
|
|
8
|
+
type: "scroll-page";
|
|
9
|
+
direction: "up" | "down";
|
|
10
|
+
}
|
|
11
|
+
export interface ScrollRequestDistance {
|
|
12
|
+
type: "scroll-distance";
|
|
13
|
+
distance: number;
|
|
14
|
+
}
|
|
15
|
+
export type ScrollRequest = ScrollRequestPage | ScrollRequestDistance | ScrollRequestEnd;
|
|
16
|
+
export type ScrollRequestHandler = (request: ScrollRequest) => void;
|
|
17
|
+
export interface TableScrollHookProps {
|
|
18
|
+
onRangeChange: (from: number, to: number) => void;
|
|
19
|
+
rowHeight: number;
|
|
20
|
+
viewportHeight: number;
|
|
21
|
+
viewport: Viewport;
|
|
22
|
+
}
|
|
23
|
+
export declare const useTableScroll: ({ onRangeChange, rowHeight, viewport, }: TableScrollHookProps) => {
|
|
24
|
+
onScrollbarContainerScroll: () => void;
|
|
25
|
+
onContentContainerScroll: () => void;
|
|
26
|
+
onTableContainerScroll: () => void;
|
|
27
|
+
requestScroll: ScrollRequestHandler;
|
|
28
|
+
contentContainerRef: import("react").RefObject<HTMLDivElement>;
|
|
29
|
+
scrollbarContainerRef: import("react").RefObject<HTMLDivElement>;
|
|
30
|
+
tableContainerRef: import("react").RefObject<HTMLDivElement>;
|
|
31
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This hook measures and calculates the values needed to manage layout
|
|
3
|
+
* and virtualisation of the table. This includes measurements required
|
|
4
|
+
* to support pinned columns.
|
|
5
|
+
*/
|
|
6
|
+
import { KeyedColumnDescriptor, TableHeadings } from "@vuu-ui/vuu-datagrid-types";
|
|
7
|
+
import { MeasuredSize } from "./useMeasuredContainer";
|
|
8
|
+
export interface TableViewportHookProps {
|
|
9
|
+
columns: KeyedColumnDescriptor[];
|
|
10
|
+
headerHeight: number;
|
|
11
|
+
headings: TableHeadings;
|
|
12
|
+
rowCount: number;
|
|
13
|
+
rowHeight: number;
|
|
14
|
+
size?: MeasuredSize;
|
|
15
|
+
}
|
|
16
|
+
export interface ViewportMeasurements {
|
|
17
|
+
fillerHeight: number;
|
|
18
|
+
maxScrollContainerScrollHorizontal: number;
|
|
19
|
+
maxScrollContainerScrollVertical: number;
|
|
20
|
+
pinnedWidthLeft: number;
|
|
21
|
+
pinnedWidthRight: number;
|
|
22
|
+
rowCount: number;
|
|
23
|
+
scrollContentHeight: number;
|
|
24
|
+
scrollbarSize: number;
|
|
25
|
+
scrollContentWidth: number;
|
|
26
|
+
totalHeaderHeight: number;
|
|
27
|
+
}
|
|
28
|
+
export declare const useTableViewport: ({ columns, headerHeight, headings, rowCount, rowHeight, size, }: TableViewportHookProps) => {
|
|
29
|
+
fillerHeight: number;
|
|
30
|
+
maxScrollContainerScrollHorizontal: number;
|
|
31
|
+
maxScrollContainerScrollVertical: number;
|
|
32
|
+
pinnedWidthLeft: number;
|
|
33
|
+
pinnedWidthRight: number;
|
|
34
|
+
rowCount: number;
|
|
35
|
+
scrollContentHeight: number;
|
|
36
|
+
scrollbarSize: number;
|
|
37
|
+
scrollContentWidth: number;
|
|
38
|
+
totalHeaderHeight: number;
|
|
39
|
+
};
|