@redis-ui/components 42.8.0 → 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/AutoCompleteSelect/AutoCompleteSelect.cjs +7 -1
- package/dist/AutoCompleteSelect/AutoCompleteSelect.js +7 -1
- package/dist/AutoCompleteSelect/hooks/useAutoCompleteSelect.cjs +7 -1
- package/dist/AutoCompleteSelect/hooks/useAutoCompleteSelect.d.ts +8 -1
- package/dist/AutoCompleteSelect/hooks/useAutoCompleteSelect.js +7 -1
- package/dist/BoxSelectionGroup/components/Item/components/BoxStateIndicator/BoxStateIndicator.cjs +8 -4
- package/dist/BoxSelectionGroup/components/Item/components/BoxStateIndicator/BoxStateIndicator.js +8 -4
- package/dist/BoxSelectionGroup/components/Item/components/Compose/Compose.style.cjs +18 -4
- package/dist/BoxSelectionGroup/components/Item/components/Compose/Compose.style.js +18 -4
- package/dist/BoxSelectionGroup/hooks/useBoxSelectionGroup.cjs +3 -1
- package/dist/BoxSelectionGroup/hooks/useBoxSelectionGroup.js +3 -1
- package/dist/Button/Button.style.cjs +4 -1
- package/dist/Button/Button.style.js +4 -1
- package/dist/Button/Button.style.utils.cjs +16 -1
- package/dist/Button/Button.style.utils.js +16 -1
- package/dist/Button/Button.types.cjs +1 -1
- package/dist/Button/Button.types.d.ts +1 -1
- package/dist/Button/Button.types.js +1 -1
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.cjs +59 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.d.ts +4 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.js +57 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.style.cjs +40 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.style.d.ts +8 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.style.js +38 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.types.d.ts +5 -0
- package/dist/Button/TextButton/TextButton.style.cjs +4 -1
- package/dist/Button/TextButton/TextButton.style.js +4 -1
- package/dist/Button/TextButton/TextButton.types.cjs +1 -1
- package/dist/Button/TextButton/TextButton.types.d.ts +1 -1
- package/dist/Button/TextButton/TextButton.types.js +1 -1
- package/dist/Button/index.d.ts +2 -0
- package/dist/Checkbox/components/Label/Label.style.cjs +15 -3
- package/dist/Checkbox/components/Label/Label.style.js +15 -3
- package/dist/Chip/components/CloseButton/CloseButton.cjs +3 -1
- package/dist/Chip/components/CloseButton/CloseButton.js +3 -1
- package/dist/Chip/components/Compose/Compose.style.cjs +4 -1
- package/dist/Chip/components/Compose/Compose.style.js +4 -1
- package/dist/Drawer/components/Description/Description.cjs +3 -1
- package/dist/Drawer/components/Description/Description.js +3 -1
- package/dist/Helpers/contexts/Popper/PopperCollisionBoundaryManager.cjs +3 -1
- package/dist/Helpers/contexts/Popper/PopperCollisionBoundaryManager.js +3 -1
- package/dist/Helpers/contexts/PrimitiveContextState.cjs +28 -16
- package/dist/Helpers/contexts/PrimitiveContextState.js +28 -16
- package/dist/Helpers/contexts/SharedId.context.cjs +9 -5
- package/dist/Helpers/contexts/SharedId.context.js +9 -5
- package/dist/Helpers/css.utils.cjs +18 -4
- package/dist/Helpers/css.utils.d.ts +15 -3
- package/dist/Helpers/css.utils.js +18 -4
- package/dist/Helpers/hooks/useScrollable.cjs +3 -1
- package/dist/Helpers/hooks/useScrollable.js +3 -1
- package/dist/Helpers/react.utils.cjs +6 -2
- package/dist/Helpers/react.utils.js +6 -2
- 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/Inputs/QuantityCounter/components/InputGroup/components/ValueLabel/ValueLabel.cjs +9 -5
- package/dist/Inputs/QuantityCounter/components/InputGroup/components/ValueLabel/ValueLabel.js +9 -5
- package/dist/Inputs/components/Compose/Compose.style.cjs +29 -6
- package/dist/Inputs/components/Compose/Compose.style.js +29 -6
- package/dist/Inputs/hooks/numericInput/numericInput.utils.cjs +12 -4
- package/dist/Inputs/hooks/numericInput/numericInput.utils.js +12 -4
- package/dist/Inputs/hooks/numericInput/useNumericInput.cjs +15 -3
- package/dist/Inputs/hooks/numericInput/useNumericInput.js +15 -3
- package/dist/Loader/Loader.cjs +1 -0
- package/dist/Loader/Loader.js +1 -0
- package/dist/Menu/components/Content/components/Item/Components/Compose/Compose.style.cjs +19 -4
- package/dist/Menu/components/Content/components/Item/Components/Compose/Compose.style.js +19 -4
- package/dist/Menu/components/Content/components/Label/components/Compose/Compose.style.cjs +4 -1
- package/dist/Menu/components/Content/components/Label/components/Compose/Compose.style.js +4 -1
- package/dist/Modal/components/Content/components/Compose/Compose.cjs +3 -1
- package/dist/Modal/components/Content/components/Compose/Compose.js +3 -1
- package/dist/Modal/components/Content/components/Description/Description.cjs +3 -1
- package/dist/Modal/components/Content/components/Description/Description.js +3 -1
- package/dist/MultiSelect/components/Compose/hooks/useMultiSelectContextApi.cjs +3 -1
- package/dist/MultiSelect/components/Compose/hooks/useMultiSelectContextApi.js +3 -1
- package/dist/MultiSelect/components/Trigger/components/MultiValue/MultiValue.cjs +3 -1
- package/dist/MultiSelect/components/Trigger/components/MultiValue/MultiValue.js +3 -1
- package/dist/Overflow/Overflow.cjs +3 -1
- package/dist/Overflow/Overflow.js +3 -1
- package/dist/Overflow/Overflow.utils.cjs +15 -6
- package/dist/Overflow/Overflow.utils.js +15 -6
- package/dist/Overflow/components/OverflowContainer/OverflowContainer.cjs +3 -1
- package/dist/Overflow/components/OverflowContainer/OverflowContainer.js +3 -1
- package/dist/Pagination/components/PageSizeSelect.cjs +3 -1
- package/dist/Pagination/components/PageSizeSelect.js +3 -1
- package/dist/Popover/components/Content/Content.cjs +3 -1
- package/dist/Popover/components/Content/Content.js +3 -1
- package/dist/Popover/components/Content/components/Footer/Footer.cjs +3 -1
- package/dist/Popover/components/Content/components/Footer/Footer.js +3 -1
- package/dist/RadioGroup/components/Item/components/Label/Label.style.cjs +15 -3
- package/dist/RadioGroup/components/Item/components/Label/Label.style.js +15 -3
- package/dist/ScreenReaderAnnounce/ScreenReaderAnnounce.cjs +3 -1
- package/dist/ScreenReaderAnnounce/ScreenReaderAnnounce.js +3 -1
- package/dist/Section/components/Header/components/CollapseButton/CollapseButton.cjs +3 -1
- package/dist/Section/components/Header/components/CollapseButton/CollapseButton.js +3 -1
- package/dist/Select/components/Content/components/Option/components/Compose/Compose.style.cjs +16 -4
- package/dist/Select/components/Content/components/Option/components/Compose/Compose.style.js +16 -4
- package/dist/Select/components/Content/components/OptionList/OptionList.cjs +6 -4
- package/dist/Select/components/Content/components/OptionList/OptionList.js +6 -4
- package/dist/Select/components/Content/components/OptionList/Virtual.cjs +9 -5
- package/dist/Select/components/Content/components/OptionList/Virtual.js +9 -5
- package/dist/Select/components/Context/hooks/useSearch.cjs +3 -1
- package/dist/Select/components/Context/hooks/useSearch.js +3 -1
- package/dist/Select/components/Trigger/components/Compose/Compose.style.cjs +33 -7
- package/dist/Select/components/Trigger/components/Compose/Compose.style.js +33 -7
- package/dist/SideBar/components/Item/Item.style.cjs +14 -3
- package/dist/SideBar/components/Item/Item.style.js +14 -3
- package/dist/Skeleton/components/Circle/Circle.cjs +1 -1
- package/dist/Skeleton/components/Circle/Circle.js +1 -1
- package/dist/Skeleton/components/Square/Square.cjs +1 -1
- package/dist/Skeleton/components/Square/Square.js +1 -1
- package/dist/Slider/components/Label/Compose/Compose.cjs +3 -1
- package/dist/Slider/components/Label/Compose/Compose.js +3 -1
- package/dist/Slider/components/Mark/Compose/Compose.cjs +3 -1
- package/dist/Slider/components/Mark/Compose/Compose.js +3 -1
- package/dist/Slider/hooks/useOffset.cjs +3 -1
- package/dist/Slider/hooks/useOffset.js +3 -1
- 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 +5 -10
- package/dist/Stepper/components/Step/components/Compose/Compose.js +5 -10
- 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/Stepper/hooks/useStepperInteractive.cjs +12 -4
- package/dist/Stepper/hooks/useStepperInteractive.js +12 -4
- package/dist/Switch/components/Switcher/Switcher.cjs +3 -1
- package/dist/Switch/components/Switcher/Switcher.js +3 -1
- package/dist/Switch/components/Switcher/Switcher.style.cjs +31 -8
- package/dist/Switch/components/Switcher/Switcher.style.js +31 -8
- package/dist/Tabs/components/TabBar/components/Trigger/components/Marker/Marker.style.cjs +24 -5
- package/dist/Tabs/components/TabBar/components/Trigger/components/Marker/Marker.style.js +24 -5
- package/dist/Tabs/components/TabBar/components/Trigger/components/Tab/Tab.style.cjs +24 -5
- package/dist/Tabs/components/TabBar/components/Trigger/components/Tab/Tab.style.js +24 -5
- package/dist/ThemeModeSwitch/useThemeModeSwitch.cjs +6 -2
- package/dist/ThemeModeSwitch/useThemeModeSwitch.js +6 -2
- package/dist/Toast/core/content.helper.cjs +8 -4
- package/dist/Toast/core/content.helper.js +8 -4
- package/dist/Tooltip/components/Content/Content.cjs +3 -1
- package/dist/Tooltip/components/Content/Content.js +3 -1
- package/dist/TreeView/TreeView.cjs +3 -1
- package/dist/TreeView/TreeView.js +3 -1
- package/dist/TreeView/components/TreeItem/components/Compose/Compose.cjs +6 -4
- package/dist/TreeView/components/TreeItem/components/Compose/Compose.js +6 -4
- package/dist/Typography/Typography.types.cjs +4 -0
- package/dist/Typography/Typography.types.d.ts +2 -1
- package/dist/Typography/Typography.types.js +4 -0
- package/dist/index.cjs +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +98 -90
- package/package.json +10 -9
- package/skills/redis-ui-components/SKILL.md +126 -0
- 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/Button.md +169 -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/FlexDivider.md +152 -0
- package/skills/redis-ui-components/references/FlexGroup.md +149 -0
- package/skills/redis-ui-components/references/FlexItem.md +58 -0
- package/skills/redis-ui-components/references/FlexSplit.md +37 -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/Select.md +517 -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,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'`.
|
|
@@ -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`.
|