@utilitywarehouse/hearth-react-native 0.21.0 → 0.22.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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +14 -14
- package/CHANGELOG.md +38 -0
- package/build/components/Card/Card.props.d.ts +4 -8
- package/build/components/Card/CardRoot.js +0 -1
- package/build/components/Checkbox/Checkbox.d.ts +1 -1
- package/build/components/Checkbox/Checkbox.js +2 -2
- package/build/components/Checkbox/Checkbox.props.d.ts +2 -0
- package/build/components/Modal/Modal.js +1 -1
- package/build/components/Radio/Radio.d.ts +1 -1
- package/build/components/Radio/Radio.js +2 -2
- package/build/components/Radio/Radio.props.d.ts +2 -0
- package/build/components/VerificationInput/VerificationInput.js +182 -20
- package/build/components/VerificationInput/VerificationInputSlot.d.ts +7 -3
- package/build/components/VerificationInput/VerificationInputSlot.js +45 -7
- package/docs/changelog.mdx +249 -0
- package/docs/components/NextPrevPage.tsx +2 -2
- package/package.json +6 -6
- package/src/components/Card/Card.props.ts +5 -8
- package/src/components/Card/CardRoot.tsx +0 -1
- package/src/components/Checkbox/Checkbox.docs.mdx +1 -0
- package/src/components/Checkbox/Checkbox.props.ts +2 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +26 -0
- package/src/components/Checkbox/Checkbox.tsx +2 -0
- package/src/components/Modal/Modal.tsx +1 -1
- package/src/components/Radio/Radio.docs.mdx +1 -0
- package/src/components/Radio/Radio.props.ts +2 -0
- package/src/components/Radio/Radio.stories.tsx +22 -0
- package/src/components/Radio/Radio.tsx +2 -0
- package/src/components/Radio/RadioTile.figma.tsx +4 -0
- package/src/components/VerificationInput/VerificationInput.tsx +218 -29
- package/src/components/VerificationInput/VerificationInputSlot.tsx +90 -14
- package/build/components/VerificationInput/useVerificationInput.d.ts +0 -15
- package/build/components/VerificationInput/useVerificationInput.js +0 -73
- package/src/components/VerificationInput/useVerificationInput.ts +0 -88
package/docs/changelog.mdx
CHANGED
|
@@ -9,6 +9,255 @@ import { BackToTopButton } from './components';
|
|
|
9
9
|
The changelog for the Hearth React Native library. Here you can find all the changes, improvements, and bug fixes for each version.
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
## 0.21.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#917](https://github.com/utilitywarehouse/hearth/pull/917) [`6a016dc`](https://github.com/utilitywarehouse/hearth/commit/6a016dca0d1a06e40a877da15aced590d0c68112) Thanks [@jordmccord](https://github.com/jordmccord)! - 🌟 [FEATURE]: Add 2xl size variant to Heading component
|
|
17
|
+
|
|
18
|
+
The `Heading` component now supports a `2xl` size option, providing a larger heading size for prominent page titles and hero sections. This size is responsive across device sizes with appropriate font sizes and line heights for mobile, tablet, and desktop viewports.
|
|
19
|
+
|
|
20
|
+
**Components affected**:
|
|
21
|
+
- `Heading`
|
|
22
|
+
|
|
23
|
+
**Developer changes**:
|
|
24
|
+
|
|
25
|
+
Use the new `2xl` size prop:
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
<Heading size="2xl">Welcome to Hearth</Heading>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The `2xl` size will render with:
|
|
32
|
+
- Mobile: 44px font size, 52px line height
|
|
33
|
+
- Tablet: 44px font size, 52px line height
|
|
34
|
+
- Desktop: 54px font size, 62px line height
|
|
35
|
+
|
|
36
|
+
- [#949](https://github.com/utilitywarehouse/hearth/pull/949) [`e1aacf0`](https://github.com/utilitywarehouse/hearth/commit/e1aacf06a58fd8358e9e7546ec35d8194a0d8d74) Thanks [@MichalCiesliczka](https://github.com/MichalCiesliczka)! - 🌟 [FEATURE]: Add segment refs to `DateInput` for programmatic focus control
|
|
37
|
+
|
|
38
|
+
The `DateInput` component now supports direct refs for each segment input via `dayRef`, `monthRef`, and `yearRef`.
|
|
39
|
+
This makes it easier to move focus between segments from custom flows (for example, advancing focus after validation or from custom buttons).
|
|
40
|
+
|
|
41
|
+
Documentation and Storybook examples are also updated to show how to use segment refs in real usage.
|
|
42
|
+
|
|
43
|
+
**Components affected**:
|
|
44
|
+
- `DateInput`
|
|
45
|
+
|
|
46
|
+
**Developer changes**:
|
|
47
|
+
|
|
48
|
+
You can now pass refs to each segment and call `.focus()` when needed:
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
import { useRef, useState } from 'react';
|
|
52
|
+
import { TextInput } from 'react-native';
|
|
53
|
+
import { Button, DateInput } from '@utilitywarehouse/hearth-react-native';
|
|
54
|
+
|
|
55
|
+
const DateWithSegmentFocus = () => {
|
|
56
|
+
const [day, setDay] = useState('');
|
|
57
|
+
const [month, setMonth] = useState('');
|
|
58
|
+
const [year, setYear] = useState('');
|
|
59
|
+
|
|
60
|
+
const dayRef = useRef<TextInput>(null);
|
|
61
|
+
const monthRef = useRef<TextInput>(null);
|
|
62
|
+
const yearRef = useRef<TextInput>(null);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
<DateInput
|
|
67
|
+
label="Date of birth"
|
|
68
|
+
dayValue={day}
|
|
69
|
+
monthValue={month}
|
|
70
|
+
yearValue={year}
|
|
71
|
+
onDayChange={setDay}
|
|
72
|
+
onMonthChange={setMonth}
|
|
73
|
+
onYearChange={setYear}
|
|
74
|
+
dayRef={dayRef}
|
|
75
|
+
monthRef={monthRef}
|
|
76
|
+
yearRef={yearRef}
|
|
77
|
+
/>
|
|
78
|
+
|
|
79
|
+
<Button onPress={() => monthRef.current?.focus()}>Focus month</Button>
|
|
80
|
+
</>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
This is a non-breaking enhancement, so existing `DateInput` usage continues to work without any changes.
|
|
86
|
+
|
|
87
|
+
- [#918](https://github.com/utilitywarehouse/hearth/pull/918) [`2db4dbe`](https://github.com/utilitywarehouse/hearth/commit/2db4dbe273583239b148c4399af829df596a00c1) Thanks [@jordmccord](https://github.com/jordmccord)! - 💔 [BREAKING CHANGE]: Simplify semantic token naming and introduce utility prop types
|
|
88
|
+
|
|
89
|
+
This release simplifies the semantic token naming convention and introduces a new utility prop system to make the API more intuitive and consistent across components.
|
|
90
|
+
|
|
91
|
+
**Components affected**:
|
|
92
|
+
- `Box`
|
|
93
|
+
- `Container`
|
|
94
|
+
- `Card`
|
|
95
|
+
- `Flex`
|
|
96
|
+
- `Grid`
|
|
97
|
+
- `Center`
|
|
98
|
+
- `BodyText`
|
|
99
|
+
- `Heading`
|
|
100
|
+
- `DetailText`
|
|
101
|
+
- `Carousel`
|
|
102
|
+
- `CarouselItem`
|
|
103
|
+
|
|
104
|
+
**Developer changes**:
|
|
105
|
+
|
|
106
|
+
### Background Colors
|
|
107
|
+
|
|
108
|
+
Background color props now accept simplified semantic tokens. Update your code as follows:
|
|
109
|
+
|
|
110
|
+
```diff
|
|
111
|
+
- <Box backgroundColor="backgroundPrimary">
|
|
112
|
+
+ <Box backgroundColor="primary">
|
|
113
|
+
|
|
114
|
+
- <Box backgroundColor="backgroundSecondary">
|
|
115
|
+
+ <Box backgroundColor="secondary">
|
|
116
|
+
|
|
117
|
+
- <Box backgroundColor="backgroundBrand">
|
|
118
|
+
+ <Box backgroundColor="brand">
|
|
119
|
+
|
|
120
|
+
- <Container bg="backgroundPrimary">
|
|
121
|
+
+ <Container bg="primary">
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
You can still use full color tokens (e.g., `backgroundColor={color.blue[400]}`) by using a `StyleSheet`, the `useTheme` hook, or directly importing from the tokens library:
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
import { StyleSheet } from 'react-native';
|
|
128
|
+
|
|
129
|
+
const styles = StyleSheet.create(theme => ({
|
|
130
|
+
customBackground: {
|
|
131
|
+
backgroundColor: theme.color.blue[400],
|
|
132
|
+
},
|
|
133
|
+
}));
|
|
134
|
+
|
|
135
|
+
<Box style={styles.customBackground} />;
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import { useTheme } from '@utilitywarehouse/hearth-react-native';
|
|
140
|
+
|
|
141
|
+
const theme = useTheme();
|
|
142
|
+
|
|
143
|
+
<Box backgroundColor={theme.color.purple[800]} />;
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
148
|
+
|
|
149
|
+
<Box backgroundColor={color.blue[400]} />;
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Text Colors
|
|
153
|
+
|
|
154
|
+
Text color props now accept simplified semantic tokens:
|
|
155
|
+
|
|
156
|
+
```diff
|
|
157
|
+
- <BodyText color="white">Text</BodyText>
|
|
158
|
+
+ <BodyText color="inverted">Text</BodyText>
|
|
159
|
+
|
|
160
|
+
- <BodyText color="grey1000">Text</BodyText>
|
|
161
|
+
+ <BodyText color="primary">Text</BodyText>
|
|
162
|
+
|
|
163
|
+
- <Heading color="textSecondary">Heading</Heading>
|
|
164
|
+
+ <Heading color="secondary">Heading</Heading>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Border Colors
|
|
168
|
+
|
|
169
|
+
Border color props now accept simplified semantic tokens:
|
|
170
|
+
|
|
171
|
+
```diff
|
|
172
|
+
- <Box borderColor="grey800">
|
|
173
|
+
+ <Box borderColor="strong">
|
|
174
|
+
|
|
175
|
+
- <Box borderColor="borderSubtle">
|
|
176
|
+
+ <Box borderColor="subtle">
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Utility Props
|
|
180
|
+
|
|
181
|
+
Components now support consistent utility props through shared type interfaces. The following components have been updated to support additional utility props:
|
|
182
|
+
- **Container**: Added `MarginProps`, `PaddingProps`, `GapProps`, and `BackgroundColorProps`
|
|
183
|
+
- **Card**: Added `MarginProps` and `GapProps`
|
|
184
|
+
- **Flex**: Now properly supports `MarginProps`, `PaddingProps`, and `GapProps`
|
|
185
|
+
- **Text components** (BodyText, Heading, DetailText): Now support `MarginProps`
|
|
186
|
+
|
|
187
|
+
This means you can now use margin utilities directly on these components:
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
<BodyText mt="200" mb="100">Text with margin utilities</BodyText>
|
|
191
|
+
<Container mx="300" py="200">Container with spacing utilities</Container>
|
|
192
|
+
<Card mt="200" gap="100">Card with margin and gap utilities</Card>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Migration guide**:
|
|
196
|
+
1. Replace semantic background color tokens:
|
|
197
|
+
- `backgroundPrimary` → `primary`
|
|
198
|
+
- `backgroundSecondary` → `secondary`
|
|
199
|
+
- `backgroundBrand` → `brand`
|
|
200
|
+
2. Replace semantic text color tokens:
|
|
201
|
+
- `white` → `inverted` (for text on dark backgrounds)
|
|
202
|
+
- `grey1000` / `textPrimary` → `primary`
|
|
203
|
+
- `textSecondary` → `secondary`
|
|
204
|
+
3. Replace semantic border color tokens:
|
|
205
|
+
- `grey800` / `borderStrong` → `strong`
|
|
206
|
+
- `borderSubtle` → `subtle`
|
|
207
|
+
4. For non-semantic colors, use a `StyleSheet` and use the full color token from the theme:
|
|
208
|
+
|
|
209
|
+
```tsx
|
|
210
|
+
import { StyleSheet } from 'react-native';
|
|
211
|
+
|
|
212
|
+
const styles = StyleSheet.create(theme => ({
|
|
213
|
+
customBackground: {
|
|
214
|
+
backgroundColor: theme.color.blue[400],
|
|
215
|
+
},
|
|
216
|
+
}));
|
|
217
|
+
|
|
218
|
+
<Box style={styles.customBackground} />;
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
or the `useTheme` hook:
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
import { useTheme } from '@utilitywarehouse/hearth-react-native';
|
|
225
|
+
|
|
226
|
+
const theme = useTheme();
|
|
227
|
+
<Box backgroundColor={theme.color.purple[800]} />;
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
or use the tokens library:
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
234
|
+
|
|
235
|
+
<Box backgroundColor={color.purple[800]} />;
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Backwards compatibility**:
|
|
239
|
+
|
|
240
|
+
The full color tokens (e.g., `backgroundPrimary`, `grey1000`) are still supported as fallbacks but are deprecated and will cause type errors. We recommend migrating to the simplified tokens for a cleaner API.
|
|
241
|
+
|
|
242
|
+
**References**:
|
|
243
|
+
- [Semantic tokens documentation](https://github.com/utilitywarehouse/hearth/blob/main/packages/tokens/src/semantic-light.ts)
|
|
244
|
+
|
|
245
|
+
### Patch Changes
|
|
246
|
+
|
|
247
|
+
- [#917](https://github.com/utilitywarehouse/hearth/pull/917) [`6a016dc`](https://github.com/utilitywarehouse/hearth/commit/6a016dca0d1a06e40a877da15aced590d0c68112) Thanks [@jordmccord](https://github.com/jordmccord)! - 💅 [ENHANCEMENT]: Update design tokens from Figma
|
|
248
|
+
|
|
249
|
+
Updated design tokens to include new font sizes, line heights, and component-specific tokens:
|
|
250
|
+
- Added `background.loading` colour token for both light and dark modes
|
|
251
|
+
- Added new font sizes: 575 (44px) and 650 (54px)
|
|
252
|
+
- Added new line heights: 975 (52px) and 1050 (62px)
|
|
253
|
+
- Updated `Modal` component tokens with `mobile.paddingBottom` and `handle.paddingBottom` properties
|
|
254
|
+
- Added `borderBottom` property to `Navigation` component tokens
|
|
255
|
+
- Updated `Skeleton` component `loadingColor` value in light mode
|
|
256
|
+
|
|
257
|
+
**Developer changes**:
|
|
258
|
+
|
|
259
|
+
No changes required. These tokens are automatically applied to components that use them.
|
|
260
|
+
|
|
12
261
|
## 0.20.0
|
|
13
262
|
|
|
14
263
|
### Minor Changes
|
|
@@ -32,7 +32,7 @@ const NextPrevPage: React.FC<NextPrevPageProps> = ({
|
|
|
32
32
|
<div className="sb-unstyled">
|
|
33
33
|
<View style={styles.container}>
|
|
34
34
|
{!!prevLink && (
|
|
35
|
-
<Card gap="100">
|
|
35
|
+
<Card gap="100" alignItems="flex-start">
|
|
36
36
|
{!!prevTitle && <Heading size="sm">{prevTitle}</Heading>}
|
|
37
37
|
<CardPressHandler>
|
|
38
38
|
<Link
|
|
@@ -47,7 +47,7 @@ const NextPrevPage: React.FC<NextPrevPageProps> = ({
|
|
|
47
47
|
)}
|
|
48
48
|
<div />
|
|
49
49
|
{!!nextLink && (
|
|
50
|
-
<Card gap="100">
|
|
50
|
+
<Card gap="100" alignItems="flex-start">
|
|
51
51
|
{!!nextTitle && <Heading size="sm">{nextTitle}</Heading>}
|
|
52
52
|
<CardPressHandler>
|
|
53
53
|
<Link onPress={() => openLink(nextLink)}>Next Page</Link>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utilitywarehouse/hearth-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.1",
|
|
4
4
|
"description": "Utility Warehouse React Native UI library",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"react": "^19.1.0",
|
|
43
43
|
"react-native": "0.80.0",
|
|
44
44
|
"react-native-edge-to-edge": "1.6.1",
|
|
45
|
-
"react-native-gesture-handler": "2.
|
|
46
|
-
"react-native-nitro-modules": "
|
|
45
|
+
"react-native-gesture-handler": "2.28.0",
|
|
46
|
+
"react-native-nitro-modules": "0.31.4",
|
|
47
47
|
"react-native-reanimated": "4.1.3",
|
|
48
48
|
"react-native-svg": "^15.12.1",
|
|
49
49
|
"react-native-unistyles": "3.0.17",
|
|
50
50
|
"react-native-web": "^0.20.0",
|
|
51
|
-
"react-native-worklets": "^0.
|
|
51
|
+
"react-native-worklets": "^0.5.1",
|
|
52
52
|
"remark-gfm": "^4.0.1",
|
|
53
53
|
"storybook": "^10.2.1",
|
|
54
54
|
"typescript": "^5.7.3",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"vite-plugin-svgr": "^4.5.0",
|
|
57
57
|
"vitest": "^3.2.4",
|
|
58
58
|
"@utilitywarehouse/hearth-fonts": "^0.0.4",
|
|
59
|
-
"@utilitywarehouse/hearth-react-icons": "^0.8.0",
|
|
60
59
|
"@utilitywarehouse/hearth-react-native-icons": "^0.8.0",
|
|
60
|
+
"@utilitywarehouse/hearth-react-icons": "^0.8.0",
|
|
61
61
|
"@utilitywarehouse/hearth-svg-assets": "^0.5.0",
|
|
62
62
|
"@utilitywarehouse/hearth-tokens": "^0.2.3"
|
|
63
63
|
},
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@utilitywarehouse/hearth-react-native-icons": "0.8.0",
|
|
67
67
|
"react": ">=17 || ^18.0.0 || ^19.0.0",
|
|
68
68
|
"react-native": ">=0.77",
|
|
69
|
-
"react-native-gesture-handler": "
|
|
69
|
+
"react-native-gesture-handler": ">=2.0.0",
|
|
70
70
|
"react-native-reanimated": "3.x || ^4.x",
|
|
71
71
|
"react-native-svg": ">=13.4.0",
|
|
72
72
|
"react-native-unistyles": ">=3.0.0",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { PressableProps
|
|
2
|
-
import { GapProps, MarginProps, SpacingValues } from '../../types';
|
|
1
|
+
import { PressableProps } from 'react-native';
|
|
2
|
+
import { DisplayProps, FlexLayoutProps, GapProps, MarginProps, SpacingValues } from '../../types';
|
|
3
3
|
|
|
4
|
-
interface CardProps
|
|
4
|
+
interface CardProps
|
|
5
|
+
extends PressableProps, MarginProps, GapProps, FlexLayoutProps, Omit<DisplayProps, 'direction'> {
|
|
5
6
|
variant?: 'emphasis' | 'subtle';
|
|
6
7
|
colorScheme?:
|
|
7
8
|
| 'neutralStrong'
|
|
@@ -25,12 +26,8 @@ interface CardProps extends PressableProps, MarginProps, GapProps {
|
|
|
25
26
|
noPadding?: boolean;
|
|
26
27
|
disabled?: boolean;
|
|
27
28
|
spacing?: SpacingValues;
|
|
28
|
-
/** @deprecated Use `spacing` instead. The `
|
|
29
|
+
/** @deprecated Use `spacing` instead. The `space` prop will be removed in a future release. */
|
|
29
30
|
space?: SpacingValues;
|
|
30
|
-
alignItems?: ViewStyle['alignItems'];
|
|
31
|
-
justifyContent?: ViewStyle['justifyContent'];
|
|
32
|
-
flexDirection?: ViewStyle['flexDirection'];
|
|
33
|
-
flexWrap?: ViewStyle['flexWrap'];
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
export default CardProps;
|
|
@@ -123,7 +123,6 @@ Card.displayName = 'Card';
|
|
|
123
123
|
const styles = StyleSheet.create(theme => ({
|
|
124
124
|
card: {
|
|
125
125
|
overflow: 'hidden',
|
|
126
|
-
alignItems: 'flex-start',
|
|
127
126
|
borderRadius: theme.components.card.borderRadius,
|
|
128
127
|
variants: {
|
|
129
128
|
spacing: theme.globalStyle.variants.spacing,
|
|
@@ -87,6 +87,7 @@ const MyComponent = () => {
|
|
|
87
87
|
| `label` | `string` | - | The label to be displayed next to the checkbox. |
|
|
88
88
|
| `helperText` | `string` | - | The helper text to be displayed below the checkbox. |
|
|
89
89
|
| `helperIcon` | `React.ComponentType` | - | The icon to be displayed next to the helper text. |
|
|
90
|
+
| `badge` | `ReactNode` | - | The badge to be displayed below the helper text. |
|
|
90
91
|
| `invalidText` | `string` | - | The invalid text to be displayed below the checkbox. |
|
|
91
92
|
| `validText` | `string` | - | The valid text to be displayed below the checkbox. |
|
|
92
93
|
| `showValidationIcon` | `boolean` | `true` | Whether to show the validation icon. |
|
|
@@ -23,6 +23,7 @@ type CheckboxWithChildrenProps = {
|
|
|
23
23
|
label?: never;
|
|
24
24
|
helperText?: never;
|
|
25
25
|
helperIcon?: never;
|
|
26
|
+
badge?: never;
|
|
26
27
|
invalidText?: never;
|
|
27
28
|
validText?: never;
|
|
28
29
|
showValidationIcon?: never;
|
|
@@ -34,6 +35,7 @@ type CheckboxWithoutChildrenProps = {
|
|
|
34
35
|
label?: string;
|
|
35
36
|
helperText?: string;
|
|
36
37
|
helperIcon?: ComponentType;
|
|
38
|
+
badge?: ReactNode;
|
|
37
39
|
invalidText?: string;
|
|
38
40
|
validText?: string;
|
|
39
41
|
showValidationIcon?: boolean;
|
|
@@ -5,6 +5,7 @@ import { Checkbox, CheckboxGroup, CheckboxImage } from '.';
|
|
|
5
5
|
import bankLogo from '../../../docs/assets/bank-logo.png';
|
|
6
6
|
import bankLogo1 from '../../../docs/assets/bank-logo1.png';
|
|
7
7
|
import { VariantTitle } from '../../../docs/components';
|
|
8
|
+
import { Badge } from '../Badge';
|
|
8
9
|
|
|
9
10
|
const meta = {
|
|
10
11
|
title: 'Stories / Checkbox',
|
|
@@ -133,6 +134,31 @@ export const WithImage: Story = {
|
|
|
133
134
|
),
|
|
134
135
|
};
|
|
135
136
|
|
|
137
|
+
export const WithBadge: Story = {
|
|
138
|
+
args: {
|
|
139
|
+
label: 'Label',
|
|
140
|
+
helperText: 'Helper text',
|
|
141
|
+
},
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
143
|
+
render: ({ checked: checkedArg = false, onChange, ...args }) => {
|
|
144
|
+
const [checked, setChecked] = React.useState(checkedArg);
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
setChecked(checkedArg);
|
|
147
|
+
}, [checkedArg]);
|
|
148
|
+
return (
|
|
149
|
+
<Checkbox
|
|
150
|
+
onChange={val => {
|
|
151
|
+
console.log('-----');
|
|
152
|
+
setChecked(val);
|
|
153
|
+
}}
|
|
154
|
+
badge={<Badge>New</Badge>}
|
|
155
|
+
{...args}
|
|
156
|
+
checked={checked}
|
|
157
|
+
/>
|
|
158
|
+
);
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
|
|
136
162
|
export const Variants: Story = {
|
|
137
163
|
render: () => {
|
|
138
164
|
const [values, setValues] = React.useState(['Label 1']);
|
|
@@ -36,6 +36,7 @@ const Checkbox = ({
|
|
|
36
36
|
checked,
|
|
37
37
|
helperIcon,
|
|
38
38
|
helperText,
|
|
39
|
+
badge,
|
|
39
40
|
invalidText,
|
|
40
41
|
validText,
|
|
41
42
|
validationStatus: validation,
|
|
@@ -61,6 +62,7 @@ const Checkbox = ({
|
|
|
61
62
|
<CheckboxTextContent>
|
|
62
63
|
{!!label && <CheckboxLabel>{label}</CheckboxLabel>}
|
|
63
64
|
{!!helperText && <Helper disabled={disabled} icon={helperIcon} text={helperText} />}
|
|
65
|
+
{badge ? badge : null}
|
|
64
66
|
{validationStatus === 'invalid' && !!invalidText && (
|
|
65
67
|
<Helper
|
|
66
68
|
showIcon={showValidationIcon}
|
|
@@ -100,6 +100,7 @@ const MyComponent = () => {
|
|
|
100
100
|
| `label` | `string` | - | The label to be displayed next to the radio. |
|
|
101
101
|
| `helperText` | `string` | - | The helper text to be displayed below the radio. |
|
|
102
102
|
| `helperIcon` | `React.ComponentType` | - | The icon to be displayed next to the helper text. |
|
|
103
|
+
| `badge` | `ReactNode` | - | The badge to be displayed below the helper text. |
|
|
103
104
|
| `invalidText` | `string` | - | The invalid text to be displayed below the radio. |
|
|
104
105
|
| `validText` | `string` | - | The valid text to be displayed below the radio. |
|
|
105
106
|
| `showValidationIcon` | `boolean` | `true` | Whether to show the validation icon. |
|
|
@@ -14,6 +14,7 @@ interface RadioWithChildrenProps extends RadioBaseProps {
|
|
|
14
14
|
label?: never;
|
|
15
15
|
helperText?: never;
|
|
16
16
|
helperIcon?: never;
|
|
17
|
+
badge?: never;
|
|
17
18
|
invalidText?: never;
|
|
18
19
|
validText?: never;
|
|
19
20
|
showValidationIcon?: never;
|
|
@@ -25,6 +26,7 @@ interface RadioWithoutChildrenProps extends RadioBaseProps {
|
|
|
25
26
|
label?: string;
|
|
26
27
|
helperText?: string;
|
|
27
28
|
helperIcon?: ComponentType;
|
|
29
|
+
badge?: ReactNode;
|
|
28
30
|
invalidText?: string;
|
|
29
31
|
validText?: string;
|
|
30
32
|
showValidationIcon?: boolean;
|
|
@@ -5,6 +5,7 @@ import { Radio, RadioGroup, RadioImage } from '.';
|
|
|
5
5
|
import bankLogo from '../../../docs/assets/bank-logo.png';
|
|
6
6
|
import bankLogo1 from '../../../docs/assets/bank-logo1.png';
|
|
7
7
|
import { VariantTitle } from '../../../docs/components';
|
|
8
|
+
import { Badge } from '../Badge';
|
|
8
9
|
import { Flex } from '../Flex';
|
|
9
10
|
import { FormField } from '../FormField';
|
|
10
11
|
|
|
@@ -136,6 +137,27 @@ export const WithImage: Story = {
|
|
|
136
137
|
),
|
|
137
138
|
};
|
|
138
139
|
|
|
140
|
+
export const WithBadge: Story = {
|
|
141
|
+
args: {
|
|
142
|
+
value: 'Option 1',
|
|
143
|
+
label: 'Label',
|
|
144
|
+
helperText: 'Helper text',
|
|
145
|
+
},
|
|
146
|
+
render: args => (
|
|
147
|
+
<RadioGroup>
|
|
148
|
+
<Radio
|
|
149
|
+
aria-label="Label 1"
|
|
150
|
+
onChange={(checked: boolean) => {
|
|
151
|
+
console.log(checked, '###');
|
|
152
|
+
}}
|
|
153
|
+
nativeID="Radio-1"
|
|
154
|
+
badge={<Badge>New</Badge>}
|
|
155
|
+
{...args}
|
|
156
|
+
/>
|
|
157
|
+
</RadioGroup>
|
|
158
|
+
),
|
|
159
|
+
};
|
|
160
|
+
|
|
139
161
|
export const Variants: Story = {
|
|
140
162
|
parameters: {
|
|
141
163
|
controls: { exclude: ['value', 'label', 'disabled'] },
|
|
@@ -36,6 +36,7 @@ const Radio = ({
|
|
|
36
36
|
disabled,
|
|
37
37
|
helperIcon,
|
|
38
38
|
helperText,
|
|
39
|
+
badge,
|
|
39
40
|
invalidText,
|
|
40
41
|
validText,
|
|
41
42
|
validationStatus: validation,
|
|
@@ -60,6 +61,7 @@ const Radio = ({
|
|
|
60
61
|
<RadioTextContent>
|
|
61
62
|
{!!label && <RadioLabel>{label}</RadioLabel>}
|
|
62
63
|
{!!helperText && <Helper disabled={disabled} icon={helperIcon} text={helperText} />}
|
|
64
|
+
{badge ? badge : null}
|
|
63
65
|
{validationStatus === 'invalid' && !!invalidText && (
|
|
64
66
|
<Helper
|
|
65
67
|
showIcon={showValidationIcon}
|
|
@@ -9,6 +9,9 @@ figma.connect(
|
|
|
9
9
|
helperText: figma.boolean('Helper text?', {
|
|
10
10
|
true: figma.string('Helper text'),
|
|
11
11
|
}),
|
|
12
|
+
badge: figma.boolean('Badge?', {
|
|
13
|
+
true: figma.children('Badge'),
|
|
14
|
+
}),
|
|
12
15
|
label: figma.string('Label'),
|
|
13
16
|
image: figma.boolean('Image?', {
|
|
14
17
|
true: figma.instance('Radio Image'),
|
|
@@ -24,6 +27,7 @@ figma.connect(
|
|
|
24
27
|
<RadioTile
|
|
25
28
|
label={props.label}
|
|
26
29
|
helperText={props.helperText}
|
|
30
|
+
badge={props.badge}
|
|
27
31
|
image={props.image}
|
|
28
32
|
checked={props.checked}
|
|
29
33
|
disabled={props.indicator.disabled}
|