@utilitywarehouse/hearth-react-native 0.19.1 → 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.
Files changed (149) hide show
  1. package/.storybook/manager.ts +1 -0
  2. package/.storybook/preview.tsx +1 -0
  3. package/.turbo/turbo-build.log +1 -1
  4. package/.turbo/turbo-lint.log +13 -13
  5. package/CHANGELOG.md +299 -4
  6. package/build/components/BodyText/BodyText.js +12 -5
  7. package/build/components/BodyText/BodyText.props.d.ts +5 -19
  8. package/build/components/Box/Box.js +23 -3
  9. package/build/components/Box/Box.props.d.ts +3 -95
  10. package/build/components/Card/Card.props.d.ts +2 -5
  11. package/build/components/Container/Container.props.d.ts +2 -78
  12. package/build/components/DateInput/DateInput.d.ts +1 -1
  13. package/build/components/DateInput/DateInput.js +2 -2
  14. package/build/components/DateInput/DateInput.props.d.ts +15 -1
  15. package/build/components/DateInput/DateInputSegment.d.ts +1 -1
  16. package/build/components/DateInput/DateInputSegment.js +2 -2
  17. package/build/components/DetailText/DetailText.js +14 -13
  18. package/build/components/DetailText/DetailText.props.d.ts +4 -17
  19. package/build/components/Flex/Flex.js +3 -1
  20. package/build/components/Flex/Flex.props.d.ts +2 -2
  21. package/build/components/Heading/Heading.js +34 -13
  22. package/build/components/Heading/Heading.props.d.ts +4 -18
  23. package/build/components/Select/Select.d.ts +1 -1
  24. package/build/components/Select/Select.js +9 -10
  25. package/build/components/Select/Select.props.d.ts +16 -0
  26. package/build/core/themes.d.ts +188 -8
  27. package/build/core/themes.js +18 -2
  28. package/build/hooks/useStyleProps.js +22 -5
  29. package/build/tokens/color.d.ts +4 -0
  30. package/build/tokens/color.js +2 -0
  31. package/build/tokens/components/dark/modal.d.ts +6 -0
  32. package/build/tokens/components/dark/modal.js +6 -0
  33. package/build/tokens/components/dark/navigation.d.ts +1 -0
  34. package/build/tokens/components/dark/navigation.js +1 -0
  35. package/build/tokens/components/light/modal.d.ts +6 -0
  36. package/build/tokens/components/light/modal.js +6 -0
  37. package/build/tokens/components/light/navigation.d.ts +1 -0
  38. package/build/tokens/components/light/navigation.js +1 -0
  39. package/build/tokens/components/light/skeleton.d.ts +1 -1
  40. package/build/tokens/components/light/skeleton.js +1 -1
  41. package/build/tokens/font.d.ts +2 -0
  42. package/build/tokens/font.js +2 -0
  43. package/build/tokens/line-height.d.ts +2 -0
  44. package/build/tokens/line-height.js +2 -0
  45. package/build/tokens/primitive.d.ts +4 -0
  46. package/build/tokens/primitive.js +4 -0
  47. package/build/tokens/semantic-dark.d.ts +1 -0
  48. package/build/tokens/semantic-dark.js +1 -0
  49. package/build/tokens/semantic-light.d.ts +1 -0
  50. package/build/tokens/semantic-light.js +1 -0
  51. package/build/tokens/typography.d.ts +30 -0
  52. package/build/tokens/typography.js +15 -0
  53. package/build/types/index.d.ts +4 -2
  54. package/build/types/index.js +4 -2
  55. package/build/types/semanticColorValues.d.ts +22 -0
  56. package/build/types/semanticColorValues.js +1 -0
  57. package/build/types/utilityProps.d.ts +326 -0
  58. package/build/types/utilityProps.js +1 -0
  59. package/build/types/values.d.ts +4 -3
  60. package/build/utils/coloursAsArray.d.ts +4 -0
  61. package/build/utils/coloursAsArray.js +5 -0
  62. package/build/utils/index.d.ts +1 -1
  63. package/build/utils/index.js +1 -1
  64. package/build/utils/styleUtils.d.ts +26 -2
  65. package/build/utils/styleUtils.js +42 -13
  66. package/build/utils/themeValueHelpers.d.ts +13 -0
  67. package/build/utils/themeValueHelpers.js +29 -0
  68. package/docs/changelog.mdx +74 -2
  69. package/docs/components/AllComponents.web.tsx +23 -24
  70. package/docs/components/UsageWrap.tsx +2 -2
  71. package/docs/introduction.mdx +0 -7
  72. package/package.json +5 -3
  73. package/src/components/BodyText/BodyText.props.ts +5 -19
  74. package/src/components/BodyText/BodyText.stories.tsx +2 -1
  75. package/src/components/BodyText/BodyText.tsx +17 -6
  76. package/src/components/Box/Box.docs.mdx +5 -4
  77. package/src/components/Box/Box.props.ts +3 -231
  78. package/src/components/Box/Box.stories.tsx +2 -2
  79. package/src/components/Box/Box.tsx +38 -9
  80. package/src/components/Button/Button.docs.mdx +46 -1
  81. package/src/components/Card/Card.docs.mdx +1 -1
  82. package/src/components/Card/Card.props.ts +2 -5
  83. package/src/components/Card/Card.stories.tsx +54 -23
  84. package/src/components/Carousel/Carousel.docs.mdx +49 -44
  85. package/src/components/Center/Center.docs.mdx +6 -4
  86. package/src/components/Checkbox/CheckboxGroup.figma.tsx +21 -1
  87. package/src/components/Container/Container.docs.mdx +13 -8
  88. package/src/components/Container/Container.props.ts +9 -80
  89. package/src/components/Container/Container.stories.tsx +81 -65
  90. package/src/components/DateInput/DateInput.docs.mdx +43 -0
  91. package/src/components/DateInput/DateInput.props.ts +15 -1
  92. package/src/components/DateInput/DateInput.stories.tsx +37 -2
  93. package/src/components/DateInput/DateInput.tsx +6 -0
  94. package/src/components/DateInput/DateInputSegment.tsx +2 -0
  95. package/src/components/DetailText/DetailText.props.ts +4 -17
  96. package/src/components/DetailText/DetailText.stories.tsx +2 -3
  97. package/src/components/DetailText/DetailText.tsx +16 -17
  98. package/src/components/Flex/Flex.props.ts +2 -2
  99. package/src/components/Flex/Flex.stories.tsx +1 -1
  100. package/src/components/Flex/Flex.tsx +4 -1
  101. package/src/components/Grid/Grid.docs.mdx +53 -49
  102. package/src/components/Heading/Heading.props.ts +4 -18
  103. package/src/components/Heading/Heading.stories.tsx +2 -1
  104. package/src/components/Heading/Heading.tsx +40 -18
  105. package/src/components/PillGroup/Pill.figma.tsx +4 -17
  106. package/src/components/PillGroup/PillGroup.figma.tsx +8 -9
  107. package/src/components/ProgressStepper/ProgressStep.figma.tsx +4 -15
  108. package/src/components/ProgressStepper/ProgressStepper.figma.tsx +9 -16
  109. package/src/components/Radio/Radio.figma.tsx +35 -22
  110. package/src/components/Radio/RadioGroup.figma.tsx +69 -41
  111. package/src/components/Radio/RadioTile.figma.tsx +34 -0
  112. package/src/components/RadioCard/RadioCard.figma.tsx +24 -0
  113. package/src/components/SectionHeader/SectionHeader.figma.tsx +31 -25
  114. package/src/components/Select/Select.docs.mdx +76 -28
  115. package/src/components/Select/Select.figma.tsx +44 -43
  116. package/src/components/Select/Select.props.ts +16 -0
  117. package/src/components/Select/Select.tsx +42 -35
  118. package/src/components/Select/SelectOption.figma.tsx +3 -21
  119. package/src/components/Spinner/Spinner.figma.tsx +12 -25
  120. package/src/components/Switch/Switch.figma.tsx +2 -23
  121. package/src/components/Tabs/Tab.figma.tsx +21 -0
  122. package/src/components/Tabs/Tabs.figma.tsx +18 -27
  123. package/src/components/Textarea/Textarea.figma.tsx +64 -0
  124. package/src/components/Toast/ToastItem.figma.tsx +1 -8
  125. package/src/components/ToggleButtonCard/ToggleButtonCard.figma.tsx +24 -0
  126. package/src/components/VerificationInput/VerificationInput.figma.tsx +53 -0
  127. package/src/core/themes.ts +19 -2
  128. package/src/hooks/useStyleProps.ts +40 -5
  129. package/src/tokens/color.ts +2 -0
  130. package/src/tokens/components/dark/modal.ts +6 -0
  131. package/src/tokens/components/dark/navigation.ts +1 -0
  132. package/src/tokens/components/light/modal.ts +6 -0
  133. package/src/tokens/components/light/navigation.ts +1 -0
  134. package/src/tokens/components/light/skeleton.ts +1 -1
  135. package/src/tokens/font.ts +2 -0
  136. package/src/tokens/line-height.ts +2 -0
  137. package/src/tokens/primitive.ts +4 -0
  138. package/src/tokens/semantic-dark.ts +1 -0
  139. package/src/tokens/semantic-light.ts +1 -0
  140. package/src/tokens/typography.ts +15 -0
  141. package/src/types/index.ts +4 -2
  142. package/src/types/semanticColorValues.ts +26 -0
  143. package/src/types/utilityProps.ts +410 -0
  144. package/src/types/values.ts +4 -7
  145. package/src/utils/coloursAsArray.ts +6 -0
  146. package/src/utils/index.ts +8 -1
  147. package/src/utils/styleUtils.ts +45 -14
  148. package/src/utils/themeValueHelpers.ts +38 -0
  149. package/src/components/Radio/RadioTileRoot.figma.tsx +0 -31
@@ -1,6 +1,7 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-vite';
2
2
  import { Container } from '.';
3
3
  import { lightTheme } from '../../core/themes';
4
+ import { useTheme } from '../../hooks';
4
5
  import { BodyText } from '../BodyText';
5
6
  import { Box } from '../Box';
6
7
 
@@ -165,12 +166,12 @@ const meta = {
165
166
  description: 'The space between child elements.',
166
167
  },
167
168
  backgroundColor: {
168
- options: ['backgroundBrand', 'backgroundPrimary', 'backgroundSecondary', 'transparent'],
169
+ options: ['brand', 'primary', 'secondary', 'transparent'],
169
170
  control: 'select',
170
171
  description: 'The background color of the container.',
171
172
  },
172
173
  bg: {
173
- options: ['backgroundBrand', 'backgroundPrimary', 'backgroundSecondary', 'transparent'],
174
+ options: ['brand', 'primary', 'secondary', 'transparent'],
174
175
  control: 'select',
175
176
  description: 'The background color of the container.',
176
177
  },
@@ -185,51 +186,60 @@ export default meta;
185
186
  type Story = StoryObj<typeof meta>;
186
187
 
187
188
  export const Playground: Story = {
188
- render: args => (
189
- <Box backgroundColor="red100">
190
- <Container {...args} backgroundColor="backgroundSecondary">
191
- <Box bg="blue400" p="200" borderRadius="md">
192
- <BodyText>Container content 1</BodyText>
193
- </Box>
194
- <Box bg="purple400" p="200" borderRadius="md">
195
- <BodyText>Container content 2</BodyText>
196
- </Box>
197
- <Box bg="piggyPink400" p="200" borderRadius="md">
198
- <BodyText>Container content 3</BodyText>
199
- </Box>
200
- </Container>
201
- </Box>
202
- ),
189
+ render: args => {
190
+ const { color } = useTheme();
191
+ return (
192
+ <Box backgroundColor={color.red['100']}>
193
+ <Container {...args} backgroundColor="secondary">
194
+ <Box bg={color.blue['400']} p="200" borderRadius="md">
195
+ <BodyText>Container content 1</BodyText>
196
+ </Box>
197
+ <Box bg={color.purple['400']} p="200" borderRadius="md">
198
+ <BodyText>Container content 2</BodyText>
199
+ </Box>
200
+ <Box bg={color.piggyPink['400']} p="200" borderRadius="md">
201
+ <BodyText>Container content 3</BodyText>
202
+ </Box>
203
+ </Container>
204
+ </Box>
205
+ );
206
+ },
203
207
  };
204
208
 
205
209
  export const WithPadding: Story = {
206
210
  args: {
207
211
  padding: '300',
208
212
  },
209
- render: args => (
210
- <Box backgroundColor="red100">
211
- <Container {...args} backgroundColor="backgroundSecondary">
212
- <Box bg="blue400" p="200" borderRadius="md">
213
- <BodyText>Container with padding</BodyText>
214
- </Box>
215
- </Container>
216
- </Box>
217
- ),
213
+ render: args => {
214
+ const { color } = useTheme();
215
+ return (
216
+ <Box backgroundColor={color.red['100']}>
217
+ <Container {...args} backgroundColor="secondary">
218
+ <Box bg={color.blue['400']} p="200" borderRadius="md">
219
+ <BodyText>Container with padding</BodyText>
220
+ </Box>
221
+ </Container>
222
+ </Box>
223
+ );
224
+ },
218
225
  };
219
226
 
220
227
  export const WithMargin: Story = {
221
228
  args: {
222
229
  margin: '300',
223
230
  },
224
- render: args => (
225
- <Box backgroundColor="red100">
226
- <Container {...args} backgroundColor="backgroundSecondary">
227
- <Box bg="blue400" p="200" borderRadius="md">
228
- <BodyText>Container with margin</BodyText>
229
- </Box>
230
- </Container>
231
- </Box>
232
- ),
231
+ render: args => {
232
+ const { color } = useTheme();
233
+ return (
234
+ <Box backgroundColor={color.red['100']}>
235
+ <Container {...args} backgroundColor="secondary">
236
+ <Box bg={color.blue['400']} p="200" borderRadius="md">
237
+ <BodyText>Container with margin</BodyText>
238
+ </Box>
239
+ </Container>
240
+ </Box>
241
+ );
242
+ },
233
243
  };
234
244
 
235
245
  export const WithCustomSpacing: Story = {
@@ -238,37 +248,43 @@ export const WithCustomSpacing: Story = {
238
248
  paddingHorizontal: '200',
239
249
  paddingVertical: '300',
240
250
  },
241
- render: args => (
242
- <Box backgroundColor="red100">
243
- <Container {...args} backgroundColor="backgroundSecondary">
244
- <Box bg="blue400" p="200" borderRadius="md">
245
- <BodyText>Item 1</BodyText>
246
- </Box>
247
- <Box bg="purple400" p="200" borderRadius="md">
248
- <BodyText>Item 2</BodyText>
249
- </Box>
250
- <Box bg="piggyPink400" p="200" borderRadius="md">
251
- <BodyText>Item 3</BodyText>
252
- </Box>
253
- <Box bg="orange400" p="200" borderRadius="md">
254
- <BodyText>Item 4</BodyText>
255
- </Box>
256
- </Container>
257
- </Box>
258
- ),
251
+ render: args => {
252
+ const { color } = useTheme();
253
+ return (
254
+ <Box backgroundColor={color.red['100']}>
255
+ <Container {...args} backgroundColor="secondary">
256
+ <Box bg={color.blue['400']} p="200" borderRadius="md">
257
+ <BodyText>Item 1</BodyText>
258
+ </Box>
259
+ <Box bg={color.purple['400']} p="200" borderRadius="md">
260
+ <BodyText>Item 2</BodyText>
261
+ </Box>
262
+ <Box bg={color.piggyPink['400']} p="200" borderRadius="md">
263
+ <BodyText>Item 3</BodyText>
264
+ </Box>
265
+ <Box bg={color.orange['400']} p="200" borderRadius="md">
266
+ <BodyText>Item 4</BodyText>
267
+ </Box>
268
+ </Container>
269
+ </Box>
270
+ );
271
+ },
259
272
  };
260
273
 
261
274
  export const LayoutTokens: Story = {
262
- render: () => (
263
- <Box backgroundColor="red100">
264
- <Container backgroundColor="backgroundSecondary">
265
- <Box bg="blue100" p="200" borderRadius="md">
266
- <BodyText>
267
- This Container uses the responsive layout tokens from the design system. It will
268
- automatically adjust margin and padding based on the current breakpoint.
269
- </BodyText>
270
- </Box>
271
- </Container>
272
- </Box>
273
- ),
275
+ render: () => {
276
+ const { color } = useTheme();
277
+ return (
278
+ <Box backgroundColor={color.red['100']}>
279
+ <Container backgroundColor="secondary">
280
+ <Box bg={color.blue['100']} p="200" borderRadius="md">
281
+ <BodyText>
282
+ This Container uses the responsive layout tokens from the design system. It will
283
+ automatically adjust margin and padding based on the current breakpoint.
284
+ </BodyText>
285
+ </Box>
286
+ </Container>
287
+ </Box>
288
+ );
289
+ },
274
290
  };
@@ -26,6 +26,7 @@ The `DateInput` component allows users to enter dates manually using separate in
26
26
  - [Flexible Segments](#flexible-segments)
27
27
  - [Grouping Inputs](#grouping-inputs)
28
28
  - [With State](#with-state)
29
+ - [Segment Refs](#segment-refs)
29
30
  - [Overriding Styles](#overriding-styles)
30
31
  - [Accessibility](#accessibility)
31
32
 
@@ -86,6 +87,9 @@ const MyComponent = () => {
86
87
  | `dayValue` | `string` | - | Controlled value for the day segment |
87
88
  | `monthValue` | `string` | - | Controlled value for the month segment |
88
89
  | `yearValue` | `string` | - | Controlled value for the year segment |
90
+ | `dayRef` | `Ref<TextInput>` | - | Ref for the day input segment |
91
+ | `monthRef` | `Ref<TextInput>` | - | Ref for the month input segment |
92
+ | `yearRef` | `Ref<TextInput>` | - | Ref for the year input segment |
89
93
  | `onDayChange` | `(text: string) => void` | - | Callback fired when the day value changes |
90
94
  | `onMonthChange` | `(text: string) => void` | - | Callback fired when the month value changes |
91
95
  | `onYearChange` | `(text: string) => void` | - | Callback fired when the year value changes |
@@ -159,6 +163,45 @@ Programmatically control date values:
159
163
 
160
164
  <Canvas of={Stories.WithState} />
161
165
 
166
+ ### Segment Refs
167
+
168
+ Use `dayRef`, `monthRef`, and `yearRef` to focus each segment programmatically:
169
+
170
+ <Canvas of={Stories.WithRefs} />
171
+
172
+ ```tsx
173
+ import { useRef, useState } from 'react';
174
+ import { TextInput } from 'react-native';
175
+ import { Button, DateInput } from '@utilitywarehouse/hearth-react-native';
176
+
177
+ const MyComponent = () => {
178
+ const [day, setDay] = useState('');
179
+ const [month, setMonth] = useState('');
180
+ const [year, setYear] = useState('');
181
+
182
+ const dayRef = useRef<TextInput>(null);
183
+ const monthRef = useRef<TextInput>(null);
184
+ const yearRef = useRef<TextInput>(null);
185
+
186
+ return (
187
+ <>
188
+ <DateInput
189
+ dayValue={day}
190
+ monthValue={month}
191
+ yearValue={year}
192
+ onDayChange={setDay}
193
+ onMonthChange={setMonth}
194
+ onYearChange={setYear}
195
+ dayRef={dayRef}
196
+ monthRef={monthRef}
197
+ yearRef={yearRef}
198
+ />
199
+ <Button onPress={() => monthRef.current?.focus()}>Focus month</Button>
200
+ </>
201
+ );
202
+ };
203
+ ```
204
+
162
205
  ### Overriding Styles
163
206
 
164
207
  You can override the styles of the input containers, input fields, and input labels using the `inputContainerStyle`, `inputStyle`, and `inputLabelStyle` props respectively:
@@ -1,4 +1,5 @@
1
- import type { TextInputProps, ViewProps } from 'react-native';
1
+ import type { Ref } from 'react';
2
+ import type { TextInput, TextInputProps, ViewProps } from 'react-native';
2
3
  import type { FormFieldBaseProps } from '../FormField/FormField.props';
3
4
  import LabelProps from '../Label/Label.props';
4
5
 
@@ -42,6 +43,18 @@ export interface DateInputProps extends FormFieldBaseProps {
42
43
  * The controlled value for the year segment. Must be used with an `onYearChange` handler.
43
44
  */
44
45
  yearValue?: string;
46
+ /**
47
+ * Ref for the day segment input.
48
+ */
49
+ dayRef?: Ref<TextInput>;
50
+ /**
51
+ * Ref for the month segment input.
52
+ */
53
+ monthRef?: Ref<TextInput>;
54
+ /**
55
+ * Ref for the year segment input.
56
+ */
57
+ yearRef?: Ref<TextInput>;
45
58
  /**
46
59
  * Callback fired when the day value changes.
47
60
  */
@@ -96,6 +109,7 @@ export interface DateInputSegmentProps {
96
109
  label: string;
97
110
  placeholder?: string;
98
111
  value?: string;
112
+ inputRef?: Ref<TextInput>;
99
113
  onChange?: (text: string) => void;
100
114
  onFocus?: DateInputProps['onDayFocus'];
101
115
  onBlur?: DateInputProps['onDayBlur'];
@@ -1,7 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-native';
2
2
  import { TickSmallIcon, WarningSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
3
- import { useState } from 'react';
4
- import { View } from 'react-native';
3
+ import { useRef, useState } from 'react';
4
+ import { TextInput, View } from 'react-native';
5
5
  import { Button, Card, Flex, Heading } from '../../components';
6
6
  import { DateInput } from './';
7
7
 
@@ -268,6 +268,41 @@ export const WithState: Story = {
268
268
  },
269
269
  };
270
270
 
271
+ export const WithRefs: Story = {
272
+ render: () => {
273
+ const [day, setDay] = useState('');
274
+ const [month, setMonth] = useState('');
275
+ const [year, setYear] = useState('');
276
+
277
+ const dayRef = useRef<TextInput>(null);
278
+ const monthRef = useRef<TextInput>(null);
279
+ const yearRef = useRef<TextInput>(null);
280
+
281
+ return (
282
+ <Flex spacing="md">
283
+ <DateInput
284
+ label="Date"
285
+ helperText="Use buttons to focus each segment"
286
+ dayValue={day}
287
+ monthValue={month}
288
+ yearValue={year}
289
+ onDayChange={setDay}
290
+ onMonthChange={setMonth}
291
+ onYearChange={setYear}
292
+ dayRef={dayRef}
293
+ monthRef={monthRef}
294
+ yearRef={yearRef}
295
+ />
296
+ <Flex spacing="xs">
297
+ <Button onPress={() => dayRef.current?.focus()}>Focus day</Button>
298
+ <Button onPress={() => monthRef.current?.focus()}>Focus month</Button>
299
+ <Button onPress={() => yearRef.current?.focus()}>Focus year</Button>
300
+ </Flex>
301
+ </Flex>
302
+ );
303
+ },
304
+ };
305
+
271
306
  export const CustomWidth: Story = {
272
307
  render: () => (
273
308
  <DateInput
@@ -23,6 +23,9 @@ const DateInput = ({
23
23
  dayValue,
24
24
  monthValue,
25
25
  yearValue,
26
+ dayRef,
27
+ monthRef,
28
+ yearRef,
26
29
  onDayChange,
27
30
  onMonthChange,
28
31
  onYearChange,
@@ -57,6 +60,7 @@ const DateInput = ({
57
60
  label="Day"
58
61
  placeholder={dayPlaceholder}
59
62
  value={dayValue}
63
+ inputRef={dayRef}
60
64
  onChange={onDayChange}
61
65
  onFocus={onDayFocus}
62
66
  onBlur={onDayBlur}
@@ -76,6 +80,7 @@ const DateInput = ({
76
80
  label="Month"
77
81
  placeholder={monthPlaceholder}
78
82
  value={monthValue}
83
+ inputRef={monthRef}
79
84
  onChange={onMonthChange}
80
85
  onFocus={onMonthFocus}
81
86
  onBlur={onMonthBlur}
@@ -95,6 +100,7 @@ const DateInput = ({
95
100
  label="Year"
96
101
  placeholder={yearPlaceholder}
97
102
  value={yearValue}
103
+ inputRef={yearRef}
98
104
  onChange={onYearChange}
99
105
  onFocus={onYearFocus}
100
106
  onBlur={onYearBlur}
@@ -8,6 +8,7 @@ const DateInputSegment = ({
8
8
  label,
9
9
  placeholder,
10
10
  value,
11
+ inputRef,
11
12
  onChange,
12
13
  onFocus,
13
14
  onBlur,
@@ -27,6 +28,7 @@ const DateInputSegment = ({
27
28
  {label}
28
29
  </BodyText>
29
30
  <Input
31
+ ref={inputRef}
30
32
  value={value}
31
33
  onChangeText={onChange}
32
34
  onFocus={onFocus}
@@ -1,21 +1,8 @@
1
- import type { TextProps as RNTextProps, TextStyle } from 'react-native';
2
- import type { ColorValue } from '../../types';
1
+ import type { CommonTextProps } from '../../types';
3
2
 
4
- interface TextProps extends RNTextProps {
3
+ interface DetailTextProps extends CommonTextProps {
4
+ /** Text size variant. */
5
5
  size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
6
- strikeThrough?: boolean;
7
- underline?: boolean;
8
- truncated?: boolean;
9
- italic?: boolean;
10
- color?: ColorValue;
11
- textTransform?: TextStyle['textTransform'];
12
- textAlign?: TextStyle['textAlign'];
13
- textAlignVertical?: TextStyle['textAlignVertical'];
14
- textDecorationLine?: TextStyle['textDecorationLine'];
15
- textDecorationStyle?: TextStyle['textDecorationStyle'];
16
- textDecorationColor?: ColorValue;
17
- userSelect?: TextStyle['userSelect'];
18
- inverted?: boolean;
19
6
  }
20
7
 
21
- export default TextProps;
8
+ export default DetailTextProps;
@@ -1,7 +1,7 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-vite';
2
2
  import { DetailText } from '.';
3
3
  import { VariantTitle } from '../../../docs/components';
4
- import { coloursAsArray } from '../../utils';
4
+ import { coloursAsArray, textColorKeys } from '../../utils';
5
5
  import { Box } from '../Box';
6
6
 
7
7
  // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
@@ -24,7 +24,6 @@ const meta = {
24
24
  control: 'boolean',
25
25
  description: 'Truncate the text.',
26
26
  },
27
-
28
27
  italic: {
29
28
  type: 'boolean',
30
29
  control: 'boolean',
@@ -41,7 +40,7 @@ const meta = {
41
40
  description: 'Strike through the text.',
42
41
  },
43
42
  color: {
44
- options: coloursAsArray(),
43
+ options: textColorKeys,
45
44
  control: 'select',
46
45
  description: 'Color of the text. Use the color name from the theme.',
47
46
  },
@@ -1,8 +1,7 @@
1
- import { useMemo } from 'react';
2
1
  import { Text } from 'react-native';
3
2
  import { StyleSheet } from 'react-native-unistyles';
4
- import { useTheme } from '../../hooks';
5
- import { getFlattenedColorValue } from '../../utils';
3
+ import { useStyleProps } from '../../hooks';
4
+ import { getFlattenedColorValue, resolveThemeValueWithFallback } from '../../utils';
6
5
  import type DetailTextProps from './DetailText.props';
7
6
 
8
7
  const DetailText = ({
@@ -23,7 +22,8 @@ const DetailText = ({
23
22
  inverted,
24
23
  ...props
25
24
  }: DetailTextProps) => {
26
- const { color: themeColor, colorMode } = useTheme();
25
+ const { computedStyles: utilityStyles, remainingProps } = useStyleProps(props);
26
+
27
27
  styles.useVariants({
28
28
  size,
29
29
  underline,
@@ -31,19 +31,10 @@ const DetailText = ({
31
31
  italic,
32
32
  inverted,
33
33
  });
34
- const colorValue = useMemo(
35
- () => getFlattenedColorValue(color, themeColor),
36
- // eslint-disable-next-line react-hooks/exhaustive-deps
37
- [color, colorMode]
38
- );
39
- const decorationColor = useMemo(
40
- () => getFlattenedColorValue(textDecorationColor, themeColor),
41
- // eslint-disable-next-line react-hooks/exhaustive-deps
42
- [textDecorationColor, colorMode]
43
- );
34
+
44
35
  return (
45
36
  <Text
46
- {...props}
37
+ {...remainingProps}
47
38
  {...(truncated
48
39
  ? {
49
40
  numberOfLines: 1,
@@ -52,16 +43,16 @@ const DetailText = ({
52
43
  : {})}
53
44
  style={[
54
45
  styles.text,
46
+ utilityStyles,
55
47
  {
56
- ...(colorValue && { color: colorValue }),
57
48
  ...(textTransform && { textTransform }),
58
49
  ...(textAlign && { textAlign }),
59
- ...(decorationColor && { textDecorationColor: decorationColor }),
60
50
  ...(textDecorationLine && { textDecorationLine }),
61
51
  ...(textDecorationStyle && { textDecorationStyle }),
62
52
  ...(userSelect && { userSelect }),
63
53
  ...(textAlignVertical && { textAlignVertical }),
64
54
  },
55
+ styles.getColours(color, textDecorationColor),
65
56
  props.style,
66
57
  ]}
67
58
  >
@@ -143,6 +134,14 @@ const styles = StyleSheet.create(theme => ({
143
134
  },
144
135
  },
145
136
  },
137
+ getColours: (color?: string, textDecorationColor?: string) => ({
138
+ ...(color
139
+ ? { color: resolveThemeValueWithFallback(color, theme.helpers.semanticColor.text, theme.color) }
140
+ : {}),
141
+ ...(textDecorationColor
142
+ ? { textDecorationColor: getFlattenedColorValue(textDecorationColor, theme.color) }
143
+ : {}),
144
+ }),
146
145
  }));
147
146
 
148
147
  export default DetailText;
@@ -1,7 +1,7 @@
1
1
  import type { FlexAlignType, ViewProps, ViewStyle } from 'react-native';
2
- import { SpacingValues } from '../../types';
2
+ import { FlexLayoutProps, GapProps, SpacingValues } from '../../types';
3
3
 
4
- interface FlexProps extends ViewProps {
4
+ interface FlexProps extends ViewProps, FlexLayoutProps, GapProps {
5
5
  direction?: ViewStyle['flexDirection'];
6
6
  align?: FlexAlignType;
7
7
  justify?: ViewStyle['justifyContent'];
@@ -68,7 +68,7 @@ export const Playground: Story = {
68
68
  bg={`grey${index + 1}00`}
69
69
  w={100 + index * 10}
70
70
  h={100 + index * 10}
71
- borderColor="grey800"
71
+ borderColor="strong"
72
72
  borderWidth="2"
73
73
  borderRadius="md"
74
74
  />
@@ -1,5 +1,6 @@
1
1
  import { View, ViewStyle } from 'react-native';
2
2
  import { StyleSheet } from 'react-native-unistyles';
3
+ import { useStyleProps } from '../../hooks';
3
4
  import FlexProps from './Flex.props';
4
5
 
5
6
  const Flex = ({
@@ -20,10 +21,12 @@ const Flex = ({
20
21
  flexWrap: wrap,
21
22
  };
22
23
 
24
+ const { computedStyles, remainingProps } = useStyleProps(rest);
25
+
23
26
  styles.useVariants({ spacing: space ?? spacing });
24
27
 
25
28
  return (
26
- <View style={[propStyle, styles.flex, style]} {...rest}>
29
+ <View style={[propStyle, styles.flex, computedStyles, style]} {...remainingProps}>
27
30
  {children}
28
31
  </View>
29
32
  );