-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathTextAreaComponent.stories.tsx
More file actions
68 lines (63 loc) · 1.95 KB
/
TextAreaComponent.stories.tsx
File metadata and controls
68 lines (63 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import type { Meta, StoryObj } from '@storybook/react-vite';
import React, { useState } from 'react';
import { fn } from 'storybook/test';
import TextAreaComponent from '../TextAreaComponent';
import { withControlGroup } from '../../../../.storybook/withControlGroup';
const meta = {
component: TextAreaComponent,
title: 'TextAreaComponent',
render: (props) => {
// due to stories incompatibility, eslint rule is off
// React Hook "useState" is called in function "render" that is neither a React function component
// TODO: introduce a stateless stories component to reflect thaat component logic itself
const [value, setValue] = useState(props.value); // eslint-disable-line react-hooks/rules-of-hooks
return (
<TextAreaComponent
{...props}
handleChange={(field, data) => {
setValue(data);
props.handleChange(field, data);
}}
value={value}
/>
);
},
decorators: [withControlGroup],
} satisfies Meta<typeof TextAreaComponent>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Base: Story = {
args: {
handleChange: fn(),
value: '',
field: 'field',
error: false,
controlOptions: { rowsMax: 10, rowsMin: 2 },
disabled: false,
encrypted: false,
},
};
export const UnEncrypted: Story = {
args: {
handleChange: fn(),
value: `visbile text
multiple lanes`,
field: 'field',
error: false,
controlOptions: { rowsMax: 10, rowsMin: 2 },
disabled: false,
encrypted: false,
},
};
export const Encrypted: Story = {
args: {
handleChange: fn(),
value: `none visbile text
multiple lanes`,
field: 'field',
error: false,
controlOptions: { rowsMax: 10, rowsMin: 2 },
disabled: false,
encrypted: true,
},
};