Skip to content

Commit ca2f1d5

Browse files
authored
Grids' template context cleanup (#12772)
* refactor(grid): explicit template context types * refactor(grids): explicitly type public template ref w/o context
1 parent 8c7b36b commit ca2f1d5

File tree

7 files changed

+37
-31
lines changed

7 files changed

+37
-31
lines changed

projects/igniteui-angular/src/lib/grids/columns/column.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy, ColumnTy
772772

773773
/** @hidden */
774774
@Input()
775-
public collapsibleIndicatorTemplate: TemplateRef<any>;
775+
public collapsibleIndicatorTemplate: TemplateRef<IgxColumnTemplateContext>;
776776

777777
/**
778778
* Row index where the current field should end.
@@ -867,6 +867,7 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy, ColumnTy
867867
protected summaryTemplateDirective: IgxSummaryTemplateDirective;
868868
/**
869869
* @hidden
870+
* @see {@link bodyTemplate}
870871
*/
871872
@ContentChild(IgxCellTemplateDirective, { read: IgxCellTemplateDirective })
872873
protected cellTemplate: IgxCellTemplateDirective;

projects/igniteui-angular/src/lib/grids/common/grid.interface.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -780,32 +780,37 @@ export interface IgxCellTemplateContext {
780780
cell: CellType
781781
}
782782

783+
export interface IgxRowSelectorTemplateDetails {
784+
index: number;
785+
/** @deprecated Use `key` */
786+
rowID: any;
787+
key: any;
788+
selected: boolean;
789+
select?: () => void;
790+
deselect?: () => void;
791+
}
792+
783793
export interface IgxRowSelectorTemplateContext {
784-
$implicit: {
785-
index: number,
786-
rowID: any,
787-
key: any,
788-
selected: boolean,
789-
select?: () => void,
790-
deselect?: () => void
791-
}
794+
$implicit: IgxRowSelectorTemplateDetails;
792795
}
793796

797+
export interface IgxGroupByRowSelectorTemplateDetails {
798+
selectedCount: number;
799+
totalCount: number;
800+
groupRow: IGroupByRecord;
801+
}
794802
export interface IgxGroupByRowSelectorTemplateContext {
795-
$implicit: {
796-
selectedCount: number,
797-
totalCount: number,
798-
groupRow: IGroupByRecord
799-
}
803+
$implicit: IgxGroupByRowSelectorTemplateDetails;
800804
}
801805

806+
export interface IgxHeadSelectorTemplateDetails {
807+
selectedCount: number;
808+
totalCount: number;
809+
selectAll?: () => void;
810+
deselectAll?: () => void;
811+
}
802812
export interface IgxHeadSelectorTemplateContext {
803-
$implicit: {
804-
selectedCount: number;
805-
totalCount: number;
806-
selectAll?: () => void;
807-
deselectAll?: () => void;
808-
};
813+
$implicit: IgxHeadSelectorTemplateDetails;
809814
}
810815

811816
export interface IgxSummaryTemplateContext {

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
245245
* ```
246246
*/
247247
@Input()
248-
public emptyGridTemplate: TemplateRef<any>;
248+
public emptyGridTemplate: TemplateRef<void>;
249249

250250
/**
251251
* Gets/Sets a custom template for adding row UI when grid is empty.
@@ -256,7 +256,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
256256
* ```
257257
*/
258258
@Input()
259-
public addRowEmptyTemplate: TemplateRef<any>;
259+
public addRowEmptyTemplate: TemplateRef<void>;
260260

261261
/**
262262
* Gets/Sets a custom template when loading.
@@ -267,7 +267,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
267267
* ```
268268
*/
269269
@Input()
270-
public loadingGridTemplate: TemplateRef<any>;
270+
public loadingGridTemplate: TemplateRef<void>;
271271

272272
/**
273273
* Get/Set IgxSummaryRow height

projects/igniteui-angular/src/lib/grids/grid/grid.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
149149
* ```
150150
*/
151151
@Input()
152-
public dropAreaTemplate: TemplateRef<any>;
152+
public dropAreaTemplate: TemplateRef<void>;
153153

154154
/**
155155
* @hidden @internal

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
372372
* @hidden @internal
373373
*/
374374
@Input()
375-
public addRowEmptyTemplate: TemplateRef<any>;
375+
public addRowEmptyTemplate: TemplateRef<void>;
376376

377377
/**
378378
* @hidden @internal
@@ -2176,7 +2176,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
21762176
* ```
21772177
*/
21782178
@Input()
2179-
public emptyPivotGridTemplate: TemplateRef<any>;
2179+
public emptyPivotGridTemplate: TemplateRef<void>;
21802180

21812181
/**
21822182
* @hidden @internal

projects/igniteui-angular/src/lib/grids/public_api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export {
1717
CellType, RowType, IGX_GRID_BASE, ValidationStatus, IGridFormGroupCreatedEventArgs, IGridValidationState, IGridValidationStatusEventArgs, IRecordValidationState, IFieldValidationState, ColumnType,
1818
IgxGridMasterDetailContext, IgxGroupByRowTemplateContext, IgxGridTemplateContext, IgxGridRowTemplateContext, IgxGridRowDragGhostContext, IgxGridEmptyTemplateContext, IgxGridRowEditTemplateContext,
1919
IgxGridRowEditTextTemplateContext, IgxGridRowEditActionsTemplateContext, IgxGridHeaderTemplateContext, IgxColumnTemplateContext, IgxCellTemplateContext, IgxGroupByRowSelectorTemplateContext,
20-
IgxHeadSelectorTemplateContext, IgxSummaryTemplateContext
20+
IgxHeadSelectorTemplateContext, IgxSummaryTemplateContext, IgxHeadSelectorTemplateDetails, IgxGroupByRowSelectorTemplateDetails, IgxRowSelectorTemplateContext, IgxRowSelectorTemplateDetails
2121
} from './common/grid.interface';
2222
export * from './summaries/grid-summary';
2323
export * from './grid-common.module';
@@ -38,4 +38,4 @@ export * from './summaries/summary.module';
3838
export * from './grouping/tree-grid-group-by-area.component';
3939
export * from './grouping/grid-group-by-area.component';
4040
export * from './grouping/group-by-area.directive';
41-
export { DropPosition } from './moving/moving.service';
41+
export { DropPosition } from './moving/moving.service';

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export class IgxTreeGridComponent extends IgxGridBaseDirective implements GridTy
277277
protected _filterStrategy = new TreeGridFilteringStrategy();
278278
protected _transactions: HierarchicalTransactionService<HierarchicalTransaction, HierarchicalState>;
279279
private _data;
280-
private _rowLoadingIndicatorTemplate: TemplateRef<any>;
280+
private _rowLoadingIndicatorTemplate: TemplateRef<void>;
281281
private _expansionDepth = Infinity;
282282
private _filteredData = null;
283283

@@ -377,11 +377,11 @@ export class IgxTreeGridComponent extends IgxGridBaseDirective implements GridTy
377377
* @memberof IgxTreeGridComponent
378378
*/
379379
@Input()
380-
public get rowLoadingIndicatorTemplate(): TemplateRef<any> {
380+
public get rowLoadingIndicatorTemplate(): TemplateRef<void> {
381381
return this._rowLoadingIndicatorTemplate;
382382
}
383383

384-
public set rowLoadingIndicatorTemplate(value: TemplateRef<any>) {
384+
public set rowLoadingIndicatorTemplate(value: TemplateRef<void>) {
385385
this._rowLoadingIndicatorTemplate = value;
386386
this.notifyChanges();
387387
}

0 commit comments

Comments
 (0)