Better table implementation (#11781)

* wip

* wip

* weird splitview scrolling stuff

* working table

* remove spliceable table

* handling resizing columns

* get perf table integrated into grid

* make more improvments to table view

* testing

* wip

* wip

* fix async data window; add more optimization to scrolling

* work on scrolling

* fix column resizing

* start working on table widget

* inital work to get table widget working with styles and mouse controls

* fix unrendering selection; fix sizes of cells

* support high perf table option; remove unused files; add cell borders to high perf

* add accessibility tags

* handle borders and row count

* more styling changfes

* fix strict null checks

* adding inital keyboard navigation

* center row count; add padding left to rows

* inital drag selection

* remove drag implementation; it can be done better utilizing the global mouse monitor object

* range logic

* create custom grid range

* work with new range

* remove unused code

* fix how plus range works

* add drag selection; change focus to set selection; fix problem with creating a range with inverse start and end

* code cleanup

* fix strict-null-checks

* fix up perf table

* fix layering

* inital table service

* finish table service

* fix some compile errors

* fix compile

* fix compile

* fix up for use

* fix layering

* remove console use

* fix strict nulls
This commit is contained in:
Anthony Dresser
2020-08-18 12:10:05 -07:00
committed by GitHub
parent 17856855f6
commit c4b524237c
47 changed files with 3276 additions and 753 deletions

View File

@@ -0,0 +1,96 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IGridRange } from 'sql/base/common/gridRange';
import { IGridPosition } from 'sql/base/common/gridPosition';
export interface ITableRenderer<T, TTemplateData> {
renderTemplate(container: HTMLElement): TTemplateData;
renderCell(element: T, index: number, cell: number, columnId: string, templateData: TTemplateData, width: number | undefined): void;
disposeCell?(element: T, index: number, cell: number, olumnId: string, templateData: TTemplateData, width: number | undefined): void;
disposeTemplate(templateData: TTemplateData): void;
}
export interface IStaticTableRenderer<T, TTemplateData> extends ITableRenderer<T, TTemplateData> {
renderCell(element: T | undefined, index: number, cell: number, columnId: string, templateData: TTemplateData, width: number | undefined): void;
disposeCell?(element: T | undefined, index: number, cell: number, columnId: string, templateData: TTemplateData, width: number | undefined): void;
}
export class TableError extends Error {
constructor(user: string, message: string) {
super(`TableError [${user}] ${message}`);
}
}
export interface ITableDataSource<T> {
getRow(index: number): Promise<T>;
}
export interface ITableEvent<T> {
elements: T[];
indexes: IGridRange[];
browserEvent?: UIEvent;
}
export interface ITableMouseEvent<T> {
browserEvent: MouseEvent;
buttons: number;
element: T | undefined;
index: IGridPosition | undefined;
}
export interface ITableContextMenuEvent<T> {
browserEvent: UIEvent;
element: T | undefined;
index: IGridPosition | undefined;
anchor: HTMLElement | { x: number; y: number; };
}
export interface ITableDragEvent {
start: IGridPosition;
current: IGridPosition;
}
export interface ITableColumn<T, TTemplateData> {
/**
* Renderer associated with this column
*/
renderer: ITableRenderer<T, TTemplateData> | IStaticTableRenderer<T, TTemplateData>;
/**
* Initial width of this column
*/
width?: number;
/**
* Minimum allowed width of this column
*/
minWidth?: number;
/**
* Is this column resizable?
*/
resizeable?: boolean;
/**
* This string will be added to the cell as a class
* Useful for styling specific columns
*/
cellClass?: string;
/**
* Specifies this column doesn't need data to render
* Useful when you don't need to wait for data you render a column
*/
static?: boolean;
id: string;
/**
* Name to display in the column header
*/
name: string;
}
export interface IStaticColumn<T, TTemplateData> extends ITableColumn<T, TTemplateData> {
/**
* Renderer associated with this column
*/
renderer: IStaticTableRenderer<T, TTemplateData>;
}