Skip to content

Commit e38f33f

Browse files
Overlay, Popup, Toast, Popover, LoadIndicator, LoadPanel: convert into ES6 class (DevExpress#29189)
1 parent 384dd37 commit e38f33f

File tree

22 files changed

+1233
-888
lines changed

22 files changed

+1233
-888
lines changed

packages/devextreme/js/__internal/core/widget/component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export class Component<
200200

201201
_logDeprecatedOptionWarning(
202202
option: string,
203-
info: { since: string; message: string; alias: string },
203+
info: { since: string; message: string; alias?: string },
204204
): void {
205205
const message = info.message || `Use the '${info.alias}' option instead`;
206206
errors.log('W0001', this.NAME, option, info.since, message);
@@ -480,7 +480,7 @@ export class Component<
480480

481481
// eslint-disable-next-line @stylistic/max-len
482482
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
483-
_getOptionValue(name: string, context: any): any {
483+
_getOptionValue(name: string, context?: any): any {
484484
const value = this.option(name);
485485

486486
if (isFunction(value)) {

packages/devextreme/js/__internal/core/widget/widget.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ class Widget<
6060

6161
private _isReady?: boolean;
6262

63-
// eslint-disable-next-line @stylistic/max-len
64-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
65-
static getOptionsFromContainer({ name, fullName, value }) {
63+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
64+
static getOptionsFromContainer({ name, fullName, value }): Record<string, unknown> {
6665
let options = {};
6766

6867
if (name === fullName) {
@@ -205,7 +204,7 @@ class Widget<
205204
.done(() => (!this._disposed ? this._fireContentReadyAction() : void 0));
206205
}
207206

208-
_renderContentImpl(): void {}
207+
_renderContentImpl(): Promise<void> | void {}
209208

210209
_fireContentReadyAction(): Promise<void> | DeferredObj<void> | void {
211210
return deferRender(() => this._contentReadyAction?.());
@@ -305,7 +304,6 @@ class Widget<
305304
return this._focusTarget();
306305
}
307306

308-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
309307
_focusInHandler(event: DxEvent): void {
310308
if (!event.isDefaultPrevented()) {
311309
this._createActionByOption('onFocusIn', {
@@ -315,7 +313,6 @@ class Widget<
315313
}
316314
}
317315

318-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
319316
_focusOutHandler(event: DxEvent): void {
320317
if (!event.isDefaultPrevented()) {
321318
this._createActionByOption('onFocusOut', {

packages/devextreme/js/__internal/grids/grid_core/validating/m_validating.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,7 @@ export const validatingEditorFactoryExtender = (Base: ModuleType<EditorFactory>)
11441144
onPositioned: this.overlayPositionedHandler.bind(this),
11451145
};
11461146

1147+
// @ts-expect-error ts-error
11471148
this._revertTooltip = new Overlay($tooltipElement, tooltipOptions);
11481149
}
11491150

packages/devextreme/js/__internal/ui/chat/messagelist.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class MessageList extends Widget<Properties> {
114114
}
115115

116116
_renderContentImpl(): void {
117+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
117118
super._renderContentImpl();
118119

119120
this._attachResizeObserverSubscription();

packages/devextreme/js/__internal/ui/drop_down_editor/m_drop_down_editor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ class DropDownEditor<
639639
// @ts-expect-error ts-error
640640
this._popup = this._createComponent(this._$popup, Popup, popupConfig);
641641

642-
this._popup.on({
642+
this._popup!.on({
643643
showing: this._popupShowingHandler.bind(this),
644644
shown: this._popupShownHandler.bind(this),
645645
hiding: this._popupHidingHandler.bind(this),

packages/devextreme/js/__internal/ui/m_dialog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const custom = function (options) {
8383
.attr('id', messageId);
8484

8585
const popupToolbarItems = [];
86-
86+
// @ts-expect-error ts-error
8787
const popupInstance = new Popup($element, extend({
8888
title: options.title ?? '',
8989
showTitle: ensureDefined(options.showTitle, true),

packages/devextreme/js/__internal/ui/m_load_indicator.ts

Lines changed: 68 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import messageLocalization from '@js/common/core/localization/message';
22
import registerComponent from '@js/core/component_registrator';
33
import devices from '@js/core/devices';
4+
import type { DefaultOptionsRule } from '@js/core/options/utils';
5+
import type { dxElementWrapper } from '@js/core/renderer';
46
import $ from '@js/core/renderer';
5-
import { extend } from '@js/core/utils/extend';
67
import { getHeight, getWidth } from '@js/core/utils/size';
78
import { getNavigator } from '@js/core/utils/window';
9+
import type { Properties } from '@js/ui/load_indicator';
810
import { 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

1114
import supportUtils from '../core/utils/m_support';
1215

@@ -20,23 +23,36 @@ const LOADINDICATOR_SEGMENT_CLASS = 'dx-loadindicator-segment';
2023
const LOADINDICATOR_SEGMENT_INNER_CLASS = 'dx-loadindicator-segment-inner';
2124
const 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

205225
registerComponent('dxLoadIndicator', LoadIndicator);
206226

0 commit comments

Comments
 (0)