@@ -42,7 +42,11 @@ export class HaDataTable extends LitElement {
4242 @state ( ) private _filteredData : DataTableRowData [ ] = [ ] ;
4343
4444 private _sortData = memoizeOne (
45- ( data : DataTableRowData [ ] , sortColumn ?: string , sortDirection ?: SortingDirection ) => {
45+ (
46+ data : DataTableRowData [ ] ,
47+ sortColumn ?: string ,
48+ sortDirection ?: SortingDirection ,
49+ ) => {
4650 if ( ! sortColumn || ! sortDirection ) {
4751 return data ;
4852 }
@@ -63,11 +67,15 @@ export class HaDataTable extends LitElement {
6367 } ) ;
6468
6569 return sorted ;
66- }
70+ } ,
6771 ) ;
6872
6973 private _filterData = memoizeOne (
70- ( data : DataTableRowData [ ] , filter : string , columns : DataTableColumnContainer ) => {
74+ (
75+ data : DataTableRowData [ ] ,
76+ filter : string ,
77+ columns : DataTableColumnContainer ,
78+ ) => {
7179 if ( ! filter ) {
7280 return data ;
7381 }
@@ -81,12 +89,16 @@ export class HaDataTable extends LitElement {
8189 return String ( value ) . toLowerCase ( ) . includes ( filterLower ) ;
8290 } ) ;
8391 } ) ;
84- }
92+ } ,
8593 ) ;
8694
8795 protected willUpdate ( ) {
8896 const filtered = this . _filterData ( this . data , this . filter , this . columns ) ;
89- this . _filteredData = this . _sortData ( filtered , this . sortColumn , this . sortDirection ) ;
97+ this . _filteredData = this . _sortData (
98+ filtered ,
99+ this . sortColumn ,
100+ this . sortDirection ,
101+ ) ;
90102 }
91103
92104 private _handleHeaderClick ( columnKey : string ) {
@@ -111,7 +123,7 @@ export class HaDataTable extends LitElement {
111123 detail : { column : this . sortColumn , direction : this . sortDirection } ,
112124 bubbles : true ,
113125 composed : true ,
114- } )
126+ } ) ,
115127 ) ;
116128 }
117129
@@ -121,7 +133,7 @@ export class HaDataTable extends LitElement {
121133 detail : { index, data : this . _filteredData [ index ] } ,
122134 bubbles : true ,
123135 composed : true ,
124- } )
136+ } ) ,
125137 ) ;
126138 }
127139
@@ -131,7 +143,7 @@ export class HaDataTable extends LitElement {
131143 }
132144
133145 const columnKeys = Object . keys ( this . columns ) . filter (
134- ( key ) => ! this . columns [ key ] . hidden
146+ ( key ) => ! this . columns [ key ] . hidden ,
135147 ) ;
136148
137149 return html `
@@ -176,18 +188,20 @@ export class HaDataTable extends LitElement {
176188 </ tr>
177189 </ thead>
178190 <tbody>
179- ${ this . _filteredData . map ( ( row , index ) => html `
180- <tr @click = ${ ( ) => this . _handleRowClick ( index ) } >
181- ${ columnKeys . map ( ( key ) => {
182- const column = this . columns [ key ] ;
183- const cellContent = column . template
184- ? column . template ( row )
185- : row [ key ] ;
186-
187- return html `<td> ${ cellContent } </ td> ` ;
188- } ) }
189- </ tr>
190- ` ) }
191+ ${ this . _filteredData . map (
192+ ( row , index ) => html `
193+ <tr @click = ${ ( ) => this . _handleRowClick ( index ) } >
194+ ${ columnKeys . map ( ( key ) => {
195+ const column = this . columns [ key ] ;
196+ const cellContent = column . template
197+ ? column . template ( row )
198+ : row [ key ] ;
199+
200+ return html `<td> ${ cellContent } </ td> ` ;
201+ } ) }
202+ </ tr>
203+ ` ,
204+ ) }
191205 </ tbody>
192206 </ table>
193207 </ div>
@@ -383,4 +397,4 @@ declare global {
383397 interface HTMLElementTagNameMap {
384398 "ha-data-table" : HaDataTable ;
385399 }
386- }
400+ }
0 commit comments