@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,265 @@
|
|
|
1
|
+
# RadioGroup
|
|
2
|
+
|
|
3
|
+
A compound radio group for selecting a single option from a list. It supports controlled and uncontrolled state, horizontal or vertical layout, readonly and disabled modes, data-driven items, and full item composition.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
```tsx
|
|
7
|
+
import { RadioGroup } from '@redislabsdev/redis-ui-components';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Props
|
|
11
|
+
| Prop | Type | Default | Description |
|
|
12
|
+
|------|------|---------|-------------|
|
|
13
|
+
| items | `RadioGroupItem[]` | *required* | Array of radio items to render |
|
|
14
|
+
| value | `string` | - | Controlled selected value |
|
|
15
|
+
| defaultValue | `string` | - | Initial selected value for uncontrolled usage |
|
|
16
|
+
| onChange | `(value: string) => void` | - | Called when the selected value changes |
|
|
17
|
+
| layout | `'horizontal' \| 'vertical'` | `vertical` | Group orientation |
|
|
18
|
+
| disabled | `boolean` | `false` | Disables all radio items in the group |
|
|
19
|
+
| readOnly | `boolean` | `false` | Prevents selection changes while keeping the current appearance |
|
|
20
|
+
| id | `string` | - | Shared id for the group and its generated items |
|
|
21
|
+
|
|
22
|
+
The component also accepts standard `HTMLAttributes<HTMLDivElement>` passthrough props through `RadioGroup.Compose`.
|
|
23
|
+
|
|
24
|
+
### RadioGroupItem Type
|
|
25
|
+
| Field | Type | Description |
|
|
26
|
+
|-------|------|-------------|
|
|
27
|
+
| value | `string` | *required* - Unique item value |
|
|
28
|
+
| label | `string` | Label text shown next to the indicator; pass `''` to hide the label |
|
|
29
|
+
| disabled | `boolean` | Disables the item |
|
|
30
|
+
| id | `string` | Custom id for the item |
|
|
31
|
+
|
|
32
|
+
## Sub-components
|
|
33
|
+
|
|
34
|
+
- `RadioGroup.Compose` - Low-level radio group wrapper used by the compound examples and custom layouts.
|
|
35
|
+
- `RadioGroup.Item` - Generates a single radio item from item data.
|
|
36
|
+
- `RadioGroup.Item.Compose` - Composes a single radio item with shared id and value context.
|
|
37
|
+
- `RadioGroup.Item.Indicator` - Renders the selectable indicator for a radio item.
|
|
38
|
+
- `RadioGroup.Item.Label` - Renders the associated label for a radio item.
|
|
39
|
+
|
|
40
|
+
### RadioGroup.Compose Props
|
|
41
|
+
| Prop | Type | Default | Description |
|
|
42
|
+
|------|------|---------|-------------|
|
|
43
|
+
| children | `React.ReactNode` | *required* | Group contents |
|
|
44
|
+
| disabled | `boolean` | `false` | Disables the entire radio group |
|
|
45
|
+
| value | `string` | - | Controlled selected value |
|
|
46
|
+
| defaultValue | `string` | - | Initial selected value for uncontrolled usage |
|
|
47
|
+
| onChange | `(value: string) => void` | - | Called when the selected value changes |
|
|
48
|
+
| layout | `'horizontal' \| 'vertical'` | `vertical` | Group orientation |
|
|
49
|
+
| readOnly | `boolean` | `false` | Prevents selection changes |
|
|
50
|
+
| id | `string` | - | Shared group id |
|
|
51
|
+
|
|
52
|
+
`RadioGroup.Compose` also accepts standard `HTMLAttributes<HTMLDivElement>` passthrough props.
|
|
53
|
+
|
|
54
|
+
### RadioGroup.Item Props
|
|
55
|
+
| Prop | Type | Default | Description |
|
|
56
|
+
|------|------|---------|-------------|
|
|
57
|
+
| value | `string` | *required* | Item value |
|
|
58
|
+
| label | `string` | - | Optional label text; if omitted, the value is shown, and `''` hides the label |
|
|
59
|
+
| disabled | `boolean` | `false` | Disables the item |
|
|
60
|
+
| id | `string` | - | Custom item id |
|
|
61
|
+
|
|
62
|
+
`RadioGroup.Item` forwards standard button attributes to `RadioGroup.Item.Indicator`.
|
|
63
|
+
|
|
64
|
+
### RadioGroup.Item.Compose Props
|
|
65
|
+
| Prop | Type | Default | Description |
|
|
66
|
+
|------|------|---------|-------------|
|
|
67
|
+
| children | `React.ReactNode` | *required* | Item contents |
|
|
68
|
+
| value | `string` | *required* | Item value |
|
|
69
|
+
| disabled | `boolean` | `false` | Disables the item |
|
|
70
|
+
| id | `string` | - | Shared id for the item label and indicator |
|
|
71
|
+
|
|
72
|
+
`RadioGroup.Item.Compose` also accepts standard `HTMLAttributes<HTMLDivElement>` passthrough props and renders its children inside the item wrapper.
|
|
73
|
+
|
|
74
|
+
`RadioGroup.Item.Indicator` accepts standard `HTMLAttributes<HTMLButtonElement>` passthrough props.
|
|
75
|
+
|
|
76
|
+
`RadioGroup.Item.Label` accepts standard `LabelHTMLAttributes<HTMLLabelElement>` passthrough props.
|
|
77
|
+
|
|
78
|
+
## Examples
|
|
79
|
+
|
|
80
|
+
### Basic Usage
|
|
81
|
+
```tsx
|
|
82
|
+
import { RadioGroup } from '@redislabsdev/redis-ui-components';
|
|
83
|
+
|
|
84
|
+
const items = [
|
|
85
|
+
{ value: '1', label: 'Item 1' },
|
|
86
|
+
{ value: '2', label: 'Item 2' },
|
|
87
|
+
{ value: '3', label: 'Disabled item', disabled: true }
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
<RadioGroup items={items} defaultValue={items[0].value} />
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Controlled
|
|
94
|
+
> Use `value` and `onChange` props to control `RadioGroup` state
|
|
95
|
+
```tsx
|
|
96
|
+
import { Button, RadioGroup } from '@redislabsdev/redis-ui-components';
|
|
97
|
+
import { useState } from 'react';
|
|
98
|
+
|
|
99
|
+
const items = [
|
|
100
|
+
{ value: '1', label: 'Item 1' },
|
|
101
|
+
{ value: '2', label: 'Item 2' },
|
|
102
|
+
{ value: '3', label: 'Disabled item', disabled: true }
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
function Example() {
|
|
106
|
+
const [value, setValue] = useState('2');
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<>
|
|
110
|
+
<Button onClick={() => setValue('1')}>Select first option</Button>
|
|
111
|
+
<Button onClick={() => setValue('3')}>Select disabled option</Button>
|
|
112
|
+
<Button onClick={() => setValue('')}>Unselect all</Button>
|
|
113
|
+
<RadioGroup items={items} value={value} onChange={setValue} />
|
|
114
|
+
</>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Layout
|
|
120
|
+
> Set `layout` prop to `"horizontal"` to have horizontal layout. Vertical layout is default.
|
|
121
|
+
```tsx
|
|
122
|
+
import { RadioGroup } from '@redislabsdev/redis-ui-components';
|
|
123
|
+
|
|
124
|
+
const items = [
|
|
125
|
+
{ value: '1', label: 'Item 1' },
|
|
126
|
+
{ value: '2', label: 'Item 2' },
|
|
127
|
+
{ value: '3', label: 'Disabled item', disabled: true }
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
<>
|
|
131
|
+
<RadioGroup items={items} layout="horizontal" />
|
|
132
|
+
<RadioGroup items={items} />
|
|
133
|
+
</>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Readonly
|
|
137
|
+
> In readonly mode items appear as normal, but the user cannot change the selection
|
|
138
|
+
```tsx
|
|
139
|
+
import { RadioGroup } from '@redislabsdev/redis-ui-components';
|
|
140
|
+
|
|
141
|
+
const items = [
|
|
142
|
+
{ value: '1', label: 'Item 1' },
|
|
143
|
+
{ value: '2', label: 'Item 2' },
|
|
144
|
+
{ value: '3', label: 'Disabled item', disabled: true }
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
<RadioGroup items={items} readOnly defaultValue="2" />
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Disabled
|
|
151
|
+
> Use `disabled` prop of the `RadioGroup` to turn all items to disabled mode
|
|
152
|
+
```tsx
|
|
153
|
+
import { RadioGroup } from '@redislabsdev/redis-ui-components';
|
|
154
|
+
|
|
155
|
+
const items = [
|
|
156
|
+
{ value: '1', label: 'Item 1' },
|
|
157
|
+
{ value: '2', label: 'Item 2' },
|
|
158
|
+
{ value: '3', label: 'Disabled item', disabled: true }
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
<RadioGroup items={items} disabled defaultValue="2" />
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### WithinFormField
|
|
165
|
+
> `RadioGroup` can be used together with `FormField` and `Label` components.
|
|
166
|
+
```tsx
|
|
167
|
+
import { FormField, RadioGroup } from '@redislabsdev/redis-ui-components';
|
|
168
|
+
|
|
169
|
+
const items = [
|
|
170
|
+
{ value: '1', label: 'Item 1' },
|
|
171
|
+
{ value: '2', label: 'Item 2' },
|
|
172
|
+
{ value: '3', label: 'Disabled item', disabled: true }
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
<FormField
|
|
176
|
+
label="FormField Label"
|
|
177
|
+
required
|
|
178
|
+
optional
|
|
179
|
+
infoIconProps={{ text: 'ToolTip!' }}
|
|
180
|
+
additionalText="RadioGroup with horizontal layout"
|
|
181
|
+
>
|
|
182
|
+
<RadioGroup items={items} defaultValue="2" layout="horizontal" />
|
|
183
|
+
</FormField>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### ItemsData
|
|
187
|
+
> Without composition, items are generated from item data, which allows you to define a value, label, disabled state and custom id
|
|
188
|
+
```tsx
|
|
189
|
+
import { RadioGroup } from '@redislabsdev/redis-ui-components';
|
|
190
|
+
|
|
191
|
+
const radioGroupItems = [
|
|
192
|
+
{ label: 'Item 1', value: '1' },
|
|
193
|
+
{ label: 'Disabled', value: '2', disabled: true },
|
|
194
|
+
{ label: 'Next one is without label (must pass empty string to label prop)', value: '3' },
|
|
195
|
+
{ label: '', value: '4' },
|
|
196
|
+
{ label: 'Next one takes value as label', value: '5' },
|
|
197
|
+
{ value: '6' },
|
|
198
|
+
{ value: '7', label: 'Custom id', id: 'custom-id' }
|
|
199
|
+
];
|
|
200
|
+
|
|
201
|
+
<RadioGroup items={radioGroupItems} defaultValue="2" />
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### GroupComposition
|
|
205
|
+
> `RadioGroup` can be composed of `Item`s.
|
|
206
|
+
> In this case, each `Item` is defined as component rather than as plain data.
|
|
207
|
+
```tsx
|
|
208
|
+
import { RadioGroup } from '@redislabsdev/redis-ui-components';
|
|
209
|
+
|
|
210
|
+
<RadioGroup.Compose>
|
|
211
|
+
<RadioGroup.Item label="Item 1" value="1" />
|
|
212
|
+
<RadioGroup.Item label="Disabled" value="2" disabled />
|
|
213
|
+
<RadioGroup.Item
|
|
214
|
+
label="Next one is without label (must pass empty string to label prop) "
|
|
215
|
+
value="3"
|
|
216
|
+
/>
|
|
217
|
+
<RadioGroup.Item label="" value="4" />
|
|
218
|
+
<RadioGroup.Item label="Next one takes value as label" value="5" />
|
|
219
|
+
<RadioGroup.Item value="6" />
|
|
220
|
+
<RadioGroup.Item value="7" id="custom-id" label="Custom id" />
|
|
221
|
+
</RadioGroup.Compose>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### ItemComposition
|
|
225
|
+
> `RadioGroup` allows to compose each item separately.<br>
|
|
226
|
+
> `Item.Indicator` and `Item.Label` can be customized and used with other custom components
|
|
227
|
+
```tsx
|
|
228
|
+
import { Label, RadioGroup } from '@redislabsdev/redis-ui-components';
|
|
229
|
+
|
|
230
|
+
<RadioGroup.Compose defaultValue="1" layout="horizontal">
|
|
231
|
+
<RadioGroup.Item.Compose value="1">
|
|
232
|
+
<RadioGroup.Item.Label>Label on the left</RadioGroup.Item.Label>
|
|
233
|
+
<RadioGroup.Item.Indicator />
|
|
234
|
+
</RadioGroup.Item.Compose>
|
|
235
|
+
<RadioGroup.Item.Compose value="2" id="manual-id">
|
|
236
|
+
<RadioGroup.Item.Indicator />
|
|
237
|
+
<RadioGroup.Item.Label>Manual id</RadioGroup.Item.Label>
|
|
238
|
+
</RadioGroup.Item.Compose>
|
|
239
|
+
<RadioGroup.Item.Compose value="3">
|
|
240
|
+
<RadioGroup.Item.Indicator />
|
|
241
|
+
</RadioGroup.Item.Compose>
|
|
242
|
+
<RadioGroup.Item.Compose value="4" disabled>
|
|
243
|
+
<RadioGroup.Item.Indicator />
|
|
244
|
+
<RadioGroup.Item.Label>Disabled item</RadioGroup.Item.Label>
|
|
245
|
+
</RadioGroup.Item.Compose>
|
|
246
|
+
<RadioGroup.Item.Compose value="5">
|
|
247
|
+
<RadioGroup.Item.Indicator id="inlineId" />
|
|
248
|
+
<RadioGroup.Item.Label htmlFor="inlineId">Id and htmlFor out of context</RadioGroup.Item.Label>
|
|
249
|
+
</RadioGroup.Item.Compose>
|
|
250
|
+
<RadioGroup.Item.Compose value="6">
|
|
251
|
+
<RadioGroup.Item.Indicator />
|
|
252
|
+
<RadioGroup.Item.Label>With Info</RadioGroup.Item.Label>
|
|
253
|
+
<Label.InfoIcon content="Any info text or content" />
|
|
254
|
+
</RadioGroup.Item.Compose>
|
|
255
|
+
</RadioGroup.Compose>
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Notes
|
|
259
|
+
- Use `value` and `onChange` to control `RadioGroup` state.
|
|
260
|
+
- Horizontal layout is enabled with `layout="horizontal"`; vertical layout is the default.
|
|
261
|
+
- In readonly mode, items render normally but the user cannot change the selection.
|
|
262
|
+
- `disabled` turns all items into disabled mode.
|
|
263
|
+
- `RadioGroup` can be used together with `FormField` and `Label`.
|
|
264
|
+
- Without composition, items are generated from item data and can define `value`, `label`, `disabled`, and custom `id`.
|
|
265
|
+
- `Item.Indicator` and `Item.Label` can be customized and combined with other custom components.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# ScreenReaderAnnounce
|
|
2
|
+
|
|
3
|
+
An invisible announcement helper for screen readers with configurable live region behavior and opt-in first-render announcements.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { ScreenReaderAnnounce } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
|------|------|---------|-------------|
|
|
15
|
+
| text | `string` | required | Announcement text |
|
|
16
|
+
| allowAnnounce | `boolean` | `undefined` | Forces or disables the initial announcement behavior |
|
|
17
|
+
| aria-live | `'polite' \| 'assertive'` | `polite` | Live region priority |
|
|
18
|
+
| aria-atomic | `boolean` | `true` | Treats the announcement as a single atomic update |
|
|
19
|
+
| role | `'alert' \| 'status' \| 'log'` | - | Semantic role for the live region |
|
|
20
|
+
| other `VisuallyHidden` props | `ComponentProps<typeof VisuallyHidden>` minus `children`, `style`, `className`, `aria-hidden`, `role`, `text`, `asChild`, and other ARIA props | - | Remaining props forwarded to the hidden announcer |
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
### Playground
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { ScreenReaderAnnounce } from '@redislabsdev/redis-ui-components';
|
|
28
|
+
|
|
29
|
+
<ScreenReaderAnnounce text="This is a screen reader announcement" allowAnnounce />
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### AutomaticAnnouncement
|
|
33
|
+
|
|
34
|
+
> By default, the component only announces text changes after the first render to avoid unnecessary announcements on initial page load.
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { useState } from 'react';
|
|
38
|
+
import { Button, ScreenReaderAnnounce } from '@redislabsdev/redis-ui-components';
|
|
39
|
+
|
|
40
|
+
function Example() {
|
|
41
|
+
const [text, setText] = useState('Initial text');
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
<Button onClick={() => setText(`Text ${Date.now()}`)}>Update Text</Button>
|
|
46
|
+
<ScreenReaderAnnounce text={text} />
|
|
47
|
+
</>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### ForceAnnouncement
|
|
53
|
+
|
|
54
|
+
> Use `allowAnnounce=true` to force announcement on first render.
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import { ScreenReaderAnnounce } from '@redislabsdev/redis-ui-components';
|
|
58
|
+
|
|
59
|
+
<>
|
|
60
|
+
<div>This will announce immediately</div>
|
|
61
|
+
<ScreenReaderAnnounce text="Forced announcement on first render" allowAnnounce />
|
|
62
|
+
</>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### DisabledAnnouncement
|
|
66
|
+
|
|
67
|
+
> Use `allowAnnounce=false` to disable announcements.
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { useState } from 'react';
|
|
71
|
+
import { Button, ScreenReaderAnnounce } from '@redislabsdev/redis-ui-components';
|
|
72
|
+
|
|
73
|
+
function Example() {
|
|
74
|
+
const [text, setText] = useState('Initial text');
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<>
|
|
78
|
+
<Button onClick={() => setText('Updated text - but no announcement')}>Update Text</Button>
|
|
79
|
+
<ScreenReaderAnnounce text={text} allowAnnounce={false} />
|
|
80
|
+
</>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### AriaLiveValues
|
|
86
|
+
|
|
87
|
+
> Use `aria-live` to control announcement priority. Do not use it together with `role`.
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
import { useState } from 'react';
|
|
91
|
+
import { Button, ScreenReaderAnnounce } from '@redislabsdev/redis-ui-components';
|
|
92
|
+
|
|
93
|
+
function Example() {
|
|
94
|
+
const [politeText, setPoliteText] = useState('Polite announcement');
|
|
95
|
+
const [assertiveText, setAssertiveText] = useState('Assertive announcement');
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<>
|
|
99
|
+
<Button onClick={() => setPoliteText(`Polite: ${Date.now()}`)}>Update Polite</Button>
|
|
100
|
+
<div>Polite (default): {politeText}</div>
|
|
101
|
+
<ScreenReaderAnnounce text={politeText} aria-live="polite" />
|
|
102
|
+
|
|
103
|
+
<Button onClick={() => setAssertiveText(`Assertive: ${Date.now()}`)}>Update Assertive</Button>
|
|
104
|
+
<div>Assertive (interrupts): {assertiveText}</div>
|
|
105
|
+
<ScreenReaderAnnounce text={assertiveText} aria-live="assertive" />
|
|
106
|
+
</>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### RoleValues
|
|
112
|
+
|
|
113
|
+
> Use `role` to define semantic meaning of announcements. Do not use it together with `aria-live`.
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
import { useState } from 'react';
|
|
117
|
+
import { Button, ScreenReaderAnnounce } from '@redislabsdev/redis-ui-components';
|
|
118
|
+
|
|
119
|
+
function Example() {
|
|
120
|
+
const [statusText, setStatusText] = useState('Status announcement');
|
|
121
|
+
const [alertText, setAlertText] = useState('Alert announcement');
|
|
122
|
+
const [logText, setLogText] = useState('Log announcement');
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<>
|
|
126
|
+
<Button onClick={() => setStatusText(`Status: ${Date.now()}`)}>Update Status</Button>
|
|
127
|
+
<div>Status (default): {statusText}</div>
|
|
128
|
+
<ScreenReaderAnnounce text={statusText} role="status" />
|
|
129
|
+
|
|
130
|
+
<Button onClick={() => setAlertText(`Alert: ${Date.now()}`)}>Update Alert</Button>
|
|
131
|
+
<div>Alert (important): {alertText}</div>
|
|
132
|
+
<ScreenReaderAnnounce text={alertText} role="alert" />
|
|
133
|
+
|
|
134
|
+
<Button onClick={() => setLogText(`Log: ${Date.now()}`)}>Update Log</Button>
|
|
135
|
+
<div>Log (sequential): {logText}</div>
|
|
136
|
+
<ScreenReaderAnnounce text={logText} role="log" />
|
|
137
|
+
</>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Notes
|
|
143
|
+
|
|
144
|
+
- By default the component waits for the first text change before announcing.
|
|
145
|
+
- `allowAnnounce` can force the first announcement or disable announcements entirely.
|
|
146
|
+
- Use either `aria-live` or `role`, but not both on the same instance.
|
|
147
|
+
- The component renders nothing when `text` is empty.
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# SearchBar
|
|
2
|
+
|
|
3
|
+
Composite search bar for table screens that combines search, filters, column selection, and custom actions.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { SearchBar, type ColumnOption } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> Composition examples also use icons from `@redislabsdev/redis-ui-icons`:
|
|
12
|
+
> ```tsx
|
|
13
|
+
> import { ExportIcon, RefreshIcon } from '@redislabsdev/redis-ui-icons';
|
|
14
|
+
> ```
|
|
15
|
+
|
|
16
|
+
## Props
|
|
17
|
+
|
|
18
|
+
| Prop | Type | Default | Description |
|
|
19
|
+
|------|------|---------|-------------|
|
|
20
|
+
| searchValue | `string` | required | Current search text passed to the built-in search input. |
|
|
21
|
+
| onSearchChange | `(value: string) => void` | required | Called when the search text changes. |
|
|
22
|
+
| onFiltersChange | `(activeFilters: FilterActive[]) => void` | required | Called when filter selection changes. |
|
|
23
|
+
| activeFilters | `FilterActive[]` | required | Active filters rendered by the filters section. |
|
|
24
|
+
| availableFilters | `FilterItemConfig[]` | required | Filter definitions shown in the filters section. |
|
|
25
|
+
| availableColumns | `ColumnOption[]` | - | Optional column definitions shown in the column selector. |
|
|
26
|
+
| activeColumns | `string[]` | - | Optional active column ids. |
|
|
27
|
+
| onColumnsChange | `(selectedColumns: string[]) => void` | - | Called when selected columns change. |
|
|
28
|
+
| children | `React.ReactNode` | - | Additional content forwarded to `SearchBar.Compose`. |
|
|
29
|
+
|
|
30
|
+
### Related Types
|
|
31
|
+
|
|
32
|
+
- `ColumnOption` - Column definition type exported by `SearchBar`; used by `availableColumns` and the column selector.
|
|
33
|
+
|
|
34
|
+
## Sub-components
|
|
35
|
+
|
|
36
|
+
- `SearchBar.Compose` - Shared state wrapper that provides `SearchBar` context and wraps the composed search layout.
|
|
37
|
+
- `SearchBar.SearchSection` - Default search header with the search input and actions row.
|
|
38
|
+
- `SearchBar.SearchSection.Compose` - Low-level wrapper for fully custom search header layouts.
|
|
39
|
+
- `SearchBar.SearchSection.SearchInput` - Search input wrapper with the built-in `Search anything` placeholder.
|
|
40
|
+
- `SearchBar.SearchSection.Actions` - Default actions row that renders the filter toggle and optional column selector.
|
|
41
|
+
- `SearchBar.SearchSection.Actions.Compose` - Low-level wrapper for custom action-row layouts.
|
|
42
|
+
- `SearchBar.SearchSection.Actions.FilterToggle` - Filter toggle button with the active filter count badge.
|
|
43
|
+
- `SearchBar.SearchSection.Actions.ColumnSelector` - Column multi-select used to show or hide table columns.
|
|
44
|
+
- `SearchBar.SearchSection.Actions.CustomActions` - Slot for custom action buttons or other trailing controls.
|
|
45
|
+
- `SearchBar.FiltersSection` - Filter panel section rendered below the search header.
|
|
46
|
+
|
|
47
|
+
## Props
|
|
48
|
+
|
|
49
|
+
### SearchBar.Compose Props
|
|
50
|
+
|
|
51
|
+
| Prop | Type | Default | Description |
|
|
52
|
+
|------|------|---------|-------------|
|
|
53
|
+
| activeFilters | `FilterActive[]` | required | Active filters shared with nested controls. |
|
|
54
|
+
| children | `React.ReactNode` | required | Custom search bar layout content. |
|
|
55
|
+
|
|
56
|
+
`SearchBar.Compose` also accepts native `HTMLAttributes<HTMLDivElement>` props.
|
|
57
|
+
|
|
58
|
+
### SearchBar.SearchSection Props
|
|
59
|
+
|
|
60
|
+
| Prop | Type | Default | Description |
|
|
61
|
+
|------|------|---------|-------------|
|
|
62
|
+
| searchValue | `string` | required | Current search input value. |
|
|
63
|
+
| onSearchChange | `(value: string) => void` | required | Called when the search input changes. |
|
|
64
|
+
| availableColumns | `ColumnOption[]` | - | Column options passed to the column selector. |
|
|
65
|
+
| activeColumns | `string[]` | - | Active column ids. |
|
|
66
|
+
| onColumnsChange | `(selectedColumns: string[]) => void` | - | Called when selected columns change. |
|
|
67
|
+
| children | `React.ReactNode` | - | Additional search section content. |
|
|
68
|
+
|
|
69
|
+
### SearchBar.SearchSection.Compose Props
|
|
70
|
+
|
|
71
|
+
| Prop | Type | Default | Description |
|
|
72
|
+
|------|------|---------|-------------|
|
|
73
|
+
| children | `React.ReactNode` | required | Custom search header content. |
|
|
74
|
+
|
|
75
|
+
`SearchBar.SearchSection.Compose` also accepts native `HTMLAttributes<HTMLDivElement>` props.
|
|
76
|
+
|
|
77
|
+
### SearchBar.SearchSection.SearchInput Props
|
|
78
|
+
|
|
79
|
+
`SearchBar.SearchSection.SearchInput` does not define new props. It inherits the `SearchInput` prop surface from the input package and renders with a built-in `Search anything` placeholder.
|
|
80
|
+
|
|
81
|
+
### SearchBar.SearchSection.Actions Props
|
|
82
|
+
|
|
83
|
+
| Prop | Type | Default | Description |
|
|
84
|
+
|------|------|---------|-------------|
|
|
85
|
+
| availableColumns | `ColumnOption[]` | - | Column options used to render the column selector. |
|
|
86
|
+
| activeColumns | `string[]` | - | Active column ids. |
|
|
87
|
+
| onColumnsChange | `(selectedColumns: string[]) => void` | - | Called when selected columns change. |
|
|
88
|
+
|
|
89
|
+
### SearchBar.SearchSection.Actions.Compose Props
|
|
90
|
+
|
|
91
|
+
| Prop | Type | Default | Description |
|
|
92
|
+
|------|------|---------|-------------|
|
|
93
|
+
| children | `React.ReactNode` | required | Custom action row content. |
|
|
94
|
+
|
|
95
|
+
`SearchBar.SearchSection.Actions.Compose` also accepts native `HTMLAttributes<HTMLDivElement>` props.
|
|
96
|
+
|
|
97
|
+
### SearchBar.SearchSection.Actions.FilterToggle Props
|
|
98
|
+
|
|
99
|
+
`SearchBar.SearchSection.Actions.FilterToggle` does not define custom props. It reads `SearchBar` context and shows the active filter count.
|
|
100
|
+
|
|
101
|
+
### SearchBar.SearchSection.Actions.ColumnSelector Props
|
|
102
|
+
|
|
103
|
+
| Prop | Type | Default | Description |
|
|
104
|
+
|------|------|---------|-------------|
|
|
105
|
+
| availableColumns | `ColumnOption[]` | required | Column definitions available in the selector. |
|
|
106
|
+
| activeColumns | `string[]` | required | Active column ids. |
|
|
107
|
+
| onChange | `(selectedColumns: string[]) => void` | required | Called when the selection changes. |
|
|
108
|
+
|
|
109
|
+
### SearchBar.SearchSection.Actions.CustomActions Props
|
|
110
|
+
|
|
111
|
+
| Prop | Type | Default | Description |
|
|
112
|
+
|------|------|---------|-------------|
|
|
113
|
+
| children | `React.ReactNode` | - | Custom trailing actions rendered next to the built-in controls. |
|
|
114
|
+
|
|
115
|
+
`SearchBar.SearchSection.Actions.CustomActions` also accepts native `HTMLAttributes<HTMLDivElement>` props.
|
|
116
|
+
|
|
117
|
+
### SearchBar.FiltersSection Props
|
|
118
|
+
|
|
119
|
+
| Prop | Type | Default | Description |
|
|
120
|
+
|------|------|---------|-------------|
|
|
121
|
+
| availableFilters | `FilterItemConfig[]` | required | Filter definitions shown in the filter section. |
|
|
122
|
+
| onFiltersChange | `(activeFilters: FilterActive[]) => void` | required | Called when filters change. |
|
|
123
|
+
|
|
124
|
+
`SearchBar.FiltersSection` also accepts native `HTMLAttributes<HTMLDivElement>` props.
|
|
125
|
+
|
|
126
|
+
## Examples
|
|
127
|
+
|
|
128
|
+
### Playground
|
|
129
|
+
|
|
130
|
+
> The playground story keeps filter and column state in sync with `useArgState`.
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
import { useArgState } from '../../helpers/useArgState';
|
|
134
|
+
import { SearchBar } from '@redislabsdev/redis-ui-components';
|
|
135
|
+
|
|
136
|
+
function Render(args) {
|
|
137
|
+
const [activeFilters, setActiveFilters] = useArgState({
|
|
138
|
+
arg: args.activeFilters,
|
|
139
|
+
event: args.onFiltersChange,
|
|
140
|
+
getNewState: (_, [value]) => value
|
|
141
|
+
});
|
|
142
|
+
const [activeColumns, setActiveColumns] = useArgState({
|
|
143
|
+
arg: args.activeColumns,
|
|
144
|
+
event: args.onColumnsChange,
|
|
145
|
+
getNewState: (_, [value]) => value
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<SearchBar
|
|
150
|
+
{...args}
|
|
151
|
+
activeFilters={activeFilters}
|
|
152
|
+
onFiltersChange={setActiveFilters}
|
|
153
|
+
activeColumns={activeColumns}
|
|
154
|
+
onColumnsChange={setActiveColumns}
|
|
155
|
+
/>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Controlled
|
|
161
|
+
|
|
162
|
+
> SearchBar works in controlled mode.<br/>
|
|
163
|
+
> Component requires following props:
|
|
164
|
+
> - `availableFilters` array of filters with type and options
|
|
165
|
+
> - `activeFilters` selected filter values
|
|
166
|
+
> - `onFiltersChange` handler to update filter selection
|
|
167
|
+
> - `searchValue` string (initial value)
|
|
168
|
+
> - `onSearchChange` handler to update search state
|
|
169
|
+
>
|
|
170
|
+
> To enable column selection you should specify following optional props
|
|
171
|
+
> - `availableColumns` array of columns
|
|
172
|
+
> - `activeColumns` selected columns ids
|
|
173
|
+
> - `onColumnsChange` handler to update column selection
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
import { useState } from 'react';
|
|
177
|
+
import { SearchBar } from '@redislabsdev/redis-ui-components';
|
|
178
|
+
|
|
179
|
+
function Render() {
|
|
180
|
+
const [searchValue, setSearchValue] = useState('');
|
|
181
|
+
const [activeFilters, setActiveFilters] = useState(defaultFilters);
|
|
182
|
+
const [activeColumns, setActiveColumns] = useState(defaultColumns);
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<SearchBar
|
|
186
|
+
availableFilters={availableFilters}
|
|
187
|
+
activeFilters={activeFilters}
|
|
188
|
+
onFiltersChange={setActiveFilters}
|
|
189
|
+
availableColumns={availableColumns}
|
|
190
|
+
activeColumns={activeColumns}
|
|
191
|
+
onColumnsChange={setActiveColumns}
|
|
192
|
+
searchValue={searchValue}
|
|
193
|
+
onSearchChange={setSearchValue}
|
|
194
|
+
data-testid="search-bar-test-id"
|
|
195
|
+
/>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Composition
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
import { useState } from 'react';
|
|
204
|
+
import { IconButton, SearchBar } from '@redislabsdev/redis-ui-components';
|
|
205
|
+
import { ExportIcon, RefreshIcon } from '@redislabsdev/redis-ui-icons';
|
|
206
|
+
|
|
207
|
+
function Render() {
|
|
208
|
+
const [activeFilters, setActiveFilters] = useState(defaultFilters);
|
|
209
|
+
const [activeColumns, setActiveColumns] = useState(defaultColumns);
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<SearchBar.Compose activeFilters={activeFilters}>
|
|
213
|
+
<SearchBar.SearchSection.Compose>
|
|
214
|
+
<SearchBar.SearchSection.SearchInput />
|
|
215
|
+
<SearchBar.SearchSection.Actions.Compose>
|
|
216
|
+
<SearchBar.SearchSection.Actions.FilterToggle />
|
|
217
|
+
<SearchBar.SearchSection.Actions.ColumnSelector
|
|
218
|
+
availableColumns={availableColumns}
|
|
219
|
+
activeColumns={activeColumns}
|
|
220
|
+
onChange={setActiveColumns}
|
|
221
|
+
/>
|
|
222
|
+
<SearchBar.SearchSection.Actions.CustomActions>
|
|
223
|
+
<IconButton icon={ExportIcon} size="L" title="Export" />
|
|
224
|
+
<IconButton icon={RefreshIcon} size="L" title="Refresh" />
|
|
225
|
+
</SearchBar.SearchSection.Actions.CustomActions>
|
|
226
|
+
</SearchBar.SearchSection.Actions.Compose>
|
|
227
|
+
</SearchBar.SearchSection.Compose>
|
|
228
|
+
<SearchBar.FiltersSection
|
|
229
|
+
onFiltersChange={setActiveFilters}
|
|
230
|
+
availableFilters={availableFilters}
|
|
231
|
+
/>
|
|
232
|
+
</SearchBar.Compose>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Notes
|
|
238
|
+
|
|
239
|
+
- The root `SearchBar` forwards remaining props to `SearchBar.Compose`, so compose-container attributes can be applied at the root.
|
|
240
|
+
- `SearchBar.SearchSection.Actions` only renders `ColumnSelector` when `availableColumns`, `activeColumns`, and `onColumnsChange` are all provided.
|
|
241
|
+
- `SearchBar.FiltersSection` and `SearchBar.SearchSection.Actions.FilterToggle` rely on `SearchBar` context and must be rendered inside `SearchBar.Compose`.
|
|
242
|
+
- The controlled story manages search text, filters, and columns with local `useState` hooks.
|