Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(react-ui): remove deprecated entities #3523

Merged
merged 9 commits into from
Sep 27, 2024
9 changes: 9 additions & 0 deletions packages/react-ui-codemod/react-ui-5.0/renameThemeVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ const RENAMED_VARS: Record<string, string> = {
fileUploaderPaddingY:'fileUploaderPaddingYSmall',
pickerBg: 'calendarBg',
pickerBorderRadius: 'calendarBorderRadius',
tokenDefaultIdleBg: 'tokenBg',
tokenDefaultIdleColor: 'tokenColor',
tokenDefaultIdleBorderColor: 'tokenBorderColor',
tokenDefaultIdleBgHover: 'tokenBgHover',
tokenDefaultIdleColorHover: 'tokenColorHover',
tokenDefaultIdleBorderColorHover: 'tokenBorderColorHover',
tokenDefaultActiveBg: 'tokenBgActive',
tokenDefaultActiveColor: 'tokenColorActive',
tokenDefaultActiveBorderColor: 'tokenBorderColorActive'
};

export default function transform(file: FileInfo, api: API) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui-testing/Tests/PagingTests/PagingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void SetUp()
[Test]
public void TestPresence()
{
page.Paging1.IsPresent.Wait().That(Is.True);
page.Paging1.IsPresent.Wait().That(Is.False);
}

[Test]
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions packages/react-ui/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ import { useButtonArrow } from './ButtonArrow';
import { getInnerLinkTheme } from './getInnerLinkTheme';
import { LoadingButtonIcon } from './LoadingButtonIcon';

/**
* @deprecated use SizeProp
*/
export type ButtonSize = SizeProp;
export type ButtonType = 'button' | 'submit' | 'reset';
export type ButtonUse = 'default' | 'primary' | 'success' | 'danger' | 'pay' | 'link' | 'text' | 'backless';

Expand Down
5 changes: 0 additions & 5 deletions packages/react-ui/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ import { styles, globalClasses } from './Checkbox.styles';
import { CheckedIcon } from './CheckedIcon';
import { IndeterminateIcon } from './IndeterminateIcon';

/**
* @deprecated use SizeProp
*/
export type CheckboxSize = SizeProp;

export interface CheckboxProps
extends CommonProps,
Pick<AriaAttributes, 'aria-describedby' | 'aria-label'>,
Expand Down
5 changes: 0 additions & 5 deletions packages/react-ui/components/FileUploader/FileUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ import { globalClasses, jsStyles } from './FileUploader.styles';

const stopPropagation: React.ReactEventHandler = (e) => e.stopPropagation();

/**
* @deprecated use SizeProp
*/
export type FileUploaderSize = SizeProp;

type FileUploaderOverriddenProps = 'size';

interface _FileUploaderProps
Expand Down
4 changes: 0 additions & 4 deletions packages/react-ui/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ import { PolyfillPlaceholder } from './InputLayout/PolyfillPlaceholder';

export const inputTypes = ['password', 'text', 'number', 'tel', 'search', 'time', 'date', 'url', 'email'] as const;

/**
* @deprecated use SizeProp
*/
export type InputSize = SizeProp;
export type InputAlign = 'left' | 'center' | 'right';
export type InputType = (typeof inputTypes)[number];
export type InputIconType = React.ReactNode | (() => React.ReactNode);
Expand Down
5 changes: 0 additions & 5 deletions packages/react-ui/components/MenuFooter/MenuFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ import { SizeProp } from '../../lib/types/props';

import { styles } from './MenuFooter.styles';

/**
* @deprecated use SizeProp
*/
export type MenuFooterSize = SizeProp;

export interface MenuFooterProps extends CommonProps, Pick<HTMLAttributes<HTMLElement>, 'id'> {
_enableIconPadding?: boolean;
children: ReactNode;
Expand Down
5 changes: 0 additions & 5 deletions packages/react-ui/components/MenuHeader/MenuHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import { MenuContext } from '../../internal/Menu/MenuContext';

import { styles } from './MenuHeader.styles';

/**
* @deprecated use SizeProp
*/
export type MenuHeaderSize = SizeProp;

export interface MenuHeaderProps extends CommonProps, Pick<HTMLAttributes<HTMLElement>, 'id'> {
_enableIconPadding?: boolean;
children: ReactNode;
Expand Down
5 changes: 0 additions & 5 deletions packages/react-ui/components/MenuItem/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ import { getVisualStateDataAttributes } from '../../internal/CommonWrapper/utils

import { styles } from './MenuItem.styles';

/**
* @deprecated use SizeProp
*/
export type MenuItemSize = SizeProp;

export type MenuItemState = null | 'hover' | 'selected' | void;

export interface MenuItemProps
Expand Down
16 changes: 2 additions & 14 deletions packages/react-ui/components/Paging/Paging.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@ export interface PagingProps extends CommonProps {
* на каждом из них. Такие случаи лучше обрабатывать отдельно.
*/
useGlobalListener?: boolean;
/**
* Определяет, нужно ли показывать `Paging` когда страница всего одна.
*
* Этот проп будет удалён в 5-ой версии библиотеки,
* так как поведение со скрытием `Paging`'а станет поведением по умолчанию.
*
* @default false
*/
shouldBeVisibleWithLessThanTwoPages?: boolean; // TODO Delete in 5.0
}

export interface PagingState {
Expand All @@ -86,9 +77,7 @@ export const PagingDataTids = {
pageLink: 'Paging__pageLink',
} as const;

type DefaultProps = Required<
Pick<PagingProps, 'component' | 'shouldBeVisibleWithLessThanTwoPages' | 'useGlobalListener'>
>;
type DefaultProps = Required<Pick<PagingProps, 'component' | 'useGlobalListener'>>;

@rootNode
@locale('Paging', PagingLocaleHelper)
Expand All @@ -98,7 +87,6 @@ export class Paging extends React.PureComponent<PagingProps, PagingState> {

public static defaultProps: DefaultProps = {
component: PagingDefaultComponent,
shouldBeVisibleWithLessThanTwoPages: true,
useGlobalListener: false,
};

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

public render() {
if (this.props.pagesCount < 2 && !this.getProps().shouldBeVisibleWithLessThanTwoPages) {
if (this.props.pagesCount < 2) {
return null;
}

Expand Down
17 changes: 4 additions & 13 deletions packages/react-ui/components/Paging/__tests__/Paging-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,16 @@ describe('Paging', () => {
expect(screen.getAllByTestId(PagingDataTids.pageLink)).toHaveLength(5);
});

it('should not be rendered when only one page is presented and the flag is enabled', () => {
const callback = jest.fn();
render(
<Paging pagesCount={1} activePage={1} onPageChange={callback} shouldBeVisibleWithLessThanTwoPages={false} />,
);

expect(screen.queryByTestId(PagingDataTids.root)).not.toBeInTheDocument();
});

it('should be rendered when only one page is presented and the flag is disabled', () => {
it('should not be rendered when pagesCount < 2', () => {
const callback = jest.fn();
render(<Paging pagesCount={1} activePage={1} onPageChange={callback} />);

expect(screen.getByTestId(PagingDataTids.root)).toBeInTheDocument();
expect(screen.queryByTestId(PagingDataTids.root)).not.toBeInTheDocument();
});

it('should be rendered when two or more pages are presented and the flag is enabled', () => {
it('should be rendered when pagesCount >= 2', () => {
const callback = jest.fn();
render(<Paging pagesCount={2} activePage={1} onPageChange={callback} shouldBeVisibleWithLessThanTwoPages />);
render(<Paging pagesCount={2} activePage={1} onPageChange={callback} />);

expect(screen.getByTestId(PagingDataTids.root)).toBeInTheDocument();
});
Expand Down
5 changes: 0 additions & 5 deletions packages/react-ui/components/Radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ import { FocusControlWrapper } from '../../internal/FocusControlWrapper';

import { styles, globalClasses } from './Radio.styles';

/**
* @deprecated use SizeProp
*/
export type RadioSize = SizeProp;

export interface RadioProps<T>
extends Pick<AriaAttributes, 'aria-label'>,
CommonProps,
Expand Down
23 changes: 6 additions & 17 deletions packages/react-ui/components/ScrollContainer/ScrollContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,13 @@ export interface ScrollContainerProps extends CommonProps {
* Смещение горизонтального скроллбара
*/
offsetX?: Partial<Record<OffsetCSSPropsX, React.CSSProperties[OffsetCSSPropsX]>>;
/**
* Скрывать скроллбар при отсутствии активности пользователя
* @deprecated use showScrollBar
*/
hideScrollBar?: boolean;

/**
* Показывать скроллбар
*/
showScrollBar?: 'always' | 'scroll' | 'hover' | 'never';
/**
* Задержка перед скрытием скроллбара, ms. Работает только если `hideScrollBar = true` или `showScrollBar = 'scroll' | 'hover'`
* Задержка перед скрытием скроллбара, ms. Работает только `showScrollBar = 'scroll' | 'hover'`
*/
hideScrollBarDelay?: number;
/**
Expand All @@ -93,13 +89,7 @@ export const ScrollContainerDataTids = {
type DefaultProps = Required<
Pick<
ScrollContainerProps,
| 'invert'
| 'scrollBehaviour'
| 'preventWindowScroll'
| 'hideScrollBar'
| 'disableAnimations'
| 'hideScrollBarDelay'
| 'showScrollBar'
'invert' | 'scrollBehaviour' | 'preventWindowScroll' | 'disableAnimations' | 'hideScrollBarDelay' | 'showScrollBar'
>
>;

Expand Down Expand Up @@ -129,7 +119,6 @@ export class ScrollContainer extends React.Component<ScrollContainerProps, Scrol
invert: false,
scrollBehaviour: 'auto',
preventWindowScroll: false,
hideScrollBar: false,
disableAnimations: isTestEnv,
hideScrollBarDelay: 500,
showScrollBar: 'always',
Expand All @@ -140,7 +129,7 @@ export class ScrollContainer extends React.Component<ScrollContainerProps, Scrol
private scrollX: Nullable<ScrollBar>;
private scrollY: Nullable<ScrollBar>;
private setRootNode!: TSetRootNode;
private initialIsScrollBarVisible = !this.getProps().hideScrollBar && this.getProps().showScrollBar === 'always';
private initialIsScrollBarVisible = this.getProps().showScrollBar === 'always';

public state: ScrollContainerState = {
isScrollBarXVisible: this.initialIsScrollBarVisible,
Expand Down Expand Up @@ -326,8 +315,8 @@ export class ScrollContainer extends React.Component<ScrollContainerProps, Scrol
if (scrollState !== prevScrollState) {
this.handleScrollStateChange(scrollState, axis);
}
const { hideScrollBar, showScrollBar } = this.getProps();
(hideScrollBar || showScrollBar === 'scroll') && this.showScrollBarOnMouseWheel(axis);
const { showScrollBar } = this.getProps();
showScrollBar === 'scroll' && this.showScrollBarOnMouseWheel(axis);
};

private refScrollBarY = (scrollbar: Nullable<ScrollBar>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,6 @@ kind('ScrollContainer', () => {
});
});

story('HideScrollBar', ({ setStoryParameters }) => {
setStoryParameters({ skip: { 'themes dont affect logic': { in: /^(?!\b(firefox2022|chrome2022)\b)/ } } });

test('hideScroll', async function () {
const beforeScroll = await this.takeScreenshot();
await this.browser.executeScript(function () {
const scrollContainer = window.document.querySelector('[data-tid~="ScrollContainer__inner"]');
if (scrollContainer) {
scrollContainer.scrollTop = 500;
}
});
this.browser
.actions({
bridge: true,
})
.move({ origin: this.browser.findElement({ css: 'body' }) });
await delay(200);
const duringScroll = await this.takeScreenshot();
await delay(3000);
const afterScroll = await this.takeScreenshot();
await this.expect({ beforeScroll, duringScroll, afterScroll }).to.matchImages();
});
});

story('ScrollBarVisibleAfterTogglingDisabled', ({ setStoryParameters }) => {
setStoryParameters({ skip: { 'themes dont affect logic': { in: /^(?!\bchrome2022\b)/ } } });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,27 +328,6 @@ export const OffsetYAndX: Story = () => (
</div>
);

export const HideScrollBar: Story = () => (
<div style={wrapperStyle}>
<ScrollContainer
hideScrollBar
// Magic delay to capture the scrollbar
hideScrollBarDelay={2000}
disableAnimations
>
<div style={{ width: 300 }}>
{Array(30)
.fill(null)
.map((_, i) => (
<div style={{ width: 200 }} key={i}>
{i}
</div>
))}
</div>
</ScrollContainer>
</div>
);

export const ScrollBarVisibleAfterTogglingDisabled: Story = () => {
const [isDisabled, setIsDisabled] = useState(false);

Expand Down
4 changes: 0 additions & 4 deletions packages/react-ui/components/Switcher/Switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ import { styles } from './Switcher.styles';
import { getSwitcherTheme } from './switcherTheme';
import { mod } from './helpers';

/**
* @deprecated use SizeProp
*/
export type SwitcherSize = SizeProp;
export type SwitcherItems = string | SwitcherItem;

export const SwitcherDataTids = {
Expand Down
6 changes: 0 additions & 6 deletions packages/react-ui/components/Tabs/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';
import { cx } from '../../lib/theming/Emotion';
import { rootNode, TSetRootNode } from '../../lib/rootNode';
import { createPropsGetter } from '../../lib/createPropsGetter';
import { SizeProp } from '../../lib/types/props';
import { getVisualStateDataAttributes } from '../../internal/CommonWrapper/utils/getVisualStateDataAttributes';

import { TabsContext, TabsContextDefaultValue, TabsContextType } from './TabsContext';
Expand All @@ -31,11 +30,6 @@ export const TabDataTids = {
root: 'Tab__root',
} as const;

/**
* @deprecated use SizeProp
*/
export type TabSize = SizeProp;

export interface TabProps<T extends string = string>
extends Pick<AriaAttributes, 'aria-label' | 'aria-describedby'>,
CommonProps {
Expand Down
5 changes: 0 additions & 5 deletions packages/react-ui/components/Textarea/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ import { styles } from './Textarea.styles';
import { TextareaCounter, TextareaCounterRef } from './TextareaCounter';
import { TextareaWithSafari17Workaround } from './TextareaWithSafari17Workaround';

/**
* @deprecated use SizeProp
*/
export type TextareaSize = SizeProp;

const DEFAULT_WIDTH = 250;
const AUTORESIZE_THROTTLE_DEFAULT_WAIT = 100;

Expand Down
Loading