@utilitywarehouse/hearth-react-native 0.20.0 → 0.21.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/.storybook/manager.ts +1 -0
- package/.storybook/preview.tsx +1 -0
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +13 -13
- package/CHANGELOG.md +249 -0
- package/build/components/BodyText/BodyText.js +12 -5
- package/build/components/BodyText/BodyText.props.d.ts +5 -19
- package/build/components/Box/Box.js +23 -3
- package/build/components/Box/Box.props.d.ts +3 -95
- package/build/components/Card/Card.props.d.ts +2 -5
- package/build/components/Container/Container.props.d.ts +2 -78
- package/build/components/DateInput/DateInput.d.ts +1 -1
- package/build/components/DateInput/DateInput.js +2 -2
- package/build/components/DateInput/DateInput.props.d.ts +15 -1
- package/build/components/DateInput/DateInputSegment.d.ts +1 -1
- package/build/components/DateInput/DateInputSegment.js +2 -2
- package/build/components/DetailText/DetailText.js +14 -13
- package/build/components/DetailText/DetailText.props.d.ts +4 -17
- package/build/components/Flex/Flex.js +3 -1
- package/build/components/Flex/Flex.props.d.ts +2 -2
- package/build/components/Heading/Heading.js +34 -13
- package/build/components/Heading/Heading.props.d.ts +4 -18
- package/build/core/themes.d.ts +188 -8
- package/build/core/themes.js +18 -2
- package/build/hooks/useStyleProps.js +22 -5
- package/build/tokens/color.d.ts +4 -0
- package/build/tokens/color.js +2 -0
- package/build/tokens/components/dark/modal.d.ts +6 -0
- package/build/tokens/components/dark/modal.js +6 -0
- package/build/tokens/components/dark/navigation.d.ts +1 -0
- package/build/tokens/components/dark/navigation.js +1 -0
- package/build/tokens/components/light/modal.d.ts +6 -0
- package/build/tokens/components/light/modal.js +6 -0
- package/build/tokens/components/light/navigation.d.ts +1 -0
- package/build/tokens/components/light/navigation.js +1 -0
- package/build/tokens/components/light/skeleton.d.ts +1 -1
- package/build/tokens/components/light/skeleton.js +1 -1
- package/build/tokens/font.d.ts +2 -0
- package/build/tokens/font.js +2 -0
- package/build/tokens/line-height.d.ts +2 -0
- package/build/tokens/line-height.js +2 -0
- package/build/tokens/primitive.d.ts +4 -0
- package/build/tokens/primitive.js +4 -0
- package/build/tokens/semantic-dark.d.ts +1 -0
- package/build/tokens/semantic-dark.js +1 -0
- package/build/tokens/semantic-light.d.ts +1 -0
- package/build/tokens/semantic-light.js +1 -0
- package/build/tokens/typography.d.ts +30 -0
- package/build/tokens/typography.js +15 -0
- package/build/types/index.d.ts +4 -2
- package/build/types/index.js +4 -2
- package/build/types/semanticColorValues.d.ts +22 -0
- package/build/types/semanticColorValues.js +1 -0
- package/build/types/utilityProps.d.ts +326 -0
- package/build/types/utilityProps.js +1 -0
- package/build/types/values.d.ts +4 -3
- package/build/utils/coloursAsArray.d.ts +4 -0
- package/build/utils/coloursAsArray.js +5 -0
- package/build/utils/index.d.ts +1 -1
- package/build/utils/index.js +1 -1
- package/build/utils/styleUtils.d.ts +26 -2
- package/build/utils/styleUtils.js +42 -13
- package/build/utils/themeValueHelpers.d.ts +13 -0
- package/build/utils/themeValueHelpers.js +29 -0
- package/docs/changelog.mdx +74 -2
- package/docs/components/AllComponents.web.tsx +23 -24
- package/docs/components/UsageWrap.tsx +2 -2
- package/docs/introduction.mdx +0 -7
- package/package.json +5 -3
- package/src/components/BodyText/BodyText.props.ts +5 -19
- package/src/components/BodyText/BodyText.stories.tsx +2 -1
- package/src/components/BodyText/BodyText.tsx +17 -6
- package/src/components/Box/Box.docs.mdx +5 -4
- package/src/components/Box/Box.props.ts +3 -231
- package/src/components/Box/Box.stories.tsx +2 -2
- package/src/components/Box/Box.tsx +38 -9
- package/src/components/Button/Button.docs.mdx +46 -1
- package/src/components/Card/Card.docs.mdx +1 -1
- package/src/components/Card/Card.props.ts +2 -5
- package/src/components/Card/Card.stories.tsx +54 -23
- package/src/components/Carousel/Carousel.docs.mdx +49 -44
- package/src/components/Center/Center.docs.mdx +6 -4
- package/src/components/Container/Container.docs.mdx +13 -8
- package/src/components/Container/Container.props.ts +9 -80
- package/src/components/Container/Container.stories.tsx +81 -65
- package/src/components/DateInput/DateInput.docs.mdx +43 -0
- package/src/components/DateInput/DateInput.props.ts +15 -1
- package/src/components/DateInput/DateInput.stories.tsx +37 -2
- package/src/components/DateInput/DateInput.tsx +6 -0
- package/src/components/DateInput/DateInputSegment.tsx +2 -0
- package/src/components/DetailText/DetailText.props.ts +4 -17
- package/src/components/DetailText/DetailText.stories.tsx +2 -3
- package/src/components/DetailText/DetailText.tsx +16 -17
- package/src/components/Flex/Flex.props.ts +2 -2
- package/src/components/Flex/Flex.stories.tsx +1 -1
- package/src/components/Flex/Flex.tsx +4 -1
- package/src/components/Grid/Grid.docs.mdx +53 -49
- package/src/components/Heading/Heading.props.ts +4 -18
- package/src/components/Heading/Heading.stories.tsx +2 -1
- package/src/components/Heading/Heading.tsx +40 -18
- package/src/components/Toast/ToastItem.figma.tsx +1 -8
- package/src/core/themes.ts +19 -2
- package/src/hooks/useStyleProps.ts +40 -5
- package/src/tokens/color.ts +2 -0
- package/src/tokens/components/dark/modal.ts +6 -0
- package/src/tokens/components/dark/navigation.ts +1 -0
- package/src/tokens/components/light/modal.ts +6 -0
- package/src/tokens/components/light/navigation.ts +1 -0
- package/src/tokens/components/light/skeleton.ts +1 -1
- package/src/tokens/font.ts +2 -0
- package/src/tokens/line-height.ts +2 -0
- package/src/tokens/primitive.ts +4 -0
- package/src/tokens/semantic-dark.ts +1 -0
- package/src/tokens/semantic-light.ts +1 -0
- package/src/tokens/typography.ts +15 -0
- package/src/types/index.ts +4 -2
- package/src/types/semanticColorValues.ts +26 -0
- package/src/types/utilityProps.ts +410 -0
- package/src/types/values.ts +4 -7
- package/src/utils/coloursAsArray.ts +6 -0
- package/src/utils/index.ts +8 -1
- package/src/utils/styleUtils.ts +45 -14
- package/src/utils/themeValueHelpers.ts +38 -0
package/.storybook/manager.ts
CHANGED
package/.storybook/preview.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
|
|
2
2
|
import '@utilitywarehouse/hearth-fonts';
|
|
3
|
+
import '@utilitywarehouse/hearth-tokens/index.css';
|
|
3
4
|
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
4
5
|
import { useEffect } from 'react';
|
|
5
6
|
import '../../../shared/storybook/styles/diff-highlighting.css';
|
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @utilitywarehouse/hearth-react-native@0.
|
|
2
|
+
> @utilitywarehouse/hearth-react-native@0.21.0 lint /home/runner/work/hearth/hearth/packages/react-native
|
|
3
3
|
> TIMING=1 eslint .
|
|
4
4
|
|
|
5
5
|
|
|
@@ -58,15 +58,15 @@
|
|
|
58
58
|
|
|
59
59
|
✖ 25 problems (0 errors, 25 warnings)
|
|
60
60
|
|
|
61
|
-
Rule
|
|
62
|
-
|
|
63
|
-
@typescript-eslint/no-unused-vars
|
|
64
|
-
react-hooks/exhaustive-deps
|
|
65
|
-
no-global-assign
|
|
66
|
-
react-hooks/rules-of-hooks
|
|
67
|
-
no-misleading-character-class
|
|
68
|
-
|
|
69
|
-
no-unexpected-multiline
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
no-
|
|
61
|
+
Rule | Time (ms) | Relative
|
|
62
|
+
:---------------------------------|----------:|--------:
|
|
63
|
+
@typescript-eslint/no-unused-vars | 1327.577 | 60.2%
|
|
64
|
+
react-hooks/exhaustive-deps | 77.842 | 3.5%
|
|
65
|
+
no-global-assign | 77.325 | 3.5%
|
|
66
|
+
react-hooks/rules-of-hooks | 64.813 | 2.9%
|
|
67
|
+
no-misleading-character-class | 44.059 | 2.0%
|
|
68
|
+
no-loss-of-precision | 40.431 | 1.8%
|
|
69
|
+
no-unexpected-multiline | 40.191 | 1.8%
|
|
70
|
+
@typescript-eslint/ban-ts-comment | 32.434 | 1.5%
|
|
71
|
+
no-useless-escape | 27.764 | 1.3%
|
|
72
|
+
no-fallthrough | 27.614 | 1.3%
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,254 @@
|
|
|
1
1
|
# @utilitywarehouse/hearth-react-native
|
|
2
2
|
|
|
3
|
+
## 0.21.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
**Components affected**:
|
|
12
|
+
- `Heading`
|
|
13
|
+
|
|
14
|
+
**Developer changes**:
|
|
15
|
+
|
|
16
|
+
Use the new `2xl` size prop:
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
<Heading size="2xl">Welcome to Hearth</Heading>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The `2xl` size will render with:
|
|
23
|
+
- Mobile: 44px font size, 52px line height
|
|
24
|
+
- Tablet: 44px font size, 52px line height
|
|
25
|
+
- Desktop: 54px font size, 62px line height
|
|
26
|
+
|
|
27
|
+
- [#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
|
|
28
|
+
|
|
29
|
+
The `DateInput` component now supports direct refs for each segment input via `dayRef`, `monthRef`, and `yearRef`.
|
|
30
|
+
This makes it easier to move focus between segments from custom flows (for example, advancing focus after validation or from custom buttons).
|
|
31
|
+
|
|
32
|
+
Documentation and Storybook examples are also updated to show how to use segment refs in real usage.
|
|
33
|
+
|
|
34
|
+
**Components affected**:
|
|
35
|
+
- `DateInput`
|
|
36
|
+
|
|
37
|
+
**Developer changes**:
|
|
38
|
+
|
|
39
|
+
You can now pass refs to each segment and call `.focus()` when needed:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { useRef, useState } from 'react';
|
|
43
|
+
import { TextInput } from 'react-native';
|
|
44
|
+
import { Button, DateInput } from '@utilitywarehouse/hearth-react-native';
|
|
45
|
+
|
|
46
|
+
const DateWithSegmentFocus = () => {
|
|
47
|
+
const [day, setDay] = useState('');
|
|
48
|
+
const [month, setMonth] = useState('');
|
|
49
|
+
const [year, setYear] = useState('');
|
|
50
|
+
|
|
51
|
+
const dayRef = useRef<TextInput>(null);
|
|
52
|
+
const monthRef = useRef<TextInput>(null);
|
|
53
|
+
const yearRef = useRef<TextInput>(null);
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<>
|
|
57
|
+
<DateInput
|
|
58
|
+
label="Date of birth"
|
|
59
|
+
dayValue={day}
|
|
60
|
+
monthValue={month}
|
|
61
|
+
yearValue={year}
|
|
62
|
+
onDayChange={setDay}
|
|
63
|
+
onMonthChange={setMonth}
|
|
64
|
+
onYearChange={setYear}
|
|
65
|
+
dayRef={dayRef}
|
|
66
|
+
monthRef={monthRef}
|
|
67
|
+
yearRef={yearRef}
|
|
68
|
+
/>
|
|
69
|
+
|
|
70
|
+
<Button onPress={() => monthRef.current?.focus()}>Focus month</Button>
|
|
71
|
+
</>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
This is a non-breaking enhancement, so existing `DateInput` usage continues to work without any changes.
|
|
77
|
+
|
|
78
|
+
- [#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
|
|
79
|
+
|
|
80
|
+
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.
|
|
81
|
+
|
|
82
|
+
**Components affected**:
|
|
83
|
+
- `Box`
|
|
84
|
+
- `Container`
|
|
85
|
+
- `Card`
|
|
86
|
+
- `Flex`
|
|
87
|
+
- `Grid`
|
|
88
|
+
- `Center`
|
|
89
|
+
- `BodyText`
|
|
90
|
+
- `Heading`
|
|
91
|
+
- `DetailText`
|
|
92
|
+
- `Carousel`
|
|
93
|
+
- `CarouselItem`
|
|
94
|
+
|
|
95
|
+
**Developer changes**:
|
|
96
|
+
|
|
97
|
+
### Background Colors
|
|
98
|
+
|
|
99
|
+
Background color props now accept simplified semantic tokens. Update your code as follows:
|
|
100
|
+
|
|
101
|
+
```diff
|
|
102
|
+
- <Box backgroundColor="backgroundPrimary">
|
|
103
|
+
+ <Box backgroundColor="primary">
|
|
104
|
+
|
|
105
|
+
- <Box backgroundColor="backgroundSecondary">
|
|
106
|
+
+ <Box backgroundColor="secondary">
|
|
107
|
+
|
|
108
|
+
- <Box backgroundColor="backgroundBrand">
|
|
109
|
+
+ <Box backgroundColor="brand">
|
|
110
|
+
|
|
111
|
+
- <Container bg="backgroundPrimary">
|
|
112
|
+
+ <Container bg="primary">
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
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:
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import { StyleSheet } from 'react-native';
|
|
119
|
+
|
|
120
|
+
const styles = StyleSheet.create(theme => ({
|
|
121
|
+
customBackground: {
|
|
122
|
+
backgroundColor: theme.color.blue[400],
|
|
123
|
+
},
|
|
124
|
+
}));
|
|
125
|
+
|
|
126
|
+
<Box style={styles.customBackground} />;
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import { useTheme } from '@utilitywarehouse/hearth-react-native';
|
|
131
|
+
|
|
132
|
+
const theme = useTheme();
|
|
133
|
+
|
|
134
|
+
<Box backgroundColor={theme.color.purple[800]} />;
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
139
|
+
|
|
140
|
+
<Box backgroundColor={color.blue[400]} />;
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Text Colors
|
|
144
|
+
|
|
145
|
+
Text color props now accept simplified semantic tokens:
|
|
146
|
+
|
|
147
|
+
```diff
|
|
148
|
+
- <BodyText color="white">Text</BodyText>
|
|
149
|
+
+ <BodyText color="inverted">Text</BodyText>
|
|
150
|
+
|
|
151
|
+
- <BodyText color="grey1000">Text</BodyText>
|
|
152
|
+
+ <BodyText color="primary">Text</BodyText>
|
|
153
|
+
|
|
154
|
+
- <Heading color="textSecondary">Heading</Heading>
|
|
155
|
+
+ <Heading color="secondary">Heading</Heading>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Border Colors
|
|
159
|
+
|
|
160
|
+
Border color props now accept simplified semantic tokens:
|
|
161
|
+
|
|
162
|
+
```diff
|
|
163
|
+
- <Box borderColor="grey800">
|
|
164
|
+
+ <Box borderColor="strong">
|
|
165
|
+
|
|
166
|
+
- <Box borderColor="borderSubtle">
|
|
167
|
+
+ <Box borderColor="subtle">
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Utility Props
|
|
171
|
+
|
|
172
|
+
Components now support consistent utility props through shared type interfaces. The following components have been updated to support additional utility props:
|
|
173
|
+
- **Container**: Added `MarginProps`, `PaddingProps`, `GapProps`, and `BackgroundColorProps`
|
|
174
|
+
- **Card**: Added `MarginProps` and `GapProps`
|
|
175
|
+
- **Flex**: Now properly supports `MarginProps`, `PaddingProps`, and `GapProps`
|
|
176
|
+
- **Text components** (BodyText, Heading, DetailText): Now support `MarginProps`
|
|
177
|
+
|
|
178
|
+
This means you can now use margin utilities directly on these components:
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
<BodyText mt="200" mb="100">Text with margin utilities</BodyText>
|
|
182
|
+
<Container mx="300" py="200">Container with spacing utilities</Container>
|
|
183
|
+
<Card mt="200" gap="100">Card with margin and gap utilities</Card>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Migration guide**:
|
|
187
|
+
1. Replace semantic background color tokens:
|
|
188
|
+
- `backgroundPrimary` → `primary`
|
|
189
|
+
- `backgroundSecondary` → `secondary`
|
|
190
|
+
- `backgroundBrand` → `brand`
|
|
191
|
+
2. Replace semantic text color tokens:
|
|
192
|
+
- `white` → `inverted` (for text on dark backgrounds)
|
|
193
|
+
- `grey1000` / `textPrimary` → `primary`
|
|
194
|
+
- `textSecondary` → `secondary`
|
|
195
|
+
3. Replace semantic border color tokens:
|
|
196
|
+
- `grey800` / `borderStrong` → `strong`
|
|
197
|
+
- `borderSubtle` → `subtle`
|
|
198
|
+
4. For non-semantic colors, use a `StyleSheet` and use the full color token from the theme:
|
|
199
|
+
|
|
200
|
+
```tsx
|
|
201
|
+
import { StyleSheet } from 'react-native';
|
|
202
|
+
|
|
203
|
+
const styles = StyleSheet.create(theme => ({
|
|
204
|
+
customBackground: {
|
|
205
|
+
backgroundColor: theme.color.blue[400],
|
|
206
|
+
},
|
|
207
|
+
}));
|
|
208
|
+
|
|
209
|
+
<Box style={styles.customBackground} />;
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
or the `useTheme` hook:
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import { useTheme } from '@utilitywarehouse/hearth-react-native';
|
|
216
|
+
|
|
217
|
+
const theme = useTheme();
|
|
218
|
+
<Box backgroundColor={theme.color.purple[800]} />;
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
or use the tokens library:
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
225
|
+
|
|
226
|
+
<Box backgroundColor={color.purple[800]} />;
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**Backwards compatibility**:
|
|
230
|
+
|
|
231
|
+
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.
|
|
232
|
+
|
|
233
|
+
**References**:
|
|
234
|
+
- [Semantic tokens documentation](https://github.com/utilitywarehouse/hearth/blob/main/packages/tokens/src/semantic-light.ts)
|
|
235
|
+
|
|
236
|
+
### Patch Changes
|
|
237
|
+
|
|
238
|
+
- [#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
|
|
239
|
+
|
|
240
|
+
Updated design tokens to include new font sizes, line heights, and component-specific tokens:
|
|
241
|
+
- Added `background.loading` colour token for both light and dark modes
|
|
242
|
+
- Added new font sizes: 575 (44px) and 650 (54px)
|
|
243
|
+
- Added new line heights: 975 (52px) and 1050 (62px)
|
|
244
|
+
- Updated `Modal` component tokens with `mobile.paddingBottom` and `handle.paddingBottom` properties
|
|
245
|
+
- Added `borderBottom` property to `Navigation` component tokens
|
|
246
|
+
- Updated `Skeleton` component `loadingColor` value in light mode
|
|
247
|
+
|
|
248
|
+
**Developer changes**:
|
|
249
|
+
|
|
250
|
+
No changes required. These tokens are automatically applied to components that use them.
|
|
251
|
+
|
|
3
252
|
## 0.20.0
|
|
4
253
|
|
|
5
254
|
### Minor Changes
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Text } from 'react-native';
|
|
3
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
-
import {
|
|
4
|
+
import { useStyleProps } from '../../hooks';
|
|
5
|
+
import { getFlattenedColorValue, resolveThemeValueWithFallback } from '../../utils';
|
|
5
6
|
const BodyText = ({ children, color, size = 'md', truncated, weight = 'regular', underline, strikeThrough, italic, textTransform, textAlign, textAlignVertical, textDecorationColor, textDecorationLine, textDecorationStyle, userSelect, inverted, ...props }) => {
|
|
7
|
+
// Extract margin utility props from remaining props
|
|
8
|
+
const { computedStyles: utilityStyles, remainingProps } = useStyleProps(props);
|
|
6
9
|
styles.useVariants({
|
|
7
10
|
size,
|
|
8
11
|
weight,
|
|
@@ -11,14 +14,14 @@ const BodyText = ({ children, color, size = 'md', truncated, weight = 'regular',
|
|
|
11
14
|
italic,
|
|
12
15
|
inverted,
|
|
13
16
|
});
|
|
14
|
-
return (_jsx(Text, { ...
|
|
17
|
+
return (_jsx(Text, { ...remainingProps, ...(truncated
|
|
15
18
|
? {
|
|
16
19
|
numberOfLines: 1,
|
|
17
20
|
ellipsizeMode: 'tail',
|
|
18
21
|
}
|
|
19
22
|
: {}), style: [
|
|
20
23
|
styles.text,
|
|
21
|
-
|
|
24
|
+
utilityStyles,
|
|
22
25
|
{
|
|
23
26
|
...(textTransform && { textTransform }),
|
|
24
27
|
...(textAlign && { textAlign }),
|
|
@@ -28,6 +31,7 @@ const BodyText = ({ children, color, size = 'md', truncated, weight = 'regular',
|
|
|
28
31
|
...(textAlignVertical && { textAlignVertical }),
|
|
29
32
|
},
|
|
30
33
|
styles.getColours(color, textDecorationColor),
|
|
34
|
+
props.style,
|
|
31
35
|
], children: children }));
|
|
32
36
|
};
|
|
33
37
|
BodyText.displayName = 'BodyText';
|
|
@@ -85,11 +89,14 @@ const styles = StyleSheet.create(theme => ({
|
|
|
85
89
|
},
|
|
86
90
|
},
|
|
87
91
|
getColours: (color, textDecorationColor) => ({
|
|
88
|
-
...(color
|
|
92
|
+
...(color
|
|
93
|
+
? {
|
|
94
|
+
color: resolveThemeValueWithFallback(color, theme.helpers.semanticColor.text, theme.color),
|
|
95
|
+
}
|
|
96
|
+
: {}),
|
|
89
97
|
...(textDecorationColor
|
|
90
98
|
? { textDecorationColor: getFlattenedColorValue(textDecorationColor, theme.color) }
|
|
91
99
|
: {}),
|
|
92
100
|
}),
|
|
93
101
|
}));
|
|
94
|
-
BodyText.displayName = 'BodyText';
|
|
95
102
|
export default BodyText;
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface TextProps extends RNTextProps {
|
|
1
|
+
import type { CommonTextProps } from '../../types';
|
|
2
|
+
interface BodyTextProps extends CommonTextProps {
|
|
3
|
+
/** Text size variant. */
|
|
5
4
|
size?: 'sm' | 'md' | 'lg';
|
|
6
|
-
|
|
7
|
-
underline?: boolean;
|
|
8
|
-
truncated?: boolean;
|
|
5
|
+
/** Font weight variant. */
|
|
9
6
|
weight?: 'regular' | 'semibold' | 'bold';
|
|
10
|
-
italic?: boolean;
|
|
11
|
-
color?: ColorValue;
|
|
12
|
-
textTransform?: TextStyle['textTransform'];
|
|
13
|
-
textAlign?: TextStyle['textAlign'];
|
|
14
|
-
textAlignVertical?: TextStyle['textAlignVertical'];
|
|
15
|
-
textDecorationLine?: TextStyle['textDecorationLine'];
|
|
16
|
-
textDecorationStyle?: TextStyle['textDecorationStyle'];
|
|
17
|
-
textDecorationColor?: ColorValue;
|
|
18
|
-
userSelect?: TextStyle['userSelect'];
|
|
19
|
-
inverted?: boolean;
|
|
20
|
-
ref?: Ref<Text>;
|
|
21
7
|
}
|
|
22
|
-
export default
|
|
8
|
+
export default BodyTextProps;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { View } from 'react-native';
|
|
4
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
-
import { propStyleMapping,
|
|
5
|
+
import { propStyleMapping, resolveThemeKey, resolveThemeValueWithFallback, semanticPropMapping, themeStyleFallbackMapping, themeStyleMapping, viewStyleProps, } from '../../utils';
|
|
6
6
|
// --- Box component definition ---
|
|
7
7
|
const BoxComponent = ({ as, style, children, ...props }) => {
|
|
8
8
|
const { computedProps } = useMemo(() => {
|
|
@@ -10,6 +10,8 @@ const BoxComponent = ({ as, style, children, ...props }) => {
|
|
|
10
10
|
Object.entries(props).forEach(([propName, propValue]) => {
|
|
11
11
|
if (propValue === undefined)
|
|
12
12
|
return;
|
|
13
|
+
if (semanticPropMapping[propName])
|
|
14
|
+
return;
|
|
13
15
|
if (propStyleMapping[propName] || viewStyleProps.has(propName)) {
|
|
14
16
|
return;
|
|
15
17
|
}
|
|
@@ -26,6 +28,16 @@ const styles = StyleSheet.create(theme => ({
|
|
|
26
28
|
Object.entries(props).forEach(([propName, propValue]) => {
|
|
27
29
|
if (propValue === undefined)
|
|
28
30
|
return;
|
|
31
|
+
// Check for semantic prop mappings first (e.g., iconColor, color)
|
|
32
|
+
const semanticMapping = semanticPropMapping[propName];
|
|
33
|
+
if (semanticMapping) {
|
|
34
|
+
const { styleProp, themeKey } = semanticMapping;
|
|
35
|
+
const themeMapping = resolveThemeKey(theme, themeKey);
|
|
36
|
+
const fallbackKey = themeStyleFallbackMapping[themeKey];
|
|
37
|
+
const fallbackMapping = fallbackKey ? resolveThemeKey(theme, fallbackKey) : undefined;
|
|
38
|
+
computedStyles[styleProp] = resolveThemeValueWithFallback(propValue, themeMapping, fallbackMapping);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
29
41
|
let stylePropName;
|
|
30
42
|
// Handle shorthand props
|
|
31
43
|
if (propStyleMapping[propName]) {
|
|
@@ -39,8 +51,16 @@ const styles = StyleSheet.create(theme => ({
|
|
|
39
51
|
return;
|
|
40
52
|
// Resolve theme value if needed
|
|
41
53
|
const themeKey = themeStyleMapping[stylePropName];
|
|
42
|
-
if (themeKey
|
|
43
|
-
|
|
54
|
+
if (themeKey) {
|
|
55
|
+
const themeObj = resolveThemeKey(theme, themeKey);
|
|
56
|
+
const fallbackKey = themeStyleFallbackMapping[themeKey];
|
|
57
|
+
const fallbackMapping = fallbackKey ? resolveThemeKey(theme, fallbackKey) : undefined;
|
|
58
|
+
if (themeObj) {
|
|
59
|
+
computedStyles[stylePropName] = resolveThemeValueWithFallback(propValue, themeObj, fallbackMapping);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
computedStyles[stylePropName] = propValue;
|
|
63
|
+
}
|
|
44
64
|
}
|
|
45
65
|
else {
|
|
46
66
|
computedStyles[stylePropName] = propValue;
|
|
@@ -1,102 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { ViewProps
|
|
3
|
-
import type {
|
|
4
|
-
export type OmittedStyles = Omit<ViewStyle, 'backgroundColor' | 'borderBlockColor' | 'borderBlockEndColor' | 'borderBlockStartColor' | 'borderBottomColor' | 'borderBottomEndRadius' | 'borderBottomLeftRadius' | 'borderBottomRightRadius' | 'borderBottomStartRadius' | 'borderBottomWidth' | 'borderColor' | 'borderEndColor' | 'borderEndEndRadius' | 'borderEndStartRadius' | 'borderEndWidth' | 'borderLeftColor' | 'borderLeftWidth' | 'borderRadius' | 'borderRightColor' | 'borderRightWidth' | 'borderStartColor' | 'borderStartEndRadius' | 'borderStartStartRadius' | 'borderStartWidth' | 'borderTopColor' | 'borderTopEndRadius' | 'borderTopLeftRadius' | 'borderTopRightRadius' | 'borderTopStartRadius' | 'borderTopWidth' | 'borderWidth' | 'bottom' | 'columnGap' | 'end' | 'gap' | 'height' | 'left' | 'margin' | 'marginBottom' | 'marginEnd' | 'marginHorizontal' | 'marginLeft' | 'marginRight' | 'marginStart' | 'marginTop' | 'marginVertical' | 'maxHeight' | 'maxWidth' | 'minHeight' | 'minWidth' | 'opacity' | 'outlineColor' | 'padding' | 'paddingBottom' | 'paddingEnd' | 'paddingHorizontal' | 'paddingLeft' | 'paddingRight' | 'paddingStart' | 'paddingTop' | 'paddingVertical' | 'right' | 'rowGap' | 'shadowColor' | 'start' | 'top' | 'width' | 'rotation' | 'scaleX' | 'scaleY' | 'transformMatrix' | 'translateX' | 'translateY'>;
|
|
5
|
-
export type OtherBoxViewStyles = Pick<OmittedStyles, 'alignContent' | 'alignItems' | 'alignSelf' | 'aspectRatio' | 'backfaceVisibility' | 'borderCurve' | 'borderStyle' | 'cursor' | 'direction' | 'display' | 'elevation' | 'flex' | 'flexBasis' | 'flexDirection' | 'flexGrow' | 'flexShrink' | 'flexWrap' | 'justifyContent' | 'boxShadow' | 'outlineOffset' | 'outlineStyle' | 'outlineWidth' | 'overflow' | 'pointerEvents' | 'position' | 'shadowOffset' | 'shadowOpacity' | 'shadowRadius' | 'transform' | 'transformOrigin' | 'zIndex'>;
|
|
6
|
-
export interface BoxStyleMappingValues {
|
|
7
|
-
bg?: ColorValue;
|
|
8
|
-
bgColor?: ColorValue;
|
|
9
|
-
h?: SpaceValue;
|
|
10
|
-
w?: SpaceValue;
|
|
11
|
-
p?: SpaceValue;
|
|
12
|
-
px?: SpaceValue;
|
|
13
|
-
py?: SpaceValue;
|
|
14
|
-
pt?: SpaceValue;
|
|
15
|
-
pb?: SpaceValue;
|
|
16
|
-
pr?: SpaceValue;
|
|
17
|
-
pl?: SpaceValue;
|
|
18
|
-
m?: SpaceValue;
|
|
19
|
-
mx?: SpaceValue;
|
|
20
|
-
my?: SpaceValue;
|
|
21
|
-
mt?: SpaceValue;
|
|
22
|
-
mb?: SpaceValue;
|
|
23
|
-
mr?: SpaceValue;
|
|
24
|
-
ml?: SpaceValue;
|
|
25
|
-
rounded?: BorderRadiusValue;
|
|
26
|
-
}
|
|
27
|
-
export interface ThemedBoxViewStyleProps {
|
|
28
|
-
top?: SpaceValue;
|
|
29
|
-
bottom?: SpaceValue;
|
|
30
|
-
left?: SpaceValue;
|
|
31
|
-
right?: SpaceValue;
|
|
32
|
-
padding?: SpaceValue;
|
|
33
|
-
paddingHorizontal?: SpaceValue;
|
|
34
|
-
paddingVertical?: SpaceValue;
|
|
35
|
-
paddingTop?: SpaceValue;
|
|
36
|
-
paddingBottom?: SpaceValue;
|
|
37
|
-
paddingLeft?: SpaceValue;
|
|
38
|
-
paddingRight?: SpaceValue;
|
|
39
|
-
paddingEnd?: SpaceValue;
|
|
40
|
-
paddingStart?: SpaceValue;
|
|
41
|
-
margin?: SpaceValue;
|
|
42
|
-
marginHorizontal?: SpaceValue;
|
|
43
|
-
marginVertical?: SpaceValue;
|
|
44
|
-
marginTop?: SpaceValue;
|
|
45
|
-
marginBottom?: SpaceValue;
|
|
46
|
-
marginLeft?: SpaceValue;
|
|
47
|
-
marginRight?: SpaceValue;
|
|
48
|
-
marginEnd?: SpaceValue;
|
|
49
|
-
marginStart?: SpaceValue;
|
|
50
|
-
columnGap?: SpaceValue;
|
|
51
|
-
gap?: SpaceValue;
|
|
52
|
-
rowGap?: SpaceValue;
|
|
53
|
-
height?: SpaceValue;
|
|
54
|
-
width?: SpaceValue;
|
|
55
|
-
minHeight?: SpaceValue;
|
|
56
|
-
minWidth?: SpaceValue;
|
|
57
|
-
maxWidth?: SpaceValue;
|
|
58
|
-
maxHeight?: SpaceValue;
|
|
59
|
-
start?: SpaceValue;
|
|
60
|
-
end?: SpaceValue;
|
|
61
|
-
backgroundColor?: ColorValue;
|
|
62
|
-
borderColor?: ColorValue;
|
|
63
|
-
borderBottomColor?: ColorValue;
|
|
64
|
-
borderLeftColor?: ColorValue;
|
|
65
|
-
borderRightColor?: ColorValue;
|
|
66
|
-
borderTopColor?: ColorValue;
|
|
67
|
-
borderBlockColor?: ColorValue;
|
|
68
|
-
borderBlockEndColor?: ColorValue;
|
|
69
|
-
borderBlockStartColor?: ColorValue;
|
|
70
|
-
borderEndColor?: ColorValue;
|
|
71
|
-
borderStartColor?: ColorValue;
|
|
72
|
-
outlineColor?: ColorValue;
|
|
73
|
-
shadowColor?: ColorValue;
|
|
74
|
-
borderRadius?: BorderRadiusValue;
|
|
75
|
-
borderBottomEndRadius?: BorderRadiusValue;
|
|
76
|
-
borderBottomLeftRadius?: BorderRadiusValue;
|
|
77
|
-
borderBottomRightRadius?: BorderRadiusValue;
|
|
78
|
-
borderBottomStartRadius?: BorderRadiusValue;
|
|
79
|
-
borderTopEndRadius?: BorderRadiusValue;
|
|
80
|
-
borderTopLeftRadius?: BorderRadiusValue;
|
|
81
|
-
borderTopRightRadius?: BorderRadiusValue;
|
|
82
|
-
borderTopStartRadius?: BorderRadiusValue;
|
|
83
|
-
borderEndEndRadius?: BorderRadiusValue;
|
|
84
|
-
borderEndStartRadius?: BorderRadiusValue;
|
|
85
|
-
borderStartEndRadius?: BorderRadiusValue;
|
|
86
|
-
borderStartStartRadius?: BorderRadiusValue;
|
|
87
|
-
opacity?: OpacityValue;
|
|
88
|
-
borderBottomWidth?: BordeWidthValue;
|
|
89
|
-
borderEndWidth?: BordeWidthValue;
|
|
90
|
-
borderLeftWidth?: BordeWidthValue;
|
|
91
|
-
borderRightWidth?: BordeWidthValue;
|
|
92
|
-
borderStartWidth?: BordeWidthValue;
|
|
93
|
-
borderTopWidth?: BordeWidthValue;
|
|
94
|
-
borderWidth?: BordeWidthValue;
|
|
95
|
-
}
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import type { AllUtilityProps, SpacingValues } from '../../types';
|
|
96
4
|
interface CustomBoxProps {
|
|
97
5
|
as?: React.ElementType;
|
|
98
6
|
spacing?: SpacingValues;
|
|
99
7
|
}
|
|
100
|
-
export interface BoxProps extends
|
|
8
|
+
export interface BoxProps extends AllUtilityProps, ViewProps, CustomBoxProps {
|
|
101
9
|
}
|
|
102
10
|
export default BoxProps;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PressableProps, ViewStyle } from 'react-native';
|
|
2
|
-
import {
|
|
3
|
-
interface CardProps extends PressableProps {
|
|
2
|
+
import { GapProps, MarginProps, SpacingValues } from '../../types';
|
|
3
|
+
interface CardProps extends PressableProps, MarginProps, GapProps {
|
|
4
4
|
variant?: 'emphasis' | 'subtle';
|
|
5
5
|
colorScheme?: 'neutralStrong' | 'neutralSubtle' | 'brand' | 'energy' | 'broadband' | 'mobile' | 'insurance' | 'cashback' | 'pig';
|
|
6
6
|
shadowColor?: 'functional' | 'brand' | 'energy' | 'broadband' | 'mobile' | 'insurance' | 'cashback' | 'pig';
|
|
@@ -13,8 +13,5 @@ interface CardProps extends PressableProps {
|
|
|
13
13
|
justifyContent?: ViewStyle['justifyContent'];
|
|
14
14
|
flexDirection?: ViewStyle['flexDirection'];
|
|
15
15
|
flexWrap?: ViewStyle['flexWrap'];
|
|
16
|
-
gap?: SpaceValue;
|
|
17
|
-
rowGap?: SpaceValue;
|
|
18
|
-
columnGap?: SpaceValue;
|
|
19
16
|
}
|
|
20
17
|
export default CardProps;
|
|
@@ -1,76 +1,6 @@
|
|
|
1
1
|
import type { ViewProps } from 'react-native';
|
|
2
|
-
import {
|
|
3
|
-
interface ContainerProps extends ViewProps {
|
|
4
|
-
/**
|
|
5
|
-
* The padding of the container.
|
|
6
|
-
*/
|
|
7
|
-
padding?: SpaceValue;
|
|
8
|
-
/**
|
|
9
|
-
* The horizontal padding of the container.
|
|
10
|
-
*/
|
|
11
|
-
paddingHorizontal?: SpaceValue;
|
|
12
|
-
/**
|
|
13
|
-
* The vertical padding of the container.
|
|
14
|
-
*/
|
|
15
|
-
paddingVertical?: SpaceValue;
|
|
16
|
-
/**
|
|
17
|
-
* The top padding of the container.
|
|
18
|
-
*/
|
|
19
|
-
paddingTop?: SpaceValue;
|
|
20
|
-
/**
|
|
21
|
-
* The bottom padding of the container.
|
|
22
|
-
*/
|
|
23
|
-
paddingBottom?: SpaceValue;
|
|
24
|
-
/**
|
|
25
|
-
* The left padding of the container.
|
|
26
|
-
*/
|
|
27
|
-
paddingLeft?: SpaceValue;
|
|
28
|
-
/**
|
|
29
|
-
* The right padding of the container.
|
|
30
|
-
*/
|
|
31
|
-
paddingRight?: SpaceValue;
|
|
32
|
-
/**
|
|
33
|
-
* The margin of the container.
|
|
34
|
-
*/
|
|
35
|
-
margin?: SpaceValue;
|
|
36
|
-
/**
|
|
37
|
-
* The horizontal margin of the container.
|
|
38
|
-
*/
|
|
39
|
-
marginHorizontal?: SpaceValue;
|
|
40
|
-
/**
|
|
41
|
-
* The vertical margin of the container.
|
|
42
|
-
*/
|
|
43
|
-
marginVertical?: SpaceValue;
|
|
44
|
-
/**
|
|
45
|
-
* The top margin of the container.
|
|
46
|
-
*/
|
|
47
|
-
marginTop?: SpaceValue;
|
|
48
|
-
/**
|
|
49
|
-
* The bottom margin of the container.
|
|
50
|
-
*/
|
|
51
|
-
marginBottom?: SpaceValue;
|
|
52
|
-
/**
|
|
53
|
-
* The left margin of the container.
|
|
54
|
-
*/
|
|
55
|
-
marginLeft?: SpaceValue;
|
|
56
|
-
/**
|
|
57
|
-
* The right margin of the container.
|
|
58
|
-
*/
|
|
59
|
-
marginRight?: SpaceValue;
|
|
60
|
-
p?: SpaceValue;
|
|
61
|
-
px?: SpaceValue;
|
|
62
|
-
py?: SpaceValue;
|
|
63
|
-
pt?: SpaceValue;
|
|
64
|
-
pb?: SpaceValue;
|
|
65
|
-
pl?: SpaceValue;
|
|
66
|
-
pr?: SpaceValue;
|
|
67
|
-
m?: SpaceValue;
|
|
68
|
-
mx?: SpaceValue;
|
|
69
|
-
my?: SpaceValue;
|
|
70
|
-
mt?: SpaceValue;
|
|
71
|
-
mb?: SpaceValue;
|
|
72
|
-
ml?: SpaceValue;
|
|
73
|
-
mr?: SpaceValue;
|
|
2
|
+
import type { BackgroundColorProps, GapProps, MarginProps, PaddingProps, SpacingValues } from '../../types';
|
|
3
|
+
interface ContainerProps extends ViewProps, MarginProps, PaddingProps, GapProps, BackgroundColorProps {
|
|
74
4
|
/**
|
|
75
5
|
* The spacing between child elements (gap).
|
|
76
6
|
*/
|
|
@@ -80,11 +10,5 @@ interface ContainerProps extends ViewProps {
|
|
|
80
10
|
* @deprecated Use `spacing` instead. The `space` prop will be removed in a future release.
|
|
81
11
|
*/
|
|
82
12
|
space?: SpacingValues;
|
|
83
|
-
/**
|
|
84
|
-
* The space between child elements.
|
|
85
|
-
*/
|
|
86
|
-
gap?: SpaceValue;
|
|
87
|
-
backgroundColor?: 'backgroundBrand' | 'backgroundPrimary' | 'backgroundSecondary' | 'transparent';
|
|
88
|
-
bg?: 'backgroundBrand' | 'backgroundPrimary' | 'backgroundSecondary' | 'transparent';
|
|
89
13
|
}
|
|
90
14
|
export default ContainerProps;
|