diff --git a/js/notebook/src/contextMenu/BkoContextMenu.ts b/js/notebook/src/contextMenu/BkoContextMenu.ts index 941d099cda..0611c8e852 100644 --- a/js/notebook/src/contextMenu/BkoContextMenu.ts +++ b/js/notebook/src/contextMenu/BkoContextMenu.ts @@ -19,10 +19,10 @@ declare var lab: { contextMenu: ContextMenu }; import { ContextMenu, Menu } from '@phosphor/widgets'; import { CommandRegistry } from '@phosphor/commands'; import { IDisposable } from '@phosphor/disposable'; -import MenuItem from "shared/interfaces/contextMenuItemInterface"; +import MenuItem from "../shared/interfaces/contextMenuItemInterface"; import MenuInterface from '../shared/interfaces/menuInterface' -interface addItem { +export interface addItem { addItem: Function } diff --git a/js/notebook/src/tableDisplay/dataGrid/DataGridScope.ts b/js/notebook/src/tableDisplay/dataGrid/DataGridScope.ts index 8571e717e7..fea29ba09f 100644 --- a/js/notebook/src/tableDisplay/dataGrid/DataGridScope.ts +++ b/js/notebook/src/tableDisplay/dataGrid/DataGridScope.ts @@ -23,6 +23,7 @@ import ColumnLimitModal from "./modal/ColumnLimitModal"; import createStore, { BeakerXDataStore } from "./store/BeakerXDataStore"; import { selectModel } from "./model/selectors"; import BeakerXThemeHelper from "../../BeakerXThemeHelper"; +import IDataModelState from "./interface/IDataGridModelState"; export class DataGridScope { contextMenu: DataGridContextMenu; @@ -53,7 +54,7 @@ export class DataGridScope { this.initColumnLimitModal(); } - get state() { + get state(): IDataModelState { return selectModel(this.store.state); } diff --git a/js/notebook/src/tableDisplay/dataGrid/cell/BeakerXCellRenderer.ts b/js/notebook/src/tableDisplay/dataGrid/cell/BeakerXCellRenderer.ts index 82157efc69..61bf912076 100644 --- a/js/notebook/src/tableDisplay/dataGrid/cell/BeakerXCellRenderer.ts +++ b/js/notebook/src/tableDisplay/dataGrid/cell/BeakerXCellRenderer.ts @@ -27,7 +27,7 @@ import getStringSize = DataGridHelpers.getStringSize; import retrieveUrl = DataGridHelpers.retrieveUrl; import BeakerXThemeHelper from "../../../BeakerXThemeHelper"; -interface ICellRendererOptions { +export interface ICellRendererOptions { font?: string, color?: string, text?: any, diff --git a/js/notebook/src/tableDisplay/dataGrid/cell/CellManager.ts b/js/notebook/src/tableDisplay/dataGrid/cell/CellManager.ts index 25ca99a8d5..6ad6236be5 100644 --- a/js/notebook/src/tableDisplay/dataGrid/cell/CellManager.ts +++ b/js/notebook/src/tableDisplay/dataGrid/cell/CellManager.ts @@ -23,7 +23,7 @@ import {ICellData} from "../interface/ICell"; import {DataGridHelpers} from "../dataGridHelpers"; import isUrl = DataGridHelpers.isUrl; -interface ICellDataOptions { +export interface ICellDataOptions { row: number, column: number, value: any, diff --git a/js/notebook/src/tableDisplay/dataGrid/column/DataGridColumn.ts b/js/notebook/src/tableDisplay/dataGrid/column/DataGridColumn.ts index 9c3c94217e..e7c930261e 100644 --- a/js/notebook/src/tableDisplay/dataGrid/column/DataGridColumn.ts +++ b/js/notebook/src/tableDisplay/dataGrid/column/DataGridColumn.ts @@ -61,6 +61,7 @@ import {ColumnValuesIterator} from "./ColumnValuesIterator"; import {DataGridHelpers} from "../dataGridHelpers"; import getStringSize = DataGridHelpers.getStringSize; import {selectDataFontSize} from "../model/selectors/model"; +import Highlighter from "../highlighter/Highlighter"; export default class DataGridColumn { index: number; @@ -272,7 +273,7 @@ export default class DataGridColumn { return selectRenderer(this.store.state, this); } - getHighlighter(highlighterType: HIGHLIGHTER_TYPE) { + getHighlighter(highlighterType: HIGHLIGHTER_TYPE): Highlighter[] { return this.dataGrid.highlighterManager.getColumnHighlighters(this, highlighterType); } diff --git a/js/notebook/src/tableDisplay/dataGrid/highlighter/HighlighterManager.ts b/js/notebook/src/tableDisplay/dataGrid/highlighter/HighlighterManager.ts index 7d6fe1344d..8753401421 100644 --- a/js/notebook/src/tableDisplay/dataGrid/highlighter/HighlighterManager.ts +++ b/js/notebook/src/tableDisplay/dataGrid/highlighter/HighlighterManager.ts @@ -37,7 +37,7 @@ export default class HighlighterManager { constructor(dataGrid: BeakerXDataGrid) { this.dataGrid = dataGrid; this.highlighters = []; - this.cachedHighlighters = new Map(); + this.cachedHighlighters = new Map(); this.createHighlighter = this.createHighlighter.bind(this); this.registerHighlighter = this.registerHighlighter.bind(this); diff --git a/js/notebook/src/tableDisplay/dataGrid/model/selectors/column.ts b/js/notebook/src/tableDisplay/dataGrid/model/selectors/column.ts index e3389054b4..a8dfb6d1a8 100644 --- a/js/notebook/src/tableDisplay/dataGrid/model/selectors/column.ts +++ b/js/notebook/src/tableDisplay/dataGrid/model/selectors/column.ts @@ -26,6 +26,8 @@ import { import {getAlignmentByChar} from "../../column/columnAlignment"; import {IColumnPosition} from "../../interface/IColumn"; import {ALL_TYPES} from "../../dataTypes"; +import Highlighter from "../../highlighter/Highlighter"; +import IHihglighterState from "../../interface/IHighlighterState"; export const DEFAULT_INDEX_COLUMN_NAME = 'index'; @@ -186,7 +188,7 @@ export const selectColumnHighlighters = createSelector( (state, columnName) => columnName, (state, columnName, highlighterType) => highlighterType ], - (highlighters, columnName, highlighterType) => highlighters.filter( + (highlighters, columnName, highlighterType): IHihglighterState[] => highlighters.filter( highlighter => highlighter.colName === columnName && highlighter.type === highlighterType ) ); diff --git a/js/notebook/src/types/BeakerXThemeHelper.d.ts b/js/notebook/src/types/BeakerXThemeHelper.d.ts new file mode 100644 index 0000000000..0b20253e87 --- /dev/null +++ b/js/notebook/src/types/BeakerXThemeHelper.d.ts @@ -0,0 +1,12 @@ +import { DataGrid } from "@phosphor/datagrid"; +export default class BeakerXThemeHelper { + static readonly isDark: boolean; + static getStyle(): DataGrid.IStyle; + static readonly DEFAULT_DATA_FONT_COLOR: string; + static readonly DEFAULT_HEADER_FONT_COLOR: string; + static readonly DEFAULT_HIGHLIGHT_COLOR: string; + static readonly DEFAULT_CELL_BACKGROUND: string; + static readonly FOCUSED_CELL_BACKGROUND: string; + private static getDarkStyle(); + private static getLightStyle(); +} diff --git a/js/notebook/src/types/BxHTML.d.ts b/js/notebook/src/types/BxHTML.d.ts new file mode 100644 index 0000000000..077fc5f4bf --- /dev/null +++ b/js/notebook/src/types/BxHTML.d.ts @@ -0,0 +1,12 @@ +import widgets from './widgets'; +export declare class BxHTMLModel extends widgets.HTMLModel { + defaults(): any; +} +export declare class BxHTMLView extends widgets.HTMLView { + render(): void; +} +declare const _default: { + BxHTMLModel: typeof BxHTMLModel; + BxHTMLView: typeof BxHTMLView; +}; +export default _default; diff --git a/js/notebook/src/types/CyclingDisplayBox.d.ts b/js/notebook/src/types/CyclingDisplayBox.d.ts new file mode 100644 index 0000000000..d5158677ae --- /dev/null +++ b/js/notebook/src/types/CyclingDisplayBox.d.ts @@ -0,0 +1,14 @@ +import widgets from './widgets'; +export declare class CyclingDisplayBoxModel extends widgets.BoxModel { + defaults(): any; +} +export declare class CyclingDisplayBoxView extends widgets.BoxView { + initialize(): void; + update_children(): void; + draw_widget(): void; +} +declare const _default: { + CyclingDisplayBoxView: typeof CyclingDisplayBoxView; + CyclingDisplayBoxModel: typeof CyclingDisplayBoxModel; +}; +export default _default; diff --git a/js/notebook/src/types/EasyForm.d.ts b/js/notebook/src/types/EasyForm.d.ts new file mode 100644 index 0000000000..ce6551a0db --- /dev/null +++ b/js/notebook/src/types/EasyForm.d.ts @@ -0,0 +1,34 @@ +import widgets from './widgets'; +export * from './easyForm/selectMultipleWidget'; +export * from './easyForm/selectMultipleSingleWidget'; +export * from './easyForm/datePickerWidget'; +export * from './easyForm/comboBoxWidget'; +export * from './easyForm/textWidget'; +export * from './easyForm/passwordWidget'; +export * from './easyForm/TextareaWidget'; +export * from './easyForm/checkboxWidget'; +import './easyForm/css/jupyter-easyform.scss'; +import 'flatpickr/dist/flatpickr.css'; +import 'jquery-ui/themes/base/all.css'; +import 'jquery-ui/ui/widgets/button'; +import 'jquery-ui/ui/widgets/autocomplete'; +export declare class EasyFormModel extends widgets.DOMWidgetModel { + defaults(): any; + static serializers: { + children: { + deserialize: any; + }; + }; +} +export declare class EasyFormView extends widgets.BoxView { + render(): void; + events(): { + 'keypress': string; + }; + handleEnterKeyPress(event: any): any; +} +declare const _default: { + EasyFormModel: typeof EasyFormModel; + EasyFormView: typeof EasyFormView; +}; +export default _default; diff --git a/js/notebook/src/types/Foldout.d.ts b/js/notebook/src/types/Foldout.d.ts new file mode 100644 index 0000000000..cb938c87d8 --- /dev/null +++ b/js/notebook/src/types/Foldout.d.ts @@ -0,0 +1,39 @@ +import { Widget, Panel } from '@phosphor/widgets'; +import widgets from './widgets'; +export declare class FoldoutModel extends widgets.BoxModel { + defaults(): any; +} +export declare class FoldoutView extends widgets.BoxView { + label: Panel; + labelContent: Widget; + content: Panel; + previewContainer: Widget; + previewContent: HTMLElement; + previewContentParent: HTMLElement; + hiddenContainer: HTMLElement; + timeoutId: number; + active: boolean; + hidePreview: boolean; + initialize(parameters: any): void; + add_child_model(model: any): any; + addLabel(): void; + addContent(): void; + addPreviewContent(): void; + addHiddenContainer(): void; + headerClickCallback(): void; + activateFoldout(): void; + deactivateFoldout(): void; + activateFoldoutCallback(): void; + deactivateFoldoutCallback(): void; + getPreviewContent(): HTMLElement; + render(): void; + updateHiddenContainer(): void; + restorePreviewContent(): void; + renderPreview(): void; + dispose(): void; +} +declare const _default: { + FoldoutModel: typeof FoldoutModel; + FoldoutView: typeof FoldoutView; +}; +export default _default; diff --git a/js/notebook/src/types/GridView.d.ts b/js/notebook/src/types/GridView.d.ts new file mode 100644 index 0000000000..39a8a65aac --- /dev/null +++ b/js/notebook/src/types/GridView.d.ts @@ -0,0 +1,13 @@ +import widgets from './widgets'; +import './gridView/grid-view.scss'; +export declare class GridViewModel extends widgets.VBoxModel { + defaults(): any; +} +export declare class GridView extends widgets.VBoxView { + render(): void; +} +declare const _default: { + GridViewModel: typeof GridViewModel; + GridView: typeof GridView; +}; +export default _default; diff --git a/js/notebook/src/types/HTMLPre.d.ts b/js/notebook/src/types/HTMLPre.d.ts new file mode 100644 index 0000000000..c7e4940354 --- /dev/null +++ b/js/notebook/src/types/HTMLPre.d.ts @@ -0,0 +1,12 @@ +import widgets from './widgets'; +export declare class HTMLPreModel extends widgets.StringModel { + defaults(): any; +} +export declare class HTMLPreView extends widgets.DescriptionView { + render(): void; +} +declare const _default: { + HTMLPreModel: typeof HTMLPreModel; + HTMLPreView: typeof HTMLPreView; +}; +export default _default; diff --git a/js/notebook/src/types/SparkConfiguration.d.ts b/js/notebook/src/types/SparkConfiguration.d.ts new file mode 100644 index 0000000000..440ef8a7f4 --- /dev/null +++ b/js/notebook/src/types/SparkConfiguration.d.ts @@ -0,0 +1,11 @@ +import widgets from './widgets'; +export declare class SparkConfigurationModel extends widgets.VBoxModel { + defaults(): any; +} +export declare class SparkConfigurationView extends widgets.VBoxView { +} +declare const _default: { + SparkConfigurationModel: typeof SparkConfigurationModel; + SparkConfigurationView: typeof SparkConfigurationView; +}; +export default _default; diff --git a/js/notebook/src/types/SparkFoldout.d.ts b/js/notebook/src/types/SparkFoldout.d.ts new file mode 100644 index 0000000000..b4b4769194 --- /dev/null +++ b/js/notebook/src/types/SparkFoldout.d.ts @@ -0,0 +1,13 @@ +import Foldout from "./Foldout"; +import widgets from './widgets'; +export declare class SparkFoldoutModel extends widgets.BoxModel { + defaults(): any; +} +export declare class SparkFoldoutView extends Foldout.FoldoutView { + getPreviewContent(): HTMLElement; +} +declare const _default: { + SparkFoldoutModel: typeof SparkFoldoutModel; + SparkFoldoutView: typeof SparkFoldoutView; +}; +export default _default; diff --git a/js/notebook/src/types/SparkStateProgress.d.ts b/js/notebook/src/types/SparkStateProgress.d.ts new file mode 100644 index 0000000000..6febeb355a --- /dev/null +++ b/js/notebook/src/types/SparkStateProgress.d.ts @@ -0,0 +1,31 @@ +import widgets from './widgets'; +import "./shared/style/spark.scss"; +export declare class SparkStateProgressModel extends widgets.VBoxModel { + defaults(): any; +} +export declare class SparkStateProgressView extends widgets.VBoxView { + progressBar: HTMLElement; + progressBarDone: HTMLElement; + progressBarActive: HTMLElement; + progressBarWaiting: HTMLElement; + progressLabels: HTMLElement; + progressLabelDone: HTMLElement; + progressLabelActive: HTMLElement; + progressLabelWaiting: HTMLElement; + progressLabelAll: HTMLElement; + render(): void; + update(): any; + private updateLabelWidths(); + private createWidget(); + private createJobPanel(); + private createJobLink(state); + private createStagePanel(state); + private createStageLink(state); + private createStageProgressBar(state); + private createStageProgressLabels(state); +} +declare const _default: { + SparkStateProgressModel: typeof SparkStateProgressModel; + SparkStateProgressView: typeof SparkStateProgressView; +}; +export default _default; diff --git a/js/notebook/src/types/SparkUI.d.ts b/js/notebook/src/types/SparkUI.d.ts new file mode 100644 index 0000000000..17abfb69cd --- /dev/null +++ b/js/notebook/src/types/SparkUI.d.ts @@ -0,0 +1,42 @@ +import widgets from './widgets'; +export declare class SparkUIModel extends widgets.VBoxModel { + defaults(): any; +} +export declare class SparkUIView extends widgets.VBoxView { + private sparkStats; + private sparkAppId; + private sparkUiWebUrl; + private sparkMasterUrl; + private apiCallIntervalId; + private connectionLabelActive; + private connectionLabelMemory; + private connectionLabelDead; + private connectionStatusElement; + private masterUrlInput; + private executorCoresInput; + private executorMemoryInput; + initialize(parameters: any): void; + render(): void; + update(): void; + private addSparkUrls(); + private addSparUiWebUrl(); + private addMasterUrl(); + private handleLocalMasterUrl(); + private toggleExecutorConfigInputs(); + private openWebUi(); + private openExecutors(); + private updateChildren(); + private resolveChildren(view); + private createSparkMetricsWidget(); + private connectToApi(); + private setApiCallInterval(api); + private clearApiCallInterval(); + private updateMetrics(data); + private addSparkMetricsWidget(); + dispose(): void; +} +declare const _default: { + SparkUIModel: typeof SparkUIModel; + SparkUIView: typeof SparkUIView; +}; +export default _default; diff --git a/js/notebook/src/types/TabView.d.ts b/js/notebook/src/types/TabView.d.ts new file mode 100644 index 0000000000..6ebca49ded --- /dev/null +++ b/js/notebook/src/types/TabView.d.ts @@ -0,0 +1,14 @@ +import widgets from './widgets'; +export declare class TabModel extends widgets.TabModel { + defaults(): any; +} +export declare class TabView extends widgets.TabView { + render(): void; + _onTabChanged(tabBar: any, tabs: any): void; + _triggerSelectEventForChildren(currentIndex: any): void; +} +declare const _default: { + TabModel: typeof TabModel; + TabView: typeof TabView; +}; +export default _default; diff --git a/js/notebook/src/types/TableDisplay.d.ts b/js/notebook/src/types/TableDisplay.d.ts new file mode 100644 index 0000000000..811b27eb73 --- /dev/null +++ b/js/notebook/src/types/TableDisplay.d.ts @@ -0,0 +1,18 @@ +import widgets from './widgets'; +export declare class TableDisplayModel extends widgets.DOMWidgetModel { + defaults(): any; +} +export declare class TableDisplayView extends widgets.DOMWidgetView { + private _currentScope; + render(): void; + handleModellUpdate(): void; + handleUpdateData(): void; + showWarning(data: any): void; + initDataGridTable(data: any): void; + remove(): void; +} +declare const _default: { + TableDisplayModel: typeof TableDisplayModel; + TableDisplayView: typeof TableDisplayView; +}; +export default _default; diff --git a/js/notebook/src/types/contextMenu/BkoContextMenu.d.ts b/js/notebook/src/types/contextMenu/BkoContextMenu.d.ts new file mode 100644 index 0000000000..2e6dd98681 --- /dev/null +++ b/js/notebook/src/types/contextMenu/BkoContextMenu.d.ts @@ -0,0 +1,37 @@ +import { ContextMenu, Menu } from '@phosphor/widgets'; +import { CommandRegistry } from '@phosphor/commands'; +import { IDisposable } from '@phosphor/disposable'; +import MenuItem from "../shared/interfaces/contextMenuItemInterface"; +import MenuInterface from '../shared/interfaces/menuInterface'; +export interface addItem { + addItem: Function; +} +export default abstract class BkoContextMenu implements MenuInterface { + event: MouseEvent; + protected scope: any; + protected commands: CommandRegistry; + protected menuItems: Menu.IItem[]; + protected inLab: boolean; + protected disposables: IDisposable[]; + contextMenu: ContextMenu; + constructor(scope: any); + protected abstract buildMenu(): void; + protected isInLab(): boolean; + protected handleContextMenu(event: MouseEvent): void; + open(e: MouseEvent): void; + protected buildLabMenu(): void; + protected buildBkoMenu(): void; + protected createItems(items: MenuItem[], menu: addItem): void; + protected createMenuItem(menuItem: MenuItem, menu: addItem): void; + protected addMenuItem(menuItem: MenuItem, menu: addItem): Menu.IItem; + protected addSeparatorItem(menuItem: MenuItem, menu: addItem): Menu.IItem; + protected addSubmenuItem(menuItem: MenuItem, menu: addItem, subitems: MenuItem[]): Menu.IItem; + protected addCommand(menuItem: MenuItem): void; + protected addKeyBinding(menuItem: MenuItem): void; + protected createSubmenu(menuItem: MenuItem, subitems: MenuItem[]): Menu; + protected bindEvents(): void; + destroy(): void; + removeMenuItems(): void; + dispose(): void; + unbind(): void; +} diff --git a/js/notebook/src/types/easyForm/TextareaWidget.d.ts b/js/notebook/src/types/easyForm/TextareaWidget.d.ts new file mode 100644 index 0000000000..6cfa7105f7 --- /dev/null +++ b/js/notebook/src/types/easyForm/TextareaWidget.d.ts @@ -0,0 +1,16 @@ +import widgets from '../widgets'; +export declare class TextareaModel extends widgets.TextareaModel { + defaults(): any; +} +export declare class TextareaView extends widgets.TextareaView { + render(): void; + setWidth(width: number): void; + setHeight(height: number): void; + setRows(rows: number): void; + setCols(cols: number): void; +} +declare const _default: { + TextareaModel: typeof TextareaModel; + TextareaView: typeof TextareaView; +}; +export default _default; diff --git a/js/notebook/src/types/easyForm/checkboxWidget.d.ts b/js/notebook/src/types/easyForm/checkboxWidget.d.ts new file mode 100644 index 0000000000..37ff0491aa --- /dev/null +++ b/js/notebook/src/types/easyForm/checkboxWidget.d.ts @@ -0,0 +1,13 @@ +import widgets from '../widgets'; +export declare class CheckboxModel extends widgets.CheckboxModel { + defaults(): any; +} +export declare class CheckboxView extends widgets.CheckboxView { + render(): void; + renderSingle(): void; +} +declare const _default: { + CheckboxModel: typeof CheckboxModel; + CheckboxView: typeof CheckboxView; +}; +export default _default; diff --git a/js/notebook/src/types/easyForm/comboBoxWidget.d.ts b/js/notebook/src/types/easyForm/comboBoxWidget.d.ts new file mode 100644 index 0000000000..8626de1bb0 --- /dev/null +++ b/js/notebook/src/types/easyForm/comboBoxWidget.d.ts @@ -0,0 +1,14 @@ +import widgets from '../widgets'; +export declare class ComboBoxModel extends widgets.SelectModel { + defaults(): any; +} +export declare class ComboBoxView extends widgets.SelectView { + render(): void; + setValueToModel(value: any): void; + update(): void; +} +declare const _default: { + ComboBoxModel: typeof ComboBoxModel; + ComboBoxView: typeof ComboBoxView; +}; +export default _default; diff --git a/js/notebook/src/types/easyForm/datePickerWidget.d.ts b/js/notebook/src/types/easyForm/datePickerWidget.d.ts new file mode 100644 index 0000000000..5b86ede719 --- /dev/null +++ b/js/notebook/src/types/easyForm/datePickerWidget.d.ts @@ -0,0 +1,18 @@ +import widgets from '../widgets'; +export declare class DatePickerModel extends widgets.StringModel { + defaults(): any; +} +export declare class DatePickerView extends widgets.LabeledDOMWidgetView { + render(): void; + initDatePicker(): void; + update(options?: any): void; + events(): { + "change input": string; + }; + setValueToModel(value: any): void; +} +declare const _default: { + DatePickerModel: typeof DatePickerModel; + DatePickerView: typeof DatePickerView; +}; +export default _default; diff --git a/js/notebook/src/types/easyForm/passwordWidget.d.ts b/js/notebook/src/types/easyForm/passwordWidget.d.ts new file mode 100644 index 0000000000..326383f791 --- /dev/null +++ b/js/notebook/src/types/easyForm/passwordWidget.d.ts @@ -0,0 +1,16 @@ +import widgets from '../widgets'; +export declare class PasswordModel extends widgets.PasswordModel { + defaults(): any; +} +export declare class PasswordView extends widgets.PasswordView { + handleKeypress(e: any): void; + handleEnterKeyPress(e: any): void; + render(): void; + setWidth(width: number): void; + setSize(size: number): void; +} +declare const _default: { + PasswordModel: typeof PasswordModel; + PasswordView: typeof PasswordView; +}; +export default _default; diff --git a/js/notebook/src/types/easyForm/selectMultipleSingleWidget.d.ts b/js/notebook/src/types/easyForm/selectMultipleSingleWidget.d.ts new file mode 100644 index 0000000000..fd70efabd1 --- /dev/null +++ b/js/notebook/src/types/easyForm/selectMultipleSingleWidget.d.ts @@ -0,0 +1,12 @@ +import widgets from '../widgets'; +export declare class SelectMultipleSingleModel extends widgets.SelectModel { + defaults(): any; +} +export declare class SelectMultipleSingleView extends widgets.SelectView { + update(): void; +} +declare const _default: { + SelectMultipleSingleModel: typeof SelectMultipleSingleModel; + SelectMultipleSingleView: typeof SelectMultipleSingleView; +}; +export default _default; diff --git a/js/notebook/src/types/easyForm/selectMultipleWidget.d.ts b/js/notebook/src/types/easyForm/selectMultipleWidget.d.ts new file mode 100644 index 0000000000..ab8dfb180a --- /dev/null +++ b/js/notebook/src/types/easyForm/selectMultipleWidget.d.ts @@ -0,0 +1,12 @@ +import widgets from '../widgets'; +export declare class SelectMultipleModel extends widgets.SelectMultipleModel { + defaults(): any; +} +export declare class SelectMultipleView extends widgets.SelectMultipleView { + update(): void; +} +declare const _default: { + SelectMultipleModel: typeof SelectMultipleModel; + SelectMultipleView: typeof SelectMultipleView; +}; +export default _default; diff --git a/js/notebook/src/types/easyForm/textWidget.d.ts b/js/notebook/src/types/easyForm/textWidget.d.ts new file mode 100644 index 0000000000..89ccf2e594 --- /dev/null +++ b/js/notebook/src/types/easyForm/textWidget.d.ts @@ -0,0 +1,17 @@ +import widgets from '../widgets'; +export declare const TEXT_INPUT_WIDTH_UNIT = "px"; +export declare class TextModel extends widgets.TextModel { + defaults(): any; +} +export declare class TextView extends widgets.TextView { + handleKeypress(e: any): void; + handleEnterKeyPress(e: any): void; + render(): void; + setWidth(width: number): void; + setSize(size: number): void; +} +declare const _default: { + TextModel: typeof TextModel; + TextView: typeof TextView; +}; +export default _default; diff --git a/js/notebook/src/global.env.d.ts b/js/notebook/src/types/global.env.d.ts similarity index 100% rename from js/notebook/src/global.env.d.ts rename to js/notebook/src/types/global.env.d.ts diff --git a/js/notebook/src/types/index.d.ts b/js/notebook/src/types/index.d.ts new file mode 100644 index 0000000000..8221443f75 --- /dev/null +++ b/js/notebook/src/types/index.d.ts @@ -0,0 +1,15 @@ +/// + +// Export widget models and views, and the npm package version number. +export * from './BxHTML'; +export * from './Foldout'; +export * from './HTMLPre'; +export * from './SparkUI'; +export * from './SparkStateProgress'; +export * from './SparkConfiguration'; +export * from './SparkFoldout'; +export * from './TableDisplay'; +export * from './TabView'; +export * from './GridView'; +export * from './CyclingDisplayBox'; +export * from './EasyForm'; diff --git a/js/notebook/src/types/plot/plotSanitize.d.ts b/js/notebook/src/types/plot/plotSanitize.d.ts new file mode 100644 index 0000000000..529456c171 --- /dev/null +++ b/js/notebook/src/types/plot/plotSanitize.d.ts @@ -0,0 +1,10 @@ +declare global { + interface Window { + cssSchemaFixed: boolean; + cssSchema: any; + require: Function; + } +} +declare let sanitize: any; +export default sanitize; +export declare const sanitizeHTML: (html: string, allowCss?: boolean) => any; diff --git a/js/notebook/src/types/shared/interfaces/contextMenuItemInterface.d.ts b/js/notebook/src/types/shared/interfaces/contextMenuItemInterface.d.ts new file mode 100644 index 0000000000..cf675a1df0 --- /dev/null +++ b/js/notebook/src/types/shared/interfaces/contextMenuItemInterface.d.ts @@ -0,0 +1,5 @@ +import MenuItem from './menuItemInterface'; +export default interface ContextMenuItem extends MenuItem { + selector: string; + id: string; +} diff --git a/js/notebook/src/types/shared/interfaces/menuInterface.d.ts b/js/notebook/src/types/shared/interfaces/menuInterface.d.ts new file mode 100644 index 0000000000..e8af8dc057 --- /dev/null +++ b/js/notebook/src/types/shared/interfaces/menuInterface.d.ts @@ -0,0 +1,4 @@ +export default interface Menu { + open: Function; + destroy: Function; +} diff --git a/js/notebook/src/types/shared/interfaces/menuItemInterface.d.ts b/js/notebook/src/types/shared/interfaces/menuItemInterface.d.ts new file mode 100644 index 0000000000..63f646e6a0 --- /dev/null +++ b/js/notebook/src/types/shared/interfaces/menuItemInterface.d.ts @@ -0,0 +1,21 @@ +import { CommandRegistry } from '@phosphor/commands'; +export default interface MenuItem { + title: string; + action?: Function; + enableItemsFiltering?: boolean; + id?: string; + icon?: string; + inputPlaceholder?: string; + inputAction?: Function; + isChecked?: Function | boolean; + items?: MenuItem[] | Function; + keepOpen?: boolean; + separator?: boolean; + shortcut?: string; + submenuClass?: string; + type?: string; + tooltip?: string; + updateLayout?: boolean; + isVisible?: CommandRegistry.CommandFunc; + args?: object; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/BeakerXDataGrid.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/BeakerXDataGrid.d.ts new file mode 100644 index 0000000000..c6c493d8b0 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/BeakerXDataGrid.d.ts @@ -0,0 +1,69 @@ +import { CellRenderer, DataGrid, DataModel, GraphicsContext } from "@phosphor/datagrid"; +import { BeakerXDataGridModel } from "./model/BeakerXDataGridModel"; +import { Widget } from "@phosphor/widgets"; +import { Signal } from '@phosphor/signaling'; +import { ICellData } from "./interface/ICell"; +import DataGridColumn from "./column/DataGridColumn"; +import IDataModelState from "./interface/IDataGridModelState"; +import HighlighterManager from "./highlighter/HighlighterManager"; +import ColumnManager from "./column/ColumnManager"; +import RowManager from "./row/RowManager"; +import CellSelectionManager from "./cell/CellSelectionManager"; +import CellManager from "./cell/CellManager"; +import EventManager from "./event/EventManager"; +import CellFocusManager from "./cell/CellFocusManager"; +import CellTooltipManager from "./cell/CellTooltipManager"; +import { BeakerXDataStore } from "./store/BeakerXDataStore"; +import ColumnPosition from "./column/ColumnPosition"; +import { SectionList } from "@phosphor/datagrid/lib/sectionlist"; +import ColumnRegion = DataModel.ColumnRegion; +import { DataGridResize } from "./DataGridResize"; +export declare class BeakerXDataGrid extends DataGrid { + id: string; + store: BeakerXDataStore; + columnSections: SectionList; + columnHeaderSections: SectionList; + model: BeakerXDataGridModel; + rowHeaderSections: SectionList; + rowSections: SectionList; + viewport: Widget; + highlighterManager: HighlighterManager; + columnManager: ColumnManager; + columnPosition: ColumnPosition; + rowManager: RowManager; + cellSelectionManager: CellSelectionManager; + cellManager: CellManager; + eventManager: EventManager; + cellFocusManager: CellFocusManager; + cellTooltipManager: CellTooltipManager; + dataGridResize: DataGridResize; + canvasGC: GraphicsContext; + focused: boolean; + wrapperId: string; + cellHovered: Signal; + commSignal: Signal; + static FOCUS_CSS_CLASS: string; + constructor(options: DataGrid.IOptions, dataStore: BeakerXDataStore); + init(store: BeakerXDataStore): void; + getColumn(config: CellRenderer.ICellConfig): DataGridColumn; + getColumnByName(columnName: string): DataGridColumn | undefined; + getCellData(clientX: number, clientY: number): ICellData | null; + getColumnOffset(position: number, region: ColumnRegion): number; + getRowOffset(row: number): number; + updateModelData(state: IDataModelState): void; + setWrapperId(id: string): void; + setInitialSize(): void; + resize(args?: any): void; + setFocus(focus: boolean): void; + handleEvent(event: Event): void; + destroy(): void; + onAfterAttach(msg: any): void; + messageHook(handler: any, msg: any): boolean; + colorizeColumnBorder(data: ICellData, color: string): void; + private addHighlighterManager(); + private addCellRenderers(); + private handleStateChanged(); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/DataFormatter.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/DataFormatter.d.ts new file mode 100644 index 0000000000..4caba1a426 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/DataFormatter.d.ts @@ -0,0 +1,31 @@ +import { CellRenderer } from "@phosphor/datagrid"; +import { IColumnState } from "./interface/IColumn"; +import { BeakerXDataStore } from "./store/BeakerXDataStore"; +export declare const DEFAULT_TIME_FORMAT = "YYYYMMDD HH:mm:ss.SSS ZZ"; +export declare class DataFormatter { + store: BeakerXDataStore; + constructor(store: BeakerXDataStore); + destroy(): void; + readonly stringFormatForColumn: {}; + readonly timeStrings: any; + readonly timeZone: string; + readonly stringFormatForType: {}; + readonly formatForTimes: any; + readonly columnNames: string[]; + getFormatFnByDisplayType(displayType: any, columnState?: IColumnState): CellRenderer.ConfigFunc; + private isNull(value); + private handleNull(formatFn); + private value(config); + private string(config); + private integer(config); + private formattedInteger(config); + private double(config); + private doubleWithPrecision(precision); + private exponential_5(config); + private exponential_15(config); + private datetime(config, formatForTimes); + private getTimeFormatForColumn(columnState?); + private datetimeWithFormat(formatForTimes?); + private boolean(config); + private html(config); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/DataGridResize.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/DataGridResize.d.ts new file mode 100644 index 0000000000..00787b32e5 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/DataGridResize.d.ts @@ -0,0 +1,47 @@ +import { BeakerXDataGrid } from "./BeakerXDataGrid"; +import { DataModel } from "@phosphor/datagrid"; +import ColumnRegion = DataModel.ColumnRegion; +export declare class DataGridResize { + dataGrid: BeakerXDataGrid; + resizeStartRect: { + width: number; + height: number; + x: number; + y: number; + }; + resizeMode: 'h' | 'v' | 'both' | null; + resizing: boolean; + resizedHorizontally: boolean; + constructor(dataGrid: BeakerXDataGrid); + destroy(): void; + setInitialSize(): void; + resize(): void; + updateWidgetHeight(): void; + updateWidgetWidth(): void; + setInitialSectionWidths(): void; + setInitialSectionWidth(section: any, region: DataModel.ColumnRegion): void; + fillEmptyDataGridSpace(): void; + updateColumnWidth(region: ColumnRegion): Function; + startResizing(event: MouseEvent): void; + stopResizing(): void; + isResizing(): boolean; + shouldResizeDataGrid(event: MouseEvent): boolean; + setResizeMode(event: MouseEvent): void; + setCursorStyle(cursor: 'auto' | 'ew-resize' | 'ns-resize' | 'nwse-resize'): void; + private fillEmptySpaceResizeFn(region, value); + private getDataGridResizeConfig(event); + private handleMouseMove(event); + private getResizedWidth(event); + private getResizedHeight(event); + private handleMouseUp(event); + private captureEvent(event); + private getWidgetHeight(); + private resizeSections(); + private resizeSectionWidth(column); + private resizeHeader(); + private setBaseRowSize(); + private getSectionWidth(column); + private setSectionWidth(area, column, value); + private installMessageHook(); + private viewportResizeMessageHook(handler, msg); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/DataGridScope.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/DataGridScope.d.ts new file mode 100644 index 0000000000..d80e32f2d5 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/DataGridScope.d.ts @@ -0,0 +1,22 @@ +import IDataGridScopeOptions from "./interface/IDataGridScopeOptions"; +import DataGridContextMenu from "./contextMenu/DataGridContextMenu"; +import ColumnLimitModal from "./modal/ColumnLimitModal"; +import IDataModelState from "./interface/IDataGridModelState"; +export declare class DataGridScope { + contextMenu: DataGridContextMenu; + private element; + private store; + private dataGrid; + private tableDisplayModel; + private tableDisplayView; + constructor(options: IDataGridScopeOptions); + readonly state: IDataModelState; + render(): void; + doDestroy(): void; + updateModelData(newData: any): void; + doResetAll(): void; + connectToCommSignal(): void; + createContextMenu(): void; + initColumnLimitModal(): ColumnLimitModal; + setInitialSize(): void; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/BeakerXCellRenderer.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/BeakerXCellRenderer.d.ts new file mode 100644 index 0000000000..3bc4721cd4 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/BeakerXCellRenderer.d.ts @@ -0,0 +1,39 @@ +import { CellRenderer, GraphicsContext, TextRenderer } from "@phosphor/datagrid"; +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import { BeakerXDataStore } from "../store/BeakerXDataStore"; +import IRenderer from "../interface/IRenderer"; +export interface ICellRendererOptions { + font?: string; + color?: string; + text?: any; + vAlign?: string; + hAlign?: string; + boxHeight?: number; + textHeight?: number; +} +export default abstract class BeakerXCellRenderer extends TextRenderer { + store: BeakerXDataStore; + dataGrid: BeakerXDataGrid; + backgroundColor: CellRenderer.ConfigOption; + horizontalAlignment: CellRenderer.ConfigOption; + format: TextRenderer.FormatFunc; + font: CellRenderer.ConfigOption; + textColor: CellRenderer.ConfigOption; + constructor(dataGrid: BeakerXDataGrid, options?: TextRenderer.IOptions); + abstract drawText(gc: GraphicsContext, config: CellRenderer.ICellConfig): void; + drawBackground(gc: GraphicsContext, config: CellRenderer.ICellConfig): void; + drawTextUnderline(gc: GraphicsContext, textConfig: any, config: any): void; + getBackgroundColor(config: CellRenderer.ICellConfig): string; + getHorizontalAlignment(config: CellRenderer.ICellConfig): string; + getFormat(config: CellRenderer.ICellConfig): any; + getFont({region}: { + region: any; + }): string; + getTextColor(config: any): string; + getRenderer(config: CellRenderer.ICellConfig): IRenderer | undefined; + getOptions(config: CellRenderer.ICellConfig): ICellRendererOptions; + getTextPosition(config: CellRenderer.ICellConfig, options: ICellRendererOptions, isHeaderCell?: boolean): { + textX: number; + textY: number; + }; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/CellFocusManager.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellFocusManager.d.ts new file mode 100644 index 0000000000..f9de9fd786 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellFocusManager.d.ts @@ -0,0 +1,19 @@ +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import { ICellData } from "../interface/ICell"; +import { CellRenderer } from "@phosphor/datagrid"; +export default class CellFocusManager { + dataGrid: BeakerXDataGrid; + focusedCellData: ICellData | null; + constructor(dataGrid: BeakerXDataGrid); + destroy(): void; + setFocusedCell(cellData: ICellData | null): void; + setFocusedCellByNavigationKey(keyCode: number): void; + getFocussedCellBackground(config: CellRenderer.ICellConfig): string; + private setRightFocusedCell(); + private setLeftFocusedCell(); + private setUpFocusedCell(moveBy?); + private setDownFocusedCell(moveBy?); + private setPageUpFocusedCell(); + private setPageDownFocusedCell(); + private scrollIfNeeded(direction); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/CellManager.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellManager.d.ts new file mode 100644 index 0000000000..323bd94b3e --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellManager.d.ts @@ -0,0 +1,30 @@ +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import { IRangeCells } from "./CellSelectionManager"; +import { CellRenderer, DataModel } from "@phosphor/datagrid"; +import { ICellData } from "../interface/ICell"; +export interface ICellDataOptions { + row: number; + column: number; + value: any; + region: DataModel.CellRegion; +} +export default class CellManager { + dataGrid: BeakerXDataGrid; + hoveredCellData: ICellData; + static cellsEqual(cellData: ICellData, secondCellData: ICellData): boolean; + constructor(dataGrid: BeakerXDataGrid); + destroy(): void; + repaintRow(cellData: any): void; + setHoveredCellData(data: ICellData | null): void; + getSelectedCells(): any; + getAllCells(): any; + getCells(rowsRange: IRangeCells, columnsRange: IRangeCells): any; + copyToClipboard(): void; + CSVDownload(selectedOnly: any): void; + createCellConfig({row, column, value, region}: ICellDataOptions | ICellData): CellRenderer.ICellConfig; + private handleCellHovered(sender, {data}); + private updateViewportCursor(value); + private getCSVFromCells(selectedOnly); + private executeCopy(text); + private exportCellsTo(cells, format); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/CellRendererFactory.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellRendererFactory.d.ts new file mode 100644 index 0000000000..da901c7294 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellRendererFactory.d.ts @@ -0,0 +1,9 @@ +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import { ALL_TYPES } from "../dataTypes"; +import HTMLCellRenderer from "./HTMLCellRenderer"; +import HeaderCellRenderer from "./HeaderCellRenderer"; +import DefaultCellRenderer from "./DefaultCellRenderer"; +export declare class CellRendererFactory { + static getRenderer(dataGrid: BeakerXDataGrid, dataType?: ALL_TYPES): HTMLCellRenderer | DefaultCellRenderer; + static getHeaderRenderer(dataGrid: any): HeaderCellRenderer; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/CellSelectionManager.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellSelectionManager.d.ts new file mode 100644 index 0000000000..420a2e454e --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellSelectionManager.d.ts @@ -0,0 +1,31 @@ +import { CellRenderer } from "@phosphor/datagrid"; +import ICellConfig = CellRenderer.ICellConfig; +import { ICellData } from "../interface/ICell"; +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +export interface IRangeCells { + startCell: ICellData; + endCell: ICellData; +} +export default class CellSelectionManager { + selectedCellColor: string; + startCellData: ICellData | null; + endCellData: ICellData | null; + enabled: boolean; + dataGrid: BeakerXDataGrid; + constructor(dataGrid: BeakerXDataGrid); + destroy(): void; + setStartCell(cellData: ICellData): void; + setEndCell(cellData: ICellData): void; + getColumnsRangeCells(): IRangeCells | null; + getRowsRangeCells(): IRangeCells | null; + isBetweenRows(config: ICellConfig): boolean; + isBetweenColumns(config: ICellConfig): boolean; + enable(): void; + clear(): void; + isSelected(config: ICellConfig): boolean; + getBackgroundColor(config: any): string; + handleMouseDown(event: MouseEvent): void; + handleBodyCellHover(event: MouseEvent): void; + handleMouseUp(event: MouseEvent): void; + handleCellInteraction(data: ICellData): void; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/CellTooltip.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellTooltip.d.ts new file mode 100644 index 0000000000..029e15ba8c --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellTooltip.d.ts @@ -0,0 +1,10 @@ +export default class CellTooltip { + timeoutId: number; + node: HTMLElement; + container: HTMLElement; + static TOOLTIP_ANIMATION_DELAY: number; + constructor(text: string, container: HTMLElement); + destroy(): void; + show(x: number, y: number): void; + hide(): void; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/CellTooltipManager.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellTooltipManager.d.ts new file mode 100644 index 0000000000..7d468413cc --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellTooltipManager.d.ts @@ -0,0 +1,20 @@ +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import { ICellData } from "../interface/ICell"; +import CellTooltip from "./CellTooltip"; +export default class CellTooltipManager { + activeTooltips: CellTooltip[]; + dataGrid: BeakerXDataGrid; + tooltips: string[][]; + lastData: ICellData; + hasIndex: boolean; + constructor(dataGrid: BeakerXDataGrid); + destroy(): void; + hideTooltips(): void; + handleCellHovered(sender: BeakerXDataGrid, {data}: { + data: any; + }): void; + private shouldShowTooltip(data); + private shouldShowBodyTooltip(data); + private showTooltip(data); + private getTooltipText(data); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/DataGridCell.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/DataGridCell.d.ts new file mode 100644 index 0000000000..e76aeeae58 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/DataGridCell.d.ts @@ -0,0 +1,14 @@ +import { CellRenderer } from "@phosphor/datagrid"; +import { ICellData } from "../interface/ICell"; +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import ICellConfig = CellRenderer.ICellConfig; +export default class DataGridCell { + static isHeaderCell(config: CellRenderer.ICellConfig | ICellData): boolean; + static getCellData(dataGrid: BeakerXDataGrid, clientX: number, clientY: number): ICellData | null; + static dataEquals(data1: ICellData, data2: ICellData): boolean; + static isCellHovered(hoveredCell: ICellData, comparedCell: ICellData | ICellConfig): boolean; + static findHoveredRowIndex(dataGrid: BeakerXDataGrid, y: number): { + index: number; + delta: number; + }; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/DefaultCellRenderer.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/DefaultCellRenderer.d.ts new file mode 100644 index 0000000000..0cd6182d37 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/DefaultCellRenderer.d.ts @@ -0,0 +1,5 @@ +import { CellRenderer, GraphicsContext } from "@phosphor/datagrid"; +import BeakerXCellRenderer from "./BeakerXCellRenderer"; +export default class DefaultCellRenderer extends BeakerXCellRenderer { + drawText(gc: GraphicsContext, config: CellRenderer.ICellConfig): void; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/HTMLCellRenderer.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/HTMLCellRenderer.d.ts new file mode 100644 index 0000000000..6bdc2a2bd7 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/HTMLCellRenderer.d.ts @@ -0,0 +1,11 @@ +import { CellRenderer, GraphicsContext, TextRenderer } from "@phosphor/datagrid"; +import BeakerXCellRenderer from "./BeakerXCellRenderer"; +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +export default class HTMLCellRenderer extends BeakerXCellRenderer { + dataCache: any; + constructor(dataGrid: BeakerXDataGrid, options?: TextRenderer.IOptions); + drawText(gc: GraphicsContext, config: CellRenderer.ICellConfig): void; + getFontFaceStyle(): string; + getSVGData(text: string, config: CellRenderer.ICellConfig, vAlign: any, hAlign: any): string; + getCacheKey(config: any, vAlign: any, hAlign: any): string; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/HeaderCellRenderer.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/HeaderCellRenderer.d.ts new file mode 100644 index 0000000000..5bb5516a9a --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/HeaderCellRenderer.d.ts @@ -0,0 +1,6 @@ +import { CellRenderer, GraphicsContext } from "@phosphor/datagrid"; +import BeakerXCellRenderer from "./BeakerXCellRenderer"; +export default class HeaderCellRenderer extends BeakerXCellRenderer { + getBackgroundColor(config: CellRenderer.ICellConfig): string; + drawText(gc: GraphicsContext, config: CellRenderer.ICellConfig): void; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnFilter.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnFilter.d.ts new file mode 100644 index 0000000000..11b4c940e4 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnFilter.d.ts @@ -0,0 +1,39 @@ +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import DataGridColumn from "./DataGridColumn"; +import { Widget } from "@phosphor/widgets"; +export declare const FILTER_INPUT_TOOLTIP = "filter with an expression with a variable defined for each column and $ means the current column. eg \"$ > 5\"."; +export declare const SEARCH_INPUT_TOOLTIP = "search for a substring, show only matching rows."; +export default class ColumnFilter { + dataGrid: BeakerXDataGrid; + column: DataGridColumn; + filterWidget: Widget; + filterNode: HTMLElement; + filterIcon: HTMLSpanElement; + clearIcon: HTMLSpanElement; + filterInput: HTMLInputElement; + useSearch: boolean; + static getColumnNameVarPrefix(columnName: any): "" | "col_"; + static escapeColumnName(columnName: string): string; + constructor(dataGrid: BeakerXDataGrid, column: DataGridColumn, options: { + x; + y; + width; + height; + }); + showSearchInput(shouldFocus: boolean): void; + showFilterInput(shouldFocus: boolean): void; + hideInput(): void; + updateInputNode(): void; + attach(node: HTMLElement): void; + blur(): void; + destroy(): void; + private updateInputPosition(); + private showInput(shouldFocus); + private filterHandler(event); + private createExpression(value); + private createFilterExpression(value); + private createSearchExpression(value); + private addInputNode(options); + private bindEvents(); + private getInputHeight(); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnManager.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnManager.d.ts new file mode 100644 index 0000000000..7c6febe3d2 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnManager.d.ts @@ -0,0 +1,62 @@ +import DataGridColumn from "./DataGridColumn"; +import { CellRenderer, DataModel } from "@phosphor/datagrid"; +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import { Signal } from '@phosphor/signaling'; +import { ICellData } from "../interface/ICell"; +import { IColumnPosition, IColumns } from "../interface/IColumn"; +import { BeakerXDataStore } from "../store/BeakerXDataStore"; +import { COLUMN_TYPES, SORT_ORDER } from "./enums"; +import CellRegion = DataModel.CellRegion; +import ICellConfig = CellRenderer.ICellConfig; +export interface IBkoColumnsChangedArgs { + type: COLUMN_CHANGED_TYPES; + value: any; + column: DataGridColumn; +} +export declare enum COLUMN_CHANGED_TYPES { + 'columnSort' = 0, +} +export default class ColumnManager { + store: BeakerXDataStore; + dataGrid: BeakerXDataGrid; + columns: IColumns; + columnsChanged: Signal; + constructor(dataGrid: BeakerXDataGrid); + static createPositionFromCell(config: ICellConfig | ICellData): IColumnPosition; + static getColumnRegionByCell(config: ICellConfig | ICellData | { + region: CellRegion; + }): DataModel.ColumnRegion; + readonly bodyColumns: DataGridColumn[]; + readonly indexColumns: DataGridColumn[]; + readonly bodyColumnNames: string[]; + readonly indexColumnNames: string[]; + addColumns(): void; + getColumn(config: CellRenderer.ICellConfig): DataGridColumn; + getColumnByIndex(columnType: COLUMN_TYPES, index: number): DataGridColumn; + getColumnByPosition(position: IColumnPosition): DataGridColumn; + getColumnByName(columnName: string): DataGridColumn | undefined; + destroy(): void; + sortByColumn(column: DataGridColumn, sortOrder: SORT_ORDER): void; + resetFilters(): void; + showFilters(column?: DataGridColumn): void; + showSearch(column?: DataGridColumn): void; + blurColumnFilterInputs(): void; + updateColumnFilterNodes(): void; + updateColumnMenuTriggers(): void; + takeColumnsByCells(startCell: ICellData, endCell: ICellData): any[]; + takeColumnByCell(cellData: ICellData): DataGridColumn | null; + showAllColumns(): void; + resetColumnsAlignment(): void; + resetColumnPositions(): void; + resetColumnStates(): void; + setColumnsDataTypePrecission(precission: number): void; + recalculateMinMaxValues(): void; + createColumnMenus(): void; + private recalculateColumnsMinMax(columns); + private showFilterInputs(useSearch, column?); + private addBodyColumns(); + private addIndexColumns(); + private addColumn(name, index, type); + private createColumnsMap(); + private destroyAllColumns(); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnPosition.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnPosition.d.ts new file mode 100644 index 0000000000..cc1b36ac79 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnPosition.d.ts @@ -0,0 +1,31 @@ +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import { ICellData } from "../interface/ICell"; +import { BeakerXDataStore } from "../store/BeakerXDataStore"; +import DataGridColumn from "./DataGridColumn"; +import { IColumnPosition } from "../interface/IColumn"; +export default class ColumnPosition { + dataGrid: BeakerXDataGrid; + store: BeakerXDataStore; + grabbedCellData: ICellData | null; + dropCellData: ICellData | null; + draggableHeaderCanvas: HTMLCanvasElement; + draggableHeaderOffsetLeft: number | null; + dragStartTimeoutId: number; + constructor(dataGrid: BeakerXDataGrid); + destroy(): void; + startDragging(data: ICellData): void; + stopDragging(): void; + isDragging(): boolean; + reset(): void; + getColumnByPosition(position: IColumnPosition): DataGridColumn; + dropColumn(): void; + setPosition(column: DataGridColumn, position: IColumnPosition): void; + updateAll(): void; + moveDraggedHeader(event: MouseEvent): boolean; + private debounceDragStart(data); + private handleDragStart(data); + private moveColumn(); + private toggleGrabbing(enable); + private attachDraggableHeader(data); + private handleCellHovered(sender, {data, event}); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnValuesIterator.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnValuesIterator.d.ts new file mode 100644 index 0000000000..c93de22979 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnValuesIterator.d.ts @@ -0,0 +1,4 @@ +export declare namespace ColumnValuesIterator { + function longestString(valueResolver: Function): (a: any, b: any) => 0 | 1 | -1; + function minMax(valueResolver: Function): (a: any, b: any) => 0 | 1 | -1; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/column/DataGridColumn.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/column/DataGridColumn.d.ts new file mode 100644 index 0000000000..b147fe0478 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/DataGridColumn.d.ts @@ -0,0 +1,78 @@ +import ColumnMenu from "../headerMenu/ColumnMenu"; +import IndexMenu from "../headerMenu/IndexMenu"; +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import { IColumnOptions } from "../interface/IColumn"; +import { CellRenderer, DataModel, TextRenderer } from "@phosphor/datagrid"; +import { ALL_TYPES } from "../dataTypes"; +import { HIGHLIGHTER_TYPE } from "../interface/IHighlighterState"; +import ColumnManager from "./ColumnManager"; +import ColumnFilter from "./ColumnFilter"; +import { BeakerXDataStore } from "../store/BeakerXDataStore"; +import { COLUMN_TYPES, SORT_ORDER } from "./enums"; +import Highlighter from "../highlighter/Highlighter"; +export default class DataGridColumn { + index: number; + name: string; + type: COLUMN_TYPES; + menu: ColumnMenu | IndexMenu; + dataGrid: BeakerXDataGrid; + store: BeakerXDataStore; + columnManager: ColumnManager; + columnFilter: ColumnFilter; + formatFn: CellRenderer.ConfigFunc; + minValue: any; + maxValue: any; + longestStringValue: string; + constructor(options: IColumnOptions, dataGrid: BeakerXDataGrid, columnManager: ColumnManager); + static getColumnTypeByRegion(region: DataModel.CellRegion, position: number): COLUMN_TYPES; + assignFormatFn(): void; + createMenu(): void; + addColumnFilter(): void; + setDisplayType(displayType: ALL_TYPES | string): void; + setTimeDisplayType(timeUnit: any): void; + hide(): void; + show(): void; + search(filter: string): void; + filter(filter: string, search?: boolean): void; + resetFilter(): void; + connectToColumnsChanged(): void; + connectToCellHovered(): void; + handleHeaderCellHovered(sender: BeakerXDataGrid, {data}: { + data: any; + }): void; + getAlignment(): any; + setAlignment(horizontalAlignment: TextRenderer.HorizontalAlignment): void; + resetAlignment(): void; + setWidth(width: number): void; + getState(): any; + getVisible(): boolean; + getDataType(): any; + getSortOrder(): any; + getFilter(): any; + getKeepTrigger(): any; + getDataTypeName(): string; + getDisplayType(): any; + getFormatForTimes(): any; + getPosition(): any; + getRenderer(): any; + getHighlighter(highlighterType: HIGHLIGHTER_TYPE): Highlighter[]; + toggleHighlighter(highlighterType: HIGHLIGHTER_TYPE): void; + resetHighlighters(): void; + sort(sortOrder: SORT_ORDER): void; + toggleSort(): void; + getValueResolver(): Function; + move(destination: number): void; + setDataTypePrecission(precission: number): void; + addMinMaxValues(): void; + resetState(): void; + destroy(): void; + toggleDataBarsRenderer(enable?: boolean): void; + isFrozen(): boolean; + toggleColumnFrozen(): void; + recalculateLongestStringValue(displayType: ALL_TYPES | string): void; + private resizeHTMLRows(valuesIterator); + private updateColumnFilter(filter); + private toggleVisibility(value); + private onColumnsChanged(sender, args); + private setColumnSortOrder(order); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/column/columnAlignment.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/column/columnAlignment.d.ts new file mode 100644 index 0000000000..a40b12c8c6 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/columnAlignment.d.ts @@ -0,0 +1,19 @@ +import { TextRenderer } from "@phosphor/datagrid"; +export declare const LEFT: TextRenderer.HorizontalAlignment; +export declare const RIGHT: TextRenderer.HorizontalAlignment; +export declare const CENTER: TextRenderer.HorizontalAlignment; +export declare const DEFAULT_ALIGNMENT: "left"; +export declare const ALIGNMENTS_BY_TYPE: { + 'datetime': "center"; + 'time': "center"; + 'integer': "right"; + 'int64': "right"; + 'double': "right"; +}; +export declare const ALIGNMENTS_BY_CHAR: { + 'C': "center"; + 'R': "right"; + 'L': "left"; +}; +export declare const getAlignmentByType: (type: number) => "left" | "right" | "center"; +export declare const getAlignmentByChar: (char: string) => "left" | "right" | "center"; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/column/enums.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/column/enums.d.ts new file mode 100644 index 0000000000..6083e8af95 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/enums.d.ts @@ -0,0 +1,13 @@ +export declare enum COLUMN_TYPES { + index = 0, + body = 1, +} +export declare enum SORT_ORDER { + ASC = 0, + DESC = 1, + NO_SORT = 2, +} +export declare enum COLUMN_SIDE { + left = 0, + right = 1, +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/column/reducer.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/column/reducer.d.ts new file mode 100644 index 0000000000..8ad7e66b97 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/reducer.d.ts @@ -0,0 +1,16 @@ +import { Reducer } from "@phosphor/datastore"; +import { IColumnsState } from "../interface/IColumn"; +export declare const UPDATE_COLUMNS_STATES = "UPDATE_COLUMNS_STATES"; +export declare const UPDATE_COLUMN_STATE = "UPDATE_COLUMNS_STATE"; +export declare const UPDATE_COLUMN_POSITIONS = "UPDATE_COLUMN_POSITIONS"; +export declare const UPDATE_COLUMNS_TYPES = "UPDATE_COLUMNS_TYPES"; +export declare const UPDATE_COLUMNS_NAMES = "UPDATE_COLUMNS_NAMES"; +export declare const UPDATE_COLUMNS_FILTERS = "UPDATE_COLUMNS_FILTERS"; +export declare const UPDATE_COLUMN_FILTER = "UPDATE_COLUMN_FILTER"; +export declare const UPDATE_COLUMN_HORIZONTAL_ALIGNMENT = "UPDATE_COLUMN_HORIZONTAL_ALIGNMENT"; +export declare const UPDATE_COLUMN_FORMAT_FOR_TIMES = "UPDATE_COLUMN_FORMAT_FOR_TIMES"; +export declare const UPDATE_COLUMN_DISPLAY_TYPE = "UPDATE_COLUMN_DISPLAY_TYPE"; +export declare const UPDATE_COLUMN_SORT_ORDER = "UPDATE_COLUMN_SORT_ORDER"; +export declare const UPDATE_COLUMN_WIDTH = "UPDATE_COLUMN_WIDTH"; +declare const columnReducer: Reducer; +export default columnReducer; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/column/selectors.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/column/selectors.d.ts new file mode 100644 index 0000000000..495c2d4da1 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/selectors.d.ts @@ -0,0 +1,41 @@ +/// +import { IBeakerXDataGridState } from "../store/BeakerXDataStore"; +import { IColumnPosition, IColumnState } from "../interface/IColumn"; +export declare const selectColumnStates: (state: IBeakerXDataGridState) => Map; +export declare const selectColumnStatesArray: ((state: IBeakerXDataGridState) => any) & { + resultFunc: (res: Map) => any; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectBodyColumnStates: ((state: IBeakerXDataGridState) => any) & { + resultFunc: (res: any) => any; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectVisibleBodyColumns: ((state: any) => any) & { + resultFunc: (res1: any, res2: {}, res3: string[]) => any; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectColumnStateByKey: (state: any, key: any) => any; +export declare const selectColumnState: (state: IBeakerXDataGridState, column: any) => any; +export declare const selectColumnDataTypeName: ((state: IBeakerXDataGridState, props: any, ...args: any[]) => any) & { + resultFunc: (res: any) => any; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectColumnHorizontalAlignment: (state: IBeakerXDataGridState, column: any) => any; +export declare const selectColumnDisplayType: (state: IBeakerXDataGridState, column: any) => any; +export declare const selectColumnFilter: (state: IBeakerXDataGridState, column: any) => any; +export declare const selectColumnDataType: (state: IBeakerXDataGridState, column: any) => any; +export declare const selectColumnSortOrder: (state: IBeakerXDataGridState, column: any) => any; +export declare const selectColumnKeepTrigger: (state: IBeakerXDataGridState, column: any) => any; +export declare const selectColumnFormatForTimes: (state: IBeakerXDataGridState, column: any) => any; +export declare const selectColumnWidth: (state: IBeakerXDataGridState, column: any) => any; +export declare const selectColumnPosition: (state: IBeakerXDataGridState, column: any) => any; +export declare const selectColumnIndexByPosition: ((state: any, props: IColumnPosition, ...args: any[]) => number) & { + resultFunc: (res1: any, res2: IColumnPosition) => number; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectOutputColumnLimit: (state: IBeakerXDataGridState) => any; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/consts.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/consts.d.ts new file mode 100644 index 0000000000..10c908ba23 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/consts.d.ts @@ -0,0 +1,127 @@ +export declare const scopeData: { + allStringTypes: { + type: number; + name: string; + }[]; + allTimeTypes: { + type: number; + name: string; + }[]; + allIntTypes: { + type: number; + name: string; + }[]; + allDoubleTypes: { + type: number; + name: string; + }[]; + allBoolTypes: { + type: number; + name: string; + }[]; + allTypes: { + type: number; + name: string; + }[]; + rowsToDisplayMenu: (string | number)[][]; + allPrecissions: number[]; +}; +export declare const CELL_TYPE = "bko-tabledisplay"; +export declare const ROW_HEIGHT = 27; +export declare const ROW_HEIGHT_ADVANCED_MODE = 22; +export declare const DEFAULT_PAGE_LENGTH = 25; +export declare const MIN_ROWS_FOR_PAGING = 25; +export declare const FC_LEFT_SEPARATOR_CLASS = "left-fix-col-separator"; +export declare const FC_RIGHT_SEPARATOR_CLASS = "right-fix-col-separator"; +export declare const FC_COL_FIXED_CLASS = "fix-col-fixed"; +export declare const TIME_UNIT_FORMATS: { + DATETIME: { + title: string; + format: string; + }; + DAYS: { + title: string; + format: string; + }; + HOURS: { + title: string; + format: string; + }; + MINUTES: { + title: string; + format: string; + }; + SECONDS: { + title: string; + format: string; + }; + MILLISECONDS: { + title: string; + format: string; + }; +}; +declare const _default: { + scopeData: { + allStringTypes: { + type: number; + name: string; + }[]; + allTimeTypes: { + type: number; + name: string; + }[]; + allIntTypes: { + type: number; + name: string; + }[]; + allDoubleTypes: { + type: number; + name: string; + }[]; + allBoolTypes: { + type: number; + name: string; + }[]; + allTypes: { + type: number; + name: string; + }[]; + rowsToDisplayMenu: (string | number)[][]; + allPrecissions: number[]; + }; + CELL_TYPE: string; + ROW_HEIGHT: number; + ROW_HEIGHT_ADVANCED_MODE: number; + DEFAULT_PAGE_LENGTH: number; + MIN_ROWS_FOR_PAGING: number; + FC_LEFT_SEPARATOR_CLASS: string; + FC_RIGHT_SEPARATOR_CLASS: string; + FC_COL_FIXED_CLASS: string; + TIME_UNIT_FORMATS: { + DATETIME: { + title: string; + format: string; + }; + DAYS: { + title: string; + format: string; + }; + HOURS: { + title: string; + format: string; + }; + MINUTES: { + title: string; + format: string; + }; + SECONDS: { + title: string; + format: string; + }; + MILLISECONDS: { + title: string; + format: string; + }; + }; +}; +export default _default; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/contextMenu/DataGridContextMenu.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/contextMenu/DataGridContextMenu.d.ts new file mode 100644 index 0000000000..84781f8301 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/contextMenu/DataGridContextMenu.d.ts @@ -0,0 +1,6 @@ +import BkoContextMenu from '../../../contextMenu/BkoContextMenu'; +import { DataGridScope } from "../DataGridScope"; +export default class DataGridContextMenu extends BkoContextMenu { + constructor(scope: DataGridScope); + protected buildMenu(): void; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/contextMenu/createCellContextMenuItems.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/contextMenu/createCellContextMenuItems.d.ts new file mode 100644 index 0000000000..ac58df2721 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/contextMenu/createCellContextMenuItems.d.ts @@ -0,0 +1,4 @@ +import MenuItem from '../../../shared/interfaces/contextMenuItemInterface'; +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import DataGridContextMenu from "./DataGridContextMenu"; +export default function createCellContextMenuItems(dataGrid: BeakerXDataGrid, contextMenu: DataGridContextMenu): MenuItem[]; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/contextMenu/createHeaderContextMenuItems.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/contextMenu/createHeaderContextMenuItems.d.ts new file mode 100644 index 0000000000..12c71a2b2f --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/contextMenu/createHeaderContextMenuItems.d.ts @@ -0,0 +1,4 @@ +import MenuItem from '../../../shared/interfaces/contextMenuItemInterface'; +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import DataGridContextMenu from "./DataGridContextMenu"; +export default function createHeaderContextMenuItems(dataGrid: BeakerXDataGrid, contextMenu: DataGridContextMenu): MenuItem[]; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/dataGridHelpers.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/dataGridHelpers.d.ts new file mode 100644 index 0000000000..b56c046047 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/dataGridHelpers.d.ts @@ -0,0 +1,30 @@ +import { SectionList } from "@phosphor/datagrid/lib/sectionlist"; +import DataGridColumn from "./column/DataGridColumn"; +export declare namespace DataGridHelpers { + function escapeHTML(text: any): any; + function truncateString(text: any, limit?: number): string; + function disableKeyboardManager(): void; + function enableKeyboardManager(): void; + function enableNotebookEditMode(): void; + function getStringSize(value: any, fontSize: Number | null | undefined): { + width: number; + height: number; + }; + function findSectionIndex(list: SectionList, cursorPosition: number): { + index: number; + delta: number; + } | null; + function throttle(func: Function, limit: number, context?: any, controllObject?: { + timerId: number; + }): (T) => U | undefined; + function debounce(f: (a: A) => void, delay: number, controllObject?: { + timerId: number; + }): (a: A) => void; + function isUrl(url: string): boolean; + function retrieveUrl(text: string): string | null; + function getEventKeyCode(event: KeyboardEvent): any; + function sortColumnsByPositionCallback(columnA: DataGridColumn, columnB: DataGridColumn): number; + function applyTimezone(timestamp: any, tz: any): any; + function formatTimestamp(timestamp: any, tz: any, format: any): any; + function hasUpperCaseLetter(value: string): boolean; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/dataTypes.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/dataTypes.d.ts new file mode 100644 index 0000000000..86956a626e --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/dataTypes.d.ts @@ -0,0 +1,22 @@ +export declare enum ALL_TYPES { + 'string' = 0, + 'integer' = 1, + 'formatted integer' = 2, + 'double' = 3, + 'double with precision' = 4, + 'exponential 5' = 6, + 'exponential 15' = 7, + 'datetime' = 8, + 'boolean' = 9, + 'html' = 10, + 'int64' = 11, + 'time' = 12, +} +export declare const getTypeByName: (typeName: string) => number; +export declare function getDisplayType(type: ALL_TYPES, stringFormatForType?: any, stringFormatForColumn?: any): string | ALL_TYPES.string | ALL_TYPES.formatted integer | ALL_TYPES.double | ALL_TYPES.datetime; +export declare function isDoubleWithPrecision(type: string | number): boolean; +export declare function getDoublePrecisionByType(type: string | number): string; +export declare function getAllowedTypesByType(type: any): { + type: number; + name: string; +}[]; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/event/EventManager.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/event/EventManager.d.ts new file mode 100644 index 0000000000..c921e098b6 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/event/EventManager.d.ts @@ -0,0 +1,39 @@ +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import { BeakerXDataStore } from "../store/BeakerXDataStore"; +export default class EventManager { + dataGrid: BeakerXDataGrid; + store: BeakerXDataStore; + cellHoverControll: { + timerId: any; + }; + constructor(dataGrid: BeakerXDataGrid); + handleEvent(event: Event, parentHandler: Function): void; + isOverHeader(event: MouseEvent): boolean; + destroy(): void; + handleMouseMoveOutsideArea(event: MouseEvent): void; + private handleSelectStart(event); + private handleScrollBarMouseUp(event); + private handleWindowResize(event); + private handleMouseUp(event); + private dropColumn(); + private handleBodyClick(event); + private handleMouseMove(event); + private isOutsideViewport(event); + private isOutsideGrid(event); + private handleCellHover(event); + private handleMouseDown(event); + private handleStartDragging(event); + private handleMouseOut(event); + private isNodeInsideGrid(event); + private handleMouseWheel(event, parentHandler); + private handleHeaderClick(event); + private isHeaderClicked(event); + private handleKeyDown(event); + private handleHighlighterKeyDown(code, column); + private handleEnterKeyDown(code, shiftKey, cellData); + private handleNavigationKeyDown(code, event); + private handleNumKeyDown(code, shiftKey, column); + private handleDoubleClick(event); + private removeEventListeners(); + private clearReferences(); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/event/enums.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/event/enums.d.ts new file mode 100644 index 0000000000..728e36e351 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/event/enums.d.ts @@ -0,0 +1,23 @@ +export declare enum KEYBOARD_KEYS { + KeyB = 66, + KeyH = 72, + KeyU = 85, + ArrowLeft = 37, + ArrowUp = 38, + ArrowRight = 39, + ArrowDown = 40, + PageUp = 33, + PageDown = 34, + Digit0 = 48, + Digit1 = 49, + Digit2 = 50, + Digit3 = 51, + Digit4 = 52, + Digit5 = 53, + Digit6 = 54, + Digit7 = 55, + Digit8 = 56, + Digit9 = 57, + Escape = 27, + Enter = 13, +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/event/helpers.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/event/helpers.d.ts new file mode 100644 index 0000000000..5b37df29ae --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/event/helpers.d.ts @@ -0,0 +1,4 @@ +export declare namespace EventHelpers { + function isOutsideNode(event: MouseEvent, node: HTMLElement): boolean; + function isInsideGridNode(event: MouseEvent, gridNode: HTMLElement): boolean | Element; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/BkoMenu.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/BkoMenu.d.ts new file mode 100644 index 0000000000..a6868da376 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/BkoMenu.d.ts @@ -0,0 +1,11 @@ +import { Menu } from '@phosphor/widgets'; +import { Message } from '@phosphor/messaging'; +export default class BkoMenu extends Menu { + keepOpen: boolean | undefined; + trigger: HTMLElement; + dispose(): void; + triggerActiveItem(): void; + protected onBeforeAttach(msg: Message): void; + protected onActivateRequest(msg: Message): void; + close(): void; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/ColumnMenu.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/ColumnMenu.d.ts new file mode 100644 index 0000000000..cf95af0fdd --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/ColumnMenu.d.ts @@ -0,0 +1,4 @@ +import HeaderMenu from "./HeaderMenu"; +export default class ColumnMenu extends HeaderMenu { + protected buildMenu(): void; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/HeaderMenu.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/HeaderMenu.d.ts new file mode 100644 index 0000000000..b4980fcebb --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/HeaderMenu.d.ts @@ -0,0 +1,44 @@ +import { CommandRegistry } from '@phosphor/commands'; +import { Widget } from '@phosphor/widgets'; +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import Menu from './BkoMenu'; +import MenuItem from '../../../shared/interfaces/menuItemInterface'; +import MenuInterface from '../../../shared/interfaces/menuInterface'; +import DataGridColumn from "../column/DataGridColumn"; +export default abstract class HeaderMenu implements MenuInterface { + columnIndex: number; + protected commands: CommandRegistry; + protected menu: Menu; + protected viewport: Widget; + protected triggerNode: HTMLElement; + protected dataGrid: BeakerXDataGrid; + protected column: DataGridColumn; + private TRIGGER_CLASS_OPENED; + private TRIGGER_CLASS_SORTING_DESC; + private TRIGGER_CLASS_SORTING_ASC; + static DEFAULT_TRIGGER_HEIGHT: number; + static DEFAULT_TRIGGER_WIDTH: number; + constructor(column: DataGridColumn); + protected abstract buildMenu(): void; + updateTriggerPosition(): void; + showTrigger(): void; + hideTrigger(): void; + attachTriggerToMenu(): void; + open(submenuIndex?: number): void; + destroy(): void; + toggleMenu(submenuIndex?: number): void; + createItems(items: MenuItem[], menu: Menu): void; + addCommand(menuItem: MenuItem, menu: Menu): string; + createSubmenu(menuItem: MenuItem, subitems: MenuItem[]): Menu; + protected assignTriggerSortingCssClass(): void; + protected addTrigger(): void; + private handleMenuTriggerClick(event); + protected getMenuPosition(trigger: any): { + top: any; + left: any; + }; + protected correctPosition(trigger: any): void; + protected handleKeydownEvent(event: KeyboardEvent): void; + protected addItemsFiltering(menu: Menu): void; + protected hideMenuItems(menu: Menu, filterValue: string): void; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/IndexMenu.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/IndexMenu.d.ts new file mode 100644 index 0000000000..e7ccf35ae5 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/IndexMenu.d.ts @@ -0,0 +1,4 @@ +import HeaderMenu from './HeaderMenu'; +export default class IndexMenu extends HeaderMenu { + protected buildMenu(): void; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/createColumnMenuItems.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/createColumnMenuItems.d.ts new file mode 100644 index 0000000000..0ec58def29 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/createColumnMenuItems.d.ts @@ -0,0 +1,3 @@ +import MenuItem from "../../../shared/interfaces/menuItemInterface"; +import DataGridColumn from "../column/DataGridColumn"; +export declare function createColumnMenuItems(column: DataGridColumn): MenuItem[]; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/createFormatMenuItems.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/createFormatMenuItems.d.ts new file mode 100644 index 0000000000..8ba1156e67 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/createFormatMenuItems.d.ts @@ -0,0 +1,5 @@ +import MenuItem from "../../../shared/interfaces/menuItemInterface"; +import DataGridColumn from "../column/DataGridColumn"; +export declare function createFormatMenuItems(column: DataGridColumn): MenuItem[]; +export declare function createPrecisionSubitems(column: DataGridColumn): MenuItem[]; +export declare function createTimeSubitems(): MenuItem[]; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/createIndexMenuItems.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/createIndexMenuItems.d.ts new file mode 100644 index 0000000000..2e95fa624d --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/createIndexMenuItems.d.ts @@ -0,0 +1,3 @@ +import MenuItem from '../../../shared/interfaces/menuItemInterface'; +import DataGridColumn from "../column/DataGridColumn"; +export declare function createIndexMenuItems(column: DataGridColumn): MenuItem[]; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/highlighter/HeatmapHighlighter.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/HeatmapHighlighter.d.ts new file mode 100644 index 0000000000..4fd59a5638 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/HeatmapHighlighter.d.ts @@ -0,0 +1,9 @@ +import Highlighter from "./Highlighter"; +import IHihglighterState from "../interface/IHighlighterState"; +import DataGridColumn from "../column/DataGridColumn"; +import { CellRenderer } from "@phosphor/datagrid"; +export default class HeatmapHighlighter extends Highlighter { + colorScale: Function; + constructor(column: DataGridColumn, state: IHihglighterState); + getBackgroundColor(config: CellRenderer.ICellConfig): any; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/highlighter/Highlighter.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/Highlighter.d.ts new file mode 100644 index 0000000000..7f7aef99a3 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/Highlighter.d.ts @@ -0,0 +1,13 @@ +import IHihglighterState from "../interface/IHighlighterState"; +import { CellRenderer } from "@phosphor/datagrid"; +import DataGridColumn from "../column/DataGridColumn"; +import { BeakerXDataGridModel } from "../model/BeakerXDataGridModel"; +export default class Highlighter { + column: DataGridColumn; + model: BeakerXDataGridModel; + state: IHihglighterState; + constructor(column: DataGridColumn, state: IHihglighterState); + getBackgroundColor(config: CellRenderer.ICellConfig): string; + getValueToHighlight(config: CellRenderer.ICellConfig): any; + destroy(): void; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/highlighter/HighlighterFactory.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/HighlighterFactory.d.ts new file mode 100644 index 0000000000..9199318abc --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/HighlighterFactory.d.ts @@ -0,0 +1,10 @@ +import IHihglighterState from "../interface/IHighlighterState"; +import HeatmapHighlighter from "./HeatmapHighlighter"; +import DataGridColumn from "../column/DataGridColumn"; +import UniqueEntriesHighlighter from "./UniqueEntriesHighlighter"; +import ValueHighlighter from "./ValueHighlighter"; +import SortHighlighter from "./SortHighlighter"; +export default class HighlighterFactory { + static defaultHighlighterState: IHihglighterState; + static getHighlighter(config: IHihglighterState, column: DataGridColumn): HeatmapHighlighter | UniqueEntriesHighlighter | ValueHighlighter | SortHighlighter; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/highlighter/HighlighterManager.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/HighlighterManager.d.ts new file mode 100644 index 0000000000..07e3ef214c --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/HighlighterManager.d.ts @@ -0,0 +1,23 @@ +/// +import IHihglighterState, { HIGHLIGHTER_TYPE } from "../interface/IHighlighterState"; +import Highlighter from "./Highlighter"; +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import { CellRenderer } from "@phosphor/datagrid"; +export default class HighlighterManager { + highlighters: Highlighter[]; + dataGrid: BeakerXDataGrid; + cachedHighlighters: Map; + constructor(dataGrid: BeakerXDataGrid); + destroy(): void; + createHighlighters(): void; + createHighlighter(state: IHihglighterState): void; + registerHighlighter(highlighter: Highlighter | null): void; + unregisterHighlighter(highlighter: Highlighter): void; + getColumnHighlighters(column: any, highlighterType?: HIGHLIGHTER_TYPE): Highlighter[]; + addColumnHighlighter(column: any, highlighterType: HIGHLIGHTER_TYPE): void; + removeColumnHighlighter(column: any, highlighterType?: HIGHLIGHTER_TYPE): void; + toggleColumnHighlighter(column: any, highlighterType: HIGHLIGHTER_TYPE): void; + removeHighlighters(): void; + getCellBackground(config: CellRenderer.ICellConfig): string; + private getHighlighterKey(column, highlighterType); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/highlighter/SortHighlighter.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/SortHighlighter.d.ts new file mode 100644 index 0000000000..46f14cbd12 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/SortHighlighter.d.ts @@ -0,0 +1,10 @@ +import IHihglighterState from "../interface/IHighlighterState"; +import DataGridColumn from "../column/DataGridColumn"; +import Highlighter from "./Highlighter"; +import { CellRenderer } from "@phosphor/datagrid"; +export default class SortHighlighter extends Highlighter { + oddRowColor: string; + evenRowColor: string; + constructor(column: DataGridColumn, state: IHihglighterState); + getBackgroundColor(config: CellRenderer.ICellConfig): string; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/highlighter/ThreeColorHeatmapHighlighter.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/ThreeColorHeatmapHighlighter.d.ts new file mode 100644 index 0000000000..ffc8db76bb --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/ThreeColorHeatmapHighlighter.d.ts @@ -0,0 +1,6 @@ +import IHihglighterState from "../interface/IHighlighterState"; +import DataGridColumn from "../column/DataGridColumn"; +import HeatmapHighlighter from "./HeatmapHighlighter"; +export default class ThreeColorHeatmapHighlighter extends HeatmapHighlighter { + constructor(column: DataGridColumn, state: IHihglighterState); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/highlighter/UniqueEntriesHighlighter.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/UniqueEntriesHighlighter.d.ts new file mode 100644 index 0000000000..260633b4df --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/UniqueEntriesHighlighter.d.ts @@ -0,0 +1,12 @@ +import Highlighter from "./Highlighter"; +import IHihglighterState from "../interface/IHighlighterState"; +import DataGridColumn from "../column/DataGridColumn"; +import { CellRenderer } from "@phosphor/datagrid"; +export default class UniqueEntriesHighlighter extends Highlighter { + uniqueValues: any[]; + uniqueColors: {}; + constructor(column: DataGridColumn, state: IHihglighterState); + getBackgroundColor(config: CellRenderer.ICellConfig): any; + generateUniqueValues(): void; + getColorGenerationFn(initialSaturationRatio?: number, initialLightnessRatio?: number): () => string; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/highlighter/ValueHighlighter.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/ValueHighlighter.d.ts new file mode 100644 index 0000000000..9c076e218d --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/ValueHighlighter.d.ts @@ -0,0 +1,8 @@ +import IHihglighterState from "../interface/IHighlighterState"; +import DataGridColumn from "../column/DataGridColumn"; +import Highlighter from "./Highlighter"; +import { CellRenderer } from "@phosphor/datagrid"; +export default class ValueHighlighter extends Highlighter { + constructor(column: DataGridColumn, state: IHihglighterState); + getBackgroundColor(config: CellRenderer.ICellConfig): any; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/index.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/index.d.ts new file mode 100644 index 0000000000..6423799783 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/index.d.ts @@ -0,0 +1 @@ +export * from './DataGridScope'; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/interface/ICell.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/interface/ICell.d.ts new file mode 100644 index 0000000000..50abfb5b79 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/interface/ICell.d.ts @@ -0,0 +1,13 @@ +import { COLUMN_TYPES } from "../column/enums"; +import { DataModel } from "@phosphor/datagrid/lib/datamodel"; +export interface ICellData { + type: COLUMN_TYPES; + column: number; + row: number; + delta: number; + offset: number; + offsetTop: number; + region?: DataModel.CellRegion; + value?: any; + width?: number; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/interface/IColumn.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/interface/IColumn.d.ts new file mode 100644 index 0000000000..f7cb41e6d0 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/interface/IColumn.d.ts @@ -0,0 +1,38 @@ +/// +import DataGridColumn from "../column/DataGridColumn"; +import { DataModel, TextRenderer } from "@phosphor/datagrid"; +import { ALL_TYPES } from "../dataTypes"; +import { COLUMN_TYPES, SORT_ORDER } from "../column/enums"; +export interface IColumn { + index: number; + type: COLUMN_TYPES; +} +export interface IColumnOptions { + index: number; + name: string; + type: COLUMN_TYPES; +} +export interface IColumns { + [key: number]: DataGridColumn[]; +} +export declare type IColumnsState = Map; +export interface IColumnState { + name: string; + index: number; + columnType: COLUMN_TYPES; + dataTypeName: string; + dataType: ALL_TYPES; + displayType: ALL_TYPES | string; + keepTrigger: boolean; + horizontalAlignment: TextRenderer.HorizontalAlignment; + formatForTimes: any; + sortOrder: SORT_ORDER; + filter: string | null; + position: IColumnPosition; + width?: number; + renderer?: number; +} +export interface IColumnPosition { + value: number; + region: DataModel.ColumnRegion; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/interface/IDataGridModelState.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/interface/IDataGridModelState.d.ts new file mode 100644 index 0000000000..ce98ee175d --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/interface/IDataGridModelState.d.ts @@ -0,0 +1,33 @@ +import IHihglighterState from "./IHighlighterState"; +export default interface IDataModelState { + alignmentForColumn?: {}; + alignmentForType?: {}; + cellHighlighters: IHihglighterState[]; + columnNames: string[]; + columnOrder: string[]; + columnsFrozen?: {}; + columnsFrozenRight?: {}; + columnsVisible: {}; + contextMenuItems?: string[]; + contextMenuTags?: {}; + dataFontSize?: number | null; + doubleClickTag?: string | null; + fontColor?: string[]; + hasDoubleClickAction?: boolean; + hasIndex: boolean; + headerFontSize?: number | null; + headersVertical?: boolean; + rendererForColumn?: {}; + rendererForType?: {}; + stringFormatForColumn: {}; + stringFormatForTimes?: string | null; + stringFormatForType?: {}; + subtype?: string; + timeZone?: string; + timeStrings?: any; + tooManyRows?: boolean; + tooltips: string[][]; + type?: string; + types: string[]; + values: any; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/interface/IDataGridScopeOptions.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/interface/IDataGridScopeOptions.d.ts new file mode 100644 index 0000000000..e81f62c146 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/interface/IDataGridScopeOptions.d.ts @@ -0,0 +1,7 @@ +import { DataGrid } from "@phosphor/datagrid"; +export default interface IDataGridScopeOptions extends DataGrid.IOptions { + element: HTMLElement; + data: any; + widgetModel: any; + widgetView: any; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/interface/IHighlighterState.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/interface/IHighlighterState.d.ts new file mode 100644 index 0000000000..6f86d0f7a3 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/interface/IHighlighterState.d.ts @@ -0,0 +1,23 @@ +export declare enum HIGHLIGHTER_STYLE { + SINGLE_COLUMN = "SINGLE_COLUMN", + FULL_ROW = "FULL_ROW", +} +export declare enum HIGHLIGHTER_TYPE { + heatmap = "HeatmapHighlighter", + uniqueEntries = "UniqueEntriesHighlighter", + threeColorHeatmap = "ThreeColorHeatmapHighlighter", + value = "ValueHighlighter", + sort = "SortHighlighter", +} +export default interface IHihglighterState { + colName: string; + maxColor: string | null; + maxVal: number | null; + minColor: string | null; + minVal: number | null; + midColor: string | null; + midVal: number | null; + style: HIGHLIGHTER_STYLE; + type: HIGHLIGHTER_TYPE; + colors: string[] | null; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/interface/IRenderer.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/interface/IRenderer.d.ts new file mode 100644 index 0000000000..e285585a9d --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/interface/IRenderer.d.ts @@ -0,0 +1,9 @@ +export declare enum RENDERER_TYPE { + DataBars = "DataBars", +} +export default interface IRenderer { + type: RENDERER_TYPE; + includeText: boolean; + percent?: number; + direction?: 'RIGHT' | 'LEFT'; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/modal/ColumnLimitModal.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/modal/ColumnLimitModal.d.ts new file mode 100644 index 0000000000..712fb53135 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/modal/ColumnLimitModal.d.ts @@ -0,0 +1,14 @@ +import '../../../global.env'; +import ColumnManager from "../column/ColumnManager"; +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import { BeakerXDataStore } from "../store/BeakerXDataStore"; +export default class ColumnLimitModal { + store: BeakerXDataStore; + columnManager: ColumnManager; + container: HTMLElement; + modalId: string; + constructor(dataGrid: BeakerXDataGrid, container: HTMLElement); + shouldOpenModal(): boolean; + init(): void; + bindEvents(modal: any): void; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/modal/columnLimitModalTemplate.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/modal/columnLimitModalTemplate.d.ts new file mode 100644 index 0000000000..a2ff9e714e --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/modal/columnLimitModalTemplate.d.ts @@ -0,0 +1 @@ +export default function createModalTemplate(outputColumnLimit: number, columnNumber: number): string; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/model/BeakerXDataGridModel.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/model/BeakerXDataGridModel.d.ts new file mode 100644 index 0000000000..75c3cca4b5 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/model/BeakerXDataGridModel.d.ts @@ -0,0 +1,38 @@ +import { DataModel } from "@phosphor/datagrid"; +import { ALL_TYPES } from '../dataTypes'; +import { DataFormatter } from '../DataFormatter'; +import IDataModelState from '../interface/IDataGridModelState'; +import { MapIterator } from '@phosphor/algorithm'; +import { IColumn } from "../interface/IColumn"; +import ColumnManager from "../column/ColumnManager"; +import RowManager from "../row/RowManager"; +import { BeakerXDataStore } from "../store/BeakerXDataStore"; +export declare class BeakerXDataGridModel extends DataModel { + store: BeakerXDataStore; + dataFormatter: DataFormatter; + columnManager: ColumnManager; + rowManager: RowManager; + headerRowsCount: number; + static DEFAULT_INDEX_COLUMN_TYPE: string; + private _data; + constructor(store: BeakerXDataStore, columnManager: ColumnManager, rowManager: RowManager); + destroy(): void; + reset(): void; + emitChanged(args: DataModel.ChangedArgs): void; + addProperties(store: BeakerXDataStore, columnManager: ColumnManager, rowManager: RowManager): void; + updateData(state: IDataModelState): void; + rowCount(region: DataModel.RowRegion): number; + columnCount(region: DataModel.ColumnRegion): number; + data(region: DataModel.CellRegion, row: number, position: number): any; + metadata(region: DataModel.CellRegion, position: number): DataModel.Metadata; + setState(state: any): void; + setFilterHeaderVisible(visible: boolean): void; + getColumnValuesIterator(column: IColumn): MapIterator; + setHeaderTextVertical(headersVertical: boolean): void; + getColumnValueResolver(dataType: ALL_TYPES): Function; + private htmlTextContentResolver(value); + private dateValueResolver(value); + private defaultValueResolver(value); + private doubleValueResolver(value); + private integerValueResolver(value); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/model/reducer.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/model/reducer.d.ts new file mode 100644 index 0000000000..201cb01a68 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/model/reducer.d.ts @@ -0,0 +1,13 @@ +import { Reducer } from "@phosphor/datastore"; +import IDataModelState from "../interface/IDataGridModelState"; +export declare const UPDATE_MODEL_DATA = "UPDATE_MODEL_DATA"; +export declare const UPDATE_COLUMN_RENDERER = "UPDATE_COLUMN_RENDERER"; +export declare const UPDATE_COLUMN_ORDER = "UPDATE_COLUMN_ORDER"; +export declare const UPDATE_COLUMN_FROZEN = "UPDATE_COLUMN_FROZEN"; +export declare const UPDATE_COLUMN_VISIBLE = "UPDATE_COLUMN_VISIBLE"; +export declare const UPDATE_COLUMNS_VISIBLE = "UPDATE_COLUMNS_VISIBLE"; +export declare const RESET_COLUMNS_ORDER = "RESET_COLUMNS_ORDER"; +export declare const ADD_COLUMN_HIGHLIGHTER = "ADD_COLUMN_HIGHLIGHTER"; +export declare const REMOVE_COLUMN_HIGHLIGHTER = "REMOVE_COLUMN_HIGHLIGHTER"; +declare const dataGridModelReducer: Reducer; +export default dataGridModelReducer; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/model/selectors/column.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/model/selectors/column.d.ts new file mode 100644 index 0000000000..650c841656 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/model/selectors/column.d.ts @@ -0,0 +1,69 @@ +import { IColumnPosition } from "../../interface/IColumn"; +import IHihglighterState from "../../interface/IHighlighterState"; +export declare const DEFAULT_INDEX_COLUMN_NAME = "index"; +export declare const selectColumnNames: ((state: any) => string[]) & { + resultFunc: (res: string[]) => string[]; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectBodyColumnNames: ((state: any) => string[]) & { + resultFunc: (res1: string[], res2: boolean) => string[]; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectColumnIndexByName: ((state: any, props: any, ...args: any[]) => number) & { + resultFunc: (res1: string[], res2: any) => number; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectIndexColumnNames: ((state: any) => string[]) & { + resultFunc: (res1: string[], res2: boolean) => string[]; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectColumnsFrozenNames: ((state: any) => string[]) & { + resultFunc: (res1: {}, res2: string[]) => string[]; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectColumnsFrozenCount: (state: any) => number; +export declare const selectIsColumnFrozen: ((state: any, props: any, ...args: any[]) => boolean) & { + resultFunc: (res1: string[], res2: any) => boolean; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectColumnVisible: ((state: any, props: any, ...args: any[]) => boolean) & { + resultFunc: (res1: {}, res2: string[], res3: any) => boolean; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectInitialColumnAlignment: ((state: any, props: any, ...args: any[]) => "left" | "right" | "center") & { + resultFunc: (res1: any, res2: any, res3: "left" | "right" | "center") => "left" | "right" | "center"; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectVisibleColumnsFrozenCount: ((state: any) => number) & { + resultFunc: (res1: string[], res2: {}) => number; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectColumnDataTypeByName: ((state: any, props: any, ...args: any[]) => any) & { + resultFunc: (res1: string[], res2: string[], res3: any) => any; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectInitialColumnPositions: ((state: any) => IColumnPosition[]) & { + resultFunc: (res1: string[], res2: string[], res3: {}, res4: boolean, res5: string[]) => IColumnPosition[]; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectRenderer: ((state: any, props: any, ...args: any[]) => any) & { + resultFunc: (res1: any, res2: any) => any; + recomputations: () => number; + resetRecomputations: () => number; +}; +export declare const selectColumnHighlighters: ((state: any, props: any, ...args: any[]) => IHihglighterState[]) & { + resultFunc: (res1: IHihglighterState[], res2: any, res3: any) => IHihglighterState[]; + recomputations: () => number; + resetRecomputations: () => number; +}; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/model/selectors/index.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/model/selectors/index.d.ts new file mode 100644 index 0000000000..19484d926a --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/model/selectors/index.d.ts @@ -0,0 +1,2 @@ +export * from './model'; +export * from './column'; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/model/selectors/model.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/model/selectors/model.d.ts new file mode 100644 index 0000000000..6bbb16ac5d --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/model/selectors/model.d.ts @@ -0,0 +1,31 @@ +import IDataModelState from "../../interface/IDataGridModelState"; +import IHihglighterState from "../../interface/IHighlighterState"; +export declare const selectModel: (state: any) => IDataModelState; +export declare const selectValues: (state: any) => any; +export declare const selectHasIndex: (state: any) => boolean; +export declare const selectTooltips: (state: any) => string[][]; +export declare const selectCellHighlighters: (state: any) => IHihglighterState[]; +export declare const selectHeadersVertical: (state: any) => boolean; +export declare const selectHeaderFontSize: (state: any) => number; +export declare const selectDataFontSize: (state: any) => number; +export declare const selectFontColor: (state: any) => string[]; +export declare const selectRawColumnNames: (state: any) => string[]; +export declare const selectAlignmentForColumn: (state: any, dataType: any, columnName: any) => any; +export declare const selectAlignmentForType: (state: any, dataType: any) => any; +export declare const selectAlignmentByType: (state: any, dataType: any) => "left" | "right" | "center"; +export declare const selectHasDoubleClickAction: (state: any) => boolean; +export declare const selectDoubleClickTag: (state: any) => string; +export declare const selectContextMenuItems: (state: any) => string[]; +export declare const selectContextMenuTags: (state: any) => {}; +export declare const selectStringFormatForType: (state: any) => {}; +export declare const selectStringFormatForColumn: (state: any) => {}; +export declare const selectStringFormatForTimes: (state: any) => string; +export declare const selectFormatForTimes: (state: any) => any; +export declare const selectTimeStrings: (state: any) => any; +export declare const selectRendererForColumn: (state: any, column: any) => any; +export declare const selectRendererForType: (state: any, column: any) => any; +export declare const selectTimeZone: (state: any) => string; +export declare const selectColumnTypes: (state: any) => string[]; +export declare const selectColumnOrder: (state: any) => string[]; +export declare const selectColumnsVisible: (state: any) => {}; +export declare const selectColumnsFrozen: (state: any) => {}; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/row/DataGridRow.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/row/DataGridRow.d.ts new file mode 100644 index 0000000000..d7c662544b --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/row/DataGridRow.d.ts @@ -0,0 +1,5 @@ +export default class DataGridRow { + index: number; + values: any[]; + constructor(index: number, values: any[]); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/row/RowManager.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/row/RowManager.d.ts new file mode 100644 index 0000000000..0b8e96b518 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/row/RowManager.d.ts @@ -0,0 +1,35 @@ +import DataGridRow from "./DataGridRow"; +import { MapIterator } from '@phosphor/algorithm'; +import DataGridColumn from "../column/DataGridColumn"; +import ColumnManager from "../column/ColumnManager"; +import { COLUMN_TYPES, SORT_ORDER } from "../column/enums"; +export default class RowManager { + rowsIterator: MapIterator; + rows: DataGridRow[]; + filterExpression: string; + expressionVars: string; + sortedBy: DataGridColumn; + columnManager: ColumnManager; + rowsToShow: number; + constructor(data: any[], hasIndex: boolean, columnManager: ColumnManager); + destroy(): void; + createRows(data: any, hasIndex: any): void; + createRowsWithGeneratedIndex(data: any): void; + createRowsWithIndex(data: any): void; + getRow(index: any): DataGridRow; + sortByColumn(column: DataGridColumn): void; + sortRows(column: DataGridColumn, sortOrder: SORT_ORDER, valueResolver?: Function): void; + private compareSortedValues(value1, value2); + resetSorting(): void; + defaultValueResolver(row: DataGridRow, columnIndex: number): any; + indexValueResolver(row: any, columnIndex: number): any; + createFilterExpressionVars(): void; + searchRows(): void; + filterRows(evalFn?: Function): void; + takeRows(start: number, end: number): DataGridRow[]; + createFilterExpression(): void; + evaluateFilterExpression(row: any, formatFns: any): any; + evaluateSearchExpression(row: any, formatFns: any): any; + getValueByColumn(row: number, columnIndex: number, columnType: COLUMN_TYPES): any; + setRowsToShow(rows: any): void; +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/store/BeakerXDataStore.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/store/BeakerXDataStore.d.ts new file mode 100644 index 0000000000..957b971187 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/store/BeakerXDataStore.d.ts @@ -0,0 +1,14 @@ +/// +import { DataStore } from "@phosphor/datastore"; +import IDataModelState from "../interface/IDataGridModelState"; +import { IColumnsState, IColumnState } from "../interface/IColumn"; +export interface IBeakerXDataGridState { + model: IDataModelState; + columns: IColumnsState; +} +export declare type BeakerXDataStore = DataStore; +export default function createStore(initialState: IDataModelState): DataStore<{ + model: IDataModelState; + columns: Map; +}>; +export declare function createInitialColumnsState(initialState: IDataModelState): IColumnsState; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/store/DataGridAction.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/store/DataGridAction.d.ts new file mode 100644 index 0000000000..c91c883642 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/store/DataGridAction.d.ts @@ -0,0 +1,26 @@ +import { Action } from "@phosphor/datastore"; +import { COLUMN_TYPES } from "../column/enums"; +export default class DataGridAction extends Action { + payload: any; + constructor(type: string, payload: any); +} +export declare class DataGridColumnsAction extends DataGridAction { + payload: { + value: any; + hasIndex?: boolean; + defaultValue?: any; + columnsFrozenNames?: string[]; + columnsVisible?: {}; + }; + constructor(type: string, payload: any); +} +export declare class DataGridColumnAction extends DataGridAction { + payload: { + columnType: COLUMN_TYPES; + columnIndex: number; + columnName?: string; + hasIndex?: boolean; + value: any; + }; + constructor(type: string, payload: any); +} diff --git a/js/notebook/src/types/tableDisplay/dataGrid/style/dataGridStyle.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/style/dataGridStyle.d.ts new file mode 100644 index 0000000000..6fa588b7a7 --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/style/dataGridStyle.d.ts @@ -0,0 +1,18 @@ +import './dataGrid.scss'; +export declare const DEFAULT_DATA_FONT_SIZE = 13; +export declare const DEFAULT_BORDER_COLOR = "#D4D0D0"; +export declare const DEFAULT_GRID_PADDING = 20; +export declare const DEFAULT_GRID_BORDER_WIDTH = 1; +export declare const MIN_COLUMN_WIDTH = 40; +export declare const DEFAULT_ROW_HEIGHT = 24; +export declare const DEFAULT_COLORS: { + [x: number]: { + red: any; + blue: any; + green: any; + }; +}; +export declare function rgbToHex(r: any, g: any, b: any): any; +export declare function darken(color: string, factor?: number): string; +export declare function getDefaultColor(color: any): any; +export declare function formatColor(hexColor: any): any; diff --git a/js/notebook/src/types/tree/Types/IApiSettingsResponse.d.ts b/js/notebook/src/types/tree/Types/IApiSettingsResponse.d.ts new file mode 100644 index 0000000000..8ba4e8ceec --- /dev/null +++ b/js/notebook/src/types/tree/Types/IApiSettingsResponse.d.ts @@ -0,0 +1,7 @@ +import IJVMOptions from "./IJVMOptions"; +import IUIOptions from "./IUIOptions"; +export default interface IApiSettingsResponse { + jvm_options: IJVMOptions; + ui_options: IUIOptions; + version: number; +} diff --git a/js/notebook/src/types/tree/Types/IJVMOptions.d.ts b/js/notebook/src/types/tree/Types/IJVMOptions.d.ts new file mode 100644 index 0000000000..bced7d2188 --- /dev/null +++ b/js/notebook/src/types/tree/Types/IJVMOptions.d.ts @@ -0,0 +1,14 @@ +export default interface IJVMOptions extends IDefaultJVMOptions { + other: IOtherJVMOptions; + properties: IPropertiesJVMOptions; +} +export interface IDefaultJVMOptions { + heap_GB: number; +} +export interface IOtherJVMOptions extends Array { +} +export interface IPropertiesJVMOptions extends Array<{ + name: string; + value: string; +}> { +} diff --git a/js/notebook/src/types/tree/Types/IUIOptions.d.ts b/js/notebook/src/types/tree/Types/IUIOptions.d.ts new file mode 100644 index 0000000000..7a1359caa5 --- /dev/null +++ b/js/notebook/src/types/tree/Types/IUIOptions.d.ts @@ -0,0 +1,9 @@ +export default interface IUIOptions { + auto_close: boolean; + improve_fonts: boolean; + wide_cells: boolean; + show_publication: boolean; + show_catalog: boolean; + auto_save: boolean; + use_data_grid: boolean; +} diff --git a/js/notebook/src/types/tree/Utils/BeakerXApi.d.ts b/js/notebook/src/types/tree/Utils/BeakerXApi.d.ts new file mode 100644 index 0000000000..67d3a5ed2e --- /dev/null +++ b/js/notebook/src/types/tree/Utils/BeakerXApi.d.ts @@ -0,0 +1,11 @@ +import IApiSettingsResponse from "../Types/IApiSettingsResponse"; +export default class BeakerXApi { + readonly DEFAULT_SETTINGS: IApiSettingsResponse; + private apiUrl; + constructor(baseUrl?: string); + getApiUrl(endpoint: string): string; + getVersion(): Promise; + loadSettings(): Promise; + mergeWithDefaults(settings: IApiSettingsResponse): IApiSettingsResponse; + saveSettings(data: any): Promise; +}