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

sdds-serv: add TextArea component #1263

Merged
merged 4 commits into from
Jun 25, 2024
Merged
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: 6 additions & 2 deletions packages/plasma-b2c/api/plasma-b2c.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ import { TabsContext } from '@salutejs/plasma-new-hope/styled-components';
import { TabsControllerProps } from '@salutejs/plasma-new-hope/styled-components';
import { TabsProps } from '@salutejs/plasma-new-hope/styled-components';
import { TextareaHTMLAttributes } from '@salutejs/plasma-core';
import { TextAreaProps } from '@salutejs/plasma-hope';
import type { TextAreaProps as TextAreaProps_2 } from '@salutejs/plasma-hope';
import { TextareaResize } from '@salutejs/plasma-core';
import { TextFieldPrimitiveValue } from '@salutejs/plasma-new-hope/types/components/TextField/TextField.types';
import { TextfieldPrimitiveValue } from '@salutejs/plasma-new-hope/types/components/Range/Range.types';
Expand Down Expand Up @@ -1993,7 +1993,11 @@ export const TextArea: ForwardRefExoticComponent<TextAreaProps & RefAttributes<H

export { TextareaHTMLAttributes }

export { TextAreaProps }
// @public (undocumented)
export interface TextAreaProps extends TextAreaProps_2 {
// @deprecated (undocumented)
resize?: 'none' | 'both' | 'horizontal' | 'vertical';
}

export { TextareaResize }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const StoryDefault = ({ status, enableContentRight, ...rest }: StoryProps) => {

return (
<TextArea
resize="none"
value={value}
contentRight={enableContentRight ? <IconPlaceholder /> : undefined}
status={status || undefined}
Expand Down
5 changes: 3 additions & 2 deletions packages/plasma-b2c/src/components/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { textAreaConfig, component, mergeConfig } from '@salutejs/plasma-new-hope/styled-components';
import type { ForwardRefExoticComponent, RefAttributes } from 'react';

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

import type { TextAreaProps } from '.';

const mergedConfig = mergeConfig(textAreaConfig, config);
const TextAreaComponent = component(mergedConfig) as React.ForwardRefExoticComponent<
TextAreaProps & React.RefAttributes<HTMLTextAreaElement>
const TextAreaComponent = component(mergedConfig) as ForwardRefExoticComponent<
TextAreaProps & RefAttributes<HTMLTextAreaElement>
>;

/**
Expand Down
10 changes: 9 additions & 1 deletion packages/plasma-b2c/src/components/TextArea/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
import type { TextAreaProps as TextAreaPropsBase } from '@salutejs/plasma-hope';

export { TextArea } from './TextArea';
export type { TextAreaProps } from '@salutejs/plasma-hope';

export interface TextAreaProps extends TextAreaPropsBase {
/**
* @deprecated не используется в компоненте
*/
resize?: 'none' | 'both' | 'horizontal' | 'vertical';
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TextareaHTMLAttributes } from '@salutejs/plasma-core';
import { TextareaHTMLAttributes } from '../../types';

export interface TextAreaPropsBase {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { textAreaRoot, textAreaConfig } from './TextArea';
export { tokens as textAreaTokens } from './TextArea.tokens';
export type { TextAreaProps } from './TextArea.types';
55 changes: 55 additions & 0 deletions packages/plasma-new-hope/src/types/TextareaHTMLAttributes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// INFO: Issue об этом решении - https://github.com/salute-developers/plasma/issues/1219

import React from 'react';

import { DisabledProps } from '../mixins';

export interface TextareaHTMLAttributes<T> extends DisabledProps, React.TextareaHTMLAttributes<T> {
autoComplete?: string;
autoFocus?: boolean;
cols?: number;
dirName?: string;
form?: string;
/**
* Минимальная длина значения поля
*/
minLength?: number;
/**
* Максимальная длина значения поля
*/
maxLength?: number;
/**
* Определяет уникальное имя элемента формы
*/
name?: string;
/**
* Выводит текст внутри поля формы, который исчезает при получении фокуса
*/
placeholder?: string;
/**
* Элемент формы не может изменяться пользователем
*/
readOnly?: boolean;
/**
* Флаг обязательности поля
*/
required?: boolean;
rows?: number;
/**
* Определяет значение элемента формы
*/
value?: string | ReadonlyArray<string> | number;
wrap?: string;
/**
* Обработчик изменения элемента формы
*/
onChange?: React.TextareaHTMLAttributes<T>['onChange'];
/**
* Обработчик фокуса на элементе формы
*/
onFocus?: React.TextareaHTMLAttributes<T>['onFocus'];
/**
* Обработчик блюра на элементе формы
*/
onBlur?: React.TextareaHTMLAttributes<T>['onBlur'];
}
1 change: 1 addition & 0 deletions packages/plasma-new-hope/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export type { AsProps } from './AsProps';
export type { NumericRange, CreateArrayWithLengthX } from './Range';
export type { InputHTMLAttributes } from './InputHTMLAttributes';
export type { TextareaHTMLAttributes } from './TextareaHTMLAttributes';
8 changes: 6 additions & 2 deletions packages/plasma-web/api/plasma-web.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ import { TabsContext } from '@salutejs/plasma-new-hope/styled-components';
import { TabsControllerProps } from '@salutejs/plasma-new-hope/styled-components';
import { TabsProps } from '@salutejs/plasma-new-hope/styled-components';
import { TextareaHTMLAttributes } from '@salutejs/plasma-core';
import { TextAreaProps } from '@salutejs/plasma-hope';
import type { TextAreaProps as TextAreaProps_2 } from '@salutejs/plasma-hope';
import { TextareaResize } from '@salutejs/plasma-core';
import { TextFieldPrimitiveValue } from '@salutejs/plasma-new-hope/types/components/TextField/TextField.types';
import { TextfieldPrimitiveValue } from '@salutejs/plasma-new-hope/types/components/Range/Range.types';
Expand Down Expand Up @@ -1995,7 +1995,11 @@ export const TextArea: ForwardRefExoticComponent<TextAreaProps & RefAttributes<H

export { TextareaHTMLAttributes }

export { TextAreaProps }
// @public (undocumented)
export interface TextAreaProps extends TextAreaProps_2 {
// @deprecated (undocumented)
resize?: 'none' | 'both' | 'horizontal' | 'vertical';
}

export { TextareaResize }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const StoryDefault = ({ enableContentRight, status, ...rest }: StoryProps) => {

return (
<TextArea
resize="none"
value={value}
contentRight={enableContentRight ? <IconPlaceholder /> : undefined}
status={status || undefined}
Expand Down
5 changes: 3 additions & 2 deletions packages/plasma-web/src/components/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { textAreaConfig, component, mergeConfig } from '@salutejs/plasma-new-hope/styled-components';
import type { ForwardRefExoticComponent, RefAttributes } from 'react';

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

import type { TextAreaProps } from '.';

const mergedConfig = mergeConfig(textAreaConfig, config);
const TextAreaComponent = component(mergedConfig) as React.ForwardRefExoticComponent<
TextAreaProps & React.RefAttributes<HTMLTextAreaElement>
const TextAreaComponent = component(mergedConfig) as ForwardRefExoticComponent<
TextAreaProps & RefAttributes<HTMLTextAreaElement>
>;

/**
Expand Down
10 changes: 9 additions & 1 deletion packages/plasma-web/src/components/TextArea/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
import type { TextAreaProps as TextAreaPropsBase } from '@salutejs/plasma-hope';

export { TextArea } from './TextArea';
export type { TextAreaProps } from '@salutejs/plasma-hope';

export interface TextAreaProps extends TextAreaPropsBase {
/**
* @deprecated не используется в компоненте
*/
resize?: 'none' | 'both' | 'horizontal' | 'vertical';
}
22 changes: 22 additions & 0 deletions packages/sdds-serv/api/sdds-serv.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ import { TabItemRefs } from '@salutejs/plasma-new-hope/styled-components';
import { TabsContext } from '@salutejs/plasma-new-hope/styled-components';
import { TabsControllerProps } from '@salutejs/plasma-new-hope/styled-components';
import { TabsProps } from '@salutejs/plasma-new-hope/styled-components';
import { TextareaHTMLAttributes } from '@salutejs/plasma-new-hope/types/types';
import { TextAreaPropsExtends } from '@salutejs/plasma-new-hope/types/components/TextArea/TextArea.types';
import { TextFieldPrimitiveValue } from '@salutejs/plasma-new-hope/types/components/TextField/TextField.types';
import { TextfieldPrimitiveValue } from '@salutejs/plasma-new-hope/types/components/Range/Range.types';
import { TextFieldProps } from '@salutejs/plasma-new-hope/styled-components';
Expand Down Expand Up @@ -1478,6 +1480,26 @@ export { TabsControllerProps }

export { TabsProps }

// @public
export const TextArea: FunctionComponent<PropsType< {
size: {
xs: string;
s: string;
m: string;
l: string;
};
view: {
default: string;
primary: string;
positive: string;
warning: string;
negative: string;
};
disabled: {
true: string;
};
}> & TextareaHTMLAttributes<HTMLTextAreaElement> & TextAreaPropsExtends & RefAttributes<HTMLTextAreaElement>>;

// @public
export const TextField: FunctionComponent<PropsType< {
view: {
Expand Down
Loading
Loading