@utilitywarehouse/hearth-react-native 0.20.0 → 0.22.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 +272 -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 +4 -11
- 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/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/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/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/NextPrevPage.tsx +2 -2
- package/docs/components/UsageWrap.tsx +2 -2
- package/docs/introduction.mdx +0 -7
- package/package.json +8 -6
- 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 +5 -11
- package/src/components/Card/Card.stories.tsx +54 -23
- package/src/components/Card/CardRoot.tsx +0 -1
- package/src/components/Carousel/Carousel.docs.mdx +49 -44
- package/src/components/Center/Center.docs.mdx +6 -4
- 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/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/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/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
|
@@ -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: ['
|
|
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: ['
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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 {
|
|
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 {
|
|
2
|
-
import type { ColorValue } from '../../types';
|
|
1
|
+
import type { CommonTextProps } from '../../types';
|
|
3
2
|
|
|
4
|
-
interface
|
|
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
|
|
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:
|
|
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 {
|
|
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 {
|
|
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
|
-
|
|
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
|
-
{...
|
|
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'];
|
|
@@ -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]} {...
|
|
29
|
+
<View style={[propStyle, styles.flex, computedStyles, style]} {...remainingProps}>
|
|
27
30
|
{children}
|
|
28
31
|
</View>
|
|
29
32
|
);
|