@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,298 @@
|
|
|
1
|
+
# Drawer
|
|
2
|
+
|
|
3
|
+
A sliding overlay panel for focused workflows, with collapsible or persistent behavior and composable header, description, body, and footer sections.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Drawer } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> Footer examples use icons from `@redislabsdev/redis-ui-icons`:
|
|
12
|
+
> ```tsx
|
|
13
|
+
> import { StarsIcon } from '@redislabsdev/redis-ui-icons';
|
|
14
|
+
> ```
|
|
15
|
+
|
|
16
|
+
## Props
|
|
17
|
+
|
|
18
|
+
| Prop | Type | Default | Description |
|
|
19
|
+
|------|------|---------|-------------|
|
|
20
|
+
| persistent | `boolean` | `false` | Keeps the drawer from closing on outside click or `Esc`, and suppresses the default header close button. |
|
|
21
|
+
| open | `boolean` | required | Controls whether the drawer is open. |
|
|
22
|
+
| onOpenChange | `(open: boolean) => void` | - | Called when the open state changes. |
|
|
23
|
+
| containerElement | `HTMLElement` | - | Portal container to render the drawer into instead of `body`. |
|
|
24
|
+
| zIndex | `number` | `theme.core.zIndex.zIndex9998` | Z-index used for the drawer overlay and content. |
|
|
25
|
+
| onDrawerWillOpen | `() => void` | - | Fires when the open animation starts. |
|
|
26
|
+
| onDrawerDidOpen | `() => void` | - | Fires when the open animation ends. |
|
|
27
|
+
| onDrawerWillClose | `() => void` | - | Fires when the close animation starts. |
|
|
28
|
+
| onDrawerDidClose | `() => void` | - | Fires when the close animation ends. |
|
|
29
|
+
|
|
30
|
+
The component also accepts the native `HTMLAttributes<HTMLDivElement>` props.
|
|
31
|
+
|
|
32
|
+
## Sub-components
|
|
33
|
+
|
|
34
|
+
- `Drawer.Header` - Default header wrapper that renders a title and, in non-persistent mode, a close button.
|
|
35
|
+
- `Drawer.Description` - Accessible description wrapper for drawer content.
|
|
36
|
+
- `Drawer.Body` - Main content area inside the drawer.
|
|
37
|
+
- `Drawer.Footer` - Default footer wrapper for primary, secondary, and tertiary actions.
|
|
38
|
+
- `Drawer.Header.Compose` - Custom header layout container.
|
|
39
|
+
- `Drawer.Header.Title` - Drawer heading helper for custom header compositions.
|
|
40
|
+
- `Drawer.Description.Text` - Typography helper for drawer description text.
|
|
41
|
+
- `Drawer.Footer.Compose` - Custom footer layout container.
|
|
42
|
+
- `Drawer.Footer.ActionButtonsContainer` - Container for footer action buttons.
|
|
43
|
+
|
|
44
|
+
### `Drawer.Header`
|
|
45
|
+
|
|
46
|
+
| Prop | Type | Default | Description |
|
|
47
|
+
|------|------|---------|-------------|
|
|
48
|
+
| title | `string` | required | Header title text. |
|
|
49
|
+
| titleHidden | `boolean` | `false` | Visually hides the title while keeping it accessible. |
|
|
50
|
+
|
|
51
|
+
It also accepts the native `HTMLAttributes<HTMLDivElement>` props through the composed header container.
|
|
52
|
+
|
|
53
|
+
### `Drawer.Header.Compose`
|
|
54
|
+
|
|
55
|
+
Accepts the native `HTMLAttributes<HTMLDivElement>` props for the custom header container.
|
|
56
|
+
|
|
57
|
+
### `Drawer.Header.Title`
|
|
58
|
+
|
|
59
|
+
| Prop | Type | Default | Description |
|
|
60
|
+
|------|------|---------|-------------|
|
|
61
|
+
| hidden | `boolean` | `false` | Visually hides the title while keeping it accessible. |
|
|
62
|
+
|
|
63
|
+
It inherits the `Typography.Heading` props.
|
|
64
|
+
|
|
65
|
+
### `Drawer.Description`
|
|
66
|
+
|
|
67
|
+
| Prop | Type | Default | Description |
|
|
68
|
+
|------|------|---------|-------------|
|
|
69
|
+
| hidden | `boolean` | `false` | Visually hides the description while keeping it accessible. |
|
|
70
|
+
|
|
71
|
+
It also accepts the native `HTMLAttributes<HTMLDivElement>` props through the description container.
|
|
72
|
+
|
|
73
|
+
### `Drawer.Description.Text`
|
|
74
|
+
|
|
75
|
+
It inherits the `Typography.Heading` props.
|
|
76
|
+
|
|
77
|
+
### `Drawer.Body`
|
|
78
|
+
|
|
79
|
+
| Prop | Type | Default | Description |
|
|
80
|
+
|------|------|---------|-------------|
|
|
81
|
+
| focusableForScroll | `boolean` | `true` | Adds focus and region semantics when the body content is scrollable. |
|
|
82
|
+
|
|
83
|
+
It also accepts the native `HTMLAttributes<HTMLDivElement>` props.
|
|
84
|
+
|
|
85
|
+
### `Drawer.Footer`
|
|
86
|
+
|
|
87
|
+
| Prop | Type | Default | Description |
|
|
88
|
+
|------|------|---------|-------------|
|
|
89
|
+
| primaryButtonText | `string` | - | Text for the primary action button. |
|
|
90
|
+
| secondaryButtonText | `string` | - | Text for the secondary action button. |
|
|
91
|
+
| tertiaryButtonText | `string` | - | Text for the tertiary text button. |
|
|
92
|
+
| tertiaryButtonIcon | `IconType` | - | Optional icon rendered before the tertiary button text. |
|
|
93
|
+
| primaryButtonDisabled | `boolean` | - | Disables the primary action button. |
|
|
94
|
+
| secondaryButtonDisabled | `boolean` | - | Disables the secondary action button. |
|
|
95
|
+
| tertiaryButtonDisabled | `boolean` | - | Disables the tertiary action button. |
|
|
96
|
+
| onPrimaryButtonClick | `(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void` | - | Primary button click handler. |
|
|
97
|
+
| onSecondaryButtonClick | `(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void` | - | Secondary button click handler. |
|
|
98
|
+
| onTertiaryButtonClick | `(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void` | - | Tertiary button click handler. |
|
|
99
|
+
|
|
100
|
+
It also accepts the native `HTMLAttributes<HTMLDivElement>` props.
|
|
101
|
+
|
|
102
|
+
### `Drawer.Footer.Compose`
|
|
103
|
+
|
|
104
|
+
Accepts the native `HTMLAttributes<HTMLDivElement>` props for the custom footer container.
|
|
105
|
+
|
|
106
|
+
### `Drawer.Footer.ActionButtonsContainer`
|
|
107
|
+
|
|
108
|
+
Accepts the native `HTMLAttributes<HTMLDivElement>` props for the action button container.
|
|
109
|
+
|
|
110
|
+
## Examples
|
|
111
|
+
|
|
112
|
+
### Basic Usage
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
import { Button, Drawer } from '@redislabsdev/redis-ui-components';
|
|
116
|
+
import { StarsIcon } from '@redislabsdev/redis-ui-icons';
|
|
117
|
+
import { useState } from 'react';
|
|
118
|
+
|
|
119
|
+
function Render() {
|
|
120
|
+
const [open, setOpen] = useState(false);
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<>
|
|
124
|
+
<Button onClick={() => setOpen(true)}>Open drawer</Button>
|
|
125
|
+
|
|
126
|
+
<Drawer open={open} onOpenChange={setOpen}>
|
|
127
|
+
<Drawer.Header title="Drawer.Header" titleHidden={false} />
|
|
128
|
+
<Drawer.Description hidden={false}>Drawer.Description</Drawer.Description>
|
|
129
|
+
<Drawer.Body>Drawer.Body</Drawer.Body>
|
|
130
|
+
<Drawer.Footer
|
|
131
|
+
primaryButtonText="Primary"
|
|
132
|
+
secondaryButtonText="Secondary"
|
|
133
|
+
tertiaryButtonText="Tertiary"
|
|
134
|
+
tertiaryButtonIcon={StarsIcon}
|
|
135
|
+
onPrimaryButtonClick={() => setOpen(false)}
|
|
136
|
+
onSecondaryButtonClick={() => setOpen(false)}
|
|
137
|
+
/>
|
|
138
|
+
</Drawer>
|
|
139
|
+
</>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Collapsible
|
|
145
|
+
|
|
146
|
+
> The auto collapsible mode is the default mode for the Drawer. It allows closing the drawer automatically when the user clicks outside or presses the `Esc` key. In this mode `Drawer.Header` will have the close button.
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { Button, Drawer } from '@redislabsdev/redis-ui-components';
|
|
150
|
+
import { useState } from 'react';
|
|
151
|
+
|
|
152
|
+
import { StoryDrawerBodyContent } from './story.components';
|
|
153
|
+
|
|
154
|
+
function Render() {
|
|
155
|
+
const [open, setOpen] = useState(false);
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<>
|
|
159
|
+
<Button onClick={() => setOpen(true)}>Open drawer</Button>
|
|
160
|
+
|
|
161
|
+
<Drawer open={open} onOpenChange={setOpen}>
|
|
162
|
+
<Drawer.Header title="Collapsible drawer" />
|
|
163
|
+
<Drawer.Body>
|
|
164
|
+
<StoryDrawerBodyContent />
|
|
165
|
+
</Drawer.Body>
|
|
166
|
+
<Drawer.Footer secondaryButtonText="Close" onSecondaryButtonClick={() => setOpen(false)} />
|
|
167
|
+
</Drawer>
|
|
168
|
+
</>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Persistent
|
|
174
|
+
|
|
175
|
+
> The persistent mode prevents the drawer from being accidentally closed, which could result in the loss of filled form data. Use `persistent` prop to enable this mode. You'll need to manage open state manually and close the drawer explicitly.
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
import { Button, Drawer, Typography } from '@redislabsdev/redis-ui-components';
|
|
179
|
+
import { useState } from 'react';
|
|
180
|
+
|
|
181
|
+
function Render() {
|
|
182
|
+
const [open, setOpen] = useState(false);
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<>
|
|
186
|
+
<Button onClick={() => setOpen(true)}>Open drawer</Button>
|
|
187
|
+
|
|
188
|
+
<Drawer persistent open={open} onOpenChange={setOpen}>
|
|
189
|
+
<Drawer.Header title="Persistent drawer" />
|
|
190
|
+
<Drawer.Body>
|
|
191
|
+
<Typography.Heading size="S">Persistent drawers usually contain forms</Typography.Heading>
|
|
192
|
+
<br />
|
|
193
|
+
<Typography.Body>
|
|
194
|
+
The persistent mode prevents the drawer from being accidentally closed, which could
|
|
195
|
+
result in the loss of filled form data.
|
|
196
|
+
</Typography.Body>
|
|
197
|
+
</Drawer.Body>
|
|
198
|
+
<Drawer.Footer
|
|
199
|
+
primaryButtonText="Submit"
|
|
200
|
+
secondaryButtonText="Cancel"
|
|
201
|
+
onSecondaryButtonClick={() => setOpen(false)}
|
|
202
|
+
onPrimaryButtonClick={() => setOpen(false)}
|
|
203
|
+
/>
|
|
204
|
+
</Drawer>
|
|
205
|
+
</>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### InContainer
|
|
211
|
+
|
|
212
|
+
> Drawer can be opened under a specified container instead of `body`. Use `containerElement` prop to set the container element.
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import { Button, Drawer } from '@redislabsdev/redis-ui-components';
|
|
216
|
+
import { useState } from 'react';
|
|
217
|
+
|
|
218
|
+
import { StoryDrawerBodyContent } from './story.components';
|
|
219
|
+
import * as S from './story.style';
|
|
220
|
+
|
|
221
|
+
function Render() {
|
|
222
|
+
const [open, setOpen] = useState(false);
|
|
223
|
+
const [container, setContainer] = useState<HTMLDivElement | null>(null);
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<S.StoryDrawerContainer ref={setContainer}>
|
|
227
|
+
<Button onClick={() => setOpen(true)}>Open drawer</Button>
|
|
228
|
+
|
|
229
|
+
<Drawer open={open} onOpenChange={setOpen} containerElement={container || undefined}>
|
|
230
|
+
<Drawer.Header title="Drawer in container" />
|
|
231
|
+
<Drawer.Body>
|
|
232
|
+
<StoryDrawerBodyContent />
|
|
233
|
+
</Drawer.Body>
|
|
234
|
+
</Drawer>
|
|
235
|
+
</S.StoryDrawerContainer>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Composition
|
|
241
|
+
|
|
242
|
+
> Use `Drawer.Header.Compose` and `Drawer.Footer.Compose` to compose the header and footer. `Drawer.Body` can have any children.
|
|
243
|
+
|
|
244
|
+
```tsx
|
|
245
|
+
import { Button, Drawer, Typography } from '@redislabsdev/redis-ui-components';
|
|
246
|
+
import { useState } from 'react';
|
|
247
|
+
|
|
248
|
+
import { StoryDrawerBodyContent } from './story.components';
|
|
249
|
+
import { StoryGroupTitle, StoryHList, StoryVList } from '../../helpers/Story.style';
|
|
250
|
+
|
|
251
|
+
function Render() {
|
|
252
|
+
const [open, setOpen] = useState(false);
|
|
253
|
+
|
|
254
|
+
return (
|
|
255
|
+
<>
|
|
256
|
+
<Button onClick={() => setOpen(true)}>Open drawer</Button>
|
|
257
|
+
|
|
258
|
+
<Drawer open={open} onOpenChange={setOpen}>
|
|
259
|
+
<Drawer.Header.Compose>
|
|
260
|
+
<StoryHList>
|
|
261
|
+
<Drawer.Header.Title>Drawer.Header.Title</Drawer.Header.Title>
|
|
262
|
+
<Button>Custom Header content</Button>
|
|
263
|
+
</StoryHList>
|
|
264
|
+
</Drawer.Header.Compose>
|
|
265
|
+
<Drawer.Description>
|
|
266
|
+
<StoryHList>
|
|
267
|
+
<Drawer.Description.Text>Drawer.Description.Text</Drawer.Description.Text>
|
|
268
|
+
<Button>Custom Description content</Button>
|
|
269
|
+
</StoryHList>
|
|
270
|
+
</Drawer.Description>
|
|
271
|
+
<Drawer.Body>
|
|
272
|
+
<StoryVList $align="stretch">
|
|
273
|
+
<StoryGroupTitle>Drawer.Body: any content</StoryGroupTitle>
|
|
274
|
+
<StoryDrawerBodyContent />
|
|
275
|
+
</StoryVList>
|
|
276
|
+
</Drawer.Body>
|
|
277
|
+
<Drawer.Footer.Compose>
|
|
278
|
+
<Typography.Body>Custom Footer content</Typography.Body>
|
|
279
|
+
<Drawer.Footer.ActionButtonsContainer>
|
|
280
|
+
<Button variant="secondary-invert" onClick={() => setOpen(false)}>
|
|
281
|
+
Custom Close
|
|
282
|
+
</Button>
|
|
283
|
+
</Drawer.Footer.ActionButtonsContainer>
|
|
284
|
+
</Drawer.Footer.Compose>
|
|
285
|
+
</Drawer>
|
|
286
|
+
</>
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Notes
|
|
292
|
+
|
|
293
|
+
- The default mode is collapsible: outside clicks and the `Esc` key close the drawer, and `Drawer.Header` shows a close button.
|
|
294
|
+
- Use `persistent` when the drawer contains form state that should not be lost accidentally.
|
|
295
|
+
- Use `containerElement` when the drawer should render into a specific container instead of `body`.
|
|
296
|
+
- `Drawer.Header.Compose` and `Drawer.Footer.Compose` are the intended escape hatches for custom layouts.
|
|
297
|
+
- `Drawer.Body` can contain any children, including other interactive components and scrollable content.
|
|
298
|
+
- When composing the drawer, keep a proper title through `Drawer.Header.title` or `Drawer.Header.Title` so the dialog remains accessible.
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Filters
|
|
2
|
+
|
|
3
|
+
Controlled filter bar for combining menu-based filters, a clear action, and an active-chip summary. Use the composition API when you need to place the controls in a custom layout.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Filters } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
|------|------|---------|-------------|
|
|
15
|
+
| availableFilters | `FilterItemConfig[]` | required | Filter definitions to render. Each item provides a key, label, options, and optional filter type. |
|
|
16
|
+
| activeFilters | `FilterActive[]` | required | Current active filter state. |
|
|
17
|
+
| onChange | `(activeFilters: FilterActive[]) => void` | required | Called when the active filter selection changes. |
|
|
18
|
+
| showSearchLimit | `number` | `7` | Minimum number of options before a filter shows a search input. |
|
|
19
|
+
|
|
20
|
+
`Filters` extends `HTMLAttributes<HTMLDivElement>` except `onChange`, so you can pass standard div props to the root container.
|
|
21
|
+
|
|
22
|
+
### Exported Types
|
|
23
|
+
|
|
24
|
+
- `FilterType` - `'MultiSelect' | 'MultiTreeSelect'`
|
|
25
|
+
- `FilterItemConfig` - filter definition with `key`, `label`, `options`, optional `type`, and optional `showSearch`
|
|
26
|
+
- `FilterOption` - option definition with `label`, `value`, optional `id`, optional `chipLabel`, and optional nested `descendants`
|
|
27
|
+
- `FilterActive` - active filter entry with `key`, `selectedOptions`, and optional `type`
|
|
28
|
+
|
|
29
|
+
## Sub-components
|
|
30
|
+
|
|
31
|
+
- `Filters.Compose` - Provides Filters context and debounced change handling for custom compositions.
|
|
32
|
+
- `Filters.FiltersContainer` - Wrapper for the filter trigger row.
|
|
33
|
+
- `Filters.MultiSelectFilter` - Checkbox-based menu for flat multi-select filters.
|
|
34
|
+
- `Filters.MultiTreeSelectFilter` - Tree-based menu for hierarchical filters.
|
|
35
|
+
- `Filters.Clear` - Clear-all action bound to the current filter state.
|
|
36
|
+
- `Filters.Chips` - Renders chips for the active filters and handles removal.
|
|
37
|
+
|
|
38
|
+
### Filters.Compose Props
|
|
39
|
+
|
|
40
|
+
| Prop | Type | Default | Description |
|
|
41
|
+
|------|------|---------|-------------|
|
|
42
|
+
| availableFilters | `FilterItemConfig[]` | required | Filter definitions available to the composition. |
|
|
43
|
+
| activeFilters | `FilterActive[]` | required | Current active filter state. |
|
|
44
|
+
| onChange | `(activeFilters: FilterActive[]) => void` | required | Called when the active filter selection changes. |
|
|
45
|
+
| showSearchLimit | `number` | `7` | Minimum number of options before a filter shows a search input. |
|
|
46
|
+
| children | `React.ReactNode` | required | Custom composition content rendered inside the Filters context. |
|
|
47
|
+
|
|
48
|
+
### Filters.FiltersContainer Props
|
|
49
|
+
|
|
50
|
+
Inherits `HTMLAttributes<HTMLDivElement>`.
|
|
51
|
+
|
|
52
|
+
### Filters.MultiSelectFilter Props
|
|
53
|
+
|
|
54
|
+
| Prop | Type | Default | Description |
|
|
55
|
+
|------|------|---------|-------------|
|
|
56
|
+
| filter | `FilterItemConfig` | required | Filter configuration used to build the menu. |
|
|
57
|
+
| showSearchLimit | `number` | required | Minimum option count before the search input renders. |
|
|
58
|
+
|
|
59
|
+
`Filters.MultiSelectFilter` also accepts all `MenuProps` except `children`.
|
|
60
|
+
|
|
61
|
+
### Filters.MultiTreeSelectFilter Props
|
|
62
|
+
|
|
63
|
+
| Prop | Type | Default | Description |
|
|
64
|
+
|------|------|---------|-------------|
|
|
65
|
+
| filter | `FilterItemConfig` | required | Tree filter configuration used to build the menu. |
|
|
66
|
+
| showSearchLimit | `number` | required | Minimum option count before the search input renders. |
|
|
67
|
+
|
|
68
|
+
`Filters.MultiTreeSelectFilter` uses the same prop surface as `Filters.MultiSelectFilter` and also accepts all `MenuProps` except `children`.
|
|
69
|
+
|
|
70
|
+
### Filters.Clear Props
|
|
71
|
+
|
|
72
|
+
`Filters.Clear` inherits `TextButtonProps`.
|
|
73
|
+
|
|
74
|
+
### Filters.Chips Props
|
|
75
|
+
|
|
76
|
+
`Filters.Chips` inherits `Omit<ChipListProps, 'chips'>`.
|
|
77
|
+
|
|
78
|
+
## Examples
|
|
79
|
+
|
|
80
|
+
### Basic Usage
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import { Filters } from '@redislabsdev/redis-ui-components';
|
|
84
|
+
import { useArgState } from '../../helpers/useArgState';
|
|
85
|
+
|
|
86
|
+
function Render(args) {
|
|
87
|
+
const [activeFilters, setActiveFilters] = useArgState({
|
|
88
|
+
arg: args.activeFilters,
|
|
89
|
+
event: args.onChange,
|
|
90
|
+
getNewState: (_, [value]) => value
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
return <Filters {...args} activeFilters={activeFilters} onChange={setActiveFilters} />;
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Controlled
|
|
98
|
+
|
|
99
|
+
> Filters work in controlled mode only.<br/>
|
|
100
|
+
> Component requires array of filters with type and options `availableFilters`,
|
|
101
|
+
> selected filter values `activeFilters`,
|
|
102
|
+
> and `onChange` handler to update selection
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import { useState } from 'react';
|
|
106
|
+
import { Filters } from '@redislabsdev/redis-ui-components';
|
|
107
|
+
import { availableFilters, defaultFilters } from './FiltersStory.data';
|
|
108
|
+
|
|
109
|
+
function Render() {
|
|
110
|
+
const [activeFilters, setActiveFilters] = useState(defaultFilters);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<Filters
|
|
114
|
+
availableFilters={availableFilters}
|
|
115
|
+
activeFilters={activeFilters}
|
|
116
|
+
onChange={setActiveFilters}
|
|
117
|
+
/>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Composition
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
import { useState } from 'react';
|
|
126
|
+
import { Filters } from '@redislabsdev/redis-ui-components';
|
|
127
|
+
import { availableFilters, defaultFilters } from './FiltersStory.data';
|
|
128
|
+
|
|
129
|
+
function Render() {
|
|
130
|
+
const [activeFilters, setActiveFilters] = useState(defaultFilters);
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<Filters.Compose
|
|
134
|
+
availableFilters={availableFilters}
|
|
135
|
+
activeFilters={activeFilters}
|
|
136
|
+
onChange={setActiveFilters}
|
|
137
|
+
>
|
|
138
|
+
<div style={{ display: 'flex', gap: '15px', alignItems: 'center', padding: '5px 0' }}>
|
|
139
|
+
<Filters.FiltersContainer>
|
|
140
|
+
{availableFilters.map((filter) => {
|
|
141
|
+
const FilterComponent =
|
|
142
|
+
filter.type === 'MultiTreeSelect'
|
|
143
|
+
? Filters.MultiTreeSelectFilter
|
|
144
|
+
: Filters.MultiSelectFilter;
|
|
145
|
+
|
|
146
|
+
return <FilterComponent key={filter.key} filter={filter} showSearchLimit={7} />;
|
|
147
|
+
})}
|
|
148
|
+
</Filters.FiltersContainer>
|
|
149
|
+
<Filters.Clear />
|
|
150
|
+
</div>
|
|
151
|
+
<Filters.Chips />
|
|
152
|
+
</Filters.Compose>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Notes
|
|
158
|
+
|
|
159
|
+
- `Filters` works in controlled mode only.
|
|
160
|
+
- `showSearchLimit` defaults to `7` and controls when a search input appears inside a filter menu.
|
|
161
|
+
- `Filters.Clear` clears the current selection and is disabled when there are no active filters.
|
|
162
|
+
- `Filters.Chips` derives chip labels from the active filters and caps the chip list at two rows.
|