@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,213 @@
|
|
|
1
|
+
# SearchInput
|
|
2
|
+
|
|
3
|
+
Composable search input with validation, reset, loading, and `FormField` support.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { SearchInput } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> If the component uses icons in examples, also note:
|
|
12
|
+
> ```tsx
|
|
13
|
+
> import { SearchIcon } from '@redislabsdev/redis-ui-icons';
|
|
14
|
+
> ```
|
|
15
|
+
|
|
16
|
+
## Props
|
|
17
|
+
|
|
18
|
+
| Prop | Type | Default | Description |
|
|
19
|
+
|------|------|---------|-------------|
|
|
20
|
+
| id | `string` | - | Shared id for the compose wrapper and the inner input. |
|
|
21
|
+
| variant | `'outline' \| 'underline'` | `'outline'` | Visual style for the input wrapper. |
|
|
22
|
+
| error | `ReactElement \| string` | - | Error content shown in the status tooltip. |
|
|
23
|
+
| valid | `boolean` | - | Enables the success state. |
|
|
24
|
+
| value | `string` | - | Controlled search value. |
|
|
25
|
+
| defaultValue | `string` | - | Uncontrolled initial search value. |
|
|
26
|
+
| onChange | `(value: string) => void` | - | Called when the search value changes. |
|
|
27
|
+
| autoSize | `boolean` | `false` | Makes the inner input size itself to the current value. |
|
|
28
|
+
| loading | `boolean` | `false` | Shows the inline loading indicator. |
|
|
29
|
+
| allowReset | `boolean` | `true` | Shows the reset button when a value is present. |
|
|
30
|
+
|
|
31
|
+
The component also accepts standard `input` attributes on the inner tag via `RestInputProps`, excluding `children`, `defaultValue`, `value`, `onChange`, and `readOnly`.
|
|
32
|
+
|
|
33
|
+
## Sub-components
|
|
34
|
+
|
|
35
|
+
- `SearchInput.Compose` - Compose wrapper used for custom layouts around the search field.
|
|
36
|
+
- `SearchInput.Tag` - The underlying input element. Supports `autoSize`.
|
|
37
|
+
- `SearchInput.ResetButton` - Clear/reset action button shown when a value is present.
|
|
38
|
+
- `SearchInput.StatusIndicator` - Error/success indicator with tooltip support for errors.
|
|
39
|
+
- `SearchInput.LoadingIndicator` - Inline loading spinner shown while `loading` is true.
|
|
40
|
+
- `SearchInput.SearchIcon` - Leading search icon rendered with the component theme color.
|
|
41
|
+
|
|
42
|
+
## Examples
|
|
43
|
+
|
|
44
|
+
### Playground
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import { SearchInput } from '@redislabsdev/redis-ui-components';
|
|
48
|
+
|
|
49
|
+
<SearchInput placeholder="SearchInput" type="text" id="custom-id" disabled={false} />
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Status
|
|
53
|
+
|
|
54
|
+
> Adding `valid` prop enables valid status.
|
|
55
|
+
>
|
|
56
|
+
> Adding some text to the `error` prop of `SearchInput` enables error status. Hover the error indicator to see the message in a tooltip.
|
|
57
|
+
>
|
|
58
|
+
> Error status overrides valid status.
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
<>
|
|
62
|
+
Valid status
|
|
63
|
+
<SearchInput placeholder="Search Input" valid />
|
|
64
|
+
Error status
|
|
65
|
+
<SearchInput placeholder="Search Input" error="Error message" />
|
|
66
|
+
</>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### ResetButton
|
|
70
|
+
|
|
71
|
+
> `SearchInput` allows users to clean the value. The reset button is enabled by default. Set `allowReset` to `false` to hide it.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
<SearchInput placeholder="Search Input" defaultValue="orange" allowReset />
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Disabled
|
|
78
|
+
|
|
79
|
+
> Adding the `disabled` prop switches the component into disabled state.
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
<>
|
|
83
|
+
Disabled
|
|
84
|
+
<SearchInput disabled />
|
|
85
|
+
Disabled with value
|
|
86
|
+
<SearchInput disabled defaultValue="orange" />
|
|
87
|
+
Disabled with indicators
|
|
88
|
+
<SearchInput disabled defaultValue="banana" error="Error message" allowReset />
|
|
89
|
+
</>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### WithLabel
|
|
93
|
+
|
|
94
|
+
> `SearchInput` does not have its own label or other external decoration elements.
|
|
95
|
+
>
|
|
96
|
+
> Use `FormField` for those cases. If a custom id is specified, `FormField` inherits it; otherwise the label is connected automatically via a generated id.
|
|
97
|
+
>
|
|
98
|
+
> Custom ids must start with a letter to work correctly.
|
|
99
|
+
>
|
|
100
|
+
> `FormField` also inherits status and some states from the input.
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import { FormField, SearchInput } from '@redislabsdev/redis-ui-components';
|
|
104
|
+
|
|
105
|
+
<>
|
|
106
|
+
<FormField label="FormField Label with custom id">
|
|
107
|
+
<SearchInput placeholder="Search Input" id="custom-id" />
|
|
108
|
+
</FormField>
|
|
109
|
+
<FormField
|
|
110
|
+
label="FormField Label with auto-generated id"
|
|
111
|
+
additionalText="FormField additional text"
|
|
112
|
+
>
|
|
113
|
+
<SearchInput placeholder="Search Input" />
|
|
114
|
+
</FormField>
|
|
115
|
+
</>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Variants
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import { FormField, SearchInput } from '@redislabsdev/redis-ui-components';
|
|
122
|
+
|
|
123
|
+
<>
|
|
124
|
+
<FormField label="Outline (default)" additionalText="outline">
|
|
125
|
+
<SearchInput placeholder="Search Input" />
|
|
126
|
+
</FormField>
|
|
127
|
+
<FormField label="Underline" additionalText="underline">
|
|
128
|
+
<SearchInput placeholder="Search Input" variant="underline" />
|
|
129
|
+
</FormField>
|
|
130
|
+
</>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### AutoSize
|
|
134
|
+
|
|
135
|
+
> Regular text input ignores `width: auto`.
|
|
136
|
+
>
|
|
137
|
+
> Add `autoSize` to make the search input grow with its content.
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
<>
|
|
141
|
+
Type text in the input boxes to see how it auto-sizes
|
|
142
|
+
<SearchInput autoSize placeholder="placeholder" />
|
|
143
|
+
Input without placeholder:
|
|
144
|
+
<SearchInput autoSize defaultValue="edit value" />
|
|
145
|
+
</>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### ComposeInputWithButton
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import { useState, type KeyboardEvent } from 'react';
|
|
152
|
+
import { ActionIconButton, FormField, SearchInput } from '@redislabsdev/redis-ui-components';
|
|
153
|
+
import { SearchIcon } from '@redislabsdev/redis-ui-icons';
|
|
154
|
+
|
|
155
|
+
function Render() {
|
|
156
|
+
const [token, setToken] = useState('');
|
|
157
|
+
const [loading, setLoading] = useState(false);
|
|
158
|
+
|
|
159
|
+
const search = () => {
|
|
160
|
+
setLoading(true);
|
|
161
|
+
setTimeout(() => {
|
|
162
|
+
setLoading(false);
|
|
163
|
+
// eslint-disable-next-line no-alert
|
|
164
|
+
alert(`Search for "${token}" was successful`);
|
|
165
|
+
}, 1000);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const onKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
|
169
|
+
if (token && e.key.toLowerCase() === 'enter') {
|
|
170
|
+
search();
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<FormField
|
|
176
|
+
label="Search"
|
|
177
|
+
additionalText="Enter search token and press Enter or click Search button"
|
|
178
|
+
>
|
|
179
|
+
<SearchInput.Compose
|
|
180
|
+
id="token_input"
|
|
181
|
+
value={token}
|
|
182
|
+
onChange={(newValue) => {
|
|
183
|
+
setToken(newValue);
|
|
184
|
+
}}
|
|
185
|
+
>
|
|
186
|
+
<SearchInput.Tag onKeyDown={onKeyDown} autoComplete="off" disabled={loading} />
|
|
187
|
+
<SearchInput.ResetButton />
|
|
188
|
+
<SearchInput.LoadingIndicator loading={loading} />
|
|
189
|
+
{!loading && (
|
|
190
|
+
<ActionIconButton
|
|
191
|
+
size="M"
|
|
192
|
+
disabled={!token}
|
|
193
|
+
icon={SearchIcon}
|
|
194
|
+
variant="secondary"
|
|
195
|
+
onClick={search}
|
|
196
|
+
/>
|
|
197
|
+
)}
|
|
198
|
+
</SearchInput.Compose>
|
|
199
|
+
</FormField>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Notes
|
|
205
|
+
|
|
206
|
+
- `error` enables the error state, and error state overrides `valid`.
|
|
207
|
+
- `allowReset` is enabled by default for `SearchInput`.
|
|
208
|
+
- `SearchInput` does not expose the `readOnly`, `parser`, or `formatter` API from `Input`.
|
|
209
|
+
- Use `FormField` when you need a label or other external decoration around the search input.
|
|
210
|
+
- Custom ids passed through `FormField` must start with a letter.
|
|
211
|
+
- `autoSize` is required when you want the search input to grow with its contents.
|
|
212
|
+
- Use `SearchInput.Compose` when you need custom layouts around the search field, such as placing a button beside it.
|
|
213
|
+
- The component forwards refs to the underlying input element.
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
# Section
|
|
2
|
+
|
|
3
|
+
Composable section container with a header, optional collapsible body, and optional summary bar.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Section } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
### `Section`
|
|
14
|
+
|
|
15
|
+
| Prop | Type | Default | Description |
|
|
16
|
+
|------|------|---------|-------------|
|
|
17
|
+
| label | `string` | required | Header label text |
|
|
18
|
+
| actions | `ReactNode` | - | Header action content rendered on the right |
|
|
19
|
+
| content | `ReactNode` | - | Main section body content |
|
|
20
|
+
| summary | `ReactNode` | - | Summary content shown when the section is collapsed |
|
|
21
|
+
| summaryAlwaysVisible | `boolean` | `false` | Keep the summary bar visible even when the section is open |
|
|
22
|
+
|
|
23
|
+
`Section` also accepts the compose-state props from `Section.Compose` through the underlying root container.
|
|
24
|
+
|
|
25
|
+
### `Section.Compose`
|
|
26
|
+
|
|
27
|
+
| Prop | Type | Default | Description |
|
|
28
|
+
|------|------|---------|-------------|
|
|
29
|
+
| children | `ReactNode` | required | Custom section layout built from the compound sub-components |
|
|
30
|
+
| defaultOpen | `boolean` | - | Initial open state |
|
|
31
|
+
| open | `boolean` | - | Controlled open state |
|
|
32
|
+
| onOpenChange | `(open: boolean) => void` | - | Open state change handler |
|
|
33
|
+
| disabled | `boolean` | `false` | Disable the collapsible root |
|
|
34
|
+
| collapsible | `boolean` | `false` | Enable collapse and expand behavior |
|
|
35
|
+
| className, style, id, data-* and other HTML attributes | `ComposeElementProps` | - | Standard container attributes inherited from the compose root |
|
|
36
|
+
|
|
37
|
+
### `Section.Header`
|
|
38
|
+
|
|
39
|
+
| Prop | Type | Default | Description |
|
|
40
|
+
|------|------|---------|-------------|
|
|
41
|
+
| label | `string` | required | Header title text |
|
|
42
|
+
| actions | `ReactNode` | - | Header actions rendered in the trailing slot |
|
|
43
|
+
|
|
44
|
+
`Section.Header` is a convenience wrapper around `Section.Header.Compose`, `Section.Header.Label`, `Section.Header.Group`, and `Section.Header.CollapseButton`.
|
|
45
|
+
|
|
46
|
+
### `Section.Header.Compose`
|
|
47
|
+
|
|
48
|
+
| Prop | Type | Default | Description |
|
|
49
|
+
|------|------|---------|-------------|
|
|
50
|
+
| children | `ReactNode` | required | Custom header layout |
|
|
51
|
+
| className, style, id, data-* and other HTML attributes | `ComposeElementProps` | - | Standard container attributes inherited from the header compose root |
|
|
52
|
+
|
|
53
|
+
### `Section.Header.Label`
|
|
54
|
+
|
|
55
|
+
| Prop | Type | Default | Description |
|
|
56
|
+
|------|------|---------|-------------|
|
|
57
|
+
| label | `string` | required | Header title text |
|
|
58
|
+
| other heading props | `TypographyHeadingProps` without `children` and `id` | - | Standard heading props inherited from the typography component |
|
|
59
|
+
|
|
60
|
+
### `Section.Header.CollapseButton`
|
|
61
|
+
|
|
62
|
+
| Prop | Type | Default | Description |
|
|
63
|
+
|------|------|---------|-------------|
|
|
64
|
+
| hidden | `boolean` | `false` | Visually hide the collapse trigger while keeping it accessible |
|
|
65
|
+
| icon | `IconType` | `ChevronDownIcon` | Custom icon used for the collapse toggle |
|
|
66
|
+
| other icon button props | `IconButtonProps` without `id` and `icon` | - | Standard icon button props inherited from `IconButton` |
|
|
67
|
+
|
|
68
|
+
### `Section.Header.Group`
|
|
69
|
+
|
|
70
|
+
| Prop | Type | Default | Description |
|
|
71
|
+
|------|------|---------|-------------|
|
|
72
|
+
| children | `ReactNode` | required | Grouped header content |
|
|
73
|
+
| className, style, id, data-* and other HTML attributes | `ComposeElementProps` | - | Standard layout attributes for the group container |
|
|
74
|
+
|
|
75
|
+
### `Section.Body`
|
|
76
|
+
|
|
77
|
+
| Prop | Type | Default | Description |
|
|
78
|
+
|------|------|---------|-------------|
|
|
79
|
+
| children | `ReactNode` | required | Section body content |
|
|
80
|
+
| className, style, id, data-* and other HTML attributes | `ComposeElementProps` | - | Standard body container attributes |
|
|
81
|
+
|
|
82
|
+
### `Section.SummaryBar`
|
|
83
|
+
|
|
84
|
+
| Prop | Type | Default | Description |
|
|
85
|
+
|------|------|---------|-------------|
|
|
86
|
+
| children | `ReactNode` | required | Summary content rendered in the footer bar |
|
|
87
|
+
| alwaysVisible | `boolean` | `false` | Keep the summary visible even when the section is open |
|
|
88
|
+
| className, style, id, data-* and other HTML attributes | `HTMLAttributes<HTMLElement>` | - | Standard summary bar attributes |
|
|
89
|
+
|
|
90
|
+
### `CategoryValueList`
|
|
91
|
+
|
|
92
|
+
| Prop | Type | Default | Description |
|
|
93
|
+
|------|------|---------|-------------|
|
|
94
|
+
| categoryValueList | `CategoryValueListItem[]` | required | Category/value pairs rendered as compact summary chips |
|
|
95
|
+
|
|
96
|
+
## Sub-components
|
|
97
|
+
|
|
98
|
+
- `Section.Compose` - Collapsible root container used for custom section composition.
|
|
99
|
+
- `Section.Header` - Convenience header wrapper that renders the default header structure.
|
|
100
|
+
- `Section.Header.Compose` - Header layout container for custom compositions.
|
|
101
|
+
- `Section.Header.Label` - Title label that links to the collapse trigger when the section is collapsible.
|
|
102
|
+
- `Section.Header.ActionButton` - Alias of `TextButton` for header actions.
|
|
103
|
+
- `Section.Header.CollapseButton` - Accessible collapse and expand trigger.
|
|
104
|
+
- `Section.Header.Group` - Flex group for splitting header content across opposite sides.
|
|
105
|
+
- `Section.Body` - Section body region.
|
|
106
|
+
- `Section.SummaryBar` - Summary strip shown in collapsed state.
|
|
107
|
+
- `CategoryValueList` - Helper export for summary bars that display category/value pairs.
|
|
108
|
+
|
|
109
|
+
## Examples
|
|
110
|
+
|
|
111
|
+
### Playground
|
|
112
|
+
|
|
113
|
+
> Default story showing the root `Section` API with a label, body content, actions, summary, and collapsible state enabled.
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
import { Section, TextButton } from '@redislabsdev/redis-ui-components';
|
|
117
|
+
|
|
118
|
+
<Section
|
|
119
|
+
label="Section Label"
|
|
120
|
+
content="Section content"
|
|
121
|
+
actions={<TextButton>Action Button</TextButton>}
|
|
122
|
+
summary="Summary"
|
|
123
|
+
collapsible
|
|
124
|
+
defaultOpen
|
|
125
|
+
/>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### StaticallyExpanded
|
|
129
|
+
|
|
130
|
+
> If `content` is provided and `collapsible` is not enabled, the section stays statically expanded.
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
import { Section, TextButton } from '@redislabsdev/redis-ui-components';
|
|
134
|
+
|
|
135
|
+
<Section
|
|
136
|
+
label="Statically expanded (non-collapsible)"
|
|
137
|
+
content="Section content"
|
|
138
|
+
actions={<TextButton>Action Button</TextButton>}
|
|
139
|
+
/>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Collapsible
|
|
143
|
+
|
|
144
|
+
> Collapsed state changes only work when both `content` and `collapsible` are set.
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import { Section, TextButton } from '@redislabsdev/redis-ui-components';
|
|
148
|
+
|
|
149
|
+
<Section
|
|
150
|
+
label="Collapsible (initially openened)"
|
|
151
|
+
content="Section content"
|
|
152
|
+
actions={<TextButton>Action Button</TextButton>}
|
|
153
|
+
collapsible
|
|
154
|
+
defaultOpen
|
|
155
|
+
/>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### ControlledCollapsible
|
|
159
|
+
|
|
160
|
+
> Use `open` and `onOpenChange` to control the collapsed and expanded states.
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
import { useState } from 'react';
|
|
164
|
+
import { Section } from '@redislabsdev/redis-ui-components';
|
|
165
|
+
|
|
166
|
+
function Example() {
|
|
167
|
+
const [open, setOpen] = useState(true);
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
<Section
|
|
171
|
+
open={open}
|
|
172
|
+
onOpenChange={setOpen}
|
|
173
|
+
label="Controlled Collapsible (initially opened)"
|
|
174
|
+
content="Section content"
|
|
175
|
+
collapsible
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### SimpleSummary
|
|
182
|
+
|
|
183
|
+
> `summary` can be a simple string and is visible only when the section is collapsed.
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
import { Section, TextButton } from '@redislabsdev/redis-ui-components';
|
|
187
|
+
|
|
188
|
+
<Section
|
|
189
|
+
label="Collapsible with Summary"
|
|
190
|
+
content="Section content"
|
|
191
|
+
actions={<TextButton>Action Button</TextButton>}
|
|
192
|
+
collapsible
|
|
193
|
+
summary="Summary"
|
|
194
|
+
/>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### CustomSummary
|
|
198
|
+
|
|
199
|
+
> `summary` can render any React node.
|
|
200
|
+
|
|
201
|
+
```tsx
|
|
202
|
+
import { Section, ChipList, TextButton } from '@redislabsdev/redis-ui-components';
|
|
203
|
+
import { StoryHList } from '../../helpers/Story.style';
|
|
204
|
+
import * as S from './Section.style';
|
|
205
|
+
|
|
206
|
+
const chips = [
|
|
207
|
+
{ label: 'Chip 1', key: '1' },
|
|
208
|
+
{ label: 'Chip 2', key: '2' },
|
|
209
|
+
{ label: 'Chip 3', key: '3' }
|
|
210
|
+
];
|
|
211
|
+
|
|
212
|
+
<Section
|
|
213
|
+
label="Collapsible with custom Summary"
|
|
214
|
+
content="Section content"
|
|
215
|
+
actions={<TextButton>Action Button</TextButton>}
|
|
216
|
+
collapsible
|
|
217
|
+
summary={
|
|
218
|
+
<StoryHList>
|
|
219
|
+
<div style={{ width: '250px' }}>
|
|
220
|
+
<ChipList chips={chips} />
|
|
221
|
+
</div>
|
|
222
|
+
<S.TypographyBody>Summary bar</S.TypographyBody>
|
|
223
|
+
</StoryHList>
|
|
224
|
+
}
|
|
225
|
+
/>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### SummaryAlwaysVisible
|
|
229
|
+
|
|
230
|
+
> `summaryAlwaysVisible` keeps the summary bar visible even when the section is open.
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
import { Section, TextButton } from '@redislabsdev/redis-ui-components';
|
|
234
|
+
|
|
235
|
+
<Section
|
|
236
|
+
label="Collapsible with always visible Summary"
|
|
237
|
+
content="Section content"
|
|
238
|
+
actions={<TextButton>Action Button</TextButton>}
|
|
239
|
+
collapsible
|
|
240
|
+
defaultOpen
|
|
241
|
+
summary="Always visible Summary"
|
|
242
|
+
summaryAlwaysVisible
|
|
243
|
+
/>
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### WithoutContentWithSummary
|
|
247
|
+
|
|
248
|
+
> If `content` is missing, the section stays collapsed and the summary remains visible.
|
|
249
|
+
>
|
|
250
|
+
> If `collapsible` is not set, the summary background matches the content background.
|
|
251
|
+
|
|
252
|
+
```tsx
|
|
253
|
+
import { Section, TextButton } from '@redislabsdev/redis-ui-components';
|
|
254
|
+
|
|
255
|
+
<>
|
|
256
|
+
<Section
|
|
257
|
+
label="Collapsible with Summary & without Content"
|
|
258
|
+
actions={<TextButton>Action Button</TextButton>}
|
|
259
|
+
summary="Summary"
|
|
260
|
+
collapsible
|
|
261
|
+
/>
|
|
262
|
+
<Section
|
|
263
|
+
label="Non-Collapsible with Summary & without Content"
|
|
264
|
+
actions={<TextButton>Action Button</TextButton>}
|
|
265
|
+
summary="Summary"
|
|
266
|
+
/>
|
|
267
|
+
</>
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### SummaryWithCategoryValueList
|
|
271
|
+
|
|
272
|
+
> Use `CategoryValueList` for category-value pair summaries.
|
|
273
|
+
|
|
274
|
+
```tsx
|
|
275
|
+
import { CategoryValueList, Label, Section, TextButton } from '@redislabsdev/redis-ui-components';
|
|
276
|
+
|
|
277
|
+
const categoryValueList = [
|
|
278
|
+
{ category: 'Category 1', value: 'Value 1', key: '1' },
|
|
279
|
+
{ category: 'Category 2', value: 'Value 2', key: '2' },
|
|
280
|
+
{ category: 'Category 3', value: 'Value 3', key: '3' },
|
|
281
|
+
{ category: 'Category 4', value: 'Value 4', key: '4' },
|
|
282
|
+
{ category: 'Category 5', value: 'Value 5', key: '5' }
|
|
283
|
+
];
|
|
284
|
+
|
|
285
|
+
<Section
|
|
286
|
+
label="Collapsible with Summary as Category-Value pairs"
|
|
287
|
+
actions={<TextButton>Action Button</TextButton>}
|
|
288
|
+
collapsible
|
|
289
|
+
summary={<CategoryValueList categoryValueList={categoryValueList} />}
|
|
290
|
+
content={
|
|
291
|
+
<>
|
|
292
|
+
{categoryValueList.map(({ category, value }) => (
|
|
293
|
+
<div key={category}>
|
|
294
|
+
<Label label={category} />
|
|
295
|
+
<Label label={value} />
|
|
296
|
+
</div>
|
|
297
|
+
))}
|
|
298
|
+
</>
|
|
299
|
+
}
|
|
300
|
+
/>
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Composition
|
|
304
|
+
|
|
305
|
+
> `Section` and `Section.Header` are composable.
|
|
306
|
+
>
|
|
307
|
+
> Use `Header.Group` to split header content into opposite-side groups.
|
|
308
|
+
>
|
|
309
|
+
> Use `Header.Label` for the title, `Header.CollapseButton` for the toggle arrow, and `Header.ActionButton` for one or more actions.
|
|
310
|
+
|
|
311
|
+
```tsx
|
|
312
|
+
import { Badge, Button, Checkbox, Label, Section } from '@redislabsdev/redis-ui-components';
|
|
313
|
+
import { StoryHList } from '../../helpers/Story.style';
|
|
314
|
+
|
|
315
|
+
<Section.Compose collapsible>
|
|
316
|
+
<Section.Header.Compose>
|
|
317
|
+
<Section.Header.Group>
|
|
318
|
+
<StoryHList>
|
|
319
|
+
<Section.Header.CollapseButton />
|
|
320
|
+
<Checkbox onClick={(e) => e.stopPropagation()} />
|
|
321
|
+
<Label
|
|
322
|
+
infoIconProps={{ content: 'Info tooltip' }}
|
|
323
|
+
label={<Section.Header.Label label="Custom Label" style={{ lineHeight: 'unset' }} />}
|
|
324
|
+
style={{ margin: 0 }}
|
|
325
|
+
/>
|
|
326
|
+
<Badge label="Badge" />
|
|
327
|
+
</StoryHList>
|
|
328
|
+
</Section.Header.Group>
|
|
329
|
+
<Section.Header.Group>
|
|
330
|
+
<Button variant="secondary-ghost">Action 1</Button>
|
|
331
|
+
<Button variant="secondary-fill">Action 2</Button>
|
|
332
|
+
</Section.Header.Group>
|
|
333
|
+
</Section.Header.Compose>
|
|
334
|
+
<Section.Body>Section content</Section.Body>
|
|
335
|
+
<Section.SummaryBar>Summary</Section.SummaryBar>
|
|
336
|
+
</Section.Compose>
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## Notes
|
|
340
|
+
|
|
341
|
+
- `Section` is statically expanded when `content` is present and `collapsible` is not enabled.
|
|
342
|
+
- Toggling collapsed state only works when both `content` and `collapsible` are set.
|
|
343
|
+
- Use `open` and `onOpenChange` for controlled collapse behavior.
|
|
344
|
+
- `summary` can be either a string or any React node.
|
|
345
|
+
- `summaryAlwaysVisible` keeps the summary visible while the section is open.
|
|
346
|
+
- If `content` is missing, the section remains collapsed and still shows the summary.
|
|
347
|
+
- If `collapsible` is not set, the summary background matches the content background.
|
|
348
|
+
- `Section.Header.Label`, `Section.Header.CollapseButton`, and `Section.Header.ActionButton` are the intended building blocks for custom headers.
|
|
349
|
+
- `CategoryValueList` is exported alongside `Section` and is useful for compact summary bars with category/value pairs.
|