From a731c6014089e55afeac0131f8552f7930ec7607 Mon Sep 17 00:00:00 2001 From: Mariusz Jurowicz Date: Thu, 12 Jul 2018 22:07:02 +0200 Subject: [PATCH] #5742 add highlight support for jvm kernels magics (#7662) * #5742 add highlight support for jvm kernels magics * #5742 define line magic highlighter mode * #5742 remove GrovyMode namespace, update types * #5742 add line magic highlighting in Lab * #5742 highlight Spark and classpath magics * #5742 support line magics not only in first line of cell --- js/lab/src/plugin/codeEditor.ts | 86 +++++++++++- js/lab/src/plugin/index.ts | 3 +- js/notebook/src/extension/codeEditor.ts | 123 ++++++++++++++++++ .../src/extension/groovyModeExtension.ts | 40 ------ js/notebook/src/extension/index.ts | 4 +- js/notebook/src/types/BeakerXThemeHelper.d.ts | 20 +-- js/notebook/src/types/Spinner.d.ts | 16 --- js/notebook/src/types/global.env.d.ts | 2 +- js/notebook/src/types/plot/plotSanitize.d.ts | 2 +- .../src/types/shared/bkCoreManager.d.ts | 22 ++++ js/notebook/src/types/shared/bkGlobals.d.ts | 38 ++++++ js/notebook/src/types/shared/bkHelper.d.ts | 17 +++ js/notebook/src/types/shared/bkUtils.d.ts | 13 ++ .../sparkUI/toolbarSparkConnectionStatus.d.ts | 4 +- .../dataGrid/BeakerXDataGrid.d.ts | 6 +- .../tableDisplay/dataGrid/DataFormatter.d.ts | 31 ++--- .../tableDisplay/dataGrid/DataGridResize.d.ts | 32 ++--- .../dataGrid/cell/BeakerXCellRenderer.d.ts | 3 +- .../dataGrid/cell/CellFocusManager.d.ts | 14 +- .../dataGrid/cell/CellManager.d.ts | 12 +- .../dataGrid/cell/CellRendererFactory.d.ts | 3 +- .../dataGrid/cell/CellTooltipManager.d.ts | 10 +- .../dataGrid/cell/HTMLCellRenderer.d.ts | 4 +- .../dataGrid/cell/ImageCellRenderer.d.ts | 13 ++ .../dataGrid/column/ColumnFilter.d.ts | 26 ++-- .../dataGrid/column/ColumnManager.d.ts | 17 +-- .../dataGrid/column/ColumnPosition.d.ts | 12 +- .../dataGrid/column/DataGridColumn.d.ts | 29 +++-- .../dataGrid/column/columnAlignment.d.ts | 4 +- .../tableDisplay/dataGrid/column/enums.d.ts | 6 +- .../dataGrid/column/selectors.d.ts | 32 +---- .../types/tableDisplay/dataGrid/consts.d.ts | 44 +++++++ .../dataGrid/dataGridHelpers.d.ts | 7 +- .../tableDisplay/dataGrid/dataTypes.d.ts | 3 +- .../dataGrid/event/EventManager.d.ts | 50 +++---- .../tableDisplay/dataGrid/event/enums.d.ts | 2 +- .../dataGrid/headerMenu/HeaderMenu.d.ts | 3 +- .../highlighter/HighlighterManager.d.ts | 2 +- .../dataGrid/interface/IHighlighterState.d.ts | 4 +- .../dataGrid/interface/IRenderer.d.ts | 2 +- .../dataGrid/model/BeakerXDataGridModel.d.ts | 10 +- .../dataGrid/model/selectors/column.d.ts | 78 ++--------- .../dataGrid/model/selectors/model.d.ts | 2 +- .../tableDisplay/dataGrid/row/RowManager.d.ts | 2 +- .../dataGrid/style/dataGridStyle.d.ts | 2 +- 45 files changed, 536 insertions(+), 319 deletions(-) create mode 100644 js/notebook/src/extension/codeEditor.ts delete mode 100644 js/notebook/src/extension/groovyModeExtension.ts create mode 100644 js/notebook/src/types/shared/bkCoreManager.d.ts create mode 100644 js/notebook/src/types/shared/bkGlobals.d.ts create mode 100644 js/notebook/src/types/shared/bkHelper.d.ts create mode 100644 js/notebook/src/types/shared/bkUtils.d.ts create mode 100644 js/notebook/src/types/tableDisplay/dataGrid/cell/ImageCellRenderer.d.ts diff --git a/js/lab/src/plugin/codeEditor.ts b/js/lab/src/plugin/codeEditor.ts index cbb960e38c..b6916cf8e2 100644 --- a/js/lab/src/plugin/codeEditor.ts +++ b/js/lab/src/plugin/codeEditor.ts @@ -18,10 +18,13 @@ import { CodeMirrorEditor } from "@jupyterlab/codemirror"; import { Cell, CodeCell } from '@jupyterlab/cells'; import 'codemirror/mode/groovy/groovy'; +import {NotebookPanel} from "@jupyterlab/notebook"; const LINE_COMMENT_CHAR = '//'; +const LINE_MAGIC_MODE = 'line_magic'; +const CodeMirror = require("codemirror"); -export const registerCommentOutCmd = (panel) => { +export const registerCommentOutCmd = (panel: NotebookPanel) => { const cells = panel.notebook.widgets || []; cells @@ -50,3 +53,84 @@ const setCodeMirrorLineComment = (cell: Cell) => { mode.lineComment = LINE_COMMENT_CHAR; doc.mode = mode; }; + +export function extendHighlightModes(panel: NotebookPanel) { + const cells = panel.notebook.widgets || []; + + cells + .filter((cell) => (cell.editor instanceof CodeMirrorEditor)) + .forEach(setLineMagicForCell); + + CodeMirror.defineInitHook(addLineMagicsOverlay); +} + +function setLineMagicForCell(cell: Cell) { + if (!(cell instanceof CodeCell)) { + return; + } + + addLineMagicsOverlay((cell.editor).editor); +} + +const lineMagicOverlay = { + startState() { + return { firstMatched: false, inMagicLine: false }; + }, + + token(stream, state) { + if (stream.match(/^%(%classpath|%spark|\w+)/, false)) { + state.inMagicLine = true; + } + + if (state.inMagicLine) { + stream.eat(() => true); + + if (stream.eol()) { + state.inMagicLine = false; + } + + return LINE_MAGIC_MODE; + } + + stream.skipToEnd(); + + return null; + } +}; + +export function autoHighlightLineMagics(code_mirror) { + const current_mode = code_mirror.getOption('mode'); + + if (current_mode === LINE_MAGIC_MODE) { + return; + } + + const re = /^%(%classpath|%spark|\w+)/; + + code_mirror.eachLine((line) => { + if (line && line.text.match(re) !== null) { + // Add an overlay mode to recognize the first line as "line magic" instead + // of the mode used for the rest of the cell. + CodeMirror.defineMode(LINE_MAGIC_MODE, (config) => { + return CodeMirror.overlayMode(CodeMirror.getMode(config, current_mode), lineMagicOverlay); + }); + + code_mirror.setOption('mode', LINE_MAGIC_MODE); + + return false; + } + }); +} + +export function addLineMagicsOverlay(editor: any) { + autoHighlightLineMagics(editor); + + editor.off("focus", autoHighlightLineMagics); + editor.on("focus", autoHighlightLineMagics); + editor.off("change", autoHighlightLineMagics); + editor.on("change", autoHighlightLineMagics); + editor.off("blur", autoHighlightLineMagics); + editor.on("blur", autoHighlightLineMagics); + + editor.refresh(); +} diff --git a/js/lab/src/plugin/index.ts b/js/lab/src/plugin/index.ts index e59934fc91..f94a33803c 100644 --- a/js/lab/src/plugin/index.ts +++ b/js/lab/src/plugin/index.ts @@ -21,7 +21,7 @@ import { INotebookModel, NotebookPanel } from '@jupyterlab/notebook'; import { JupyterLab } from "@jupyterlab/application"; import { ISettingRegistry } from "@jupyterlab/coreutils"; import { registerCommTargets } from './comm'; -import { registerCommentOutCmd } from './codeEditor'; +import {extendHighlightModes, registerCommentOutCmd} from './codeEditor'; import { enableInitializationCellsFeature } from './initializationCells'; import UIOptionFeaturesHelper from "./UIOptionFeaturesHelper"; @@ -55,6 +55,7 @@ class BeakerxExtension implements DocumentRegistry.WidgetExtension { let settings = this.settings; Promise.all([panel.ready, panel.session.ready, context.ready]).then(function() { + extendHighlightModes(panel); enableInitializationCellsFeature(panel); registerCommentOutCmd(panel); registerCommTargets(panel, context); diff --git a/js/notebook/src/extension/codeEditor.ts b/js/notebook/src/extension/codeEditor.ts new file mode 100644 index 0000000000..eacd5bf5ee --- /dev/null +++ b/js/notebook/src/extension/codeEditor.ts @@ -0,0 +1,123 @@ +/* + * Copyright 2018 TWO SIGMA OPEN SOURCE, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// + +export const LINE_COMMENT_CHAR = '//'; +export const LINE_MAGIC_MODE = 'line_magic'; + +export function extendWithLineComment(Jupyter: any, CodeMirror: any) { + CodeMirror.extendMode('groovy', { lineComment: LINE_COMMENT_CHAR }); + + Jupyter.notebook.get_cells().map(setCodeMirrorLineComment); +} + +function setCodeMirrorLineComment(cell: any) { + if (cell.cell_type !== 'code') { + return; + } + + const cm = cell.code_mirror; + const doc = cm.getDoc(); + const mode = cm.getMode(); + + if (!mode.lineComment) { + mode.lineComment = LINE_COMMENT_CHAR; + doc.mode = mode; + } +} + +export function extendHighlightModes(Jupyter: any) { + Jupyter.CodeCell.options_default.highlight_modes = { + ...Jupyter.CodeCell.options_default.highlight_modes, + magic_python: {reg: ['^%%python']}, + magic_groovy: {reg: ['^%%groovy']}, + magic_java: {reg: ['^%%java']}, + magic_scala: {reg: ['^%%scala']}, + magic_kotlin: {reg: ['^%%kotlin']}, + magic_clojure: {reg: ['^%%clojure']}, + magic_sql: {reg: ['^%%sql']}, + magic_html: {reg: ['^%%html']} + }; + + Jupyter.notebook.get_cells().map(setLineMagicForCell); + CodeMirror.defineInitHook(addLineMagicsOverlay); +} + +function setLineMagicForCell(cell) { + cell.auto_highlight(); + addLineMagicsOverlay(cell.code_mirror); +} + +const lineMagicOverlay = { + startState() { + return { firstMatched: false, inMagicLine: false }; + }, + + token(stream, state) { + if (stream.match(/^%(%classpath|%spark|\w+)/)) { + state.inMagicLine = true; + } + + if (state.inMagicLine) { + stream.eat(() => true); + + if (stream.eol()) { + state.inMagicLine = false; + } + + return LINE_MAGIC_MODE; + } + + stream.skipToEnd(); + + return null; + } +}; + +export function autoHighlightLineMagics(code_mirror) { + const current_mode = code_mirror.getOption('mode'); + + if (current_mode === LINE_MAGIC_MODE) { + return; + } + + const re = /^%(%classpath|%spark|\w+)/; + + code_mirror.eachLine((line) => { + if (line && line.text.match(re) !== null) { + // Add an overlay mode to recognize the first line as "line magic" instead + // of the mode used for the rest of the cell. + CodeMirror.defineMode(LINE_MAGIC_MODE, (config) => { + return CodeMirror.overlayMode(CodeMirror.getMode(config, current_mode), lineMagicOverlay); + }); + + code_mirror.setOption('mode', LINE_MAGIC_MODE); + + return false; + } + }); +} + +export function addLineMagicsOverlay(code_mirror) { + autoHighlightLineMagics(code_mirror); + code_mirror.off("focus", autoHighlightLineMagics); + code_mirror.on("focus", autoHighlightLineMagics); + code_mirror.off("change", autoHighlightLineMagics); + code_mirror.on("change", autoHighlightLineMagics); + code_mirror.off("blur", autoHighlightLineMagics); + code_mirror.on("blur", autoHighlightLineMagics); +} diff --git a/js/notebook/src/extension/groovyModeExtension.ts b/js/notebook/src/extension/groovyModeExtension.ts deleted file mode 100644 index 30a14bad80..0000000000 --- a/js/notebook/src/extension/groovyModeExtension.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2018 TWO SIGMA OPEN SOURCE, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export namespace GroovyMode { - export const LINE_COMMENT_CHAR = '//'; - - export function setCodeMirrorLineComment(cell: any) { - if (cell.cell_type !== 'code') { - return; - } - - const cm = cell.code_mirror; - const doc = cm.getDoc(); - const mode = cm.getMode(); - - if (!mode.lineComment) { - mode.lineComment = LINE_COMMENT_CHAR; - doc.mode = mode; - } - } - - export function extendWithLineComment(Jupyter: any, CodeMirror: any) { - CodeMirror.extendMode('groovy', { lineComment: LINE_COMMENT_CHAR }); - - Jupyter.notebook.get_cells().map(setCodeMirrorLineComment); - } -} diff --git a/js/notebook/src/extension/index.ts b/js/notebook/src/extension/index.ts index 917bb32c60..937e8d4873 100644 --- a/js/notebook/src/extension/index.ts +++ b/js/notebook/src/extension/index.ts @@ -26,7 +26,6 @@ import {enableInitializationCellsFeature} from './initializationCells'; import {Autotranslation} from './autotranslation'; import {BeakerXKernel} from './kernel'; import {displayHTML} from '../htmlOutput/htmlOutput'; -import {GroovyMode} from "./groovyModeExtension"; import bkCoreManager from '../shared/bkCoreManager'; import '../shared/style/beakerx.scss'; @@ -99,7 +98,8 @@ function setupNotebook() { }) .catch((reason) => { console.error(log_prefix, 'unhandled error:', reason); }); - GroovyMode.extendWithLineComment(Jupyter, CodeMirror); + extendWithLineComment(Jupyter, CodeMirror); + extendHighlightModes(Jupyter); } export const load_ipython_extension = () => { diff --git a/js/notebook/src/types/BeakerXThemeHelper.d.ts b/js/notebook/src/types/BeakerXThemeHelper.d.ts index 74215cb6a9..7faf1ec4bc 100644 --- a/js/notebook/src/types/BeakerXThemeHelper.d.ts +++ b/js/notebook/src/types/BeakerXThemeHelper.d.ts @@ -1,19 +1,3 @@ -/* - * Copyright 2018 TWO SIGMA OPEN SOURCE, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - import { DataGrid } from "@phosphor/datagrid"; export default class BeakerXThemeHelper { static readonly isDark: boolean; @@ -28,6 +12,6 @@ export default class BeakerXThemeHelper { static readonly HIGHLIGHTED_CELL_BACKGROUND_ODD: string; static readonly MIN_LIGHTNESS_VALUE: number; static readonly MIN_SATURATION_VALUE: number; - private static getDarkStyle(); - private static getLightStyle(); + private static getDarkStyle; + private static getLightStyle; } diff --git a/js/notebook/src/types/Spinner.d.ts b/js/notebook/src/types/Spinner.d.ts index 00badfaa8e..ee2c968c5a 100644 --- a/js/notebook/src/types/Spinner.d.ts +++ b/js/notebook/src/types/Spinner.d.ts @@ -1,19 +1,3 @@ -/* - * Copyright 2018 TWO SIGMA OPEN SOURCE, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - import widgets from './widgets'; export declare class SpinnerModel extends widgets.DOMWidgetModel { defaults(): any; diff --git a/js/notebook/src/types/global.env.d.ts b/js/notebook/src/types/global.env.d.ts index 76896783cd..78c4359c4f 100644 --- a/js/notebook/src/types/global.env.d.ts +++ b/js/notebook/src/types/global.env.d.ts @@ -32,6 +32,7 @@ interface MapConstructor { declare var Map: MapConstructor; declare var CodeMirror: any; +declare var Proxy: ProxyConstructor; declare interface NumberConstructor { isNaN: (number: number) => boolean, @@ -48,7 +49,6 @@ interface ProxyConstructor { new (target: T, handler: ProxyHandler): T; } -declare var Proxy: ProxyConstructor; declare interface Array { from: (arrayLike: any[]) => any[] diff --git a/js/notebook/src/types/plot/plotSanitize.d.ts b/js/notebook/src/types/plot/plotSanitize.d.ts index 529456c171..d9f2337f3a 100644 --- a/js/notebook/src/types/plot/plotSanitize.d.ts +++ b/js/notebook/src/types/plot/plotSanitize.d.ts @@ -1,4 +1,4 @@ -declare global { +declare global { interface Window { cssSchemaFixed: boolean; cssSchema: any; diff --git a/js/notebook/src/types/shared/bkCoreManager.d.ts b/js/notebook/src/types/shared/bkCoreManager.d.ts new file mode 100644 index 0000000000..eaa358a28a --- /dev/null +++ b/js/notebook/src/types/shared/bkCoreManager.d.ts @@ -0,0 +1,22 @@ +declare const bkCoreManager: { + _bkAppImpl: { + getBeakerObject: () => { + beakerObj: { + prefs: { + outputColumnLimit: number; + outputLineLimit: number; + theme: { + name: string; + plotColors: string[]; + }; + }; + }; + }; + }; + _prefs: { + getTheme: () => any; + }; + getTheme: () => any; + getBkApp: () => any; +}; +export default bkCoreManager; diff --git a/js/notebook/src/types/shared/bkGlobals.d.ts b/js/notebook/src/types/shared/bkGlobals.d.ts new file mode 100644 index 0000000000..01c2062402 --- /dev/null +++ b/js/notebook/src/types/shared/bkGlobals.d.ts @@ -0,0 +1,38 @@ +declare const _default: { + DEFAULT_EVALUATOR: string; + REQUIREJS_TIMEOUT: number; + RECONNECT_TIMEOUT: number; + CELL_INSTANTIATION_DISTANCE: number; + EVENTS: { + RECONNECT_FAILED: string; + LANGUAGE_MANAGER_SHOW_SPINNER: string; + LANGUAGE_MANAGER_HIDE_SPINNER: string; + DISCARD_LANGUAGE_SETTINGS: string; + HIGHLIGHT_EDITED_LANGUAGE_SETTINGS: string; + SET_LANGUAGE_SETTINGS_EDITED: string; + LANGUAGE_ADDED: string; + CELL_OUTPUT_EXPANDED: string; + CELL_OUTPUT_LM_SHOWED: string; + ADVANCED_MODE_TOGGLED: string; + FILE_DROPPED: string; + }; + FILE_LOCATION: { + FILESYS: string; + HTTP: string; + AJAX: string; + }; + EVALUATOR_SPEC: { + PROPERTIES: { + STRING: string; + BOOLEAN: string; + ENUM: string; + SELECT: string; + }; + ACTION: string; + }; + THEMES: { + DEFAULT: string; + AMBIANCE: string; + }; +}; +export default _default; diff --git a/js/notebook/src/types/shared/bkHelper.d.ts b/js/notebook/src/types/shared/bkHelper.d.ts new file mode 100644 index 0000000000..6657808859 --- /dev/null +++ b/js/notebook/src/types/shared/bkHelper.d.ts @@ -0,0 +1,17 @@ +/// +export declare const defaultPlotColors: { + [x: string]: string[]; +}; +export declare function getCurrentApp(): any; +export declare const isChrome: boolean; +export declare function getTheme(): any; +export declare function getBeakerObject(): any; +declare const _default: { + isChrome: boolean; + defaultPlotColors: { + [x: string]: string[]; + }; + getTheme: typeof getTheme; + getBeakerObject: typeof getBeakerObject; +}; +export default _default; diff --git a/js/notebook/src/types/shared/bkUtils.d.ts b/js/notebook/src/types/shared/bkUtils.d.ts new file mode 100644 index 0000000000..b4dbc8dad9 --- /dev/null +++ b/js/notebook/src/types/shared/bkUtils.d.ts @@ -0,0 +1,13 @@ +export declare function generateId(length: any): string; +export declare function applyTimezone(timestamp: any, tz: any): any; +export declare function formatTimestamp(timestamp: any, tz: any, format: any): any; +export declare function rgbaToHex(r: any, g: any, b: any, a: any): string; +export declare function formatBytes(bytes: number): string; +declare const _default: { + generateId: typeof generateId; + applyTimezone: typeof applyTimezone; + formatTimestamp: typeof formatTimestamp; + rgbaToHex: typeof rgbaToHex; + formatBytes: typeof formatBytes; +}; +export default _default; diff --git a/js/notebook/src/types/sparkUI/toolbarSparkConnectionStatus.d.ts b/js/notebook/src/types/sparkUI/toolbarSparkConnectionStatus.d.ts index 50a2d4b7c2..6009d0732e 100644 --- a/js/notebook/src/types/sparkUI/toolbarSparkConnectionStatus.d.ts +++ b/js/notebook/src/types/sparkUI/toolbarSparkConnectionStatus.d.ts @@ -9,6 +9,6 @@ export declare class ToolbarSparkConnectionStatus { clear(): void; propagateToolbarWidget(): void; append(): void; - private handleToolbarSparkClick(event); - private appendToolbarSparkStats(); + private handleToolbarSparkClick; + private appendToolbarSparkStats; } diff --git a/js/notebook/src/types/tableDisplay/dataGrid/BeakerXDataGrid.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/BeakerXDataGrid.d.ts index c6c493d8b0..1d8e960b4c 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/BeakerXDataGrid.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/BeakerXDataGrid.d.ts @@ -63,7 +63,7 @@ export declare class BeakerXDataGrid extends DataGrid { onAfterAttach(msg: any): void; messageHook(handler: any, msg: any): boolean; colorizeColumnBorder(data: ICellData, color: string): void; - private addHighlighterManager(); - private addCellRenderers(); - private handleStateChanged(); + 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 index 4caba1a426..5d6b690a3a 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/DataFormatter.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/DataFormatter.d.ts @@ -13,19 +13,20 @@ export declare class DataFormatter { 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); + private isNull; + private handleNull; + private rawValue; + private value; + private string; + private integer; + private formattedInteger; + private double; + private doubleWithPrecision; + private exponential_5; + private exponential_15; + private datetime; + private getTimeFormatForColumn; + private datetimeWithFormat; + private boolean; + private html; } diff --git a/js/notebook/src/types/tableDisplay/dataGrid/DataGridResize.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/DataGridResize.d.ts index 00787b32e5..5447f05b2b 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/DataGridResize.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/DataGridResize.d.ts @@ -28,20 +28,20 @@ export declare class DataGridResize { 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); + private fillEmptySpaceResizeFn; + private getDataGridResizeConfig; + private handleMouseMove; + private getResizedWidth; + private getResizedHeight; + private handleMouseUp; + private captureEvent; + private getWidgetHeight; + private resizeSections; + private resizeSectionWidth; + private resizeHeader; + private setBaseRowSize; + private getSectionWidth; + private setSectionWidth; + private installMessageHook; + private viewportResizeMessageHook; } diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/BeakerXCellRenderer.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/BeakerXCellRenderer.d.ts index 3bc4721cd4..e64de764ec 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/cell/BeakerXCellRenderer.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/BeakerXCellRenderer.d.ts @@ -20,13 +20,12 @@ export default abstract class BeakerXCellRenderer extends TextRenderer { 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}: { + getFont({ region }: { region: any; }): string; getTextColor(config: any): string; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/CellFocusManager.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellFocusManager.d.ts index f9de9fd786..2e57aa88c8 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/cell/CellFocusManager.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellFocusManager.d.ts @@ -9,11 +9,11 @@ export default class CellFocusManager { 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); + private setRightFocusedCell; + private setLeftFocusedCell; + private setUpFocusedCell; + private setDownFocusedCell; + private setPageUpFocusedCell; + private setPageDownFocusedCell; + private scrollIfNeeded; } diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/CellManager.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellManager.d.ts index 323bd94b3e..8d0f92a2fe 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/cell/CellManager.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellManager.d.ts @@ -21,10 +21,10 @@ export default class CellManager { 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); + createCellConfig({ row, column, value, region }: ICellDataOptions | ICellData): CellRenderer.ICellConfig; + private handleCellHovered; + private updateViewportCursor; + private getCSVFromCells; + private executeCopy; + private exportCellsTo; } diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/CellRendererFactory.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellRendererFactory.d.ts index da901c7294..88186960db 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/cell/CellRendererFactory.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellRendererFactory.d.ts @@ -3,7 +3,8 @@ import { ALL_TYPES } from "../dataTypes"; import HTMLCellRenderer from "./HTMLCellRenderer"; import HeaderCellRenderer from "./HeaderCellRenderer"; import DefaultCellRenderer from "./DefaultCellRenderer"; +import ImageCellRenderer from "./ImageCellRenderer"; export declare class CellRendererFactory { - static getRenderer(dataGrid: BeakerXDataGrid, dataType?: ALL_TYPES): HTMLCellRenderer | DefaultCellRenderer; + static getRenderer(dataGrid: BeakerXDataGrid, dataType?: ALL_TYPES): HTMLCellRenderer | DefaultCellRenderer | ImageCellRenderer; static getHeaderRenderer(dataGrid: any): HeaderCellRenderer; } diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/CellTooltipManager.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellTooltipManager.d.ts index 7d468413cc..f47194291a 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/cell/CellTooltipManager.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/CellTooltipManager.d.ts @@ -10,11 +10,11 @@ export default class CellTooltipManager { constructor(dataGrid: BeakerXDataGrid); destroy(): void; hideTooltips(): void; - handleCellHovered(sender: BeakerXDataGrid, {data}: { + handleCellHovered(sender: BeakerXDataGrid, { data }: { data: any; }): void; - private shouldShowTooltip(data); - private shouldShowBodyTooltip(data); - private showTooltip(data); - private getTooltipText(data); + private shouldShowTooltip; + private shouldShowBodyTooltip; + private showTooltip; + private getTooltipText; } diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/HTMLCellRenderer.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/HTMLCellRenderer.d.ts index 42ed06e0bd..05f841442c 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/cell/HTMLCellRenderer.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/HTMLCellRenderer.d.ts @@ -1,9 +1,7 @@ -import { CellRenderer, GraphicsContext, TextRenderer } from "@phosphor/datagrid"; +import { CellRenderer, GraphicsContext } from "@phosphor/datagrid"; import BeakerXCellRenderer from "./BeakerXCellRenderer"; -import { BeakerXDataGrid } from "../BeakerXDataGrid"; export default class HTMLCellRenderer extends BeakerXCellRenderer { dataCache: Map; - 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; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/cell/ImageCellRenderer.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/cell/ImageCellRenderer.d.ts new file mode 100644 index 0000000000..27fd580e0a --- /dev/null +++ b/js/notebook/src/types/tableDisplay/dataGrid/cell/ImageCellRenderer.d.ts @@ -0,0 +1,13 @@ +import { CellRenderer, GraphicsContext } from "@phosphor/datagrid"; +import { BeakerXDataGrid } from "../BeakerXDataGrid"; +import { BeakerXDataStore } from "../store/BeakerXDataStore"; +export default class ImageCellRenderer extends CellRenderer { + store: BeakerXDataStore; + dataGrid: BeakerXDataGrid; + backgroundColor: CellRenderer.ConfigOption; + constructor(dataGrid: BeakerXDataGrid); + drawBackground(gc: GraphicsContext, config: CellRenderer.ICellConfig): void; + paint(gc: GraphicsContext, config: CellRenderer.ICellConfig): void; + drawImage(gc: GraphicsContext, config: CellRenderer.ICellConfig): void; + resizeCell(config: any, width: any, height: any): 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 index 11b4c940e4..81830c0ad2 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnFilter.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnFilter.d.ts @@ -15,10 +15,10 @@ export default class ColumnFilter { static getColumnNameVarPrefix(columnName: any): "" | "col_"; static escapeColumnName(columnName: string): string; constructor(dataGrid: BeakerXDataGrid, column: DataGridColumn, options: { - x; - y; - width; - height; + x: any; + y: any; + width: any; + height: any; }); showSearchInput(shouldFocus: boolean): void; showFilterInput(shouldFocus: boolean): void; @@ -27,13 +27,13 @@ export default class ColumnFilter { 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(); + private updateInputPosition; + private showInput; + private filterHandler; + private createExpression; + private createFilterExpression; + private createSearchExpression; + private addInputNode; + 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 index 7c6febe3d2..8f411ecdee 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnManager.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnManager.d.ts @@ -14,7 +14,7 @@ export interface IBkoColumnsChangedArgs { column: DataGridColumn; } export declare enum COLUMN_CHANGED_TYPES { - 'columnSort' = 0, + 'columnSort' = 0 } export default class ColumnManager { store: BeakerXDataStore; @@ -43,6 +43,7 @@ export default class ColumnManager { blurColumnFilterInputs(): void; updateColumnFilterNodes(): void; updateColumnMenuTriggers(): void; + closeAllMenus(): void; takeColumnsByCells(startCell: ICellData, endCell: ICellData): any[]; takeColumnByCell(cellData: ICellData): DataGridColumn | null; showAllColumns(): void; @@ -52,11 +53,11 @@ export default class ColumnManager { 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(); + private recalculateColumnsMinMax; + private showFilterInputs; + private addBodyColumns; + private addIndexColumns; + private addColumn; + 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 index cc1b36ac79..621d7636ed 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnPosition.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/ColumnPosition.d.ts @@ -22,10 +22,10 @@ export default class ColumnPosition { 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}); + private debounceDragStart; + private handleDragStart; + private moveColumn; + private toggleGrabbing; + private attachDraggableHeader; + private handleCellHovered; } diff --git a/js/notebook/src/types/tableDisplay/dataGrid/column/DataGridColumn.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/column/DataGridColumn.d.ts index b147fe0478..d750ff7474 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/column/DataGridColumn.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/DataGridColumn.d.ts @@ -1,3 +1,4 @@ +/// import ColumnMenu from "../headerMenu/ColumnMenu"; import IndexMenu from "../headerMenu/IndexMenu"; import { BeakerXDataGrid } from "../BeakerXDataGrid"; @@ -37,23 +38,23 @@ export default class DataGridColumn { resetFilter(): void; connectToColumnsChanged(): void; connectToCellHovered(): void; - handleHeaderCellHovered(sender: BeakerXDataGrid, {data}: { + handleHeaderCellHovered(sender: BeakerXDataGrid, { data }: { data: any; }): void; - getAlignment(): any; + getAlignment(): import("@phosphor/widgets/lib/layout").Layout.HorizontalAlignment; setAlignment(horizontalAlignment: TextRenderer.HorizontalAlignment): void; resetAlignment(): void; setWidth(width: number): void; - getState(): any; + getState(): import("../interface/IColumn").IColumnState; getVisible(): boolean; - getDataType(): any; - getSortOrder(): any; - getFilter(): any; - getKeepTrigger(): any; + getDataType(): ALL_TYPES; + getSortOrder(): SORT_ORDER; + getFilter(): string; + getKeepTrigger(): boolean; getDataTypeName(): string; - getDisplayType(): any; + getDisplayType(): string | ALL_TYPES; getFormatForTimes(): any; - getPosition(): any; + getPosition(): import("../interface/IColumn").IColumnPosition; getRenderer(): any; getHighlighter(highlighterType: HIGHLIGHTER_TYPE): Highlighter[]; toggleHighlighter(highlighterType: HIGHLIGHTER_TYPE): void; @@ -70,9 +71,9 @@ export default class DataGridColumn { 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); + private resizeHTMLRows; + private updateColumnFilter; + private toggleVisibility; + private onColumnsChanged; + private setColumnSortOrder; } diff --git a/js/notebook/src/types/tableDisplay/dataGrid/column/columnAlignment.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/column/columnAlignment.d.ts index a40b12c8c6..a3f6f91cb8 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/column/columnAlignment.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/columnAlignment.d.ts @@ -15,5 +15,5 @@ export declare const ALIGNMENTS_BY_CHAR: { 'R': "right"; 'L': "left"; }; -export declare const getAlignmentByType: (type: number) => "left" | "right" | "center"; -export declare const getAlignmentByChar: (char: string) => "left" | "right" | "center"; +export declare const getAlignmentByType: (type: number) => import("@phosphor/widgets/lib/layout").Layout.HorizontalAlignment; +export declare const getAlignmentByChar: (char: string) => import("@phosphor/widgets/lib/layout").Layout.HorizontalAlignment; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/column/enums.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/column/enums.d.ts index 6083e8af95..f189fa7841 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/column/enums.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/enums.d.ts @@ -1,13 +1,13 @@ export declare enum COLUMN_TYPES { index = 0, - body = 1, + body = 1 } export declare enum SORT_ORDER { ASC = 0, DESC = 1, - NO_SORT = 2, + NO_SORT = 2 } export declare enum COLUMN_SIDE { left = 0, - right = 1, + right = 1 } diff --git a/js/notebook/src/types/tableDisplay/dataGrid/column/selectors.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/column/selectors.d.ts index 9819830abd..f00d6d63c3 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/column/selectors.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/column/selectors.d.ts @@ -4,29 +4,13 @@ import { IColumnPosition, IColumnState } from "../interface/IColumn"; import { ALL_TYPES } from "../dataTypes"; import { SORT_ORDER } from "./enums"; 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 selectColumnStatesArray: import("reselect").OutputSelector) => any>; +export declare const selectBodyColumnStates: import("reselect").OutputSelector any>; +export declare const selectVisibleBodyColumns: import("reselect").OutputSelector any>; export declare const selectColumnStateByKey: (state: any, key: any) => IColumnState; export declare const selectColumnState: (state: IBeakerXDataGridState, column: any) => IColumnState; -export declare const selectColumnDataTypeName: ((state: IBeakerXDataGridState, props: any, ...args: any[]) => string) & { - resultFunc: (res: IColumnState) => string; - recomputations: () => number; - resetRecomputations: () => number; -}; -export declare const selectColumnHorizontalAlignment: (state: IBeakerXDataGridState, column: any) => "left" | "right" | "center"; +export declare const selectColumnDataTypeName: import("reselect").OutputParametricSelector string>; +export declare const selectColumnHorizontalAlignment: (state: IBeakerXDataGridState, column: any) => import("@phosphor/widgets/lib/layout").Layout.HorizontalAlignment; export declare const selectColumnDisplayType: (state: IBeakerXDataGridState, column: any) => string | ALL_TYPES; export declare const selectColumnFilter: (state: IBeakerXDataGridState, column: any) => string; export declare const selectColumnDataType: (state: IBeakerXDataGridState, column: any) => ALL_TYPES; @@ -35,9 +19,5 @@ export declare const selectColumnKeepTrigger: (state: IBeakerXDataGridState, col export declare const selectColumnFormatForTimes: (state: IBeakerXDataGridState, column: any) => any; export declare const selectColumnWidth: (state: IBeakerXDataGridState, column: any) => number; export declare const selectColumnPosition: (state: IBeakerXDataGridState, column: any) => IColumnPosition; -export declare const selectColumnIndexByPosition: ((state: any, props: IColumnPosition, ...args: any[]) => number) & { - resultFunc: (res1: any, res2: IColumnPosition) => number; - recomputations: () => number; - resetRecomputations: () => number; -}; +export declare const selectColumnIndexByPosition: import("reselect").OutputParametricSelector 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 index 10c908ba23..5c741f09c1 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/consts.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/consts.d.ts @@ -38,10 +38,32 @@ export declare const TIME_UNIT_FORMATS: { DATETIME: { title: string; format: string; + valueModifier: number; + }; + DATETIME_MS: { + title: string; + format: string; + valueModifier: number; + }; + DATETIME_NS: { + title: string; + format: string; + valueModifier: number; }; DAYS: { title: string; format: string; + valueModifier: number; + }; + DAYS_MS: { + title: string; + format: string; + valueModifier: number; + }; + DAYS_NS: { + title: string; + format: string; + valueModifier: number; }; HOURS: { title: string; @@ -101,10 +123,32 @@ declare const _default: { DATETIME: { title: string; format: string; + valueModifier: number; + }; + DATETIME_MS: { + title: string; + format: string; + valueModifier: number; + }; + DATETIME_NS: { + title: string; + format: string; + valueModifier: number; }; DAYS: { title: string; format: string; + valueModifier: number; + }; + DAYS_MS: { + title: string; + format: string; + valueModifier: number; + }; + DAYS_NS: { + title: string; + format: string; + valueModifier: number; }; HOURS: { title: string; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/dataGridHelpers.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/dataGridHelpers.d.ts index b56c046047..be727a80f8 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/dataGridHelpers.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/dataGridHelpers.d.ts @@ -1,5 +1,7 @@ import { SectionList } from "@phosphor/datagrid/lib/sectionlist"; import DataGridColumn from "./column/DataGridColumn"; +import { CellRenderer } from "@phosphor/datagrid"; +import { BeakerXDataGrid } from "./BeakerXDataGrid"; export declare namespace DataGridHelpers { function escapeHTML(text: any): any; function truncateString(text: any, limit?: number): string; @@ -15,8 +17,8 @@ export declare namespace DataGridHelpers { delta: number; } | null; function throttle(func: Function, limit: number, context?: any, controllObject?: { - timerId: number; - }): (T) => U | undefined; + timerId: any; + }): (T: any) => U | undefined; function debounce(f: (a: A) => void, delay: number, controllObject?: { timerId: number; }): (a: A) => void; @@ -27,4 +29,5 @@ export declare namespace DataGridHelpers { function applyTimezone(timestamp: any, tz: any): any; function formatTimestamp(timestamp: any, tz: any, format: any): any; function hasUpperCaseLetter(value: string): boolean; + function getBackgroundColor(dataGrid: BeakerXDataGrid, config: CellRenderer.ICellConfig): string; } diff --git a/js/notebook/src/types/tableDisplay/dataGrid/dataTypes.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/dataTypes.d.ts index 86956a626e..7057f3cab5 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/dataTypes.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/dataTypes.d.ts @@ -11,9 +11,10 @@ export declare enum ALL_TYPES { 'html' = 10, 'int64' = 11, 'time' = 12, + 'image' = 13 } 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 getDisplayType(type: ALL_TYPES, stringFormatForType?: any, stringFormatForColumn?: any): string | ALL_TYPES.string | ALL_TYPES.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): { diff --git a/js/notebook/src/types/tableDisplay/dataGrid/event/EventManager.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/event/EventManager.d.ts index c921e098b6..ef55ec52f3 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/event/EventManager.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/event/EventManager.d.ts @@ -11,29 +11,29 @@ export default class EventManager { 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(); + private handleSelectStart; + private handleScrollBarMouseUp; + private handleWindowResize; + private handleMouseUp; + private dropColumn; + private handleBodyClick; + private handleMouseMove; + private isOutsideViewport; + private isOutsideGrid; + private handleCellHover; + private handleMouseDown; + private handleStartDragging; + private handleMouseOut; + private isNodeInsideGrid; + private handleMouseWheel; + private handleHeaderClick; + private isHeaderClicked; + private handleKeyDown; + private handleHighlighterKeyDown; + private handleEnterKeyDown; + private handleNavigationKeyDown; + private handleNumKeyDown; + private handleDoubleClick; + 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 index 728e36e351..d34e63dd77 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/event/enums.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/event/enums.d.ts @@ -19,5 +19,5 @@ export declare enum KEYBOARD_KEYS { Digit8 = 56, Digit9 = 57, Escape = 27, - Enter = 13, + Enter = 13 } diff --git a/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/HeaderMenu.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/HeaderMenu.d.ts index b4980fcebb..c150432ea3 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/HeaderMenu.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/headerMenu/HeaderMenu.d.ts @@ -25,6 +25,7 @@ export default abstract class HeaderMenu implements MenuInterface { hideTrigger(): void; attachTriggerToMenu(): void; open(submenuIndex?: number): void; + close(): void; destroy(): void; toggleMenu(submenuIndex?: number): void; createItems(items: MenuItem[], menu: Menu): void; @@ -32,7 +33,7 @@ export default abstract class HeaderMenu implements MenuInterface { createSubmenu(menuItem: MenuItem, subitems: MenuItem[]): Menu; protected assignTriggerSortingCssClass(): void; protected addTrigger(): void; - private handleMenuTriggerClick(event); + private handleMenuTriggerClick; protected getMenuPosition(trigger: any): { top: any; left: any; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/highlighter/HighlighterManager.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/HighlighterManager.d.ts index d67623a392..0fd93fa81f 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/highlighter/HighlighterManager.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/highlighter/HighlighterManager.d.ts @@ -19,5 +19,5 @@ export default class HighlighterManager { toggleColumnHighlighter(column: any, highlighterType: HIGHLIGHTER_TYPE): void; removeHighlighters(): void; getCellBackground(config: CellRenderer.ICellConfig): string; - private getHighlighterKey(column, highlighterType); + private getHighlighterKey; } diff --git a/js/notebook/src/types/tableDisplay/dataGrid/interface/IHighlighterState.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/interface/IHighlighterState.d.ts index 6f86d0f7a3..7ab895bea4 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/interface/IHighlighterState.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/interface/IHighlighterState.d.ts @@ -1,13 +1,13 @@ export declare enum HIGHLIGHTER_STYLE { SINGLE_COLUMN = "SINGLE_COLUMN", - FULL_ROW = "FULL_ROW", + FULL_ROW = "FULL_ROW" } export declare enum HIGHLIGHTER_TYPE { heatmap = "HeatmapHighlighter", uniqueEntries = "UniqueEntriesHighlighter", threeColorHeatmap = "ThreeColorHeatmapHighlighter", value = "ValueHighlighter", - sort = "SortHighlighter", + sort = "SortHighlighter" } export default interface IHihglighterState { colName: string; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/interface/IRenderer.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/interface/IRenderer.d.ts index e285585a9d..6628c48823 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/interface/IRenderer.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/interface/IRenderer.d.ts @@ -1,5 +1,5 @@ export declare enum RENDERER_TYPE { - DataBars = "DataBars", + DataBars = "DataBars" } export default interface IRenderer { type: RENDERER_TYPE; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/model/BeakerXDataGridModel.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/model/BeakerXDataGridModel.d.ts index 75c3cca4b5..d1d673c88c 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/model/BeakerXDataGridModel.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/model/BeakerXDataGridModel.d.ts @@ -30,9 +30,9 @@ export declare class BeakerXDataGridModel extends DataModel { 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); + private htmlTextContentResolver; + private dateValueResolver; + private defaultValueResolver; + private doubleValueResolver; + private integerValueResolver; } 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 index 650c841656..b527db1438 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/model/selectors/column.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/model/selectors/column.d.ts @@ -1,69 +1,17 @@ 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 selectColumnNames: import("reselect").OutputSelector string[]>; +export declare const selectBodyColumnNames: import("reselect").OutputSelector string[]>; +export declare const selectColumnIndexByName: import("reselect").OutputParametricSelector number>; +export declare const selectIndexColumnNames: import("reselect").OutputSelector string[]>; +export declare const selectColumnsFrozenNames: import("reselect").OutputSelector string[]>; 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; -}; +export declare const selectIsColumnFrozen: import("reselect").OutputParametricSelector boolean>; +export declare const selectColumnVisible: import("reselect").OutputParametricSelector boolean>; +export declare const selectInitialColumnAlignment: import("reselect").OutputParametricSelector import("@phosphor/widgets/lib/layout").Layout.HorizontalAlignment>; +export declare const selectVisibleColumnsFrozenCount: import("reselect").OutputSelector number>; +export declare const selectColumnDataTypeByName: import("reselect").OutputParametricSelector any>; +export declare const selectInitialColumnPositions: import("reselect").OutputSelector IColumnPosition[]>; +export declare const selectRenderer: import("reselect").OutputParametricSelector any>; +export declare const selectColumnHighlighters: import("reselect").OutputParametricSelector IHihglighterState[]>; 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 index 6bbb16ac5d..7d39c61ba7 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/model/selectors/model.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/model/selectors/model.d.ts @@ -12,7 +12,7 @@ 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 selectAlignmentByType: (state: any, dataType: any) => import("@phosphor/widgets/lib/layout").Layout.HorizontalAlignment; export declare const selectHasDoubleClickAction: (state: any) => boolean; export declare const selectDoubleClickTag: (state: any) => string; export declare const selectContextMenuItems: (state: any) => string[]; diff --git a/js/notebook/src/types/tableDisplay/dataGrid/row/RowManager.d.ts b/js/notebook/src/types/tableDisplay/dataGrid/row/RowManager.d.ts index 0b8e96b518..9db4acd98a 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/row/RowManager.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/row/RowManager.d.ts @@ -19,7 +19,7 @@ export default class RowManager { getRow(index: any): DataGridRow; sortByColumn(column: DataGridColumn): void; sortRows(column: DataGridColumn, sortOrder: SORT_ORDER, valueResolver?: Function): void; - private compareSortedValues(value1, value2); + private compareSortedValues; resetSorting(): void; defaultValueResolver(row: DataGridRow, columnIndex: number): any; indexValueResolver(row: any, columnIndex: number): 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 index 6fa588b7a7..90b44e0dda 100644 --- a/js/notebook/src/types/tableDisplay/dataGrid/style/dataGridStyle.d.ts +++ b/js/notebook/src/types/tableDisplay/dataGrid/style/dataGridStyle.d.ts @@ -6,7 +6,7 @@ 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]: { + [x: string]: { red: any; blue: any; green: any;