@redis-ui/components 43.0.2 → 43.2.1
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/HighlightedIcon/HighlightedIcon.cjs +26 -0
- package/dist/HighlightedIcon/HighlightedIcon.d.ts +3 -0
- package/dist/HighlightedIcon/HighlightedIcon.js +26 -0
- package/dist/HighlightedIcon/HighlightedIcon.style.cjs +49 -0
- package/dist/HighlightedIcon/HighlightedIcon.style.d.ts +5 -0
- package/dist/HighlightedIcon/HighlightedIcon.style.js +47 -0
- package/dist/HighlightedIcon/HighlightedIcon.types.d.ts +8 -0
- package/dist/HighlightedIcon/index.d.ts +3 -0
- package/dist/Stepper/Stepper.cjs +14 -5
- package/dist/Stepper/Stepper.d.ts +2 -0
- package/dist/Stepper/Stepper.js +14 -5
- package/dist/Stepper/Stepper.utils.cjs +12 -0
- package/dist/Stepper/Stepper.utils.d.ts +2 -0
- package/dist/Stepper/Stepper.utils.js +12 -0
- package/dist/Stepper/components/Compose/Compose.d.ts +1 -0
- package/dist/Stepper/components/Step/Step.cjs +2 -0
- package/dist/Stepper/components/Step/Step.d.ts +1 -0
- package/dist/Stepper/components/Step/Step.js +2 -0
- package/dist/Stepper/components/Step/components/Compose/Compose.cjs +2 -9
- package/dist/Stepper/components/Step/components/Compose/Compose.js +2 -9
- package/dist/Stepper/components/Step/components/Separator/Separator.cjs +15 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.d.ts +3 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.js +15 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.style.cjs +24 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.style.d.ts +1 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.style.js +22 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.types.d.ts +5 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +74 -70
- package/package.json +2 -2
- package/skills/redis-ui-components/SKILL.md +0 -2
- package/skills/redis-ui-components/references/ActionIconButton.md +96 -0
- package/skills/redis-ui-components/references/AppBar.md +161 -0
- package/skills/redis-ui-components/references/AppSelectionMenu.md +184 -0
- package/skills/redis-ui-components/references/AutoCompleteSelect.md +193 -0
- package/skills/redis-ui-components/references/Badge.md +77 -0
- package/skills/redis-ui-components/references/Banner.md +563 -0
- package/skills/redis-ui-components/references/BoxSelectionGroup.md +487 -0
- package/skills/redis-ui-components/references/Breadcrumbs.md +214 -0
- package/skills/redis-ui-components/references/ButtonGroup.md +126 -0
- package/skills/redis-ui-components/references/Card.md +56 -0
- package/skills/redis-ui-components/references/Checkbox.md +171 -0
- package/skills/redis-ui-components/references/Chip.md +154 -0
- package/skills/redis-ui-components/references/ChipList.md +307 -0
- package/skills/redis-ui-components/references/CopyToClipboardButton.md +47 -0
- package/skills/redis-ui-components/references/CountryFlag.md +57 -0
- package/skills/redis-ui-components/references/Drawer.md +298 -0
- package/skills/redis-ui-components/references/Filters.md +162 -0
- package/skills/redis-ui-components/references/FormField.md +678 -0
- package/skills/redis-ui-components/references/IconButton.md +63 -0
- package/skills/redis-ui-components/references/Input.md +295 -0
- package/skills/redis-ui-components/references/KeyValueList.md +501 -0
- package/skills/redis-ui-components/references/Label.md +238 -0
- package/skills/redis-ui-components/references/Link.md +402 -0
- package/skills/redis-ui-components/references/Loader.md +100 -0
- package/skills/redis-ui-components/references/Menu.md +988 -0
- package/skills/redis-ui-components/references/MidBar.md +358 -0
- package/skills/redis-ui-components/references/Modal.md +525 -0
- package/skills/redis-ui-components/references/MoreInfoIcon.md +119 -0
- package/skills/redis-ui-components/references/MultiSelect.md +558 -0
- package/skills/redis-ui-components/references/NumericInput.md +322 -0
- package/skills/redis-ui-components/references/Overflow.md +127 -0
- package/skills/redis-ui-components/references/Pagination.md +151 -0
- package/skills/redis-ui-components/references/PasswordInput.md +262 -0
- package/skills/redis-ui-components/references/Popover.md +868 -0
- package/skills/redis-ui-components/references/ProfileIcon.md +65 -0
- package/skills/redis-ui-components/references/ProgressBar.md +103 -0
- package/skills/redis-ui-components/references/QuantityCounter.md +555 -0
- package/skills/redis-ui-components/references/RadioGroup.md +265 -0
- package/skills/redis-ui-components/references/ScreenReaderAnnounce.md +147 -0
- package/skills/redis-ui-components/references/SearchBar.md +242 -0
- package/skills/redis-ui-components/references/SearchInput.md +213 -0
- package/skills/redis-ui-components/references/Section.md +349 -0
- package/skills/redis-ui-components/references/SideBar.md +468 -0
- package/skills/redis-ui-components/references/Slider.md +398 -0
- package/skills/redis-ui-components/references/Stepper.md +288 -0
- package/skills/redis-ui-components/references/Switch.md +193 -0
- package/skills/redis-ui-components/references/Tabs.md +383 -0
- package/skills/redis-ui-components/references/TextArea.md +139 -0
- package/skills/redis-ui-components/references/TextButton.md +217 -0
- package/skills/redis-ui-components/references/Toast.md +399 -0
- package/skills/redis-ui-components/references/ToggleButton.md +163 -0
- package/skills/redis-ui-components/references/Tooltip.md +636 -0
- package/skills/redis-ui-components/references/Typography.md +323 -0
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
# FormField
|
|
2
|
+
|
|
3
|
+
A field wrapper for labels, helper text, and shared id/state propagation around inputs and other controls.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { FormField } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
|------|------|---------|-------------|
|
|
15
|
+
| children | `ReactNode` | - | Field content rendered inside `FormField.InputContainer` |
|
|
16
|
+
| label | `ReactNode` | - | Label content rendered above the field |
|
|
17
|
+
| infoIconProps | `InfoIconProps` | - | Props forwarded to the label info icon tooltip |
|
|
18
|
+
| required | `boolean` | - | Shows the required marker on the label |
|
|
19
|
+
| optional | `boolean` | - | Shows the optional marker on the label |
|
|
20
|
+
| additionalText | `ReactNode` | - | Helper text rendered below the field |
|
|
21
|
+
| additionalTextDescribesField | `boolean` | `false` | When true, links helper text into the field's aria description when possible |
|
|
22
|
+
| id | `string` | auto-generated | Shared id used by the label and field; set `""` to disable sharing |
|
|
23
|
+
| layout | `'vertical' \| 'horizontal'` | `'vertical'` | Field layout used by the compose wrapper |
|
|
24
|
+
| compose wrapper props | `ComposeElementProps<HTMLElement>` | - | Standard wrapper props applied to the root compose element |
|
|
25
|
+
|
|
26
|
+
The component also accepts standard wrapper props via `ComposeElementProps<HTMLElement>` on the outer compose element.
|
|
27
|
+
|
|
28
|
+
## Sub-components
|
|
29
|
+
|
|
30
|
+
- `FormField.Compose` - Low-level field composition wrapper that provides shared id and state providers.
|
|
31
|
+
- `FormField.Label` - Shared label component for field labels and info tooltips.
|
|
32
|
+
- `FormField.InputContainer` - Layout container for the input or composed control.
|
|
33
|
+
- `FormField.AdditionalText` - Helper text block rendered below the field.
|
|
34
|
+
- `FormField.Nested` - State boundary for nested controls that should not always inherit the parent field state.
|
|
35
|
+
- `FormField.VerticalGroup` - Layout wrapper for aligning multiple fields, including mixed horizontal and vertical layouts.
|
|
36
|
+
|
|
37
|
+
### FormField.Compose Props
|
|
38
|
+
|
|
39
|
+
| Prop | Type | Default | Description |
|
|
40
|
+
|------|------|---------|-------------|
|
|
41
|
+
| children | `ReactNode` | - | Compose content rendered inside the field wrapper |
|
|
42
|
+
| id | `string` | auto-generated | Shared id used by the field and nested controls |
|
|
43
|
+
| layout | `'vertical' \| 'horizontal'` | `'vertical'` | Controls whether the field is rendered in a vertical or horizontal layout |
|
|
44
|
+
| compose wrapper props | `ComposeElementProps<HTMLElement>` | - | Standard wrapper props applied to the compose root |
|
|
45
|
+
|
|
46
|
+
### FormField.AdditionalText Props
|
|
47
|
+
|
|
48
|
+
| Prop | Type | Default | Description |
|
|
49
|
+
|------|------|---------|-------------|
|
|
50
|
+
| children | `ReactNode` | - | Helper text content |
|
|
51
|
+
| size | `TypographyBodySize` | `'S'` | Typography body size used for the helper text |
|
|
52
|
+
| forceStatus | `FieldStatus` | - | Overrides the inherited field status when styling the helper text |
|
|
53
|
+
| describeField | `boolean` | `false` | Adds the helper text to the field's aria description when possible |
|
|
54
|
+
| typography body props | `TypographyBodyProps` | - | Standard body typography props forwarded to the helper text |
|
|
55
|
+
|
|
56
|
+
### FormField.Label Props
|
|
57
|
+
|
|
58
|
+
| Prop | Type | Default | Description |
|
|
59
|
+
|------|------|---------|-------------|
|
|
60
|
+
| label | `ReactNode` | - | Label content rendered above the field |
|
|
61
|
+
| infoIconProps | `InfoIconProps` | - | Props forwarded to the info icon tooltip |
|
|
62
|
+
| required | `boolean` | - | Shows the required marker |
|
|
63
|
+
| optional | `boolean` | - | Shows the optional marker |
|
|
64
|
+
| readOnly | `boolean` | - | Renders the label in read-only styling |
|
|
65
|
+
| label props | `LabelHTMLAttributes<HTMLLabelElement>` | - | Additional native label attributes |
|
|
66
|
+
|
|
67
|
+
### FormField.Nested Props
|
|
68
|
+
|
|
69
|
+
| Prop | Type | Default | Description |
|
|
70
|
+
|------|------|---------|-------------|
|
|
71
|
+
| children | `ReactNode` | - | Nested content rendered inside the isolated field boundary |
|
|
72
|
+
| id | `string` | - | Optional shared id for the nested boundary |
|
|
73
|
+
| disabledState | `'pass' \| 'cut' \| 'smart'` | `'smart'` | Controls how disabled state is shared between the parent field and nested controls |
|
|
74
|
+
|
|
75
|
+
## Examples
|
|
76
|
+
|
|
77
|
+
### Playground
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { FormField, Input } from '@redislabsdev/redis-ui-components';
|
|
81
|
+
|
|
82
|
+
<FormField label="FormField Label" additionalText="additional text">
|
|
83
|
+
<Input />
|
|
84
|
+
</FormField>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### PartsAndProps
|
|
88
|
+
|
|
89
|
+
> FormField can have label and additional text.
|
|
90
|
+
> Label in turn can have `label` text, `required` marker, `optional` marker text and info icon with tooltip.
|
|
91
|
+
> All parts are optional.
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import { FormField, Input } from '@redislabsdev/redis-ui-components';
|
|
95
|
+
|
|
96
|
+
<>
|
|
97
|
+
<FormField
|
|
98
|
+
label="Label"
|
|
99
|
+
required
|
|
100
|
+
optional
|
|
101
|
+
infoIconProps={{ content: 'Info tooltip' }}
|
|
102
|
+
additionalText="additional text"
|
|
103
|
+
>
|
|
104
|
+
<Input />
|
|
105
|
+
</FormField>
|
|
106
|
+
<FormField>
|
|
107
|
+
<Input />
|
|
108
|
+
</FormField>
|
|
109
|
+
</>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### HorizontalLayout
|
|
113
|
+
|
|
114
|
+
> Normally, horizontal layout is not aligned among fields.
|
|
115
|
+
>
|
|
116
|
+
> To align them, please wrap multiple FormFields with `FormField.VerticalGroup`
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import { FormField, Input } from '@redislabsdev/redis-ui-components';
|
|
120
|
+
|
|
121
|
+
<>
|
|
122
|
+
<FormField label="Short label" additionalText="additional text" layout="horizontal">
|
|
123
|
+
<Input />
|
|
124
|
+
</FormField>
|
|
125
|
+
<FormField
|
|
126
|
+
label="Looooooooooooooooong label"
|
|
127
|
+
additionalText="additional text"
|
|
128
|
+
layout="horizontal"
|
|
129
|
+
>
|
|
130
|
+
<Input />
|
|
131
|
+
</FormField>
|
|
132
|
+
<FormField.VerticalGroup>
|
|
133
|
+
<FormField label="Short label" additionalText="additional text" layout="horizontal">
|
|
134
|
+
<Input />
|
|
135
|
+
</FormField>
|
|
136
|
+
<FormField
|
|
137
|
+
label="Looooooooooooooooong label"
|
|
138
|
+
additionalText="additional text"
|
|
139
|
+
layout="horizontal"
|
|
140
|
+
>
|
|
141
|
+
<Input />
|
|
142
|
+
</FormField>
|
|
143
|
+
</FormField.VerticalGroup>
|
|
144
|
+
</>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### VerticalLayout
|
|
148
|
+
|
|
149
|
+
> FormField vertical layout looks the same inside `FormField.VerticalGroup`,
|
|
150
|
+
> if no horizontal layout FormField exists in the same group
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
import { FormField, Input } from '@redislabsdev/redis-ui-components';
|
|
154
|
+
|
|
155
|
+
<>
|
|
156
|
+
<FormField label="Short label" additionalText="additional text">
|
|
157
|
+
<Input />
|
|
158
|
+
</FormField>
|
|
159
|
+
<FormField
|
|
160
|
+
label="Looooooooooooooooong label"
|
|
161
|
+
additionalText="additional text"
|
|
162
|
+
>
|
|
163
|
+
<Input />
|
|
164
|
+
</FormField>
|
|
165
|
+
<FormField.VerticalGroup>
|
|
166
|
+
<FormField label="Short label" additionalText="additional text">
|
|
167
|
+
<Input />
|
|
168
|
+
</FormField>
|
|
169
|
+
<FormField
|
|
170
|
+
label="Looooooooooooooooong label"
|
|
171
|
+
additionalText="additional text"
|
|
172
|
+
>
|
|
173
|
+
<Input />
|
|
174
|
+
</FormField>
|
|
175
|
+
</FormField.VerticalGroup>
|
|
176
|
+
</>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### VerticalGroupWithMixedLayout
|
|
180
|
+
|
|
181
|
+
> If `FormField.VerticalGroup` contains FormFields with mixed horizontal and vertical layouts,
|
|
182
|
+
> it will align all inputs, including read-only ones
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
import { FormField, Input } from '@redislabsdev/redis-ui-components';
|
|
186
|
+
|
|
187
|
+
<FormField.VerticalGroup>
|
|
188
|
+
<FormField label="Vertical layout FormField">
|
|
189
|
+
<Input />
|
|
190
|
+
</FormField>
|
|
191
|
+
<FormField additionalText="no label field">
|
|
192
|
+
<Input />
|
|
193
|
+
</FormField>
|
|
194
|
+
<FormField layout="horizontal" label="Horizontal layout">
|
|
195
|
+
<Input />
|
|
196
|
+
</FormField>
|
|
197
|
+
<FormField
|
|
198
|
+
layout="horizontal"
|
|
199
|
+
label="Horizontal layout with readOnly input"
|
|
200
|
+
additionalText="additional text"
|
|
201
|
+
>
|
|
202
|
+
<Input defaultValue="read-only text" readOnly />
|
|
203
|
+
</FormField>
|
|
204
|
+
</FormField.VerticalGroup>
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Status
|
|
208
|
+
|
|
209
|
+
> FormField can inherit status of the underling input.
|
|
210
|
+
>
|
|
211
|
+
> Error status changes color of the additional text to red.
|
|
212
|
+
> Valid status doesn't change look of the FormField parts.
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import { FormField, Input } from '@redislabsdev/redis-ui-components';
|
|
216
|
+
|
|
217
|
+
<>
|
|
218
|
+
<FormField label="Valid status" additionalText="additional text">
|
|
219
|
+
<Input valid />
|
|
220
|
+
</FormField>
|
|
221
|
+
<FormField
|
|
222
|
+
label="Error status"
|
|
223
|
+
additionalText="additional text - should have error color"
|
|
224
|
+
>
|
|
225
|
+
<Input error="Error message" />
|
|
226
|
+
</FormField>
|
|
227
|
+
</>
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### DisabledAndReadonly
|
|
231
|
+
|
|
232
|
+
> FormField can inherit disabled and readOnly states of the descending input.
|
|
233
|
+
>
|
|
234
|
+
> Read-only state changes color of the FormField label.
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
import { FormField, Input } from '@redislabsdev/redis-ui-components';
|
|
238
|
+
|
|
239
|
+
<>
|
|
240
|
+
<FormField label="Disabled input" additionalText="additional text">
|
|
241
|
+
<Input disabled value="text" />
|
|
242
|
+
</FormField>
|
|
243
|
+
<FormField label="Read-only input" additionalText="additional text">
|
|
244
|
+
<Input value="read-only input value" readOnly />
|
|
245
|
+
</FormField>
|
|
246
|
+
</>
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### SharedId
|
|
250
|
+
|
|
251
|
+
> FormField and Inputs, Select and few other components use SharedId engine.
|
|
252
|
+
> It allows share custom id, defined on a FormField or underling input.
|
|
253
|
+
>
|
|
254
|
+
> If no id defined, SharedId engine generates id and shares it between FormField and underling input.
|
|
255
|
+
>
|
|
256
|
+
> If id should not be shared, the FormField's `id` property should be set to an empty string.
|
|
257
|
+
> In this case, the label and the input will not be connected by the html "for-id" relationship
|
|
258
|
+
|
|
259
|
+
```tsx
|
|
260
|
+
import { FormField, Input } from '@redislabsdev/redis-ui-components';
|
|
261
|
+
|
|
262
|
+
<>
|
|
263
|
+
<FormField label="FormField with custom id" additionalText="id defined on input">
|
|
264
|
+
<Input id="input-custom-id" />
|
|
265
|
+
</FormField>
|
|
266
|
+
<FormField
|
|
267
|
+
label="FormField with custom id"
|
|
268
|
+
additionalText="id defined on FormField"
|
|
269
|
+
id="form-field-custom-id"
|
|
270
|
+
>
|
|
271
|
+
<Input />
|
|
272
|
+
</FormField>
|
|
273
|
+
<FormField
|
|
274
|
+
label="FormField with auto-generated id"
|
|
275
|
+
additionalText="id is not defined - silently generated"
|
|
276
|
+
>
|
|
277
|
+
<Input />
|
|
278
|
+
</FormField>
|
|
279
|
+
<FormField
|
|
280
|
+
label="FormField without shared id"
|
|
281
|
+
additionalText="id is not defined and not generated"
|
|
282
|
+
id=""
|
|
283
|
+
>
|
|
284
|
+
<Input />
|
|
285
|
+
</FormField>
|
|
286
|
+
</>
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### NestedComponents
|
|
290
|
+
|
|
291
|
+
> Some states and id are shared between FormField and underling input.
|
|
292
|
+
>
|
|
293
|
+
> If an additional component that can share states/id is nested in the main Input or FormField,
|
|
294
|
+
> then the states/id will be shared across all players.
|
|
295
|
+
>
|
|
296
|
+
> To prevent this, wrap the nested component in `FormField.Nested`
|
|
297
|
+
> and it will have independent states/id shared under the `FormField.Nested` wrapper
|
|
298
|
+
>
|
|
299
|
+
> > Note: The `disabled` state is shared smartly with the nested component.
|
|
300
|
+
> > It is propagated to the nested component from the container only if container is disabled.
|
|
301
|
+
> >
|
|
302
|
+
> > This behavior can be changed by setting `disabledState` to:
|
|
303
|
+
> > - `cut` - prevent sharing state, use nested component own state
|
|
304
|
+
> > - `pass` - propagate state in both directions (container will be disabled, if nested is disabled)
|
|
305
|
+
> >
|
|
306
|
+
> > You can prevent sharing disabled state also by wrapping the nested component in `FieldDisabledProvider`
|
|
307
|
+
|
|
308
|
+
```tsx
|
|
309
|
+
import {
|
|
310
|
+
FieldDisabledProvider,
|
|
311
|
+
FormField,
|
|
312
|
+
Input,
|
|
313
|
+
QuantityCounter,
|
|
314
|
+
Select
|
|
315
|
+
} from '@redislabsdev/redis-ui-components';
|
|
316
|
+
|
|
317
|
+
const options = [{ value: 'MB' }, { value: 'GB' }, { value: 'TB' }];
|
|
318
|
+
|
|
319
|
+
<>
|
|
320
|
+
<FormField
|
|
321
|
+
label='Nested component is wrapped in "FormField.Nested"'
|
|
322
|
+
additionalText='The nested Input has its own "error" status'
|
|
323
|
+
>
|
|
324
|
+
<QuantityCounter.Compose defaultValue={123}>
|
|
325
|
+
<QuantityCounter.InputGroup.Compose>
|
|
326
|
+
<QuantityCounter.InputGroup.Tag />
|
|
327
|
+
<QuantityCounter.InputGroup.ValueLabel>
|
|
328
|
+
<FormField.Nested>
|
|
329
|
+
<Input
|
|
330
|
+
defaultValue="TB"
|
|
331
|
+
autoSize
|
|
332
|
+
style={{
|
|
333
|
+
width: 'fit-content',
|
|
334
|
+
height: 'fit-content',
|
|
335
|
+
border: 'none',
|
|
336
|
+
padding: 0
|
|
337
|
+
}}
|
|
338
|
+
error="error"
|
|
339
|
+
/>
|
|
340
|
+
</FormField.Nested>
|
|
341
|
+
</QuantityCounter.InputGroup.ValueLabel>
|
|
342
|
+
</QuantityCounter.InputGroup.Compose>
|
|
343
|
+
</QuantityCounter.Compose>
|
|
344
|
+
</FormField>
|
|
345
|
+
|
|
346
|
+
<FormField
|
|
347
|
+
label='Nested component is not wrapped in "FormField.Nested"'
|
|
348
|
+
additionalText='The nested Input has an "error" status that propagates to the main Input and FormField'
|
|
349
|
+
>
|
|
350
|
+
<QuantityCounter.Compose defaultValue={123}>
|
|
351
|
+
<QuantityCounter.InputGroup.Compose>
|
|
352
|
+
<QuantityCounter.InputGroup.Tag />
|
|
353
|
+
<QuantityCounter.InputGroup.ValueLabel>
|
|
354
|
+
<Input
|
|
355
|
+
defaultValue="TB"
|
|
356
|
+
autoSize
|
|
357
|
+
style={{
|
|
358
|
+
width: 'fit-content',
|
|
359
|
+
height: 'fit-content',
|
|
360
|
+
border: 'none',
|
|
361
|
+
padding: 0
|
|
362
|
+
}}
|
|
363
|
+
error="error"
|
|
364
|
+
/>
|
|
365
|
+
</QuantityCounter.InputGroup.ValueLabel>
|
|
366
|
+
</QuantityCounter.InputGroup.Compose>
|
|
367
|
+
</QuantityCounter.Compose>
|
|
368
|
+
</FormField>
|
|
369
|
+
|
|
370
|
+
<FormField
|
|
371
|
+
label='Nested component is wrapped in "FormField.Nested"'
|
|
372
|
+
additionalText='The "disabled" state is smartly passed to descendants. Disabling container disables nested components.'
|
|
373
|
+
>
|
|
374
|
+
<QuantityCounter.Compose defaultValue={123}>
|
|
375
|
+
<QuantityCounter.InputGroup.Compose>
|
|
376
|
+
<QuantityCounter.InputGroup.Tag disabled />
|
|
377
|
+
<QuantityCounter.InputGroup.ValueLabel>
|
|
378
|
+
<FormField.Nested>
|
|
379
|
+
<Select
|
|
380
|
+
options={options}
|
|
381
|
+
style={{
|
|
382
|
+
width: 'fit-content',
|
|
383
|
+
height: 'fit-content',
|
|
384
|
+
border: 'none',
|
|
385
|
+
padding: 0
|
|
386
|
+
}}
|
|
387
|
+
defaultValue="MB"
|
|
388
|
+
/>
|
|
389
|
+
</FormField.Nested>
|
|
390
|
+
</QuantityCounter.InputGroup.ValueLabel>
|
|
391
|
+
</QuantityCounter.InputGroup.Compose>
|
|
392
|
+
</QuantityCounter.Compose>
|
|
393
|
+
</FormField>
|
|
394
|
+
|
|
395
|
+
<FormField
|
|
396
|
+
label='Nested component is wrapped in "FormField.Nested"'
|
|
397
|
+
additionalText='The "disabled" state is smartly passed to descendants. Disabling nested does not affect the container'
|
|
398
|
+
>
|
|
399
|
+
<QuantityCounter.Compose defaultValue={123}>
|
|
400
|
+
<QuantityCounter.InputGroup.Compose>
|
|
401
|
+
<QuantityCounter.InputGroup.Tag />
|
|
402
|
+
<QuantityCounter.InputGroup.ValueLabel>
|
|
403
|
+
<FormField.Nested>
|
|
404
|
+
<Select
|
|
405
|
+
options={options}
|
|
406
|
+
style={{
|
|
407
|
+
width: 'fit-content',
|
|
408
|
+
height: 'fit-content',
|
|
409
|
+
border: 'none',
|
|
410
|
+
padding: 0
|
|
411
|
+
}}
|
|
412
|
+
defaultValue="MB"
|
|
413
|
+
disabled
|
|
414
|
+
/>
|
|
415
|
+
</FormField.Nested>
|
|
416
|
+
</QuantityCounter.InputGroup.ValueLabel>
|
|
417
|
+
</QuantityCounter.InputGroup.Compose>
|
|
418
|
+
</QuantityCounter.Compose>
|
|
419
|
+
</FormField>
|
|
420
|
+
|
|
421
|
+
<FormField
|
|
422
|
+
label='Nested component is wrapped in "FieldDisabledProvider"'
|
|
423
|
+
additionalText='The nested component has its own "disabled" state'
|
|
424
|
+
>
|
|
425
|
+
<QuantityCounter.Compose defaultValue={123}>
|
|
426
|
+
<QuantityCounter.InputGroup.Compose>
|
|
427
|
+
<QuantityCounter.InputGroup.Tag />
|
|
428
|
+
<QuantityCounter.InputGroup.ValueLabel>
|
|
429
|
+
<FieldDisabledProvider>
|
|
430
|
+
<Select
|
|
431
|
+
options={options}
|
|
432
|
+
style={{
|
|
433
|
+
width: 'fit-content',
|
|
434
|
+
height: 'fit-content',
|
|
435
|
+
border: 'none',
|
|
436
|
+
padding: 0
|
|
437
|
+
}}
|
|
438
|
+
defaultValue="MB"
|
|
439
|
+
disabled
|
|
440
|
+
/>
|
|
441
|
+
</FieldDisabledProvider>
|
|
442
|
+
</QuantityCounter.InputGroup.ValueLabel>
|
|
443
|
+
</QuantityCounter.InputGroup.Compose>
|
|
444
|
+
</QuantityCounter.Compose>
|
|
445
|
+
</FormField>
|
|
446
|
+
</>
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### ComposeWithLink
|
|
450
|
+
|
|
451
|
+
```tsx
|
|
452
|
+
import { FormField, Input, Link } from '@redislabsdev/redis-ui-components';
|
|
453
|
+
|
|
454
|
+
<FormField.Compose>
|
|
455
|
+
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
456
|
+
<FormField.Label label="Label" />
|
|
457
|
+
<Link external variant="inline" onClick={() => false} />
|
|
458
|
+
</div>
|
|
459
|
+
<FormField.InputContainer>
|
|
460
|
+
<Input />
|
|
461
|
+
</FormField.InputContainer>
|
|
462
|
+
<FormField.AdditionalText>additional text</FormField.AdditionalText>
|
|
463
|
+
</FormField.Compose>;
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### withSelect
|
|
467
|
+
|
|
468
|
+
```tsx
|
|
469
|
+
import { FormField, Select } from '@redislabsdev/redis-ui-components';
|
|
470
|
+
|
|
471
|
+
const options = [
|
|
472
|
+
{ value: 'apple', label: 'Apple' },
|
|
473
|
+
{ value: 'orange', label: 'Orange' },
|
|
474
|
+
{ value: 'grape', label: 'Grape' },
|
|
475
|
+
{ value: 'pear', label: 'Pear' }
|
|
476
|
+
];
|
|
477
|
+
|
|
478
|
+
<FormField.VerticalGroup style={{ rowGap: '2rem' }}>
|
|
479
|
+
<FormField
|
|
480
|
+
label="FormField Label"
|
|
481
|
+
additionalText="horizontal layout with select"
|
|
482
|
+
layout="horizontal"
|
|
483
|
+
>
|
|
484
|
+
<Select options={options} onChange={() => undefined} onOpenChange={() => undefined} />
|
|
485
|
+
</FormField>
|
|
486
|
+
<FormField label="FormField Label" additionalText="vertical layout with Select">
|
|
487
|
+
<Select options={options} onChange={() => undefined} onOpenChange={() => undefined} />
|
|
488
|
+
</FormField>
|
|
489
|
+
<FormField label="FormField Label" additionalText="disabled Select">
|
|
490
|
+
<Select options={options} disabled onChange={() => undefined} onOpenChange={() => undefined} />
|
|
491
|
+
</FormField>
|
|
492
|
+
<FormField label="FormField Label" additionalText="error state of Select">
|
|
493
|
+
<Select options={options} error="error" onChange={() => undefined} onOpenChange={() => undefined} />
|
|
494
|
+
</FormField>
|
|
495
|
+
<FormField label="FormField Label" additionalText="custom id of Select">
|
|
496
|
+
<Select options={options} id="custom-id" onChange={() => undefined} onOpenChange={() => undefined} />
|
|
497
|
+
</FormField>
|
|
498
|
+
</FormField.VerticalGroup>
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
### withMultiSelect
|
|
502
|
+
|
|
503
|
+
```tsx
|
|
504
|
+
import { FormField, MultiSelect } from '@redislabsdev/redis-ui-components';
|
|
505
|
+
|
|
506
|
+
const options = [
|
|
507
|
+
{ value: 'apple', label: 'Apple' },
|
|
508
|
+
{ value: 'orange', label: 'Orange' },
|
|
509
|
+
{ value: 'grape', label: 'Grape' },
|
|
510
|
+
{ value: 'pear', label: 'Pear' }
|
|
511
|
+
];
|
|
512
|
+
|
|
513
|
+
<FormField.VerticalGroup>
|
|
514
|
+
<FormField
|
|
515
|
+
label="FormField Label"
|
|
516
|
+
additionalText="horizontal layout with multiSelect"
|
|
517
|
+
layout="horizontal"
|
|
518
|
+
>
|
|
519
|
+
<MultiSelect
|
|
520
|
+
options={options}
|
|
521
|
+
defaultValue={['apple', 'orange']}
|
|
522
|
+
onChange={() => undefined}
|
|
523
|
+
onOpenChange={() => undefined}
|
|
524
|
+
/>
|
|
525
|
+
</FormField>
|
|
526
|
+
<FormField label="FormField Label" additionalText="vertical layout with MultiSelect">
|
|
527
|
+
<MultiSelect options={options} onChange={() => undefined} onOpenChange={() => undefined} />
|
|
528
|
+
</FormField>
|
|
529
|
+
<FormField label="FormField Label" additionalText="disabled MultiSelect">
|
|
530
|
+
<MultiSelect options={options} disabled onChange={() => undefined} onOpenChange={() => undefined} />
|
|
531
|
+
</FormField>
|
|
532
|
+
<FormField label="FormField Label" additionalText="error state of MultiSelect">
|
|
533
|
+
<MultiSelect options={options} error="error" onChange={() => undefined} onOpenChange={() => undefined} />
|
|
534
|
+
</FormField>
|
|
535
|
+
<FormField label="FormField Label" additionalText="custom id of MultiSelect">
|
|
536
|
+
<MultiSelect options={options} id="custom-id" onChange={() => undefined} onOpenChange={() => undefined} />
|
|
537
|
+
</FormField>
|
|
538
|
+
</FormField.VerticalGroup>
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
### withRadioGroupHorizontal
|
|
542
|
+
|
|
543
|
+
> RadioGroup `horizontal` layout
|
|
544
|
+
|
|
545
|
+
```tsx
|
|
546
|
+
import { FormField, RadioGroup } from '@redislabsdev/redis-ui-components';
|
|
547
|
+
|
|
548
|
+
const StoryRadioGroup = (props) => (
|
|
549
|
+
<RadioGroup.Compose defaultValue="1" layout="horizontal" {...props}>
|
|
550
|
+
<RadioGroup.Item value="1" label="Item 1" />
|
|
551
|
+
<RadioGroup.Item value="2" label="Item 2" />
|
|
552
|
+
</RadioGroup.Compose>
|
|
553
|
+
);
|
|
554
|
+
|
|
555
|
+
<FormField.VerticalGroup style={{ rowGap: '2rem' }}>
|
|
556
|
+
<FormField label="FormField Label" additionalText="horizontal FormField" layout="horizontal">
|
|
557
|
+
<StoryRadioGroup />
|
|
558
|
+
</FormField>
|
|
559
|
+
<FormField label="FormField Label" additionalText="vertical FormField">
|
|
560
|
+
<StoryRadioGroup />
|
|
561
|
+
</FormField>
|
|
562
|
+
<FormField label="FormField Label" additionalText="disabled RadioGroup">
|
|
563
|
+
<StoryRadioGroup disabled />
|
|
564
|
+
</FormField>
|
|
565
|
+
<FormField label="FormField Label" additionalText="readOnly state of RadioGroup">
|
|
566
|
+
<StoryRadioGroup readOnly />
|
|
567
|
+
</FormField>
|
|
568
|
+
<FormField label="FormField Label" additionalText="custom id of RadioGroup">
|
|
569
|
+
<StoryRadioGroup id="custom-id" />
|
|
570
|
+
</FormField>
|
|
571
|
+
</FormField.VerticalGroup>
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
### withRadioGroupVertical
|
|
575
|
+
|
|
576
|
+
> RadioGroup `vertical` layout
|
|
577
|
+
|
|
578
|
+
```tsx
|
|
579
|
+
import { FormField, RadioGroup } from '@redislabsdev/redis-ui-components';
|
|
580
|
+
|
|
581
|
+
const StoryRadioGroup = (props) => (
|
|
582
|
+
<RadioGroup.Compose defaultValue="1" layout="horizontal" {...props}>
|
|
583
|
+
<RadioGroup.Item value="1" label="Item 1" />
|
|
584
|
+
<RadioGroup.Item value="2" label="Item 2" />
|
|
585
|
+
</RadioGroup.Compose>
|
|
586
|
+
);
|
|
587
|
+
|
|
588
|
+
<FormField.VerticalGroup style={{ rowGap: '2rem' }}>
|
|
589
|
+
<FormField label="FormField Label" additionalText="horizontal FormField" layout="horizontal">
|
|
590
|
+
<StoryRadioGroup layout="vertical" />
|
|
591
|
+
</FormField>
|
|
592
|
+
<FormField label="FormField Label" additionalText="vertical FormField" layout="vertical">
|
|
593
|
+
<StoryRadioGroup layout="vertical" />
|
|
594
|
+
</FormField>
|
|
595
|
+
</FormField.VerticalGroup>
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
### withSwitch
|
|
599
|
+
|
|
600
|
+
```tsx
|
|
601
|
+
import { useState } from 'react';
|
|
602
|
+
import { FormField, Switch } from '@redislabsdev/redis-ui-components';
|
|
603
|
+
|
|
604
|
+
function Render() {
|
|
605
|
+
const [state, setState] = useState(true);
|
|
606
|
+
|
|
607
|
+
return (
|
|
608
|
+
<FormField.VerticalGroup style={{ rowGap: '2rem' }}>
|
|
609
|
+
<FormField
|
|
610
|
+
label="FormField Label"
|
|
611
|
+
additionalText="horizontal layout with Switch"
|
|
612
|
+
layout="horizontal"
|
|
613
|
+
>
|
|
614
|
+
<Switch checked={state} onCheckedChange={setState} />
|
|
615
|
+
</FormField>
|
|
616
|
+
<FormField label="FormField Label" additionalText="vertical layout with Switch">
|
|
617
|
+
<Switch checked={state} onCheckedChange={setState} />
|
|
618
|
+
</FormField>
|
|
619
|
+
<FormField label="FormField Label" additionalText="disabled Switch">
|
|
620
|
+
<Switch checked={state} onCheckedChange={setState} disabled />
|
|
621
|
+
</FormField>
|
|
622
|
+
<FormField label="FormField Label" additionalText="readOnly state of Switch">
|
|
623
|
+
<Switch checked={state} onCheckedChange={setState} readOnly />
|
|
624
|
+
</FormField>
|
|
625
|
+
<FormField label="FormField Label" additionalText="custom id of Switch">
|
|
626
|
+
<Switch checked={state} onCheckedChange={setState} id="custom-id" />
|
|
627
|
+
</FormField>
|
|
628
|
+
</FormField.VerticalGroup>
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
### withInputs
|
|
634
|
+
|
|
635
|
+
```tsx
|
|
636
|
+
import {
|
|
637
|
+
FormField,
|
|
638
|
+
NumericInput,
|
|
639
|
+
PasswordInput,
|
|
640
|
+
QuantityCounter,
|
|
641
|
+
SearchInput,
|
|
642
|
+
TextArea
|
|
643
|
+
} from '@redislabsdev/redis-ui-components';
|
|
644
|
+
|
|
645
|
+
<FormField.VerticalGroup style={{ rowGap: '2rem' }}>
|
|
646
|
+
<FormField label="FormField Label" additionalText="with SearchInput">
|
|
647
|
+
<SearchInput defaultValue="search text" />
|
|
648
|
+
</FormField>
|
|
649
|
+
<FormField label="FormField Label" additionalText="with PasswordInput">
|
|
650
|
+
<PasswordInput defaultValue="password" autoComplete="off" />
|
|
651
|
+
</FormField>
|
|
652
|
+
<FormField label="FormField Label" additionalText="with NumericInput">
|
|
653
|
+
<NumericInput defaultValue={10.1} />
|
|
654
|
+
</FormField>
|
|
655
|
+
<FormField label="FormField Label" additionalText="with QuantityCounter">
|
|
656
|
+
<QuantityCounter defaultValue={123} valueLabel="hedgehogs" maxDecimals={0} autoValidate />
|
|
657
|
+
</FormField>
|
|
658
|
+
<FormField label="FormField Label" additionalText="with TextArea">
|
|
659
|
+
<TextArea
|
|
660
|
+
value={`A grasshopper spent the summer hopping about in the sun and singing to his heart's content. One day, an ant went hurrying by, looking very hot and weary. "Why are you working on such a lovely day?" said the grasshopper. "I'm collecting food for the winter," said the ant, "and I suggest you do the same."`}
|
|
661
|
+
/>
|
|
662
|
+
</FormField>
|
|
663
|
+
</FormField.VerticalGroup>
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
## Notes
|
|
667
|
+
|
|
668
|
+
- FormField can render labels and helper text, and each of those parts is optional.
|
|
669
|
+
- Use `FormField.VerticalGroup` to align multiple fields when mixing horizontal and vertical layouts.
|
|
670
|
+
- Vertical fields inside `FormField.VerticalGroup` stay aligned the same way unless a horizontal field is present in the group.
|
|
671
|
+
- Mixed horizontal and vertical layouts inside `FormField.VerticalGroup` align all inputs, including read-only ones.
|
|
672
|
+
- Error status is inherited from the nested input and turns the additional text red; valid status does not change the field appearance.
|
|
673
|
+
- Read-only state is inherited from the nested input and changes the label color.
|
|
674
|
+
- Shared ids are auto-generated when omitted; setting `id=""` disables sharing between the label and the input.
|
|
675
|
+
- `FormField.Nested` isolates nested controls from the parent field's shared id and state.
|
|
676
|
+
- `disabledState="smart"` propagates disabled state from the container only when the container is disabled; `cut` and `pass` change that sharing behavior.
|
|
677
|
+
- `FieldDisabledProvider` can also be used to keep a nested control's disabled state independent.
|
|
678
|
+
- `FormField.Compose` can be used to build custom layouts, such as placing a link next to the label row.
|