@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,184 @@
|
|
|
1
|
+
# AppSelectionMenu
|
|
2
|
+
|
|
3
|
+
App selection menu component. It renders a default menu trigger and item list, and it also exposes compose helpers for custom triggers, content, and item layouts.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { AppSelectionMenu } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> Examples also use icons from `@redislabsdev/redis-ui-icons`.
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
|
|
15
|
+
### AppSelectionMenu
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Default | Description |
|
|
18
|
+
|------|------|---------|-------------|
|
|
19
|
+
| items | `AppSelectionMenuItemProps[]` | required | Menu items rendered by the default implementation |
|
|
20
|
+
| defaultOpen | `boolean` | - | Initial open state when the component is uncontrolled |
|
|
21
|
+
| open | `boolean` | - | Controlled open state |
|
|
22
|
+
| onOpenChange | `(open: boolean) => void` | - | Called when the open state changes |
|
|
23
|
+
|
|
24
|
+
### AppSelectionMenu.Compose
|
|
25
|
+
|
|
26
|
+
| Prop | Type | Default | Description |
|
|
27
|
+
|------|------|---------|-------------|
|
|
28
|
+
| children | `React.ReactNode` | required | Compound menu structure rendered inside the controllable provider |
|
|
29
|
+
| defaultOpen | `boolean` | - | Initial open state when uncontrolled |
|
|
30
|
+
| open | `boolean` | - | Controlled open state |
|
|
31
|
+
| onOpenChange | `(open: boolean) => void` | - | Called when the open state changes |
|
|
32
|
+
|
|
33
|
+
### AppSelectionMenu.Trigger
|
|
34
|
+
|
|
35
|
+
| Prop | Type | Default | Description |
|
|
36
|
+
|------|------|---------|-------------|
|
|
37
|
+
| children | `React.ReactElement` | required | Trigger content rendered inside the default toggle button |
|
|
38
|
+
|
|
39
|
+
### AppSelectionMenu.Trigger.Compose
|
|
40
|
+
|
|
41
|
+
| Prop | Type | Default | Description |
|
|
42
|
+
|------|------|---------|-------------|
|
|
43
|
+
| children | `React.ReactElement` | required | Custom trigger content rendered inside the popover trigger |
|
|
44
|
+
|
|
45
|
+
### AppSelectionMenu.Content
|
|
46
|
+
|
|
47
|
+
| Prop | Type | Default | Description |
|
|
48
|
+
|------|------|---------|-------------|
|
|
49
|
+
| children | `React.ReactNode` | required | Menu content rendered inside the default dropdown container |
|
|
50
|
+
|
|
51
|
+
### AppSelectionMenu.Content.Compose
|
|
52
|
+
|
|
53
|
+
| Prop | Type | Default | Description |
|
|
54
|
+
|------|------|---------|-------------|
|
|
55
|
+
| children | `React.ReactNode` | required | Custom content rendered inside the styled popover container |
|
|
56
|
+
|
|
57
|
+
### AppSelectionMenu.Item
|
|
58
|
+
|
|
59
|
+
| Prop | Type | Default | Description |
|
|
60
|
+
|------|------|---------|-------------|
|
|
61
|
+
| label | `string` | required | Item label rendered under the icon |
|
|
62
|
+
| icon | `IconType` | required | Icon rendered for the item |
|
|
63
|
+
| onClick | `() => void` | required | Click handler invoked when the item is selected |
|
|
64
|
+
| disabled | `boolean` | - | Disables the item and prevents interaction |
|
|
65
|
+
|
|
66
|
+
### AppSelectionMenu.Item.Compose
|
|
67
|
+
|
|
68
|
+
| Prop | Type | Default | Description |
|
|
69
|
+
|------|------|---------|-------------|
|
|
70
|
+
| children | `React.ReactElement` | required | Custom item content to clone and wire to the menu context |
|
|
71
|
+
| onClick | `() => void` | required | Click handler invoked before the menu closes |
|
|
72
|
+
| disabled | `boolean` | - | Disables click handling for the composed item |
|
|
73
|
+
|
|
74
|
+
## Sub-components
|
|
75
|
+
|
|
76
|
+
- `AppSelectionMenu.Compose` - Provides the controllable open state and menu context for custom composition.
|
|
77
|
+
- `AppSelectionMenu.Trigger` - Default trigger that renders the stock toggle button with the current active state.
|
|
78
|
+
- `AppSelectionMenu.Trigger.Compose` - Low-level trigger wrapper for custom trigger content.
|
|
79
|
+
- `AppSelectionMenu.Content` - Default dropdown content container.
|
|
80
|
+
- `AppSelectionMenu.Content.Compose` - Low-level content wrapper for custom dropdown layouts.
|
|
81
|
+
- `AppSelectionMenu.Item` - Default menu item with icon and label.
|
|
82
|
+
- `AppSelectionMenu.Item.Compose` - Low-level item wrapper that closes the menu after a selection.
|
|
83
|
+
- `AppSelectionMenu.Icon` - Default trigger icon rendered by the stock component.
|
|
84
|
+
|
|
85
|
+
## Examples
|
|
86
|
+
|
|
87
|
+
### Playground
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
import { AppSelectionMenu } from '@redislabsdev/redis-ui-components';
|
|
91
|
+
import { ActiveActiveIcon, BillingIcon, RedisAiIcon } from '@redislabsdev/redis-ui-icons';
|
|
92
|
+
|
|
93
|
+
const items = [
|
|
94
|
+
{ label: 'Disabled', onClick: () => {}, icon: RedisAiIcon, disabled: true },
|
|
95
|
+
{ label: 'Item 2', onClick: () => {}, icon: ActiveActiveIcon },
|
|
96
|
+
{ label: 'Item 5', onClick: () => {}, icon: BillingIcon }
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
<AppSelectionMenu items={items} />
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Default Open
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import { AppSelectionMenu } from '@redislabsdev/redis-ui-components';
|
|
106
|
+
import { ActiveActiveIcon, BillingIcon, RedisAiIcon } from '@redislabsdev/redis-ui-icons';
|
|
107
|
+
|
|
108
|
+
const items = [
|
|
109
|
+
{ label: 'Disabled', onClick: () => {}, icon: RedisAiIcon, disabled: true },
|
|
110
|
+
{ label: 'Item 2', onClick: () => {}, icon: ActiveActiveIcon },
|
|
111
|
+
{ label: 'Item 5', onClick: () => {}, icon: BillingIcon }
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
<AppSelectionMenu items={items} defaultOpen />
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Controlled
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
import { useState } from 'react';
|
|
121
|
+
import { AppSelectionMenu, Button } from '@redislabsdev/redis-ui-components';
|
|
122
|
+
import { ActiveActiveIcon, BillingIcon, RedisAiIcon } from '@redislabsdev/redis-ui-icons';
|
|
123
|
+
|
|
124
|
+
const items = [
|
|
125
|
+
{ label: 'Disabled', onClick: () => {}, icon: RedisAiIcon, disabled: true },
|
|
126
|
+
{ label: 'Item 2', onClick: () => {}, icon: ActiveActiveIcon },
|
|
127
|
+
{ label: 'Item 5', onClick: () => {}, icon: BillingIcon }
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
const [open, setOpen] = useState(false);
|
|
131
|
+
|
|
132
|
+
<>
|
|
133
|
+
<Button variant="secondary-fill" onClick={() => setOpen((prev) => !prev)}>
|
|
134
|
+
{open ? 'Close' : 'Open'}
|
|
135
|
+
</Button>
|
|
136
|
+
<AppSelectionMenu items={items} open={open} onOpenChange={setOpen} />
|
|
137
|
+
</>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Composition
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
import { AppSelectionMenu, ActionIconButton, Typography } from '@redislabsdev/redis-ui-components';
|
|
144
|
+
import { StarsIcon, ActiveActiveIcon, BillingIcon, RedisAiIcon } from '@redislabsdev/redis-ui-icons';
|
|
145
|
+
import * as S from './AppSelectionMenu.style';
|
|
146
|
+
|
|
147
|
+
const items = [
|
|
148
|
+
{ label: 'Disabled', onClick: () => {}, icon: RedisAiIcon, disabled: true },
|
|
149
|
+
{ label: 'Item 2', onClick: () => {}, icon: ActiveActiveIcon },
|
|
150
|
+
{ label: 'Item 5', onClick: () => {}, icon: BillingIcon }
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
<AppSelectionMenu.Compose>
|
|
154
|
+
<AppSelectionMenu.Trigger.Compose>
|
|
155
|
+
<S.CustomTriggerContainer>
|
|
156
|
+
<StarsIcon />
|
|
157
|
+
</S.CustomTriggerContainer>
|
|
158
|
+
</AppSelectionMenu.Trigger.Compose>
|
|
159
|
+
<AppSelectionMenu.Content.Compose>
|
|
160
|
+
<S.CustomContentWrapper>
|
|
161
|
+
{items.map((item) => (
|
|
162
|
+
<AppSelectionMenu.Item.Compose
|
|
163
|
+
key={item.label}
|
|
164
|
+
onClick={item.onClick}
|
|
165
|
+
disabled={item.disabled}
|
|
166
|
+
>
|
|
167
|
+
<S.CustomItem>
|
|
168
|
+
<Typography.Body>{item.label}</Typography.Body>
|
|
169
|
+
<ActionIconButton icon={item.icon} />
|
|
170
|
+
</S.CustomItem>
|
|
171
|
+
</AppSelectionMenu.Item.Compose>
|
|
172
|
+
))}
|
|
173
|
+
</S.CustomContentWrapper>
|
|
174
|
+
</AppSelectionMenu.Content.Compose>
|
|
175
|
+
</AppSelectionMenu.Compose>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Notes
|
|
179
|
+
|
|
180
|
+
- `AppSelectionMenu` is the stock implementation. It renders `AppSelectionMenu.Icon` as the default trigger and maps `items` into `AppSelectionMenu.Item`.
|
|
181
|
+
- Use `AppSelectionMenu.Compose` together with `Trigger.Compose`, `Content.Compose`, and `Item.Compose` when you need to customize the trigger, dropdown container, or row markup.
|
|
182
|
+
- `AppSelectionMenu.Item.Compose` invokes `onClick` and then closes the menu.
|
|
183
|
+
- `AppSelectionMenu.Trigger.Compose` wraps its children in a popover trigger with the default `aria-label="Menu"`.
|
|
184
|
+
- `AppSelectionMenuItemProps` require `label`, `icon`, and `onClick`; `disabled` is optional.
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# AutoCompleteSelect
|
|
2
|
+
|
|
3
|
+
A controlled autocomplete input that shows matching suggestions as the user types and lets users keep a manual value when there are no matches. Use `FormField` or `Label` when you need external labeling.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { AutoCompleteSelect } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
|------|------|---------|-------------|
|
|
15
|
+
| id | `string` | - | Id for the input element, used for label and accessibility wiring. |
|
|
16
|
+
| placeholder | `string` | `'Select'` | Placeholder text shown in the input. |
|
|
17
|
+
| value | `string` | - | Controlled input value. |
|
|
18
|
+
| onChange | `(value: string, isSuggestion?: boolean) => void` | - | Called when the input value changes or a suggestion is selected. |
|
|
19
|
+
| options | `AutoCompleteOption[]` | *required* | Available autocomplete options. |
|
|
20
|
+
| error | `string` | `''` | Error message. Enables error state and tooltip content. |
|
|
21
|
+
| manualOptionText | `string` | `''` | Text appended to the manual value when no suggestions are available. |
|
|
22
|
+
| optionsLabel | `string` | `'Suggestions'` | Label shown above the suggestion list. |
|
|
23
|
+
| disabled | `boolean` | `false` | Disables the input and dropdown interactions. |
|
|
24
|
+
| contentMaxHeight | `string` | - | Maximum height of the dropdown content area. |
|
|
25
|
+
|
|
26
|
+
The component also accepts standard `InputHTMLAttributes<HTMLInputElement>` props, excluding `onChange` and `defaultValue`.
|
|
27
|
+
|
|
28
|
+
## Examples
|
|
29
|
+
|
|
30
|
+
### Basic Usage
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { useState } from 'react';
|
|
34
|
+
import { AutoCompleteSelect } from '@redislabsdev/redis-ui-components';
|
|
35
|
+
import { storyOptions } from './AutoCompleteSelectStory.data';
|
|
36
|
+
|
|
37
|
+
function Render() {
|
|
38
|
+
const [value, setValue] = useState('');
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<AutoCompleteSelect
|
|
42
|
+
placeholder="Please select"
|
|
43
|
+
manualOptionText="new tag"
|
|
44
|
+
options={storyOptions}
|
|
45
|
+
value={value}
|
|
46
|
+
onChange={setValue}
|
|
47
|
+
id="custom-id"
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### ControlledValue
|
|
54
|
+
|
|
55
|
+
> `AutoCompleteSelect` always works in controlled mode. Use `value` and `onChange` props for that
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { useState } from 'react';
|
|
59
|
+
import { AutoCompleteSelect } from '@redislabsdev/redis-ui-components';
|
|
60
|
+
import { storyOptions } from './AutoCompleteSelectStory.data';
|
|
61
|
+
|
|
62
|
+
function Render() {
|
|
63
|
+
const [value, setValue] = useState('');
|
|
64
|
+
|
|
65
|
+
return <AutoCompleteSelect options={storyOptions} value={value} onChange={setValue} />;
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### ControlledAsyncOptions
|
|
70
|
+
|
|
71
|
+
> Options can be loaded dynamically, according to the current input value (search value), while user is typing it.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import { useState } from 'react';
|
|
75
|
+
import {
|
|
76
|
+
AutoCompleteOption,
|
|
77
|
+
AutoCompleteSelect
|
|
78
|
+
} from '@redislabsdev/redis-ui-components';
|
|
79
|
+
import { storyOptions } from './AutoCompleteSelectStory.data';
|
|
80
|
+
|
|
81
|
+
const fetchOptionsBySearchValue = async (search: string) => {
|
|
82
|
+
const newOptions = storyOptions.filter((option) => option.value.includes(search));
|
|
83
|
+
|
|
84
|
+
if (newOptions.length !== 0) {
|
|
85
|
+
return new Promise<AutoCompleteOption[]>((resolve) => {
|
|
86
|
+
setTimeout(
|
|
87
|
+
() => resolve(storyOptions.filter((option) => option.value.includes(search))),
|
|
88
|
+
500
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return null;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
function Render() {
|
|
97
|
+
const [value, setValue] = useState('');
|
|
98
|
+
const [options, setOptions] = useState<AutoCompleteOption[]>([]);
|
|
99
|
+
|
|
100
|
+
const handleChange = async (valueChanged: string) => {
|
|
101
|
+
setValue(valueChanged);
|
|
102
|
+
|
|
103
|
+
if (valueChanged) {
|
|
104
|
+
const newOptions = await fetchOptionsBySearchValue(valueChanged);
|
|
105
|
+
|
|
106
|
+
if (newOptions?.length) {
|
|
107
|
+
setOptions(newOptions);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return <AutoCompleteSelect options={options} value={value} onChange={handleChange} />;
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### WithLabel
|
|
117
|
+
|
|
118
|
+
> Component doesn't have internal label or any other decoration elements.
|
|
119
|
+
> Use `FormField` or `Label` to manage it.
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
import { useState } from 'react';
|
|
123
|
+
import { AutoCompleteSelect, FormField } from '@redislabsdev/redis-ui-components';
|
|
124
|
+
import { storyOptions } from './AutoCompleteSelectStory.data';
|
|
125
|
+
|
|
126
|
+
function Render() {
|
|
127
|
+
const [value, setValue] = useState('');
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<FormField label="FormField Label" additionalText="FormField additional text">
|
|
131
|
+
<AutoCompleteSelect options={storyOptions} value={value} onChange={setValue} />
|
|
132
|
+
</FormField>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### ErrorState
|
|
138
|
+
|
|
139
|
+
> Adding some text to the `error` prop of `AutoCompleteSelect` enables error state.
|
|
140
|
+
> Hover error indicator to see specified text in tooltip
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
import { useState } from 'react';
|
|
144
|
+
import { AutoCompleteSelect } from '@redislabsdev/redis-ui-components';
|
|
145
|
+
import { storyOptions } from './AutoCompleteSelectStory.data';
|
|
146
|
+
|
|
147
|
+
function Render() {
|
|
148
|
+
const [value, setValue] = useState('');
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<AutoCompleteSelect
|
|
152
|
+
value={value}
|
|
153
|
+
onChange={setValue}
|
|
154
|
+
options={storyOptions}
|
|
155
|
+
error="Error message"
|
|
156
|
+
/>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Disabled
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
import { AutoCompleteSelect } from '@redislabsdev/redis-ui-components';
|
|
165
|
+
import { storyOptions } from './AutoCompleteSelectStory.data';
|
|
166
|
+
|
|
167
|
+
<>
|
|
168
|
+
Default
|
|
169
|
+
<AutoCompleteSelect value="" onChange={() => {}} options={storyOptions} disabled />
|
|
170
|
+
With selected item
|
|
171
|
+
<AutoCompleteSelect
|
|
172
|
+
value="environment"
|
|
173
|
+
onChange={() => {}}
|
|
174
|
+
options={storyOptions}
|
|
175
|
+
disabled
|
|
176
|
+
/>
|
|
177
|
+
With error message
|
|
178
|
+
<AutoCompleteSelect
|
|
179
|
+
value="blabla"
|
|
180
|
+
onChange={() => {}}
|
|
181
|
+
options={storyOptions}
|
|
182
|
+
disabled
|
|
183
|
+
error="Error message"
|
|
184
|
+
/>
|
|
185
|
+
</>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Notes
|
|
189
|
+
|
|
190
|
+
- `AutoCompleteSelect` always works in controlled mode.
|
|
191
|
+
- Use `FormField` or `Label` when you need external decoration around the input.
|
|
192
|
+
- Options can be loaded dynamically as the user types.
|
|
193
|
+
- Adding text to `error` enables the error state and shows the tooltip content.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Badge
|
|
2
|
+
|
|
3
|
+
Compact status badge with variant-based coloring and optional icons.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Badge } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
If you pass a custom icon in examples, import it from `@redislabsdev/redis-ui-icons`.
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
|
|
15
|
+
| Prop | Type | Default | Description |
|
|
16
|
+
|------|------|---------|-------------|
|
|
17
|
+
| label | `string` | required | Text rendered inside the badge |
|
|
18
|
+
| variant | `'white' \| 'light' \| 'default' \| 'informative' \| 'success' \| 'notice' \| 'danger' \| 'attention' \| 'disabled'` | `'default'` | Visual badge variant that controls surface and icon styling |
|
|
19
|
+
| withIcon | `boolean` | `false` | Shows the default variant icon when enabled |
|
|
20
|
+
| icon | `IconType` | - | Overrides the default icon used for the current variant |
|
|
21
|
+
| color | `string` | - | Overrides the badge accent color directly |
|
|
22
|
+
| theme | `Theme` | - | Theme override passed through to styled-components |
|
|
23
|
+
|
|
24
|
+
The component also extends `React.HTMLAttributes<HTMLDivElement>`.
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
### Basic Usage
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { Badge } from '@redislabsdev/redis-ui-components';
|
|
32
|
+
|
|
33
|
+
<Badge label="Badge" withIcon />
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### WithCustomColor
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { Badge } from '@redislabsdev/redis-ui-components';
|
|
40
|
+
|
|
41
|
+
<Badge label="Badge" withIcon color="#0366d6" />
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Icons
|
|
45
|
+
|
|
46
|
+
> `Badge` can be rendered with or without an icon using `withIcon`. Pass `icon` to customize the icon.
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { Badge } from '@redislabsdev/redis-ui-components';
|
|
50
|
+
import { PhoneIcon } from '@redislabsdev/redis-ui-icons';
|
|
51
|
+
|
|
52
|
+
<>
|
|
53
|
+
<Badge label="Without icon" />
|
|
54
|
+
<Badge label="With default icon" withIcon />
|
|
55
|
+
<Badge label="With custom icon" withIcon icon={PhoneIcon} />
|
|
56
|
+
</>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Variants
|
|
60
|
+
|
|
61
|
+
> `Badge` can be rendered in a few variants using the `variant` prop.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { Badge, badgeVariants } from '@redislabsdev/redis-ui-components';
|
|
65
|
+
|
|
66
|
+
<>
|
|
67
|
+
{badgeVariants.map((variant) => (
|
|
68
|
+
<Badge key={variant} variant={variant} label={variant} withIcon />
|
|
69
|
+
))}
|
|
70
|
+
</>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Notes
|
|
74
|
+
|
|
75
|
+
- `withIcon` uses the default icon for the selected variant when `icon` is not provided.
|
|
76
|
+
- `variant` controls both the badge surface color and the default icon choice.
|
|
77
|
+
- `color` overrides the badge accent color directly and is used instead of the theme variant color.
|