11import messageLocalization from '@js/common/core/localization/message' ;
22import registerComponent from '@js/core/component_registrator' ;
33import devices from '@js/core/devices' ;
4+ import type { DefaultOptionsRule } from '@js/core/options/utils' ;
5+ import type { dxElementWrapper } from '@js/core/renderer' ;
46import $ from '@js/core/renderer' ;
5- import { extend } from '@js/core/utils/extend' ;
67import { getHeight , getWidth } from '@js/core/utils/size' ;
78import { getNavigator } from '@js/core/utils/window' ;
9+ import type { Properties } from '@js/ui/load_indicator' ;
810import { current , isGeneric , isMaterialBased } from '@js/ui/themes' ;
9- import Widget from '@js/ui/widget/ui.widget' ;
11+ import type { OptionChanged } from '@ts/core/widget/types' ;
12+ import Widget from '@ts/core/widget/widget' ;
1013
1114import supportUtils from '../core/utils/m_support' ;
1215
@@ -20,23 +23,36 @@ const LOADINDICATOR_SEGMENT_CLASS = 'dx-loadindicator-segment';
2023const LOADINDICATOR_SEGMENT_INNER_CLASS = 'dx-loadindicator-segment-inner' ;
2124const LOADINDICATOR_IMAGE_CLASS = 'dx-loadindicator-image' ;
2225
23- // @ts -expect-error
24- const LoadIndicator = Widget . inherit ( {
25- _getDefaultOptions ( ) {
26- return extend ( this . callBase ( ) , {
26+ export interface LoadIndicatorProperties extends Properties {
27+ viaImage ?: boolean ;
28+
29+ _animatingSegmentCount ?: number ;
30+
31+ _animatingSegmentInner ?: boolean ;
32+ }
33+
34+ class LoadIndicator extends Widget < LoadIndicatorProperties > {
35+ _$wrapper ! : dxElementWrapper ;
36+
37+ _$content ! : dxElementWrapper ;
38+
39+ _$indicator ?: dxElementWrapper ;
40+
41+ _getDefaultOptions ( ) : LoadIndicatorProperties {
42+ return {
43+ ...super . _getDefaultOptions ( ) ,
2744 indicatorSrc : '' ,
2845 activeStateEnabled : false ,
2946 hoverStateEnabled : false ,
3047 _animatingSegmentCount : 1 ,
3148 _animatingSegmentInner : false ,
49+ } ;
50+ }
3251
33- } ) ;
34- } ,
35-
36- _defaultOptionsRules ( ) {
52+ _defaultOptionsRules ( ) : DefaultOptionsRule < LoadIndicatorProperties > [ ] {
3753 const themeName = current ( ) ;
3854
39- return this . callBase ( ) . concat ( [
55+ return super . _defaultOptionsRules ( ) . concat ( [
4056 {
4157 device ( ) {
4258 const realDevice = devices . real ( ) ;
@@ -48,7 +64,7 @@ const LoadIndicator = Widget.inherit({
4864 } ,
4965 } ,
5066 {
51- device ( ) {
67+ device ( ) : boolean {
5268 return isMaterialBased ( themeName ) ;
5369 } ,
5470 options : {
@@ -57,22 +73,23 @@ const LoadIndicator = Widget.inherit({
5773 } ,
5874 } ,
5975 {
60- device ( ) {
76+ device ( ) : boolean {
6177 return isGeneric ( themeName ) ;
6278 } ,
6379 options : {
6480 _animatingSegmentCount : 7 ,
6581 } ,
6682 } ,
6783 ] ) ;
68- } ,
84+ }
6985
70- _useTemplates ( ) {
86+ // eslint-disable-next-line class-methods-use-this
87+ _useTemplates ( ) : boolean {
7188 return false ;
72- } ,
89+ }
7390
74- _init ( ) {
75- this . callBase ( ) ;
91+ _init ( ) : void {
92+ super . _init ( ) ;
7693
7794 this . $element ( ) . addClass ( LOADINDICATOR_CLASS ) ;
7895
@@ -83,45 +100,47 @@ const LoadIndicator = Widget.inherit({
83100 } ;
84101
85102 this . setAria ( aria ) ;
86- } ,
103+ }
87104
88- _initMarkup ( ) {
89- this . callBase ( ) ;
105+ _initMarkup ( ) : void {
106+ super . _initMarkup ( ) ;
90107 this . _renderWrapper ( ) ;
91108 this . _renderIndicatorContent ( ) ;
92109 this . _renderMarkup ( ) ;
93- } ,
110+ }
94111
95- _renderWrapper ( ) {
112+ _renderWrapper ( ) : void {
96113 this . _$wrapper = $ ( '<div>' ) . addClass ( LOADINDICATOR_WRAPPER_CLASS ) ;
97114 this . $element ( ) . append ( this . _$wrapper ) ;
98- } ,
115+ }
99116
100- _renderIndicatorContent ( ) {
117+ _renderIndicatorContent ( ) : void {
101118 this . _$content = $ ( '<div>' ) . addClass ( LOADINDICATOR_CONTENT_CLASS ) ;
102119 this . _$wrapper . append ( this . _$content ) ;
103- } ,
120+ }
104121
105- _renderMarkup ( ) {
122+ _renderMarkup ( ) : void {
106123 const { viaImage, indicatorSrc } = this . option ( ) ;
107124
108125 if ( supportUtils . animation ( ) && ! viaImage && ! indicatorSrc ) { // B236922
109126 this . _renderMarkupForAnimation ( ) ;
110127 } else {
111128 this . _renderMarkupForImage ( ) ;
112129 }
113- } ,
130+ }
114131
115- _renderMarkupForAnimation ( ) {
132+ _renderMarkupForAnimation ( ) : void {
116133 const animatingSegmentInner = this . option ( '_animatingSegmentInner' ) ;
117134
118135 this . _$indicator = $ ( '<div>' ) . addClass ( LOADINDICATOR_ICON_CLASS ) ;
119136 this . _$content . append ( this . _$indicator ) ;
120137
121138 // Indicator markup
139+ // @ts -expect-error ts-error
122140 for ( let i = this . option ( '_animatingSegmentCount' ) ; i >= 0 ; -- i ) {
123141 const $segment = $ ( '<div>' )
124142 . addClass ( LOADINDICATOR_SEGMENT_CLASS )
143+ // eslint-disable-next-line @typescript-eslint/restrict-plus-operands, @typescript-eslint/no-base-to-string
125144 . addClass ( LOADINDICATOR_SEGMENT_CLASS + i ) ;
126145
127146 if ( animatingSegmentInner ) {
@@ -130,9 +149,9 @@ const LoadIndicator = Widget.inherit({
130149
131150 this . _$indicator . append ( $segment ) ;
132151 }
133- } ,
152+ }
134153
135- _renderMarkupForImage ( ) {
154+ _renderMarkupForImage ( ) : void {
136155 const { indicatorSrc } = this . option ( ) ;
137156
138157 if ( indicatorSrc ) {
@@ -141,14 +160,14 @@ const LoadIndicator = Widget.inherit({
141160 } else if ( supportUtils . animation ( ) ) {
142161 this . _renderMarkupForAnimation ( ) ;
143162 }
144- } ,
163+ }
145164
146- _renderDimensions ( ) {
147- this . callBase ( ) ;
165+ _renderDimensions ( ) : void {
166+ super . _renderDimensions ( ) ;
148167 this . _updateContentSizeForAnimation ( ) ;
149- } ,
168+ }
150169
151- _updateContentSizeForAnimation ( ) {
170+ _updateContentSizeForAnimation ( ) : void {
152171 if ( ! this . _$indicator ) {
153172 return ;
154173 }
@@ -159,6 +178,7 @@ const LoadIndicator = Widget.inherit({
159178 if ( width || height ) {
160179 width = getWidth ( this . $element ( ) ) ;
161180 height = getHeight ( this . $element ( ) ) ;
181+ // @ts -expect-error ts-error
162182 const minDimension = Math . min ( height , width ) ;
163183
164184 this . _$wrapper . css ( {
@@ -167,40 +187,40 @@ const LoadIndicator = Widget.inherit({
167187 fontSize : minDimension ,
168188 } ) ;
169189 }
170- } ,
190+ }
171191
172- _clean ( ) {
173- this . callBase ( ) ;
192+ _clean ( ) : void {
193+ super . _clean ( ) ;
174194
175195 this . _removeMarkupForAnimation ( ) ;
176196 this . _removeMarkupForImage ( ) ;
177- } ,
197+ }
178198
179- _removeMarkupForAnimation ( ) {
199+ _removeMarkupForAnimation ( ) : void {
180200 if ( ! this . _$indicator ) {
181201 return ;
182202 }
183203
184204 this . _$indicator . remove ( ) ;
185205 delete this . _$indicator ;
186- } ,
206+ }
187207
188- _removeMarkupForImage ( ) {
208+ _removeMarkupForImage ( ) : void {
189209 this . _$wrapper . css ( 'backgroundImage' , 'none' ) ;
190- } ,
210+ }
191211
192- _optionChanged ( args ) {
212+ _optionChanged ( args : OptionChanged < LoadIndicatorProperties > ) : void {
193213 switch ( args . name ) {
194214 case '_animatingSegmentCount' :
195215 case '_animatingSegmentInner' :
196216 case 'indicatorSrc' :
197217 this . _invalidate ( ) ;
198218 break ;
199219 default :
200- this . callBase ( args ) ;
220+ super . _optionChanged ( args ) ;
201221 }
202- } ,
203- } ) ;
222+ }
223+ }
204224
205225registerComponent ( 'dxLoadIndicator' , LoadIndicator ) ;
206226
0 commit comments