@utilitywarehouse/hearth-react-native 0.13.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +22 -0
- package/build/components/BodyText/index.d.ts +1 -0
- package/build/components/Card/CardAction/CardActionRoot.js +3 -3
- package/build/components/Checkbox/CheckboxGroup.context.d.ts +2 -0
- package/build/components/Checkbox/CheckboxGroup.js +5 -5
- package/build/components/Checkbox/CheckboxTextContent.js +0 -1
- package/build/components/Checkbox/CheckboxTileRoot.js +9 -1
- package/build/components/FormField/FormField.d.ts +5 -5
- package/build/components/List/List.context.d.ts +2 -0
- package/build/components/List/List.context.js +2 -0
- package/build/components/List/List.js +19 -15
- package/build/components/List/ListAction/ListAction.js +3 -2
- package/build/components/List/ListAction/ListAction.props.d.ts +0 -1
- package/build/components/List/ListItem/ListItem.props.d.ts +4 -1
- package/build/components/List/ListItem/ListItemHeading.d.ts +13 -0
- package/build/components/List/ListItem/ListItemHeading.js +12 -0
- package/build/components/List/ListItem/ListItemHelperText.d.ts +2 -2
- package/build/components/List/ListItem/ListItemRoot.d.ts +1 -1
- package/build/components/List/ListItem/ListItemRoot.js +7 -6
- package/build/components/List/ListItem/index.d.ts +1 -1
- package/build/components/List/ListItem/index.js +1 -1
- package/build/components/Radio/RadioGroup.context.d.ts +2 -0
- package/build/components/Radio/RadioGroup.js +1 -1
- package/build/components/Radio/RadioTextContent.js +0 -1
- package/build/components/Radio/RadioTileRoot.js +9 -1
- package/docs/introduction.mdx +10 -0
- package/package.json +3 -3
- package/src/components/BodyText/index.ts +1 -0
- package/src/components/Card/CardAction/CardActionRoot.tsx +3 -3
- package/src/components/Checkbox/CheckboxGroup.context.ts +1 -0
- package/src/components/Checkbox/CheckboxGroup.tsx +7 -8
- package/src/components/Checkbox/CheckboxTextContent.tsx +0 -1
- package/src/components/Checkbox/CheckboxTileRoot.tsx +9 -1
- package/src/components/List/List.context.ts +4 -0
- package/src/components/List/List.docs.mdx +30 -24
- package/src/components/List/List.stories.tsx +26 -1
- package/src/components/List/List.tsx +26 -19
- package/src/components/List/ListAction/ListAction.props.ts +0 -1
- package/src/components/List/ListAction/ListAction.tsx +3 -2
- package/src/components/List/ListItem/ListItem.props.ts +4 -1
- package/src/components/List/ListItem/ListItemHeading.tsx +20 -0
- package/src/components/List/ListItem/ListItemHelperText.tsx +2 -3
- package/src/components/List/ListItem/ListItemRoot.tsx +11 -6
- package/src/components/List/ListItem/index.ts +1 -1
- package/src/components/Modal/Modal.docs.mdx +23 -20
- package/src/components/Radio/Radio.stories.tsx +24 -0
- package/src/components/Radio/RadioGroup.context.ts +1 -0
- package/src/components/Radio/RadioGroup.tsx +2 -2
- package/src/components/Radio/RadioTextContent.tsx +0 -1
- package/src/components/Radio/RadioTileRoot.tsx +9 -1
- package/build/components/List/ListItem/ListItemText.d.ts +0 -6
- package/build/components/List/ListItem/ListItemText.js +0 -7
- package/src/components/List/ListItem/ListItemText.tsx +0 -14
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.14.1 lint /home/runner/work/hearth/hearth/packages/react-native
|
|
3
3
|
> TIMING=1 eslint --max-warnings 0
|
|
4
4
|
|
|
5
5
|
Rule | Time (ms) | Relative
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @utilitywarehouse/hearth-react-native
|
|
2
2
|
|
|
3
|
+
## 0.14.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#749](https://github.com/utilitywarehouse/hearth/pull/749) [`ded4b2e`](https://github.com/utilitywarehouse/hearth/commit/ded4b2e3dcad9c1cc4860a13120e44a43e5f0dde) Thanks [@jordmccord](https://github.com/jordmccord)! - Fixes `CardAction` padding
|
|
8
|
+
|
|
9
|
+
## 0.14.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#741](https://github.com/utilitywarehouse/hearth/pull/741) [`acf081a`](https://github.com/utilitywarehouse/hearth/commit/acf081a8e10722ea1e9106f8111f5d9548815646) Thanks [@jordmccord](https://github.com/jordmccord)! - Renames `ListItemText` to `ListItemHeading` (`ListItemText` is deprecated and will be removed in a later release)
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#741](https://github.com/utilitywarehouse/hearth/pull/741) [`acf081a`](https://github.com/utilitywarehouse/hearth/commit/acf081a8e10722ea1e9106f8111f5d9548815646) Thanks [@jordmccord](https://github.com/jordmccord)! - Adds `truncateHeading` and `truncateHelperText` props to `ListItem`
|
|
18
|
+
|
|
19
|
+
- [#740](https://github.com/utilitywarehouse/hearth/pull/740) [`16f1ce0`](https://github.com/utilitywarehouse/hearth/commit/16f1ce073d62c4e72693e7e07233a7498c0d0602) Thanks [@jordmccord](https://github.com/jordmccord)! - Fixes custom `ListItem` first child border issue
|
|
20
|
+
|
|
21
|
+
- [#737](https://github.com/utilitywarehouse/hearth/pull/737) [`85f76db`](https://github.com/utilitywarehouse/hearth/commit/85f76dbbf7c90db96d7e89e5f5e353a772dd84c2) Thanks [@jordmccord](https://github.com/jordmccord)! - Fixes `Radio` and `Checkbox` Groups row direction issue
|
|
22
|
+
|
|
23
|
+
- [#741](https://github.com/utilitywarehouse/hearth/pull/741) [`acf081a`](https://github.com/utilitywarehouse/hearth/commit/acf081a8e10722ea1e9106f8111f5d9548815646) Thanks [@jordmccord](https://github.com/jordmccord)! - Fixes `ListItemText` and `ListItemHelperText` prop types
|
|
24
|
+
|
|
3
25
|
## 0.13.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -120,9 +120,9 @@ const styles = StyleSheet.create(theme => ({
|
|
|
120
120
|
withIconContainer: {
|
|
121
121
|
alignItems: 'center',
|
|
122
122
|
flexDirection: 'row',
|
|
123
|
-
paddingVertical: theme.components.
|
|
124
|
-
paddingHorizontal: theme.components.
|
|
125
|
-
gap: theme.components.
|
|
123
|
+
paddingVertical: theme.components.cardAction.content.paddingVertical,
|
|
124
|
+
paddingHorizontal: theme.components.cardAction.content.paddingHorizontal,
|
|
125
|
+
gap: theme.components.cardAction.content.gap,
|
|
126
126
|
flex: 1,
|
|
127
127
|
variants: {
|
|
128
128
|
hasIconContainer: {
|
|
@@ -2,9 +2,11 @@ export declare const CheckboxGroupContext: import("react").Context<{
|
|
|
2
2
|
disabled?: boolean;
|
|
3
3
|
validationStatus?: "valid" | "invalid" | "initial";
|
|
4
4
|
type?: "default" | "tile";
|
|
5
|
+
direction?: "column" | "row";
|
|
5
6
|
}>;
|
|
6
7
|
export declare const useCheckboxGroupContext: () => {
|
|
7
8
|
disabled?: boolean;
|
|
8
9
|
validationStatus?: "valid" | "invalid" | "initial";
|
|
9
10
|
type?: "default" | "tile";
|
|
11
|
+
direction?: "column" | "row";
|
|
10
12
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
|
-
import { CheckboxGroup as CheckboxGroupComponent } from './Checkbox';
|
|
4
|
-
import { CheckboxGroupContext } from './CheckboxGroup.context';
|
|
5
3
|
import { View } from 'react-native';
|
|
6
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
7
|
-
import CheckboxGroupTextContent from './CheckboxGroupTextContent';
|
|
8
|
-
import { Label } from '../Label';
|
|
9
5
|
import { Helper } from '../Helper';
|
|
6
|
+
import { Label } from '../Label';
|
|
7
|
+
import { CheckboxGroup as CheckboxGroupComponent } from './Checkbox';
|
|
8
|
+
import { CheckboxGroupContext } from './CheckboxGroup.context';
|
|
9
|
+
import CheckboxGroupTextContent from './CheckboxGroupTextContent';
|
|
10
10
|
const CheckboxGroup = ({ children, disabled, readonly, validationStatus, label, helperText, invalidText, validText, showValidationIcon = true, helperIcon, type, direction = 'column', gap, ...props }) => {
|
|
11
|
-
const value = useMemo(() => ({ disabled, validationStatus, type }), [disabled, validationStatus, type]);
|
|
11
|
+
const value = useMemo(() => ({ disabled, validationStatus, type, direction }), [disabled, validationStatus, type, direction]);
|
|
12
12
|
const showHeader = !!label || !!helperText || !!invalidText || !!validText;
|
|
13
13
|
const childrenArray = React.Children.toArray(children);
|
|
14
14
|
const childIsCard = type === 'tile' ||
|
|
@@ -2,10 +2,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
4
4
|
import { useCheckboxContext } from './Checkbox.context';
|
|
5
|
+
import { useCheckboxGroupContext } from './CheckboxGroup.context';
|
|
5
6
|
const CheckboxTileRoot = ({ children }) => {
|
|
7
|
+
const { direction } = useCheckboxGroupContext();
|
|
6
8
|
const { checked } = useCheckboxContext();
|
|
7
9
|
styles.useVariants({
|
|
8
10
|
checked,
|
|
11
|
+
direction,
|
|
9
12
|
});
|
|
10
13
|
return _jsx(View, { style: styles.container, children: children });
|
|
11
14
|
};
|
|
@@ -13,7 +16,6 @@ const styles = StyleSheet.create(theme => ({
|
|
|
13
16
|
container: {
|
|
14
17
|
flexDirection: 'row',
|
|
15
18
|
justifyContent: 'flex-start',
|
|
16
|
-
flex: 1,
|
|
17
19
|
alignSelf: 'stretch',
|
|
18
20
|
gap: theme.components.checkbox.gap,
|
|
19
21
|
padding: theme.components.checkbox.tile.padding,
|
|
@@ -29,6 +31,12 @@ const styles = StyleSheet.create(theme => ({
|
|
|
29
31
|
margin: -theme.components.checkbox.tile.borderWidthSelected / 2,
|
|
30
32
|
},
|
|
31
33
|
},
|
|
34
|
+
direction: {
|
|
35
|
+
row: {},
|
|
36
|
+
column: {
|
|
37
|
+
flex: 1,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
32
40
|
},
|
|
33
41
|
},
|
|
34
42
|
}));
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
2
|
import FormFieldProps from './FormField.props';
|
|
3
|
-
export declare const FormFieldComponent: import("@gluestack-ui/form-control/lib/types").IFormControlComponentType<import("react-native").ViewProps, Omit<import("../Helper/Helper.props").default, "validationStatus">, Omit<import("../Helper/Helper.props").default, "validationStatus">, Omit<import("..").IconProps, "as">, unknown, Omit<import("../Label/Label.props").default, "disabled">, unknown, Omit<import("../Helper/Helper.props").default, "validationStatus">, import("
|
|
3
|
+
export declare const FormFieldComponent: import("@gluestack-ui/form-control/lib/types").IFormControlComponentType<import("react-native").ViewProps, Omit<import("../Helper/Helper.props").default, "validationStatus">, Omit<import("../Helper/Helper.props").default, "validationStatus">, Omit<import("..").IconProps, "as">, unknown, Omit<import("../Label/Label.props").default, "disabled">, unknown, Omit<import("../Helper/Helper.props").default, "validationStatus">, import("..").BodyTextProps>;
|
|
4
4
|
export declare const FormFieldLabel: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>> & {
|
|
5
5
|
Text: import("react").ForwardRefExoticComponent<Omit<Omit<import("../Label/Label.props").default, "disabled">, "ref"> & import("react").RefAttributes<Omit<import("../Label/Label.props").default, "disabled">>>;
|
|
6
6
|
};
|
|
7
7
|
export declare const FormFieldLabelText: import("react").ForwardRefExoticComponent<Omit<Omit<import("../Label/Label.props").default, "disabled">, "ref"> & import("react").RefAttributes<Omit<import("../Label/Label.props").default, "disabled">>>;
|
|
8
8
|
export declare const FormFieldHelper: import("react").ForwardRefExoticComponent<Omit<import("../Helper/Helper.props").default, "validationStatus"> & import("react").RefAttributes<Omit<import("../Helper/Helper.props").default, "validationStatus">>> & {
|
|
9
|
-
Text: import("react").ForwardRefExoticComponent<Omit<import("
|
|
9
|
+
Text: import("react").ForwardRefExoticComponent<Omit<import("..").BodyTextProps, "ref"> & import("react").RefAttributes<import("..").BodyTextProps>>;
|
|
10
10
|
};
|
|
11
|
-
export declare const FormFieldHelperText: import("react").ForwardRefExoticComponent<Omit<import("
|
|
11
|
+
export declare const FormFieldHelperText: import("react").ForwardRefExoticComponent<Omit<import("..").BodyTextProps, "ref"> & import("react").RefAttributes<import("..").BodyTextProps>>;
|
|
12
12
|
export declare const FormFieldHelperIcon: {
|
|
13
13
|
(props: import("..").IconProps): import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
displayName: string;
|
|
15
15
|
};
|
|
16
16
|
export declare const FormFieldValidText: {
|
|
17
|
-
(props: import("
|
|
17
|
+
(props: import("..").BodyTextProps): import("react/jsx-runtime").JSX.Element;
|
|
18
18
|
displayName: string;
|
|
19
19
|
};
|
|
20
20
|
export declare const FormFieldInvalidText: {
|
|
21
|
-
(props: import("
|
|
21
|
+
(props: import("..").BodyTextProps): import("react/jsx-runtime").JSX.Element;
|
|
22
22
|
displayName: string;
|
|
23
23
|
};
|
|
24
24
|
export declare const FormFieldTextContent: typeof View;
|
|
@@ -4,7 +4,8 @@ import { View } from 'react-native';
|
|
|
4
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
5
5
|
import { Card } from '../Card';
|
|
6
6
|
import { SectionHeader } from '../SectionHeader';
|
|
7
|
-
import { ListContext } from './List.context';
|
|
7
|
+
import { ListContext, ListFirstItemContext } from './List.context';
|
|
8
|
+
import { ListAction } from './ListAction';
|
|
8
9
|
import { ListItem } from './ListItem';
|
|
9
10
|
const markFirstListItem = (children) => {
|
|
10
11
|
let found = false;
|
|
@@ -12,21 +13,24 @@ const markFirstListItem = (children) => {
|
|
|
12
13
|
return React.Children.map(children, (child) => {
|
|
13
14
|
if (!React.isValidElement(child))
|
|
14
15
|
return child;
|
|
15
|
-
// Check if the current element is the ListItem and hasn't been marked yet
|
|
16
|
-
if (!found
|
|
16
|
+
// Check if the current element is the ListItem or ListAction and hasn't been marked yet
|
|
17
|
+
if (!found) {
|
|
18
|
+
if (child.type === ListItem || child.type === ListAction) {
|
|
19
|
+
found = true;
|
|
20
|
+
return (_jsx(ListFirstItemContext.Provider, { value: true, children: child }));
|
|
21
|
+
}
|
|
22
|
+
// If the child has nested children, process them recursively
|
|
23
|
+
if (React.isValidElement(child) &&
|
|
24
|
+
child.props &&
|
|
25
|
+
typeof child.props === 'object' &&
|
|
26
|
+
child.props !== null &&
|
|
27
|
+
'children' in child.props &&
|
|
28
|
+
child.props.children) {
|
|
29
|
+
const clonedChildren = recursiveClone(child.props.children);
|
|
30
|
+
return React.cloneElement(child, { children: clonedChildren });
|
|
31
|
+
}
|
|
17
32
|
found = true;
|
|
18
|
-
|
|
19
|
-
return React.cloneElement(child, { isFirst: true });
|
|
20
|
-
}
|
|
21
|
-
// If the child has nested children, process them recursively
|
|
22
|
-
if (React.isValidElement(child) &&
|
|
23
|
-
child.props &&
|
|
24
|
-
typeof child.props === 'object' &&
|
|
25
|
-
child.props !== null &&
|
|
26
|
-
'children' in child.props &&
|
|
27
|
-
child.props.children) {
|
|
28
|
-
const clonedChildren = recursiveClone(child.props.children);
|
|
29
|
-
return React.cloneElement(child, { children: clonedChildren });
|
|
33
|
+
return _jsx(ListFirstItemContext.Provider, { value: true, children: child });
|
|
30
34
|
}
|
|
31
35
|
return child;
|
|
32
36
|
});
|
|
@@ -3,7 +3,7 @@ import { createPressable } from '@gluestack-ui/pressable';
|
|
|
3
3
|
import { ChevronRightSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
4
4
|
import { Pressable } from 'react-native';
|
|
5
5
|
import { StyleSheet } from 'react-native-unistyles';
|
|
6
|
-
import { useListContext } from '../List.context';
|
|
6
|
+
import { useListContext, useListFirstItemContext } from '../List.context';
|
|
7
7
|
import ListActionContent from './ListActionContent';
|
|
8
8
|
import ListActionText from './ListActionText';
|
|
9
9
|
import ListActionTrailingContent from './ListActionTrailingContent';
|
|
@@ -11,6 +11,7 @@ import ListActionTrailingIcon from './ListActionTrailingIcon';
|
|
|
11
11
|
const ListActionRoot = ({ heading, disabled, variant = 'subtle', ...props }) => {
|
|
12
12
|
const { onPress } = props;
|
|
13
13
|
const listContext = useListContext();
|
|
14
|
+
const isFirstContext = useListFirstItemContext();
|
|
14
15
|
const { active } = props.states || { active: false };
|
|
15
16
|
const getListContainer = () => {
|
|
16
17
|
if (listContext?.container?.includes('subtle')) {
|
|
@@ -29,7 +30,7 @@ const ListActionRoot = ({ heading, disabled, variant = 'subtle', ...props }) =>
|
|
|
29
30
|
disabled: isDisabled,
|
|
30
31
|
active,
|
|
31
32
|
showDisabled: !listContext?.disabled && disabled,
|
|
32
|
-
isFirstChild:
|
|
33
|
+
isFirstChild: isFirstContext,
|
|
33
34
|
container: listContext?.container,
|
|
34
35
|
});
|
|
35
36
|
return (_jsxs(Pressable, { ...props, testID: testID, style: [styles.container, props.style], disabled: isDisabled || !onPress, children: [_jsx(ListActionContent, { children: _jsx(ListActionText, { children: heading }) }), _jsx(ListActionTrailingContent, { style: styles.centeredTrailingIcon, children: _jsx(ListActionTrailingIcon, { as: ChevronRightSmallIcon }) })] }));
|
|
@@ -4,7 +4,6 @@ interface ListItemBaseProps extends Omit<PressableProps, 'children'> {
|
|
|
4
4
|
loading?: boolean;
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
variant?: 'subtle' | 'emphasis';
|
|
7
|
-
isFirst?: boolean;
|
|
8
7
|
}
|
|
9
8
|
export interface ListItemWithChildren extends ListItemBaseProps {
|
|
10
9
|
children: ViewProps['children'];
|
|
@@ -15,6 +14,8 @@ export interface ListItemWithChildren extends ListItemBaseProps {
|
|
|
15
14
|
numericValue?: never;
|
|
16
15
|
badge?: never;
|
|
17
16
|
badgePosition?: never;
|
|
17
|
+
truncateHeading?: never;
|
|
18
|
+
truncateHelperText?: never;
|
|
18
19
|
}
|
|
19
20
|
export interface ListItemWithoutChildren extends ListItemBaseProps {
|
|
20
21
|
children?: never;
|
|
@@ -25,6 +26,8 @@ export interface ListItemWithoutChildren extends ListItemBaseProps {
|
|
|
25
26
|
numericValue?: string | number;
|
|
26
27
|
badge?: ReactNode;
|
|
27
28
|
badgePosition?: 'top' | 'bottom';
|
|
29
|
+
truncateHeading?: boolean;
|
|
30
|
+
truncateHelperText?: boolean;
|
|
28
31
|
}
|
|
29
32
|
type ListItemProps = ListItemWithChildren | ListItemWithoutChildren;
|
|
30
33
|
export default ListItemProps;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BodyTextProps } from '../../BodyText';
|
|
2
|
+
declare const ListItemHeading: {
|
|
3
|
+
({ children, ...props }: BodyTextProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `ListItemHeading` instead.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ListItemText: {
|
|
10
|
+
({ children, ...props }: BodyTextProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
13
|
+
export default ListItemHeading;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BodyText } from '../../BodyText';
|
|
3
|
+
const ListItemHeading = ({ children, ...props }) => {
|
|
4
|
+
return (_jsx(BodyText, { size: "lg", ...props, children: children }));
|
|
5
|
+
};
|
|
6
|
+
ListItemHeading.displayName = 'ListItemHeading';
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use `ListItemHeading` instead.
|
|
9
|
+
*/
|
|
10
|
+
export const ListItemText = ListItemHeading;
|
|
11
|
+
ListItemText.displayName = 'ListItemText';
|
|
12
|
+
export default ListItemHeading;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BodyTextProps } from '../../BodyText';
|
|
2
2
|
declare const ListItemHelperText: {
|
|
3
|
-
({ children, ...props }:
|
|
3
|
+
({ children, ...props }: BodyTextProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
displayName: string;
|
|
5
5
|
};
|
|
6
6
|
export default ListItemHelperText;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type ListItemProps from './ListItem.props';
|
|
2
2
|
declare const ListItemRoot: {
|
|
3
|
-
({ heading, helperText, leadingContent, trailingContent, disabled, loading, children, states, variant, badge, badgePosition, numericValue, ...props }: ListItemProps & {
|
|
3
|
+
({ heading, helperText, leadingContent, trailingContent, disabled, loading, children, states, variant, badge, badgePosition, numericValue, truncateHeading, truncateHelperText, ...props }: ListItemProps & {
|
|
4
4
|
states?: {
|
|
5
5
|
active?: boolean;
|
|
6
6
|
disabled?: boolean;
|
|
@@ -5,17 +5,18 @@ import { Pressable } from 'react-native';
|
|
|
5
5
|
import { StyleSheet } from 'react-native-unistyles';
|
|
6
6
|
import { DetailText } from '../../DetailText';
|
|
7
7
|
import { Skeleton } from '../../Skeleton';
|
|
8
|
-
import { useListContext } from '../List.context';
|
|
8
|
+
import { useListContext, useListFirstItemContext } from '../List.context';
|
|
9
9
|
import { ListItemContext } from './ListItem.context';
|
|
10
10
|
import ListItemContent from './ListItemContent';
|
|
11
|
+
import ListItemHeading from './ListItemHeading';
|
|
11
12
|
import ListItemHelperText from './ListItemHelperText';
|
|
12
13
|
import ListItemLeadingContent from './ListItemLeadingContent';
|
|
13
|
-
import ListItemText from './ListItemText';
|
|
14
14
|
import ListItemTrailingContent from './ListItemTrailingContent';
|
|
15
15
|
import ListItemTrailingIcon from './ListItemTrailingIcon';
|
|
16
|
-
const ListItemRoot = ({ heading, helperText, leadingContent, trailingContent, disabled, loading, children, states, variant = 'subtle', badge, badgePosition = 'bottom', numericValue, ...props }) => {
|
|
16
|
+
const ListItemRoot = ({ heading, helperText, leadingContent, trailingContent, disabled, loading, children, states, variant = 'subtle', badge, badgePosition = 'bottom', numericValue, truncateHeading = false, truncateHelperText = false, ...props }) => {
|
|
17
17
|
const { onPress } = props;
|
|
18
18
|
const listContext = useListContext();
|
|
19
|
+
const isFirstContext = useListFirstItemContext();
|
|
19
20
|
const { active } = states || { active: false };
|
|
20
21
|
const getListContainer = () => {
|
|
21
22
|
if (listContext?.container?.includes('subtle')) {
|
|
@@ -37,8 +38,8 @@ const ListItemRoot = ({ heading, helperText, leadingContent, trailingContent, di
|
|
|
37
38
|
showPressed,
|
|
38
39
|
active,
|
|
39
40
|
disabled: isDisabled || isLoading,
|
|
40
|
-
showDisabled: !listContext
|
|
41
|
-
isFirstChild:
|
|
41
|
+
showDisabled: !listContext.disabled && disabled,
|
|
42
|
+
isFirstChild: isFirstContext,
|
|
42
43
|
container: listContext?.container,
|
|
43
44
|
});
|
|
44
45
|
const value = useMemo(() => {
|
|
@@ -52,7 +53,7 @@ const ListItemRoot = ({ heading, helperText, leadingContent, trailingContent, di
|
|
|
52
53
|
if (loading || listContext?.loading) {
|
|
53
54
|
return (_jsxs(Pressable, { ...props, testID: loadingTestID, style: [styles.container, props.style], disabled: isDisabled, children: [leadingContent ? _jsx(Skeleton, { width: 24, height: 24 }) : null, _jsxs(ListItemContent, { children: [_jsx(Skeleton, { width: "80%", height: 20 }), _jsx(Skeleton, { width: "100%", height: 16 })] }), onPress || trailingContent ? _jsx(Skeleton, { width: 24, height: 24 }) : null] }));
|
|
54
55
|
}
|
|
55
|
-
return (_jsx(ListItemContext.Provider, { value: value, children: _jsx(Pressable, { ...props, testID: testID, style: [styles.container, props.style], disabled: isDisabled, accessibilityRole: onPress ? 'button' : undefined, children: children ? (children) : (_jsxs(_Fragment, { children: [leadingContent ? (_jsx(ListItemLeadingContent, { children: leadingContent })) : null, _jsxs(ListItemContent, { children: [badgePosition === 'top' && badge ? badge : null, _jsx(
|
|
56
|
+
return (_jsx(ListItemContext.Provider, { value: value, children: _jsx(Pressable, { ...props, testID: testID, style: [styles.container, props.style], disabled: isDisabled, accessibilityRole: onPress ? 'button' : undefined, children: children ? (children) : (_jsxs(_Fragment, { children: [leadingContent ? (_jsx(ListItemLeadingContent, { children: leadingContent })) : null, _jsxs(ListItemContent, { children: [badgePosition === 'top' && badge ? badge : null, _jsx(ListItemHeading, { truncated: truncateHeading, children: heading }), helperText ? (_jsx(ListItemHelperText, { truncated: truncateHelperText, children: helperText })) : null, badgePosition === 'bottom' && badge ? badge : null] }), !!numericValue && _jsx(DetailText, { size: "lg", children: numericValue }), trailingContent ? (_jsx(ListItemTrailingContent, { children: trailingContent })) : onPress ? (_jsx(ListItemTrailingContent, { style: styles.centeredTrailingIcon, children: _jsx(ListItemTrailingIcon, { as: ChevronRightSmallIcon }) })) : null] })) }) }));
|
|
56
57
|
};
|
|
57
58
|
ListItemRoot.displayName = 'ListItemRoot';
|
|
58
59
|
const styles = StyleSheet.create(theme => ({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { default as ListItem } from './ListItem';
|
|
2
2
|
export type { default as ListItemProps } from './ListItem.props';
|
|
3
3
|
export { default as ListItemContent } from './ListItemContent';
|
|
4
|
+
export { default as ListItemHeading, ListItemText } from './ListItemHeading';
|
|
4
5
|
export { default as ListItemHelperText } from './ListItemHelperText';
|
|
5
6
|
export { default as ListItemIcon } from './ListItemIcon';
|
|
6
7
|
export { default as ListItemLeadingContent } from './ListItemLeadingContent';
|
|
7
|
-
export { default as ListItemText } from './ListItemText';
|
|
8
8
|
export { default as ListItemTrailingContent } from './ListItemTrailingContent';
|
|
9
9
|
export { default as ListItemTrailingIcon } from './ListItemTrailingIcon';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { default as ListItem } from './ListItem';
|
|
2
2
|
export { default as ListItemContent } from './ListItemContent';
|
|
3
|
+
export { default as ListItemHeading, ListItemText } from './ListItemHeading';
|
|
3
4
|
export { default as ListItemHelperText } from './ListItemHelperText';
|
|
4
5
|
export { default as ListItemIcon } from './ListItemIcon';
|
|
5
6
|
export { default as ListItemLeadingContent } from './ListItemLeadingContent';
|
|
6
|
-
export { default as ListItemText } from './ListItemText';
|
|
7
7
|
export { default as ListItemTrailingContent } from './ListItemTrailingContent';
|
|
8
8
|
export { default as ListItemTrailingIcon } from './ListItemTrailingIcon';
|
|
@@ -2,9 +2,11 @@ export declare const RadioGroupContext: import("react").Context<{
|
|
|
2
2
|
disabled?: boolean;
|
|
3
3
|
validationStatus?: "valid" | "invalid" | "initial";
|
|
4
4
|
type?: "default" | "tile";
|
|
5
|
+
direction?: "column" | "row";
|
|
5
6
|
}>;
|
|
6
7
|
export declare const useRadioGroupContext: () => {
|
|
7
8
|
disabled?: boolean;
|
|
8
9
|
validationStatus?: "valid" | "invalid" | "initial";
|
|
9
10
|
type?: "default" | "tile";
|
|
11
|
+
direction?: "column" | "row";
|
|
10
12
|
};
|
|
@@ -8,7 +8,7 @@ import { RadioGroup as RadioGroupComponent } from './Radio';
|
|
|
8
8
|
import { RadioGroupContext } from './RadioGroup.context';
|
|
9
9
|
import RadioGroupTextContent from './RadioGroupTextContent';
|
|
10
10
|
const RadioGroup = ({ children, disabled, readonly, validationStatus, label, helperText, invalidText, validText, showValidationIcon = true, helperIcon, type, direction = 'column', gap, ...props }) => {
|
|
11
|
-
const value = useMemo(() => ({ disabled, validationStatus, type }), [disabled, validationStatus, type]);
|
|
11
|
+
const value = useMemo(() => ({ disabled, validationStatus, type, direction }), [disabled, validationStatus, type, direction]);
|
|
12
12
|
const showHeader = !!label || !!helperText || !!invalidText || !!validText;
|
|
13
13
|
const childrenArray = React.Children.toArray(children);
|
|
14
14
|
const childIsCard = type === 'tile' ||
|
|
@@ -2,10 +2,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
4
4
|
import { useRadioContext } from './Radio.context';
|
|
5
|
+
import { useRadioGroupContext } from './RadioGroup.context';
|
|
5
6
|
const RadioTileRoot = ({ children }) => {
|
|
7
|
+
const { direction } = useRadioGroupContext();
|
|
6
8
|
const { checked } = useRadioContext();
|
|
7
9
|
styles.useVariants({
|
|
8
10
|
checked,
|
|
11
|
+
direction,
|
|
9
12
|
});
|
|
10
13
|
return _jsx(View, { style: styles.container, children: children });
|
|
11
14
|
};
|
|
@@ -13,7 +16,6 @@ const styles = StyleSheet.create(theme => ({
|
|
|
13
16
|
container: {
|
|
14
17
|
flexDirection: 'row',
|
|
15
18
|
justifyContent: 'flex-start',
|
|
16
|
-
flex: 1,
|
|
17
19
|
alignSelf: 'stretch',
|
|
18
20
|
gap: theme.components.radio.gap,
|
|
19
21
|
padding: theme.components.radio.tile.padding,
|
|
@@ -29,6 +31,12 @@ const styles = StyleSheet.create(theme => ({
|
|
|
29
31
|
margin: -theme.components.radio.tile.borderWidthSelected / 2,
|
|
30
32
|
},
|
|
31
33
|
},
|
|
34
|
+
direction: {
|
|
35
|
+
row: {},
|
|
36
|
+
column: {
|
|
37
|
+
flex: 1,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
32
40
|
},
|
|
33
41
|
},
|
|
34
42
|
}));
|
package/docs/introduction.mdx
CHANGED
|
@@ -212,6 +212,16 @@ StyleSheet.configure({
|
|
|
212
212
|
breakpoints,
|
|
213
213
|
});
|
|
214
214
|
|
|
215
|
+
// For some reason react-native-reanimated's default mock doesn't mock useReducedMotion, so we need to override it here
|
|
216
|
+
// as we use that method in our components.
|
|
217
|
+
jest.mock('react-native-reanimated', () => {
|
|
218
|
+
return {
|
|
219
|
+
...jest.requireActual('react-native-reanimated/mock'),
|
|
220
|
+
useReducedMotion: () => {}, // Add this line
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
require('react-native-reanimated').setUpTests();
|
|
224
|
+
|
|
215
225
|
// rest of your setup...
|
|
216
226
|
```
|
|
217
227
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utilitywarehouse/hearth-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "Utility Warehouse React Native UI library",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"vite-plugin-svgr": "^4.5.0",
|
|
57
57
|
"vitest": "^3.2.4",
|
|
58
58
|
"@utilitywarehouse/hearth-fonts": "^0.0.4",
|
|
59
|
-
"@utilitywarehouse/hearth-react-native-icons": "^0.7.4",
|
|
60
59
|
"@utilitywarehouse/hearth-react-icons": "^0.7.4",
|
|
61
|
-
"@utilitywarehouse/hearth-
|
|
60
|
+
"@utilitywarehouse/hearth-react-native-icons": "^0.7.4",
|
|
61
|
+
"@utilitywarehouse/hearth-svg-assets": "^0.3.0",
|
|
62
62
|
"@utilitywarehouse/hearth-tokens": "^0.2.2"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
@@ -222,9 +222,9 @@ const styles = StyleSheet.create(theme => ({
|
|
|
222
222
|
withIconContainer: {
|
|
223
223
|
alignItems: 'center',
|
|
224
224
|
flexDirection: 'row',
|
|
225
|
-
paddingVertical: theme.components.
|
|
226
|
-
paddingHorizontal: theme.components.
|
|
227
|
-
gap: theme.components.
|
|
225
|
+
paddingVertical: theme.components.cardAction.content.paddingVertical,
|
|
226
|
+
paddingHorizontal: theme.components.cardAction.content.paddingHorizontal,
|
|
227
|
+
gap: theme.components.cardAction.content.gap,
|
|
228
228
|
flex: 1,
|
|
229
229
|
variants: {
|
|
230
230
|
hasIconContainer: {
|
|
@@ -4,6 +4,7 @@ export const CheckboxGroupContext = createContext<{
|
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
validationStatus?: 'valid' | 'invalid' | 'initial';
|
|
6
6
|
type?: 'default' | 'tile';
|
|
7
|
+
direction?: 'column' | 'row';
|
|
7
8
|
}>({});
|
|
8
9
|
|
|
9
10
|
export const useCheckboxGroupContext = () => useContext(CheckboxGroupContext);
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
1
|
import React, { useMemo } from 'react';
|
|
3
|
-
import { CheckboxGroup as CheckboxGroupComponent } from './Checkbox';
|
|
4
|
-
import CheckboxGroupProps from './CheckboxGroup.props';
|
|
5
|
-
import { CheckboxGroupContext } from './CheckboxGroup.context';
|
|
6
2
|
import { View } from 'react-native';
|
|
7
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
8
|
-
import CheckboxGroupTextContent from './CheckboxGroupTextContent';
|
|
9
|
-
import { Label } from '../Label';
|
|
10
4
|
import { Helper } from '../Helper';
|
|
5
|
+
import { Label } from '../Label';
|
|
6
|
+
import { CheckboxGroup as CheckboxGroupComponent } from './Checkbox';
|
|
7
|
+
import { CheckboxGroupContext } from './CheckboxGroup.context';
|
|
8
|
+
import CheckboxGroupProps from './CheckboxGroup.props';
|
|
9
|
+
import CheckboxGroupTextContent from './CheckboxGroupTextContent';
|
|
11
10
|
|
|
12
11
|
const CheckboxGroup = ({
|
|
13
12
|
children,
|
|
@@ -26,8 +25,8 @@ const CheckboxGroup = ({
|
|
|
26
25
|
...props
|
|
27
26
|
}: CheckboxGroupProps) => {
|
|
28
27
|
const value = useMemo(
|
|
29
|
-
() => ({ disabled, validationStatus, type }),
|
|
30
|
-
[disabled, validationStatus, type]
|
|
28
|
+
() => ({ disabled, validationStatus, type, direction }),
|
|
29
|
+
[disabled, validationStatus, type, direction]
|
|
31
30
|
);
|
|
32
31
|
const showHeader = !!label || !!helperText || !!invalidText || !!validText;
|
|
33
32
|
const childrenArray = React.Children.toArray(children as any);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { View, ViewProps } from 'react-native';
|
|
2
2
|
import { StyleSheet } from 'react-native-unistyles';
|
|
3
3
|
import { useCheckboxContext } from './Checkbox.context';
|
|
4
|
+
import { useCheckboxGroupContext } from './CheckboxGroup.context';
|
|
4
5
|
|
|
5
6
|
const CheckboxTileRoot = ({ children }: { children: ViewProps['children'] }) => {
|
|
7
|
+
const { direction } = useCheckboxGroupContext();
|
|
6
8
|
const { checked } = useCheckboxContext();
|
|
7
9
|
styles.useVariants({
|
|
8
10
|
checked,
|
|
11
|
+
direction,
|
|
9
12
|
});
|
|
10
13
|
return <View style={styles.container}>{children}</View>;
|
|
11
14
|
};
|
|
@@ -14,7 +17,6 @@ const styles = StyleSheet.create(theme => ({
|
|
|
14
17
|
container: {
|
|
15
18
|
flexDirection: 'row',
|
|
16
19
|
justifyContent: 'flex-start',
|
|
17
|
-
flex: 1,
|
|
18
20
|
alignSelf: 'stretch',
|
|
19
21
|
gap: theme.components.checkbox.gap,
|
|
20
22
|
padding: theme.components.checkbox.tile.padding,
|
|
@@ -30,6 +32,12 @@ const styles = StyleSheet.create(theme => ({
|
|
|
30
32
|
margin: -theme.components.checkbox.tile.borderWidthSelected / 2,
|
|
31
33
|
},
|
|
32
34
|
},
|
|
35
|
+
direction: {
|
|
36
|
+
row: {},
|
|
37
|
+
column: {
|
|
38
|
+
flex: 1,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
33
41
|
},
|
|
34
42
|
},
|
|
35
43
|
}));
|