Skip to content

Commit

Permalink
refactor: few small interface fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Oct 1, 2021
1 parent 13bd9a4 commit 1bbf56f
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/common/src/extensions/extensionCommonUtils.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/interfaces/column.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export interface Column<T = any> {
/** 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 2 additions & 10 deletions packages/common/src/interfaces/slickCompositeEditor.interface.ts
Original file line number Diff line number Diff line change
@@ -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<HTMLElement | JQuery<HTMLElement> | 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<Editor>;
}
2 changes: 1 addition & 1 deletion packages/common/src/interfaces/slickEvent.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface SlickEvent<T = any> {
* object the event was fired with.
* @param fn {Function} Event handler.
*/
subscribe: (fn: (e: SlickEventData | Event, data: Partial<T>) => void) => Promise<any>;
subscribe: (fn: (e: SlickEventData | Event, data: T) => void) => Promise<any>;

/**
* Removes an event handler added with <code>subscribe(fn).
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/interfaces/slickGrid.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export interface SlickGrid {
focus(): void;

/** Get the canvas DOM element */
getActiveCanvasNode(): HTMLElement;
getActiveCanvasNode(element?: HTMLElement | JQuery<HTMLElement>): HTMLElement;

/**
* Returns an object representing the coordinates of the currently active cell:
Expand All @@ -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;
Expand Down Expand Up @@ -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<T = any>(newData: T | T[], scrollToTop: boolean): void;
setData<T = any>(newData: T | T[], scrollToTop?: boolean): void;

/** Set the Footer Visibility and optionally enable/disable animation (enabled by default) */
setFooterRowVisibility(visible: boolean, animate?: boolean): void;
Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/interfaces/slickNamespace.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
SlickEventHandler,
SlickGrid,
SlickGridMenu,
SlickGroup,
SlickGroupItemMetadataProvider,
SlickHeaderButtons,
SlickHeaderMenu,
Expand All @@ -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.
Expand Down Expand Up @@ -88,7 +88,7 @@ export interface SlickNamespace {
CompositeEditor: new (modalColumns: Column[], containers: Array<HTMLElement | JQuery<HTMLElement> | null>, options?: CompositeEditorOption) => SlickCompositeEditor;

/** Event is a Pub/Sub SlickGrid Event */
Event: new () => SlickEvent;
Event: new <T = any> () => SlickEvent<T>;

/**
* An event object for passing data to event handlers and letting them control propagation.
Expand All @@ -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;


// --
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/services/domUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1bbf56f

Please sign in to comment.