@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DateInputProps } from './DateInput.props';
|
|
2
2
|
declare const DateInput: {
|
|
3
|
-
({ label, helperText, helperIcon, validationStatus, validText, invalidText, disabled, readonly, required, hideDay, hideMonth, hideYear, dayPlaceholder, monthPlaceholder, yearPlaceholder, dayValue, monthValue, yearValue, onDayChange, onMonthChange, onYearChange, onDayFocus, onMonthFocus, onYearFocus, onDayBlur, onMonthBlur, onYearBlur, inputLabelStyle, inputContainerStyle, inputStyle, ...props }: DateInputProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
({ label, helperText, helperIcon, validationStatus, validText, invalidText, disabled, readonly, required, hideDay, hideMonth, hideYear, dayPlaceholder, monthPlaceholder, yearPlaceholder, dayValue, monthValue, yearValue, dayRef, monthRef, yearRef, onDayChange, onMonthChange, onYearChange, onDayFocus, onMonthFocus, onYearFocus, onDayBlur, onMonthBlur, onYearBlur, inputLabelStyle, inputContainerStyle, inputStyle, ...props }: DateInputProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
displayName: string;
|
|
5
5
|
};
|
|
6
6
|
export default DateInput;
|
|
@@ -3,8 +3,8 @@ import { View } from 'react-native';
|
|
|
3
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
4
4
|
import { FormField } from '../FormField';
|
|
5
5
|
import DateInputSegment from './DateInputSegment';
|
|
6
|
-
const DateInput = ({ label, helperText, helperIcon, validationStatus = 'initial', validText, invalidText, disabled, readonly, required, hideDay = false, hideMonth = false, hideYear = false, dayPlaceholder = 'DD', monthPlaceholder = 'MM', yearPlaceholder = 'YYYY', dayValue, monthValue, yearValue, onDayChange, onMonthChange, onYearChange, onDayFocus, onMonthFocus, onYearFocus, onDayBlur, onMonthBlur, onYearBlur, inputLabelStyle, inputContainerStyle, inputStyle, ...props }) => {
|
|
7
|
-
return (_jsx(FormField, { label: label, helperText: helperText, helperIcon: helperIcon, validationStatus: validationStatus, validText: validText, invalidText: invalidText, disabled: disabled, readonly: readonly, required: required, style: styles.wrap, ...props, children: _jsxs(View, { style: styles.container, children: [!hideDay && (_jsx(DateInputSegment, { label: "Day", placeholder: dayPlaceholder, value: dayValue, onChange: onDayChange, onFocus: onDayFocus, onBlur: onDayBlur, disabled: disabled, required: required, readonly: readonly, validationStatus: validationStatus, maxLength: 2, testID: "date-input-day", inputContainerStyle: inputContainerStyle, inputStyle: inputStyle, inputLabelStyle: inputLabelStyle })), !hideMonth && (_jsx(DateInputSegment, { label: "Month", placeholder: monthPlaceholder, value: monthValue, onChange: onMonthChange, onFocus: onMonthFocus, onBlur: onMonthBlur, disabled: disabled, required: required, readonly: readonly, validationStatus: validationStatus, maxLength: 2, testID: "date-input-month", inputContainerStyle: inputContainerStyle, inputStyle: inputStyle, inputLabelStyle: inputLabelStyle })), !hideYear && (_jsx(DateInputSegment, { label: "Year", placeholder: yearPlaceholder, value: yearValue, onChange: onYearChange, onFocus: onYearFocus, onBlur: onYearBlur, disabled: disabled, required: required, readonly: readonly, validationStatus: validationStatus, maxLength: 4, testID: "date-input-year", inputContainerStyle: inputContainerStyle, inputStyle: inputStyle, inputLabelStyle: inputLabelStyle }))] }) }));
|
|
6
|
+
const DateInput = ({ label, helperText, helperIcon, validationStatus = 'initial', validText, invalidText, disabled, readonly, required, hideDay = false, hideMonth = false, hideYear = false, dayPlaceholder = 'DD', monthPlaceholder = 'MM', yearPlaceholder = 'YYYY', dayValue, monthValue, yearValue, dayRef, monthRef, yearRef, onDayChange, onMonthChange, onYearChange, onDayFocus, onMonthFocus, onYearFocus, onDayBlur, onMonthBlur, onYearBlur, inputLabelStyle, inputContainerStyle, inputStyle, ...props }) => {
|
|
7
|
+
return (_jsx(FormField, { label: label, helperText: helperText, helperIcon: helperIcon, validationStatus: validationStatus, validText: validText, invalidText: invalidText, disabled: disabled, readonly: readonly, required: required, style: styles.wrap, ...props, children: _jsxs(View, { style: styles.container, children: [!hideDay && (_jsx(DateInputSegment, { label: "Day", placeholder: dayPlaceholder, value: dayValue, inputRef: dayRef, onChange: onDayChange, onFocus: onDayFocus, onBlur: onDayBlur, disabled: disabled, required: required, readonly: readonly, validationStatus: validationStatus, maxLength: 2, testID: "date-input-day", inputContainerStyle: inputContainerStyle, inputStyle: inputStyle, inputLabelStyle: inputLabelStyle })), !hideMonth && (_jsx(DateInputSegment, { label: "Month", placeholder: monthPlaceholder, value: monthValue, inputRef: monthRef, onChange: onMonthChange, onFocus: onMonthFocus, onBlur: onMonthBlur, disabled: disabled, required: required, readonly: readonly, validationStatus: validationStatus, maxLength: 2, testID: "date-input-month", inputContainerStyle: inputContainerStyle, inputStyle: inputStyle, inputLabelStyle: inputLabelStyle })), !hideYear && (_jsx(DateInputSegment, { label: "Year", placeholder: yearPlaceholder, value: yearValue, inputRef: yearRef, onChange: onYearChange, onFocus: onYearFocus, onBlur: onYearBlur, disabled: disabled, required: required, readonly: readonly, validationStatus: validationStatus, maxLength: 4, testID: "date-input-year", inputContainerStyle: inputContainerStyle, inputStyle: inputStyle, inputLabelStyle: inputLabelStyle }))] }) }));
|
|
8
8
|
};
|
|
9
9
|
DateInput.displayName = 'DateInput';
|
|
10
10
|
const styles = StyleSheet.create(theme => ({
|
|
@@ -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
|
export interface DateInputProps extends FormFieldBaseProps {
|
|
@@ -41,6 +42,18 @@ export interface DateInputProps extends FormFieldBaseProps {
|
|
|
41
42
|
* The controlled value for the year segment. Must be used with an `onYearChange` handler.
|
|
42
43
|
*/
|
|
43
44
|
yearValue?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Ref for the day segment input.
|
|
47
|
+
*/
|
|
48
|
+
dayRef?: Ref<TextInput>;
|
|
49
|
+
/**
|
|
50
|
+
* Ref for the month segment input.
|
|
51
|
+
*/
|
|
52
|
+
monthRef?: Ref<TextInput>;
|
|
53
|
+
/**
|
|
54
|
+
* Ref for the year segment input.
|
|
55
|
+
*/
|
|
56
|
+
yearRef?: Ref<TextInput>;
|
|
44
57
|
/**
|
|
45
58
|
* Callback fired when the day value changes.
|
|
46
59
|
*/
|
|
@@ -85,6 +98,7 @@ export interface DateInputSegmentProps {
|
|
|
85
98
|
label: string;
|
|
86
99
|
placeholder?: string;
|
|
87
100
|
value?: string;
|
|
101
|
+
inputRef?: Ref<TextInput>;
|
|
88
102
|
onChange?: (text: string) => void;
|
|
89
103
|
onFocus?: DateInputProps['onDayFocus'];
|
|
90
104
|
onBlur?: DateInputProps['onDayBlur'];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DateInputSegmentProps } from './DateInput.props';
|
|
2
2
|
declare const DateInputSegment: {
|
|
3
|
-
({ label, placeholder, value, onChange, onFocus, onBlur, disabled, validationStatus, maxLength, readonly, testID, inputContainerStyle, inputStyle, inputLabelStyle, }: DateInputSegmentProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
({ label, placeholder, value, inputRef, onChange, onFocus, onBlur, disabled, validationStatus, maxLength, readonly, testID, inputContainerStyle, inputStyle, inputLabelStyle, }: DateInputSegmentProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
displayName: string;
|
|
5
5
|
};
|
|
6
6
|
export default DateInputSegment;
|
|
@@ -3,9 +3,9 @@ import { View } from 'react-native';
|
|
|
3
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
4
4
|
import { BodyText } from '../BodyText';
|
|
5
5
|
import { Input } from '../Input';
|
|
6
|
-
const DateInputSegment = ({ label, placeholder, value, onChange, onFocus, onBlur, disabled, validationStatus, maxLength, readonly, testID, inputContainerStyle, inputStyle, inputLabelStyle, }) => {
|
|
6
|
+
const DateInputSegment = ({ label, placeholder, value, inputRef, onChange, onFocus, onBlur, disabled, validationStatus, maxLength, readonly, testID, inputContainerStyle, inputStyle, inputLabelStyle, }) => {
|
|
7
7
|
styles.useVariants({ disabled });
|
|
8
|
-
return (_jsxs(View, { style: [styles.container, inputContainerStyle], children: [_jsx(BodyText, { size: "md", style: [styles.label, inputLabelStyle], children: label }), _jsx(Input, { value: value, onChangeText: onChange, onFocus: onFocus, onBlur: onBlur, placeholder: disabled ? undefined : placeholder, keyboardType: "number-pad", maxLength: maxLength, testID: testID, accessibilityLabel: label, disabled: disabled, validationStatus: validationStatus, readonly: readonly, style: inputStyle })] }));
|
|
8
|
+
return (_jsxs(View, { style: [styles.container, inputContainerStyle], children: [_jsx(BodyText, { size: "md", style: [styles.label, inputLabelStyle], children: label }), _jsx(Input, { ref: inputRef, value: value, onChangeText: onChange, onFocus: onFocus, onBlur: onBlur, placeholder: disabled ? undefined : placeholder, keyboardType: "number-pad", maxLength: maxLength, testID: testID, accessibilityLabel: label, disabled: disabled, validationStatus: validationStatus, readonly: readonly, style: inputStyle })] }));
|
|
9
9
|
};
|
|
10
10
|
DateInputSegment.displayName = 'DateInputSegment';
|
|
11
11
|
const styles = StyleSheet.create(theme => ({
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
2
|
import { Text } from 'react-native';
|
|
4
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
-
import {
|
|
6
|
-
import { getFlattenedColorValue } from '../../utils';
|
|
4
|
+
import { useStyleProps } from '../../hooks';
|
|
5
|
+
import { getFlattenedColorValue, resolveThemeValueWithFallback } from '../../utils';
|
|
7
6
|
const DetailText = ({ children, color, size = 'md', truncated, underline, strikeThrough, italic, textTransform, textAlign, textAlignVertical, textDecorationColor, textDecorationLine, textDecorationStyle, userSelect, inverted, ...props }) => {
|
|
8
|
-
const {
|
|
7
|
+
const { computedStyles: utilityStyles, remainingProps } = useStyleProps(props);
|
|
9
8
|
styles.useVariants({
|
|
10
9
|
size,
|
|
11
10
|
underline,
|
|
@@ -13,29 +12,23 @@ const DetailText = ({ children, color, size = 'md', truncated, underline, strike
|
|
|
13
12
|
italic,
|
|
14
13
|
inverted,
|
|
15
14
|
});
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
|
-
[color, colorMode]);
|
|
19
|
-
const decorationColor = useMemo(() => getFlattenedColorValue(textDecorationColor, themeColor),
|
|
20
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
|
-
[textDecorationColor, colorMode]);
|
|
22
|
-
return (_jsx(Text, { ...props, ...(truncated
|
|
15
|
+
return (_jsx(Text, { ...remainingProps, ...(truncated
|
|
23
16
|
? {
|
|
24
17
|
numberOfLines: 1,
|
|
25
18
|
ellipsizeMode: 'tail',
|
|
26
19
|
}
|
|
27
20
|
: {}), style: [
|
|
28
21
|
styles.text,
|
|
22
|
+
utilityStyles,
|
|
29
23
|
{
|
|
30
|
-
...(colorValue && { color: colorValue }),
|
|
31
24
|
...(textTransform && { textTransform }),
|
|
32
25
|
...(textAlign && { textAlign }),
|
|
33
|
-
...(decorationColor && { textDecorationColor: decorationColor }),
|
|
34
26
|
...(textDecorationLine && { textDecorationLine }),
|
|
35
27
|
...(textDecorationStyle && { textDecorationStyle }),
|
|
36
28
|
...(userSelect && { userSelect }),
|
|
37
29
|
...(textAlignVertical && { textAlignVertical }),
|
|
38
30
|
},
|
|
31
|
+
styles.getColours(color, textDecorationColor),
|
|
39
32
|
props.style,
|
|
40
33
|
], children: children }));
|
|
41
34
|
};
|
|
@@ -111,5 +104,13 @@ const styles = StyleSheet.create(theme => ({
|
|
|
111
104
|
},
|
|
112
105
|
},
|
|
113
106
|
},
|
|
107
|
+
getColours: (color, textDecorationColor) => ({
|
|
108
|
+
...(color
|
|
109
|
+
? { color: resolveThemeValueWithFallback(color, theme.helpers.semanticColor.text, theme.color) }
|
|
110
|
+
: {}),
|
|
111
|
+
...(textDecorationColor
|
|
112
|
+
? { textDecorationColor: getFlattenedColorValue(textDecorationColor, theme.color) }
|
|
113
|
+
: {}),
|
|
114
|
+
}),
|
|
114
115
|
}));
|
|
115
116
|
export default DetailText;
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { CommonTextProps } from '../../types';
|
|
2
|
+
interface DetailTextProps extends CommonTextProps {
|
|
3
|
+
/** Text size variant. */
|
|
4
4
|
size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
|
|
5
|
-
strikeThrough?: boolean;
|
|
6
|
-
underline?: boolean;
|
|
7
|
-
truncated?: boolean;
|
|
8
|
-
italic?: boolean;
|
|
9
|
-
color?: ColorValue;
|
|
10
|
-
textTransform?: TextStyle['textTransform'];
|
|
11
|
-
textAlign?: TextStyle['textAlign'];
|
|
12
|
-
textAlignVertical?: TextStyle['textAlignVertical'];
|
|
13
|
-
textDecorationLine?: TextStyle['textDecorationLine'];
|
|
14
|
-
textDecorationStyle?: TextStyle['textDecorationStyle'];
|
|
15
|
-
textDecorationColor?: ColorValue;
|
|
16
|
-
userSelect?: TextStyle['userSelect'];
|
|
17
|
-
inverted?: boolean;
|
|
18
5
|
}
|
|
19
|
-
export default
|
|
6
|
+
export default DetailTextProps;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { useStyleProps } from '../../hooks';
|
|
4
5
|
const Flex = ({ style, children, direction = 'column', align = 'flex-start', justify = 'flex-start', wrap = 'nowrap', spacing = 'md', space, ...rest }) => {
|
|
5
6
|
const propStyle = {
|
|
6
7
|
flexDirection: direction,
|
|
@@ -8,8 +9,9 @@ const Flex = ({ style, children, direction = 'column', align = 'flex-start', jus
|
|
|
8
9
|
justifyContent: justify,
|
|
9
10
|
flexWrap: wrap,
|
|
10
11
|
};
|
|
12
|
+
const { computedStyles, remainingProps } = useStyleProps(rest);
|
|
11
13
|
styles.useVariants({ spacing: space ?? spacing });
|
|
12
|
-
return (_jsx(View, { style: [propStyle, styles.flex, style], ...
|
|
14
|
+
return (_jsx(View, { style: [propStyle, styles.flex, computedStyles, style], ...remainingProps, children: children }));
|
|
13
15
|
};
|
|
14
16
|
Flex.displayName = 'Flex';
|
|
15
17
|
const styles = StyleSheet.create(theme => ({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FlexAlignType, ViewProps, ViewStyle } from 'react-native';
|
|
2
|
-
import { SpacingValues } from '../../types';
|
|
3
|
-
interface FlexProps extends ViewProps {
|
|
2
|
+
import { FlexLayoutProps, GapProps, SpacingValues } from '../../types';
|
|
3
|
+
interface FlexProps extends ViewProps, FlexLayoutProps, GapProps {
|
|
4
4
|
direction?: ViewStyle['flexDirection'];
|
|
5
5
|
align?: FlexAlignType;
|
|
6
6
|
justify?: ViewStyle['justifyContent'];
|
|
@@ -1,40 +1,34 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
2
|
import { Text } from 'react-native';
|
|
4
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
-
import {
|
|
6
|
-
import { getFlattenedColorValue } from '../../utils';
|
|
4
|
+
import { useStyleProps } from '../../hooks';
|
|
5
|
+
import { getFlattenedColorValue, resolveThemeValueWithFallback } from '../../utils';
|
|
7
6
|
const Heading = ({ children, color, size = 'lg', truncated, underline, strikeThrough, textTransform, textAlign, textAlignVertical, textDecorationColor, textDecorationLine, textDecorationStyle, userSelect, inverted, ...props }) => {
|
|
7
|
+
// Extract margin utility props from remaining props
|
|
8
|
+
const { computedStyles: utilityStyles, remainingProps } = useStyleProps(props);
|
|
8
9
|
styles.useVariants({
|
|
9
10
|
size,
|
|
10
11
|
underline,
|
|
11
12
|
strikeThrough,
|
|
12
13
|
inverted,
|
|
13
14
|
});
|
|
14
|
-
|
|
15
|
-
const colorValue = useMemo(() => getFlattenedColorValue(color, themeColor),
|
|
16
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
|
-
[color, colorMode]);
|
|
18
|
-
const decorationColor = useMemo(() => getFlattenedColorValue(textDecorationColor, themeColor),
|
|
19
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20
|
-
[textDecorationColor, colorMode]);
|
|
21
|
-
return (_jsx(Text, { ...props, ...(truncated
|
|
15
|
+
return (_jsx(Text, { ...remainingProps, ...(truncated
|
|
22
16
|
? {
|
|
23
17
|
numberOfLines: 1,
|
|
24
18
|
ellipsizeMode: 'tail',
|
|
25
19
|
}
|
|
26
20
|
: {}), style: [
|
|
27
21
|
styles.text,
|
|
22
|
+
utilityStyles,
|
|
28
23
|
{
|
|
29
|
-
...(colorValue ? { color: colorValue } : {}),
|
|
30
24
|
...(textTransform ? { textTransform } : {}),
|
|
31
25
|
...(textAlign ? { textAlign } : {}),
|
|
32
26
|
...(textAlignVertical ? { textAlignVertical } : {}),
|
|
33
|
-
...(decorationColor && { textDecorationColor: decorationColor }),
|
|
34
27
|
...(textDecorationLine && { textDecorationLine }),
|
|
35
28
|
...(textDecorationStyle && { textDecorationStyle }),
|
|
36
29
|
...(userSelect && { userSelect }),
|
|
37
30
|
},
|
|
31
|
+
styles.getColours(color, textDecorationColor),
|
|
38
32
|
props.style,
|
|
39
33
|
], children: children }));
|
|
40
34
|
};
|
|
@@ -115,6 +109,23 @@ const styles = StyleSheet.create(theme => ({
|
|
|
115
109
|
lg: theme.typography.desktop.heading.xl.lineHeight,
|
|
116
110
|
},
|
|
117
111
|
},
|
|
112
|
+
'2xl': {
|
|
113
|
+
fontSize: {
|
|
114
|
+
base: theme.typography.mobile.heading['2xl'].fontSize,
|
|
115
|
+
md: theme.typography.tablet.heading['2xl'].fontSize,
|
|
116
|
+
lg: theme.typography.desktop.heading['2xl'].fontSize,
|
|
117
|
+
},
|
|
118
|
+
fontWeight: {
|
|
119
|
+
base: theme.typography.mobile.heading['2xl'].fontWeight,
|
|
120
|
+
md: theme.typography.tablet.heading['2xl'].fontWeight,
|
|
121
|
+
lg: theme.typography.desktop.heading['2xl'].fontWeight,
|
|
122
|
+
},
|
|
123
|
+
lineHeight: {
|
|
124
|
+
base: theme.typography.mobile.heading['2xl'].lineHeight,
|
|
125
|
+
md: theme.typography.tablet.heading['2xl'].lineHeight,
|
|
126
|
+
lg: theme.typography.desktop.heading['2xl'].lineHeight,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
118
129
|
},
|
|
119
130
|
underline: {
|
|
120
131
|
true: {
|
|
@@ -133,5 +144,15 @@ const styles = StyleSheet.create(theme => ({
|
|
|
133
144
|
},
|
|
134
145
|
},
|
|
135
146
|
},
|
|
147
|
+
getColours: (color, textDecorationColor) => ({
|
|
148
|
+
...(color
|
|
149
|
+
? {
|
|
150
|
+
color: resolveThemeValueWithFallback(color, theme.helpers.semanticColor.text, theme.color),
|
|
151
|
+
}
|
|
152
|
+
: {}),
|
|
153
|
+
...(textDecorationColor
|
|
154
|
+
? { textDecorationColor: getFlattenedColorValue(textDecorationColor, theme.color) }
|
|
155
|
+
: {}),
|
|
156
|
+
}),
|
|
136
157
|
}));
|
|
137
158
|
export default Heading;
|
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
6
|
-
strikeThrough?: boolean;
|
|
7
|
-
underline?: boolean;
|
|
8
|
-
truncated?: boolean;
|
|
9
|
-
color?: ColorValue;
|
|
10
|
-
textTransform?: TextStyle['textTransform'];
|
|
11
|
-
textAlign?: TextStyle['textAlign'];
|
|
12
|
-
textAlignVertical?: TextStyle['textAlignVertical'];
|
|
13
|
-
textDecorationLine?: TextStyle['textDecorationLine'];
|
|
14
|
-
textDecorationStyle?: TextStyle['textDecorationStyle'];
|
|
15
|
-
textDecorationColor?: ColorValue;
|
|
16
|
-
userSelect?: TextStyle['userSelect'];
|
|
17
|
-
inverted?: boolean;
|
|
18
|
-
ref?: Ref<Text>;
|
|
1
|
+
import type { CommonTextProps } from '../../types';
|
|
2
|
+
interface HeadingProps extends CommonTextProps {
|
|
3
|
+
/** Heading size variant. */
|
|
4
|
+
size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
19
5
|
}
|
|
20
6
|
export default HeadingProps;
|