@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,154 @@
|
|
|
1
|
+
# Chip
|
|
2
|
+
|
|
3
|
+
A compact label chip with optional close action, two sizes, two visual variants, and tooltip support. The root `Chip` is a compound component that renders `Chip.Compose`, `Chip.Title`, and `Chip.CloseButton` internally.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Chip } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
|------|------|---------|-------------|
|
|
15
|
+
| text | `string` | required | Chip label text |
|
|
16
|
+
| size | `'M' \| 'S'` | `'M'` | Chip size |
|
|
17
|
+
| variant | `'regular' \| 'flat'` | `'regular'` | Visual variant |
|
|
18
|
+
| disabled | `boolean` | `false` | Disables the chip and hides the close button |
|
|
19
|
+
| tooltip | `string \| Omit<TooltipContentProps, 'children'>` | - | Tooltip content shown on hover |
|
|
20
|
+
| onClose | `VoidFunction` | - | Close handler used to show the close button |
|
|
21
|
+
| closeButtonTitle | `string` | `'Remove'` | Title passed to the close button |
|
|
22
|
+
|
|
23
|
+
The component also extends all native `HTMLAttributes<HTMLSpanElement>` props through the composed span container, excluding `children` and `content`.
|
|
24
|
+
|
|
25
|
+
## Sub-components
|
|
26
|
+
|
|
27
|
+
- `Chip.Compose` - Renders the chip container and accepts the compound state props, tooltip configuration, and span attributes.
|
|
28
|
+
- `Chip.Title` - Renders the chip label and applies ellipsis with tooltip-on-ellipsis behavior.
|
|
29
|
+
- `Chip.CloseButton` - Renders the close action button and hides itself when the chip is disabled or `onClose` is missing.
|
|
30
|
+
|
|
31
|
+
## Examples
|
|
32
|
+
|
|
33
|
+
### Playground
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { Chip } from '@redislabsdev/redis-ui-components';
|
|
37
|
+
|
|
38
|
+
<Chip text="Chip" size="M" />
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Variants
|
|
42
|
+
|
|
43
|
+
> `Chip` can be rendered in 2 variants
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { Chip } from '@redislabsdev/redis-ui-components';
|
|
47
|
+
|
|
48
|
+
<>
|
|
49
|
+
<Chip text="regular" />
|
|
50
|
+
<Chip text="flat" variant="flat" />
|
|
51
|
+
</>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Closable
|
|
55
|
+
|
|
56
|
+
> To allow `Chip` have Close button, add handler to the `onClose` event.
|
|
57
|
+
>
|
|
58
|
+
> Note: by design `flat` chip should not have Close button, do not add `onClose` for it.
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { Chip } from '@redislabsdev/redis-ui-components';
|
|
62
|
+
|
|
63
|
+
<>
|
|
64
|
+
<Chip text="regular" />
|
|
65
|
+
<Chip text="regular, closable" onClose={() => alert('close clicked')} />
|
|
66
|
+
<Chip text="flat should not be closable" variant="flat" />
|
|
67
|
+
</>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Disabled
|
|
71
|
+
|
|
72
|
+
> `Chip` can be disabled by setting `disabled` prop.
|
|
73
|
+
>
|
|
74
|
+
> Note: when closable chip is disabled, close button is hidden
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { Chip } from '@redislabsdev/redis-ui-components';
|
|
78
|
+
|
|
79
|
+
const handleClose = () => {};
|
|
80
|
+
|
|
81
|
+
<>
|
|
82
|
+
<Chip text="regular" disabled />
|
|
83
|
+
<Chip text="regular, closable" onClose={handleClose} disabled />
|
|
84
|
+
<Chip text="flat" variant="flat" disabled />
|
|
85
|
+
</>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Sizes
|
|
89
|
+
|
|
90
|
+
> There are 2 predefined sizes for the `Chip`
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import { Chip } from '@redislabsdev/redis-ui-components';
|
|
94
|
+
|
|
95
|
+
const handleClose = () => {};
|
|
96
|
+
|
|
97
|
+
<>
|
|
98
|
+
<Chip text="size = M" size="M" onClose={handleClose} />
|
|
99
|
+
<Chip text="size = S" size="S" onClose={handleClose} />
|
|
100
|
+
</>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### CustomTooltip
|
|
104
|
+
|
|
105
|
+
> Custom tooltip can be added using `tooltip` prop.
|
|
106
|
+
> Tooltip can have any content.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { Chip } from '@redislabsdev/redis-ui-components';
|
|
110
|
+
|
|
111
|
+
<>
|
|
112
|
+
<Chip text="hover for simple tooltip" tooltip="simple tooltip content" />
|
|
113
|
+
<Chip
|
|
114
|
+
text="hover for customized tooltip"
|
|
115
|
+
tooltip={{
|
|
116
|
+
content: (
|
|
117
|
+
<>
|
|
118
|
+
<strong>Customized</strong> <em>tooltip</em>
|
|
119
|
+
</>
|
|
120
|
+
),
|
|
121
|
+
placement: 'bottom',
|
|
122
|
+
color: 'danger500'
|
|
123
|
+
}}
|
|
124
|
+
/>
|
|
125
|
+
<Chip text="hover disabled for tooltip" tooltip="simple tooltip content" disabled />
|
|
126
|
+
</>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### EllipsisAndTooltip
|
|
130
|
+
|
|
131
|
+
> If `text` is too long for the `Chip`, it is cropped with ellipsis and native tooltip is added.
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { Chip } from '@redislabsdev/redis-ui-components';
|
|
135
|
+
|
|
136
|
+
const longText =
|
|
137
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse in euismod sapien. Integer eleifend purus quis dictum porttitor.';
|
|
138
|
+
const handleClose = () => {};
|
|
139
|
+
|
|
140
|
+
<>
|
|
141
|
+
<Chip text={longText} style={{ maxWidth: 240 }} />
|
|
142
|
+
<Chip text={longText} style={{ maxWidth: 240 }} onClose={handleClose} />
|
|
143
|
+
<Chip text={longText} style={{ maxWidth: 240 }} variant="flat" />
|
|
144
|
+
</>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Notes
|
|
148
|
+
|
|
149
|
+
- `Chip.Compose` accepts either a simple tooltip string or full tooltip content props and wraps the chip in `Tooltip` only when `tooltip` is provided.
|
|
150
|
+
- `Chip.CloseButton` defaults to the `ToastCancelIcon` icon and a `Remove` title.
|
|
151
|
+
- `Chip.Title` uses `Typography.Body` internally and enables ellipsis tooltips automatically.
|
|
152
|
+
- `flat` chips should not receive `onClose`; that variant is intentionally non-closable.
|
|
153
|
+
- When a closable chip is disabled, the close button is hidden.
|
|
154
|
+
- The package also exports `ChipContainer` from the compose style file for advanced styling scenarios.
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# ChipList
|
|
2
|
+
|
|
3
|
+
Renders a list of chips with optional close actions, row limiting, and a customizable overflow chip for hidden items.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { ChipList, ChipItem } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> If you need to type the chip data separately, also import `ChipItem`.
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
|
|
15
|
+
| Prop | Type | Default | Description |
|
|
16
|
+
|------|------|---------|-------------|
|
|
17
|
+
| chips | `ChipItem[]` | - | Chips to render in the list |
|
|
18
|
+
| onRemoveItem | `(chip: string) => void` | - | Called with the chip `key` when a close action is triggered |
|
|
19
|
+
| removeItemButtonTitle | `string` | - | Title for the close button on each chip |
|
|
20
|
+
| maxRows | `number` | `1` | Maximum number of rows to display before collapsing hidden items into the extra chip |
|
|
21
|
+
| size | `ChipSizes` | `'M'` | Chip size |
|
|
22
|
+
| variant | `ChipVariants` | - | Chip visual variant |
|
|
23
|
+
| disabled | `boolean` | - | Disables all chips in the list |
|
|
24
|
+
| renderExtraTooltip | `(chipItems: ChipItem[]) => Exclude<ReactNode, number>` | - | Custom renderer for the hidden-items tooltip content |
|
|
25
|
+
|
|
26
|
+
### ChipItem
|
|
27
|
+
|
|
28
|
+
| Prop | Type | Default | Description |
|
|
29
|
+
|------|------|---------|-------------|
|
|
30
|
+
| key | `string` | - | Unique identifier for the chip |
|
|
31
|
+
| label | `string` | - | Text shown inside the chip |
|
|
32
|
+
| disabled | `boolean` | `false` | Disables the individual chip |
|
|
33
|
+
| tooltip | `ChipProps['tooltip']` | - | Tooltip content for the chip |
|
|
34
|
+
|
|
35
|
+
`ChipItem` also extends the native `HTMLAttributes<HTMLSpanElement>` props.
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
### Playground
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { useRef, useState } from 'react';
|
|
43
|
+
import { Button, ChipList } from '@redislabsdev/redis-ui-components';
|
|
44
|
+
|
|
45
|
+
const itemsList = [
|
|
46
|
+
{ label: 'Chip text 1', key: '1' },
|
|
47
|
+
{ label: 'Chip text 2', key: '2' },
|
|
48
|
+
{ label: 'Chip 3', key: '3' },
|
|
49
|
+
{ label: 'Chip 4', key: '4' },
|
|
50
|
+
{ label: 'Chip text 5 ', key: '5' },
|
|
51
|
+
{ label: 'Chip text 6', key: '6' },
|
|
52
|
+
{ label: 'Chip text 7', key: '7' }
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
export function Example() {
|
|
56
|
+
const itemIndex = useRef(itemsList.length);
|
|
57
|
+
const [chips, setChips] = useState(itemsList);
|
|
58
|
+
|
|
59
|
+
const handleRemoveItem = (itemKey: string) => {
|
|
60
|
+
setChips((items) => items.filter((item) => item.key !== itemKey));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const addOne = () => {
|
|
64
|
+
itemIndex.current += 1;
|
|
65
|
+
setChips((items) => [
|
|
66
|
+
...items,
|
|
67
|
+
{ label: `chip text ${itemIndex.current}`, key: `${itemIndex.current}` }
|
|
68
|
+
]);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<>
|
|
73
|
+
<div style={{ display: 'flex', gap: '0.8rem', marginBottom: '1.2rem' }}>
|
|
74
|
+
<Button onClick={() => setChips(itemsList)}>Reset</Button>
|
|
75
|
+
<Button onClick={() => setChips([])}>Delete all</Button>
|
|
76
|
+
<Button onClick={addOne}>Add one</Button>
|
|
77
|
+
</div>
|
|
78
|
+
<ChipList chips={chips} onRemoveItem={handleRemoveItem} />
|
|
79
|
+
</>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Variants
|
|
85
|
+
|
|
86
|
+
> `ChipList` can be rendered in 2 variants `regular` (default) and `flat`
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { ChipList } from '@redislabsdev/redis-ui-components';
|
|
90
|
+
|
|
91
|
+
const itemsList = [
|
|
92
|
+
{ label: 'Chip text 1', key: '1' },
|
|
93
|
+
{ label: 'Chip text 2', key: '2' },
|
|
94
|
+
{ label: 'Chip 3', key: '3' },
|
|
95
|
+
{ label: 'Chip 4', key: '4' },
|
|
96
|
+
{ label: 'Chip text 5 ', key: '5' },
|
|
97
|
+
{ label: 'Chip text 6', key: '6' },
|
|
98
|
+
{ label: 'Chip text 7', key: '7' }
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
<>
|
|
102
|
+
<ChipList chips={itemsList} />
|
|
103
|
+
<ChipList chips={itemsList} variant="flat" />
|
|
104
|
+
</>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Closable
|
|
108
|
+
|
|
109
|
+
> To allow `ChipList` have items with Close button, add handler to the `onRemoveItem` event.
|
|
110
|
+
>
|
|
111
|
+
> Note: by design `flat` ChipList items should not have Close button, do not add `onRemoveItem` for it.
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
import { ChipList } from '@redislabsdev/redis-ui-components';
|
|
115
|
+
|
|
116
|
+
const itemsList = [
|
|
117
|
+
{ label: 'Chip text 1', key: '1' },
|
|
118
|
+
{ label: 'Chip text 2', key: '2' },
|
|
119
|
+
{ label: 'Chip 3', key: '3' },
|
|
120
|
+
{ label: 'Chip 4', key: '4' },
|
|
121
|
+
{ label: 'Chip text 5 ', key: '5' },
|
|
122
|
+
{ label: 'Chip text 6', key: '6' },
|
|
123
|
+
{ label: 'Chip text 7', key: '7' }
|
|
124
|
+
];
|
|
125
|
+
|
|
126
|
+
<>
|
|
127
|
+
<ChipList chips={itemsList} onRemoveItem={(item) => alert(`close clicked for item ${item}`)} />
|
|
128
|
+
<ChipList chips={itemsList} variant="flat" />
|
|
129
|
+
</>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Sizes
|
|
133
|
+
|
|
134
|
+
> There are 2 predefined sizes for the `ChipList`
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
import { ChipList } from '@redislabsdev/redis-ui-components';
|
|
138
|
+
|
|
139
|
+
const itemsList = [
|
|
140
|
+
{ label: 'Chip text 1', key: '1' },
|
|
141
|
+
{ label: 'Chip text 2', key: '2' },
|
|
142
|
+
{ label: 'Chip 3', key: '3' },
|
|
143
|
+
{ label: 'Chip 4', key: '4' },
|
|
144
|
+
{ label: 'Chip text 5 ', key: '5' },
|
|
145
|
+
{ label: 'Chip text 6', key: '6' },
|
|
146
|
+
{ label: 'Chip text 7', key: '7' }
|
|
147
|
+
];
|
|
148
|
+
|
|
149
|
+
<>
|
|
150
|
+
<ChipList chips={itemsList} size="M" onRemoveItem={() => {}} />
|
|
151
|
+
<ChipList chips={itemsList} size="S" onRemoveItem={() => {}} />
|
|
152
|
+
</>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Disabled
|
|
156
|
+
|
|
157
|
+
> `ChipList` can be disabled by setting `disabled` prop. This will disable all the chips of the list.<br/>
|
|
158
|
+
> Chips can be disabled individually by adding `disabled` param to the `ChipItem` definition
|
|
159
|
+
>
|
|
160
|
+
> Note: when closable chip is disabled, close button is hidden
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
import { ChipList } from '@redislabsdev/redis-ui-components';
|
|
164
|
+
|
|
165
|
+
const itemListWithDisableItems = [
|
|
166
|
+
{ label: 'Chip text 1', key: '1' },
|
|
167
|
+
{ label: 'Chip text 2', key: '2', disabled: true },
|
|
168
|
+
{ label: 'Chip 3', key: '3' },
|
|
169
|
+
{ label: 'Chip 4', key: '4', disabled: true },
|
|
170
|
+
{ label: 'Chip text 5 ', key: '5' },
|
|
171
|
+
{ label: 'Chip text 6', key: '6', disabled: true },
|
|
172
|
+
{ label: 'Chip text 7', key: '7' }
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
<>
|
|
176
|
+
<ChipList chips={itemListWithDisableItems} onRemoveItem={() => {}} disabled />
|
|
177
|
+
<ChipList chips={itemListWithDisableItems} onRemoveItem={() => {}} />
|
|
178
|
+
<ChipList chips={itemListWithDisableItems} variant="flat" disabled />
|
|
179
|
+
<ChipList chips={itemListWithDisableItems} variant="flat" />
|
|
180
|
+
</>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### MultiRows
|
|
184
|
+
|
|
185
|
+
> `ChipList` can be displayed in one or more rows.
|
|
186
|
+
> Use `maxRows` to set the maximum number of rows (default is 1)<br/>
|
|
187
|
+
> The actual number of rows is determined by the number of items and their layout.
|
|
188
|
+
>
|
|
189
|
+
> Items that exceed max rows will be replaced with an "extra" chip
|
|
190
|
+
> that shows the number of hidden items and a tooltip with a list of them.<br/>
|
|
191
|
+
> If `maxRows` is less than 1, then only the "extra" chip is displayed.
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
import { ChipList } from '@redislabsdev/redis-ui-components';
|
|
195
|
+
|
|
196
|
+
const itemsList = [
|
|
197
|
+
{ label: 'Chip text 1', key: '1' },
|
|
198
|
+
{ label: 'Chip text 2', key: '2' },
|
|
199
|
+
{ label: 'Chip 3', key: '3' },
|
|
200
|
+
{ label: 'Chip 4', key: '4' },
|
|
201
|
+
{ label: 'Chip text 5 ', key: '5' },
|
|
202
|
+
{ label: 'Chip text 6', key: '6' },
|
|
203
|
+
{ label: 'Chip text 7', key: '7' }
|
|
204
|
+
];
|
|
205
|
+
|
|
206
|
+
const bigItemsList = new Array(30).fill(0).map((_, i) => ({ label: `Chip text ${i}`, key: `${i}` }));
|
|
207
|
+
|
|
208
|
+
<>
|
|
209
|
+
<ChipList chips={itemsList} maxRows={0} />
|
|
210
|
+
<ChipList chips={itemsList} />
|
|
211
|
+
<ChipList chips={itemsList} maxRows={2} />
|
|
212
|
+
<ChipList chips={bigItemsList} maxRows={3} />
|
|
213
|
+
</>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### ItemTooltip
|
|
217
|
+
|
|
218
|
+
> Item tooltip can be added using `tooltip` item parameter.
|
|
219
|
+
> Tooltip can have any content.
|
|
220
|
+
|
|
221
|
+
```tsx
|
|
222
|
+
import { ChipList } from '@redislabsdev/redis-ui-components';
|
|
223
|
+
|
|
224
|
+
const itemsListWithTooltips = [
|
|
225
|
+
{ label: 'simple tooltip', key: '1', tooltip: 'simple tooltip content' },
|
|
226
|
+
{
|
|
227
|
+
label: 'customized tooltip',
|
|
228
|
+
key: '2',
|
|
229
|
+
tooltip: {
|
|
230
|
+
content: (
|
|
231
|
+
<>
|
|
232
|
+
<strong>Customized</strong> <em>tooltip</em>
|
|
233
|
+
</>
|
|
234
|
+
),
|
|
235
|
+
placement: 'bottom'
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
{ label: 'tooltip on disabled', key: '3', tooltip: 'simple tooltip content', disabled: true }
|
|
239
|
+
];
|
|
240
|
+
|
|
241
|
+
<ChipList chips={itemsListWithTooltips} />
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### ExtraTooltip
|
|
245
|
+
|
|
246
|
+
> The Extra Tooltip shows hidden items as simple scrollable list inside the tooltip.
|
|
247
|
+
> This tooltip content can be customized by specifying the `renderExtraTooltip` prop.<br/>
|
|
248
|
+
> The custom renderer receives a list of hidden items.
|
|
249
|
+
>
|
|
250
|
+
> Note: rendered list will be wrapped in an inner scroll container,
|
|
251
|
+
> so there is no need to do this manually.
|
|
252
|
+
|
|
253
|
+
```tsx
|
|
254
|
+
import { ReactNode } from 'react';
|
|
255
|
+
import { Chip, ChipList } from '@redislabsdev/redis-ui-components';
|
|
256
|
+
|
|
257
|
+
const bigItemsList = new Array(30)
|
|
258
|
+
.fill(0)
|
|
259
|
+
.map((_, i) => ({ label: `Chip text ${i}`, key: `${i}` }));
|
|
260
|
+
|
|
261
|
+
const getGroupItems = (
|
|
262
|
+
chipItems: Array<{ label: string; key: string; disabled?: boolean }>,
|
|
263
|
+
iterator: (groupItems: Array<{ label: string; key: string; disabled?: boolean }>, groupName: string) => ReactNode
|
|
264
|
+
) =>
|
|
265
|
+
Object.values(
|
|
266
|
+
// @ts-ignore
|
|
267
|
+
Object.groupBy(chipItems, (_, index: number) => String(index % 7)) as Record<
|
|
268
|
+
string,
|
|
269
|
+
Array<{ label: string; key: string; disabled?: boolean }>
|
|
270
|
+
>
|
|
271
|
+
).map((groupItems, index) => iterator(groupItems, String(index + 1)));
|
|
272
|
+
|
|
273
|
+
<>
|
|
274
|
+
<ChipList
|
|
275
|
+
chips={bigItemsList}
|
|
276
|
+
renderExtraTooltip={(chipItems) => {
|
|
277
|
+
return (
|
|
278
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem', alignItems: 'stretch' }}>
|
|
279
|
+
{getGroupItems(chipItems, (groupItems, index) => (
|
|
280
|
+
<div key={index} style={{ display: 'flex', flexDirection: 'column', gap: '0.6rem' }}>
|
|
281
|
+
<h3 style={{ alignSelf: 'stretch', textAlign: 'center' }}>Group {index}</h3>
|
|
282
|
+
{groupItems.map(({ label }) => (
|
|
283
|
+
<Chip key={label} text={label} />
|
|
284
|
+
))}
|
|
285
|
+
</div>
|
|
286
|
+
))}
|
|
287
|
+
</div>
|
|
288
|
+
);
|
|
289
|
+
}}
|
|
290
|
+
/>
|
|
291
|
+
<ChipList chips={bigItemsList} renderExtraTooltip={() => null} />
|
|
292
|
+
</>
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Notes
|
|
296
|
+
|
|
297
|
+
- `ChipList` supports `regular` and `flat` variants; `regular` is the default.
|
|
298
|
+
- Provide `onRemoveItem` to make chips closable.
|
|
299
|
+
- Do not use `onRemoveItem` with the `flat` variant.
|
|
300
|
+
- `maxRows` defaults to `1`.
|
|
301
|
+
- If `maxRows` is less than `1`, only the overflow chip is rendered.
|
|
302
|
+
- Hidden chips are collapsed into an extra chip that shows their count.
|
|
303
|
+
- `tooltip` can be added per chip and can contain any content.
|
|
304
|
+
- `renderExtraTooltip` receives the hidden chips and lets you fully customize the overflow tooltip.
|
|
305
|
+
- The custom overflow tooltip content is wrapped in an inner scroll container.
|
|
306
|
+
- `disabled` disables all chips in the list, and individual `ChipItem`s can also be disabled.
|
|
307
|
+
- When a closable chip is disabled, its close button is hidden.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# CopyToClipboardButton
|
|
2
|
+
|
|
3
|
+
An icon button that copies text to the clipboard and briefly switches to a success state after a successful copy.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
```tsx
|
|
7
|
+
import { CopyToClipboardButton } from '@redislabsdev/redis-ui-components';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Props
|
|
11
|
+
| Prop | Type | Default | Description |
|
|
12
|
+
|------|------|---------|-------------|
|
|
13
|
+
| textToCopy | `string` | *required* | Text copied to the clipboard when the button is clicked |
|
|
14
|
+
| copiedLabel | `string` | - | Optional label shown while the copied success state is active |
|
|
15
|
+
| native button props | `Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'>` | - | Standard button attributes except `onClick`, which is handled internally |
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Playground
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { CopyToClipboardButton } from '@redislabsdev/redis-ui-components';
|
|
23
|
+
|
|
24
|
+
<CopyToClipboardButton disabled={false} textToCopy="Hello, World!" copiedLabel="Copied!" />
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Disabled
|
|
28
|
+
|
|
29
|
+
> CopyToClipboardButton can be disabled by setting the `disabled` prop to `true`.
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
<CopyToClipboardButton textToCopy="Disabled text" disabled />
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### WithCopiedLabel
|
|
36
|
+
|
|
37
|
+
> Use `copiedLabel` prop to show a custom label when content is copied.
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
<CopyToClipboardButton textToCopy="Text with custom label" copiedLabel="Successfully copied!" />
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Notes
|
|
44
|
+
- The component forwards refs to the underlying `<button>` element.
|
|
45
|
+
- After a successful copy, the icon changes to a check mark for 1.5 seconds before reverting.
|
|
46
|
+
- If `copiedLabel` is provided, it is also used as the accessible label while the copied state is active.
|
|
47
|
+
- If `copiedLabel` is omitted, the accessible label falls back to `Copy`.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# CountryFlag
|
|
2
|
+
|
|
3
|
+
Country flag image component that loads flagcdn assets and falls back to an empty placeholder until the image is valid.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { CountryFlag } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
|------|------|---------|-------------|
|
|
15
|
+
| countryCode | `string` | required | Country code used to resolve the flag image |
|
|
16
|
+
| native img props | `React.HTMLAttributes<HTMLImageElement>` | - | Standard image attributes forwarded to the rendered flag image |
|
|
17
|
+
|
|
18
|
+
The component also extends all native `React.HTMLAttributes<HTMLImageElement>` props.
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
### Playground
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { CountryFlag } from '@redislabsdev/redis-ui-components';
|
|
26
|
+
|
|
27
|
+
<CountryFlag countryCode="us" />
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Empty
|
|
31
|
+
|
|
32
|
+
> If the `countryCode` is wrong or empty, the component shows an empty flag.
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { CountryFlag } from '@redislabsdev/redis-ui-components';
|
|
36
|
+
|
|
37
|
+
<CountryFlag countryCode="" />
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Gallery
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import countries from './codes.json';
|
|
44
|
+
import { CountryFlag } from '@redislabsdev/redis-ui-components';
|
|
45
|
+
|
|
46
|
+
<>
|
|
47
|
+
{Object.entries(countries).map(([code, name]) => (
|
|
48
|
+
<CountryFlag key={code} countryCode={code} title={`${code}:${name}`} />
|
|
49
|
+
))}
|
|
50
|
+
</>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Notes
|
|
54
|
+
|
|
55
|
+
- Flags are loaded from `flagcdn.com`.
|
|
56
|
+
- The component renders a placeholder image until the actual flag asset loads successfully.
|
|
57
|
+
- `uk`, `tp`, and `fx` are normalized to `gb`, `tl`, and `fr` before the flag URL is resolved.
|