@@ -7,8 +7,16 @@ import { GridType } from './grid.interface';
77import { IgxColumnComponent } from '../columns/column.component' ;
88import { ColumnDisplayOrder } from './enums' ;
99import { IgxColumnActionsComponent } from '../column-actions/column-actions.component' ;
10- import { IgxGridRow , IgxSummaryOperand , IgxSummaryResult } from '../grid/public_api' ;
1110import { IgxAddRow } from './crud.service' ;
11+ import { IgxGridRow } from '../grid-public-row' ;
12+ import { IgxTreeGridRowComponent } from '../tree-grid/tree-grid-row.component' ;
13+ import { IgxGridRowComponent } from '../grid/grid-row.component' ;
14+ import { IgxHierarchicalRowComponent } from '../hierarchical-grid/hierarchical-row.component' ;
15+ import { IgxSummaryOperand , IgxSummaryResult } from '../summaries/grid-summary' ;
16+
17+ interface CSSProp {
18+ [ prop : string ] : any ;
19+ }
1220
1321/**
1422 * @hidden
@@ -19,7 +27,7 @@ import { IgxAddRow } from './crud.service';
1927} )
2028export class IgxGridCellStyleClassesPipe implements PipeTransform {
2129
22- public transform ( cssClasses : { [ prop : string ] : any } , _ : any , data : any , field : string , index : number , __ : number ) : string {
30+ public transform ( cssClasses : CSSProp , _ : any , data : any , field : string , index : number , __ : number ) : string {
2331 if ( ! cssClasses ) {
2432 return '' ;
2533 }
@@ -48,8 +56,7 @@ export class IgxGridCellStyleClassesPipe implements PipeTransform {
4856} )
4957export class IgxGridCellStylesPipe implements PipeTransform {
5058
51- public transform ( styles : { [ prop : string ] : any } , _ : any , data : any , field : string , index : number , __ : number ) :
52- { [ prop : string ] : any } {
59+ public transform ( styles : CSSProp , _ : any , data : any , field : string , index : number , __ : number ) : CSSProp {
5360 const css = { } ;
5461 if ( ! styles ) {
5562 return css ;
@@ -64,53 +71,81 @@ export class IgxGridCellStylesPipe implements PipeTransform {
6471 }
6572}
6673
74+ type _RowType = IgxGridRowComponent | IgxTreeGridRowComponent | IgxHierarchicalRowComponent ;
75+
6776/**
6877 * @hidden
6978 * @internal
7079 */
71- @Pipe ( {
72- name : 'igxGridRowClasses'
73- } )
80+ @Pipe ( { name : 'igxGridRowClasses' } )
7481export class IgxGridRowClassesPipe implements PipeTransform {
82+ public row : IgxGridRow ;
7583
76- constructor ( private gridAPI : GridBaseAPIService < IgxGridBaseDirective & GridType > ) { }
84+ constructor ( private gridAPI : GridBaseAPIService < IgxGridBaseDirective & GridType > ) {
85+ this . row = new IgxGridRow ( this . gridAPI . grid as any , - 1 , { } ) ;
86+ }
7787
78- public transform ( cssClasses : { [ prop : string ] : any } , rowData : any , index : number , __ : number ) : string {
79- if ( ! cssClasses ) {
80- return '' ;
88+ public transform (
89+ cssClasses : CSSProp ,
90+ row : _RowType ,
91+ editMode : boolean ,
92+ selected : boolean ,
93+ dirty : boolean ,
94+ deleted : boolean ,
95+ dragging : boolean ,
96+ index : number ,
97+ mrl : boolean ,
98+ filteredOut : boolean ,
99+ _ : number
100+ ) {
101+ const result = new Set ( [ 'igx-grid__tr' , index % 2 ? row . grid . evenRowCSS : row . grid . oddRowCSS ] ) ;
102+ const mapping = [
103+ [ selected , 'igx-grid__tr--selected' ] ,
104+ [ editMode , 'igx-grid__tr--edit' ] ,
105+ [ dirty , 'igx-grid__tr--edited' ] ,
106+ [ deleted , 'igx-grid__tr--deleted' ] ,
107+ [ dragging , 'igx-grid__tr--drag' ] ,
108+ [ mrl , 'igx-grid__tr--mrl' ] ,
109+ // Tree grid only
110+ [ filteredOut , 'igx-grid__tr--filtered' ]
111+ ] ;
112+
113+ for ( const [ state , _class ] of mapping ) {
114+ if ( state ) {
115+ result . add ( _class as string ) ;
116+ }
81117 }
82- const result = [ ] ;
83- for ( const cssClass of Object . keys ( cssClasses ) ) {
118+
119+ for ( const cssClass of Object . keys ( cssClasses ?? { } ) ) {
84120 const callbackOrValue = cssClasses [ cssClass ] ;
85- const row = new IgxGridRow ( ( this . gridAPI . grid as any ) , index , rowData ) ;
86- const apply = typeof callbackOrValue === 'function' ? callbackOrValue ( row ) : callbackOrValue ;
121+ this . row . index = index ;
122+ ( this . row as any ) . _data = row . rowData ;
123+ const apply = typeof callbackOrValue === 'function' ? callbackOrValue ( this . row ) : callbackOrValue ;
87124 if ( apply ) {
88- result . push ( cssClass ) ;
125+ result . add ( cssClass ) ;
89126 }
90127 }
91- return result . join ( ' ' ) ;
128+ return result ;
92129 }
93130}
94131
95132/**
96133 * @hidden
97134 * @internal
98135 */
99- @Pipe ( {
100- name : 'igxGridRowStyles'
101- } )
136+ @Pipe ( { name : 'igxGridRowStyles' } )
102137export class IgxGridRowStylesPipe implements PipeTransform {
103138
104139 constructor ( private gridAPI : GridBaseAPIService < IgxGridBaseDirective & GridType > ) { }
105140
106- public transform ( styles : { [ prop : string ] : any } , rowData : any , index : number , __ : number ) : { [ prop : string ] : any } {
141+ public transform ( styles : CSSProp , rowData : any , index : number , __ : number ) : CSSProp {
107142 const css = { } ;
108143 if ( ! styles ) {
109144 return css ;
110145 }
111146 for ( const prop of Object . keys ( styles ) ) {
112147 const cb = styles [ prop ] ;
113- const row = new IgxGridRow ( ( this . gridAPI . grid as any ) , index , rowData ) ;
148+ const row = new IgxGridRow ( ( this . gridAPI . grid as any ) , index , rowData ) ;
114149 css [ prop ] = typeof cb === 'function' ? cb ( row ) : cb ;
115150 }
116151 return css ;
@@ -394,7 +429,7 @@ export class IgxGridAddRowPipe implements PipeTransform {
394429@Pipe ( { name : 'igxHeaderGroupWidth' } )
395430export class IgxHeaderGroupWidthPipe implements PipeTransform {
396431
397- public transform ( width : any , minWidth : any , hasLayout : boolean ) {
432+ public transform ( width : any , minWidth : any , hasLayout : boolean ) {
398433 return hasLayout ? '' : `${ Math . max ( parseFloat ( width ) , minWidth ) } px` ;
399434 }
400435}
0 commit comments