Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/long-bats-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@alfalab/core-components-steps': major
'@alfalab/core-components': major
---

##### Steps

- Убрали поддержку deprecated `Badge` в `Steps` и полностью перевели индикаторы шага на `StatusBadge`.
1 change: 0 additions & 1 deletion packages/steps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"main": "index.js",
"module": "./esm/index.js",
"dependencies": {
"@alfalab/core-components-badge": "^7.0.2",
"@alfalab/core-components-shared": "^2.1.1",
"@alfalab/core-components-status-badge": "^3.0.2",
"@alfalab/hooks": "^1.13.1",
Expand Down
24 changes: 20 additions & 4 deletions packages/steps/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Steps', () => {
});

describe('Render tests', () => {
test('should render with default active step', () => {
it('should render with default active step', () => {
const defaultActiveStep = 2;

const { container } = render(
Expand All @@ -79,7 +79,7 @@ describe('Steps', () => {
expect(steps[defaultActiveStep - 1]).toHaveClass('selected');
});

test('should render ordered steps', () => {
it('should render ordered steps', () => {
const { queryAllByText } = render(
<Steps>
<div>Подготовка</div>
Expand All @@ -93,7 +93,7 @@ describe('Steps', () => {
expect(steps[1].innerHTML).toBe('2');
});

test('should render unordered steps', () => {
it('should render unordered steps', () => {
const { container } = render(
<Steps ordered={false}>
<div>Шаг 1</div>
Expand All @@ -107,7 +107,23 @@ describe('Steps', () => {
expect(unorderedSteps.length).toBe(3);
});

test('should unmount without errors', () => {
it('should render custom status badge indicator', () => {
const { queryByText, getByText } = render(
<Steps
checkIsStepCustom={(stepNumber) =>
stepNumber === 1 ? { view: 'negative-alert' } : null
}
>
<div>Первый шаг</div>
<div>Второй шаг</div>
</Steps>,
);

expect(queryByText(/^1$/)).not.toBeInTheDocument();
expect(getByText(/^2$/)).toBeInTheDocument();
});

it('should unmount without errors', () => {
const { unmount } = render(
<Steps>
<div>Шаг 1</div>
Expand Down
6 changes: 3 additions & 3 deletions packages/steps/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { type CommonProps } from './types/common-props';

import styles from './index.module.css';

export type StepsProps = {
export interface StepsProps extends CommonProps {
/**
* Дополнительный класс
*/
Expand Down Expand Up @@ -76,7 +76,7 @@ export type StepsProps = {
/**
* Кастомный метод для установки кастомного индикатора шага
* @param stepNumber - номер шага
* @return Объект StepIndicatorProps { className, content, iconColor } или null
* @return Объект StepIndicatorProps { view, className, colors } или null
*/
checkIsStepCustom?: (stepNumber: number) => StepIndicatorProps | null;

Expand All @@ -85,7 +85,7 @@ export type StepsProps = {
* @param stepNumber - номер активного шага
*/
onChange?: (stepNumber: number) => void;
} & CommonProps;
}

export const Steps: React.FC<StepsProps> = ({
className,
Expand Down
8 changes: 2 additions & 6 deletions packages/steps/src/components/step-indicator/Component.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import React from 'react';
import cn from 'classnames';

import { type BadgeProps } from '@alfalab/core-components-badge';
import { StatusBadge, type StatusBadgeProps } from '@alfalab/core-components-status-badge';

import styles from './index.module.css';

/** @description В `@alfalab/core-components@51.0.0` тип будет изменен на Pick<StatusBadgeProps, 'view' | 'className' | 'colors'> */
export type StepIndicatorProps = Pick<BadgeProps, 'content' | 'iconColor' | 'className'>;
export type StepIndicatorProps = Pick<StatusBadgeProps, 'view' | 'className' | 'colors'>;

type StatusBadgeIndicatorProps = Pick<StatusBadgeProps, 'view' | 'className' | 'colors'>;

export const StepIndicator: React.FC<StatusBadgeIndicatorProps> = ({ view, className, colors }) => (
export const StepIndicator: React.FC<StepIndicatorProps> = ({ view, className, colors }) => (
<StatusBadge
size={24}
view={view}
Expand Down
3 changes: 1 addition & 2 deletions packages/steps/src/components/step/Component.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { type FC, useRef } from 'react';
import cn from 'classnames';

import { Badge } from '@alfalab/core-components-badge';
import { getDataTestId } from '@alfalab/core-components-shared';
import { useFocus } from '@alfalab/hooks';

Expand Down Expand Up @@ -121,7 +120,7 @@ export const Step: FC<StepProps> = ({

const getStepIndicator = () => {
if (customStepIndicator) {
return <Badge view='icon' size='l' {...customStepIndicator} />;
return <StepIndicator {...customStepIndicator} />;
}
if (isCriticalError) {
return <StepIndicator view='negative-cross' />;
Expand Down
4 changes: 2 additions & 2 deletions packages/steps/src/types/common-props.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type ReactNode } from 'react';

/** Обобщенный набор типов который подходит для Steps, но также прокинут в дочерний Step */
export type CommonProps = {
export interface CommonProps {
/**
* Идентификатор для систем автоматизированного тестирования
*/
Expand Down Expand Up @@ -45,4 +45,4 @@ export type CommonProps = {
* Цвет тире выполненного шага
*/
completedDashColor?: string;
};
}
3 changes: 0 additions & 3 deletions packages/steps/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
"rootDir": "src",
"outDir": "ts-dist",
"paths": {
"@alfalab/core-components-badge": ["../badge/src"],
"@alfalab/core-components-badge/*": ["../badge/src/*"],
"@alfalab/core-components-shared": ["../shared/src"],
"@alfalab/core-components-shared/*": ["../shared/src/*"],
"@alfalab/core-components-status-badge": ["../status-badge/src"],
Expand All @@ -18,7 +16,6 @@
}
},
"references": [
{ "path": "../badge/tsconfig.build.json" },
{ "path": "../shared/tsconfig.build.json" },
{ "path": "../status-badge/tsconfig.build.json" }
]
Expand Down
3 changes: 0 additions & 3 deletions packages/steps/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"rootDir": "src",
"outDir": "no-dist",
"paths": {
"@alfalab/core-components-badge": ["../badge/src"],
"@alfalab/core-components-badge/*": ["../badge/src/*"],
"@alfalab/core-components-screenshot-utils": ["../screenshot-utils/src"],
"@alfalab/core-components-screenshot-utils/*": ["../screenshot-utils/src/*"],
"@alfalab/core-components-shared": ["../shared/src"],
Expand All @@ -21,7 +19,6 @@
}
},
"references": [
{ "path": "../badge/tsconfig.build.json" },
{ "path": "../screenshot-utils/tsconfig.build.json" },
{ "path": "../shared/tsconfig.build.json" },
{ "path": "../status-badge/tsconfig.build.json" },
Expand Down
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1846,7 +1846,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@alfalab/core-components-steps@workspace:packages/steps"
dependencies:
"@alfalab/core-components-badge": "npm:^7.0.2"
"@alfalab/core-components-shared": "npm:^2.1.1"
"@alfalab/core-components-status-badge": "npm:^3.0.2"
"@alfalab/hooks": "npm:^1.13.1"
Expand Down
Loading