@agregio-solutions/design-system 1.90.1 → 1.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/design-system.cjs +9 -5
- package/dist/design-system.js +14 -6
- package/dist/packages/components/Accordion/doc.md +342 -0
- package/dist/packages/components/Badge/doc.md +192 -0
- package/dist/packages/components/Breadcrumbs/doc.md +332 -0
- package/dist/packages/components/Button/doc.md +425 -0
- package/dist/packages/components/Calendar/doc.md +465 -0
- package/dist/packages/components/ChartLegend/doc.md +151 -0
- package/dist/packages/components/ChartTooltip/doc.md +124 -0
- package/dist/packages/components/Checkbox/doc.md +329 -0
- package/dist/packages/components/CheckboxGroup/doc.md +242 -0
- package/dist/packages/components/Chip/doc.md +99 -0
- package/dist/packages/components/Combobox/Combobox.d.ts +8 -0
- package/dist/packages/components/Combobox/doc.md +680 -0
- package/dist/packages/components/DataTable/doc.md +1124 -0
- package/dist/packages/components/DatePicker/doc.md +579 -0
- package/dist/packages/components/DateRangePicker/doc.md +638 -0
- package/dist/packages/components/Drawer/doc.md +338 -0
- package/dist/packages/components/Dropdown/Dropdown.d.ts +4 -0
- package/dist/packages/components/Dropdown/doc.md +205 -0
- package/dist/packages/components/EmptyState/doc.md +101 -0
- package/dist/packages/components/FileUpload/doc.md +449 -0
- package/dist/packages/components/Filter/doc.md +196 -0
- package/dist/packages/components/Header/doc.md +373 -0
- package/dist/packages/components/I18nProvider/doc.md +187 -0
- package/dist/packages/components/Icon/doc.md +63 -0
- package/dist/packages/components/Label/doc.md +60 -0
- package/dist/packages/components/LinearProgressBar/doc.md +148 -0
- package/dist/packages/components/Link/doc.md +206 -0
- package/dist/packages/components/List/doc.md +481 -0
- package/dist/packages/components/Loader/doc.md +53 -0
- package/dist/packages/components/Menu/Menu.d.ts +5 -1
- package/dist/packages/components/Menu/doc.md +231 -0
- package/dist/packages/components/Message/doc.md +166 -0
- package/dist/packages/components/Modal/doc.md +289 -0
- package/dist/packages/components/Navigation/doc.md +992 -0
- package/dist/packages/components/NavigationItem/doc.md +167 -0
- package/dist/packages/components/NotificationCard/doc.md +206 -0
- package/dist/packages/components/Notifications/doc.md +240 -0
- package/dist/packages/components/NumberField/doc.md +582 -0
- package/dist/packages/components/PageLayout/doc.md +651 -0
- package/dist/packages/components/Pagination/doc.md +227 -0
- package/dist/packages/components/Popover/doc.md +245 -0
- package/dist/packages/components/Radio/doc.md +370 -0
- package/dist/packages/components/RouterProvider/doc.md +64 -0
- package/dist/packages/components/SearchBar/doc.md +504 -0
- package/dist/packages/components/SegmentedControl/doc.md +398 -0
- package/dist/packages/components/Select/Select.d.ts +4 -0
- package/dist/packages/components/Select/doc.md +1133 -0
- package/dist/packages/components/Skeleton/doc.md +129 -0
- package/dist/packages/components/Slider/doc.md +362 -0
- package/dist/packages/components/Stepper/doc.md +104 -0
- package/dist/packages/components/Switch/doc.md +296 -0
- package/dist/packages/components/Tabs/doc.md +295 -0
- package/dist/packages/components/Tag/doc.md +81 -0
- package/dist/packages/components/TextInput/doc.md +490 -0
- package/dist/packages/components/TimeField/doc.md +353 -0
- package/dist/packages/components/Timeline/doc.md +1046 -0
- package/dist/packages/components/Toaster/doc.md +263 -0
- package/dist/packages/components/ToggleButton/doc.md +108 -0
- package/dist/packages/components/ToggleButtonGroup/doc.md +307 -0
- package/dist/packages/components/Tooltip/doc.md +206 -0
- package/dist/packages/components/YearMonthPicker/YearMonthPicker.d.ts +8 -0
- package/dist/packages/components/YearMonthPicker/doc.md +638 -0
- package/dist/public_docs/components.md +68 -0
- package/dist/public_docs/index.md +30 -0
- package/dist/public_docs/tokens.md +121 -0
- package/package.json +3 -2
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
# TextInput
|
|
2
|
+
|
|
3
|
+
## Props
|
|
4
|
+
|
|
5
|
+
The complete Props documentation with JS doc for this component is available at this path:
|
|
6
|
+
|
|
7
|
+
node_modules/@agregio-solutions/design-system/dist/packages/components/TextInput/TextInput.d.ts
|
|
8
|
+
|
|
9
|
+
## Example usage
|
|
10
|
+
|
|
11
|
+
Here are the Storybook Stories.
|
|
12
|
+
|
|
13
|
+
Base stories:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
17
|
+
import TextInput from "./TextInput";
|
|
18
|
+
import { ICON_NAMES_ARRAY } from "@components/Icon/Icon";
|
|
19
|
+
import { useState } from "react";
|
|
20
|
+
import { fn } from "storybook/test";
|
|
21
|
+
|
|
22
|
+
const meta: Meta<typeof TextInput> = {
|
|
23
|
+
component: TextInput,
|
|
24
|
+
tags: ["autodocs"],
|
|
25
|
+
argTypes: {
|
|
26
|
+
label: { control: { type: "text" } },
|
|
27
|
+
description: { control: { type: "text" } },
|
|
28
|
+
helperText: { control: { type: "text" } },
|
|
29
|
+
errorHelperText: { control: { type: "text" } },
|
|
30
|
+
successHelperText: { control: { type: "text" } },
|
|
31
|
+
inputIcon: {
|
|
32
|
+
options: ["", ...ICON_NAMES_ARRAY],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
parameters: {
|
|
36
|
+
layout: "centered",
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
export default meta;
|
|
40
|
+
|
|
41
|
+
export const Playground: StoryObj<typeof TextInput> = {
|
|
42
|
+
args: {
|
|
43
|
+
onChange: fn(),
|
|
44
|
+
placeholder: "[Insert text]",
|
|
45
|
+
inputIcon: "help_outline",
|
|
46
|
+
required: true,
|
|
47
|
+
label: "[Insert label]",
|
|
48
|
+
labelIconRight: "help_outline",
|
|
49
|
+
labelIconRightTooltip: "Additional information",
|
|
50
|
+
description: "[Insert description]",
|
|
51
|
+
characterCounter: true,
|
|
52
|
+
maxLength: 60,
|
|
53
|
+
helperText: "[Insert helper]",
|
|
54
|
+
helperTextIcon: "help_outline",
|
|
55
|
+
disabled: false,
|
|
56
|
+
style: { width: 284 },
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const Default: StoryObj<typeof TextInput> = {
|
|
61
|
+
args: {
|
|
62
|
+
...Playground.args,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const Disabled: StoryObj<typeof TextInput> = {
|
|
67
|
+
args: {
|
|
68
|
+
...Playground.args,
|
|
69
|
+
disabled: true,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const Negative: StoryObj<typeof TextInput> = {
|
|
74
|
+
args: {
|
|
75
|
+
...Playground.args,
|
|
76
|
+
helperText: undefined,
|
|
77
|
+
inputIcon: "cancel",
|
|
78
|
+
errorHelperText: "Error message",
|
|
79
|
+
errorHelperTextIcon: "error_outline",
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const Positive: StoryObj<typeof TextInput> = {
|
|
84
|
+
args: {
|
|
85
|
+
...Playground.args,
|
|
86
|
+
helperText: undefined,
|
|
87
|
+
inputIcon: "check_circle_outline",
|
|
88
|
+
successHelperText: "Success message",
|
|
89
|
+
successHelperTextIcon: "check",
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const Warning: StoryObj<typeof TextInput> = {
|
|
94
|
+
args: {
|
|
95
|
+
...Playground.args,
|
|
96
|
+
helperText: undefined,
|
|
97
|
+
inputIcon: "warning_amber",
|
|
98
|
+
warningHelperText: "Warning message",
|
|
99
|
+
warningHelperTextIcon: "warning_amber",
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const ControlledWithCharacterCount: StoryObj<typeof TextInput> = {
|
|
104
|
+
args: {
|
|
105
|
+
...Playground.args,
|
|
106
|
+
},
|
|
107
|
+
render: (args) => {
|
|
108
|
+
const Wrapper = () => {
|
|
109
|
+
const [value, setValue] = useState<string>("");
|
|
110
|
+
return (
|
|
111
|
+
<TextInput
|
|
112
|
+
{...args}
|
|
113
|
+
value={value}
|
|
114
|
+
onChange={(event) => setValue(event.target.value)}
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
return <Wrapper />;
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const WithAddonRight: StoryObj<typeof TextInput> = {
|
|
123
|
+
args: {
|
|
124
|
+
...Playground.args,
|
|
125
|
+
inputIcon: "#",
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const Focus: StoryObj<typeof TextInput> = {
|
|
130
|
+
args: {
|
|
131
|
+
...Playground.args,
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
"data-force-focus": true,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const Horizontal: StoryObj<typeof TextInput> = {
|
|
138
|
+
args: {
|
|
139
|
+
...Playground.args,
|
|
140
|
+
description: undefined,
|
|
141
|
+
orientation: "horizontal",
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export const FullWidth: StoryObj<typeof TextInput> = {
|
|
146
|
+
args: {
|
|
147
|
+
...Playground.args,
|
|
148
|
+
style: undefined,
|
|
149
|
+
fullWidth: true,
|
|
150
|
+
},
|
|
151
|
+
parameters: {
|
|
152
|
+
layout: "padded",
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export const Multiline: StoryObj<typeof TextInput> = {
|
|
157
|
+
args: {
|
|
158
|
+
...Playground.args,
|
|
159
|
+
style: undefined,
|
|
160
|
+
fullWidth: true,
|
|
161
|
+
as: "textarea",
|
|
162
|
+
rows: 4,
|
|
163
|
+
},
|
|
164
|
+
parameters: {
|
|
165
|
+
layout: "padded",
|
|
166
|
+
},
|
|
167
|
+
render: (args) => {
|
|
168
|
+
const Wrapper = () => {
|
|
169
|
+
const [value, setValue] = useState<string>("");
|
|
170
|
+
return (
|
|
171
|
+
<TextInput
|
|
172
|
+
{...(args as any)}
|
|
173
|
+
value={value}
|
|
174
|
+
onChange={(event) => setValue(event.target.value)}
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
177
|
+
};
|
|
178
|
+
return <Wrapper />;
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## How to test this component
|
|
184
|
+
|
|
185
|
+
Here are some more advanced stories with more testing coverage and examples that you can read to understand how to test this component.
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
189
|
+
import { userEvent, within, expect, fn } from "storybook/test";
|
|
190
|
+
import TextInput from "../TextInput";
|
|
191
|
+
import { ICON_NAMES_ARRAY } from "@components/Icon/Icon";
|
|
192
|
+
import { useForm, useWatch } from "react-hook-form";
|
|
193
|
+
import {
|
|
194
|
+
ControlledWithCharacterCount,
|
|
195
|
+
Disabled,
|
|
196
|
+
Playground,
|
|
197
|
+
} from "../TextInput.stories";
|
|
198
|
+
|
|
199
|
+
const meta: Meta<typeof TextInput> = {
|
|
200
|
+
component: TextInput,
|
|
201
|
+
argTypes: {
|
|
202
|
+
label: { control: { type: "text" } },
|
|
203
|
+
description: { control: { type: "text" } },
|
|
204
|
+
helperText: { control: { type: "text" } },
|
|
205
|
+
inputIcon: {
|
|
206
|
+
options: ["", ...ICON_NAMES_ARRAY],
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
parameters: {
|
|
210
|
+
layout: "centered",
|
|
211
|
+
chromatic: { disableSnapshot: true },
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
export default meta;
|
|
215
|
+
|
|
216
|
+
export const ShouldSelectAValue: StoryObj<typeof TextInput> = {
|
|
217
|
+
args: {
|
|
218
|
+
...Playground.args,
|
|
219
|
+
},
|
|
220
|
+
play: async ({ canvasElement, args }) => {
|
|
221
|
+
const canvas = within(canvasElement);
|
|
222
|
+
const user = userEvent.setup({ delay: 50 });
|
|
223
|
+
const input = canvas.getByLabelText("[Insert label]");
|
|
224
|
+
await user.type(input, "New value");
|
|
225
|
+
await expect(input).toHaveValue("New value");
|
|
226
|
+
await expect(args.onChange).toHaveBeenCalled();
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export const NumberType: StoryObj<typeof TextInput> = {
|
|
231
|
+
args: {
|
|
232
|
+
...Playground.args,
|
|
233
|
+
type: "number",
|
|
234
|
+
},
|
|
235
|
+
play: async ({ canvasElement }) => {
|
|
236
|
+
const canvas = within(canvasElement);
|
|
237
|
+
const user = userEvent.setup({ delay: 50 });
|
|
238
|
+
const input = canvas.getByLabelText("[Insert label]");
|
|
239
|
+
await user.type(input, "12");
|
|
240
|
+
await expect(input).toHaveValue(12);
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export const EmailType: StoryObj<typeof TextInput> = {
|
|
245
|
+
args: {
|
|
246
|
+
...Playground.args,
|
|
247
|
+
type: "email",
|
|
248
|
+
},
|
|
249
|
+
play: async ({ canvasElement }) => {
|
|
250
|
+
const canvas = within(canvasElement);
|
|
251
|
+
const user = userEvent.setup({ delay: 50 });
|
|
252
|
+
const input = canvas.getByLabelText("[Insert label]");
|
|
253
|
+
await user.type(input, "contact@example.com");
|
|
254
|
+
await expect(input).toHaveValue("contact@example.com");
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
export const TelType: StoryObj<typeof TextInput> = {
|
|
259
|
+
args: {
|
|
260
|
+
...Playground.args,
|
|
261
|
+
type: "tel",
|
|
262
|
+
},
|
|
263
|
+
play: async ({ canvasElement }) => {
|
|
264
|
+
const canvas = within(canvasElement);
|
|
265
|
+
const user = userEvent.setup({ delay: 50 });
|
|
266
|
+
const input = canvas.getByLabelText("[Insert label]");
|
|
267
|
+
await user.type(input, "0612345678");
|
|
268
|
+
await expect(input).toHaveValue("0612345678");
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
export const UrlType: StoryObj<typeof TextInput> = {
|
|
273
|
+
args: {
|
|
274
|
+
...Playground.args,
|
|
275
|
+
type: "url",
|
|
276
|
+
},
|
|
277
|
+
play: async ({ canvasElement }) => {
|
|
278
|
+
const canvas = within(canvasElement);
|
|
279
|
+
const user = userEvent.setup({ delay: 50 });
|
|
280
|
+
const input = canvas.getByLabelText("[Insert label]");
|
|
281
|
+
await user.type(input, "https://example.com");
|
|
282
|
+
await expect(input).toHaveValue("https://example.com");
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
export const PasswordType: StoryObj<typeof TextInput> = {
|
|
287
|
+
args: {
|
|
288
|
+
...Playground.args,
|
|
289
|
+
type: "password",
|
|
290
|
+
},
|
|
291
|
+
play: async ({ canvasElement }) => {
|
|
292
|
+
const canvas = within(canvasElement);
|
|
293
|
+
const user = userEvent.setup({ delay: 50 });
|
|
294
|
+
const input = canvas.getByLabelText("[Insert label]");
|
|
295
|
+
await user.type(input, "password");
|
|
296
|
+
await expect(input).toHaveValue("password");
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export const DateType: StoryObj<typeof TextInput> = {
|
|
301
|
+
args: {
|
|
302
|
+
...Playground.args,
|
|
303
|
+
type: "date",
|
|
304
|
+
},
|
|
305
|
+
play: async ({ canvasElement }) => {
|
|
306
|
+
const canvas = within(canvasElement);
|
|
307
|
+
const user = userEvent.setup({ delay: 50 });
|
|
308
|
+
const input = canvas.getByLabelText("[Insert label]");
|
|
309
|
+
await user.type(input, "2024-04-03");
|
|
310
|
+
await expect(input).toHaveValue("2024-04-03");
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
export const DatetimeLocalType: StoryObj<typeof TextInput> = {
|
|
315
|
+
args: {
|
|
316
|
+
...Playground.args,
|
|
317
|
+
type: "datetime-local",
|
|
318
|
+
},
|
|
319
|
+
play: async ({ canvasElement }) => {
|
|
320
|
+
const canvas = within(canvasElement);
|
|
321
|
+
const user = userEvent.setup({ delay: 50 });
|
|
322
|
+
const input = canvas.getByLabelText("[Insert label]");
|
|
323
|
+
await user.type(input, "2024-03-15T12:00");
|
|
324
|
+
await expect(input).toHaveValue("2024-03-15T12:00");
|
|
325
|
+
},
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
export const TimeType: StoryObj<typeof TextInput> = {
|
|
329
|
+
args: {
|
|
330
|
+
...Playground.args,
|
|
331
|
+
type: "time",
|
|
332
|
+
},
|
|
333
|
+
play: async ({ canvasElement }) => {
|
|
334
|
+
const canvas = within(canvasElement);
|
|
335
|
+
const user = userEvent.setup({ delay: 50 });
|
|
336
|
+
const input = canvas.getByLabelText("[Insert label]");
|
|
337
|
+
await user.type(input, "20:59");
|
|
338
|
+
await expect(input).toHaveValue("20:59");
|
|
339
|
+
},
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
export const MonthType: StoryObj<typeof TextInput> = {
|
|
343
|
+
args: {
|
|
344
|
+
...Playground.args,
|
|
345
|
+
type: "month",
|
|
346
|
+
},
|
|
347
|
+
play: async ({ canvasElement }) => {
|
|
348
|
+
const canvas = within(canvasElement);
|
|
349
|
+
const user = userEvent.setup({ delay: 50 });
|
|
350
|
+
const input = canvas.getByLabelText("[Insert label]");
|
|
351
|
+
await user.type(input, "2024-06");
|
|
352
|
+
await expect(input).toHaveValue("2024-06");
|
|
353
|
+
},
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
export const WeekType: StoryObj<typeof TextInput> = {
|
|
357
|
+
args: {
|
|
358
|
+
...Playground.args,
|
|
359
|
+
type: "week",
|
|
360
|
+
},
|
|
361
|
+
play: async ({ canvasElement }) => {
|
|
362
|
+
const canvas = within(canvasElement);
|
|
363
|
+
const user = userEvent.setup({ delay: 50 });
|
|
364
|
+
const input = canvas.getByLabelText("[Insert label]");
|
|
365
|
+
await user.type(input, "2024-W07");
|
|
366
|
+
await expect(input).toHaveValue("2024-W07");
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
export const ShouldNotChangeDisabledInput: StoryObj<typeof TextInput> = {
|
|
371
|
+
args: {
|
|
372
|
+
...Disabled.args,
|
|
373
|
+
},
|
|
374
|
+
play: async ({ canvasElement, args }) => {
|
|
375
|
+
const canvas = within(canvasElement);
|
|
376
|
+
const user = userEvent.setup();
|
|
377
|
+
const input = canvas.getByPlaceholderText("[Insert text]");
|
|
378
|
+
await user.type(input, "Trying to type...");
|
|
379
|
+
await expect(input).not.toHaveValue("Trying to type...");
|
|
380
|
+
await expect(args.onChange).not.toHaveBeenCalled();
|
|
381
|
+
},
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
export const ControlledModeWithCharacterCount: StoryObj<typeof TextInput> = {
|
|
385
|
+
...ControlledWithCharacterCount,
|
|
386
|
+
play: async ({ canvasElement }) => {
|
|
387
|
+
const canvas = within(canvasElement);
|
|
388
|
+
const user = userEvent.setup({ delay: 50 });
|
|
389
|
+
const input = canvas.getByLabelText("[Insert label]");
|
|
390
|
+
await user.type(input, "New value");
|
|
391
|
+
await expect(input).toHaveValue("New value");
|
|
392
|
+
await canvas.findByText("9 / 60");
|
|
393
|
+
},
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
export const WithoutLabel: StoryObj<typeof TextInput> = {
|
|
397
|
+
args: {
|
|
398
|
+
"aria-label": "Aria label",
|
|
399
|
+
onChange: fn(),
|
|
400
|
+
},
|
|
401
|
+
play: async ({ canvasElement, args }) => {
|
|
402
|
+
const canvas = within(canvasElement);
|
|
403
|
+
const user = userEvent.setup({ delay: 50 });
|
|
404
|
+
const input = canvas.getByLabelText("Aria label");
|
|
405
|
+
await user.type(input, "New value");
|
|
406
|
+
await expect(input).toHaveValue("New value");
|
|
407
|
+
await expect(args.onChange).toHaveBeenCalled();
|
|
408
|
+
},
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
export const IntegrationWithReactHookForm: StoryObj<typeof TextInput> = {
|
|
412
|
+
args: {
|
|
413
|
+
...Playground.args,
|
|
414
|
+
},
|
|
415
|
+
render: (args) => {
|
|
416
|
+
const Wrapper = () => {
|
|
417
|
+
const { register, handleSubmit, control } = useForm();
|
|
418
|
+
const exampleValue = useWatch({ control, name: "example" });
|
|
419
|
+
|
|
420
|
+
return (
|
|
421
|
+
// eslint-disable-next-line no-console
|
|
422
|
+
<form onSubmit={handleSubmit((data) => console.log(data))}>
|
|
423
|
+
<div>Form value is: "{exampleValue}"</div>
|
|
424
|
+
<TextInput {...args} {...register("example")} />
|
|
425
|
+
</form>
|
|
426
|
+
);
|
|
427
|
+
};
|
|
428
|
+
return <Wrapper />;
|
|
429
|
+
},
|
|
430
|
+
play: async ({ canvasElement }) => {
|
|
431
|
+
const canvas = within(canvasElement);
|
|
432
|
+
const user = userEvent.setup({ delay: 50 });
|
|
433
|
+
const input = canvas.getByLabelText("[Insert label]");
|
|
434
|
+
await user.type(input, "New value");
|
|
435
|
+
await expect(input).toHaveValue("New value");
|
|
436
|
+
await canvas.findByText('Form value is: "New value"');
|
|
437
|
+
},
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
export const OnlyCharacterCounter: StoryObj<typeof TextInput> = {
|
|
441
|
+
args: {
|
|
442
|
+
...Playground.args,
|
|
443
|
+
characterCounter: true,
|
|
444
|
+
value: "New value",
|
|
445
|
+
description: undefined,
|
|
446
|
+
helperText: undefined,
|
|
447
|
+
errorHelperText: undefined,
|
|
448
|
+
successHelperText: undefined,
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
export const CharacterCounterAndDescription: StoryObj<typeof TextInput> = {
|
|
453
|
+
args: {
|
|
454
|
+
...OnlyCharacterCounter.args,
|
|
455
|
+
description: "Description",
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
export const CharacterCounterAndHelperText: StoryObj<typeof TextInput> = {
|
|
460
|
+
args: {
|
|
461
|
+
...OnlyCharacterCounter.args,
|
|
462
|
+
helperText: "Helper text",
|
|
463
|
+
},
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
export const CharacterCounterAndErrorHelperText: StoryObj<typeof TextInput> = {
|
|
467
|
+
args: {
|
|
468
|
+
...OnlyCharacterCounter.args,
|
|
469
|
+
errorHelperText: "Error helper text",
|
|
470
|
+
},
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
export const CharacterCounterAndSuccessHelperText: StoryObj<typeof TextInput> =
|
|
474
|
+
{
|
|
475
|
+
args: {
|
|
476
|
+
...OnlyCharacterCounter.args,
|
|
477
|
+
successHelperText: "Success helper text",
|
|
478
|
+
},
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
export const CharacterCounterAndDescriptionAndHelperText: StoryObj<
|
|
482
|
+
typeof TextInput
|
|
483
|
+
> = {
|
|
484
|
+
args: {
|
|
485
|
+
...OnlyCharacterCounter.args,
|
|
486
|
+
description: "Description",
|
|
487
|
+
helperText: "Helper text",
|
|
488
|
+
},
|
|
489
|
+
};
|
|
490
|
+
```
|