1 import type { Meta, StoryObj } from "@storybook/react"
2 import * as React from "react"
3
4 import { OtpInput } from "./otp-input"
5
6 type OtpInputStoryProps = React.ComponentProps<typeof OtpInput>
7
8 const OtpInputStory = (args: OtpInputStoryProps) => {
9 const [value, setValue] = React.useState(args.value ?? "")
10
11 return <OtpInput {...args} value={value} onChange={setValue} />
12 }
13
14 const meta: Meta<typeof OtpInput> = {
15 title: "Components/OtpInput",
16 component: OtpInput,
17 parameters: {
18 layout: "centered",
19 },
20 render: (args) => <OtpInputStory {...args} />,
21 }
22
23 export default meta
24
25 type Story = StoryObj<typeof OtpInput>
26
27 export const Default: Story = {
28 args: {
29 "aria-label": "Verification code",
30 value: "",
31 },
32 }
33
34 export const Disabled: Story = {
35 args: {
36 "aria-label": "Verification code",
37 disabled: true,
38 value: "123456",
39 },
40 }
41
42 export const Invalid: Story = {
43 args: {
44 "aria-invalid": true,
45 "aria-label": "Verification code",
46 value: "123",
47 },
48 }
49
50 export const EightDigits: Story = {
51 args: {
52 "aria-label": "Recovery code",
53 groupSize: 4,
54 length: 8,
55 value: "",
56 },
57 }