diff --git a/src/models/cellRange.interface.ts b/src/models/cellRange.interface.ts index 3260ee06..02de6f5f 100644 --- a/src/models/cellRange.interface.ts +++ b/src/models/cellRange.interface.ts @@ -1,21 +1,5 @@ -// import type { SlickCellRangeDecorator } from '../plugins/slick.cellrangedecorator'; - import type { SlickCellRangeDecorator } from '../plugins/slick.cellrangedecorator'; -export interface CellRange { - /** Selection start from which cell? */ - fromCell: number; - - /** Selection start from which row? */ - fromRow: number; - - /** Selection goes to which cell? */ - toCell: number; - - /** Selection goes to which row? */ - toRow: number; -} - export interface CellRangeDecoratorOption { selectionCssClass: string; selectionCss: CSSStyleDeclaration; @@ -41,6 +25,3 @@ export interface CellRangeSelectorOption { /** styling (for example blue background on cell) */ selectionCss: CSSStyleDeclaration; } - -export type CSSStyleDeclarationReadonly = 'length' | 'parentRule' | 'getPropertyPriority' | 'getPropertyValue' | 'item' | 'removeProperty' | 'setProperty'; -export type CSSStyleDeclarationWritable = keyof Omit; diff --git a/src/models/cssDeclaration.interface.ts b/src/models/cssDeclaration.interface.ts new file mode 100644 index 00000000..8a077201 --- /dev/null +++ b/src/models/cssDeclaration.interface.ts @@ -0,0 +1,2 @@ +export type CSSStyleDeclarationReadonly = 'length' | 'parentRule' | 'getPropertyPriority' | 'getPropertyValue' | 'item' | 'removeProperty' | 'setProperty'; +export type CSSStyleDeclarationWritable = keyof Omit; \ No newline at end of file diff --git a/src/models/excelCopyBufferOption.interface.ts b/src/models/excelCopyBufferOption.interface.ts index 28078bd4..75ebe026 100644 --- a/src/models/excelCopyBufferOption.interface.ts +++ b/src/models/excelCopyBufferOption.interface.ts @@ -1,5 +1,5 @@ -import type { CellRange, Column, FormatterResultWithHtml, FormatterResultWithText } from './index'; -import type { SlickEventData } from '../slick.core'; +import type { Column, FormatterResultWithHtml, FormatterResultWithText } from './index'; +import type { SlickEventData, SlickRange } from '../slick.core'; export interface ExcelCopyBufferOption { /** defaults to 2000(ms), delay in ms to wait before clearing the selection after a paste action */ @@ -49,11 +49,11 @@ export interface ExcelCopyBufferOption { // ------------ /** Fired when a copy cell is triggered */ - onCopyCells?: (e: SlickEventData, args: { ranges: CellRange[] }) => void; + onCopyCells?: (e: SlickEventData, args: { ranges: SlickRange[] }) => void; /** Fired when the command to copy the cells is cancelled */ - onCopyCancelled?: (e: SlickEventData, args: { ranges: CellRange[] }) => void; + onCopyCancelled?: (e: SlickEventData, args: { ranges: SlickRange[] }) => void; /** Fired when the user paste cells to the grid */ - onPasteCells?: (e: SlickEventData, args: { ranges: CellRange[] }) => void; + onPasteCells?: (e: SlickEventData, args: { ranges: SlickRange[] }) => void; } diff --git a/src/models/externalCopyClipCommand.interface.ts b/src/models/externalCopyClipCommand.interface.ts index 7be627f0..3b69b67e 100644 --- a/src/models/externalCopyClipCommand.interface.ts +++ b/src/models/externalCopyClipCommand.interface.ts @@ -1,11 +1,12 @@ +import type { Column, ExcelCopyBufferOption } from './index'; import type { SlickCellExternalCopyManager } from '../plugins/slick.cellexternalcopymanager'; -import type { CellRange, Column, ExcelCopyBufferOption } from './index'; +import type { SlickRange } from '../slick.core'; export interface ExternalCopyClipCommand { activeCell: number; activeRow: number; cellExternalCopyManager: SlickCellExternalCopyManager; - clippedRange: CellRange[]; + clippedRange: SlickRange[]; destH: number; destW: number; h: number; @@ -18,7 +19,7 @@ export interface ExternalCopyClipCommand { _options: ExcelCopyBufferOption; execute: () => void; - markCopySelection: (ranges: CellRange[]) => void; + markCopySelection: (ranges: SlickRange[]) => void; setDataItemValueForColumn: (item: any, columnDef: Column, value: any) => any | void; undo: () => void; } \ No newline at end of file diff --git a/src/models/index.ts b/src/models/index.ts index 0e7e7c5f..d819ca77 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -12,6 +12,7 @@ export * from './columnSort.interface'; export * from './compositeEditorOption.interface'; export * from './contextMenuOption.interface'; export * from './core.interface'; +export * from './cssDeclaration.interface'; export * from './customTooltipOption.interface'; export * from './dataViewEvents.interface'; export * from './domEvent.interface'; diff --git a/src/plugins/slick.cellexternalcopymanager.ts b/src/plugins/slick.cellexternalcopymanager.ts index 67d98594..f13cde69 100644 --- a/src/plugins/slick.cellexternalcopymanager.ts +++ b/src/plugins/slick.cellexternalcopymanager.ts @@ -1,4 +1,4 @@ -import type { CellRange, Column, CssStyleHash, ExcelCopyBufferOption, ExternalCopyClipCommand, SlickPlugin } from '../models/index'; +import type { Column, CssStyleHash, ExcelCopyBufferOption, ExternalCopyClipCommand, SlickPlugin } from '../models/index'; import type { SlickGrid } from '../slick.grid'; import { SlickEvent as SlickEvent_, SlickRange as SlickRange_, Utils as Utils_ } from '../slick.core'; @@ -36,15 +36,15 @@ export class SlickCellExternalCopyManager implements SlickPlugin { // -- // public API pluginName = 'CellExternalCopyManager' as const; - onCopyCells = new SlickEvent<{ ranges: CellRange[]; }>(); - onCopyCancelled = new SlickEvent<{ ranges: CellRange[]; }>(); - onPasteCells = new SlickEvent<{ ranges: CellRange[]; }>(); + onCopyCells = new SlickEvent<{ ranges: SlickRange_[]; }>(); + onCopyCancelled = new SlickEvent<{ ranges: SlickRange_[]; }>(); + onPasteCells = new SlickEvent<{ ranges: SlickRange_[]; }>(); // -- // protected props protected _grid!: SlickGrid; protected _bodyElement: HTMLElement; - protected _copiedRanges: CellRange[] | null = null; + protected _copiedRanges: SlickRange_[] | null = null; protected _clearCopyTI?: NodeJS.Timeout; protected _copiedCellStyle: string; protected _copiedCellStyleLayerKey: string; @@ -354,7 +354,7 @@ export class SlickCellExternalCopyManager implements SlickPlugin { } protected handleKeyDown(e: KeyboardEvent): boolean | void { - let ranges: CellRange[]; + let ranges: SlickRange_[]; if (!this._grid.getEditorLock().isActive() || this._grid.getOptions().autoEdit) { if (e.which === this.keyCodes.ESC) { if (this._copiedRanges) { @@ -455,7 +455,7 @@ export class SlickCellExternalCopyManager implements SlickPlugin { } } - protected markCopySelection(ranges: CellRange[]) { + protected markCopySelection(ranges: SlickRange_[]) { this.clearCopySelection(); const columns = this._grid.getColumns(); diff --git a/src/plugins/slick.cellrangedecorator.ts b/src/plugins/slick.cellrangedecorator.ts index 839f4375..bffaabcc 100644 --- a/src/plugins/slick.cellrangedecorator.ts +++ b/src/plugins/slick.cellrangedecorator.ts @@ -1,5 +1,5 @@ -import type { CSSStyleDeclarationWritable, CellRange, CellRangeDecoratorOption, SlickPlugin } from '../models/index'; -import { Utils as Utils_ } from '../slick.core'; +import type { CSSStyleDeclarationWritable, CellRangeDecoratorOption, SlickPlugin } from '../models/index'; +import { Utils as Utils_, SlickRange } from '../slick.core'; import type { SlickGrid } from '../slick.grid'; // for (iife) load Slick methods from global Slick object, or use imports for (esm) @@ -49,7 +49,7 @@ export class SlickCellRangeDecorator implements SlickPlugin { this._elem = null; } - show(range: CellRange) { + show(range: SlickRange) { if (!this._elem) { this._elem = document.createElement('div'); this._elem.className = this._options.selectionCssClass; diff --git a/src/plugins/slick.cellselectionmodel.ts b/src/plugins/slick.cellselectionmodel.ts index 76d278e8..6040647d 100644 --- a/src/plugins/slick.cellselectionmodel.ts +++ b/src/plugins/slick.cellselectionmodel.ts @@ -1,6 +1,6 @@ import { SlickEvent as SlickEvent_, SlickEventData as SlickEventData_, SlickRange as SlickRange_, Utils as Utils_ } from '../slick.core'; import { SlickCellRangeSelector as SlickCellRangeSelector_ } from './slick.cellrangeselector'; -import type { CellRange, OnActiveCellChangedEventArgs } from '../models/index'; +import type { OnActiveCellChangedEventArgs } from '../models/index'; import type { SlickDataView } from '../slick.dataview'; import type { SlickGrid } from '../slick.grid'; @@ -20,7 +20,7 @@ export class SlickCellSelectionModel { // -- // public API pluginName = 'CellSelectionModel' as const; - onSelectedRangesChanged = new SlickEvent(); + onSelectedRangesChanged = new SlickEvent(); // -- // protected props @@ -29,7 +29,7 @@ export class SlickCellSelectionModel { protected _grid!: SlickGrid; protected _prevSelectedRow?: number; protected _prevKeyDown = ''; - protected _ranges: CellRange[] = []; + protected _ranges: SlickRange_[] = []; protected _selector: SlickCellRangeSelector_; protected _options?: CellSelectionModelOption; protected _defaults: CellSelectionModelOption = { @@ -66,8 +66,8 @@ export class SlickCellSelectionModel { this._selector?.destroy(); } - protected removeInvalidRanges(ranges: CellRange[]) { - const result: CellRange[] = []; + protected removeInvalidRanges(ranges: SlickRange_[]) { + const result: SlickRange_[] = []; for (let i = 0; i < ranges.length; i++) { const r = ranges[i]; @@ -79,7 +79,7 @@ export class SlickCellSelectionModel { return result; } - protected rangesAreEqual(range1: CellRange[], range2: CellRange[]) { + protected rangesAreEqual(range1: SlickRange_[], range2: SlickRange_[]) { let areDifferent = (range1.length !== range2.length); if (!areDifferent) { for (let i = 0; i < range1.length; i++) { @@ -102,7 +102,7 @@ export class SlickCellSelectionModel { this._cachedPageRowCount = 0; } - setSelectedRanges(ranges: CellRange[], caller = 'SlickCellSelectionModel.setSelectedRanges') { + setSelectedRanges(ranges: SlickRange_[], caller = 'SlickCellSelectionModel.setSelectedRanges') { // simple check for: empty selection didn't change, prevent firing onSelectedRangesChanged if ((!this._ranges || this._ranges.length === 0) && (!ranges || ranges.length === 0)) { return; } @@ -133,7 +133,7 @@ export class SlickCellSelectionModel { } } - protected handleCellRangeSelected(_e: any, args: { range: CellRange; }) { + protected handleCellRangeSelected(_e: any, args: { range: SlickRange_; }) { this._grid.setActiveCell(args.range.fromRow, args.range.fromCell, false, false, true); this.setSelectedRanges([args.range]); } @@ -153,7 +153,7 @@ export class SlickCellSelectionModel { } protected handleKeyDown(e: KeyboardEvent) { - let ranges: CellRange[], last: SlickRange_; + let ranges: SlickRange_[], last: SlickRange_; const active = this._grid.getActiveCell(); const metaKey = e.ctrlKey || e.metaKey; let dataLn = 0; diff --git a/src/plugins/slick.rowselectionmodel.ts b/src/plugins/slick.rowselectionmodel.ts index feb0ff90..5e2a3a70 100644 --- a/src/plugins/slick.rowselectionmodel.ts +++ b/src/plugins/slick.rowselectionmodel.ts @@ -4,7 +4,7 @@ import { SlickCellRangeDecorator as SlickCellRangeDecorator_ } from './slick.cel import { SlickCellRangeSelector as SlickCellRangeSelector_ } from './slick.cellrangeselector'; import type { SlickCrossGridRowMoveManager as SlickCrossGridRowMoveManager_ } from './slick.crossgridrowmovemanager'; import type { SlickRowMoveManager as SlickRowMoveManager_ } from './slick.rowmovemanager'; -import type { CellRange, OnActiveCellChangedEventArgs, RowSelectionModelOption } from '../models/index'; +import type { OnActiveCellChangedEventArgs, RowSelectionModelOption } from '../models/index'; import type { SlickGrid } from '../slick.grid'; // for (iife) load Slick methods from global Slick object, or use imports for (esm) @@ -22,12 +22,12 @@ export class SlickRowSelectionModel { // -- // public API pluginName = 'RowSelectionModel' as const; - onSelectedRangesChanged = new SlickEvent(); + onSelectedRangesChanged = new SlickEvent(); // _handler, _inHandler, _isRowMoveManagerHandler, _options, wrapHandler // -- // protected props protected _grid!: SlickGrid; - protected _ranges: CellRange[] = []; + protected _ranges: SlickRange_[] = []; protected _eventHandler = new SlickEventHandler(); protected _inHandler = false; protected _selector?: SlickCellRangeSelector_; @@ -96,7 +96,7 @@ export class SlickRowSelectionModel { }; } - protected rangesToRows(ranges: CellRange[]): number[] { + protected rangesToRows(ranges: SlickRange_[]): number[] { const rows: number[] = []; for (let i = 0; i < ranges.length; i++) { for (let j = ranges[i].fromRow; j <= ranges[i].toRow; j++) { @@ -135,7 +135,7 @@ export class SlickRowSelectionModel { this.setSelectedRanges(this.rowsToRanges(rows), 'SlickRowSelectionModel.setSelectedRows'); } - setSelectedRanges(ranges: CellRange[], caller = 'SlickRowSelectionModel.setSelectedRanges') { + setSelectedRanges(ranges: SlickRange_[], caller = 'SlickRowSelectionModel.setSelectedRanges') { // simple check for: empty selection didn't change, prevent firing onSelectedRangesChanged if ((!this._ranges || this._ranges.length === 0) && (!ranges || ranges.length === 0)) { return; @@ -250,7 +250,7 @@ export class SlickRowSelectionModel { this._grid.setActiveCell(cell.row, cell.cell); } - protected handleCellRangeSelected(_e: SlickEventData_, args: { range: CellRange; }): boolean | void { + protected handleCellRangeSelected(_e: SlickEventData_, args: { range: SlickRange_; }): boolean | void { if (!this._grid.getOptions().multiSelect || !this._options.selectActiveRow) { return false; }