Skip to content

Commit 4383178

Browse files
committed
docs: autogenerate API docs for Input
1 parent 8764611 commit 4383178

File tree

3 files changed

+66
-118
lines changed

3 files changed

+66
-118
lines changed

src/components/Input/PasswordField.stories.tsx

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,33 @@
11
import { useEffect, useState } from "react";
2-
import { PasswordField as PasswordFieldInput, PasswordFieldProps } from "./PasswordField";
3-
import { Container } from "../Container/Container";
42

5-
const PasswordField = ({
6-
value: valueProp,
7-
...props
8-
}: Omit<PasswordFieldProps, "onChange">) => {
9-
const [value, setValue] = useState(valueProp);
10-
useEffect(() => {
11-
setValue(valueProp);
12-
}, [valueProp]);
3+
import { Meta, StoryObj } from "@storybook/react";
134

14-
return (
15-
<Container maxWidth="75%">
16-
<PasswordFieldInput
17-
value={value}
18-
onChange={(inputValue: string) => {
19-
setValue(inputValue);
20-
}}
21-
{...props}
22-
/>
23-
</Container>
24-
);
25-
};
5+
import { PasswordField } from "./PasswordField";
266

27-
export default {
7+
const meta: Meta<typeof PasswordField> = {
288
component: PasswordField,
299
title: "Forms/Input/PasswordField",
3010
tags: ["form-field", "input", "autodocs"],
31-
argTypes: {
32-
value: { control: "text" },
33-
label: { control: "text" },
34-
error: { control: "text" },
35-
disabled: { control: "boolean" },
36-
placeholder: { control: "text" },
37-
readOnly: { control: "boolean" },
38-
orientation: { control: "inline-radio", options: ["horizontal", "vertical"] },
39-
dir: { control: "inline-radio", options: ["start", "end"] },
11+
render: ({ value: valueProp, ...props }) => {
12+
const [value, setValue] = useState(valueProp);
13+
14+
useEffect(() => {
15+
setValue(valueProp);
16+
}, [valueProp]);
17+
18+
return (
19+
<PasswordField
20+
{...props}
21+
value={value}
22+
onChange={setValue}
23+
/>
24+
);
4025
},
4126
};
4227

43-
export const Playground = {
28+
export default meta;
29+
30+
export const Playground: StoryObj<typeof PasswordField> = {
4431
args: {
4532
label: "Label",
4633
disabled: false,
Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,39 @@
11
import { useEffect, useState } from "react";
2-
import { SearchField as SearchFieldInput, SearchFieldProps } from "./SearchField";
2+
3+
import { Meta, StoryObj } from "@storybook/react";
4+
35
import { Container } from "../Container/Container";
46

5-
const SearchField = ({
6-
value: valueProp,
7-
...props
8-
}: Omit<SearchFieldProps, "onChange">) => {
9-
const [value, setValue] = useState(valueProp);
10-
useEffect(() => {
11-
setValue(valueProp);
12-
}, [valueProp]);
13-
14-
return (
15-
<Container maxWidth="350px">
16-
<SearchFieldInput
17-
value={value}
18-
onChange={(inputValue: string) => {
19-
setValue(inputValue);
20-
}}
21-
{...props}
22-
/>
23-
</Container>
24-
);
25-
};
7+
import { SearchField } from "./SearchField";
268

27-
export default {
9+
const meta: Meta<typeof SearchField> = {
2810
component: SearchField,
2911
title: "Forms/Input/SearchField",
3012
tags: ["form-field", "input", "autodocs"],
31-
argTypes: {
32-
value: { control: "text" },
33-
clear: { control: "boolean" },
34-
label: { control: "text" },
35-
error: { control: "text" },
36-
disabled: { control: "boolean" },
37-
placeholder: { control: "text" },
38-
readOnly: { control: "boolean" },
39-
orientation: { control: "inline-radio", options: ["horizontal", "vertical"] },
40-
dir: { control: "inline-radio", options: ["start", "end"] },
41-
isFilter: { control: "boolean" },
13+
render: ({ value: valueProp, ...props }) => {
14+
const [value, setValue] = useState(valueProp);
15+
16+
useEffect(() => {
17+
setValue(valueProp);
18+
}, [valueProp]);
19+
20+
return (
21+
<Container maxWidth="350px">
22+
<SearchField
23+
{...props}
24+
value={value}
25+
onChange={setValue}
26+
/>
27+
</Container>
28+
);
4229
},
4330
};
4431

45-
export const Playground = {
32+
export default meta;
33+
34+
export const Playground: StoryObj<typeof SearchField> = {
4635
args: {
4736
label: "Label",
48-
disabled: false,
4937
placeholder: "Placeholder",
50-
clear: false,
51-
readOnly: false,
52-
isFilter: false,
53-
value: "",
54-
error: "",
5538
},
5639
};
Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,45 @@
1-
import { ChangeEvent, useEffect, useState } from "react";
2-
import { TextField as TextFieldInput, TextFieldProps } from "./TextField";
3-
import { Container } from "../Container/Container";
1+
import { useEffect, useState } from "react";
42

5-
const TextField = ({ value: valueProp, ...props }: Omit<TextFieldProps, "onChange">) => {
6-
const [value, setValue] = useState(valueProp);
7-
useEffect(() => {
8-
setValue(valueProp);
9-
}, [valueProp]);
3+
import { Meta, StoryObj } from "@storybook/react";
104

11-
return (
12-
<Container maxWidth="75%">
13-
<TextFieldInput
14-
value={value}
15-
onChange={(inputValue: string, e?: ChangeEvent<HTMLInputElement>) => {
16-
if (e) {
17-
e.preventDefault();
18-
}
19-
setValue(inputValue);
20-
}}
21-
{...props}
22-
/>
23-
</Container>
24-
);
25-
};
5+
import { TextField } from "./TextField";
266

27-
export default {
7+
const meta: Meta<typeof TextField> = {
288
component: TextField,
299
title: "Forms/Input/TextField",
3010
tags: ["form-field", "input", "autodocs"],
31-
argTypes: {
32-
type: {
33-
control: "inline-radio",
34-
options: ["text", "email", "tel", "url"],
35-
},
36-
value: { control: "text" },
37-
clear: { control: "boolean" },
38-
label: { control: "text" },
39-
error: { control: "text" },
40-
disabled: { control: "boolean" },
41-
placeholder: { control: "text" },
42-
readOnly: { control: "boolean" },
43-
orientation: { control: "inline-radio", options: ["horizontal", "vertical"] },
44-
dir: { control: "inline-radio", options: ["start", "end"] },
11+
render: ({ value: valueProp, ...props }) => {
12+
const [value, setValue] = useState(valueProp);
13+
14+
useEffect(() => {
15+
setValue(valueProp);
16+
}, [valueProp]);
17+
18+
return (
19+
<TextField
20+
{...props}
21+
value={value}
22+
onChange={setValue}
23+
/>
24+
);
4525
},
4626
};
4727

48-
export const Playground = {
28+
export default meta;
29+
30+
export const Playground: StoryObj<typeof TextField> = {
4931
args: {
5032
label: "Label",
51-
clear: false,
5233
type: "text",
53-
disabled: false,
5434
placeholder: "Placeholder",
5535
},
5636
};
5737

58-
export const LabelColor = {
38+
export const LabelColor: StoryObj<typeof TextField> = {
5939
args: {
6040
label: "Label",
6141
labelColor: "rgb(193, 0, 0)",
62-
clear: false,
6342
type: "text",
64-
disabled: false,
6543
placeholder: "Placeholder",
6644
},
6745
};

0 commit comments

Comments
 (0)