Skip to content

Commit

Permalink
R1: move utils (#28275)
Browse files Browse the repository at this point in the history
  • Loading branch information
pomahtri authored Nov 1, 2024
1 parent bf29be2 commit d3a195a
Show file tree
Hide file tree
Showing 196 changed files with 112 additions and 21,950 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Selector } from 'testcafe';
import ScrollView from 'devextreme-testcafe-models/scrollView/scrollView';
import { ScrollableDirection } from 'devextreme/renovation/ui/scroll_view/common/types';
import url from '../../../helpers/getPageUrl';
import { createWidget } from '../../../helpers/createWidget';
import { appendElementTo } from '../../../helpers/domUtils';

fixture.disablePageReloads`ScrollView`
.page(url(__dirname, '../../container.html'));

type ScrollableDirection = 'both' | 'horizontal' | 'vertical';

[150, 300].forEach((scrollableContentSize) => {
(['vertical', 'horizontal'] as ScrollableDirection[]).forEach((direction) => {
['onHover', 'always', 'onScroll', 'never'].forEach((showScrollbar) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable no-restricted-syntax, no-unsafe-optional-chaining */
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
import Scrollable from 'devextreme-testcafe-models/scrollView/internal/scrollable';
import { ScrollableDirection } from 'devextreme/renovation/ui/scroll_view/common/types';
import Guid from 'devextreme/core/guid';
import { testScreenshot } from '../../../helpers/themeUtils';
import url from '../../../helpers/getPageUrl';
Expand All @@ -11,6 +10,8 @@ import { appendElementTo } from '../../../helpers/domUtils';
fixture.disablePageReloads`Scrollable_ScrollToElement`
.page(url(__dirname, '../../container.html'));

type ScrollableDirection = 'both' | 'horizontal' | 'vertical';

(['both'] as ScrollableDirection[]).forEach((direction) => {
test(`ScrollToElement, element less container,direction=${direction}`, async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
import { Selector } from 'testcafe';
import Scrollable from 'devextreme-testcafe-models/scrollView/internal/scrollable';
import { ScrollableDirection } from 'devextreme/renovation/ui/scroll_view/common/types';
import { isMaterialBased } from '../../../helpers/themeUtils';
import url from '../../../helpers/getPageUrl';
import { createWidget } from '../../../helpers/createWidget';
Expand All @@ -16,6 +15,7 @@ const testFixture = () => {

testFixture()`Scrollable_visibility_integration`
.page(url(__dirname, '../../container.html'));
type ScrollableDirection = 'both' | 'horizontal' | 'vertical';

(['both'] as ScrollableDirection[]).forEach((direction) => {
[false, true].forEach((useNative) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
hasTemplate, InfernoComponent, InfernoEffect, renderTemplate,
} from '@devextreme/runtime/inferno';
import type { ComponentClass } from '@js/core/dom_component';
import { getUpdatedOptions } from '@js/renovation/ui/common/utils/get_updated_options';
import type { DisposeEffectReturn } from '@js/renovation/utils/effect_return';
import type { DisposeEffectReturn } from '@ts/core/r1/utils/effect_return';
import { getUpdatedOptions } from '@ts/core/r1/utils/get_updated_options';
import type { RefObject } from 'inferno';
import { createRef } from 'inferno';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getUpdatedOptions } from '../get_updated_options';
import { getUpdatedOptions } from './get_updated_options';

describe('get_updated_options', () => {
class DummyDataSource { dummy = true; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ function getDiffItem(key, value, previousValue): ResultItem {
return { path: key, value, previousValue };
}

function compare(resultPaths: ResultItem[],
function compare(
resultPaths: ResultItem[],
item1,
item2,
key: string,
fullPropName: string,
notDeepCopyArrays: string[]): void {
notDeepCopyArrays: string[],
): void {
if (propsToIgnore[key]) {
return;
}
Expand All @@ -51,8 +53,10 @@ function compare(resultPaths: ResultItem[],
} else {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
const diffPaths = objectDiffs(item1, item2, fullPropName, notDeepCopyArrays);
([] as ResultItem[]).push.apply(resultPaths,
diffPaths.map((item) => ({ ...item, path: `${key}${item.path}` })));
([] as ResultItem[]).push.apply(
resultPaths,
diffPaths.map((item) => ({ ...item, path: `${key}${item.path}` })),
);
}
} else {
resultPaths.push(getDiffItem(key, item2, item1));
Expand Down
3 changes: 1 addition & 2 deletions packages/devextreme/js/__internal/core/utils/m_date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { adjust } from '@js/core/utils/math';
import {
isDate, isDefined, isNumeric, isObject, isString,
} from '@js/core/utils/type';

import { toMilliseconds } from '../../../renovation/ui/common/utils/date/index';
import { toMilliseconds } from '@ts/utils/toMilliseconds';

const DAYS_IN_WEEK = 7;
const THURSDAY_WEEK_NUMBER = 4;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { BaseInfernoComponent } from '@devextreme/runtime/inferno';
import type { EventCallback } from '@js/renovation/ui/common/event_callback';
import type { EventCallback } from '@ts/core/r1/event_callback';

import LegacyNumberBox from '../../../ui/number_box';
import { DomComponentWrapper } from '../../core/r1/dom_component_wrapper';
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme/js/__internal/ui/chat/messagelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import { isDate, isDefined } from '@js/core/utils/type';
import type { Format } from '@js/localization';
import dateLocalization from '@js/localization/date';
import messageLocalization from '@js/localization/message';
import { getScrollTopMax } from '@js/renovation/ui/scroll_view/utils/get_scroll_top_max';
import type { Message, User } from '@js/ui/chat';
import ScrollView from '@js/ui/scroll_view';
import type { WidgetOptions } from '@js/ui/widget/ui.widget';
import type { OptionChanged } from '@ts/core/widget/types';
import Widget from '@ts/core/widget/widget';
import { getScrollTopMax } from '@ts/ui/scroll_view/utils/get_scroll_top_max';

import { isElementVisible } from '../splitter/utils/layout';
import type Chat from './chat';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getHeight } from '@js/core/utils/size';
import { name as clickEventName } from '@js/events/click';
import eventsEngine from '@js/events/core/events_engine';
import { addNamespace } from '@js/events/utils/index';
import { convertToLocation } from '@js/renovation/ui/scroll_view/utils/convert_location';
import { convertToLocation } from '@ts/ui/scroll_view/utils/convert_location';

import Scrollable from '../scroll_view/m_scrollable';

Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme/js/__internal/ui/list/m_list.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import eventsEngine from '@js/events/core/events_engine';
import { end as swipeEventEnd } from '@js/events/swipe';
import { addNamespace } from '@js/events/utils/index';
import messageLocalization from '@js/localization/message';
import { getElementMargin } from '@js/renovation/ui/scroll_view/utils/get_element_style';
import Button from '@js/ui/button';
import CollectionWidget from '@js/ui/collection/ui.collection_widget.live_update';
import ScrollView from '@js/ui/scroll_view';
import { current, isMaterial, isMaterialBased } from '@js/ui/themes';
import { render } from '@js/ui/widget/utils.ink_ripple';
import supportUtils from '@ts/core/utils/m_support';
import { deviceDependentOptions } from '@ts/ui/scroll_view/m_scrollable.device';
import { getElementMargin } from '@ts/ui/scroll_view/utils/get_element_style';
import DataConverterMixin from '@ts/ui/shared/m_grouped_data_converter_mixin';

import ListItem from './m_item';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { pairToObject } from '@js/core/utils/common';
import { extend } from '@js/core/utils/extend';
import { getHeight, getWidth } from '@js/core/utils/size';
import { isDefined, isString } from '@js/core/utils/type';
import { borderWidthStyles } from '@js/renovation/ui/resizable/utils';
import { OverlayPositionController } from '@ts/ui/overlay/m_overlay_position_controller';
import { borderWidthStyles } from '@ts/ui/resizable/utils';

const WEIGHT_OF_SIDES = {
left: -1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {
getMovingSides, getAreaFromElement, getAreaFromObject, getDragOffsets, filterOffsets,
} from '../utils';
filterOffsets,
getAreaFromElement, getAreaFromObject, getDragOffsets, getMovingSides,
} from './utils';

jest.mock('../../../../core/utils/size', () => ({
jest.mock('@js/core/utils/size', () => ({
getOuterWidth: ({ outerWidth }) => outerWidth,
getInnerWidth: ({ innerWidth }) => innerWidth,
getOuterHeight: ({ outerHeight }) => outerHeight,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import type {
Area, Handle, AreaObject, AreaProp, MovingSides,
} from './common/types';
import { isWindow } from '../../../core/utils/type';
import { extend } from '../../../core/utils/extend';
import { extend } from '@js/core/utils/extend';
import {
getOuterWidth,
getInnerWidth,
getOuterHeight,
getInnerHeight,
getInnerWidth,
getOffset,
} from '../../../core/utils/size';
getOuterHeight,
getOuterWidth,
} from '@js/core/utils/size';
import { isWindow } from '@js/core/utils/type';

import type {
Area, AreaObject, AreaProp, Handle, MovingSides,
} from './types';

export const borderWidthStyles = {
left: 'borderLeftWidth',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { hasWindow } from '@js/core/utils/window';
import eventsEngine from '@js/events/core/events_engine';
import scrollEvents from '@js/events/gesture/emitter.gesture.scroll';
import { addNamespace } from '@js/events/utils/index';
import { getElementLocationInternal } from '@js/renovation/ui/scroll_view/utils/get_element_location_internal';
import { getElementLocationInternal } from '@ts/ui/scroll_view/utils/get_element_location_internal';

import supportUtils from '../../core/utils/m_support';
import { deviceDependentOptions } from './m_scrollable.device';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { ensureDefined } from '@js/core/utils/common';
import {
isDefined,
isPlainObject,
} from '../../../../core/utils/type';
import {
} from '@js/core/utils/type';

import type {
ScrollableDirection,
ScrollOffset,
} from '../common/types';
import { ensureDefined } from '../../../../core/utils/common';
} from '../types';
import {
ScrollDirection,
} from './scroll_direction';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { getScrollLeftMax } from './get_scroll_left_max';
import { getScrollTopMax } from './get_scroll_top_max';
import {
ScrollOffset,
import type {
ScrollableBoundary,
ScrollableDirection,
} from '../common/types';

ScrollOffset,
} from '../types';
import { getScrollLeftMax } from './get_scroll_left_max';
import { getScrollTopMax } from './get_scroll_top_max';
import {
ScrollDirection,
} from './scroll_direction';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { titleize } from '../../../../core/utils/inflector';
import {
ElementOffset,
ScrollableDirection, ScrollOffset,
} from '../common/types';

import { getRelativeOffset } from './get_relative_offset';
import { titleize } from '@js/core/utils/inflector';

import {
DIRECTION_VERTICAL,
SCROLLABLE_CONTENT_CLASS,
} from '../common/consts';
} from '../consts';
import type {
ElementOffset,
ScrollableDirection, ScrollOffset,
} from '../types';
import { getRelativeOffset } from './get_relative_offset';

// this function tested by testcafe
/* istanbul ignore next */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { titleize } from '@js/core/utils/inflector';
import { setWindow } from '@js/core/utils/window';
import each from 'jest-each';

import {
getElementStyle,
getElementMargin,
getElementOverflowX,
getElementOverflowY,
getElementPadding,
getElementStyle,
getElementTransform,
getElementOverflowY,
getElementMargin,
} from '../get_element_style';
import { setWindow } from '../../../../../core/utils/window';
import { titleize } from '../../../../../core/utils/inflector';
} from './get_element_style';

describe('getElementStyle', () => {
it('element is not defined', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { titleize } from '../../../../core/utils/inflector';
import { getWindow, hasWindow } from '../../../../core/utils/window';
import { titleize } from '@js/core/utils/inflector';
import { getWindow, hasWindow } from '@js/core/utils/window';

import { toNumber } from '../../../utils/type_conversion';

export function getElementStyle(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getRelativeOffset } from '../get_relative_offset';
/* eslint-disable @typescript-eslint/no-explicit-any */
import { getRelativeOffset } from './get_relative_offset';

describe('getRelativeOffset(targetElementClass, sourceElement)', () => {
it('should return correct relative offset', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export function getRelativeOffset(
targetElementClass: string, sourceElement: HTMLDivElement | HTMLElement,
targetElementClass: string,
sourceElement: HTMLDivElement | HTMLElement,
): { top: number; left: number } {
const offset = { left: 0, top: 0 };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DIRECTION_HORIZONTAL, DIRECTION_VERTICAL } from '../../common/consts';
import { getScrollbarSize } from '../get_scrollbar_size';
import { DIRECTION_HORIZONTAL, DIRECTION_VERTICAL } from '../consts';
import { getScrollbarSize } from './get_scrollbar_size';

describe('getScrollbarSize(element, direction)', () => {
it('get vertical scrollbar width', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ScrollableDirection } from '../common/types';
import type { ScrollableDirection } from '../types';

export function getScrollbarSize(element: HTMLElement, direction: Omit<ScrollableDirection, 'horizontal' | 'vertical'>): number {
if (direction === 'vertical') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { getTranslateValues } from '../get_translate_values';
import { getElementTransform } from '../get_element_style';
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { getElementTransform } from './get_element_style';
import { getTranslateValues } from './get_translate_values';

jest.mock('../get_element_style', () => ({
...jest.requireActual('../get_element_style'),
jest.mock('./get_element_style', () => ({
...jest.requireActual('./get_element_style'),
getElementTransform: jest.fn(() => ''),
}));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {
DIRECTION_VERTICAL,
DIRECTION_HORIZONTAL,
DIRECTION_BOTH,
} from '../common/consts';

import {
DIRECTION_HORIZONTAL,
DIRECTION_VERTICAL,
} from '../consts';
import type {
ScrollableDirection,
} from '../common/types';
} from '../types';

export class ScrollDirection {
direction: ScrollableDirection;
Expand Down
8 changes: 4 additions & 4 deletions packages/devextreme/js/__internal/ui/tabs/m_tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import eventsEngine from '@js/events/core/events_engine';
import holdEvent from '@js/events/hold';
import pointerEvents from '@js/events/pointer';
import { addNamespace } from '@js/events/utils/index';
import {
isReachedBottom, isReachedLeft, isReachedRight, isReachedTop,
} from '@js/renovation/ui/scroll_view/utils/get_boundary_props';
import { getScrollLeftMax } from '@js/renovation/ui/scroll_view/utils/get_scroll_left_max';
import Button from '@js/ui/button';
// eslint-disable-next-line import/no-named-default
import { default as CollectionWidget } from '@js/ui/collection/ui.collection_widget.live_update';
import Scrollable from '@js/ui/scroll_view/ui.scrollable';
import { current as currentTheme, isFluent, isMaterial } from '@js/ui/themes';
import { render } from '@js/ui/widget/utils.ink_ripple';
import {
isReachedBottom, isReachedLeft, isReachedRight, isReachedTop,
} from '@ts/ui/scroll_view/utils/get_boundary_props';
import { getScrollLeftMax } from '@ts/ui/scroll_view/utils/get_scroll_left_max';

import { TABS_EXPANDED_CLASS } from './constants';
import TabsItem from './m_item';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import { name as dblclickEvent } from '@js/events/double_click';
import pointerEvents from '@js/events/pointer';
import { addNamespace } from '@js/events/utils/index';
import messageLocalization from '@js/localization/message';
import { DIRECTION_HORIZONTAL, DIRECTION_VERTICAL, SCROLLABLE_CONTENT_CLASS } from '@js/renovation/ui/scroll_view/common/consts';
import { getRelativeOffset } from '@js/renovation/ui/scroll_view/utils/get_relative_offset';
import CheckBox from '@js/ui/check_box';
import HierarchicalCollectionWidget from '@js/ui/hierarchical_collection/ui.hierarchical_collection_widget';
import LoadIndicator from '@js/ui/load_indicator';
import Scrollable from '@js/ui/scroll_view/ui.scrollable';
import supportUtils from '@ts/core/utils/m_support';
import { DIRECTION_HORIZONTAL, DIRECTION_VERTICAL, SCROLLABLE_CONTENT_CLASS } from '@ts/ui/scroll_view/consts';
import { getRelativeOffset } from '@ts/ui/scroll_view/utils/get_relative_offset';

const WIDGET_CLASS = 'dx-treeview';

Expand Down
Loading

0 comments on commit d3a195a

Please sign in to comment.