@perspective-dev/viewer-datagrid 4.0.1 → 4.1.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/dist/cdn/perspective-viewer-datagrid.js +4 -17
- package/dist/cdn/perspective-viewer-datagrid.js.map +4 -4
- package/dist/css/perspective-viewer-datagrid.css +1 -1
- package/dist/esm/color_utils.d.ts +9 -0
- package/dist/esm/custom_elements/datagrid.d.ts +52 -0
- package/dist/esm/custom_elements/toolbar.d.ts +10 -0
- package/dist/esm/data_listener/format_cell.d.ts +8 -0
- package/dist/esm/data_listener/format_tree_header.d.ts +13 -0
- package/dist/esm/data_listener/formatter_cache.d.ts +16 -0
- package/dist/esm/data_listener/index.d.ts +10 -0
- package/dist/esm/event_handlers/click/edit_click.d.ts +3 -0
- package/dist/esm/event_handlers/click.d.ts +7 -0
- package/dist/esm/event_handlers/deselect_all.d.ts +5 -0
- package/dist/esm/event_handlers/dispatch_click.d.ts +3 -0
- package/dist/esm/event_handlers/expand_collapse.d.ts +2 -0
- package/dist/esm/event_handlers/focus.d.ts +5 -0
- package/dist/esm/event_handlers/header_click.d.ts +3 -0
- package/dist/esm/event_handlers/keydown/edit_keydown.d.ts +4 -0
- package/dist/esm/event_handlers/row_select_click.d.ts +4 -0
- package/dist/esm/event_handlers/select_region.d.ts +9 -0
- package/dist/esm/event_handlers/sort.d.ts +7 -0
- package/dist/esm/get_cell_config.d.ts +8 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/model/column_overrides.d.ts +23 -0
- package/dist/esm/model/create.d.ts +3 -0
- package/dist/esm/model/index.d.ts +4 -0
- package/dist/esm/model/toolbar.d.ts +4 -0
- package/dist/esm/perspective-viewer-datagrid.js +3 -3
- package/dist/esm/perspective-viewer-datagrid.js.map +4 -4
- package/dist/esm/plugin/activate.d.ts +6 -0
- package/dist/esm/plugin/column_style_controls.d.ts +28 -0
- package/dist/esm/plugin/draw.d.ts +7 -0
- package/dist/esm/plugin/restore.d.ts +10 -0
- package/dist/esm/plugin/save.d.ts +2 -0
- package/dist/esm/style_handlers/body.d.ts +7 -0
- package/dist/esm/style_handlers/column_header.d.ts +13 -0
- package/dist/esm/style_handlers/consolidated.d.ts +57 -0
- package/dist/esm/style_handlers/editable.d.ts +7 -0
- package/dist/esm/style_handlers/focus.d.ts +16 -0
- package/dist/esm/style_handlers/group_header.d.ts +7 -0
- package/dist/esm/style_handlers/table_cell/boolean.d.ts +7 -0
- package/dist/esm/style_handlers/table_cell/cell_flash.d.ts +3 -0
- package/dist/esm/style_handlers/table_cell/datetime.d.ts +7 -0
- package/dist/esm/style_handlers/table_cell/numeric.d.ts +15 -0
- package/dist/esm/style_handlers/table_cell/row_header.d.ts +4 -0
- package/dist/esm/style_handlers/table_cell/string.d.ts +11 -0
- package/dist/esm/style_handlers/types.d.ts +20 -0
- package/dist/esm/types.d.ts +193 -0
- package/package.json +10 -5
- package/src/less/mitered-headers.less +65 -0
- package/src/less/pro.less +196 -0
- package/src/less/regular_table.less +509 -0
- package/src/less/row-hover.less +88 -0
- package/{index.d.ts → src/less/scrollbar.less} +18 -19
- package/src/less/sub-cell-scroll.less +82 -0
- package/src/less/toolbar.less +201 -0
- package/src/ts/color_utils.ts +70 -0
- package/src/ts/custom_elements/datagrid.ts +250 -0
- package/src/ts/custom_elements/toolbar.ts +75 -0
- package/src/ts/data_listener/format_cell.ts +84 -0
- package/src/ts/data_listener/format_tree_header.ts +82 -0
- package/src/ts/data_listener/formatter_cache.ts +191 -0
- package/src/ts/data_listener/index.ts +242 -0
- package/src/ts/event_handlers/click/edit_click.ts +73 -0
- package/src/ts/event_handlers/click.ts +92 -0
- package/src/ts/event_handlers/deselect_all.ts +28 -0
- package/src/ts/event_handlers/dispatch_click.ts +44 -0
- package/src/ts/event_handlers/expand_collapse.ts +44 -0
- package/src/ts/event_handlers/focus.ts +63 -0
- package/src/ts/event_handlers/header_click.ts +85 -0
- package/src/ts/event_handlers/keydown/edit_keydown.ts +213 -0
- package/src/ts/event_handlers/row_select_click.ts +87 -0
- package/src/ts/event_handlers/select_region.ts +427 -0
- package/src/ts/event_handlers/sort.ts +118 -0
- package/src/ts/get_cell_config.ts +68 -0
- package/src/ts/index.ts +49 -0
- package/src/ts/model/column_overrides.ts +112 -0
- package/src/ts/model/create.ts +247 -0
- package/src/ts/model/index.ts +19 -0
- package/src/ts/model/toolbar.ts +64 -0
- package/src/ts/plugin/activate.ts +235 -0
- package/src/ts/plugin/column_style_controls.ts +76 -0
- package/src/ts/plugin/draw.ts +69 -0
- package/src/ts/plugin/restore.ts +110 -0
- package/src/ts/plugin/save.ts +45 -0
- package/src/ts/style_handlers/body.ts +228 -0
- package/src/ts/style_handlers/column_header.ts +183 -0
- package/src/ts/style_handlers/consolidated.ts +223 -0
- package/src/ts/style_handlers/editable.ts +94 -0
- package/src/ts/style_handlers/focus.ts +106 -0
- package/src/ts/style_handlers/group_header.ts +78 -0
- package/src/ts/style_handlers/table_cell/boolean.ts +39 -0
- package/src/ts/style_handlers/table_cell/cell_flash.ts +75 -0
- package/src/ts/style_handlers/table_cell/datetime.ts +64 -0
- package/src/ts/style_handlers/table_cell/numeric.ts +186 -0
- package/src/ts/style_handlers/table_cell/row_header.ts +53 -0
- package/src/ts/style_handlers/table_cell/string.ts +102 -0
- package/src/ts/style_handlers/types.ts +41 -0
- package/src/ts/types.ts +279 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { View } from "@perspective-dev/client";
|
|
2
|
+
import type { DatagridPluginElement } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Lazy initialize this plugin with various listeners.
|
|
5
|
+
*/
|
|
6
|
+
export declare function activate(this: DatagridPluginElement, view: View): Promise<void>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ColumnType } from "@perspective-dev/client";
|
|
2
|
+
import type { DatagridPluginElement } from "../types.js";
|
|
3
|
+
interface NumberStyleOpts {
|
|
4
|
+
datagrid_number_style: {
|
|
5
|
+
fg_gradient: number;
|
|
6
|
+
pos_fg_color: string;
|
|
7
|
+
neg_fg_color: string;
|
|
8
|
+
number_fg_mode: string;
|
|
9
|
+
bg_gradient: number;
|
|
10
|
+
pos_bg_color: string;
|
|
11
|
+
neg_bg_color: string;
|
|
12
|
+
number_bg_mode: string;
|
|
13
|
+
};
|
|
14
|
+
number_string_format: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface DatetimeStyleOpts {
|
|
17
|
+
datagrid_datetime_style?: {
|
|
18
|
+
color: string;
|
|
19
|
+
bg_color: string;
|
|
20
|
+
};
|
|
21
|
+
datagrid_string_style?: {
|
|
22
|
+
color: string;
|
|
23
|
+
bg_color: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export type ColumnStyleOpts = NumberStyleOpts | DatetimeStyleOpts | null;
|
|
27
|
+
export default function column_style_opts(this: DatagridPluginElement, type: ColumnType, _group: string): ColumnStyleOpts;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { View } from "@perspective-dev/client";
|
|
2
|
+
import type { DatagridPluginElement } from "../types.js";
|
|
3
|
+
interface DatagridPluginWithActivate extends DatagridPluginElement {
|
|
4
|
+
activate(view: View): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export declare function draw(this: DatagridPluginWithActivate, view: View): Promise<void>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DatagridPluginElement, EditMode, ColumnsConfig } from "../types.js";
|
|
2
|
+
interface RestoreToken {
|
|
3
|
+
columns?: Record<string, {
|
|
4
|
+
column_size_override?: number;
|
|
5
|
+
}>;
|
|
6
|
+
edit_mode?: EditMode;
|
|
7
|
+
scroll_lock?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function restore(this: DatagridPluginElement, token: RestoreToken, columns: ColumnsConfig): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RegularTableElement } from "regular-table";
|
|
2
|
+
import type { DatagridModel, PerspectiveViewerElement, ColumnsConfig } from "../types.js";
|
|
3
|
+
import { CollectedCell, LocalSelectedPositionMap, LocalSelectedRowsMap } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Apply styles to all body cells in a single pass.
|
|
6
|
+
*/
|
|
7
|
+
export declare function applyBodyCellStyles(this: DatagridModel, cells: CollectedCell[], plugins: ColumnsConfig, isSettingsOpen: boolean, isSelectable: boolean, isEditable: boolean, regularTable: RegularTableElement, selectedRowsMap: LocalSelectedRowsMap, selectedPositionMap: LocalSelectedPositionMap, viewer: PerspectiveViewerElement): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RegularTableElement } from "regular-table";
|
|
2
|
+
import type { DatagridModel, PerspectiveViewerElement } from "../types.js";
|
|
3
|
+
import { CollectedHeaderRow } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Apply selected column styling in response to column settings toggle events.
|
|
6
|
+
* This is called directly (not as a style listener) when the user opens/closes
|
|
7
|
+
* the column settings panel.
|
|
8
|
+
*/
|
|
9
|
+
export declare function style_selected_column(this: DatagridModel, regularTable: RegularTableElement, viewer: PerspectiveViewerElement, selectedColumn: string | undefined): void;
|
|
10
|
+
/**
|
|
11
|
+
* Style a single column header row.
|
|
12
|
+
*/
|
|
13
|
+
export declare function styleColumnHeaderRow(this: DatagridModel, headerRow: CollectedHeaderRow, regularTable: RegularTableElement, is_menu_row: boolean): void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { RegularTableElement } from "regular-table";
|
|
2
|
+
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
3
|
+
import type { DatagridModel, PerspectiveViewerElement, ColumnsConfig, DatagridPluginElement, SelectedPosition } from "../types.js";
|
|
4
|
+
interface CellMetaExtended extends CellMetadata {
|
|
5
|
+
_is_hidden_by_aggregate_depth?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface CollectedCell {
|
|
8
|
+
element: HTMLElement;
|
|
9
|
+
metadata: CellMetaExtended;
|
|
10
|
+
isHeader: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface CollectedHeaderRow {
|
|
13
|
+
row: HTMLTableRowElement;
|
|
14
|
+
cells: Array<{
|
|
15
|
+
element: HTMLTableCellElement;
|
|
16
|
+
metadata: CellMetadata | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Context object passed through consolidated styling
|
|
21
|
+
*/
|
|
22
|
+
export interface StyleContext {
|
|
23
|
+
model: DatagridModel;
|
|
24
|
+
regularTable: RegularTableElement;
|
|
25
|
+
viewer: PerspectiveViewerElement;
|
|
26
|
+
datagrid: DatagridPluginElement;
|
|
27
|
+
plugins: ColumnsConfig;
|
|
28
|
+
isSettingsOpen: boolean;
|
|
29
|
+
isSelectable: boolean;
|
|
30
|
+
isEditable: boolean;
|
|
31
|
+
selectedRowsMap: Map<RegularTableElement, unknown[]>;
|
|
32
|
+
selectedPositionMap: Map<RegularTableElement, SelectedPosition>;
|
|
33
|
+
}
|
|
34
|
+
type LocalSelectedRowsMap = WeakMap<RegularTableElement, unknown[]>;
|
|
35
|
+
type LocalSelectedPositionMap = WeakMap<RegularTableElement, SelectedPosition>;
|
|
36
|
+
/**
|
|
37
|
+
* Consolidated style listener that handles all cell styling in a single pass.
|
|
38
|
+
* This eliminates redundant DOM traversals and reduces layout thrashing by:
|
|
39
|
+
* 1. Collecting all cell metadata in a read phase
|
|
40
|
+
* 2. Applying all styles in a write phase
|
|
41
|
+
*/
|
|
42
|
+
export declare function createConsolidatedStyleListener(datagrid: DatagridPluginElement, selectedRowsMap: LocalSelectedRowsMap, selectedPositionMap: LocalSelectedPositionMap): (this: DatagridModel, regularTable: RegularTableElement, viewer: PerspectiveViewerElement) => void;
|
|
43
|
+
declare module "../types.js" {
|
|
44
|
+
interface DatagridModel {
|
|
45
|
+
_applyBodyCellStyles(cells: CollectedCell[], plugins: ColumnsConfig, isSettingsOpen: boolean, isSelectable: boolean, isEditable: boolean, regularTable: RegularTableElement, selectedRowsMap: LocalSelectedRowsMap, selectedPositionMap: LocalSelectedPositionMap, viewer: PerspectiveViewerElement): void;
|
|
46
|
+
_applyGroupHeaderStyles(headerRows: CollectedHeaderRow[], regularTable: RegularTableElement): void;
|
|
47
|
+
_applyColumnHeaderStyles(headerRows: CollectedHeaderRow[], regularTable: RegularTableElement, viewer: PerspectiveViewerElement): void;
|
|
48
|
+
_applyFocusStyle(cells: CollectedCell[], regularTable: RegularTableElement, selectedPositionMap: LocalSelectedPositionMap): void;
|
|
49
|
+
_styleColumnHeaderRow(headerRow: CollectedHeaderRow, regularTable: RegularTableElement, is_menu_row: boolean): void;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Install the styling methods on the DatagridModel prototype.
|
|
54
|
+
* This should be called once during module initialization.
|
|
55
|
+
*/
|
|
56
|
+
export declare function installConsolidatedStyleMethods(modelPrototype: any): void;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RegularTableElement } from "regular-table";
|
|
2
|
+
import type { DatagridModel, PerspectiveViewerElement } from "../types.js";
|
|
3
|
+
import { CollectedHeaderRow } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Apply styles to column header rows.
|
|
6
|
+
*/
|
|
7
|
+
export declare function applyColumnHeaderStyles(this: DatagridModel, headerRows: CollectedHeaderRow[], regularTable: RegularTableElement, viewer: PerspectiveViewerElement): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RegularTableElement } from "regular-table";
|
|
2
|
+
import type { DatagridModel, SelectedPosition } from "../types.js";
|
|
3
|
+
import { CollectedCell, LocalSelectedPositionMap } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Apply focus style to the selected cell.
|
|
6
|
+
* Optimized to use collected cells instead of querySelectorAll.
|
|
7
|
+
*/
|
|
8
|
+
export declare function applyFocusStyle(this: DatagridModel, cells: CollectedCell[], regularTable: RegularTableElement, selectedPositionMap: LocalSelectedPositionMap): void;
|
|
9
|
+
/**
|
|
10
|
+
* Standalone function to focus the selected cell.
|
|
11
|
+
* This collects cells from the table and tries to focus the selected position.
|
|
12
|
+
* Returns true if focus was successful, false otherwise.
|
|
13
|
+
*
|
|
14
|
+
* Used by edit_keydown.ts for keyboard navigation.
|
|
15
|
+
*/
|
|
16
|
+
export declare function focusSelectedCell(regularTable: RegularTableElement, selectedPositionMap: Map<RegularTableElement, SelectedPosition>): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RegularTableElement } from "regular-table";
|
|
2
|
+
import type { DatagridModel } from "../types.js";
|
|
3
|
+
import { CollectedHeaderRow } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Apply styles to group header rows.
|
|
6
|
+
*/
|
|
7
|
+
export declare function applyGroupHeaderStyles(this: DatagridModel, headerRows: CollectedHeaderRow[], regularTable: RegularTableElement): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
2
|
+
import type { DatagridModel, ColumnConfig } from "../../types.js";
|
|
3
|
+
interface CellMetaWithFlags extends CellMetadata {
|
|
4
|
+
_is_hidden_by_aggregate_depth?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function cell_style_boolean(this: DatagridModel, _plugin: ColumnConfig | undefined, td: HTMLElement, metadata: CellMetaWithFlags): void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
2
|
+
import type { DatagridModel, ColorRecord } from "../../types.js";
|
|
3
|
+
export declare function style_cell_flash(this: DatagridModel, metadata: CellMetadata, td: HTMLElement, [, , , , , pos_s, pos_e]: ColorRecord, [, , , , , neg_s, neg_e]: ColorRecord, is_settings_open: boolean): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
2
|
+
import type { DatagridModel, ColumnConfig } from "../../types.js";
|
|
3
|
+
interface CellMetaWithFlags extends CellMetadata {
|
|
4
|
+
_is_hidden_by_aggregate_depth?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function cell_style_datetime(this: DatagridModel, plugin: ColumnConfig, td: HTMLElement, metadata: CellMetaWithFlags): void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DatagridModel, ColumnConfig, ColorRecord } from "../../types.js";
|
|
2
|
+
interface CellMetaWithExtras {
|
|
3
|
+
_is_hidden_by_aggregate_depth?: boolean;
|
|
4
|
+
user?: number;
|
|
5
|
+
dy: number;
|
|
6
|
+
column_header?: string[];
|
|
7
|
+
}
|
|
8
|
+
interface PluginWithColors extends Omit<ColumnConfig, "pos_fg_color" | "neg_fg_color" | "pos_bg_color" | "neg_bg_color"> {
|
|
9
|
+
pos_bg_color?: ColorRecord;
|
|
10
|
+
neg_bg_color?: ColorRecord;
|
|
11
|
+
pos_fg_color?: ColorRecord;
|
|
12
|
+
neg_fg_color?: ColorRecord;
|
|
13
|
+
}
|
|
14
|
+
export declare function cell_style_numeric(this: DatagridModel, plugin: PluginWithColors | undefined, td: HTMLElement, metadata: CellMetaWithExtras, is_settings_open: boolean): void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
2
|
+
import type { DatagridModel } from "../../types.js";
|
|
3
|
+
import { RegularTableElement } from "regular-table";
|
|
4
|
+
export declare function cell_style_row_header(this: DatagridModel, regularTable: RegularTableElement, td: HTMLElement, metadata: CellMetadata): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DatagridModel, ColumnConfig, ColorRecord } from "../../types.js";
|
|
2
|
+
interface CellMetaWithExtras {
|
|
3
|
+
_is_hidden_by_aggregate_depth?: boolean;
|
|
4
|
+
user?: string | null;
|
|
5
|
+
column_header?: string[];
|
|
6
|
+
}
|
|
7
|
+
interface PluginWithColor extends Omit<ColumnConfig, "color"> {
|
|
8
|
+
color?: ColorRecord;
|
|
9
|
+
}
|
|
10
|
+
export declare function cell_style_string(this: DatagridModel, plugin: PluginWithColor | undefined, td: HTMLElement, metadata: CellMetaWithExtras): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RegularTableElement } from "regular-table";
|
|
2
|
+
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
3
|
+
import type { SelectedPosition } from "../types.js";
|
|
4
|
+
export interface CellMetaExtended extends CellMetadata {
|
|
5
|
+
_is_hidden_by_aggregate_depth?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface CollectedCell {
|
|
8
|
+
element: HTMLElement;
|
|
9
|
+
metadata: CellMetaExtended;
|
|
10
|
+
isHeader: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface CollectedHeaderRow {
|
|
13
|
+
row: HTMLTableRowElement;
|
|
14
|
+
cells: Array<{
|
|
15
|
+
element: HTMLTableCellElement;
|
|
16
|
+
metadata: CellMetadata | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
export type LocalSelectedRowsMap = WeakMap<RegularTableElement, unknown[]>;
|
|
20
|
+
export type LocalSelectedPositionMap = WeakMap<RegularTableElement, SelectedPosition>;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { View, Table, ViewConfig, ColumnType, SortDir, ViewWindow } from "@perspective-dev/client";
|
|
2
|
+
import { RegularTableElement } from "regular-table";
|
|
3
|
+
import { CellMetadata, DataResponse } from "regular-table/dist/esm/types";
|
|
4
|
+
export type { RegularTableElement as RegularTable };
|
|
5
|
+
export type { CellMetadata as CellMeta };
|
|
6
|
+
export type EditMode = "READ_ONLY" | "EDIT" | "SELECT_COLUMN" | "SELECT_ROW" | "SELECT_REGION";
|
|
7
|
+
export type ColorRecord = [
|
|
8
|
+
string,
|
|
9
|
+
number,
|
|
10
|
+
number,
|
|
11
|
+
number,
|
|
12
|
+
string,
|
|
13
|
+
string,
|
|
14
|
+
string
|
|
15
|
+
];
|
|
16
|
+
export type SortTerm = [string, SortDir];
|
|
17
|
+
export interface SelectionArea {
|
|
18
|
+
x0: number;
|
|
19
|
+
x1: number;
|
|
20
|
+
y0: number;
|
|
21
|
+
y1: number;
|
|
22
|
+
}
|
|
23
|
+
export interface SelectionState {
|
|
24
|
+
selected_areas: SelectionArea[];
|
|
25
|
+
dirty: boolean;
|
|
26
|
+
CURRENT_MOUSEDOWN_COORDINATES?: {
|
|
27
|
+
x?: number;
|
|
28
|
+
y?: number;
|
|
29
|
+
};
|
|
30
|
+
old_selected_areas?: SelectionArea[];
|
|
31
|
+
potential_selection?: SelectionArea;
|
|
32
|
+
}
|
|
33
|
+
export interface SelectedPosition {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
content?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ColumnConfig {
|
|
39
|
+
color?: string;
|
|
40
|
+
pos_fg_color?: string;
|
|
41
|
+
neg_fg_color?: string;
|
|
42
|
+
pos_bg_color?: string;
|
|
43
|
+
neg_bg_color?: string;
|
|
44
|
+
fg_gradient?: number;
|
|
45
|
+
bg_gradient?: number;
|
|
46
|
+
number_fg_mode?: string;
|
|
47
|
+
number_bg_mode?: string;
|
|
48
|
+
string_color_mode?: string;
|
|
49
|
+
datetime_color_mode?: string;
|
|
50
|
+
fixed?: number;
|
|
51
|
+
aggregate_depth?: number;
|
|
52
|
+
column_size_override?: number;
|
|
53
|
+
format?: string;
|
|
54
|
+
date_format?: DateFormatConfig;
|
|
55
|
+
number_format?: NumberFormatConfig;
|
|
56
|
+
}
|
|
57
|
+
export interface DateFormatConfig {
|
|
58
|
+
format?: "custom" | string;
|
|
59
|
+
timeZone?: string;
|
|
60
|
+
dateStyle?: "short" | "medium" | "long" | "full" | "disabled";
|
|
61
|
+
timeStyle?: "short" | "medium" | "long" | "full" | "disabled";
|
|
62
|
+
second?: "numeric" | "2-digit" | "disabled";
|
|
63
|
+
minute?: "numeric" | "2-digit" | "disabled";
|
|
64
|
+
hour?: "numeric" | "2-digit" | "disabled";
|
|
65
|
+
day?: "numeric" | "2-digit" | "disabled";
|
|
66
|
+
weekday?: "narrow" | "short" | "long" | "disabled";
|
|
67
|
+
month?: "numeric" | "2-digit" | "narrow" | "short" | "long" | "disabled";
|
|
68
|
+
year?: "numeric" | "2-digit" | "disabled";
|
|
69
|
+
hour12?: boolean;
|
|
70
|
+
fractionalSecondDigits?: 1 | 2 | 3;
|
|
71
|
+
}
|
|
72
|
+
export interface NumberFormatConfig {
|
|
73
|
+
style?: "decimal" | "currency" | "percent" | "unit";
|
|
74
|
+
minimumFractionDigits?: number;
|
|
75
|
+
maximumFractionDigits?: number;
|
|
76
|
+
minimumIntegerDigits?: number;
|
|
77
|
+
minimumSignificantDigits?: number;
|
|
78
|
+
maximumSignificantDigits?: number;
|
|
79
|
+
currency?: string;
|
|
80
|
+
currencyDisplay?: "code" | "symbol" | "narrowSymbol" | "name";
|
|
81
|
+
notation?: "standard" | "scientific" | "engineering" | "compact";
|
|
82
|
+
compactDisplay?: "short" | "long";
|
|
83
|
+
useGrouping?: boolean;
|
|
84
|
+
}
|
|
85
|
+
export type ColumnsConfig = Record<string, ColumnConfig>;
|
|
86
|
+
export interface DatagridPluginConfig {
|
|
87
|
+
columns?: ColumnsConfig;
|
|
88
|
+
editable?: boolean;
|
|
89
|
+
scroll_lock?: boolean;
|
|
90
|
+
edit_mode?: EditMode;
|
|
91
|
+
column_size_override?: Record<string, number>;
|
|
92
|
+
}
|
|
93
|
+
export interface ElemFactory {
|
|
94
|
+
clear(): void;
|
|
95
|
+
get(): HTMLElement;
|
|
96
|
+
}
|
|
97
|
+
export type Schema = Record<string, ColumnType>;
|
|
98
|
+
export interface DatagridModel {
|
|
99
|
+
_edit_port: number;
|
|
100
|
+
_view: View;
|
|
101
|
+
_table: Table;
|
|
102
|
+
_table_schema: Schema;
|
|
103
|
+
_config: ViewConfig;
|
|
104
|
+
_num_rows: number;
|
|
105
|
+
_num_columns?: number;
|
|
106
|
+
_schema: Schema;
|
|
107
|
+
_ids: unknown[][];
|
|
108
|
+
_plugin_background: number[];
|
|
109
|
+
_color: ColorRecord;
|
|
110
|
+
_pos_fg_color: ColorRecord;
|
|
111
|
+
_neg_fg_color: ColorRecord;
|
|
112
|
+
_pos_bg_color: ColorRecord;
|
|
113
|
+
_neg_bg_color: ColorRecord;
|
|
114
|
+
_column_paths: string[];
|
|
115
|
+
_column_types: ColumnType[];
|
|
116
|
+
_is_editable: boolean[];
|
|
117
|
+
_edit_mode: EditMode;
|
|
118
|
+
_selection_state: SelectionState;
|
|
119
|
+
_row_header_types: ColumnType[];
|
|
120
|
+
_series_color_map: Map<string, Map<string, number>>;
|
|
121
|
+
_series_color_seed: Map<string, number>;
|
|
122
|
+
_div_factory: ElemFactory;
|
|
123
|
+
_last_window?: ViewWindow;
|
|
124
|
+
_is_old_viewport?: boolean;
|
|
125
|
+
_reverse_columns?: Map<string, number>;
|
|
126
|
+
_reverse_ids?: Map<string, number>;
|
|
127
|
+
last_column_paths?: string[];
|
|
128
|
+
last_meta?: unknown[][];
|
|
129
|
+
last_ids?: unknown[][];
|
|
130
|
+
last_reverse_ids?: Map<string, number>;
|
|
131
|
+
last_reverse_columns?: Map<string, number>;
|
|
132
|
+
get_psp_type(metadata: CellMetadata): ColumnType;
|
|
133
|
+
_column_settings_selected_column?: string;
|
|
134
|
+
}
|
|
135
|
+
export declare const PRIVATE_PLUGIN_SYMBOL: unique symbol;
|
|
136
|
+
export type DataListener = (regularTable: RegularTableElement, x0: number, y0: number, x1: number, y1: number) => Promise<DataResponse>;
|
|
137
|
+
export type StyleListener = () => void;
|
|
138
|
+
export interface PerspectiveViewerElement extends HTMLElement {
|
|
139
|
+
getView(): Promise<View>;
|
|
140
|
+
getTable(): Promise<Table>;
|
|
141
|
+
getEditPort(): Promise<number>;
|
|
142
|
+
restore(config: Partial<ViewConfig>): Promise<void>;
|
|
143
|
+
toggleColumnSettings(columnName?: string): Promise<void>;
|
|
144
|
+
hasAttribute(name: string): boolean;
|
|
145
|
+
setSelection(viewport?: ViewWindow): void;
|
|
146
|
+
dispatchEvent(event: Event): boolean;
|
|
147
|
+
children: HTMLCollectionOf<HTMLElement>;
|
|
148
|
+
}
|
|
149
|
+
export interface DatagridToolbarElement extends HTMLElement {
|
|
150
|
+
setEditButton(button: HTMLElement): void;
|
|
151
|
+
setScrollLockButton(button: HTMLElement): void;
|
|
152
|
+
}
|
|
153
|
+
export type ColumnOverrides = Record<string, number | undefined>;
|
|
154
|
+
export interface FormatterCacheEntry {
|
|
155
|
+
format(value: unknown): string;
|
|
156
|
+
}
|
|
157
|
+
export type FormatterCache = Map<string, FormatterCacheEntry>;
|
|
158
|
+
export interface CellConfigResult {
|
|
159
|
+
row: Record<string, unknown>;
|
|
160
|
+
column_names: string[];
|
|
161
|
+
config: Partial<ViewConfig>;
|
|
162
|
+
}
|
|
163
|
+
export interface PerspectiveClickDetail {
|
|
164
|
+
row: Record<string, unknown>;
|
|
165
|
+
column_names: string[];
|
|
166
|
+
config: Partial<ViewConfig>;
|
|
167
|
+
}
|
|
168
|
+
export interface PerspectiveSelectDetail {
|
|
169
|
+
selected: boolean;
|
|
170
|
+
row: Record<string, unknown>;
|
|
171
|
+
column_names?: string[];
|
|
172
|
+
config: Partial<ViewConfig>;
|
|
173
|
+
}
|
|
174
|
+
export interface HandledMouseEvent extends MouseEvent {
|
|
175
|
+
handled?: boolean;
|
|
176
|
+
}
|
|
177
|
+
export type SortRotationOrder = Record<string, SortDir | undefined>;
|
|
178
|
+
export interface DatagridPluginElement extends HTMLElement {
|
|
179
|
+
regular_table: RegularTableElement;
|
|
180
|
+
model?: DatagridModel;
|
|
181
|
+
_toolbar?: DatagridToolbarElement;
|
|
182
|
+
_edit_button?: HTMLElement;
|
|
183
|
+
_scroll_lock?: HTMLElement;
|
|
184
|
+
_is_scroll_lock: boolean;
|
|
185
|
+
_edit_mode: EditMode;
|
|
186
|
+
_initialized?: boolean;
|
|
187
|
+
_reset_scroll_top?: boolean;
|
|
188
|
+
_reset_scroll_left?: boolean;
|
|
189
|
+
_reset_select?: boolean;
|
|
190
|
+
_reset_column_size?: boolean;
|
|
191
|
+
}
|
|
192
|
+
export type SelectedRowsMap = WeakMap<RegularTableElement, Set<number>>;
|
|
193
|
+
export type SelectedPositionMap = WeakMap<RegularTableElement, SelectedPosition>;
|
package/package.json
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perspective-dev/viewer-datagrid",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "Perspective datagrid plugin based on `regular-table`",
|
|
5
5
|
"unpkg": "dist/cdn/perspective-viewer-datagrid.js",
|
|
6
6
|
"jsdelivr": "dist/cdn/perspective-viewer-datagrid.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"types": "./index.d.ts",
|
|
9
|
+
"types": "./dist/esm/index.d.ts",
|
|
10
10
|
"default": "./dist/esm/perspective-viewer-datagrid.js"
|
|
11
11
|
},
|
|
12
12
|
"./dist/*": "./dist/*",
|
|
13
|
+
"./src/*": "./src/*",
|
|
13
14
|
"./package.json": "./package.json"
|
|
14
15
|
},
|
|
15
16
|
"type": "module",
|
|
17
|
+
"types": "dist/esm/index.d.ts",
|
|
16
18
|
"files": [
|
|
17
19
|
"dist/**/*",
|
|
18
|
-
"
|
|
20
|
+
"src/**/*"
|
|
19
21
|
],
|
|
20
22
|
"publishConfig": {
|
|
21
23
|
"access": "public"
|
|
@@ -30,13 +32,16 @@
|
|
|
30
32
|
"@perspective-dev/client": "",
|
|
31
33
|
"@perspective-dev/viewer": "",
|
|
32
34
|
"chroma-js": ">=3 <4",
|
|
33
|
-
"regular-table": "=0.
|
|
35
|
+
"regular-table": "=0.8.0"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
36
38
|
"@prospective.co/procss": "0.1.17",
|
|
37
39
|
"@perspective-dev/esbuild-plugin": "",
|
|
38
40
|
"@perspective-dev/test": "",
|
|
39
|
-
"
|
|
41
|
+
"@types/chroma-js": "^3.1.2",
|
|
42
|
+
"prettier": ">=3 <4",
|
|
43
|
+
"typescript": ">=5 <6",
|
|
44
|
+
"zx": ">=8 <9"
|
|
40
45
|
},
|
|
41
46
|
"scripts": {
|
|
42
47
|
"build": "node ./build.mjs",
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
2
|
+
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
|
3
|
+
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
|
4
|
+
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
|
5
|
+
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
|
6
|
+
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
|
7
|
+
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
|
8
|
+
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
|
9
|
+
// ┃ This file is part of the Perspective library, distributed under the terms ┃
|
|
10
|
+
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
|
11
|
+
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
12
|
+
|
|
13
|
+
.psp-header-border:not(.psp-is-top):not(.psp-header-leaf) {
|
|
14
|
+
// right
|
|
15
|
+
box-shadow: 1px 0px var(--inactive--border-color, #8b868045);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.psp-header-group {
|
|
19
|
+
// bottom
|
|
20
|
+
box-shadow: 0px 10px 0 -9px var(--inactive--border-color, #8b868045);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.psp-is-top {
|
|
24
|
+
// top-miter-right
|
|
25
|
+
box-shadow: 5px 4px 0px -4px var(--inactive--border-color, #8b868045);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.psp-is-top.psp-header-group:not(.psp-header-group-corner) {
|
|
29
|
+
// top-miter-right and bottom
|
|
30
|
+
box-shadow:
|
|
31
|
+
5px 4px 0px -4px var(--inactive--border-color, #8b868045),
|
|
32
|
+
0px 10px 0 -9px var(--inactive--border-color, #8b868045);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.psp-header-border.psp-header-group {
|
|
36
|
+
&:not(.psp-is-top):not(.psp-header-group-corner) {
|
|
37
|
+
// right and bottom
|
|
38
|
+
box-shadow:
|
|
39
|
+
1px 0px var(--inactive--border-color, #8b868045),
|
|
40
|
+
0px 10px 0 -9px var(--inactive--border-color, #8b868045);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@mixin disabled-menu-funky-box-shadow {
|
|
45
|
+
tr.rt-autosize .psp-header-leaf.psp-header-border:not(.psp-menu-enabled) {
|
|
46
|
+
box-shadow: 1px 0px var(--inactive--border-color, #8b868045);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
perspective-viewer[settings] {
|
|
51
|
+
@include disabled-menu-funky-box-shadow;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:host-context(perspective-viewer[settings]) {
|
|
55
|
+
@include disabled-menu-funky-box-shadow;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.psp-header-leaf.psp-header-border {
|
|
59
|
+
// bottom-miter-right
|
|
60
|
+
box-shadow: 5px -4px 0px -4px var(--inactive--border-color, #8b868045);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
tr:only-child th {
|
|
64
|
+
box-shadow: none !important;
|
|
65
|
+
}
|