11import type { ReactiveController } from 'lit' ;
22import { PIPELINE } from '../internal/constants.js' ;
3- import type {
4- ColumnConfiguration ,
5- ColumnSortConfiguration ,
6- GridHost ,
7- Keys ,
8- } from '../internal/types.js' ;
3+ import type { ColumnConfiguration , GridHost , Keys } from '../internal/types.js' ;
94import { asArray } from '../internal/utils.js' ;
105import type { SortingDirection , SortingExpression , SortState } from '../operations/sort/types.js' ;
116
@@ -24,29 +19,29 @@ export class SortController<T extends object> implements ReactiveController {
2419 return true ;
2520 }
2621
27- #resolveSortOptions( options ?: boolean | ColumnSortConfiguration < T > ) {
22+ #resolveSortOptions( column ?: ColumnConfiguration < T > ) {
2823 const expr : Pick < SortingExpression < T > , 'caseSensitive' | 'comparer' > = {
2924 caseSensitive : false ,
3025 comparer : undefined ,
3126 } ;
3227
33- if ( ! options || typeof options === 'boolean' ) {
28+ if ( ! column ) {
3429 return expr as Partial < SortingExpression < T > > ;
3530 }
3631
3732 return Object . assign ( expr , {
38- caseSensitive : options . caseSensitive ,
39- comparer : options . comparer ,
33+ caseSensitive : column . sortingCaseSensitive ,
34+ comparer : column . sortConfiguration ? .comparer ,
4035 } ) as Partial < SortingExpression < T > > ;
4136 }
4237
4338 #createDefaultExpression( key : Keys < T > ) {
44- const options = this . host . getColumn ( key ) ?. sort ;
39+ const column = this . host . getColumn ( key ) ;
4540
4641 return {
4742 key,
4843 direction : 'ascending' ,
49- ...this . #resolveSortOptions( options ) ,
44+ ...this . #resolveSortOptions( column ) ,
5045 } as SortingExpression < T > ;
5146 }
5247
@@ -93,18 +88,18 @@ export class SortController<T extends object> implements ReactiveController {
9388 this . #emitSortedEvent( expression ) ;
9489 }
9590
96- public prepareExpression ( { key , sort : options } : ColumnConfiguration < T > ) : SortingExpression < T > {
97- if ( this . state . has ( key ) ) {
98- const expr = this . state . get ( key ) ! ;
91+ public prepareExpression ( column : ColumnConfiguration < T > ) : SortingExpression < T > {
92+ if ( this . state . has ( column . key ) ) {
93+ const expr = this . state . get ( column . key ) ! ;
9994
10095 return Object . assign ( expr , {
10196 direction : this . #orderBy( expr . direction ) ,
102- ...this . #resolveSortOptions( options ) ,
97+ ...this . #resolveSortOptions( column ) ,
10398 } ) ;
10499 }
105100
106101 // Initial state
107- return this . #createDefaultExpression( key ) ;
102+ return this . #createDefaultExpression( column . key ) ;
108103 }
109104
110105 public reset ( key ?: Keys < T > ) {
0 commit comments