Skip to content

Commit

Permalink
Collection.Base: convert to ES6 Class
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeniyKiyashko committed Jan 20, 2025
1 parent c3ae57e commit 7f560f0
Show file tree
Hide file tree
Showing 27 changed files with 809 additions and 561 deletions.
14 changes: 8 additions & 6 deletions packages/devextreme/js/__internal/core/widget/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { extend } from '@js/core/utils/extend';
import { each } from '@js/core/utils/iterator';
import { isDefined, isPlainObject } from '@js/core/utils/type';
import { compare as compareVersions } from '@js/core/utils/version';
import type { DxEvent } from '@js/events';
import { focusable as focusableSelector } from '@js/ui/widget/selectors';
import type { WidgetOptions } from '@js/ui/widget/ui.widget';

Expand Down Expand Up @@ -47,14 +48,14 @@ export interface Properties<TComponent = any> extends WidgetOptions<TComponent>
class Widget<
TProperties extends Properties = Properties,
> extends DOMComponent<Widget<TProperties>, TProperties> {
private readonly _feedbackHideTimeout = 400;
public _activeStateUnit!: string;

public _feedbackHideTimeout = 400;

private readonly _feedbackShowTimeout = 30;

private _contentReadyAction?: ((event?: Record<string, unknown>) => void) | null;

private readonly _activeStateUnit!: string;

private _keyboardListenerId?: string | null;

private _isReady?: boolean;
Expand Down Expand Up @@ -265,8 +266,9 @@ class Widget<
return this._getActiveElement();
}

_isFocusTarget(element: Element): boolean {
_isFocusTarget(element: Element | undefined): boolean {
const focusTargets = $(this._focusTarget()).toArray();
// @ts-expect-error ts-error
return focusTargets.includes(element);
}

Expand Down Expand Up @@ -306,7 +308,7 @@ class Widget<
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
_focusInHandler(event): void {
_focusInHandler(event: DxEvent): void {
if (!event.isDefaultPrevented()) {
this._createActionByOption('onFocusIn', {
beforeExecute: () => this._updateFocusState(event, true),
Expand All @@ -316,7 +318,7 @@ class Widget<
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
_focusOutHandler(event): void {
_focusOutHandler(event: DxEvent): void {
if (!event.isDefaultPrevented()) {
this._createActionByOption('onFocusOut', {
beforeExecute: () => this._updateFocusState(event, false),
Expand Down
4 changes: 2 additions & 2 deletions packages/devextreme/js/__internal/ui/calendar/m_calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ const SELECTION_STRATEGIES = {

// @ts-expect-error
const Calendar = Editor.inherit({
_activeStateUnit: `.${CALENDAR_CELL_CLASS}`,

_getDefaultOptions() {
return extend(this.callBase(), {

Expand Down Expand Up @@ -442,6 +440,8 @@ const Calendar = Editor.inherit({

_init() {
this.callBase();

this._activeStateUnit = `.${CALENDAR_CELL_CLASS}`;
this._initSelectionStrategy();
this._correctZoomLevel();
this._initCurrentDate();
Expand Down
5 changes: 3 additions & 2 deletions packages/devextreme/js/__internal/ui/collection/async.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import CollectionWidgetAsync from '@js/ui/collection/ui.collection_widget.async';
import type { CollectionWidgetOptions, ItemLike } from '@js/ui/collection/ui.collection_widget.base';
import type { ItemLike } from '@js/ui/collection/ui.collection_widget.base';
import type { CollectionWidgetBaseProperties } from '@ts/ui/collection/m_collection_widget.base';

import CollectionWidgetEdit from './edit';

declare class Async<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
TProperties extends CollectionWidgetOptions<any, TItem, TKey>,
TProperties extends CollectionWidgetBaseProperties<any, TItem, TKey>,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
TItem extends ItemLike = any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
97 changes: 0 additions & 97 deletions packages/devextreme/js/__internal/ui/collection/base.ts

This file was deleted.

8 changes: 4 additions & 4 deletions packages/devextreme/js/__internal/ui/collection/edit.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { dxElementWrapper } from '@js/core/renderer';
import type { CollectionWidgetOptions, ItemLike } from '@js/ui/collection/ui.collection_widget.base';
import type { ItemLike } from '@js/ui/collection/ui.collection_widget.base';
import CollectionWidgetEdit from '@js/ui/collection/ui.collection_widget.edit';

import CollectionWidgetBase from './base';
import type { CollectionWidgetBaseProperties } from '@ts/ui/collection/m_collection_widget.base';
import CollectionWidgetBase from '@ts/ui/collection/m_collection_widget.base';

declare class Edit<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
TProperties extends CollectionWidgetOptions<any, TItem, TKey>,
TProperties extends CollectionWidgetBaseProperties<any, TItem, TKey>,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
TItem extends ItemLike = any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { CollectionWidgetOptions, ItemLike } from '@js/ui/collection/ui.collection_widget.base';
import type { ItemLike } from '@js/ui/collection/ui.collection_widget.base';
import CollectionWidgetLiveUpdate from '@js/ui/collection/ui.collection_widget.live_update';
import type { CollectionWidgetBaseProperties } from '@ts/ui/collection/m_collection_widget.base';

import CollectionWidgetAsync from './async';

declare class LiveUpdate<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
TProperties extends CollectionWidgetOptions<any, TItem, TKey>,
TProperties extends CollectionWidgetBaseProperties<any, TItem, TKey>,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
TItem extends ItemLike = any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
Loading

0 comments on commit 7f560f0

Please sign in to comment.