@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,214 @@
|
|
|
1
|
+
# Breadcrumbs
|
|
2
|
+
|
|
3
|
+
A breadcrumb navigation component that renders a trail of items with a default separator, controlled navigation callbacks, and a compound composition API for custom layouts.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Breadcrumbs } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> The composition example also uses icons from `@redislabsdev/redis-ui-icons`:
|
|
12
|
+
> ```tsx
|
|
13
|
+
> import { ChevronRightIcon } from '@redislabsdev/redis-ui-icons';
|
|
14
|
+
> ```
|
|
15
|
+
|
|
16
|
+
## Props
|
|
17
|
+
|
|
18
|
+
| Prop | Type | Default | Description |
|
|
19
|
+
|------|------|---------|-------------|
|
|
20
|
+
| items | `BreadcrumbItem[]` | - | Breadcrumb entries rendered from left to right. Each item can provide `label`, optional `href`, and optional `onClick`; the last item is rendered as the current page. |
|
|
21
|
+
| separator | `ReactNode` | `'/'` | Separator rendered between breadcrumb items. |
|
|
22
|
+
| aria-label | `string` | `'Breadcrumb'` | Accessible label for the breadcrumb navigation landmark. |
|
|
23
|
+
| compose wrapper props | `ComposeElementProps<HTMLElement>` | - | Additional props passed to the underlying `<nav>` element, excluding `children`. |
|
|
24
|
+
|
|
25
|
+
## Sub-components
|
|
26
|
+
|
|
27
|
+
- `Breadcrumbs.Compose` - Navigation wrapper that renders the semantic breadcrumb `<nav>`.
|
|
28
|
+
- `Breadcrumbs.List` - Ordered list container for breadcrumb items.
|
|
29
|
+
- `Breadcrumbs.Item` - List item wrapper used to structure breadcrumb entries and separators.
|
|
30
|
+
- `Breadcrumbs.Link` - Interactive breadcrumb link that supports `href`, `onClick`, and `disabled`.
|
|
31
|
+
- `Breadcrumbs.Separator` - Separator element rendered between items, hidden from screen readers by default.
|
|
32
|
+
- `Breadcrumbs.Current` - Current page marker rendered with `aria-current="page"`.
|
|
33
|
+
|
|
34
|
+
### Breadcrumbs.Compose Props
|
|
35
|
+
|
|
36
|
+
| Prop | Type | Default | Description |
|
|
37
|
+
|------|------|---------|-------------|
|
|
38
|
+
| aria-label | `string` | `'Breadcrumb'` | Accessible label for the breadcrumb navigation landmark. |
|
|
39
|
+
| compose wrapper props | `ComposeElementProps<HTMLElement>` | - | Additional props passed to the underlying `<nav>` element. |
|
|
40
|
+
|
|
41
|
+
### Breadcrumbs.List Props
|
|
42
|
+
|
|
43
|
+
| Prop | Type | Default | Description |
|
|
44
|
+
|------|------|---------|-------------|
|
|
45
|
+
| list props | `ComposeElementProps<HTMLOListElement>` | - | Additional props passed to the underlying ordered list. |
|
|
46
|
+
|
|
47
|
+
### Breadcrumbs.Item Props
|
|
48
|
+
|
|
49
|
+
| Prop | Type | Default | Description |
|
|
50
|
+
|------|------|---------|-------------|
|
|
51
|
+
| item props | `ComposeElementProps<HTMLLIElement>` | - | Additional props passed to the underlying list item. |
|
|
52
|
+
|
|
53
|
+
### Breadcrumbs.Link Props
|
|
54
|
+
|
|
55
|
+
| Prop | Type | Default | Description |
|
|
56
|
+
|------|------|---------|-------------|
|
|
57
|
+
| children | `ReactNode` | - | Link label or custom content. |
|
|
58
|
+
| disabled | `boolean` | `false` | Disables the link and removes it from the tab order. |
|
|
59
|
+
| link props | `Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'onKeyDown'>` | - | Additional anchor props passed to the breadcrumb link. |
|
|
60
|
+
|
|
61
|
+
### Breadcrumbs.Separator Props
|
|
62
|
+
|
|
63
|
+
| Prop | Type | Default | Description |
|
|
64
|
+
|------|------|---------|-------------|
|
|
65
|
+
| children | `ReactNode` | `'/'` | Custom separator content. |
|
|
66
|
+
| separator props | `HTMLAttributes<HTMLSpanElement>` | - | Additional props passed to the separator span. |
|
|
67
|
+
|
|
68
|
+
### Breadcrumbs.Current Props
|
|
69
|
+
|
|
70
|
+
| Prop | Type | Default | Description |
|
|
71
|
+
|------|------|---------|-------------|
|
|
72
|
+
| children | `ReactNode` | - | Label or content for the current page. |
|
|
73
|
+
| current props | `HTMLAttributes<HTMLSpanElement>` | - | Additional props passed to the current page span. |
|
|
74
|
+
|
|
75
|
+
## Examples
|
|
76
|
+
|
|
77
|
+
### Playground
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { Breadcrumbs } from '@redislabsdev/redis-ui-components';
|
|
81
|
+
|
|
82
|
+
<Breadcrumbs
|
|
83
|
+
items={[
|
|
84
|
+
{ label: 'Home', onClick: () => {} },
|
|
85
|
+
{ label: 'Products', onClick: () => {} },
|
|
86
|
+
{ label: 'Category', onClick: () => {} },
|
|
87
|
+
{ label: 'Current Page' }
|
|
88
|
+
]}
|
|
89
|
+
separator="/"
|
|
90
|
+
/>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Basic
|
|
94
|
+
|
|
95
|
+
> Basic breadcrumbs with default separator. Click on breadcrumb items to navigate.
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { useState } from 'react';
|
|
99
|
+
import { Breadcrumbs } from '@redislabsdev/redis-ui-components';
|
|
100
|
+
|
|
101
|
+
function ControlledBreadcrumbExample() {
|
|
102
|
+
const [currentPath, setCurrentPath] = useState<string[]>(['Home', 'Products', 'Current Page']);
|
|
103
|
+
|
|
104
|
+
const handleClick = (index: number) => {
|
|
105
|
+
setCurrentPath(currentPath.slice(0, index + 1));
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<Breadcrumbs
|
|
110
|
+
items={currentPath.map((label, index) => ({
|
|
111
|
+
label,
|
|
112
|
+
onClick: index < currentPath.length - 1 ? () => handleClick(index) : undefined
|
|
113
|
+
}))}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Composition
|
|
120
|
+
|
|
121
|
+
> Use composition pattern for full control over rendering, including Select components.
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { useState } from 'react';
|
|
125
|
+
import { Breadcrumbs, Select, SelectOption, TextButton } from '@redislabsdev/redis-ui-components';
|
|
126
|
+
import { ChevronRightIcon } from '@redislabsdev/redis-ui-icons';
|
|
127
|
+
import styled from 'styled-components';
|
|
128
|
+
import { useTheme } from '@redislabsdev/redis-ui-styles';
|
|
129
|
+
|
|
130
|
+
const categoryOptions: SelectOption[] = [
|
|
131
|
+
{ value: 'electronics', label: 'Electronics' },
|
|
132
|
+
{ value: 'clothing', label: 'Clothing' },
|
|
133
|
+
{ value: 'books', label: 'Books' },
|
|
134
|
+
{ value: 'home', label: 'Home & Garden' }
|
|
135
|
+
];
|
|
136
|
+
|
|
137
|
+
const BreadcrumbTextButton = styled(TextButton)`
|
|
138
|
+
color: ${() => useTheme().components.breadcrumbs.current.textColor};
|
|
139
|
+
font-weight: ${() => useTheme().components.breadcrumbs.current.fontWeight};
|
|
140
|
+
|
|
141
|
+
&:hover {
|
|
142
|
+
color: ${() => useTheme().components.breadcrumbs.link.states.hover?.textColor};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&:active {
|
|
146
|
+
color: ${() => useTheme().components.breadcrumbs.link.states.active?.textColor};
|
|
147
|
+
}
|
|
148
|
+
`;
|
|
149
|
+
|
|
150
|
+
function CompositionWithSelectExample() {
|
|
151
|
+
const [selectedCategory, setSelectedCategory] = useState('electronics');
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<Breadcrumbs.Compose aria-label="Breadcrumb">
|
|
155
|
+
<Breadcrumbs.List>
|
|
156
|
+
<Breadcrumbs.Item>
|
|
157
|
+
<Breadcrumbs.Link
|
|
158
|
+
onClick={() => {
|
|
159
|
+
// eslint-disable-next-line no-alert
|
|
160
|
+
alert('Navigate to Home');
|
|
161
|
+
}}
|
|
162
|
+
>
|
|
163
|
+
Home
|
|
164
|
+
</Breadcrumbs.Link>
|
|
165
|
+
</Breadcrumbs.Item>
|
|
166
|
+
<Breadcrumbs.Item>
|
|
167
|
+
<Breadcrumbs.Separator>
|
|
168
|
+
<ChevronRightIcon size="S" />
|
|
169
|
+
</Breadcrumbs.Separator>
|
|
170
|
+
</Breadcrumbs.Item>
|
|
171
|
+
<Breadcrumbs.Item>
|
|
172
|
+
<Breadcrumbs.Link
|
|
173
|
+
onClick={() => {
|
|
174
|
+
// eslint-disable-next-line no-alert
|
|
175
|
+
alert('Navigate to Products');
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
Products
|
|
179
|
+
</Breadcrumbs.Link>
|
|
180
|
+
</Breadcrumbs.Item>
|
|
181
|
+
<Breadcrumbs.Item>
|
|
182
|
+
<Breadcrumbs.Separator>
|
|
183
|
+
<ChevronRightIcon size="S" />
|
|
184
|
+
</Breadcrumbs.Separator>
|
|
185
|
+
</Breadcrumbs.Item>
|
|
186
|
+
<Breadcrumbs.Item>
|
|
187
|
+
<Select.Compose
|
|
188
|
+
options={categoryOptions}
|
|
189
|
+
value={selectedCategory}
|
|
190
|
+
onChange={(value) => setSelectedCategory(value as string)}
|
|
191
|
+
>
|
|
192
|
+
<Select.Trigger.Compose customContainer>
|
|
193
|
+
<span>
|
|
194
|
+
<BreadcrumbTextButton variant="primary-inline">
|
|
195
|
+
<Select.Trigger.Value />
|
|
196
|
+
<Select.Trigger.Arrow />
|
|
197
|
+
</BreadcrumbTextButton>
|
|
198
|
+
</span>
|
|
199
|
+
</Select.Trigger.Compose>
|
|
200
|
+
<Select.Content searchable />
|
|
201
|
+
</Select.Compose>
|
|
202
|
+
</Breadcrumbs.Item>
|
|
203
|
+
</Breadcrumbs.List>
|
|
204
|
+
</Breadcrumbs.Compose>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Notes
|
|
210
|
+
|
|
211
|
+
- Breadcrumbs render a semantic navigation trail and the last item is treated as the current page.
|
|
212
|
+
- Basic breadcrumbs use a default `/` separator, but the separator can be customized with any React node.
|
|
213
|
+
- The composition pattern is the right choice when you need full control over rendering, including nested components such as `Select`.
|
|
214
|
+
- `BreadcrumbItem` entries are `{ label, href?, onClick? }` objects; the root component renders the last entry as `Breadcrumbs.Current`.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# ButtonGroup
|
|
2
|
+
|
|
3
|
+
A grouped button container for building segmented button sets with optional icons and explicit selected states. `ButtonGroup` does not manage selection on its own, so single- and multi-select behavior is handled by the consumer.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { ButtonGroup } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> If the examples use icons, import them from `@redislabsdev/redis-ui-icons`:
|
|
12
|
+
>
|
|
13
|
+
> ```tsx
|
|
14
|
+
> import { InfoIcon, ShardIcon, StarsIcon } from '@redislabsdev/redis-ui-icons';
|
|
15
|
+
> ```
|
|
16
|
+
|
|
17
|
+
## Props
|
|
18
|
+
|
|
19
|
+
| Prop | Type | Default | Description |
|
|
20
|
+
|------|------|---------|-------------|
|
|
21
|
+
| `...div props` | `React.HTMLAttributes<HTMLDivElement>` | - | Standard `div` attributes forwarded to the wrapper. |
|
|
22
|
+
|
|
23
|
+
## Sub-components
|
|
24
|
+
|
|
25
|
+
- `ButtonGroup.Button` - Individual button inside the group. Supports selected and disabled states.
|
|
26
|
+
- `ButtonGroup.Icon` - Icon wrapper that renders a medium-sized icon in the group color.
|
|
27
|
+
|
|
28
|
+
### `ButtonGroup.Button` Props
|
|
29
|
+
|
|
30
|
+
| Prop | Type | Default | Description |
|
|
31
|
+
|------|------|---------|-------------|
|
|
32
|
+
| `isSelected` | `boolean` | - | Marks the button as selected for styling purposes. |
|
|
33
|
+
| `onClick` | `(e: React.MouseEvent<HTMLButtonElement>) => void` | - | Click handler used to toggle selection. |
|
|
34
|
+
| `children` | `React.ReactNode` | - | Button content. |
|
|
35
|
+
|
|
36
|
+
`ButtonGroup.Button` also accepts all native `button` attributes.
|
|
37
|
+
|
|
38
|
+
### `ButtonGroup.Icon` Props
|
|
39
|
+
|
|
40
|
+
| Prop | Type | Default | Description |
|
|
41
|
+
|------|------|---------|-------------|
|
|
42
|
+
| `icon` | `IconType` | required | Icon component rendered inside the button group item. |
|
|
43
|
+
|
|
44
|
+
## Examples
|
|
45
|
+
|
|
46
|
+
### SingleSelectionSimulation
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { useState } from 'react';
|
|
50
|
+
import { ButtonGroup } from '@redislabsdev/redis-ui-components';
|
|
51
|
+
import { InfoIcon, ShardIcon, StarsIcon } from '@redislabsdev/redis-ui-icons';
|
|
52
|
+
|
|
53
|
+
const items = [
|
|
54
|
+
{ value: 'item1', label: 'Button 1', icon: ShardIcon, disabled: true },
|
|
55
|
+
{ value: 'item2', label: 'Button 2', icon: StarsIcon },
|
|
56
|
+
{ value: 'item3', label: 'Button 3' }
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
const [selected, setSelected] = useState<string>(items[0].value);
|
|
60
|
+
|
|
61
|
+
const selectSingle = (value: string) => {
|
|
62
|
+
if (selected !== value) {
|
|
63
|
+
setSelected(value);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const isSelected = (value: string) => selected === value;
|
|
68
|
+
|
|
69
|
+
<ButtonGroup>
|
|
70
|
+
{items.map((item) => (
|
|
71
|
+
<ButtonGroup.Button
|
|
72
|
+
key={item.value}
|
|
73
|
+
disabled={item.disabled}
|
|
74
|
+
isSelected={isSelected(item.value)}
|
|
75
|
+
onClick={() => selectSingle(item.value)}
|
|
76
|
+
>
|
|
77
|
+
{item.icon && <ButtonGroup.Icon icon={item.icon} />}
|
|
78
|
+
{item.label || item.value}
|
|
79
|
+
<ButtonGroup.Icon icon={InfoIcon} />
|
|
80
|
+
</ButtonGroup.Button>
|
|
81
|
+
))}
|
|
82
|
+
</ButtonGroup>;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### MultiSelectionSimulation
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { useState } from 'react';
|
|
89
|
+
import { ButtonGroup } from '@redislabsdev/redis-ui-components';
|
|
90
|
+
import { InfoIcon, ShardIcon, StarsIcon } from '@redislabsdev/redis-ui-icons';
|
|
91
|
+
|
|
92
|
+
const items = [
|
|
93
|
+
{ value: 'item1', label: 'Initially selected', icon: ShardIcon },
|
|
94
|
+
{ value: 'item2', label: 'Selected-Disabled', icon: StarsIcon, disabled: true },
|
|
95
|
+
{ value: 'item3', label: 'Initially unselected' },
|
|
96
|
+
{ value: 'item4', label: 'Disabled', disabled: true }
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
const [selected, setSelected] = useState<string[]>([items[0].value, items[1].value]);
|
|
100
|
+
|
|
101
|
+
const toggleMultiSelection = (value: string) =>
|
|
102
|
+
selected.includes(value) ? selected.filter((sel) => sel !== value) : [...selected, value];
|
|
103
|
+
const isSelected = (value: string) => selected.includes(value);
|
|
104
|
+
|
|
105
|
+
<ButtonGroup>
|
|
106
|
+
{items.map((item) => (
|
|
107
|
+
<ButtonGroup.Button
|
|
108
|
+
key={item.value}
|
|
109
|
+
disabled={item.disabled}
|
|
110
|
+
isSelected={isSelected(item.value)}
|
|
111
|
+
onClick={() => setSelected(toggleMultiSelection(item.value))}
|
|
112
|
+
>
|
|
113
|
+
{item.icon && <ButtonGroup.Icon icon={item.icon} />}
|
|
114
|
+
{item.label || item.value}
|
|
115
|
+
<ButtonGroup.Icon icon={InfoIcon} />
|
|
116
|
+
</ButtonGroup.Button>
|
|
117
|
+
))}
|
|
118
|
+
</ButtonGroup>;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Notes
|
|
122
|
+
|
|
123
|
+
- `ButtonGroup` has no internal selection logic; manage selected state in the parent component.
|
|
124
|
+
- `ButtonGroup.Button` is styled as a native `button` and can be disabled through the standard `disabled` attribute.
|
|
125
|
+
- `ButtonGroup.Icon` always renders the icon at `size="M"` with `customColor="currentColor"`.
|
|
126
|
+
- If you need to pass props to an icon component, declare it outside the render path or wrap it in `useMemo`; avoid inline arrow functions because they re-create the icon on every parent render.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Card
|
|
2
|
+
|
|
3
|
+
A simple container card with configurable width and height. It renders as a flex column and uses the theme card surface styling.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Card } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
|------|------|---------|-------------|
|
|
15
|
+
| width | `number \| string` | `100%` | Overrides the card width |
|
|
16
|
+
| height | `number \| string` | `fit-content` | Overrides the card height |
|
|
17
|
+
|
|
18
|
+
The component also extends all native `React.HTMLAttributes<HTMLDivElement>` props.
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
### Playground
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { Card } from '@redislabsdev/redis-ui-components';
|
|
26
|
+
|
|
27
|
+
<Card>Content</Card>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Sizing
|
|
31
|
+
|
|
32
|
+
> If `width` is not defined, `Card` takes 100%. If `height` is not defined, `Card` fits content
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { Card } from '@redislabsdev/redis-ui-components';
|
|
36
|
+
|
|
37
|
+
<>
|
|
38
|
+
<Card>
|
|
39
|
+
<span>No width and height defined</span>
|
|
40
|
+
</Card>
|
|
41
|
+
<Card width={150} height={100}>
|
|
42
|
+
<span>width=150px;</span>
|
|
43
|
+
<span>height=100px;</span>
|
|
44
|
+
</Card>
|
|
45
|
+
<Card width="fit-content" height="fit-content">
|
|
46
|
+
<span>width=fit-content;</span>
|
|
47
|
+
<span>height=fit-content;</span>
|
|
48
|
+
</Card>
|
|
49
|
+
</>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Notes
|
|
53
|
+
|
|
54
|
+
- If `width` is not provided, the card defaults to `100%`.
|
|
55
|
+
- If `height` is not provided, the card defaults to `fit-content`.
|
|
56
|
+
- The component forwards standard `div` attributes through `React.HTMLAttributes<HTMLDivElement>`.
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Checkbox
|
|
2
|
+
|
|
3
|
+
A compound checkbox component with primary and danger variants, controlled or uncontrolled checked state, an indeterminate mode, and composable building blocks for custom layouts.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Checkbox } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
If you use the controlled example, also import `CheckedType` from the same package.
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
|
|
15
|
+
| Prop | Type | Default | Description |
|
|
16
|
+
|------|------|---------|-------------|
|
|
17
|
+
| label | `CheckboxLabelProps['children']` | - | Label content rendered next to the checkbox |
|
|
18
|
+
| defaultChecked | `boolean` | `false` | Initial uncontrolled checked state |
|
|
19
|
+
| checked | `CheckedType` | - | Controlled checked state, including `indeterminate` |
|
|
20
|
+
| onCheckedChange | `(checked: CheckedType) => void` | - | Callback fired when the checked state changes |
|
|
21
|
+
| required | `boolean` | `false` | Marks the checkbox as required |
|
|
22
|
+
| disabled | `boolean` | `false` | Disables the checkbox interaction |
|
|
23
|
+
| id | `string` | auto-generated | Shared id used by the label and indicator |
|
|
24
|
+
| variant | `'primary' \| 'danger'` | `'primary'` | Visual variant for the checkbox |
|
|
25
|
+
| readOnly | `boolean` | `false` | Renders the indicator in read-only mode |
|
|
26
|
+
| indicator button props | `Omit<HTMLAttributes<HTMLButtonElement>, 'checked' \| 'defaultChecked' \| 'defaultValue' \| 'children' \| 'color'>` | - | Additional button props forwarded to the indicator |
|
|
27
|
+
|
|
28
|
+
## Sub-components
|
|
29
|
+
|
|
30
|
+
- `Checkbox.Compose` - Provides the checkbox context and controllable state for custom layouts.
|
|
31
|
+
- `Checkbox.Indicator` - Renders the interactive checkbox control and checkmark icon.
|
|
32
|
+
- `Checkbox.Label` - Renders the label linked to the checkbox `id`.
|
|
33
|
+
|
|
34
|
+
### Checkbox.Compose Props
|
|
35
|
+
|
|
36
|
+
| Prop | Type | Default | Description |
|
|
37
|
+
|------|------|---------|-------------|
|
|
38
|
+
| defaultChecked | `boolean` | `false` | Initial uncontrolled checked state |
|
|
39
|
+
| checked | `CheckedType` | - | Controlled checked state, including `indeterminate` |
|
|
40
|
+
| onCheckedChange | `(checked: CheckedType) => void` | - | Callback fired when the checked state changes |
|
|
41
|
+
| required | `boolean` | `false` | Marks the checkbox as required |
|
|
42
|
+
| disabled | `boolean` | `false` | Disables the checkbox interaction |
|
|
43
|
+
| id | `string` | auto-generated | Shared id used by the label and indicator |
|
|
44
|
+
| variant | `'primary' \| 'danger'` | `'primary'` | Visual variant for the checkbox |
|
|
45
|
+
| compose wrapper props | `Omit<ComposeElementProps<HTMLElement>, 'onChange' \| 'defaultChecked'>` | - | Additional wrapper props applied to the compose root |
|
|
46
|
+
|
|
47
|
+
### Checkbox.Indicator Props
|
|
48
|
+
|
|
49
|
+
| Prop | Type | Default | Description |
|
|
50
|
+
|------|------|---------|-------------|
|
|
51
|
+
| readOnly | `boolean` | `false` | Renders the indicator without allowing state changes |
|
|
52
|
+
| indicator button props | `Omit<HTMLAttributes<HTMLButtonElement>, 'checked' \| 'defaultChecked' \| 'defaultValue' \| 'children' \| 'color'>` | - | Additional button props forwarded to the indicator element |
|
|
53
|
+
|
|
54
|
+
### Checkbox.Label Props
|
|
55
|
+
|
|
56
|
+
| Prop | Type | Default | Description |
|
|
57
|
+
|------|------|---------|-------------|
|
|
58
|
+
| children | `CheckboxLabelProps['children']` | - | Label content |
|
|
59
|
+
| label props | `LabelHTMLAttributes<HTMLLabelElement>` | - | Additional label element props |
|
|
60
|
+
|
|
61
|
+
## Examples
|
|
62
|
+
|
|
63
|
+
### Playground
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import { Checkbox } from '@redislabsdev/redis-ui-components';
|
|
67
|
+
|
|
68
|
+
<Checkbox label="Checkbox Label" />
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Variants
|
|
72
|
+
|
|
73
|
+
> Use the `variant` prop to switch between the primary and danger looks.
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { Checkbox } from '@redislabsdev/redis-ui-components';
|
|
77
|
+
|
|
78
|
+
<>
|
|
79
|
+
<Checkbox label="Checked" checked />
|
|
80
|
+
<Checkbox label="Unchecked" checked={false} />
|
|
81
|
+
<Checkbox label="Indeterminate" checked="indeterminate" />
|
|
82
|
+
<Checkbox variant="danger" label="Checked" checked />
|
|
83
|
+
<Checkbox variant="danger" label="Unchecked" checked={false} />
|
|
84
|
+
<Checkbox variant="danger" label="Indeterminate" checked="indeterminate" />
|
|
85
|
+
</>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### DisabledVariants
|
|
89
|
+
|
|
90
|
+
> Disabled checkboxes also support both visual variants.
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import { Checkbox } from '@redislabsdev/redis-ui-components';
|
|
94
|
+
|
|
95
|
+
<>
|
|
96
|
+
<Checkbox disabled label="Checked" checked />
|
|
97
|
+
<Checkbox disabled label="Unchecked" />
|
|
98
|
+
<Checkbox disabled label="Indeterminate" checked="indeterminate" />
|
|
99
|
+
<Checkbox disabled variant="danger" label="Checked" checked />
|
|
100
|
+
<Checkbox disabled variant="danger" label="Unchecked" />
|
|
101
|
+
<Checkbox disabled variant="danger" label="Indeterminate" checked="indeterminate" />
|
|
102
|
+
</>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Multiline
|
|
106
|
+
|
|
107
|
+
> For multiline labels, align the checkbox container to the top so the indicator stays aligned with the first line.
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
import { Checkbox } from '@redislabsdev/redis-ui-components';
|
|
111
|
+
|
|
112
|
+
<Checkbox
|
|
113
|
+
style={{ alignItems: 'flex-start', maxWidth: 600 }}
|
|
114
|
+
label='This Checkbox with a very long label that takes up several lines. For multiline checkboxes you need to set "align-items: flex-start;" to align check indicator to the top. Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
|
|
115
|
+
/>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Controlled
|
|
119
|
+
|
|
120
|
+
> Controlled mode can switch between checked and indeterminate.
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
import { useState } from 'react';
|
|
124
|
+
import { Button, Checkbox } from '@redislabsdev/redis-ui-components';
|
|
125
|
+
import type { CheckedType } from '@redislabsdev/redis-ui-components';
|
|
126
|
+
|
|
127
|
+
const [checked, setChecked] = useState<CheckedType>('indeterminate');
|
|
128
|
+
|
|
129
|
+
const onCheckedChange = (newChecked: CheckedType) => {
|
|
130
|
+
setChecked(newChecked || 'indeterminate');
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
<>
|
|
134
|
+
<Button onClick={() => setChecked(true)}>Checked</Button>
|
|
135
|
+
<Button onClick={() => setChecked('indeterminate')}>Indeterminate</Button>
|
|
136
|
+
<Checkbox
|
|
137
|
+
checked={checked}
|
|
138
|
+
onCheckedChange={onCheckedChange}
|
|
139
|
+
label="This Checkbox switches between Checked and Indeterminate"
|
|
140
|
+
/>
|
|
141
|
+
</>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Composition
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import { Checkbox } from '@redislabsdev/redis-ui-components';
|
|
148
|
+
import { MasterCardIcon } from '@redislabsdev/redis-ui-icons/multicolor';
|
|
149
|
+
|
|
150
|
+
<>
|
|
151
|
+
<Checkbox.Compose>
|
|
152
|
+
<Checkbox.Label>Left side label</Checkbox.Label>
|
|
153
|
+
<Checkbox.Indicator />
|
|
154
|
+
</Checkbox.Compose>
|
|
155
|
+
|
|
156
|
+
<Checkbox.Compose defaultChecked>
|
|
157
|
+
<Checkbox.Indicator />
|
|
158
|
+
<Checkbox.Label>
|
|
159
|
+
<MasterCardIcon size="XL" />
|
|
160
|
+
Label with Icon
|
|
161
|
+
</Checkbox.Label>
|
|
162
|
+
</Checkbox.Compose>
|
|
163
|
+
</>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Notes
|
|
167
|
+
|
|
168
|
+
- `Checkbox.Compose`, `Checkbox.Indicator`, and `Checkbox.Label` are compound components and should be rendered together.
|
|
169
|
+
- `Checkbox.Compose` generates an id automatically when one is not provided.
|
|
170
|
+
- String labels are wrapped in body typography with ellipsis tooltip support; non-string children are rendered as-is.
|
|
171
|
+
- `checked` accepts `true`, `false`, or `'indeterminate'`.
|