@@ -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,82 @@ 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+ rowData : any ,
92+ selected : boolean ,
93+ dirty : boolean ,
94+ deleted : boolean ,
95+ dragging : boolean ,
96+ index : number ,
97+ mrl : boolean ,
98+ _ : number
99+ ) {
100+ const result = new Set ( [ 'igx-grid__tr' , index % 2 ? row . grid . evenRowCSS : row . grid . oddRowCSS ] ) ;
101+ const mapping = [
102+ [ selected , 'igx-grid__tr--selected' ] ,
103+ [ row . inEditMode , 'igx-grid_-tr--edit' ] ,
104+ [ dirty , 'igx-grid__tr--edited' ] ,
105+ [ deleted , 'igx-grid__tr--deleted' ] ,
106+ [ dragging , 'igx-grid__tr--drag' ] ,
107+ [ mrl , 'igx-grid__tr--mrl' ]
108+ ] ;
109+
110+ for ( const [ state , _class ] of mapping ) {
111+ if ( state ) {
112+ result . add ( _class as string ) ;
113+ }
81114 }
82- const result = [ ] ;
83- for ( const cssClass of Object . keys ( cssClasses ) ) {
115+
116+ if ( row instanceof IgxTreeGridRowComponent && row . treeRow . isFilteredOutParent ) {
117+ result . add ( 'igx-grid__tr--filtered' ) ;
118+ }
119+
120+ for ( const cssClass of Object . keys ( cssClasses ?? { } ) ) {
84121 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 ;
122+ this . row . index = index ;
123+ ( this . row as any ) . _data = rowData ;
124+ const apply = typeof callbackOrValue === 'function' ? callbackOrValue ( this . row ) : callbackOrValue ;
87125 if ( apply ) {
88- result . push ( cssClass ) ;
126+ result . add ( cssClass ) ;
89127 }
90128 }
91- return result . join ( ' ' ) ;
129+ return result ;
92130 }
93131}
94132
95133/**
96134 * @hidden
97135 * @internal
98136 */
99- @Pipe ( {
100- name : 'igxGridRowStyles'
101- } )
137+ @Pipe ( { name : 'igxGridRowStyles' } )
102138export class IgxGridRowStylesPipe implements PipeTransform {
103139
104140 constructor ( private gridAPI : GridBaseAPIService < IgxGridBaseDirective & GridType > ) { }
105141
106- public transform ( styles : { [ prop : string ] : any } , rowData : any , index : number , __ : number ) : { [ prop : string ] : any } {
142+ public transform ( styles : CSSProp , rowData : any , index : number , __ : number ) : CSSProp {
107143 const css = { } ;
108144 if ( ! styles ) {
109145 return css ;
110146 }
111147 for ( const prop of Object . keys ( styles ) ) {
112148 const cb = styles [ prop ] ;
113- const row = new IgxGridRow ( ( this . gridAPI . grid as any ) , index , rowData ) ;
149+ const row = new IgxGridRow ( ( this . gridAPI . grid as any ) , index , rowData ) ;
114150 css [ prop ] = typeof cb === 'function' ? cb ( row ) : cb ;
115151 }
116152 return css ;
@@ -394,7 +430,7 @@ export class IgxGridAddRowPipe implements PipeTransform {
394430@Pipe ( { name : 'igxHeaderGroupWidth' } )
395431export class IgxHeaderGroupWidthPipe implements PipeTransform {
396432
397- public transform ( width : any , minWidth : any , hasLayout : boolean ) {
433+ public transform ( width : any , minWidth : any , hasLayout : boolean ) {
398434 return hasLayout ? '' : `${ Math . max ( parseFloat ( width ) , minWidth ) } px` ;
399435 }
400436}
0 commit comments