Skip to content

Commit

Permalink
chore: revert unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zhzz committed Sep 20, 2023
1 parent 9f77aba commit f6524dd
Show file tree
Hide file tree
Showing 57 changed files with 150 additions and 171 deletions.
2 changes: 1 addition & 1 deletion packages/react-ui/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class Button extends React.Component<ButtonProps, ButtonState> {
this.node?.blur();
}

public render() {
public render(): JSX.Element {
return (
<ThemeContext.Consumer>
{(theme) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-ui/components/CurrencyLabel/CurrencyLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactElement } from 'react';
import React from 'react';

import { MAX_SAFE_DIGITS } from '../CurrencyInput/constants';
import { CurrencyHelper } from '../CurrencyInput/CurrencyHelper';
Expand Down Expand Up @@ -28,7 +28,7 @@ export const CurrencyLabel = ({
currencySymbol,
hideTrailingZeros = false,
...rest
}: CurrencyLabelProps): ReactElement => {
}: CurrencyLabelProps): JSX.Element => {
return (
<CommonWrapper {...rest}>
<span data-tid={CurrencyLabelDataTids.root}>
Expand Down
6 changes: 3 additions & 3 deletions packages/react-ui/components/DateInput/DateFragmentsView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactElement } from 'react';
import React from 'react';
import { globalObject } from '@skbkontur/global-object';

import { MaskCharLowLine } from '../../internal/MaskCharLowLine';
Expand Down Expand Up @@ -55,7 +55,7 @@ export class DateFragmentsView extends React.Component<DateFragmentViewProps> {
);
}

private renderSeparator(fragment: InternalDateFragment, index: number): ReactElement {
private renderSeparator(fragment: InternalDateFragment, index: number): JSX.Element {
const separatorClassName = cx({
[styles.mask(this.theme)]: true,
[styles.delimiterFilled()]: this.props.fragments[index + 1].value !== null,
Expand All @@ -68,7 +68,7 @@ export class DateFragmentsView extends React.Component<DateFragmentViewProps> {
);
}

private renderDateComponent(fragment: InternalDateFragment, index: number): ReactElement {
private renderDateComponent(fragment: InternalDateFragment, index: number): JSX.Element {
const { inputMode, onSelectDateComponent, selected } = this.props;
const { type, value, length, valueWithPad } = fragment;

Expand Down
4 changes: 2 additions & 2 deletions packages/react-ui/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { AriaAttributes, ReactElement } from 'react';
import React, { AriaAttributes } from 'react';
import PropTypes from 'prop-types';

import { filterProps } from '../../lib/filterProps';
Expand Down Expand Up @@ -52,7 +52,7 @@ export interface DropdownProps
width?: React.CSSProperties['width'];

/** @ignore */
_renderButton?: (params: any) => ReactElement;
_renderButton?: (params: any) => JSX.Element;

/**
* Отключает использование портала
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export class Input extends React.Component<InputProps, InputState> {
return Boolean(mask && (focused || alwaysShowMask));
}

public render() {
public render(): JSX.Element {
return (
<ThemeContext.Consumer>
{(theme) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/Kebab/Kebab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class Kebab extends React.Component<KebabProps, KebabState> {
this.listener.remove();
}

public render() {
public render(): JSX.Element {
return (
<ThemeContext.Consumer>
{(theme) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class Link extends React.Component<LinkProps, LinkState> {
private theme!: Theme;
private setRootNode!: TSetRootNode;

public render() {
public render(): JSX.Element {
return (
<ThemeContext.Consumer>
{(theme) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class Modal extends React.Component<ModalProps, ModalState> {
}
}

public render() {
public render(): JSX.Element {
return (
<ThemeContext.Consumer>
{(theme) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-ui/components/Modal/ModalBody.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactElement } from 'react';
import React from 'react';

import { ThemeContext } from '../../lib/theming/ThemeContext';
import { Theme } from '../../lib/theming/Theme';
Expand Down Expand Up @@ -51,7 +51,7 @@ export class ModalBody extends React.Component<ModalBodyProps> {
LayoutEvents.emit();
};

public renderMain(): ReactElement {
public renderMain(): JSX.Element {
const { noPadding } = this.props;
return (
<ModalContext.Consumer>
Expand Down
6 changes: 3 additions & 3 deletions packages/react-ui/components/Paging/Paging.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactElement } from 'react';
import React from 'react';
import { func, number } from 'prop-types';
import { globalObject, isElement } from '@skbkontur/global-object';

Expand Down Expand Up @@ -215,7 +215,7 @@ export class Paging extends React.PureComponent<PagingProps, PagingState> {
);
};

private renderForwardLink = (disabled: boolean, focused: boolean): ReactElement => {
private renderForwardLink = (disabled: boolean, focused: boolean): JSX.Element => {
const classes = isTheme2022(this.theme)
? cx(
styles.pageLink(this.theme),
Expand Down Expand Up @@ -255,7 +255,7 @@ export class Paging extends React.PureComponent<PagingProps, PagingState> {
);
};

private renderPageLink = (pageNumber: number, active: boolean, focused: boolean): ReactElement => {
private renderPageLink = (pageNumber: number, active: boolean, focused: boolean): JSX.Element => {
const classes = cx({
[styles.pageLink(this.theme)]: true,
[styles.pageLinkFocused(this.theme)]: focused,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-ui/components/PasswordInput/PasswordInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import React, { AriaAttributes } from 'react';
import PropTypes from 'prop-types';
import { globalObject } from '@skbkontur/global-object';
import { globalObject, isBrowser } from '@skbkontur/global-object';

import { locale } from '../../lib/locale/decorators';
import { RenderLayer } from '../../internal/RenderLayer';
Expand Down Expand Up @@ -79,7 +79,7 @@ export class PasswordInput extends React.PureComponent<PasswordInputProps, Passw
}

// @ts-expect-error: IE-specific API.
if (isIE11 && !globalObject.document && !globalObject.document.msCapsLockWarningOff) {
if (isIE11 && isBrowser(globalObject) && !globalObject.document.msCapsLockWarningOff) {
// @ts-expect-error: Read the comment above.
// turns off default ie capslock warning
globalObject.document.msCapsLockWarningOff = true;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-ui/components/RadioGroup/RadioGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { AriaAttributes, ReactElement } from 'react';
import React, { AriaAttributes } from 'react';
import invariant from 'invariant';

import { getRandomID, isNonNullable } from '../../lib/utils';
Expand Down Expand Up @@ -226,7 +226,7 @@ export class RadioGroup<T> extends React.Component<RadioGroupProps<T>, RadioGrou
return items ? mapItems<T>(this.renderRadio, items) : children;
}

private renderRadio = (itemValue: T, data: React.ReactNode, index: number): ReactElement => {
private renderRadio = (itemValue: T, data: React.ReactNode, index: number): JSX.Element => {
const itemProps = {
key: this.getKeyByItem(itemValue),
className: cx({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ function removeCallbackFromMQListener(mediaQuery: string, callback: (e: MediaQue
}

export function checkMatches(mediaQuery: string) {
if (!globalObject.matchMedia) {
return false;
}

if (!eventListenersMap.has(mediaQuery)) {
return !!globalObject.matchMedia?.(mediaQuery)?.matches;
return !!globalObject.matchMedia(mediaQuery)?.matches;
}

const eventListener = eventListenersMap.get(mediaQuery);
Expand Down
8 changes: 4 additions & 4 deletions packages/react-ui/components/SidePage/SidePage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { AriaAttributes, HTMLAttributes, ReactElement } from 'react';
import React, { AriaAttributes, HTMLAttributes } from 'react';
import { CSSTransition } from 'react-transition-group';
import FocusLock from 'react-focus-lock';
import { globalObject, isMouseEvent } from '@skbkontur/global-object';
Expand Down Expand Up @@ -163,7 +163,7 @@ export class SidePage extends React.Component<SidePageProps, SidePageState> {

private getProps = createPropsGetter(SidePage.defaultProps);

public render() {
public render(): JSX.Element {
return (
<ThemeContext.Consumer>
{(theme) => {
Expand Down Expand Up @@ -211,7 +211,7 @@ export class SidePage extends React.Component<SidePageProps, SidePageState> {
);
}

private renderContainer(isMobile: boolean): ReactElement {
private renderContainer(isMobile: boolean): JSX.Element {
const { width, blockBackground, fromLeft, 'aria-label': ariaLabel } = this.props;
const { disableFocusLock, offset, role } = this.getProps();

Expand Down Expand Up @@ -284,7 +284,7 @@ export class SidePage extends React.Component<SidePageProps, SidePageState> {
return this.layout.clientWidth;
};

private renderShadow(): ReactElement {
private renderShadow(): JSX.Element {
return (
<ZIndex priority={'Sidepage'} className={styles.overlay()} onScroll={LayoutEvents.emit}>
<HideBodyVerticalScroll key="hbvs" />
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/SidePage/SidePageFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class SidePageFooter extends React.Component<SidePageFooterProps, SidePag
return true;
}

public render() {
public render(): JSX.Element {
return (
<ThemeContext.Consumer>
{(theme) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/SidePage/SidePageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class SidePageHeader extends React.Component<SidePageHeaderProps, SidePag
this.updateReadyToFix();
};

public render() {
public render(): JSX.Element {
return (
<ThemeContext.Consumer>
{(theme) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class Tabs<T extends string = string> extends React.Component<TabsProps<T
private listeners: Array<typeof emptyHandler> = [];
private setRootNode!: TSetRootNode;

public render() {
public render(): JSX.Element {
const { value, width, children, indicatorClassName, 'aria-describedby': ariaDescribedby } = this.props;
const { vertical, size } = this.getProps();
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/Textarea/TextareaHelpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function getTextAreaHeight(params: GetTextAreaHeightParams) {
return null;
}
const { node, minRows, maxRows, extraRow } = params;
const style = globalObject.getComputedStyle?.(node);
const style = globalObject.getComputedStyle(node);
const borderTop = style.borderTopWidth ? parseInt(style.borderTopWidth, 10) : 0;
const borderBottom = style.borderBottomWidth ? parseInt(style.borderBottomWidth, 10) : 0;
const lineHeight = style.lineHeight ? parseInt(style.lineHeight, 10) : 0;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-ui/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactElement } from 'react';
import React from 'react';
import warning from 'warning';
import isEqual from 'lodash.isequal';
import { isElement, globalObject } from '@skbkontur/global-object';
Expand Down Expand Up @@ -347,7 +347,7 @@ export class Tooltip extends React.PureComponent<TooltipProps, TooltipState> imp
private renderPopup(
anchorElement: React.ReactNode | HTMLElement,
popupProps: Partial<PopupProps>,
content: ReactElement | null,
content: JSX.Element | null,
) {
const { disableAnimations, trigger } = this.getProps();
return (
Expand Down
12 changes: 4 additions & 8 deletions packages/react-ui/internal/DateSelect/DateSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ export class DateSelect extends React.PureComponent<DateSelectProps, DateSelectS
private itemsContainer: HTMLElement | null = null;
private listener: Nullable<ReturnType<typeof LayoutEvents.addListener>>;
private timeout: number | undefined;
private longClickTimer: number | undefined;
private setPositionRepeatTimer: number | undefined;
private longClickTimer = 0;
private setPositionRepeatTimer = 0;
private yearStep = 3;
private touchStartY: Nullable<number> = null;

Expand Down Expand Up @@ -453,12 +453,8 @@ export class DateSelect extends React.PureComponent<DateSelectProps, DateSelectS
};

private handleLongClickStop = () => {
if (this.longClickTimer) {
globalObject.clearTimeout(this.longClickTimer);
}
if (this.setPositionRepeatTimer) {
globalObject.clearTimeout(this.setPositionRepeatTimer);
}
globalObject.clearTimeout(this.longClickTimer);
globalObject.clearTimeout(this.setPositionRepeatTimer);
};

private getAnchor = () => this.root;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class DropdownContainer extends React.PureComponent<DropdownContainerProp

const getIsDocumentElementRoot = () => {
if (!isBrowser(globalObject)) {
return;
return false;
}
const { body, documentElement } = globalObject.document;
const htmlPosition = globalObject.getComputedStyle(documentElement).position;
Expand Down
14 changes: 7 additions & 7 deletions packages/react-ui/internal/InputLikeText/InputLikeText.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// TODO: Enable this rule in functional components.
/* eslint-disable @typescript-eslint/no-unused-vars */
import React, { ReactElement } from 'react';
import React from 'react';
import ReactDOM from 'react-dom';
import debounce from 'lodash.debounce';
import { isNode, globalObject } from '@skbkontur/global-object';
Expand Down Expand Up @@ -278,7 +278,7 @@ export class InputLikeText extends React.Component<InputLikeTextProps, InputLike
return this.renderIcon(this.props.rightIcon, this.getIconClassname(true));
};

private renderIcon = (icon: InputIconType, className: string): ReactElement | null => {
private renderIcon = (icon: InputIconType, className: string): JSX.Element | null => {
if (!icon) {
return null;
}
Expand All @@ -297,7 +297,7 @@ export class InputLikeText extends React.Component<InputLikeTextProps, InputLike
);
};

private renderPrefix = (): ReactElement | null => {
private renderPrefix = (): JSX.Element | null => {
const { prefix, disabled } = this.props;

if (!prefix) {
Expand All @@ -311,7 +311,7 @@ export class InputLikeText extends React.Component<InputLikeTextProps, InputLike
);
};

private renderSuffix = (): ReactElement | null => {
private renderSuffix = (): JSX.Element | null => {
const { suffix, disabled } = this.props;

if (!suffix) {
Expand All @@ -325,7 +325,7 @@ export class InputLikeText extends React.Component<InputLikeTextProps, InputLike
);
};

private renderLeftSide = (): ReactElement | null => {
private renderLeftSide = (): JSX.Element | null => {
const leftIcon = this.renderLeftIcon();
const prefix = this.renderPrefix();

Expand All @@ -341,7 +341,7 @@ export class InputLikeText extends React.Component<InputLikeTextProps, InputLike
);
};

private renderRightSide = (): ReactElement | null => {
private renderRightSide = (): JSX.Element | null => {
const rightIcon = this.renderRightIcon();
const suffix = this.renderSuffix();

Expand All @@ -357,7 +357,7 @@ export class InputLikeText extends React.Component<InputLikeTextProps, InputLike
);
};

private renderPlaceholder = (): ReactElement | null => {
private renderPlaceholder = (): JSX.Element | null => {
const { children, placeholder, disabled } = this.props;
const { focused } = this.state;
const hasValue = isNonNullable(children) && children !== '';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/internal/PopupMenu/PopupMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class PopupMenu extends React.Component<PopupMenuProps, PopupMenuState> {
private menu: Nullable<Menu> = null;
private setRootNode!: TSetRootNode;

public render() {
public render(): JSX.Element {
return (
<ThemeContext.Consumer>
{(theme) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-ui/internal/RenderLayer/RenderLayer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactElement } from 'react';
import React from 'react';
import { globalObject, isElement } from '@skbkontur/global-object';

import { listen as listenFocusOutside, containsTargetOrRenderContainer } from '../../lib/listenFocusOutside';
Expand All @@ -8,7 +8,7 @@ import { Nullable } from '../../typings/utility-types';
import { createPropsGetter } from '../../lib/createPropsGetter';

export interface RenderLayerProps extends CommonProps {
children: ReactElement;
children: JSX.Element;
onClickOutside?: (e: Event) => void;
onFocusOutside?: (e: Event) => void;
active?: boolean;
Expand Down
Loading

0 comments on commit f6524dd

Please sign in to comment.