@vuu-ui/vuu-table 0.8.8-debug → 0.8.9-debug

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 (51) hide show
  1. package/cjs/index.js +34039 -13836
  2. package/cjs/index.js.map +4 -4
  3. package/esm/index.js +33454 -13081
  4. package/esm/index.js.map +4 -4
  5. package/index.css +1820 -532
  6. package/index.css.map +3 -3
  7. package/package.json +5 -5
  8. package/types/index.d.ts +2 -1
  9. package/types/table/Table.d.ts +1 -1
  10. package/types/table/dataTableTypes.d.ts +33 -5
  11. package/types/table/index.d.ts +1 -1
  12. package/types/table/useTableModel.d.ts +2 -2
  13. package/types/table/useVirtualViewport.d.ts +1 -1
  14. package/types/table-next/Row.d.ts +7 -5
  15. package/types/table-next/TableNext.d.ts +1 -1
  16. package/types/table-next/cell-renderers/dropdown-cell/DropdownCell.d.ts +4 -0
  17. package/types/table-next/cell-renderers/dropdown-cell/index.d.ts +1 -0
  18. package/types/table-next/cell-renderers/index.d.ts +2 -0
  19. package/types/table-next/cell-renderers/input-cell/InputCell.d.ts +4 -0
  20. package/types/table-next/cell-renderers/input-cell/index.d.ts +1 -0
  21. package/types/table-next/column-header-pill/ColumnHeaderPill.d.ts +9 -0
  22. package/types/table-next/column-header-pill/GroupColumnPill.d.ts +8 -0
  23. package/types/table-next/column-header-pill/SortIndicator.d.ts +7 -0
  24. package/types/table-next/column-header-pill/index.d.ts +3 -0
  25. package/types/table-next/column-menu/index.d.ts +1 -0
  26. package/types/table-next/column-resizing/useTableColumnResize.d.ts +3 -4
  27. package/types/table-next/context-menu/useTableContextMenu.d.ts +5 -0
  28. package/types/table-next/header-cell/GroupHeaderCell.d.ts +9 -0
  29. package/types/table-next/header-cell/GroupHeaderCellNext.d.ts +9 -0
  30. package/types/table-next/{HeaderCell.d.ts → header-cell/HeaderCell.d.ts} +2 -3
  31. package/types/table-next/header-cell/index.d.ts +3 -0
  32. package/types/table-next/index.d.ts +3 -0
  33. package/types/table-next/moving-window.d.ts +14 -0
  34. package/types/table-next/table-cell/TableCell.d.ts +4 -0
  35. package/types/table-next/table-cell/TableGroupCell.d.ts +4 -0
  36. package/types/table-next/table-cell/index.d.ts +2 -0
  37. package/types/table-next/table-config.d.ts +1 -1
  38. package/types/table-next/table-dom-utils.d.ts +7 -0
  39. package/types/table-next/useCellEditing.d.ts +7 -0
  40. package/types/table-next/useDataSource.d.ts +11 -4
  41. package/types/table-next/useKeyboardNavigation.d.ts +27 -0
  42. package/types/table-next/useMeasuredContainer.d.ts +30 -0
  43. package/types/table-next/useResizeObserver.d.ts +15 -0
  44. package/types/table-next/useTableContextMenu.d.ts +8 -0
  45. package/types/table-next/useTableModel.d.ts +35 -8
  46. package/types/table-next/useTableNext.d.ts +39 -25
  47. package/types/table-next/useTableScroll.d.ts +8 -2
  48. package/types/{table → table-next}/useTableViewport.d.ts +2 -2
  49. package/types/table-next/TableCell.d.ts +0 -9
  50. package/types/table-next/TableGroupCell.d.ts +0 -9
  51. /package/types/table-next/{ColumnMenu.d.ts → column-menu/ColumnMenu.d.ts} +0 -0
@@ -2,4 +2,4 @@
2
2
  import { TableProps } from "./dataTableTypes";
3
3
  import "./Table.css";
4
4
  import "./Table-loading.css";
5
- export declare const Table: ({ allowConfigEditing: showSettings, className: classNameProp, config, dataSource, headerHeight, height, id: idProp, onConfigChange, onFeatureEnabled, onFeatureInvocation, onSelectionChange, onShowConfigEditor: onShowSettings, renderBufferSize, rowHeight, selectionModel, style: styleProp, width, zebraStripes, ...htmlAttributes }: TableProps) => JSX.Element;
5
+ export declare const Table: ({ allowConfigEditing: showSettings, className: classNameProp, config, dataSource, headerHeight, height, id: idProp, onConfigChange, onFeatureEnabled, onFeatureInvocation, onSelectionChange, onShowConfigEditor: onShowSettings, renderBufferSize, rowHeight, selectionModel, style: styleProp, width, ...htmlAttributes }: TableProps) => JSX.Element;
@@ -1,14 +1,33 @@
1
- import { DataSource, VuuFeatureInvocationMessage, VuuFeatureMessage } from "@vuu-ui/vuu-data";
1
+ import { DataSource, SchemaColumn, VuuFeatureInvocationMessage, VuuFeatureMessage } from "@vuu-ui/vuu-data";
2
2
  import { DataSourceRow } from "@vuu-ui/vuu-data-types";
3
- import { GridConfig, KeyedColumnDescriptor, SelectionChangeHandler, TableConfig, TableHeadings, TableSelectionModel } from "@vuu-ui/vuu-datagrid-types";
4
- import { HTMLAttributes, MouseEvent } from "react";
3
+ import { KeyedColumnDescriptor, SelectionChangeHandler, TableConfig, TableHeadings, TableSelectionModel } from "@vuu-ui/vuu-datagrid-types";
4
+ import { VuuDataRow } from "packages/vuu-protocol-types";
5
+ import { FC, HTMLAttributes, MouseEvent } from "react";
6
+ import { RowProps } from "../table-next/Row";
7
+ export type TableRowClickHandler = (row: VuuDataRow) => void;
5
8
  export interface TableProps extends HTMLAttributes<HTMLDivElement> {
9
+ Row?: FC<RowProps>;
6
10
  allowConfigEditing?: boolean;
11
+ /**
12
+ * required if a fully featured column picker is to be available
13
+ */
14
+ availableColumns?: SchemaColumn[];
7
15
  config: TableConfig;
8
16
  dataSource: DataSource;
9
17
  headerHeight?: number;
10
18
  height?: number;
11
- onConfigChange?: (config: Omit<GridConfig, "headings">) => void;
19
+ /**
20
+ * required if a fully featured column picker is to be available.
21
+ * Available columns can be changed by the addition or removal of
22
+ * one or more calculated columns.
23
+ */
24
+ onAvailableColumnsChange?: (columns: SchemaColumn[]) => void;
25
+ /**
26
+ * This callback will be invoked any time a config attribute of TableConfig
27
+ * is changed. By persisting this value and providing it to the Table as a
28
+ * prop, table state can be persisted across sessions.
29
+ */
30
+ onConfigChange?: (config: TableConfig) => void;
12
31
  /**
13
32
  * Features like context menu actions and visual links are enabled by the Vuu server.
14
33
  * This callback allows us to receive a notification when such a feature is available.
@@ -20,6 +39,11 @@ export interface TableProps extends HTMLAttributes<HTMLDivElement> {
20
39
  * response must be handled. This callback provides that response.
21
40
  */
22
41
  onFeatureInvocation?: (message: VuuFeatureInvocationMessage) => void;
42
+ /**
43
+ * callback invoked when user 'clicks' a table row. CLick triggered either
44
+ * via mouse click or keyboard (default ENTER);
45
+ */
46
+ onRowClick?: TableRowClickHandler;
23
47
  onShowConfigEditor?: () => void;
24
48
  onSelectionChange?: SelectionChangeHandler;
25
49
  renderBufferSize?: number;
@@ -31,8 +55,12 @@ export interface TableProps extends HTMLAttributes<HTMLDivElement> {
31
55
  */
32
56
  selectionBookendWidth?: number;
33
57
  selectionModel?: TableSelectionModel;
58
+ /**
59
+ * if false, table rendered without headers. Useful when table is being included in a
60
+ * composite component.
61
+ */
62
+ showColumnHeaders?: boolean;
34
63
  width?: number;
35
- zebraStripes?: boolean;
36
64
  }
37
65
  export type TableColumnResizeHandler = (phase: "begin" | "resize" | "end", columnName: string, width?: number) => void;
38
66
  export interface TableImplementationProps {
@@ -6,5 +6,5 @@ export * from "./useMeasuredContainer";
6
6
  export * from "./useSelection";
7
7
  export * from "./useTableColumnResize";
8
8
  export * from "./useTableModel";
9
- export * from "./useTableViewport";
9
+ export * from "../table-next/useTableViewport";
10
10
  export * from "./cell-renderers";
@@ -1,4 +1,4 @@
1
- import { ColumnDescriptor, GridConfig, KeyedColumnDescriptor, PinLocation } from "@vuu-ui/vuu-datagrid-types";
1
+ import { ColumnDescriptor, GridConfig, KeyedColumnDescriptor, PinLocation, TableConfig } from "@vuu-ui/vuu-datagrid-types";
2
2
  import { Reducer } from "react";
3
3
  import { DataSourceConfig } from "@vuu-ui/vuu-data";
4
4
  import { TableSchema } from "@vuu-ui/vuu-data/src/message-utils";
@@ -8,7 +8,7 @@ export interface TableModel extends Omit<GridConfig, "columns"> {
8
8
  }
9
9
  export interface ColumnActionInit {
10
10
  type: "init";
11
- tableConfig: Omit<GridConfig, "headings">;
11
+ tableConfig: TableConfig;
12
12
  dataSourceConfig?: DataSourceConfig;
13
13
  }
14
14
  export interface ColumnActionHide {
@@ -1,7 +1,7 @@
1
1
  import { KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
2
2
  import { RowAtPositionFunc } from "@vuu-ui/vuu-utils";
3
3
  import { VuuRange } from "@vuu-ui/vuu-protocol-types";
4
- import { ViewportMeasurements } from "./useTableViewport";
4
+ import { ViewportMeasurements } from "../table-next/useTableViewport";
5
5
  export interface VirtualViewportHookProps {
6
6
  columns: KeyedColumnDescriptor[];
7
7
  getRowAtPosition: RowAtPositionFunc;
@@ -1,17 +1,19 @@
1
1
  import { DataSourceRow } from "@vuu-ui/vuu-data-types";
2
- import { KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
2
+ import { DataCellEditHandler, KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
3
3
  import { RowClickHandler } from "@vuu-ui/vuu-table";
4
4
  import { ColumnMap } from "@vuu-ui/vuu-utils";
5
5
  import { CSSProperties } from "react";
6
6
  import "./Row.css";
7
- export type HtmlRowProps = {
7
+ export interface RowProps {
8
8
  className?: string;
9
9
  columnMap: ColumnMap;
10
10
  columns: KeyedColumnDescriptor[];
11
11
  row: DataSourceRow;
12
- offset?: number;
12
+ offset: number;
13
13
  onClick?: RowClickHandler;
14
+ onDataEdited?: DataCellEditHandler;
14
15
  onToggleGroup?: (row: DataSourceRow, column: KeyedColumnDescriptor) => void;
15
16
  style?: CSSProperties;
16
- };
17
- export declare const Row: import("react").MemoExoticComponent<({ className: classNameProp, columnMap, columns, row, offset, onClick, onToggleGroup, ...htmlAttributes }: HtmlRowProps) => JSX.Element>;
17
+ zebraStripes?: boolean;
18
+ }
19
+ export declare const Row: import("react").MemoExoticComponent<({ className: classNameProp, columnMap, columns, row, offset, onClick, onDataEdited, onToggleGroup, zebraStripes, ...htmlAttributes }: RowProps) => JSX.Element>;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { TableProps } from "@vuu-ui/vuu-table";
3
3
  import "./TableNext.css";
4
- export declare const TableNext: ({ className: classNameProp, config, dataSource, headerHeight, height, id: idProp, onConfigChange, onFeatureEnabled, onFeatureInvocation, onSelectionChange, onShowConfigEditor: onShowSettings, renderBufferSize, rowHeight, selectionModel, style: styleProp, width, ...htmlAttributes }: TableProps) => JSX.Element;
4
+ export declare const TableNext: ({ Row, availableColumns, className: classNameProp, config, dataSource, id: idProp, onAvailableColumnsChange, onConfigChange, onFeatureEnabled, onFeatureInvocation, onRowClick: onRowClickProp, onSelectionChange, onShowConfigEditor: onShowSettings, renderBufferSize, rowHeight, selectionModel, showColumnHeaders, headerHeight, style: styleProp, ...htmlAttributes }: TableProps) => JSX.Element;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { TableCellProps } from "@vuu-ui/vuu-datagrid-types";
3
+ import "./DropdownCell.css";
4
+ export declare const DropdownCell: ({ column, columnMap, row }: TableCellProps) => JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./DropdownCell";
@@ -0,0 +1,2 @@
1
+ export * from "./dropdown-cell";
2
+ export * from "./input-cell";
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { TableCellRendererProps } from "@vuu-ui/vuu-datagrid-types";
3
+ import "./InputCell.css";
4
+ export declare const InputCell: ({ column, columnMap, onCommit, row, }: TableCellRendererProps) => JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./InputCell";
@@ -0,0 +1,9 @@
1
+ import { KeyedColumnDescriptor } from "packages/vuu-datagrid-types";
2
+ import { HTMLAttributes } from "react";
3
+ import "./ColumnHeaderPill.css";
4
+ export interface ColumnHeaderPillProps extends HTMLAttributes<HTMLDivElement> {
5
+ column: KeyedColumnDescriptor;
6
+ removable?: boolean;
7
+ onRemove?: (column: KeyedColumnDescriptor) => void;
8
+ }
9
+ export declare const ColumnHeaderPill: ({ children, className, column, onRemove, removable, ...htmlAttributes }: ColumnHeaderPillProps) => JSX.Element;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { KeyedColumnDescriptor } from "packages/vuu-datagrid-types";
3
+ import { ColumnHeaderPillProps } from "./ColumnHeaderPill";
4
+ import "./GroupColumnPill.css";
5
+ export interface GroupColumnPillProps extends ColumnHeaderPillProps {
6
+ column: KeyedColumnDescriptor;
7
+ }
8
+ export declare const GroupColumnPill: ({ column, ...columnHeaderProps }: GroupColumnPillProps) => JSX.Element;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
3
+ import "./SortIndicator.css";
4
+ export interface SortIndicatorProps {
5
+ column: KeyedColumnDescriptor;
6
+ }
7
+ export declare const SortIndicator: ({ column }: SortIndicatorProps) => JSX.Element | null;
@@ -0,0 +1,3 @@
1
+ export * from "./ColumnHeaderPill";
2
+ export * from "./GroupColumnPill";
3
+ export * from "./SortIndicator";
@@ -0,0 +1 @@
1
+ export * from "./ColumnMenu";
@@ -1,13 +1,13 @@
1
1
  import { Heading, KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
2
2
  import { RefObject } from "react";
3
- export type TableColumnResizeHandler = (phase: "begin" | "resize" | "end", columnName: string, width?: number) => void;
3
+ import { ResizePhase } from "../useTableModel";
4
+ export type TableColumnResizeHandler = (phase: ResizePhase, columnName: string, width?: number) => void;
4
5
  export type ResizeHandler = (evt: MouseEvent, moveBy: number) => void;
5
6
  export interface CellResizeHookProps {
6
7
  column: KeyedColumnDescriptor | Heading;
7
- onResize?: (phase: resizePhase, columnName: string, width?: number) => void;
8
+ onResize?: (phase: ResizePhase, columnName: string, width?: number) => void;
8
9
  rootRef: RefObject<HTMLDivElement>;
9
10
  }
10
- type resizePhase = "begin" | "resize" | "end";
11
11
  export interface CellResizeHookResult {
12
12
  isResizing: boolean;
13
13
  onDrag: (evt: MouseEvent, moveBy: number) => void;
@@ -15,4 +15,3 @@ export interface CellResizeHookResult {
15
15
  onDragEnd: (evt: MouseEvent) => void;
16
16
  }
17
17
  export declare const useTableColumnResize: ({ column, onResize, rootRef, }: CellResizeHookProps) => CellResizeHookResult;
18
- export {};
@@ -11,6 +11,11 @@ export interface ContextMenuOptions {
11
11
  }
12
12
  export interface ContextMenuHookProps {
13
13
  dataSource?: DataSource;
14
+ /**
15
+ * A persistent Column Operation is any manipulation of a table column that should be
16
+ * persisted across user sessions. e.g. if user pins a column, column should still be
17
+ * pinned next time user opens app.
18
+ */
14
19
  onPersistentColumnOperation: (action: PersistentColumnAction) => void;
15
20
  }
16
21
  export declare const useTableContextMenu: ({ dataSource, onPersistentColumnOperation, }: ContextMenuHookProps) => MenuActionHandler;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { GroupColumnDescriptor, KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
3
+ import { HeaderCellProps } from "./HeaderCell";
4
+ import "./GroupHeaderCell.css";
5
+ export interface GroupHeaderCellProps extends Omit<HeaderCellProps, "onDragStart" | "onDrag" | "onDragEnd"> {
6
+ column: GroupColumnDescriptor;
7
+ onRemoveColumn: (column: KeyedColumnDescriptor) => void;
8
+ }
9
+ export declare const GroupHeaderCell: ({ column: groupColumn, className: classNameProp, onRemoveColumn, onResize, ...htmlAttributes }: GroupHeaderCellProps) => JSX.Element;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { GroupColumnDescriptor, KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
3
+ import { HeaderCellProps } from "./HeaderCell";
4
+ import "./GroupHeaderCell.css";
5
+ export interface GroupHeaderCellNextProps extends Omit<HeaderCellProps, "onDragStart" | "onDrag" | "onDragEnd"> {
6
+ column: GroupColumnDescriptor;
7
+ onRemoveColumn: (column: KeyedColumnDescriptor) => void;
8
+ }
9
+ export declare const GroupHeaderCellNext: ({ column: groupColumn, className: classNameProp, onRemoveColumn, onResize, ...htmlAttributes }: GroupHeaderCellNextProps) => JSX.Element;
@@ -1,11 +1,10 @@
1
1
  import { KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
2
2
  import { HTMLAttributes } from "react";
3
- import { TableColumnResizeHandler } from "./column-resizing";
3
+ import { TableColumnResizeHandler } from "../column-resizing";
4
4
  import "./HeaderCell.css";
5
5
  export interface HeaderCellProps extends HTMLAttributes<HTMLDivElement> {
6
6
  classBase?: string;
7
7
  column: KeyedColumnDescriptor;
8
- idx: number;
9
8
  onResize?: TableColumnResizeHandler;
10
9
  }
11
- export declare const HeaderCell: ({ classBase: classBaseProp, column, onClick, onResize, idx, }: HeaderCellProps) => JSX.Element;
10
+ export declare const HeaderCell: ({ className: classNameProp, column, onClick, onResize, ...htmlAttributes }: HeaderCellProps) => JSX.Element;
@@ -0,0 +1,3 @@
1
+ export * from "./GroupHeaderCell";
2
+ export * from "./GroupHeaderCellNext";
3
+ export * from "./HeaderCell";
@@ -1,2 +1,5 @@
1
+ export { GroupHeaderCellNext } from "./header-cell";
1
2
  export * from "./TableNext";
2
3
  export * from "./table-config";
4
+ export * from "./cell-renderers";
5
+ export type { RowProps } from "./Row";
@@ -0,0 +1,14 @@
1
+ import { DataSourceRow } from "@vuu-ui/vuu-data-types";
2
+ import { VuuRange } from "@vuu-ui/vuu-protocol-types";
3
+ export declare class MovingWindow {
4
+ data: DataSourceRow[];
5
+ rowCount: number;
6
+ private range;
7
+ constructor({ from, to }: VuuRange);
8
+ setRowCount: (rowCount: number) => void;
9
+ add(data: DataSourceRow): void;
10
+ getAtIndex(index: number): DataSourceRow | undefined;
11
+ isWithinRange(index: number): boolean;
12
+ setRange({ from, to }: VuuRange): void;
13
+ getSelectedRows(): DataSourceRow[];
14
+ }
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { TableCellProps } from "@vuu-ui/vuu-datagrid-types";
3
+ import "./TableCell.css";
4
+ export declare const TableCell: ({ column, columnMap, onDataEdited, row, }: TableCellProps) => JSX.Element;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { TableCellProps } from "@vuu-ui/vuu-datagrid-types";
3
+ import "./TableGroupCell.css";
4
+ export declare const TableGroupCell: ({ column, onClick, row }: TableCellProps) => JSX.Element;
@@ -0,0 +1,2 @@
1
+ export * from "./TableCell";
2
+ export * from "./TableGroupCell";
@@ -1,4 +1,4 @@
1
- import { ColumnDescriptor, TableConfig } from "packages/vuu-datagrid-types";
1
+ import { ColumnDescriptor, TableConfig } from "@vuu-ui/vuu-datagrid-types";
2
2
  export type MoveColumnTableConfigAction = {
3
3
  type: "col-move";
4
4
  column: ColumnDescriptor;
@@ -0,0 +1,7 @@
1
+ import { RefObject } from "react";
2
+ export type CellPos = [number, number];
3
+ export declare const headerCellQuery: (colIdx: number) => string;
4
+ export declare const dataCellQuery: (rowIdx: number, colIdx: number) => string;
5
+ export declare const getTableCell: (containerRef: RefObject<HTMLElement>, [rowIdx, colIdx]: CellPos) => HTMLElement;
6
+ export declare const cellIsEditable: (cell: HTMLDivElement) => boolean;
7
+ export declare const cellIsTextInput: (cell: HTMLDivElement) => boolean;
@@ -0,0 +1,7 @@
1
+ import { KeyboardEvent as ReactKeyboardEvent } from "react";
2
+ export interface CellEditingHookProps {
3
+ navigate: () => void;
4
+ }
5
+ export declare const useCellEditing: ({ navigate }: CellEditingHookProps) => {
6
+ onKeyDown: (e: ReactKeyboardEvent<HTMLElement>) => void;
7
+ };
@@ -1,10 +1,17 @@
1
- import { DataSource } from "@vuu-ui/vuu-data";
1
+ import { DataSource, DataSourceSubscribedMessage, VuuFeatureInvocationMessage, VuuFeatureMessage } from "@vuu-ui/vuu-data";
2
2
  import { DataSourceRow } from "@vuu-ui/vuu-data-types";
3
3
  import { VuuRange } from "@vuu-ui/vuu-protocol-types";
4
- export declare const useDataSource: ({ dataSource, initialRange, }: {
4
+ export interface DataSourceHookProps {
5
5
  dataSource: DataSource;
6
- initialRange: VuuRange;
7
- }) => {
6
+ onFeatureEnabled?: (message: VuuFeatureMessage) => void;
7
+ onFeatureInvocation?: (message: VuuFeatureInvocationMessage) => void;
8
+ onSizeChange: (size: number) => void;
9
+ onSubscribed: (subscription: DataSourceSubscribedMessage) => void;
10
+ range?: VuuRange;
11
+ renderBufferSize?: number;
12
+ }
13
+ export declare const useDataSource: ({ dataSource, onFeatureEnabled, onFeatureInvocation, onSizeChange, onSubscribed, range, renderBufferSize, }: DataSourceHookProps) => {
8
14
  data: DataSourceRow[];
15
+ range: VuuRange;
9
16
  setRange: (range: VuuRange) => void;
10
17
  };
@@ -0,0 +1,27 @@
1
+ import { VuuRange } from "@vuu-ui/vuu-protocol-types";
2
+ import { KeyboardEvent, MouseEvent, RefObject } from "react";
3
+ import { ScrollRequestHandler } from "./useTableScroll";
4
+ export declare const isNavigationKey: (key: string) => key is NavigationKey;
5
+ type ArrowKey = "ArrowUp" | "ArrowDown" | "ArrowLeft" | "ArrowRight";
6
+ type PageKey = "Home" | "End" | "PageUp" | "PageDown";
7
+ type NavigationKey = PageKey | ArrowKey;
8
+ export declare const isPagingKey: (key: string) => key is PageKey;
9
+ export interface NavigationHookProps {
10
+ containerRef: RefObject<HTMLElement>;
11
+ columnCount?: number;
12
+ disableHighlightOnFocus?: boolean;
13
+ label?: string;
14
+ viewportRange: VuuRange;
15
+ requestScroll?: ScrollRequestHandler;
16
+ restoreLastFocus?: boolean;
17
+ rowCount?: number;
18
+ selected?: unknown;
19
+ viewportRowCount: number;
20
+ }
21
+ export declare const useKeyboardNavigation: ({ columnCount, containerRef, disableHighlightOnFocus, requestScroll, rowCount, viewportRowCount, }: NavigationHookProps) => {
22
+ navigate: () => void;
23
+ onClick: (evt: MouseEvent) => void;
24
+ onFocus: () => void;
25
+ onKeyDown: (e: KeyboardEvent) => void;
26
+ };
27
+ export {};
@@ -0,0 +1,30 @@
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 type CssSize = {
21
+ height: string;
22
+ width: string;
23
+ };
24
+ export interface MeasuredContainerHookResult {
25
+ containerRef: RefObject<HTMLDivElement>;
26
+ cssSize: CssSize;
27
+ outerSize: Size;
28
+ innerSize?: MeasuredSize;
29
+ }
30
+ export declare const useMeasuredContainer: ({ defaultHeight, defaultWidth, height, width, }: MeasuredProps) => MeasuredContainerHookResult;
@@ -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,8 @@
1
+ import { DataSourceRow } from "@vuu-ui/vuu-data-types";
2
+ import { KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
3
+ import { MouseEvent } from "react";
4
+ export interface TableContextMenuHookProps {
5
+ columns: KeyedColumnDescriptor[];
6
+ data: DataSourceRow[];
7
+ }
8
+ export declare const useTableContextMenu: ({ columns, data, }: TableContextMenuHookProps) => (evt: MouseEvent<HTMLElement>) => void;
@@ -1,9 +1,24 @@
1
- import { ColumnDescriptor, GridConfig, KeyedColumnDescriptor, PinLocation, TableConfig } from "@vuu-ui/vuu-datagrid-types";
2
- import { Reducer } from "react";
1
+ import { ColumnDescriptor, KeyedColumnDescriptor, PinLocation, TableAttributes, TableConfig, TableHeadings } from "@vuu-ui/vuu-datagrid-types";
3
2
  import { DataSourceConfig } from "@vuu-ui/vuu-data";
4
3
  import { TableSchema } from "@vuu-ui/vuu-data/src/message-utils";
5
- export interface TableModel extends Omit<GridConfig, "columns"> {
4
+ import { VuuTable } from "@vuu-ui/vuu-protocol-types";
5
+ import { Reducer } from "react";
6
+ /**
7
+ * TableModel represents state used internally to manage Table. It is
8
+ * derived initially from the TableConfig provided by user, along with the
9
+ * data-related config from DataSource.
10
+ */
11
+ export interface TableModel extends TableAttributes {
6
12
  columns: KeyedColumnDescriptor[];
13
+ headings: TableHeadings;
14
+ }
15
+ /**
16
+ * InternalTableModel describes the state managed within the TableModel
17
+ * reducer. It is the same as TableModel but with the addition of a
18
+ * readonly copy of the original TableConfig.
19
+ */
20
+ interface InternalTableModel extends TableModel {
21
+ tableConfig: Readonly<TableConfig>;
7
22
  }
8
23
  export interface ColumnActionInit {
9
24
  type: "init";
@@ -29,10 +44,11 @@ export interface ColumnActionPin {
29
44
  column: ColumnDescriptor;
30
45
  pin?: PinLocation;
31
46
  }
47
+ export type ResizePhase = "begin" | "resize" | "end";
32
48
  export interface ColumnActionResize {
33
49
  type: "resizeColumn";
34
50
  column: KeyedColumnDescriptor;
35
- phase: "begin" | "resize" | "end";
51
+ phase: ResizePhase;
36
52
  width?: number;
37
53
  }
38
54
  export interface ColumnActionSetTableSchema {
@@ -58,7 +74,9 @@ export interface ColumnActionTableConfig extends DataSourceConfig {
58
74
  }
59
75
  export interface ColumnActionColumnSettings extends DataSourceConfig {
60
76
  type: "columnSettings";
61
- column: KeyedColumnDescriptor;
77
+ column: ColumnDescriptor;
78
+ /** required only for calculated coplumns */
79
+ vuuTable?: VuuTable;
62
80
  }
63
81
  export interface ColumnActionTableSettings extends DataSourceConfig {
64
82
  type: "tableSettings";
@@ -70,10 +88,19 @@ export declare const isShowTableSettings: (action: PersistentColumnAction) => ac
70
88
  */
71
89
  export type PersistentColumnAction = ColumnActionPin | ColumnActionHide | ColumnActionColumnSettings | ColumnActionTableSettings;
72
90
  export type GridModelAction = ColumnActionHide | ColumnActionInit | ColumnActionMove | ColumnActionPin | ColumnActionResize | ColumnActionSetTableSchema | ColumnActionShow | ColumnActionUpdate | ColumnActionUpdateProp | ColumnActionTableConfig;
73
- export type GridModelReducer = Reducer<TableModel, GridModelAction>;
91
+ export type GridModelReducer = Reducer<InternalTableModel, GridModelAction>;
74
92
  export type ColumnActionDispatch = (action: GridModelAction) => void;
75
- export declare const useTableModel: (tableConfig: TableConfig, dataSourceConfig?: DataSourceConfig) => {
93
+ export declare const useTableModel: (tableConfigProp: TableConfig, dataSourceConfig?: DataSourceConfig) => {
76
94
  columns: KeyedColumnDescriptor[];
77
95
  dispatchColumnAction: import("react").Dispatch<GridModelAction>;
78
- headings: import("@vuu-ui/vuu-datagrid-types").TableHeadings;
96
+ headings: TableHeadings;
97
+ tableAttributes: {
98
+ columnDefaultWidth?: number | undefined;
99
+ columnFormatHeader?: "capitalize" | "uppercase" | undefined;
100
+ columnSeparators?: boolean | undefined;
101
+ rowSeparators?: boolean | undefined;
102
+ zebraStripes?: boolean | undefined;
103
+ };
104
+ tableConfig: Readonly<TableConfig>;
79
105
  };
106
+ export {};
@@ -1,40 +1,44 @@
1
- import { DataSource, VuuFeatureInvocationMessage, VuuFeatureMessage } from "@vuu-ui/vuu-data";
2
- import { GridConfig, KeyedColumnDescriptor, SelectionChangeHandler, TableConfig, TableSelectionModel } from "@vuu-ui/vuu-datagrid-types";
3
- import { MouseEvent } from "react";
4
- import { MeasuredProps } from "../table";
1
+ import { DataSourceRow } from "@vuu-ui/vuu-data-types";
2
+ import { DataCellEditHandler, KeyedColumnDescriptor, TableSelectionModel } from "@vuu-ui/vuu-datagrid-types";
3
+ import { MeasuredSize } from "@vuu-ui/vuu-layout";
4
+ import { KeyboardEvent, MouseEvent, RefObject } from "react";
5
+ import { MeasuredProps, RowClickHandler, TableProps } from "../table";
5
6
  import { TableColumnResizeHandler } from "./column-resizing";
6
- export interface TableHookProps extends MeasuredProps {
7
- config: Omit<GridConfig, "headings">;
8
- dataSource: DataSource;
7
+ export interface TableHookProps extends MeasuredProps, Pick<TableProps, "availableColumns" | "config" | "dataSource" | "onAvailableColumnsChange" | "onConfigChange" | "onFeatureEnabled" | "onFeatureInvocation" | "onSelectionChange" | "onRowClick" | "renderBufferSize"> {
8
+ containerRef: RefObject<HTMLDivElement>;
9
9
  headerHeight: number;
10
- onConfigChange?: (config: TableConfig) => void;
11
- onFeatureEnabled?: (message: VuuFeatureMessage) => void;
12
- onFeatureInvocation?: (message: VuuFeatureInvocationMessage) => void;
13
- renderBufferSize?: number;
14
10
  rowHeight: number;
15
- onSelectionChange?: SelectionChangeHandler;
16
11
  selectionModel: TableSelectionModel;
17
12
  }
18
- export declare const useTable: ({ config, dataSource, headerHeight, onConfigChange, onFeatureEnabled, onFeatureInvocation, onSelectionChange, rowHeight, selectionModel, ...measuredProps }: TableHookProps) => {
13
+ export declare const useTable: ({ availableColumns, config, containerRef, dataSource, headerHeight, onAvailableColumnsChange, onConfigChange, onFeatureEnabled, onFeatureInvocation, onRowClick: onRowClickProp, onSelectionChange, renderBufferSize, rowHeight, selectionModel, }: TableHookProps) => {
14
+ onKeyDown: (e: KeyboardEvent<HTMLElement>) => void;
19
15
  columnMap: import("@vuu-ui/vuu-utils").ColumnMap;
20
16
  columns: KeyedColumnDescriptor[];
21
- containerRef: import("react").RefObject<HTMLDivElement>;
22
- containerMeasurements: {
23
- cssSize: import("../table").CssSize;
24
- outerSize: import("../table").Size;
25
- innerSize?: import("../table").MeasuredSize | undefined;
17
+ data: DataSourceRow[];
18
+ handleContextMenuAction: import("@vuu-ui/vuu-data-types").MenuActionHandler;
19
+ headerProps: {
20
+ onClick: (evt: MouseEvent) => void;
21
+ onMouseDown: import("react").MouseEventHandler<Element> | undefined;
22
+ onResize: TableColumnResizeHandler;
26
23
  };
27
- data: import("packages/vuu-data-types").DataSourceRow[];
28
- handleContextMenuAction: import("packages/vuu-data-types").MenuActionHandler;
29
- menuBuilder: import("packages/vuu-data-types").MenuBuilder<string, unknown>;
30
- onContextMenu: (evt: MouseEvent<HTMLElement>) => void;
31
- onHeaderClick: (evt: MouseEvent) => void;
32
- onHeaderResize: TableColumnResizeHandler;
33
- onRowClick: import("../table").RowClickHandler;
24
+ menuBuilder: import("@vuu-ui/vuu-data-types").MenuBuilder<string, unknown>;
25
+ onContextMenu: (evt: MouseEvent<HTMLElement, globalThis.MouseEvent>) => void;
26
+ onDataEdited: DataCellEditHandler;
27
+ onRemoveGroupColumn: (column: KeyedColumnDescriptor) => void;
28
+ onResize: (size: MeasuredSize) => void;
29
+ onRowClick: RowClickHandler;
30
+ onToggleGroup: (row: DataSourceRow, column: KeyedColumnDescriptor) => void;
34
31
  scrollProps: {
35
32
  scrollbarContainerRef: (el: HTMLDivElement | null) => void;
36
33
  contentContainerRef: (el: HTMLDivElement | null) => void;
37
34
  };
35
+ tableAttributes: {
36
+ columnDefaultWidth?: number | undefined;
37
+ columnFormatHeader?: "capitalize" | "uppercase" | undefined;
38
+ columnSeparators?: boolean | undefined;
39
+ rowSeparators?: boolean | undefined;
40
+ zebraStripes?: boolean | undefined;
41
+ };
38
42
  viewportMeasurements: {
39
43
  contentHeight: number;
40
44
  horizontalScrollbarHeight: number;
@@ -48,4 +52,14 @@ export declare const useTable: ({ config, dataSource, headerHeight, onConfigChan
48
52
  verticalScrollbarWidth: number;
49
53
  viewportBodyHeight: number;
50
54
  };
55
+ dragDropHook: {
56
+ draggable?: JSX.Element | undefined;
57
+ dropIndicator?: JSX.Element | undefined;
58
+ draggedItemIndex?: number | undefined;
59
+ isDragging: boolean;
60
+ isScrolling: RefObject<boolean>;
61
+ revealOverflowedItems: boolean;
62
+ };
63
+ onClick: (evt: MouseEvent<Element, globalThis.MouseEvent>) => void;
64
+ onFocus: () => void;
51
65
  };