UNPKG

2.57 kBTypeScriptView Raw
1/******************************************************************************
2 *
3 * Copyright (c) 2017, the Perspective Authors.
4 *
5 * This file is part of the Perspective library, distributed under the terms of
6 * the Apache License 2.0. The full license can be found in the LICENSE file.
7 *
8 */
9
10import React from "react";
11import {Table, TableData, TableOptions, Schema} from "@finos/perspective";
12
13export interface HTMLPerspectiveViewerElement extends PerspectiveViewerOptions, HTMLElement {
14 load(data: TableData | Table, options?: TableOptions): void;
15 load(schema: Schema, options?: TableOptions): void;
16 update(data: TableData): void;
17 notifyResize(): void;
18 delete(delete_table: boolean): Promise<void>;
19 clear(): void;
20 replace(data: TableData): void;
21 flush(): Promise<void>;
22 toggleConfig(): void;
23 save(): PerspectiveViewerOptions;
24 reset(): void;
25 restore(x: any): Promise<void>;
26 restyleElement(): void;
27 readonly table?: Table;
28}
29interface ComputedColumn {
30 column: string;
31 inputs: string[];
32 computed_function_name: string;
33}
34
35export type Filters = Array<[string, string, string]>;
36export type Sort = Array<[string, string] | string>;
37export type ComputedColumns = ComputedColumn[];
38export type Aggregates = {[column_name: string]: string};
39export type Pivots = string[];
40export type Columns = string[];
41
42export interface PerspectiveViewerOptions {
43 aggregates?: Aggregates;
44 editable?: boolean;
45 plugin?: string;
46 columns?: Columns;
47 "computed-columns"?: ComputedColumns;
48 "row-pivots"?: Pivots;
49 "column-pivots"?: Pivots;
50 filters?: Filters;
51 sort?: Sort;
52 selectable?: boolean;
53}
54
55interface PerspectiveViewerHTMLAttributes extends Pick<PerspectiveViewerOptions, "editable" | "plugin" | "selectable"> {
56 aggregates?: string;
57 "computed-columns"?: string;
58 "row-pivots"?: string;
59 "column-pivots"?: string;
60 filters?: string;
61 sort?: string;
62 columns?: string;
63}
64
65interface ReactPerspectiveViewerHTMLAttributes<T> extends PerspectiveViewerHTMLAttributes, React.HTMLAttributes<T> {}
66
67type PerspectiveElement = {class?: string} & React.DetailedHTMLProps<ReactPerspectiveViewerHTMLAttributes<HTMLPerspectiveViewerElement>, HTMLPerspectiveViewerElement>;
68
69declare global {
70 namespace JSX {
71 interface IntrinsicElements {
72 "perspective-viewer": PerspectiveElement;
73 }
74 }
75
76 interface Document {
77 createElement(tagName: "perspective-viewer", options?: ElementCreationOptions): HTMLPerspectiveViewerElement;
78 }
79}