From 1bbf56fcf56627bbcf97d40b913583295f3ef144 Mon Sep 17 00:00:00 2001 From: ghiscoding Date: Thu, 30 Sep 2021 23:56:22 -0400 Subject: [PATCH] refactor: few small interface fixes --- .../common/src/extensions/extensionCommonUtils.ts | 2 +- packages/common/src/interfaces/column.interface.ts | 3 +++ .../interfaces/slickCellRangeDecorator.interface.ts | 3 +++ .../src/interfaces/slickCompositeEditor.interface.ts | 12 ++---------- .../common/src/interfaces/slickEvent.interface.ts | 2 +- .../common/src/interfaces/slickGrid.interface.ts | 6 +++--- .../src/interfaces/slickNamespace.interface.ts | 8 ++++---- packages/common/src/services/domUtilities.ts | 2 +- 8 files changed, 18 insertions(+), 20 deletions(-) diff --git a/packages/common/src/extensions/extensionCommonUtils.ts b/packages/common/src/extensions/extensionCommonUtils.ts index 7349c42cb..6657327be 100644 --- a/packages/common/src/extensions/extensionCommonUtils.ts +++ b/packages/common/src/extensions/extensionCommonUtils.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-this-alias */ -import { Column, ColumnPickerOption, DOMEvent, GridMenuOption } from '../interfaces'; +import { Column, ColumnPickerOption, DOMEvent, GridMenuOption } from '../interfaces/index'; import { sanitizeTextByAvailableSanitizer } from '../services/domUtilities'; import { ColumnPickerControl } from '../controls/columnPicker.control'; import { GridMenuControl } from '../controls/gridMenu.control'; diff --git a/packages/common/src/interfaces/column.interface.ts b/packages/common/src/interfaces/column.interface.ts index b25269bb0..492c01eaa 100644 --- a/packages/common/src/interfaces/column.interface.ts +++ b/packages/common/src/interfaces/column.interface.ts @@ -58,6 +58,9 @@ export interface Column { /** Do we want default sort to be ascending? True by default */ defaultSortAsc?: boolean; + /** Defaults to false, do we want to deny executing a Paste (from a Copy of CellExternalCopyManager)? */ + denyPaste?: boolean; + /** Any inline editor function that implements Editor for the cell value or ColumnEditor */ editor?: ColumnEditor; diff --git a/packages/common/src/interfaces/slickCellRangeDecorator.interface.ts b/packages/common/src/interfaces/slickCellRangeDecorator.interface.ts index c36887872..e7fe9919d 100644 --- a/packages/common/src/interfaces/slickCellRangeDecorator.interface.ts +++ b/packages/common/src/interfaces/slickCellRangeDecorator.interface.ts @@ -7,6 +7,9 @@ export interface SlickCellRangeDecorator { /** Constructor of the CellRangeDecorator 3rd party plugin, it can optionally receive options */ constructor: (grid: SlickGrid, options?: { cellDecorator?: any; selectionCss?: { [cssRule: string]: string | number | boolean; } }) => void; + /** Destroy the plugin */ + destroy(): void; + /** Show a cell range decoration. Displays an overlay on top of a given cell range. */ show(cellRange: CellRange): HTMLElement; diff --git a/packages/common/src/interfaces/slickCompositeEditor.interface.ts b/packages/common/src/interfaces/slickCompositeEditor.interface.ts index f72b91335..c8e0f6c9a 100644 --- a/packages/common/src/interfaces/slickCompositeEditor.interface.ts +++ b/packages/common/src/interfaces/slickCompositeEditor.interface.ts @@ -1,19 +1,11 @@ -import { Column, CompositeEditorOption, Editor, } from './index'; +import { Column, CompositeEditorOption, Editor, ElementPosition, } from './index'; /** A composite SlickGrid editor factory. */ export interface SlickCompositeEditor { /** Constructor of the Slick Composite Editor, it can optionally receive options */ constructor: (columns: Column[], containers: Array | null>, options?: CompositeEditorOption) => void; - getContainerBox(index: number): { - top: number; - left: number; - bottom: number; - right: number; - width: number; - height: number; - visible: boolean; - }; + getContainerBox(index: number): ElementPosition; editor: Partial; } diff --git a/packages/common/src/interfaces/slickEvent.interface.ts b/packages/common/src/interfaces/slickEvent.interface.ts index 660627b78..b84d8ddfb 100644 --- a/packages/common/src/interfaces/slickEvent.interface.ts +++ b/packages/common/src/interfaces/slickEvent.interface.ts @@ -19,7 +19,7 @@ export interface SlickEvent { * object the event was fired with. * @param fn {Function} Event handler. */ - subscribe: (fn: (e: SlickEventData | Event, data: Partial) => void) => Promise; + subscribe: (fn: (e: SlickEventData | Event, data: T) => void) => Promise; /** * Removes an event handler added with subscribe(fn). diff --git a/packages/common/src/interfaces/slickGrid.interface.ts b/packages/common/src/interfaces/slickGrid.interface.ts index 4249e8d45..a568f5393 100644 --- a/packages/common/src/interfaces/slickGrid.interface.ts +++ b/packages/common/src/interfaces/slickGrid.interface.ts @@ -86,7 +86,7 @@ export interface SlickGrid { focus(): void; /** Get the canvas DOM element */ - getActiveCanvasNode(): HTMLElement; + getActiveCanvasNode(element?: HTMLElement | JQuery): HTMLElement; /** * Returns an object representing the coordinates of the currently active cell: @@ -111,7 +111,7 @@ export interface SlickGrid { getCanvases(): HTMLElement; /** Get Grid Canvas Node DOM Element */ - getCanvasNode(): HTMLCanvasElement; + getCanvasNode(): HTMLElement; /** Get the grid canvas width */ getCanvasWidth(): number; @@ -410,7 +410,7 @@ export interface SlickGrid { * @param newData New databinding source using a regular JavaScript array.. or a custom object exposing getItem(index) and getLength() functions. * @param scrollToTop If true, the grid will reset the vertical scroll position to the top of the grid. */ - setData(newData: T | T[], scrollToTop: boolean): void; + setData(newData: T | T[], scrollToTop?: boolean): void; /** Set the Footer Visibility and optionally enable/disable animation (enabled by default) */ setFooterRowVisibility(visible: boolean, animate?: boolean): void; diff --git a/packages/common/src/interfaces/slickNamespace.interface.ts b/packages/common/src/interfaces/slickNamespace.interface.ts index dff1c74e0..2949263c2 100644 --- a/packages/common/src/interfaces/slickNamespace.interface.ts +++ b/packages/common/src/interfaces/slickNamespace.interface.ts @@ -31,6 +31,7 @@ import { SlickEventHandler, SlickGrid, SlickGridMenu, + SlickGroup, SlickGroupItemMetadataProvider, SlickHeaderButtons, SlickHeaderMenu, @@ -42,8 +43,7 @@ import { SlickRowSelectionModel, } from './index'; import { CompositeEditorOption } from './compositeEditorOption.interface'; -import { AutoTooltipPlugin } from '../plugins/index'; -import { SlickGroup } from '..'; +import { AutoTooltipPlugin, } from '../plugins/index'; /** * Slick Grid class interface of the entire library and it's multiple controls/plugins. @@ -88,7 +88,7 @@ export interface SlickNamespace { CompositeEditor: new (modalColumns: Column[], containers: Array | null>, options?: CompositeEditorOption) => SlickCompositeEditor; /** Event is a Pub/Sub SlickGrid Event */ - Event: new () => SlickEvent; + Event: new () => SlickEvent; /** * An event object for passing data to event handlers and letting them control propagation. @@ -103,7 +103,7 @@ export interface SlickNamespace { GlobalEditorLock: SlickEditorLock; /** A structure containing a range of cells. */ - Range: new () => SlickRange; + Range: new (fromRow?: number, fromCell?: number, toRow?: number, toCell?: number) => SlickRange; // -- diff --git a/packages/common/src/services/domUtilities.ts b/packages/common/src/services/domUtilities.ts index 2edaa931f..ed58e3e4d 100644 --- a/packages/common/src/services/domUtilities.ts +++ b/packages/common/src/services/domUtilities.ts @@ -178,7 +178,7 @@ export function getElementOffsetRelativeToParent(parentElm: HTMLElement | null, } /** Get HTML element offset with pure JS */ -export function getHtmlElementOffset(element: HTMLElement): HtmlElementPosition | undefined { +export function getHtmlElementOffset(element?: HTMLElement): HtmlElementPosition | undefined { if (!element) { return undefined; }