@@ -4,16 +4,18 @@ import type { dxElementWrapper } from '@js/core/renderer';
44import $ from '@js/core/renderer' ;
55import { equalByValue } from '@js/core/utils/common' ;
66import { isRenderer } from '@js/core/utils/type' ;
7- import type { CollectionWidgetItem } from '@js/ui/collection/ui.collection_widget.base' ;
7+ import type { ItemLike } from '@js/ui/collection/ui.collection_widget.base' ;
88import type CollectionWidget from '@ts/ui/collection/m_collection_widget.edit' ;
99import type { CollectionWidgetEditProperties } from '@ts/ui/collection/m_collection_widget.edit' ;
1010
1111export type CollectionItemIndex = number | { group : number ; item : number } ;
1212
1313export type EditStrategyComponent <
14- TItem extends CollectionWidgetItem = CollectionWidgetItem ,
14+ TItem extends ItemLike = ItemLike ,
15+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16+ TKey = any ,
1517// eslint-disable-next-line @typescript-eslint/no-explicit-any
16- > = Pick < CollectionWidget < CollectionWidgetEditProperties < any , TItem > , TItem > ,
18+ > = Pick < CollectionWidget < CollectionWidgetEditProperties < any , TItem , TKey > , TItem , TKey > ,
1719 'keyOf'
1820 | '_isKeySpecified'
1921 | '_itemElements'
@@ -22,19 +24,22 @@ export type EditStrategyComponent<
2224 | '_dataController'
2325> ;
2426
25- interface KeysCache {
27+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28+ interface KeysCache < TKey = any > {
2629 [ key : string ] : unknown ;
27- keys ?: ( string | number ) [ ] ;
30+ keys ?: TKey [ ] ;
2831}
2932class EditStrategy <
3033 // eslint-disable-next-line @typescript-eslint/no-explicit-any
31- TItem extends CollectionWidgetItem = any ,
34+ TItem extends ItemLike = any ,
35+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36+ TKey = any ,
3237> {
33- _collectionWidget ! : EditStrategyComponent < TItem > ;
38+ _collectionWidget ! : EditStrategyComponent < TItem , TKey > ;
3439
35- _cache ?: KeysCache | null ;
40+ _cache ?: KeysCache < TKey > | null ;
3641
37- constructor ( collectionWidget : EditStrategyComponent < TItem > ) {
42+ constructor ( collectionWidget : EditStrategyComponent < TItem , TKey > ) {
3843 this . _collectionWidget = collectionWidget ;
3944 }
4045
@@ -54,12 +59,12 @@ class EditStrategy<
5459 }
5560
5661 // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
57- getKeysByItems ( items : TItem [ ] ) : ( string | number ) [ ] {
62+ getKeysByItems ( items : TItem [ ] ) : TKey [ ] {
5863 return Class . abstract ( ) ;
5964 }
6065
6166 // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
62- getItemsByKeys ( keys : ( string | number ) [ ] , items ?: TItem [ ] ) : TItem [ ] {
67+ getItemsByKeys ( keys : TKey [ ] , items ?: TItem [ ] ) : TItem [ ] {
6368 return Class . abstract ( ) ;
6469 }
6570
@@ -68,13 +73,13 @@ class EditStrategy<
6873 return Class . abstract ( ) ;
6974 }
7075
71- getKeyByIndex ( index : number ) : string | number {
76+ getKeyByIndex ( index : number ) : TKey {
7277 const resultIndex = this . _denormalizeItemIndex ( index ) ;
7378
7479 return this . getKeysByItems ( [ this . getItemDataByIndex ( resultIndex as number ) ] ) [ 0 ] ;
7580 }
7681
77- _equalKeys ( key1 : string | number , key2 : string | number ) : boolean {
82+ _equalKeys ( key1 : TKey , key2 : TKey ) : boolean {
7883 if ( this . _collectionWidget . _isKeySpecified ( ) ) {
7984 return equalByValue ( key1 , key2 ) ;
8085 }
@@ -90,7 +95,7 @@ class EditStrategy<
9095 }
9196
9297 // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
93- getIndexByKey ( key : string | number ) : number {
98+ getIndexByKey ( key : TKey ) : number {
9499 return Class . abstract ( ) ;
95100 }
96101
@@ -147,8 +152,7 @@ class EditStrategy<
147152
148153 // eslint-disable-next-line class-methods-use-this
149154 _isNode ( el : unknown ) : el is Element {
150- // @ts -expect-error Property 'get' does not exist on type 'unknown'
151- return domAdapter . isNode ( el && isRenderer ( el ) ? el . get ( 0 ) : el ) ;
155+ return domAdapter . isNode ( el && isRenderer ( el ) ? ( el as dxElementWrapper ) . get ( 0 ) : el ) ;
152156 }
153157
154158 // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
0 commit comments