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

PLASMA-4145: edit storybook textarea #1649

Merged
merged 2 commits into from
Dec 22, 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
iljs marked this conversation as resolved.
Show resolved Hide resolved
iljs marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import type { PopoverPlacement } from '@salutejs/plasma-new-hope';
import { TextArea } from '.';
import type { TextAreaProps } from '.';

const labelPlacements = ['inner', 'outer'];

const onChange = action('onChange');
const onFocus = action('onFocus');
const onBlur = action('onBlur');

const statuses = ['', 'success', 'warning', 'error'];
const sizes = ['xs', 's', 'm', 'l'];
const views = ['default', 'positive', 'warning', 'negative'];
const hintViews = ['default'];
const hintSizes = ['m', 's'];
const hintTriggers = ['hover', 'click'];
Expand Down Expand Up @@ -59,10 +61,9 @@ const meta: Meta<TextAreaProps> = {
},
if: { arg: 'required', truthy: false },
},
status: {
options: statuses,
clear: {
control: {
type: 'select',
type: 'boolean',
},
},
size: {
Expand All @@ -72,8 +73,14 @@ const meta: Meta<TextAreaProps> = {
type: 'select',
},
},
view: {
options: views,
control: {
type: 'select',
},
},
labelPlacement: {
options: ['inner', 'outer'],
options: labelPlacements,
control: {
type: 'select',
},
Expand All @@ -96,6 +103,11 @@ const meta: Meta<TextAreaProps> = {
},
if: { arg: 'clear', truthy: false },
},
hasHint: {
control: {
type: 'boolean',
},
},
hintText: {
control: { type: 'text' },
if: { arg: 'hasHint', truthy: true },
Expand Down Expand Up @@ -137,6 +149,24 @@ const meta: Meta<TextAreaProps> = {
control: { type: 'text' },
if: { arg: 'hasHint', truthy: true },
},
helperText: {
iljs marked this conversation as resolved.
Show resolved Hide resolved
control: { type: 'text' },
},
width: {
control: { type: 'text' },
},
height: {
control: { type: 'text' },
},
leftHelper: {
control: { type: 'text' },
},
titleCaption: {
control: { type: 'text' },
},
rightHelper: {
control: { type: 'text' },
},
...disableProps([
'helperBlock',
'$isFocused',
Expand All @@ -157,6 +187,11 @@ const meta: Meta<TextAreaProps> = {
'onFocus',
'onBlur',
'leftHelperPlacement',
'status',
'hintTargetIcon',
'hintOffset',
'hintContentLeft',
'hintView',
]),
},
args: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ const meta: Meta<TextFieldProps> = {
},
if: { arg: 'clear', truthy: true },
},
status: {
options: statuses,
control: {
type: 'select',
},
},
size: {
options: sizes,
control: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { forwardRef, useState, createRef, useCallback, useRef, MouseEventHandler } from 'react';
import React, { forwardRef, useState, createRef, useCallback, useRef, MouseEventHandler, useLayoutEffect } from 'react';
import { css } from '@linaria/core';
import { useForkRef, useResizeObserver } from '@salutejs/plasma-core';

Expand Down Expand Up @@ -199,6 +199,12 @@ export const textAreaRoot = (Root: RootProps<HTMLTextAreaElement, TextAreaRootPr
}
};

useLayoutEffect(() => {
if (outerRef.current) {
iljs marked this conversation as resolved.
Show resolved Hide resolved
setUncontrolledValue(outerRef.current.value);
}
}, [outerRef]);

useResizeObserver(outerRef, (currentElement) => {
const { width: inlineWidth } = currentElement.style;

Expand Down
iljs marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { config } from './TextArea.config';
import { TextArea } from './TextArea';

const labelPlacements = ['inner', 'outer'];
iljs marked this conversation as resolved.
Show resolved Hide resolved
const sizes = ['xs', 's', 'm', 'l'];
const views = ['default', 'positive', 'warning', 'negative'];
const hintViews = ['default'];
const hintSizes = ['m', 's'];
const hintTriggers = ['hover', 'click'];
Expand Down Expand Up @@ -67,22 +69,23 @@ const meta: Meta<StoryTextAreaProps> = {
},
if: { arg: 'required', truthy: false },
},
rows: {
size: {
options: sizes,
defaultValue: 'm',
control: {
type: 'number',
type: 'select',
},
if: { arg: 'clear', truthy: false },
},
cols: {
view: {
options: views,
control: {
type: 'number',
type: 'select',
},
if: { arg: 'clear', truthy: false },
},
labelPlacement: {
options: labelPlacements,
control: {
type: 'inline-radio',
type: 'select',
},
},
hasDivider: {
Expand All @@ -91,6 +94,23 @@ const meta: Meta<StoryTextAreaProps> = {
},
if: { arg: 'clear', truthy: true },
},
cols: {
control: {
type: 'number',
},
if: { arg: 'clear', truthy: false },
iljs marked this conversation as resolved.
Show resolved Hide resolved
},
rows: {
control: {
type: 'number',
},
if: { arg: 'clear', truthy: false },
},
hasHint: {
control: {
type: 'boolean',
},
},
hintText: {
control: { type: 'text' },
if: { arg: 'hasHint', truthy: true },
Expand Down Expand Up @@ -132,7 +152,50 @@ const meta: Meta<StoryTextAreaProps> = {
control: { type: 'text' },
if: { arg: 'hasHint', truthy: true },
},
...disableProps(['leftHelperPlacement']),
helperText: {
control: { type: 'text' },
},
width: {
control: { type: 'text' },
},
height: {
control: { type: 'text' },
},
leftHelper: {
control: { type: 'text' },
},
titleCaption: {
control: { type: 'text' },
},
rightHelper: {
control: { type: 'text' },
},
...disableProps([
'helperBlock',
'$isFocused',
'contentRight',
'autoComplete',
'autoFocus',
'dirName',
'form',
'minLength',
'maxLength',
'name',
'value',
'wrap',
'theme',
'as',
'forwardedAs',
'onChange',
'onFocus',
'onBlur',
'leftHelperPlacement',
'status',
'hintTargetIcon',
'hintOffset',
'hintContentLeft',
'hintView',
]),
},
args: {
id: 'example-textarea',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { config } from './TextArea.config';
import { TextArea } from './TextArea';

const labelPlacements = ['inner', 'outer'];
const sizes = ['xs', 's', 'm', 'l'];
const hintViews = ['default'];
const hintSizes = ['m', 's'];
const hintTriggers = ['hover', 'click'];
Expand Down Expand Up @@ -67,17 +68,18 @@ const meta: Meta<StoryTextAreaProps> = {
},
if: { arg: 'required', truthy: false },
},
rows: {
size: {
options: sizes,
defaultValue: 'm',
control: {
type: 'number',
type: 'select',
},
if: { arg: 'clear', truthy: false },
},
cols: {
view: {
options: views,
control: {
type: 'number',
type: 'select',
},
if: { arg: 'clear', truthy: false },
},
labelPlacement: {
options: labelPlacements,
Expand All @@ -91,6 +93,23 @@ const meta: Meta<StoryTextAreaProps> = {
},
if: { arg: 'clear', truthy: true },
},
cols: {
control: {
type: 'number',
},
if: { arg: 'clear', truthy: false },
},
rows: {
control: {
type: 'number',
},
if: { arg: 'clear', truthy: false },
},
hasHint: {
control: {
type: 'boolean',
},
},
hintText: {
control: { type: 'text' },
if: { arg: 'hasHint', truthy: true },
Expand Down Expand Up @@ -132,7 +151,50 @@ const meta: Meta<StoryTextAreaProps> = {
control: { type: 'text' },
if: { arg: 'hasHint', truthy: true },
},
...disableProps(['leftHelperPlacement']),
helperText: {
iljs marked this conversation as resolved.
Show resolved Hide resolved
control: { type: 'text' },
},
width: {
control: { type: 'text' },
},
height: {
control: { type: 'text' },
},
leftHelper: {
control: { type: 'text' },
},
titleCaption: {
control: { type: 'text' },
},
rightHelper: {
control: { type: 'text' },
},
...disableProps([
'helperBlock',
'$isFocused',
'contentRight',
'autoComplete',
'autoFocus',
'dirName',
'form',
'minLength',
'maxLength',
'name',
'value',
'wrap',
'theme',
'as',
'forwardedAs',
'onChange',
'onFocus',
'onBlur',
'leftHelperPlacement',
'status',
'hintTargetIcon',
'hintOffset',
'hintContentLeft',
'hintView',
]),
},
args: {
id: 'example-textarea',
Expand Down
Loading
Loading