Skip to content

Commit 7675dc5

Browse files
authored
fix: remove unused CellRange interface, use core SlickRange, fix #927 (#928)
- fixes #927
1 parent 15d53f5 commit 7675dc5

9 files changed

+37
-52
lines changed

src/models/cellRange.interface.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
1-
// import type { SlickCellRangeDecorator } from '../plugins/slick.cellrangedecorator';
2-
31
import type { SlickCellRangeDecorator } from '../plugins/slick.cellrangedecorator';
42

5-
export interface CellRange {
6-
/** Selection start from which cell? */
7-
fromCell: number;
8-
9-
/** Selection start from which row? */
10-
fromRow: number;
11-
12-
/** Selection goes to which cell? */
13-
toCell: number;
14-
15-
/** Selection goes to which row? */
16-
toRow: number;
17-
}
18-
193
export interface CellRangeDecoratorOption {
204
selectionCssClass: string;
215
selectionCss: CSSStyleDeclaration;
@@ -41,6 +25,3 @@ export interface CellRangeSelectorOption {
4125
/** styling (for example blue background on cell) */
4226
selectionCss: CSSStyleDeclaration;
4327
}
44-
45-
export type CSSStyleDeclarationReadonly = 'length' | 'parentRule' | 'getPropertyPriority' | 'getPropertyValue' | 'item' | 'removeProperty' | 'setProperty';
46-
export type CSSStyleDeclarationWritable = keyof Omit<CSSStyleDeclaration, CSSStyleDeclarationReadonly>;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export type CSSStyleDeclarationReadonly = 'length' | 'parentRule' | 'getPropertyPriority' | 'getPropertyValue' | 'item' | 'removeProperty' | 'setProperty';
2+
export type CSSStyleDeclarationWritable = keyof Omit<CSSStyleDeclaration, CSSStyleDeclarationReadonly>;

src/models/excelCopyBufferOption.interface.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { CellRange, Column, FormatterResultWithHtml, FormatterResultWithText } from './index';
2-
import type { SlickEventData } from '../slick.core';
1+
import type { Column, FormatterResultWithHtml, FormatterResultWithText } from './index';
2+
import type { SlickEventData, SlickRange } from '../slick.core';
33

44
export interface ExcelCopyBufferOption<T = any> {
55
/** defaults to 2000(ms), delay in ms to wait before clearing the selection after a paste action */
@@ -49,11 +49,11 @@ export interface ExcelCopyBufferOption<T = any> {
4949
// ------------
5050

5151
/** Fired when a copy cell is triggered */
52-
onCopyCells?: (e: SlickEventData, args: { ranges: CellRange[] }) => void;
52+
onCopyCells?: (e: SlickEventData, args: { ranges: SlickRange[] }) => void;
5353

5454
/** Fired when the command to copy the cells is cancelled */
55-
onCopyCancelled?: (e: SlickEventData, args: { ranges: CellRange[] }) => void;
55+
onCopyCancelled?: (e: SlickEventData, args: { ranges: SlickRange[] }) => void;
5656

5757
/** Fired when the user paste cells to the grid */
58-
onPasteCells?: (e: SlickEventData, args: { ranges: CellRange[] }) => void;
58+
onPasteCells?: (e: SlickEventData, args: { ranges: SlickRange[] }) => void;
5959
}

src/models/externalCopyClipCommand.interface.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import type { Column, ExcelCopyBufferOption } from './index';
12
import type { SlickCellExternalCopyManager } from '../plugins/slick.cellexternalcopymanager';
2-
import type { CellRange, Column, ExcelCopyBufferOption } from './index';
3+
import type { SlickRange } from '../slick.core';
34

45
export interface ExternalCopyClipCommand {
56
activeCell: number;
67
activeRow: number;
78
cellExternalCopyManager: SlickCellExternalCopyManager;
8-
clippedRange: CellRange[];
9+
clippedRange: SlickRange[];
910
destH: number;
1011
destW: number;
1112
h: number;
@@ -18,7 +19,7 @@ export interface ExternalCopyClipCommand {
1819
_options: ExcelCopyBufferOption;
1920

2021
execute: () => void;
21-
markCopySelection: (ranges: CellRange[]) => void;
22+
markCopySelection: (ranges: SlickRange[]) => void;
2223
setDataItemValueForColumn: (item: any, columnDef: Column, value: any) => any | void;
2324
undo: () => void;
2425
}

src/models/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export * from './columnSort.interface';
1212
export * from './compositeEditorOption.interface';
1313
export * from './contextMenuOption.interface';
1414
export * from './core.interface';
15+
export * from './cssDeclaration.interface';
1516
export * from './customTooltipOption.interface';
1617
export * from './dataViewEvents.interface';
1718
export * from './domEvent.interface';

src/plugins/slick.cellexternalcopymanager.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CellRange, Column, CssStyleHash, ExcelCopyBufferOption, ExternalCopyClipCommand, SlickPlugin } from '../models/index';
1+
import type { Column, CssStyleHash, ExcelCopyBufferOption, ExternalCopyClipCommand, SlickPlugin } from '../models/index';
22
import type { SlickGrid } from '../slick.grid';
33
import { SlickEvent as SlickEvent_, SlickRange as SlickRange_, Utils as Utils_ } from '../slick.core';
44

@@ -36,15 +36,15 @@ export class SlickCellExternalCopyManager implements SlickPlugin {
3636
// --
3737
// public API
3838
pluginName = 'CellExternalCopyManager' as const;
39-
onCopyCells = new SlickEvent<{ ranges: CellRange[]; }>();
40-
onCopyCancelled = new SlickEvent<{ ranges: CellRange[]; }>();
41-
onPasteCells = new SlickEvent<{ ranges: CellRange[]; }>();
39+
onCopyCells = new SlickEvent<{ ranges: SlickRange_[]; }>();
40+
onCopyCancelled = new SlickEvent<{ ranges: SlickRange_[]; }>();
41+
onPasteCells = new SlickEvent<{ ranges: SlickRange_[]; }>();
4242

4343
// --
4444
// protected props
4545
protected _grid!: SlickGrid;
4646
protected _bodyElement: HTMLElement;
47-
protected _copiedRanges: CellRange[] | null = null;
47+
protected _copiedRanges: SlickRange_[] | null = null;
4848
protected _clearCopyTI?: NodeJS.Timeout;
4949
protected _copiedCellStyle: string;
5050
protected _copiedCellStyleLayerKey: string;
@@ -354,7 +354,7 @@ export class SlickCellExternalCopyManager implements SlickPlugin {
354354
}
355355

356356
protected handleKeyDown(e: KeyboardEvent): boolean | void {
357-
let ranges: CellRange[];
357+
let ranges: SlickRange_[];
358358
if (!this._grid.getEditorLock().isActive() || this._grid.getOptions().autoEdit) {
359359
if (e.which === this.keyCodes.ESC) {
360360
if (this._copiedRanges) {
@@ -455,7 +455,7 @@ export class SlickCellExternalCopyManager implements SlickPlugin {
455455
}
456456
}
457457

458-
protected markCopySelection(ranges: CellRange[]) {
458+
protected markCopySelection(ranges: SlickRange_[]) {
459459
this.clearCopySelection();
460460

461461
const columns = this._grid.getColumns();

src/plugins/slick.cellrangedecorator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { CSSStyleDeclarationWritable, CellRange, CellRangeDecoratorOption, SlickPlugin } from '../models/index';
2-
import { Utils as Utils_ } from '../slick.core';
1+
import type { CSSStyleDeclarationWritable, CellRangeDecoratorOption, SlickPlugin } from '../models/index';
2+
import { Utils as Utils_, SlickRange } from '../slick.core';
33
import type { SlickGrid } from '../slick.grid';
44

55
// for (iife) load Slick methods from global Slick object, or use imports for (esm)
@@ -49,7 +49,7 @@ export class SlickCellRangeDecorator implements SlickPlugin {
4949
this._elem = null;
5050
}
5151

52-
show(range: CellRange) {
52+
show(range: SlickRange) {
5353
if (!this._elem) {
5454
this._elem = document.createElement('div');
5555
this._elem.className = this._options.selectionCssClass;

src/plugins/slick.cellselectionmodel.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SlickEvent as SlickEvent_, SlickEventData as SlickEventData_, SlickRange as SlickRange_, Utils as Utils_ } from '../slick.core';
22
import { SlickCellRangeSelector as SlickCellRangeSelector_ } from './slick.cellrangeselector';
3-
import type { CellRange, OnActiveCellChangedEventArgs } from '../models/index';
3+
import type { OnActiveCellChangedEventArgs } from '../models/index';
44
import type { SlickDataView } from '../slick.dataview';
55
import type { SlickGrid } from '../slick.grid';
66

@@ -20,7 +20,7 @@ export class SlickCellSelectionModel {
2020
// --
2121
// public API
2222
pluginName = 'CellSelectionModel' as const;
23-
onSelectedRangesChanged = new SlickEvent<CellRange[]>();
23+
onSelectedRangesChanged = new SlickEvent<SlickRange_[]>();
2424

2525
// --
2626
// protected props
@@ -29,7 +29,7 @@ export class SlickCellSelectionModel {
2929
protected _grid!: SlickGrid;
3030
protected _prevSelectedRow?: number;
3131
protected _prevKeyDown = '';
32-
protected _ranges: CellRange[] = [];
32+
protected _ranges: SlickRange_[] = [];
3333
protected _selector: SlickCellRangeSelector_;
3434
protected _options?: CellSelectionModelOption;
3535
protected _defaults: CellSelectionModelOption = {
@@ -66,8 +66,8 @@ export class SlickCellSelectionModel {
6666
this._selector?.destroy();
6767
}
6868

69-
protected removeInvalidRanges(ranges: CellRange[]) {
70-
const result: CellRange[] = [];
69+
protected removeInvalidRanges(ranges: SlickRange_[]) {
70+
const result: SlickRange_[] = [];
7171

7272
for (let i = 0; i < ranges.length; i++) {
7373
const r = ranges[i];
@@ -79,7 +79,7 @@ export class SlickCellSelectionModel {
7979
return result;
8080
}
8181

82-
protected rangesAreEqual(range1: CellRange[], range2: CellRange[]) {
82+
protected rangesAreEqual(range1: SlickRange_[], range2: SlickRange_[]) {
8383
let areDifferent = (range1.length !== range2.length);
8484
if (!areDifferent) {
8585
for (let i = 0; i < range1.length; i++) {
@@ -102,7 +102,7 @@ export class SlickCellSelectionModel {
102102
this._cachedPageRowCount = 0;
103103
}
104104

105-
setSelectedRanges(ranges: CellRange[], caller = 'SlickCellSelectionModel.setSelectedRanges') {
105+
setSelectedRanges(ranges: SlickRange_[], caller = 'SlickCellSelectionModel.setSelectedRanges') {
106106
// simple check for: empty selection didn't change, prevent firing onSelectedRangesChanged
107107
if ((!this._ranges || this._ranges.length === 0) && (!ranges || ranges.length === 0)) { return; }
108108

@@ -133,7 +133,7 @@ export class SlickCellSelectionModel {
133133
}
134134
}
135135

136-
protected handleCellRangeSelected(_e: any, args: { range: CellRange; }) {
136+
protected handleCellRangeSelected(_e: any, args: { range: SlickRange_; }) {
137137
this._grid.setActiveCell(args.range.fromRow, args.range.fromCell, false, false, true);
138138
this.setSelectedRanges([args.range]);
139139
}
@@ -153,7 +153,7 @@ export class SlickCellSelectionModel {
153153
}
154154

155155
protected handleKeyDown(e: KeyboardEvent) {
156-
let ranges: CellRange[], last: SlickRange_;
156+
let ranges: SlickRange_[], last: SlickRange_;
157157
const active = this._grid.getActiveCell();
158158
const metaKey = e.ctrlKey || e.metaKey;
159159
let dataLn = 0;

src/plugins/slick.rowselectionmodel.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { SlickCellRangeDecorator as SlickCellRangeDecorator_ } from './slick.cel
44
import { SlickCellRangeSelector as SlickCellRangeSelector_ } from './slick.cellrangeselector';
55
import type { SlickCrossGridRowMoveManager as SlickCrossGridRowMoveManager_ } from './slick.crossgridrowmovemanager';
66
import type { SlickRowMoveManager as SlickRowMoveManager_ } from './slick.rowmovemanager';
7-
import type { CellRange, OnActiveCellChangedEventArgs, RowSelectionModelOption } from '../models/index';
7+
import type { OnActiveCellChangedEventArgs, RowSelectionModelOption } from '../models/index';
88
import type { SlickGrid } from '../slick.grid';
99

1010
// for (iife) load Slick methods from global Slick object, or use imports for (esm)
@@ -22,12 +22,12 @@ export class SlickRowSelectionModel {
2222
// --
2323
// public API
2424
pluginName = 'RowSelectionModel' as const;
25-
onSelectedRangesChanged = new SlickEvent<CellRange[]>();
25+
onSelectedRangesChanged = new SlickEvent<SlickRange_[]>();
2626
// _handler, _inHandler, _isRowMoveManagerHandler, _options, wrapHandler
2727
// --
2828
// protected props
2929
protected _grid!: SlickGrid;
30-
protected _ranges: CellRange[] = [];
30+
protected _ranges: SlickRange_[] = [];
3131
protected _eventHandler = new SlickEventHandler();
3232
protected _inHandler = false;
3333
protected _selector?: SlickCellRangeSelector_;
@@ -96,7 +96,7 @@ export class SlickRowSelectionModel {
9696
};
9797
}
9898

99-
protected rangesToRows(ranges: CellRange[]): number[] {
99+
protected rangesToRows(ranges: SlickRange_[]): number[] {
100100
const rows: number[] = [];
101101
for (let i = 0; i < ranges.length; i++) {
102102
for (let j = ranges[i].fromRow; j <= ranges[i].toRow; j++) {
@@ -135,7 +135,7 @@ export class SlickRowSelectionModel {
135135
this.setSelectedRanges(this.rowsToRanges(rows), 'SlickRowSelectionModel.setSelectedRows');
136136
}
137137

138-
setSelectedRanges(ranges: CellRange[], caller = 'SlickRowSelectionModel.setSelectedRanges') {
138+
setSelectedRanges(ranges: SlickRange_[], caller = 'SlickRowSelectionModel.setSelectedRanges') {
139139
// simple check for: empty selection didn't change, prevent firing onSelectedRangesChanged
140140
if ((!this._ranges || this._ranges.length === 0) && (!ranges || ranges.length === 0)) {
141141
return;
@@ -250,7 +250,7 @@ export class SlickRowSelectionModel {
250250
this._grid.setActiveCell(cell.row, cell.cell);
251251
}
252252

253-
protected handleCellRangeSelected(_e: SlickEventData_, args: { range: CellRange; }): boolean | void {
253+
protected handleCellRangeSelected(_e: SlickEventData_, args: { range: SlickRange_; }): boolean | void {
254254
if (!this._grid.getOptions().multiSelect || !this._options.selectActiveRow) {
255255
return false;
256256
}

0 commit comments

Comments
 (0)