@redis-ui/components 41.4.1 → 42.0.0
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/README.md +330 -0
- package/dist/Button/Button.style.cjs +1 -1
- package/dist/Button/Button.style.js +1 -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/TextButton/TextButton.cjs +2 -0
- package/dist/Button/TextButton/TextButton.js +2 -0
- package/dist/Button/TextButton/TextButton.style.cjs +9 -3
- package/dist/Button/TextButton/TextButton.style.d.ts +1 -1
- package/dist/Button/TextButton/TextButton.style.js +9 -3
- package/dist/Button/TextButton/TextButton.types.d.ts +2 -0
- package/dist/Button/ToggleButton/ToggleButton.style.cjs +1 -1
- package/dist/Button/ToggleButton/ToggleButton.style.js +1 -1
- package/dist/Chip/Chip.cjs +3 -1
- package/dist/Chip/Chip.d.ts +2 -2
- package/dist/Chip/Chip.js +3 -1
- package/dist/Chip/Chip.types.d.ts +2 -1
- package/dist/Chip/components/CloseButton/CloseButton.cjs +2 -1
- package/dist/Chip/components/CloseButton/CloseButton.d.ts +1 -1
- package/dist/Chip/components/CloseButton/CloseButton.js +2 -1
- package/dist/Chip/components/CloseButton/CloseButton.types.d.ts +1 -1
- package/dist/ChipList/ChipList.cjs +2 -0
- package/dist/ChipList/ChipList.d.ts +1 -1
- package/dist/ChipList/ChipList.js +2 -0
- package/dist/ChipList/ChipList.types.d.ts +1 -0
- package/dist/ChipList/Components/ExtraItem.cjs +8 -7
- package/dist/ChipList/Components/ExtraItem.js +8 -7
- package/dist/Filters/components/MultiSelectFilter/MultiSelectFilter.cjs +2 -2
- package/dist/Filters/components/MultiSelectFilter/MultiSelectFilter.js +2 -2
- package/dist/Filters/components/MultiTreeSelectFilter/MultiTreeSelectFilter.cjs +2 -2
- package/dist/Filters/components/MultiTreeSelectFilter/MultiTreeSelectFilter.js +2 -2
- package/dist/FormField/FormField.context.cjs +4 -0
- package/dist/FormField/FormField.context.d.ts +3 -0
- package/dist/FormField/FormField.context.js +4 -0
- package/dist/FormField/components/Nested/Nested.cjs +4 -2
- package/dist/FormField/components/Nested/Nested.js +5 -3
- package/dist/Helpers/css.utils.cjs +8 -0
- package/dist/Helpers/css.utils.js +8 -0
- package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.cjs +6 -2
- package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.js +7 -3
- package/dist/Inputs/components/Compose/CommonCompose.cjs +16 -14
- package/dist/Inputs/components/Compose/CommonCompose.js +17 -15
- package/dist/Inputs/components/Context/InputValue.context.cjs +13 -9
- package/dist/Inputs/components/Context/InputValue.context.d.ts +270 -4
- package/dist/Inputs/components/Context/InputValue.context.js +13 -9
- package/dist/Inputs/components/Context/InputValueProvider.cjs +7 -2
- package/dist/Inputs/components/Context/InputValueProvider.js +8 -3
- package/dist/Inputs/components/Context/NumericInputValueProvider.cjs +6 -1
- package/dist/Inputs/components/Context/NumericInputValueProvider.js +7 -2
- package/dist/Inputs/components/InputTag/InputTag.cjs +6 -3
- package/dist/Inputs/components/InputTag/InputTag.js +7 -4
- package/dist/Inputs/components/InputTag/InputTag.style.cjs +1 -1
- package/dist/Inputs/components/InputTag/InputTag.style.js +1 -1
- package/dist/Inputs/components/ResetButton/ResetButton.cjs +7 -4
- package/dist/Inputs/components/ResetButton/ResetButton.js +7 -4
- package/dist/Label/components/Required/Required.cjs +8 -8
- package/dist/Label/components/Required/Required.js +8 -8
- package/dist/Layouts/FlexDivider/FlexDivider.cjs +22 -0
- package/dist/Layouts/FlexDivider/FlexDivider.d.ts +2 -0
- package/dist/Layouts/FlexDivider/FlexDivider.js +22 -0
- package/dist/Layouts/FlexDivider/FlexDivider.style.cjs +46 -0
- package/dist/Layouts/FlexDivider/FlexDivider.style.d.ts +6 -0
- package/dist/Layouts/FlexDivider/FlexDivider.style.js +44 -0
- package/dist/Layouts/FlexDivider/FlexDivider.types.d.ts +15 -0
- package/dist/Layouts/FlexGroup/FlexGroup.cjs +20 -0
- package/dist/Layouts/FlexGroup/FlexGroup.d.ts +2 -0
- package/dist/Layouts/FlexGroup/FlexGroup.js +20 -0
- package/dist/Layouts/FlexGroup/FlexGroup.style.cjs +20 -0
- package/dist/Layouts/FlexGroup/FlexGroup.style.d.ts +9 -0
- package/dist/Layouts/FlexGroup/FlexGroup.style.js +18 -0
- package/dist/Layouts/FlexGroup/FlexGroup.types.d.ts +19 -0
- package/dist/Layouts/FlexItem/FlexItem.cjs +16 -0
- package/dist/Layouts/FlexItem/FlexItem.d.ts +2 -0
- package/dist/Layouts/FlexItem/FlexItem.js +16 -0
- package/dist/Layouts/FlexItem/FlexItem.style.cjs +14 -0
- package/dist/Layouts/FlexItem/FlexItem.style.d.ts +5 -0
- package/dist/Layouts/FlexItem/FlexItem.style.js +12 -0
- package/dist/Layouts/FlexItem/FlexItem.types.d.ts +14 -0
- package/dist/Layouts/FlexSplit/FlexSplit.cjs +10 -0
- package/dist/Layouts/FlexSplit/FlexSplit.d.ts +2 -0
- package/dist/Layouts/FlexSplit/FlexSplit.js +10 -0
- package/dist/Layouts/FlexSplit/FlexSplit.style.cjs +27 -0
- package/dist/Layouts/FlexSplit/FlexSplit.style.d.ts +8 -0
- package/dist/Layouts/FlexSplit/FlexSplit.style.js +25 -0
- package/dist/Layouts/FlexSplit/FlexSplit.types.d.ts +8 -0
- package/dist/Layouts/index.d.ts +8 -0
- package/dist/MidBar/MidBar.cjs +30 -0
- package/dist/MidBar/MidBar.d.ts +22 -0
- package/dist/MidBar/MidBar.js +30 -0
- package/dist/MidBar/MidBar.types.d.ts +6 -0
- package/dist/MidBar/components/Header/Header.cjs +32 -0
- package/dist/MidBar/components/Header/Header.d.ts +15 -0
- package/dist/MidBar/components/Header/Header.js +32 -0
- package/dist/MidBar/components/Header/Header.types.d.ts +13 -0
- package/dist/MidBar/components/Header/components/Compose/Compose.cjs +8 -0
- package/dist/MidBar/components/Header/components/Compose/Compose.d.ts +3 -0
- package/dist/MidBar/components/Header/components/Compose/Compose.js +8 -0
- package/dist/MidBar/components/Header/components/Compose/Compose.style.cjs +31 -0
- package/dist/MidBar/components/Header/components/Compose/Compose.style.d.ts +1 -0
- package/dist/MidBar/components/Header/components/Compose/Compose.style.js +29 -0
- package/dist/MidBar/components/Header/components/Compose/Compose.types.d.ts +2 -0
- package/dist/MidBar/components/Header/components/Group/Group.cjs +12 -0
- package/dist/MidBar/components/Header/components/Group/Group.d.ts +3 -0
- package/dist/MidBar/components/Header/components/Group/Group.js +12 -0
- package/dist/MidBar/components/Header/components/Group/Group.style.cjs +22 -0
- package/dist/MidBar/components/Header/components/Group/Group.style.d.ts +4 -0
- package/dist/MidBar/components/Header/components/Group/Group.style.js +20 -0
- package/dist/MidBar/components/Header/components/Group/Group.types.d.ts +5 -0
- package/dist/MidBar/index.d.ts +2 -0
- package/dist/MoreInfoIcon/MoreInfoIcon.style.cjs +1 -1
- package/dist/MoreInfoIcon/MoreInfoIcon.style.js +1 -1
- package/dist/RadioGroup/RadioGroup.cjs +5 -23
- package/dist/RadioGroup/RadioGroup.d.ts +2 -15
- package/dist/RadioGroup/RadioGroup.js +5 -23
- package/dist/RadioGroup/RadioGroup.types.d.ts +1 -27
- package/dist/RadioGroup/components/Compose/Compose.cjs +23 -12
- package/dist/RadioGroup/components/Compose/Compose.d.ts +1 -1
- package/dist/RadioGroup/components/Compose/Compose.js +23 -12
- package/dist/RadioGroup/components/Compose/Compose.style.cjs +3 -1
- package/dist/RadioGroup/components/Compose/Compose.style.js +3 -1
- package/dist/RadioGroup/components/Item/Item.context.cjs +5 -10
- package/dist/RadioGroup/components/Item/Item.context.d.ts +1 -2
- package/dist/RadioGroup/components/Item/Item.context.js +5 -10
- package/dist/RadioGroup/components/Item/components/Compose/Compose.cjs +1 -1
- package/dist/RadioGroup/components/Item/components/Compose/Compose.js +2 -2
- package/dist/RadioGroup/components/Item/components/Indicator/Indicator.cjs +3 -1
- package/dist/RadioGroup/components/Item/components/Indicator/Indicator.js +3 -1
- package/dist/SearchBar/components/SearchSection/components/Actions/components/ColumnSelector/ColumnSelector.cjs +5 -7
- package/dist/SearchBar/components/SearchSection/components/Actions/components/ColumnSelector/ColumnSelector.js +5 -7
- package/dist/SearchBar/components/SearchSection/components/Actions/components/FiltersToggle/FiltersToggle.cjs +11 -9
- package/dist/SearchBar/components/SearchSection/components/Actions/components/FiltersToggle/FiltersToggle.js +11 -9
- package/dist/Select/components/Context/Context.cjs +6 -4
- package/dist/Select/components/Context/Context.js +7 -5
- package/dist/Select/components/Trigger/components/Compose/Compose.cjs +5 -0
- package/dist/Select/components/Trigger/components/Compose/Compose.js +6 -1
- package/dist/Select/components/Trigger/components/Compose/Compose.style.cjs +5 -0
- package/dist/Select/components/Trigger/components/Compose/Compose.style.js +5 -0
- package/dist/Stepper/Stepper.context.cjs +5 -10
- package/dist/Stepper/Stepper.context.d.ts +1 -2
- package/dist/Stepper/Stepper.context.js +5 -10
- package/dist/Stepper/Stepper.d.ts +4 -4
- package/dist/Stepper/components/Compose/Compose.cjs +6 -1
- package/dist/Stepper/components/Compose/Compose.d.ts +2 -2
- package/dist/Stepper/components/Compose/Compose.js +7 -2
- package/dist/Stepper/components/Step/Step.context.cjs +5 -10
- package/dist/Stepper/components/Step/Step.context.d.ts +1 -2
- package/dist/Stepper/components/Step/Step.context.js +5 -10
- package/dist/Stepper/components/Step/Step.d.ts +2 -3
- package/dist/Stepper/components/Step/components/Compose/Compose.cjs +1 -3
- package/dist/Stepper/components/Step/components/Compose/Compose.d.ts +1 -1
- package/dist/Stepper/components/Step/components/Compose/Compose.js +2 -4
- package/dist/Stepper/components/Step/components/Compose/Compose.style.cjs +2 -5
- package/dist/Stepper/components/Step/components/Compose/Compose.style.js +4 -7
- package/dist/Stepper/hooks/useStepperFocusing.cjs +31 -0
- package/dist/Stepper/hooks/useStepperFocusing.d.ts +16 -0
- package/dist/Stepper/hooks/useStepperFocusing.js +31 -0
- package/dist/Stepper/hooks/useStepperInteractive.cjs +30 -37
- package/dist/Stepper/hooks/useStepperInteractive.d.ts +2 -3
- package/dist/Stepper/hooks/useStepperInteractive.js +30 -37
- package/dist/ThemeModeSwitch/ThemeModeSwitch.cjs +64 -0
- package/dist/ThemeModeSwitch/ThemeModeSwitch.d.ts +2 -0
- package/dist/ThemeModeSwitch/ThemeModeSwitch.js +64 -0
- package/dist/ThemeModeSwitch/ThemeModeSwitch.style.cjs +38 -0
- package/dist/ThemeModeSwitch/ThemeModeSwitch.style.d.ts +4 -0
- package/dist/ThemeModeSwitch/ThemeModeSwitch.style.js +36 -0
- package/dist/ThemeModeSwitch/ThemeModeSwitch.types.d.ts +7 -0
- package/dist/ThemeModeSwitch/index.d.ts +3 -0
- package/dist/ThemeModeSwitch/useThemeModeSwitch.cjs +37 -0
- package/dist/ThemeModeSwitch/useThemeModeSwitch.d.ts +8 -0
- package/dist/ThemeModeSwitch/useThemeModeSwitch.js +37 -0
- package/dist/Toast/Toaster.cjs +4 -6
- package/dist/Toast/Toaster.d.ts +2 -1
- package/dist/Toast/Toaster.js +4 -6
- package/dist/Toast/Toaster.style.cjs +2 -2
- package/dist/Toast/Toaster.style.d.ts +2 -2
- package/dist/Toast/Toaster.style.js +3 -3
- package/dist/Toast/core/core.d.ts +3 -3
- package/dist/Toast/core/mapping.helpers.cjs +18 -2
- package/dist/Toast/core/mapping.helpers.d.ts +4 -3
- package/dist/Toast/core/mapping.helpers.js +22 -6
- package/dist/Toast/core/mapping.types.d.ts +3 -2
- package/dist/index.cjs +1092 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1139 -48
- package/dist/node_modules/clsx/dist/clsx.cjs +17 -0
- package/dist/node_modules/clsx/dist/clsx.js +17 -0
- package/dist/packages/components/node_modules/react-toastify/dist/react-toastify.esm.cjs +320 -0
- package/dist/packages/components/node_modules/react-toastify/dist/react-toastify.esm.js +318 -0
- package/dist/packages/icons/dist/multicolor/LoaderLarge.cjs +2 -2
- package/dist/packages/icons/dist/multicolor/LoaderLarge.js +2 -2
- package/dist/packages/icons/dist/multicolor/dark/LoaderLarge.cjs +3 -8
- package/dist/packages/icons/dist/multicolor/dark/LoaderLarge.js +3 -8
- package/dist/packages/icons/dist/multicolor/light/LoaderLarge.cjs +3 -8
- package/dist/packages/icons/dist/multicolor/light/LoaderLarge.js +3 -8
- package/package.json +4 -4
- package/dist/node_modules/clsx/dist/clsx.m.cjs +0 -15
- package/dist/node_modules/clsx/dist/clsx.m.js +0 -15
- package/dist/node_modules/react-toastify/dist/react-toastify.esm.cjs +0 -300
- package/dist/node_modules/react-toastify/dist/react-toastify.esm.js +0 -298
package/README.md
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
# Creating New Components Guide
|
|
2
|
+
|
|
3
|
+
This guide covers best practices, conventions, and patterns for creating new components in the `@redislabsdev/redis-ui-components` library.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Radix UI Foundation](#radix-ui-foundation)
|
|
8
|
+
- [Component Structure](#component-structure)
|
|
9
|
+
- [File Organization](#file-organization)
|
|
10
|
+
- [Component Composition](#component-composition)
|
|
11
|
+
- [Testing](#testing)
|
|
12
|
+
|
|
13
|
+
## Radix UI Foundation
|
|
14
|
+
|
|
15
|
+
This component library is built on top of [Radix UI](https://www.radix-ui.com/), a low-level UI component library that provides unstyled, accessible primitives for building high-quality design systems and web applications.
|
|
16
|
+
|
|
17
|
+
> **Note:** Not all components need Radix. Simple presentational components (like Button, Badge, Card) can be built from scratch using styled-components.
|
|
18
|
+
|
|
19
|
+
> **Note:** When using Radix, or any other external library for that matter, make sure you don't expose Radix types in public API. Always wrap them in our own types.
|
|
20
|
+
|
|
21
|
+
## Component Structure
|
|
22
|
+
|
|
23
|
+
### Basic Component Anatomy
|
|
24
|
+
|
|
25
|
+
Every component should follow this folder structure:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
src/ComponentName/
|
|
29
|
+
├── ComponentName.tsx # Main component implementation
|
|
30
|
+
├── ComponentName.types.ts # Types and interfaces
|
|
31
|
+
├── ComponentName.style.ts # Styles
|
|
32
|
+
├── ComponentName.test.tsx # Unit tests
|
|
33
|
+
├── index.ts # Public exports
|
|
34
|
+
└── components/ # Sub-components (if needed)
|
|
35
|
+
└── SubComponent/
|
|
36
|
+
├── SubComponent.tsx
|
|
37
|
+
├── SubComponent.types.ts
|
|
38
|
+
└── SubComponent.style.ts
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The tree is recurisve, so you can have sub-components inside sub-components, etc.
|
|
42
|
+
|
|
43
|
+
### Example: Simple Component
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
// Card.tsx
|
|
47
|
+
import * as S from './Card.style';
|
|
48
|
+
import { CardProps } from './Card.types';
|
|
49
|
+
|
|
50
|
+
const Card = (props: CardProps) => <S.Card {...props} />;
|
|
51
|
+
|
|
52
|
+
export default Card;
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## File Organization
|
|
59
|
+
|
|
60
|
+
### 1. Component File (`ComponentName.tsx`)
|
|
61
|
+
|
|
62
|
+
**✅ DO:**
|
|
63
|
+
- Use `React.forwardRef` when the component wraps a DOM element
|
|
64
|
+
- Provide default props for optional parameters
|
|
65
|
+
- Import styles as `* as S` for namespacing
|
|
66
|
+
- Keep the main component focused and delegate to sub-components
|
|
67
|
+
|
|
68
|
+
**❌ DON'T:**
|
|
69
|
+
- Mix business logic with presentation
|
|
70
|
+
- Hardcode theme values
|
|
71
|
+
|
|
72
|
+
### 2. Types File (`ComponentName.types.ts`)
|
|
73
|
+
|
|
74
|
+
**Conventions:**
|
|
75
|
+
- Always use separate file for types
|
|
76
|
+
- Extend HTML element attributes when wrapping native elements
|
|
77
|
+
- Use generics for flexible, reusable components
|
|
78
|
+
- If there are sub-components, create separate types file for each of them and compose the styles at the root level
|
|
79
|
+
- Use fully qualified names for exported types
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
// Button.types.ts
|
|
83
|
+
import { ButtonHTMLAttributes } from 'react';
|
|
84
|
+
|
|
85
|
+
export const buttonSizes = ['large', 'medium', 'small'] as const;
|
|
86
|
+
export const buttonVariants = ['primary', 'destructive', 'secondary-fill'] as const;
|
|
87
|
+
|
|
88
|
+
export type ButtonSizes = (typeof buttonSizes)[number];
|
|
89
|
+
export type ButtonVariants = (typeof buttonVariants)[number];
|
|
90
|
+
|
|
91
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
92
|
+
size?: ButtonSizes;
|
|
93
|
+
variant?: ButtonVariants;
|
|
94
|
+
disabled?: boolean;
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 3. Style File (`ComponentName.style.ts`)
|
|
99
|
+
|
|
100
|
+
**✅ DO:**
|
|
101
|
+
- Access theme values via `useTheme().components.componentName`
|
|
102
|
+
- Use token maps for consistent styling
|
|
103
|
+
- Use fully qualified names for exported styled components
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
// Button.style.ts
|
|
107
|
+
import styled, { css } from 'styled-components/macro';
|
|
108
|
+
import { getFocusStyle, useTheme } from '@redislabsdev/redis-ui-styles';
|
|
109
|
+
import { ButtonProps } from './Button.types';
|
|
110
|
+
|
|
111
|
+
export const baseButtonStyle = css`
|
|
112
|
+
border: 0;
|
|
113
|
+
display: inline-flex;
|
|
114
|
+
justify-content: center;
|
|
115
|
+
align-items: center;
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
|
|
118
|
+
${getFocusStyle()};
|
|
119
|
+
|
|
120
|
+
&:disabled {
|
|
121
|
+
cursor: not-allowed;
|
|
122
|
+
}
|
|
123
|
+
`;
|
|
124
|
+
|
|
125
|
+
export const Button = styled.button<Required<Pick<ButtonProps, 'size' | 'variant'>>>`
|
|
126
|
+
${baseButtonStyle};
|
|
127
|
+
gap: ${() => useTheme().components.button.gap};
|
|
128
|
+
padding: ${({ size }) => useTheme().components.button.sizes[size].padding};
|
|
129
|
+
background-color: ${({ variant }) => useTheme().components.button.variants[variant].bgColor};
|
|
130
|
+
`;
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**❌ DON'T:**
|
|
134
|
+
- Hardcode colors, spacing, or other design tokens
|
|
135
|
+
- Use inline styles
|
|
136
|
+
|
|
137
|
+
### 4. Index File (`index.ts`)
|
|
138
|
+
|
|
139
|
+
**Conventions:**
|
|
140
|
+
- Export the default component
|
|
141
|
+
- Export all types using `export *`
|
|
142
|
+
- Export styles as namespace if needed for external customization
|
|
143
|
+
- Export utility hooks/functions if applicable
|
|
144
|
+
|
|
145
|
+
## Component Composition
|
|
146
|
+
|
|
147
|
+
> **Note:** It’s best to discuss whether composition is appropriate early on, ideally during the design phase. By the time a PR is under review, changing this decision will involve substantial changes. Feel free to reach out to FE Infra team for advice.
|
|
148
|
+
|
|
149
|
+
### Object.assign Pattern
|
|
150
|
+
|
|
151
|
+
For components with sub-components, use `Object.assign`:
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
// Tabs.tsx
|
|
155
|
+
import { TabsProps } from './Tabs.types';
|
|
156
|
+
import ContentPane from './components/ContentPane/ContentPane';
|
|
157
|
+
import TabBar from './components/TabBar/TabBar';
|
|
158
|
+
import Compose from './components/Compose/Compose';
|
|
159
|
+
|
|
160
|
+
const Tabs = Object.assign(
|
|
161
|
+
({ tabs, variant, ...restProps }: TabsProps) => (
|
|
162
|
+
<Tabs.Compose {...restProps}>
|
|
163
|
+
<Tabs.TabBar tabs={tabs} variant={variant} />
|
|
164
|
+
<Tabs.ContentPane tabs={tabs} />
|
|
165
|
+
</Tabs.Compose>
|
|
166
|
+
),
|
|
167
|
+
{ Compose, TabBar, ContentPane }
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
export default Tabs;
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**Benefits:**
|
|
174
|
+
- Allows both simple and advanced usage patterns. Note that composed components should also provide simple props for non-advanced usage.
|
|
175
|
+
- Provides flexibility for custom layouts
|
|
176
|
+
- Maintains clean API surface
|
|
177
|
+
|
|
178
|
+
### Context Pattern
|
|
179
|
+
|
|
180
|
+
For sharing state between parent and children:
|
|
181
|
+
|
|
182
|
+
```tsx
|
|
183
|
+
// Component.context.ts
|
|
184
|
+
import { createContext, useContext } from 'react';
|
|
185
|
+
|
|
186
|
+
export const ComponentContext = createContext<ComponentContextParams>({
|
|
187
|
+
variant: 'default',
|
|
188
|
+
size: 'medium'
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
export const useComponentParams = (
|
|
192
|
+
customParams: Partial<ComponentContextParams> = {}
|
|
193
|
+
): ComponentContextParams => {
|
|
194
|
+
const context = useContext(ComponentContext);
|
|
195
|
+
return customParams ? assignWith({}, context, customParams, skipUndefined) : context;
|
|
196
|
+
};
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**✅ DO:**
|
|
200
|
+
- Use context for deeply nested component communication
|
|
201
|
+
- Memoize context values to prevent unnecessary re-renders
|
|
202
|
+
- Provide sensible defaults
|
|
203
|
+
|
|
204
|
+
**❌ DON'T:**
|
|
205
|
+
- Overuse context for simple prop drilling
|
|
206
|
+
- Forget to memoize context values
|
|
207
|
+
|
|
208
|
+
## Testing
|
|
209
|
+
|
|
210
|
+
### Test File Structure
|
|
211
|
+
|
|
212
|
+
```tsx
|
|
213
|
+
// Component.test.tsx
|
|
214
|
+
import { render, screen } from '@testing-library/react';
|
|
215
|
+
import Component from './Component';
|
|
216
|
+
|
|
217
|
+
describe('Component', () => {
|
|
218
|
+
describe('Basic rendering', () => {
|
|
219
|
+
it('should render with default props', () => {
|
|
220
|
+
render(<Component>Test content</Component>);
|
|
221
|
+
expect(screen.getByText('Test content')).toBeInTheDocument();
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
describe('Variants', () => {
|
|
226
|
+
it('should render primary variant', () => {
|
|
227
|
+
render(<Component variant="primary">Primary</Component>);
|
|
228
|
+
expect(screen.getByText('Primary')).toBeInTheDocument();
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
describe('Composition mode', () => {
|
|
233
|
+
it('should render with composition components', () => {
|
|
234
|
+
render(
|
|
235
|
+
<Component.Compose>
|
|
236
|
+
<Component.Header>Header</Component.Header>
|
|
237
|
+
<Component.Body>Body</Component.Body>
|
|
238
|
+
</Component.Compose>
|
|
239
|
+
);
|
|
240
|
+
expect(screen.getByText('Header')).toBeInTheDocument();
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### **Testing Library Queries**
|
|
247
|
+
|
|
248
|
+
Prefer queries in this order:
|
|
249
|
+
1. `getByRole` (most accessible)
|
|
250
|
+
2. `getByLabelText`
|
|
251
|
+
3. `getByPlaceholderText`
|
|
252
|
+
4. `getByText`
|
|
253
|
+
5. `getByTestId` (last resort)
|
|
254
|
+
|
|
255
|
+
You can find more info in [Testing Library docs](https://testing-library.com/docs/queries/about/).
|
|
256
|
+
|
|
257
|
+
## Tips & Tricks
|
|
258
|
+
|
|
259
|
+
### 1. **Transient Props in Styled Components**
|
|
260
|
+
|
|
261
|
+
Use `$` prefix for transient props:
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
// ✅ Good - won't pass $variant to DOM
|
|
265
|
+
const Button = styled.button<{ $variant: string }>`
|
|
266
|
+
color: ${({ $variant }) => $variant === 'primary' ? 'blue' : 'gray'};
|
|
267
|
+
`;
|
|
268
|
+
|
|
269
|
+
// ❌ Bad - will pass variant to DOM and cause warnings
|
|
270
|
+
const Button = styled.button<{ variant: string }>`
|
|
271
|
+
color: ${({ variant }) => variant === 'primary' ? 'blue' : 'gray'};
|
|
272
|
+
`;
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### 2. **Theme Type Safety**
|
|
276
|
+
|
|
277
|
+
Create theme types for your component in `packages/styles`:
|
|
278
|
+
|
|
279
|
+
```tsx
|
|
280
|
+
// packages/styles/src/themes/types/theme/components/myComponent.types.ts
|
|
281
|
+
export type MyComponentTheme = {
|
|
282
|
+
padding: string;
|
|
283
|
+
gap: string;
|
|
284
|
+
variants: {
|
|
285
|
+
primary: { bgColor: string; textColor: string };
|
|
286
|
+
secondary: { bgColor: string; textColor: string };
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Then add to all theme files (light, dark, light2, dark2).
|
|
292
|
+
|
|
293
|
+
### 3. **Composition Helpers**
|
|
294
|
+
|
|
295
|
+
Use helper types from `Helpers`:
|
|
296
|
+
|
|
297
|
+
```tsx
|
|
298
|
+
import { ComposeElementProps, ChildFree } from '../Helpers';
|
|
299
|
+
|
|
300
|
+
// ComposeElementProps: Standard props for composition components
|
|
301
|
+
// ChildFree: Omits children from props
|
|
302
|
+
type MyProps = ChildFree<ComposeElementProps>;
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### 4. **Storybook Integration**
|
|
306
|
+
|
|
307
|
+
Create stories in `docs/stories/ComponentName/`:
|
|
308
|
+
|
|
309
|
+
```tsx
|
|
310
|
+
// ComponentName.stories.tsx
|
|
311
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
312
|
+
import { ComponentName } from '@redislabsdev/redis-ui-components';
|
|
313
|
+
|
|
314
|
+
const meta: Meta<typeof ComponentName> = {
|
|
315
|
+
component: ComponentName,
|
|
316
|
+
title: 'Components/ComponentName'
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
export default meta;
|
|
320
|
+
type Story = StoryObj<typeof ComponentName>;
|
|
321
|
+
|
|
322
|
+
export const Playground: Story = {
|
|
323
|
+
args: {
|
|
324
|
+
variant: 'primary',
|
|
325
|
+
size: 'medium'
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
> **Note:** For composition components, create a separate `ComponentNameCompose.mdx` file.
|
|
@@ -25,7 +25,7 @@ const baseButtonStyle = _styled.css`
|
|
|
25
25
|
}
|
|
26
26
|
`;
|
|
27
27
|
const sizeTokenMaps = [css_utils.tokenMaps.borderRadius, css_utils.tokenMaps.padding, css_utils.tokenMaps.height, css_utils.tokenMaps.lineHeight];
|
|
28
|
-
const variantTokenMaps = [css_utils.tokenMaps.bgColor, css_utils.tokenMaps.textColor, css_utils.tokenMaps.shadowBorder];
|
|
28
|
+
const variantTokenMaps = [css_utils.tokenMaps.bgColor, css_utils.tokenMaps.bgGradient, css_utils.tokenMaps.textColor, css_utils.tokenMaps.shadowBorder];
|
|
29
29
|
const Button = _styled__default.default.button.withConfig({
|
|
30
30
|
displayName: "Buttonstyle__Button",
|
|
31
31
|
componentId: "RedisUI__sc-6zckac-0"
|
|
@@ -21,7 +21,7 @@ const baseButtonStyle = css`
|
|
|
21
21
|
}
|
|
22
22
|
`;
|
|
23
23
|
const sizeTokenMaps = [tokenMaps.borderRadius, tokenMaps.padding, tokenMaps.height, tokenMaps.lineHeight];
|
|
24
|
-
const variantTokenMaps = [tokenMaps.bgColor, tokenMaps.textColor, tokenMaps.shadowBorder];
|
|
24
|
+
const variantTokenMaps = [tokenMaps.bgColor, tokenMaps.bgGradient, tokenMaps.textColor, tokenMaps.shadowBorder];
|
|
25
25
|
const Button = _styled.button.withConfig({
|
|
26
26
|
displayName: "Buttonstyle__Button",
|
|
27
27
|
componentId: "RedisUI__sc-6zckac-0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const buttonSizes = ["large", "medium", "small"];
|
|
4
|
-
const buttonVariants = ["primary", "destructive", "secondary-fill", "secondary-invert", "secondary-ghost"];
|
|
4
|
+
const buttonVariants = ["primary", "destructive", "secondary-fill", "secondary-invert", "secondary-ghost", "upsell"];
|
|
5
5
|
exports.buttonSizes = buttonSizes;
|
|
6
6
|
exports.buttonVariants = buttonVariants;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ButtonHTMLAttributes } from 'react';
|
|
2
2
|
import { Theme } from '@redislabsdev/redis-ui-styles';
|
|
3
3
|
export declare const buttonSizes: readonly ["large", "medium", "small"];
|
|
4
|
-
export declare const buttonVariants: readonly ["primary", "destructive", "secondary-fill", "secondary-invert", "secondary-ghost"];
|
|
4
|
+
export declare const buttonVariants: readonly ["primary", "destructive", "secondary-fill", "secondary-invert", "secondary-ghost", "upsell"];
|
|
5
5
|
export type ButtonSizes = (typeof buttonSizes)[number];
|
|
6
6
|
export type ButtonVariants = (typeof buttonVariants)[number];
|
|
7
7
|
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const buttonSizes = ["large", "medium", "small"];
|
|
2
|
-
const buttonVariants = ["primary", "destructive", "secondary-fill", "secondary-invert", "secondary-ghost"];
|
|
2
|
+
const buttonVariants = ["primary", "destructive", "secondary-fill", "secondary-invert", "secondary-ghost", "upsell"];
|
|
3
3
|
export {
|
|
4
4
|
buttonSizes,
|
|
5
5
|
buttonVariants
|
|
@@ -7,6 +7,7 @@ const Button_context = require("../Button.context.cjs");
|
|
|
7
7
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
8
8
|
const React__default = /* @__PURE__ */ _interopDefault(React);
|
|
9
9
|
const TextButton = React__default.default.forwardRef(({
|
|
10
|
+
size = "M",
|
|
10
11
|
variant = "primary",
|
|
11
12
|
children,
|
|
12
13
|
...restProps
|
|
@@ -16,6 +17,7 @@ const TextButton = React__default.default.forwardRef(({
|
|
|
16
17
|
children: jsxRuntime.jsxRuntimeExports.jsx(TextButton_style.TextButton, {
|
|
17
18
|
type: "button",
|
|
18
19
|
variant,
|
|
20
|
+
size,
|
|
19
21
|
ref,
|
|
20
22
|
...restProps,
|
|
21
23
|
children
|
|
@@ -3,6 +3,7 @@ import React__default from "react";
|
|
|
3
3
|
import { TextButton as TextButton$2 } from "./TextButton.style.js";
|
|
4
4
|
import { ButtonContext } from "../Button.context.js";
|
|
5
5
|
const TextButton = React__default.forwardRef(({
|
|
6
|
+
size = "M",
|
|
6
7
|
variant = "primary",
|
|
7
8
|
children,
|
|
8
9
|
...restProps
|
|
@@ -12,6 +13,7 @@ const TextButton = React__default.forwardRef(({
|
|
|
12
13
|
children: jsxRuntimeExports.jsx(TextButton$2, {
|
|
13
14
|
type: "button",
|
|
14
15
|
variant,
|
|
16
|
+
size,
|
|
15
17
|
ref,
|
|
16
18
|
...restProps,
|
|
17
19
|
children
|
|
@@ -4,23 +4,29 @@ const _styled = require("styled-components");
|
|
|
4
4
|
const redisUiStyles = require("@redislabsdev/redis-ui-styles");
|
|
5
5
|
const Button_style = require("../Button.style.cjs");
|
|
6
6
|
const Body_style = require("../../Typography/components/Body/Body.style.cjs");
|
|
7
|
+
const css_utils = require("../../Helpers/css.utils.cjs");
|
|
7
8
|
const Button_style_utils = require("../Button.style.utils.cjs");
|
|
8
9
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
10
|
const _styled__default = /* @__PURE__ */ _interopDefault(_styled);
|
|
10
11
|
const getVariantStyle = (variant) => (theme) => {
|
|
11
12
|
const themeVariant = variant ? theme.components.textButton.variants[variant] : null;
|
|
12
13
|
return themeVariant ? _styled.css`
|
|
13
|
-
padding: ${themeVariant.padding};
|
|
14
|
-
border-radius: ${themeVariant.borderRadius};
|
|
15
14
|
border: 1px solid transparent;
|
|
16
15
|
box-sizing: border-box;
|
|
17
16
|
${Button_style_utils.getButtonStatesStyle(themeVariant.states, [Button_style_utils.bgColorMap, Button_style_utils.textColorMap, Button_style_utils.borderColorMap])};
|
|
18
17
|
` : null;
|
|
19
18
|
};
|
|
19
|
+
const sizeTokenMaps = [css_utils.tokenMaps.borderRadius, css_utils.tokenMaps.padding, css_utils.tokenMaps.height, css_utils.tokenMaps.lineHeight, css_utils.tokenMaps.gap];
|
|
20
20
|
const TextButton = _styled__default.default.button.withConfig({
|
|
21
21
|
displayName: "TextButtonstyle__TextButton",
|
|
22
22
|
componentId: "RedisUI__sc-1t8veic-0"
|
|
23
|
-
})(["", ";
|
|
23
|
+
})(["", ";", ";", ";", ";vertical-align:unset;"], Button_style.baseButtonStyle, ({
|
|
24
|
+
size,
|
|
25
|
+
variant
|
|
26
|
+
}) => {
|
|
27
|
+
const layout = variant.includes("inline") ? "inline" : "block";
|
|
28
|
+
return css_utils.styleFromTokens(sizeTokenMaps, redisUiStyles.useTheme().components.textButton.layouts[layout].sizes[size]);
|
|
29
|
+
}, () => Body_style.useBodyStyles(), ({
|
|
24
30
|
variant
|
|
25
31
|
}) => getVariantStyle(variant)(redisUiStyles.useTheme()));
|
|
26
32
|
exports.TextButton = TextButton;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TextButtonProps } from './TextButton.types';
|
|
2
|
-
export declare const TextButton: import("styled-components").StyledComponent<"button", any, Required<Pick<TextButtonProps, "variant">>, never>;
|
|
2
|
+
export declare const TextButton: import("styled-components").StyledComponent<"button", any, Required<Pick<TextButtonProps, "variant" | "size">>, never>;
|
|
@@ -2,21 +2,27 @@ import _styled, { css } from "styled-components";
|
|
|
2
2
|
import { useTheme } from "@redislabsdev/redis-ui-styles";
|
|
3
3
|
import { baseButtonStyle } from "../Button.style.js";
|
|
4
4
|
import { useBodyStyles } from "../../Typography/components/Body/Body.style.js";
|
|
5
|
+
import { styleFromTokens, tokenMaps } from "../../Helpers/css.utils.js";
|
|
5
6
|
import { getButtonStatesStyle, bgColorMap, textColorMap, borderColorMap } from "../Button.style.utils.js";
|
|
6
7
|
const getVariantStyle = (variant) => (theme) => {
|
|
7
8
|
const themeVariant = variant ? theme.components.textButton.variants[variant] : null;
|
|
8
9
|
return themeVariant ? css`
|
|
9
|
-
padding: ${themeVariant.padding};
|
|
10
|
-
border-radius: ${themeVariant.borderRadius};
|
|
11
10
|
border: 1px solid transparent;
|
|
12
11
|
box-sizing: border-box;
|
|
13
12
|
${getButtonStatesStyle(themeVariant.states, [bgColorMap, textColorMap, borderColorMap])};
|
|
14
13
|
` : null;
|
|
15
14
|
};
|
|
15
|
+
const sizeTokenMaps = [tokenMaps.borderRadius, tokenMaps.padding, tokenMaps.height, tokenMaps.lineHeight, tokenMaps.gap];
|
|
16
16
|
const TextButton = _styled.button.withConfig({
|
|
17
17
|
displayName: "TextButtonstyle__TextButton",
|
|
18
18
|
componentId: "RedisUI__sc-1t8veic-0"
|
|
19
|
-
})(["", ";
|
|
19
|
+
})(["", ";", ";", ";", ";vertical-align:unset;"], baseButtonStyle, ({
|
|
20
|
+
size,
|
|
21
|
+
variant
|
|
22
|
+
}) => {
|
|
23
|
+
const layout = variant.includes("inline") ? "inline" : "block";
|
|
24
|
+
return styleFromTokens(sizeTokenMaps, useTheme().components.textButton.layouts[layout].sizes[size]);
|
|
25
|
+
}, () => useBodyStyles(), ({
|
|
20
26
|
variant
|
|
21
27
|
}) => getVariantStyle(variant)(useTheme()));
|
|
22
28
|
export {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ButtonHTMLAttributes } from 'react';
|
|
2
|
+
export type TextButtonSizes = 'M';
|
|
2
3
|
export declare const textButtonVariants: readonly ["primary", "destructive", "primary-inline", "destructive-inline"];
|
|
3
4
|
export type TextButtonVariants = (typeof textButtonVariants)[number];
|
|
4
5
|
export interface TextButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
6
|
+
size?: TextButtonSizes;
|
|
5
7
|
variant?: TextButtonVariants;
|
|
6
8
|
}
|
|
@@ -11,5 +11,5 @@ const _styled__default = /* @__PURE__ */ _interopDefault(_styled);
|
|
|
11
11
|
const ToggleButton = _styled__default.default.button.withConfig({
|
|
12
12
|
displayName: "ToggleButtonstyle__ToggleButton",
|
|
13
13
|
componentId: "RedisUI__sc-1o8wm2j-0"
|
|
14
|
-
})(["", ";height:", ";line-height:", ";gap:", ";", ";padding:", ";border-radius:", ";border:1px solid transparent;&:where(:not([
|
|
14
|
+
})(["", ";height:", ";line-height:", ";gap:", ";", ";padding:", ";border-radius:", ";border:1px solid transparent;&:where(:not([aria-pressed='true'])){", "}&:where([aria-pressed='true']){", "}&:disabled ", "{opacity:", ";}"], Button_style.baseButtonStyle, () => redisUiStyles.useTheme().components.toggleButton.height, () => redisUiStyles.useTheme().components.toggleButton.lineHeight, () => redisUiStyles.useTheme().components.toggleButton.gap, () => Body_style.useBodyStyles(), () => redisUiStyles.useTheme().components.toggleButton.padding, () => redisUiStyles.useTheme().components.toggleButton.borderRadius, () => Button_style_utils.getButtonStatesStyle(redisUiStyles.useTheme().components.toggleButton.toggleStates.off, [Button_style_utils.bgColorMap, Button_style_utils.textColorMap, Button_style_utils.borderColorMap]), () => Button_style_utils.getButtonStatesStyle(redisUiStyles.useTheme().components.toggleButton.toggleStates.on, [Button_style_utils.bgColorMap, Button_style_utils.textColorMap, Button_style_utils.borderColorMap]), IndicatorCount_style.IndicatorCount, () => redisUiStyles.useTheme().components.toggleButton.counter.disabledOpacity);
|
|
15
15
|
exports.ToggleButton = ToggleButton;
|
|
@@ -7,7 +7,7 @@ import { IndicatorCount } from "./components/IndicatorCount/IndicatorCount.style
|
|
|
7
7
|
const ToggleButton = _styled.button.withConfig({
|
|
8
8
|
displayName: "ToggleButtonstyle__ToggleButton",
|
|
9
9
|
componentId: "RedisUI__sc-1o8wm2j-0"
|
|
10
|
-
})(["", ";height:", ";line-height:", ";gap:", ";", ";padding:", ";border-radius:", ";border:1px solid transparent;&:where(:not([
|
|
10
|
+
})(["", ";height:", ";line-height:", ";gap:", ";", ";padding:", ";border-radius:", ";border:1px solid transparent;&:where(:not([aria-pressed='true'])){", "}&:where([aria-pressed='true']){", "}&:disabled ", "{opacity:", ";}"], baseButtonStyle, () => useTheme().components.toggleButton.height, () => useTheme().components.toggleButton.lineHeight, () => useTheme().components.toggleButton.gap, () => useBodyStyles(), () => useTheme().components.toggleButton.padding, () => useTheme().components.toggleButton.borderRadius, () => getButtonStatesStyle(useTheme().components.toggleButton.toggleStates.off, [bgColorMap, textColorMap, borderColorMap]), () => getButtonStatesStyle(useTheme().components.toggleButton.toggleStates.on, [bgColorMap, textColorMap, borderColorMap]), IndicatorCount, () => useTheme().components.toggleButton.counter.disabledOpacity);
|
|
11
11
|
export {
|
|
12
12
|
ToggleButton
|
|
13
13
|
};
|
package/dist/Chip/Chip.cjs
CHANGED
|
@@ -7,6 +7,7 @@ const Title = require("./components/Title/Title.cjs");
|
|
|
7
7
|
const Chip = Object.assign(({
|
|
8
8
|
text,
|
|
9
9
|
onClose,
|
|
10
|
+
closeButtonTitle,
|
|
10
11
|
...restProps
|
|
11
12
|
}) => {
|
|
12
13
|
return jsxRuntime.jsxRuntimeExports.jsxs(Chip.Compose, {
|
|
@@ -14,7 +15,8 @@ const Chip = Object.assign(({
|
|
|
14
15
|
children: [jsxRuntime.jsxRuntimeExports.jsx(Chip.Title, {
|
|
15
16
|
children: text
|
|
16
17
|
}), jsxRuntime.jsxRuntimeExports.jsx(Chip.CloseButton, {
|
|
17
|
-
onClose
|
|
18
|
+
onClose,
|
|
19
|
+
title: closeButtonTitle
|
|
18
20
|
})]
|
|
19
21
|
});
|
|
20
22
|
}, {
|
package/dist/Chip/Chip.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ChipProps } from './Chip.types';
|
|
3
|
-
declare const Chip: (({ text, onClose, ...restProps }: ChipProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
3
|
+
declare const Chip: (({ text, onClose, closeButtonTitle, ...restProps }: ChipProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
4
4
|
Compose: ({ size, variant, disabled, tooltip, ...restProps }: import("..").ComposeChildrenProps & Omit<import("react").HTMLAttributes<HTMLSpanElement>, "content" | "children"> & import("./components/Compose/Compose.types").ChipComposeProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
Title: ({ size, ...restProps }: import("..").TypographyBodyProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
CloseButton: ({ onClose, icon: Icon, ...restProps }: Pick<import("react").HTMLAttributes<HTMLElement>, "style" | "className"> & {
|
|
6
|
+
CloseButton: ({ onClose, icon: Icon, title, ...restProps }: Pick<import("react").HTMLAttributes<HTMLElement>, "style" | "title" | "className"> & {
|
|
7
7
|
icon?: import("@redislabsdev/redis-ui-icons/monochrome").IconType | undefined;
|
|
8
8
|
} & import("./components/CloseButton/CloseButton.types").ChipCloseButtonProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
9
9
|
};
|
package/dist/Chip/Chip.js
CHANGED
|
@@ -5,6 +5,7 @@ import { Title } from "./components/Title/Title.js";
|
|
|
5
5
|
const Chip = Object.assign(({
|
|
6
6
|
text,
|
|
7
7
|
onClose,
|
|
8
|
+
closeButtonTitle,
|
|
8
9
|
...restProps
|
|
9
10
|
}) => {
|
|
10
11
|
return jsxRuntimeExports.jsxs(Chip.Compose, {
|
|
@@ -12,7 +13,8 @@ const Chip = Object.assign(({
|
|
|
12
13
|
children: [jsxRuntimeExports.jsx(Chip.Title, {
|
|
13
14
|
children: text
|
|
14
15
|
}), jsxRuntimeExports.jsx(Chip.CloseButton, {
|
|
15
|
-
onClose
|
|
16
|
+
onClose,
|
|
17
|
+
title: closeButtonTitle
|
|
16
18
|
})]
|
|
17
19
|
});
|
|
18
20
|
}, {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ChipComposeProps, RestChipComposeProps } from './components/Compose/Compose.types';
|
|
2
2
|
import type { ChipCloseButtonProps } from './components/CloseButton/CloseButton.types';
|
|
3
|
-
import type { ChildFree } from '../Helpers
|
|
3
|
+
import type { ChildFree } from '../Helpers';
|
|
4
4
|
export interface ChipProps extends ChipComposeProps, ChildFree<RestChipComposeProps>, ChipCloseButtonProps {
|
|
5
5
|
text: string;
|
|
6
|
+
closeButtonTitle?: string;
|
|
6
7
|
}
|
|
7
8
|
export type ChipSizes = 'M' | 'S';
|
|
8
9
|
export type ChipVariants = 'regular' | 'flat';
|
|
@@ -11,6 +11,7 @@ const sizeMapper = {
|
|
|
11
11
|
const CloseButton = ({
|
|
12
12
|
onClose,
|
|
13
13
|
icon: Icon = redisUiIcons.ToastCancelIcon,
|
|
14
|
+
title = "Remove",
|
|
14
15
|
...restProps
|
|
15
16
|
}) => {
|
|
16
17
|
const {
|
|
@@ -29,7 +30,7 @@ const CloseButton = ({
|
|
|
29
30
|
onClick: handleRemoveChip,
|
|
30
31
|
"$size": size,
|
|
31
32
|
"$variant": variant,
|
|
32
|
-
title
|
|
33
|
+
title,
|
|
33
34
|
...restProps,
|
|
34
35
|
children: jsxRuntime.jsxRuntimeExports.jsx(Icon, {
|
|
35
36
|
size: sizeMapper[size],
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ChipCloseButtonProps, RestChipCloseButtonProps } from './CloseButton.types';
|
|
2
|
-
export declare const CloseButton: ({ onClose, icon: Icon, ...restProps }: RestChipCloseButtonProps & ChipCloseButtonProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
2
|
+
export declare const CloseButton: ({ onClose, icon: Icon, title, ...restProps }: RestChipCloseButtonProps & ChipCloseButtonProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -9,6 +9,7 @@ const sizeMapper = {
|
|
|
9
9
|
const CloseButton = ({
|
|
10
10
|
onClose,
|
|
11
11
|
icon: Icon = ToastCancelIcon,
|
|
12
|
+
title = "Remove",
|
|
12
13
|
...restProps
|
|
13
14
|
}) => {
|
|
14
15
|
const {
|
|
@@ -27,7 +28,7 @@ const CloseButton = ({
|
|
|
27
28
|
onClick: handleRemoveChip,
|
|
28
29
|
"$size": size,
|
|
29
30
|
"$variant": variant,
|
|
30
|
-
title
|
|
31
|
+
title,
|
|
31
32
|
...restProps,
|
|
32
33
|
children: jsxRuntimeExports.jsx(Icon, {
|
|
33
34
|
size: sizeMapper[size],
|
|
@@ -3,6 +3,6 @@ import { IconType } from '@redislabsdev/redis-ui-icons';
|
|
|
3
3
|
export type ChipCloseButtonProps = {
|
|
4
4
|
onClose?: VoidFunction;
|
|
5
5
|
};
|
|
6
|
-
export type RestChipCloseButtonProps = Pick<HTMLAttributes<HTMLElement>, 'className' | 'style'> & {
|
|
6
|
+
export type RestChipCloseButtonProps = Pick<HTMLAttributes<HTMLElement>, 'className' | 'style' | 'title'> & {
|
|
7
7
|
icon?: IconType;
|
|
8
8
|
};
|
|
@@ -7,6 +7,7 @@ const ChipList_style = require("./ChipList.style.cjs");
|
|
|
7
7
|
const ChipList = ({
|
|
8
8
|
chips,
|
|
9
9
|
onRemoveItem,
|
|
10
|
+
removeItemButtonTitle,
|
|
10
11
|
maxRows = 1,
|
|
11
12
|
size = "M",
|
|
12
13
|
variant,
|
|
@@ -28,6 +29,7 @@ const ChipList = ({
|
|
|
28
29
|
children: chips.map((item) => jsxRuntime.jsxRuntimeExports.jsx(Chip.default, {
|
|
29
30
|
text: item.label,
|
|
30
31
|
onClose: onRemoveItem ? () => onRemoveItem(item.key) : void 0,
|
|
32
|
+
closeButtonTitle: removeItemButtonTitle,
|
|
31
33
|
tooltip: item.tooltip,
|
|
32
34
|
size,
|
|
33
35
|
variant,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ChipListProps } from './ChipList.types';
|
|
2
|
-
declare const ChipList: ({ chips, onRemoveItem, maxRows, size, variant, disabled, renderExtraTooltip, ...restProps }: ChipListProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const ChipList: ({ chips, onRemoveItem, removeItemButtonTitle, maxRows, size, variant, disabled, renderExtraTooltip, ...restProps }: ChipListProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default ChipList;
|