@@ -26,7 +26,6 @@ import { getOuterHeight, getOuterWidth } from '@js/core/utils/size';
26
26
import { findTemplates } from '@js/core/utils/template_manager' ;
27
27
import { isDefined , isFunction , isPlainObject } from '@js/core/utils/type' ;
28
28
import type { DataSourceOptions } from '@js/data/data_source' ;
29
- import DataHelperMixin from '@js/data_helper' ;
30
29
import type {
31
30
Cancelable , DxEvent , EventInfo , ItemInfo ,
32
31
} from '@js/events' ;
@@ -35,6 +34,7 @@ import { focusable } from '@js/ui/widget/selectors';
35
34
import { getPublicElement } from '@ts/core/m_element' ;
36
35
import type { OptionChanged } from '@ts/core/widget/types' ;
37
36
import Widget from '@ts/core/widget/widget' ;
37
+ import { DataHelperMixin } from '@ts/data/m_data_helper' ;
38
38
import CollectionWidgetItem from '@ts/ui/collection/m_item' ;
39
39
40
40
const COLLECTION_CLASS = 'dx-collection' ;
@@ -91,7 +91,11 @@ export interface CollectionWidgetBaseProperties<
91
91
92
92
focusOnSelectedItem ?: boolean ;
93
93
94
+ encodeNoDataText ?: boolean ;
95
+
94
96
_itemAttributes ?: Record < string , string > ;
97
+
98
+ selectOnFocus ?: boolean ;
95
99
}
96
100
97
101
class CollectionWidget <
@@ -101,7 +105,7 @@ class CollectionWidget<
101
105
TItem extends ItemLike = any ,
102
106
// eslint-disable-next-line @typescript-eslint/no-explicit-any
103
107
TKey = any ,
104
- > extends Widget < TProperties > {
108
+ > extends DataHelperMixin ( Widget ) < TProperties > {
105
109
private _focusedItemId ?: string ;
106
110
107
111
// eslint-disable-next-line no-restricted-globals
@@ -121,6 +125,8 @@ class CollectionWidget<
121
125
122
126
_itemFocusHandler ?: ( ) => void ;
123
127
128
+ onFocusedItemChanged ?: ( event ?: Partial < EventInfo < unknown > & ItemInfo < TItem > > ) => void ;
129
+
124
130
_inkRipple ?: {
125
131
showWave : ( config : {
126
132
element : dxElementWrapper ;
@@ -234,14 +240,12 @@ class CollectionWidget<
234
240
235
241
_init ( ) : void {
236
242
this . _compileDisplayGetter ( ) ;
237
- // @ts -expect-error ts-error
238
243
this . _initDataController ( ) ;
239
244
super . _init ( ) ;
240
245
241
246
this . _activeStateUnit = `.${ ITEM_CLASS } ` ;
242
247
243
248
this . _cleanRenderedItems ( ) ;
244
- // @ts -expect-error ts-error
245
249
this . _refreshDataSource ( ) ;
246
250
}
247
251
@@ -575,7 +579,7 @@ class CollectionWidget<
575
579
this . _updateFocusedItemState ( $target , true ) ;
576
580
// @ts -expect-error ts-error
577
581
this . onFocusedItemChanged ( this . getFocusedItemId ( ) ) ;
578
- // @ts -expect-error ts-error
582
+
579
583
const { selectOnFocus } = this . option ( ) ;
580
584
const isTargetDisabled = this . _isDisabled ( $target ) ;
581
585
@@ -683,7 +687,6 @@ class CollectionWidget<
683
687
this . _invalidate ( ) ;
684
688
break ;
685
689
case 'dataSource' :
686
- // @ts -expect-error ts-error
687
690
this . _refreshDataSource ( ) ;
688
691
// @ts -expect-error ts-error
689
692
this . _renderEmptyMessage ( ) ;
@@ -709,7 +712,6 @@ class CollectionWidget<
709
712
this . _attachContextMenuEvent ( ) ;
710
713
break ;
711
714
case 'onFocusedItemChanged' :
712
- // @ts -expect-error ts-error
713
715
this . onFocusedItemChanged = this . _createActionByOption ( 'onFocusedItemChanged' ) ;
714
716
break ;
715
717
case 'selectOnFocus' :
@@ -742,7 +744,6 @@ class CollectionWidget<
742
744
743
745
_loadNextPage ( ) : Promise < unknown > {
744
746
this . _expectNextPageLoading ( ) ;
745
- // @ts -expect-error ts-error
746
747
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
747
748
return this . _dataController . loadNextPage ( ) ;
748
749
}
@@ -866,7 +867,6 @@ class CollectionWidget<
866
867
867
868
_initMarkup ( ) : void {
868
869
super . _initMarkup ( ) ;
869
- // @ts -expect-error ts-error
870
870
this . onFocusedItemChanged = this . _createActionByOption ( 'onFocusedItemChanged' ) ;
871
871
872
872
this . $element ( ) . addClass ( COLLECTION_CLASS ) ;
@@ -1355,8 +1355,8 @@ class CollectionWidget<
1355
1355
_renderEmptyMessage ( items : TItem [ ] ) : void {
1356
1356
// eslint-disable-next-line no-param-reassign
1357
1357
items = items || this . option ( 'items' ) ;
1358
- const noDataText = this . option ( 'noDataText' ) ;
1359
- // @ts -expect-error ts-error
1358
+ const { noDataText } = this . option ( ) ;
1359
+
1360
1360
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
1361
1361
const hideNoData = ! noDataText || ( items && items . length ) || this . _dataController . isLoading ( ) ;
1362
1362
@@ -1371,11 +1371,11 @@ class CollectionWidget<
1371
1371
this . _$noData = this . _$noData ?? $ ( '<div>' ) . addClass ( 'dx-empty-message' ) ;
1372
1372
this . _$noData . appendTo ( this . _emptyMessageContainer ( ) ) ;
1373
1373
1374
- if ( this . option ( 'encodeNoDataText' ) ) {
1375
- // @ts -expect-error ts-error
1374
+ const { encodeNoDataText } = this . option ( ) ;
1375
+
1376
+ if ( encodeNoDataText ) {
1376
1377
this . _$noData . text ( noDataText ) ;
1377
1378
} else {
1378
- // @ts -expect-error ts-error
1379
1379
this . _$noData . html ( noDataText ) ;
1380
1380
}
1381
1381
}
@@ -1483,9 +1483,6 @@ class CollectionWidget<
1483
1483
}
1484
1484
}
1485
1485
1486
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1487
- ( CollectionWidget as any ) . include ( DataHelperMixin ) ;
1488
-
1489
1486
// @ts -expect-error ts-error
1490
1487
CollectionWidget . ItemClass = CollectionWidgetItem ;
1491
1488
0 commit comments