Skip to content

Commit

Permalink
fix: "RequiredProps" unions in TextField & TextArea
Browse files Browse the repository at this point in the history
  • Loading branch information
vadim-kudr committed Nov 26, 2024
1 parent 96fa7d6 commit abb4a10
Show file tree
Hide file tree
Showing 24 changed files with 5,296 additions and 15,563 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,715 changes: 748 additions & 1,967 deletions packages/plasma-b2c/api/plasma-b2c.api.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ describe('plasma-b2c: TextArea', () => {

const cases = [
{ required: true, labelPlacement: 'outer' },
{ required: true, requiredPlacement: 'right', labelPlacement: 'outer' },
{ required: true, requiredPlacement: 'left', labelPlacement: 'outer' },
{ required: true, labelPlacement: 'inner' },
{ required: true, requiredPlacement: 'right', labelPlacement: 'inner' },
{ required: true, requiredPlacement: 'left', labelPlacement: 'inner' },
];

sizes.forEach((size) => {
Expand Down Expand Up @@ -334,9 +334,9 @@ describe('plasma-b2c: TextArea', () => {

const cases = [
{ required: true, labelPlacement: 'outer' },
{ required: true, requiredPlacement: 'right', labelPlacement: 'outer' },
{ required: true, requiredPlacement: 'left', labelPlacement: 'outer' },
{ required: true, labelPlacement: 'inner' },
{ required: true, requiredPlacement: 'right', labelPlacement: 'inner' },
{ required: true, requiredPlacement: 'left', labelPlacement: 'inner' },
];

sizes.forEach((size) => {
Expand Down
49 changes: 6 additions & 43 deletions packages/plasma-b2c/src/components/TextArea/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,11 @@ import type { TextAreaProps as TextAreaPropsBase } from '@salutejs/plasma-hope';
import type { PopoverPlacement, PopoverPlacementBasic } from '@salutejs/plasma-new-hope';
import type { ReactNode } from 'react';

export { TextArea } from './TextArea';
import { TextArea } from './TextArea';

type RequiredProps =
| {
/**
* Флаг обязательности поля
*/
required: true;
/**
* Задает выравнивание индикатора обязательности поля
* @default right
*/
requiredPlacement?: 'left' | 'right';
/**
* Флаг необязательности поля
*/
optional?: false;
}
| {
/**
* Флаг необязательности поля
*/
optional?: true;
/**
* Флаг обязательности поля
*/
required?: false;
/**
* Задает выравнивание индикатора обязательности поля
* @default right
*/
requiredPlacement?: never;
};
export { TextArea };

type newHopeTextAreaProps = React.ComponentProps<typeof TextArea>;

type HintProps =
| {
Expand Down Expand Up @@ -122,16 +94,7 @@ type ClearProps =
hasDivider?: never;
};

export type TextAreaProps = TextAreaPropsBase & {
/**
* @deprecated не используется в компоненте
*/
resize?: 'none' | 'both' | 'horizontal' | 'vertical';
/**
* Метка-подпись к элементу справа.
*/
titleCaption?: ReactNode;
} & RequiredProps &
export type TextAreaProps = TextAreaPropsBase &
Pick<newHopeTextAreaProps, 'title' | 'titleCaption' | 'required' | 'requiredPlacement' | 'optional'> &
ClearProps &
RequiredProps &
HintProps;
36 changes: 3 additions & 33 deletions packages/plasma-b2c/src/components/TextField/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,6 @@ export const TextFieldComponent = component(mergedConfig);

type newHopeTextFieldProps = ComponentProps<typeof TextFieldComponent>;

export type RequiredProps =
| {
/**
* Флаг обязательности поля
*/
required: true;
/**
* Задает выравнивание индикатора обязательности поля
* @default right
*/
requiredPlacement?: 'left' | 'right';
/**
* Флаг необязательности поля
*/
optional?: false;
}
| {
/**
* Флаг обязательности поля
*/
required?: false;
/**
* Задает выравнивание индикатора обязательности поля
* @default right
*/
requiredPlacement?: never;
/**
* Флаг необязательности поля
*/
optional?: boolean;
};

type ClearProps =
| {
/**
Expand Down Expand Up @@ -133,8 +101,10 @@ export type CustomTextFieldProps = (TextFieldProps &
| 'titleCaption'
| 'labelPlacement'
| 'keepPlaceholder'
| 'required'
| 'requiredPlacement'
| 'optional'
>) &
RequiredProps &
ClearProps &
HintProps;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ describe('plasma-core: TextArea', () => {

const cases = [
{ required: true, labelPlacement: 'outer' },
{ required: true, requiredPlacement: 'right', labelPlacement: 'outer' },
{ required: true, requiredPlacement: 'left', labelPlacement: 'outer' },
{ required: true, labelPlacement: 'inner' },
{ required: true, requiredPlacement: 'right', labelPlacement: 'inner' },
{ required: true, requiredPlacement: 'left', labelPlacement: 'inner' },
];

sizes.forEach((size) => {
Expand Down
46 changes: 15 additions & 31 deletions packages/plasma-new-hope/src/components/TextArea/TextArea.types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,37 +77,21 @@ export type TextAreaDimensionsProps = OneOf<
ClearProps
>;

type RequiredProps =
| {
/**
* Флаг обязательности поля
*/
required: true;
/**
* Задает выравнивание индикатора обязательности поля
* @default right
*/
requiredPlacement?: 'left' | 'right';
/**
* Флаг необязательности поля
*/
optional?: false;
}
| {
/**
* Флаг необязательности поля
*/
optional?: true;
/**
* Флаг обязательности поля
*/
required?: false;
/**
* Задает выравнивание индикатора обязательности поля
* @default right
*/
requiredPlacement?: never;
};
type RequiredProps = {
/**
* Флаг обязательности поля
*/
required?: boolean;
/**
* Задает выравнивание индикатора обязательности поля
* @default right
*/
requiredPlacement?: 'left' | 'right';
/**
* Флаг необязательности поля
*/
optional?: boolean;
};

type HintProps =
| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,37 +60,21 @@ type TextFieldChipProps =
chipType?: 'default' | 'text';
};

export type RequiredProps =
| {
/**
* Флаг обязательности поля
*/
required: true;
/**
* Задает выравнивание индикатора обязательности поля
* @default right
*/
requiredPlacement?: 'left' | 'right';
/**
* Флаг необязательности поля
*/
optional?: false;
}
| {
/**
* Флаг обязательности поля
*/
required?: false;
/**
* Задает выравнивание индикатора обязательности поля
* @default right
*/
requiredPlacement?: never;
/**
* Флаг необязательности поля
*/
optional?: boolean;
};
export type RequiredProps = {
/**
* Флаг обязательности поля
*/
required?: boolean;
/**
* Задает выравнивание индикатора обязательности поля
* @default right
*/
requiredPlacement?: 'left' | 'right';
/**
* Флаг необязательности поля
*/
optional?: boolean;
};

type ClearProps =
| {
Expand Down
Loading

0 comments on commit abb4a10

Please sign in to comment.