|
| 1 | +import { TextInput } from "@axa-fr/design-system-slash-react/Form/Experimental"; |
| 2 | +import type { Meta, StoryObj } from "@storybook/react"; |
| 3 | +import { fn } from "@storybook/test"; |
| 4 | + |
| 5 | +const meta: Meta<typeof TextInput> = { |
| 6 | + component: TextInput, |
| 7 | + title: "Components/Form/Experimental/TextInput", |
| 8 | + argTypes: { |
| 9 | + onChange: { |
| 10 | + action: "onChange", |
| 11 | + table: { |
| 12 | + disable: true, |
| 13 | + }, |
| 14 | + }, |
| 15 | + label: { |
| 16 | + table: { |
| 17 | + category: "Visual Content", |
| 18 | + }, |
| 19 | + }, |
| 20 | + helpMessage: { |
| 21 | + table: { |
| 22 | + category: "Visual Content", |
| 23 | + }, |
| 24 | + }, |
| 25 | + errorMessage: { |
| 26 | + table: { |
| 27 | + category: "Visual Content", |
| 28 | + }, |
| 29 | + }, |
| 30 | + placeholder: { |
| 31 | + table: { |
| 32 | + category: "Visual Content", |
| 33 | + }, |
| 34 | + }, |
| 35 | + labelPosition: { |
| 36 | + table: { |
| 37 | + category: "Visual Content", |
| 38 | + }, |
| 39 | + }, |
| 40 | + contentRight: { |
| 41 | + table: { |
| 42 | + category: "Visual Content", |
| 43 | + }, |
| 44 | + control: { |
| 45 | + type: "text", |
| 46 | + }, |
| 47 | + }, |
| 48 | + required: { |
| 49 | + table: { |
| 50 | + category: "Field state", |
| 51 | + }, |
| 52 | + }, |
| 53 | + disabled: { |
| 54 | + table: { |
| 55 | + category: "Field state", |
| 56 | + }, |
| 57 | + }, |
| 58 | + value: { |
| 59 | + table: { |
| 60 | + category: "Field state", |
| 61 | + }, |
| 62 | + }, |
| 63 | + id: { |
| 64 | + table: { |
| 65 | + category: "Technical Details", |
| 66 | + }, |
| 67 | + }, |
| 68 | + name: { |
| 69 | + table: { |
| 70 | + category: "Technical Details", |
| 71 | + }, |
| 72 | + }, |
| 73 | + inputClassName: { |
| 74 | + table: { |
| 75 | + category: "Technical Details", |
| 76 | + }, |
| 77 | + }, |
| 78 | + labelClassName: { |
| 79 | + table: { |
| 80 | + category: "Technical Details", |
| 81 | + }, |
| 82 | + }, |
| 83 | + containerClassName: { |
| 84 | + table: { |
| 85 | + category: "Technical Details", |
| 86 | + }, |
| 87 | + }, |
| 88 | + }, |
| 89 | + args: { |
| 90 | + label: "What is your name?", |
| 91 | + helpMessage: "This is your government name", |
| 92 | + errorMessage: "", |
| 93 | + placeholder: "Your name", |
| 94 | + required: true, |
| 95 | + disabled: false, |
| 96 | + value: "John Doe", |
| 97 | + id: "nameid", |
| 98 | + name: "myTextInput", |
| 99 | + onChange: fn(), |
| 100 | + }, |
| 101 | +}; |
| 102 | + |
| 103 | +export default meta; |
| 104 | + |
| 105 | +type Story = StoryObj<typeof TextInput>; |
| 106 | + |
| 107 | +export const Default: Story = { |
| 108 | + render: ({ onChange, ...args }) => ( |
| 109 | + <TextInput onChange={onChange} {...args} /> |
| 110 | + ), |
| 111 | + args: {}, |
| 112 | +}; |
| 113 | + |
| 114 | +export const Vertical: Story = { |
| 115 | + render: ({ onChange, ...args }) => ( |
| 116 | + <TextInput onChange={onChange} {...args} /> |
| 117 | + ), |
| 118 | + args: { |
| 119 | + disabled: true, |
| 120 | + labelPosition: "leftAbove", |
| 121 | + }, |
| 122 | +}; |
| 123 | + |
| 124 | +export const Error: Story = { |
| 125 | + render: ({ onChange, ...args }) => ( |
| 126 | + <TextInput |
| 127 | + onChange={onChange} |
| 128 | + {...args} |
| 129 | + errorMessage="This field is required" |
| 130 | + /> |
| 131 | + ), |
| 132 | + args: { |
| 133 | + required: true, |
| 134 | + errorMessage: "This field is required", |
| 135 | + helpMessage: undefined, |
| 136 | + value: "", |
| 137 | + name: "errorInput", |
| 138 | + }, |
| 139 | +}; |
| 140 | + |
| 141 | +export const Disabled: Story = { |
| 142 | + render: ({ onChange, ...args }) => ( |
| 143 | + <TextInput onChange={onChange} {...args} /> |
| 144 | + ), |
| 145 | + args: { |
| 146 | + disabled: true, |
| 147 | + value: "Disabled input", |
| 148 | + name: "disabledInput", |
| 149 | + }, |
| 150 | +}; |
| 151 | + |
| 152 | +export const WithUnit: Story = { |
| 153 | + render: ({ onChange, ...args }) => ( |
| 154 | + <TextInput onChange={onChange} {...args} /> |
| 155 | + ), |
| 156 | + args: { |
| 157 | + label: "Price", |
| 158 | + placeholder: "Enter amount", |
| 159 | + contentRight: "€", |
| 160 | + name: "unitInput", |
| 161 | + }, |
| 162 | +}; |
| 163 | + |
| 164 | +export const RichLabel: Story = { |
| 165 | + render: ({ onChange, ...args }) => ( |
| 166 | + <TextInput onChange={onChange} {...args} /> |
| 167 | + ), |
| 168 | + args: { |
| 169 | + label: ( |
| 170 | + <span> |
| 171 | + Place name <em>optional</em> |
| 172 | + </span> |
| 173 | + ), |
| 174 | + name: "richLabelInput", |
| 175 | + }, |
| 176 | +}; |
0 commit comments