From 36173fcc6ae621952f60f0d44a31f09c378990e7 Mon Sep 17 00:00:00 2001 From: ghiscoding Date: Thu, 7 Dec 2023 00:45:05 -0500 Subject: [PATCH] chore: add more TS types to DataView --- src/models/dataViewHints.interface.ts | 7 +++++++ src/models/index.ts | 1 + src/slick.dataview.ts | 26 ++++++++++++-------------- 3 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 src/models/dataViewHints.interface.ts diff --git a/src/models/dataViewHints.interface.ts b/src/models/dataViewHints.interface.ts new file mode 100644 index 00000000..f6d4f1f5 --- /dev/null +++ b/src/models/dataViewHints.interface.ts @@ -0,0 +1,7 @@ +export interface DataViewHints { + ignoreDiffsBefore?: number; + ignoreDiffsAfter?: number; + isFilterNarrowing?: boolean; + isFilterExpanding?: boolean; + isFilterUnchanged?: boolean; +} \ No newline at end of file diff --git a/src/models/index.ts b/src/models/index.ts index 04a2d004..171de488 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -15,6 +15,7 @@ export * from './core.interface'; export * from './cssDeclaration.interface'; export * from './customTooltipOption.interface'; export * from './dataViewEvents.interface'; +export * from './dataViewHints.interface'; export * from './domEvent.interface'; export * from './drag.interface'; export * from './draggableGroupingOption.interface'; diff --git a/src/slick.dataview.ts b/src/slick.dataview.ts index 5be99c6b..efbc6061 100644 --- a/src/slick.dataview.ts +++ b/src/slick.dataview.ts @@ -2,6 +2,7 @@ import type { Aggregator, CssStyleHash, CustomDataView, + DataViewHints, Grouping, GroupingFormatterItem, ItemMetadata, @@ -77,8 +78,8 @@ export class SlickDataView implements CustomD protected sortAsc: boolean | undefined = true; protected fastSortField?: string | null | (() => string); protected sortComparer!: ((a: TData, b: TData) => number); - protected refreshHints: any = {}; - protected prevRefreshHints: any = {}; + protected refreshHints: DataViewHints = {}; + protected prevRefreshHints: DataViewHints = {}; protected filterArgs: any; protected filteredItems: TData[] = []; protected compiledFilter?: FilterFn | null; @@ -187,7 +188,7 @@ export class SlickDataView implements CustomD } } - setRefreshHints(hints: any) { + setRefreshHints(hints: DataViewHints) { this.refreshHints = hints; } @@ -832,8 +833,8 @@ export class SlickDataView implements CustomD collapseGroup(...args: any) { const calledArgs = Array.prototype.slice.call(args); const arg0 = calledArgs[0]; - let groupingKey; - let level; + let groupingKey: string; + let level: number; if (args.length === 1 && arg0.indexOf(this.groupingDelimiter) !== -1) { groupingKey = arg0; @@ -856,8 +857,8 @@ export class SlickDataView implements CustomD expandGroup(...args: any) { const calledArgs = Array.prototype.slice.call(args); const arg0 = calledArgs[0]; - let groupingKey; - let level; + let groupingKey: string; + let level: number; if (args.length === 1 && arg0.indexOf(this.groupingDelimiter) !== -1) { level = arg0.split(this.groupingDelimiter).length - 1; @@ -876,8 +877,8 @@ export class SlickDataView implements CustomD } protected extractGroups(rows: any[], parentGroup?: SlickGroup_) { - let group; - let val; + let group: SlickGroup_; + let val: any; const groups: SlickGroup_[] = []; const groupsByVal: any = {}; let r; @@ -1182,10 +1183,7 @@ export class SlickDataView implements CustomD */ protected setFunctionName(fn: any, fnName: string) { try { - Object.defineProperty(fn, 'name', { - writable: true, - value: fnName - }); + Object.defineProperty(fn, 'name', { writable: true, value: fnName }); } catch (err) { fn.name = fnName; } @@ -1265,7 +1263,7 @@ export class SlickDataView implements CustomD } protected getRowDiffs(rows: TData[], newRows: TData[]) { - let item: any; + let item: TData | SlickNonDataItem | SlickDataItem | SlickGroup_; let r; let eitherIsNonData; const diff: number[] = [];