@utilitywarehouse/hearth-react-native 0.6.0 → 0.8.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/main.ts +12 -6
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +18 -0
- package/build/components/Banner/Banner.d.ts +6 -0
- package/build/components/Banner/Banner.js +161 -0
- package/build/components/Banner/Banner.props.d.ts +82 -0
- package/build/components/Banner/Banner.props.js +1 -0
- package/build/components/Banner/index.d.ts +2 -0
- package/build/components/Banner/index.js +1 -0
- package/build/components/BottomSheet/BottomSheetBackdrop.js +1 -5
- package/build/components/BottomSheet/BottomSheetFlatList.js +1 -5
- package/build/components/BottomSheet/BottomSheetHandle.js +1 -5
- package/build/components/BottomSheet/useBottomSheetLogic.d.ts +1 -1
- package/build/components/Button/ButtonIcon.js +2 -1
- package/build/components/Button/ButtonRoot.js +2 -6
- package/build/components/Button/ButtonText.js +4 -1
- package/build/components/Card/Card.context.d.ts +7 -0
- package/build/components/Card/CardAction/CardAction.context.d.ts +9 -0
- package/build/components/Card/{CardAction.context.js → CardAction/CardAction.context.js} +7 -1
- package/build/components/Card/CardAction/CardAction.d.ts +18 -0
- package/build/components/Card/CardAction/CardAction.js +7 -0
- package/build/components/Card/CardAction/CardAction.props.d.ts +63 -0
- package/build/components/Card/CardAction/CardAction.props.js +1 -0
- package/build/components/Card/CardAction/CardActionContent.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionContent.js +13 -0
- package/build/components/Card/CardAction/CardActionHelperText.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionHelperText.js +13 -0
- package/build/components/Card/CardAction/CardActionIcon.d.ts +9 -0
- package/build/components/Card/CardAction/CardActionIcon.js +19 -0
- package/build/components/Card/CardAction/CardActionLeadingContent.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionLeadingContent.js +5 -0
- package/build/components/Card/CardAction/CardActionRoot.d.ts +12 -0
- package/build/components/Card/CardAction/CardActionRoot.js +155 -0
- package/build/components/Card/CardAction/CardActionText.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionText.js +9 -0
- package/build/components/Card/CardAction/CardActionTrailingContent.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionTrailingContent.js +5 -0
- package/build/components/Card/CardAction/CardActionTrailingIcon.d.ts +9 -0
- package/build/components/Card/CardAction/CardActionTrailingIcon.js +19 -0
- package/build/components/Card/CardAction/index.d.ts +10 -0
- package/build/components/Card/CardAction/index.js +9 -0
- package/build/components/Card/CardContent.d.ts +6 -0
- package/build/components/Card/CardContent.js +33 -0
- package/build/components/Card/CardPressHandler.context.d.ts +6 -0
- package/build/components/Card/CardPressHandler.context.js +6 -0
- package/build/components/Card/{CardAction.d.ts → CardPressHandler.d.ts} +3 -3
- package/build/components/Card/CardPressHandler.js +13 -0
- package/build/components/Card/CardRoot.js +103 -11
- package/build/components/Card/index.d.ts +3 -2
- package/build/components/Card/index.js +3 -2
- package/build/components/Checkbox/CheckboxIcon.js +2 -1
- package/build/components/Container/Container.js +3 -3
- package/build/components/CurrencyInput/CurrencyInput.js +1 -1
- package/build/components/Expandable/Expandable.d.ts +6 -0
- package/build/components/Expandable/Expandable.js +44 -0
- package/build/components/Expandable/Expandable.props.d.ts +38 -0
- package/build/components/Expandable/Expandable.props.js +1 -0
- package/build/components/Expandable/index.d.ts +2 -0
- package/build/components/Expandable/index.js +1 -0
- package/build/components/ExpandableCard/ExpandableCard.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCard.js +23 -0
- package/build/components/ExpandableCard/ExpandableCard.props.d.ts +69 -0
- package/build/components/ExpandableCard/ExpandableCard.props.js +1 -0
- package/build/components/ExpandableCard/ExpandableCardContent.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCardContent.js +14 -0
- package/build/components/ExpandableCard/ExpandableCardExpandedContent.d.ts +11 -0
- package/build/components/ExpandableCard/ExpandableCardExpandedContent.js +18 -0
- package/build/components/ExpandableCard/ExpandableCardGroup.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCardGroup.js +17 -0
- package/build/components/ExpandableCard/ExpandableCardGroup.props.d.ts +25 -0
- package/build/components/ExpandableCard/ExpandableCardGroup.props.js +1 -0
- package/build/components/ExpandableCard/ExpandableCardHelperText.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCardHelperText.js +13 -0
- package/build/components/ExpandableCard/ExpandableCardIcon.d.ts +9 -0
- package/build/components/ExpandableCard/ExpandableCardIcon.js +19 -0
- package/build/components/ExpandableCard/ExpandableCardLeadingContent.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCardLeadingContent.js +5 -0
- package/build/components/ExpandableCard/ExpandableCardText.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCardText.js +7 -0
- package/build/components/ExpandableCard/ExpandableCardTrailingContent.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCardTrailingContent.js +5 -0
- package/build/components/ExpandableCard/ExpandableCardTrailingIcon.d.ts +9 -0
- package/build/components/ExpandableCard/ExpandableCardTrailingIcon.js +17 -0
- package/build/components/ExpandableCard/ExpandableCardTrigger.d.ts +17 -0
- package/build/components/ExpandableCard/ExpandableCardTrigger.js +7 -0
- package/build/components/ExpandableCard/ExpandableCardTrigger.props.d.ts +44 -0
- package/build/components/ExpandableCard/ExpandableCardTrigger.props.js +1 -0
- package/build/components/ExpandableCard/ExpandableCardTriggerRoot.d.ts +11 -0
- package/build/components/ExpandableCard/ExpandableCardTriggerRoot.js +91 -0
- package/build/components/ExpandableCard/index.d.ts +14 -0
- package/build/components/ExpandableCard/index.js +11 -0
- package/build/components/Helper/HelperIcon.js +2 -1
- package/build/components/HighlightBanner/HighlightBanner.d.ts +6 -0
- package/build/components/HighlightBanner/HighlightBanner.js +86 -0
- package/build/components/HighlightBanner/HighlightBanner.props.d.ts +14 -0
- package/build/components/HighlightBanner/HighlightBanner.props.js +1 -0
- package/build/components/HighlightBanner/index.d.ts +2 -0
- package/build/components/HighlightBanner/index.js +1 -0
- package/build/components/Icon/Icon.d.ts +2 -6
- package/build/components/IconButton/IconButtonIcon.js +2 -1
- package/build/components/IconContainer/IconContainer.d.ts +4 -3
- package/build/components/IconContainer/IconContainer.js +3 -3
- package/build/components/Input/InputField.js +4 -2
- package/build/components/Input/InputIcon.js +2 -1
- package/build/components/Link/LinkIcon.js +3 -2
- package/build/components/List/ListAction/ListActionTrailingIcon.js +2 -1
- package/build/components/List/ListItem/ListItemIcon.js +2 -1
- package/build/components/List/ListItem/ListItemTrailingIcon.js +2 -3
- package/build/components/Radio/RadioIcon.js +7 -2
- package/build/components/RadioCard/RadioCardIcon.js +3 -2
- package/build/components/Spinner/Spinner.web.d.ts +2 -1
- package/build/components/Switch/Switch.js +5 -3
- package/build/components/Textarea/TextareaField.js +1 -1
- package/build/components/ToggleButton/ToggleButtonIcon.js +2 -1
- package/build/components/ToggleButton/ToggleButtonRoot.js +2 -2
- package/build/components/UnstyledIconButton/UnstyledIconButtonIcon.js +2 -1
- package/build/components/index.d.ts +5 -1
- package/build/components/index.js +5 -1
- package/build/core/index.d.ts +3 -3
- package/build/core/index.js +3 -3
- package/build/core/themes.d.ts +24 -12
- package/build/hooks/useColorMode.d.ts +1 -1
- package/build/hooks/useColorMode.js +7 -8
- package/build/tokens/components/dark/banner.d.ts +19 -0
- package/build/tokens/components/dark/banner.js +19 -0
- package/build/tokens/components/dark/card-action.d.ts +11 -0
- package/build/tokens/components/dark/card-action.js +10 -0
- package/build/tokens/components/dark/card-content.d.ts +25 -0
- package/build/tokens/components/dark/card-content.js +24 -0
- package/build/tokens/components/dark/drawer.d.ts +29 -0
- package/build/tokens/components/dark/drawer.js +28 -0
- package/build/tokens/components/dark/illustrations.d.ts +0 -1
- package/build/tokens/components/dark/illustrations.js +0 -1
- package/build/tokens/components/dark/index.d.ts +3 -0
- package/build/tokens/components/dark/index.js +3 -0
- package/build/tokens/components/light/banner.d.ts +19 -0
- package/build/tokens/components/light/banner.js +19 -0
- package/build/tokens/components/light/card-action.d.ts +11 -0
- package/build/tokens/components/light/card-action.js +10 -0
- package/build/tokens/components/light/card-content.d.ts +25 -0
- package/build/tokens/components/light/card-content.js +24 -0
- package/build/tokens/components/light/drawer.d.ts +29 -0
- package/build/tokens/components/light/drawer.js +28 -0
- package/build/tokens/components/light/illustrations.d.ts +0 -1
- package/build/tokens/components/light/illustrations.js +0 -1
- package/build/tokens/components/light/index.d.ts +3 -0
- package/build/tokens/components/light/index.js +3 -0
- package/build/tokens/layout.d.ts +6 -6
- package/build/tokens/layout.js +3 -3
- package/build/tokens/typography.d.ts +6 -0
- package/build/tokens/typography.js +3 -0
- package/docs/components/AllComponents.web.tsx +75 -4
- package/docs/components/NextPrevPage.tsx +5 -5
- package/docs/components/VariantTitle.tsx +17 -7
- package/package.json +16 -14
- package/src/components/Banner/Banner.docs.mdx +402 -0
- package/src/components/Banner/Banner.props.ts +106 -0
- package/src/components/Banner/Banner.stories.tsx +494 -0
- package/src/components/Banner/Banner.tsx +264 -0
- package/src/components/Banner/index.ts +2 -0
- package/src/components/BottomSheet/BottomSheetBackdrop.tsx +1 -2
- package/src/components/BottomSheet/BottomSheetFlatList.tsx +1 -3
- package/src/components/BottomSheet/BottomSheetHandle.tsx +0 -1
- package/src/components/Button/ButtonIcon.tsx +2 -1
- package/src/components/Button/ButtonRoot.tsx +2 -6
- package/src/components/Button/ButtonText.tsx +4 -1
- package/src/components/Card/Card.context.ts +7 -0
- package/src/components/Card/Card.docs.mdx +221 -15
- package/src/components/Card/Card.stories.tsx +50 -3
- package/src/components/Card/CardAction/CardAction.context.ts +22 -0
- package/src/components/Card/CardAction/CardAction.props.ts +87 -0
- package/src/components/Card/CardAction/CardAction.stories.tsx +265 -0
- package/src/components/Card/CardAction/CardAction.tsx +10 -0
- package/src/components/Card/CardAction/CardActionContent.tsx +20 -0
- package/src/components/Card/CardAction/CardActionHelperText.tsx +21 -0
- package/src/components/Card/CardAction/CardActionIcon.tsx +32 -0
- package/src/components/Card/CardAction/CardActionLeadingContent.tsx +9 -0
- package/src/components/Card/CardAction/CardActionRoot.tsx +258 -0
- package/src/components/Card/CardAction/CardActionText.tsx +17 -0
- package/src/components/Card/CardAction/CardActionTrailingContent.tsx +9 -0
- package/src/components/Card/CardAction/CardActionTrailingIcon.tsx +32 -0
- package/src/components/Card/CardAction/index.ts +10 -0
- package/src/components/Card/CardContent.tsx +40 -0
- package/src/components/Card/CardPressHandler.context.ts +12 -0
- package/src/components/Card/CardPressHandler.tsx +20 -0
- package/src/components/Card/CardRoot.tsx +128 -13
- package/src/components/Card/index.ts +3 -2
- package/src/components/Checkbox/CheckboxIcon.tsx +2 -1
- package/src/components/Container/Container.tsx +3 -3
- package/src/components/CurrencyInput/CurrencyInput.tsx +1 -1
- package/src/components/Expandable/Expandable.docs.mdx +201 -0
- package/src/components/Expandable/Expandable.props.ts +46 -0
- package/src/components/Expandable/Expandable.stories.tsx +284 -0
- package/src/components/Expandable/Expandable.tsx +92 -0
- package/src/components/Expandable/index.ts +2 -0
- package/src/components/ExpandableCard/ExpandableCard.docs.mdx +312 -0
- package/src/components/ExpandableCard/ExpandableCard.props.ts +85 -0
- package/src/components/ExpandableCard/ExpandableCard.stories.tsx +326 -0
- package/src/components/ExpandableCard/ExpandableCard.tsx +76 -0
- package/src/components/ExpandableCard/ExpandableCardContent.tsx +21 -0
- package/src/components/ExpandableCard/ExpandableCardExpandedContent.tsx +42 -0
- package/src/components/ExpandableCard/ExpandableCardGroup.props.ts +31 -0
- package/src/components/ExpandableCard/ExpandableCardGroup.tsx +40 -0
- package/src/components/ExpandableCard/ExpandableCardHelperText.tsx +21 -0
- package/src/components/ExpandableCard/ExpandableCardIcon.tsx +32 -0
- package/src/components/ExpandableCard/ExpandableCardLeadingContent.tsx +9 -0
- package/src/components/ExpandableCard/ExpandableCardText.tsx +14 -0
- package/src/components/ExpandableCard/ExpandableCardTrailingContent.tsx +9 -0
- package/src/components/ExpandableCard/ExpandableCardTrailingIcon.tsx +30 -0
- package/src/components/ExpandableCard/ExpandableCardTrigger.props.ts +47 -0
- package/src/components/ExpandableCard/ExpandableCardTrigger.tsx +10 -0
- package/src/components/ExpandableCard/ExpandableCardTriggerRoot.tsx +154 -0
- package/src/components/ExpandableCard/index.ts +14 -0
- package/src/components/Helper/HelperIcon.tsx +2 -1
- package/src/components/HighlightBanner/HighlightBanner.docs.mdx +277 -0
- package/src/components/HighlightBanner/HighlightBanner.props.ts +29 -0
- package/src/components/HighlightBanner/HighlightBanner.stories.tsx +259 -0
- package/src/components/HighlightBanner/HighlightBanner.tsx +122 -0
- package/src/components/HighlightBanner/index.ts +2 -0
- package/src/components/Icon/Icon.tsx +4 -3
- package/src/components/IconButton/IconButtonIcon.tsx +2 -1
- package/src/components/IconContainer/IconContainer.tsx +17 -19
- package/src/components/Input/InputField.tsx +2 -1
- package/src/components/Input/InputIcon.tsx +2 -1
- package/src/components/Link/LinkIcon.tsx +3 -2
- package/src/components/List/ListAction/ListActionTrailingIcon.tsx +2 -1
- package/src/components/List/ListItem/ListItemIcon.tsx +2 -1
- package/src/components/List/ListItem/ListItemTrailingIcon.tsx +2 -3
- package/src/components/Radio/RadioIcon.tsx +8 -3
- package/src/components/RadioCard/RadioCardIcon.tsx +4 -3
- package/src/components/Switch/Switch.tsx +10 -5
- package/src/components/Switch/Switch.web.tsx +1 -0
- package/src/components/Textarea/TextareaField.tsx +1 -1
- package/src/components/ToggleButton/ToggleButtonIcon.tsx +2 -1
- package/src/components/ToggleButton/ToggleButtonRoot.tsx +2 -2
- package/src/components/UnstyledIconButton/UnstyledIconButtonIcon.tsx +2 -1
- package/src/components/index.ts +5 -9
- package/src/core/index.ts +14 -11
- package/src/hooks/useColorMode.ts +9 -12
- package/src/tokens/components/dark/banner.ts +19 -0
- package/src/tokens/components/dark/card-action.ts +11 -0
- package/src/tokens/components/dark/card-content.ts +25 -0
- package/src/tokens/components/dark/drawer.ts +29 -0
- package/src/tokens/components/dark/illustrations.ts +0 -1
- package/src/tokens/components/dark/index.ts +3 -0
- package/src/tokens/components/light/banner.ts +19 -0
- package/src/tokens/components/light/card-action.ts +11 -0
- package/src/tokens/components/light/card-content.ts +25 -0
- package/src/tokens/components/light/drawer.ts +29 -0
- package/src/tokens/components/light/illustrations.ts +0 -1
- package/src/tokens/components/light/index.ts +3 -0
- package/src/tokens/layout.ts +3 -3
- package/src/tokens/typography.ts +3 -0
- package/build/components/Card/CardAction.context.d.ts +0 -6
- package/build/components/Card/CardAction.js +0 -13
- package/src/components/Card/CardAction.context.ts +0 -12
- package/src/components/Card/CardAction.tsx +0 -18
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { IconProps } from '../../Icon';
|
|
3
|
+
declare const CardActionIcon: {
|
|
4
|
+
({ children, ...props }: IconProps & {
|
|
5
|
+
as?: ComponentType;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
displayName: string;
|
|
8
|
+
};
|
|
9
|
+
export default CardActionIcon;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { Icon } from '../../Icon';
|
|
5
|
+
const CardActionIcon = ({ children, ...props }) => {
|
|
6
|
+
return (_jsx(Icon, { ...props, style: Platform.OS === 'web'
|
|
7
|
+
? // @ts-expect-error - style prop type issue
|
|
8
|
+
{ ...styles.icon, ...props.style }
|
|
9
|
+
: [styles.icon, props.style], children: children }));
|
|
10
|
+
};
|
|
11
|
+
CardActionIcon.displayName = 'CardActionIcon';
|
|
12
|
+
const styles = StyleSheet.create(theme => ({
|
|
13
|
+
icon: {
|
|
14
|
+
color: theme.color.icon.primary,
|
|
15
|
+
width: 24,
|
|
16
|
+
height: 24,
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
export default CardActionIcon;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
const CardActionLeadingContent = ({ children, ...props }) => (_jsx(View, { ...props, children: children }));
|
|
4
|
+
CardActionLeadingContent.displayName = 'CardActionLeadingContent';
|
|
5
|
+
export default CardActionLeadingContent;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type CardActionProps from './CardAction.props';
|
|
2
|
+
declare const CardActionRoot: {
|
|
3
|
+
({ heading, helperText, leadingContent, trailingContent, disabled, loading, children, states, badge, badgePosition, iconContainer, iconContainerColor, iconContainerVariant, leadingIcon, trailingIcon, size, ...props }: CardActionProps & {
|
|
4
|
+
states?: {
|
|
5
|
+
active?: boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
};
|
|
8
|
+
isFirst?: boolean;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
displayName: string;
|
|
11
|
+
};
|
|
12
|
+
export default CardActionRoot;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronRightSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { Pressable, View } from 'react-native';
|
|
5
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
6
|
+
import { Badge } from '../../Badge';
|
|
7
|
+
import { IconContainer } from '../../IconContainer';
|
|
8
|
+
import { Skeleton } from '../../Skeleton';
|
|
9
|
+
import { useCardContext } from '../Card.context';
|
|
10
|
+
import { CardActionContext } from './CardAction.context';
|
|
11
|
+
import CardActionContent from './CardActionContent';
|
|
12
|
+
import CardActionHelperText from './CardActionHelperText';
|
|
13
|
+
import CardActionIcon from './CardActionIcon';
|
|
14
|
+
import CardActionLeadingContent from './CardActionLeadingContent';
|
|
15
|
+
import CardActionText from './CardActionText';
|
|
16
|
+
import CardActionTrailingContent from './CardActionTrailingContent';
|
|
17
|
+
import CardActionTrailingIcon from './CardActionTrailingIcon';
|
|
18
|
+
const CardActionRoot = ({ heading, helperText, leadingContent, trailingContent, disabled, loading, children, states, badge, badgePosition = 'bottom', iconContainer = true, iconContainerColor, iconContainerVariant, leadingIcon, trailingIcon = ChevronRightSmallIcon, size = 'md', ...props }) => {
|
|
19
|
+
const { onPress } = props;
|
|
20
|
+
const { active } = states || { active: false };
|
|
21
|
+
const isLoading = loading;
|
|
22
|
+
const showPressed = isLoading ? false : !!onPress;
|
|
23
|
+
const isDisabled = disabled || false;
|
|
24
|
+
const testID = props.testID || 'card-action';
|
|
25
|
+
const loadingTestID = isLoading ? `${testID}-loading` : testID;
|
|
26
|
+
const { variant, hasOnlyActions } = useCardContext();
|
|
27
|
+
const isFirst = props.isFirst;
|
|
28
|
+
styles.useVariants({
|
|
29
|
+
showPressed,
|
|
30
|
+
active,
|
|
31
|
+
disabled: isDisabled || isLoading,
|
|
32
|
+
showDisabled: disabled,
|
|
33
|
+
hasIconContainer: !loading && iconContainer,
|
|
34
|
+
variant,
|
|
35
|
+
isFirst: hasOnlyActions && isFirst,
|
|
36
|
+
});
|
|
37
|
+
const value = useMemo(() => {
|
|
38
|
+
return {
|
|
39
|
+
showPressed,
|
|
40
|
+
active: active || false,
|
|
41
|
+
loading: isLoading || false,
|
|
42
|
+
disabled: isDisabled,
|
|
43
|
+
size,
|
|
44
|
+
};
|
|
45
|
+
}, [active, showPressed, isLoading, isDisabled, size]);
|
|
46
|
+
if (loading) {
|
|
47
|
+
return (_jsxs(Pressable, { ...props, testID: loadingTestID, style: [styles.container, styles.alignCenter, props.style], disabled: isDisabled, children: [leadingContent || leadingIcon ? (_jsx(Skeleton, { width: 24, height: 24, style: styles.alignCenter })) : null, _jsxs(CardActionContent, { children: [_jsx(Skeleton, { width: "80%", height: 24, borderRadius: "xs" }), _jsx(Skeleton, { width: "100%", height: 24, borderRadius: "xs" })] }), trailingIcon || trailingContent ? (_jsx(Skeleton, { width: 24, height: 24, borderRadius: "xs", style: styles.alignCenter })) : null] }));
|
|
48
|
+
}
|
|
49
|
+
return (_jsx(CardActionContext.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: [leadingIcon && iconContainer ? (_jsx(View, { style: styles.iconContainerWrap, children: _jsx(IconContainer, { style: styles.iconContainer, icon: leadingIcon, variant: iconContainerVariant, color: iconContainerColor, radiusNone: true }) })) : null, _jsxs(View, { style: styles.withIconContainer, children: [leadingContent ? (_jsx(CardActionLeadingContent, { children: leadingContent })) : null, leadingIcon && !iconContainer && !leadingContent ? (_jsx(CardActionLeadingContent, { children: _jsx(CardActionIcon, { as: leadingIcon }) })) : null, _jsxs(CardActionContent, { children: [badgePosition === 'top' && badge ? _jsx(Badge, { ...badge }) : null, _jsx(CardActionText, { children: heading }), badgePosition === 'middle' && badge ? _jsx(Badge, { ...badge }) : null, helperText ? _jsx(CardActionHelperText, { children: helperText }) : null, badgePosition === 'bottom' && badge ? _jsx(Badge, { ...badge }) : null] }), badgePosition === 'right' && badge ? (_jsx(Badge, { ...badge, style: [badge.style, styles.alignCenter] })) : null, trailingContent ? (_jsx(CardActionTrailingContent, { children: trailingContent })) : null, trailingIcon && !trailingContent ? (_jsx(CardActionTrailingContent, { children: _jsx(CardActionTrailingIcon, { as: trailingIcon }) })) : null] })] })) }) }));
|
|
50
|
+
};
|
|
51
|
+
CardActionRoot.displayName = 'CardActionRoot';
|
|
52
|
+
const styles = StyleSheet.create(theme => ({
|
|
53
|
+
container: {
|
|
54
|
+
paddingVertical: theme.components.cardAction.content.paddingVertical,
|
|
55
|
+
paddingHorizontal: theme.components.cardAction.content.paddingHorizontal,
|
|
56
|
+
flexDirection: 'row',
|
|
57
|
+
gap: theme.components.cardAction.content.gap,
|
|
58
|
+
borderTopWidth: theme.borderWidth[1],
|
|
59
|
+
borderColor: theme.color.border.strong,
|
|
60
|
+
width: '100%',
|
|
61
|
+
variants: {
|
|
62
|
+
isFirst: {
|
|
63
|
+
true: {
|
|
64
|
+
borderTopWidth: 0,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
disabled: {
|
|
68
|
+
true: {
|
|
69
|
+
cursor: 'auto',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
variant: {
|
|
73
|
+
subtle: {
|
|
74
|
+
borderColor: theme.color.border.subtle,
|
|
75
|
+
},
|
|
76
|
+
emphasis: {
|
|
77
|
+
borderColor: theme.color.border.strong,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
hasIconContainer: {
|
|
81
|
+
true: {
|
|
82
|
+
paddingHorizontal: 0,
|
|
83
|
+
paddingVertical: 0,
|
|
84
|
+
gap: 0,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
showDisabled: {
|
|
88
|
+
true: {
|
|
89
|
+
opacity: theme.opacity.disabled,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
showPressed: {
|
|
93
|
+
true: {
|
|
94
|
+
_web: {
|
|
95
|
+
_hover: {
|
|
96
|
+
backgroundColor: theme.color.interactive.neutral.surface.subtle.hover,
|
|
97
|
+
},
|
|
98
|
+
_active: {
|
|
99
|
+
backgroundColor: theme.color.interactive.neutral.surface.subtle.active,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
false: {
|
|
104
|
+
cursor: 'auto',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
active: {
|
|
108
|
+
true: {},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
compoundVariants: [
|
|
112
|
+
{
|
|
113
|
+
showPressed: true,
|
|
114
|
+
active: true,
|
|
115
|
+
styles: {
|
|
116
|
+
backgroundColor: theme.color.interactive.neutral.surface.subtle.active,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
withIconContainer: {
|
|
122
|
+
alignItems: 'center',
|
|
123
|
+
flexDirection: 'row',
|
|
124
|
+
paddingVertical: theme.components.list.item.functional.padding,
|
|
125
|
+
paddingHorizontal: theme.components.list.item.functional.padding,
|
|
126
|
+
gap: theme.components.list.item.gap,
|
|
127
|
+
flex: 1,
|
|
128
|
+
variants: {
|
|
129
|
+
hasIconContainer: {
|
|
130
|
+
true: {},
|
|
131
|
+
false: {
|
|
132
|
+
flex: 1,
|
|
133
|
+
paddingHorizontal: 0,
|
|
134
|
+
paddingVertical: 0,
|
|
135
|
+
alignItems: 'center',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
alignCenter: {
|
|
141
|
+
alignSelf: 'center',
|
|
142
|
+
alignItems: 'center',
|
|
143
|
+
},
|
|
144
|
+
iconContainer: {
|
|
145
|
+
flex: 1,
|
|
146
|
+
_web: {
|
|
147
|
+
overflow: 'visible',
|
|
148
|
+
height: '100%',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
iconContainerWrap: {
|
|
152
|
+
flexDirection: 'column',
|
|
153
|
+
},
|
|
154
|
+
}));
|
|
155
|
+
export default CardActionRoot;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BodyText } from '../../BodyText';
|
|
3
|
+
import { useCardActionContext } from './CardAction.context';
|
|
4
|
+
const CardActionText = ({ children, ...props }) => {
|
|
5
|
+
const { size } = useCardActionContext();
|
|
6
|
+
return (_jsx(BodyText, { size: size, weight: "semibold", ...props, children: children }));
|
|
7
|
+
};
|
|
8
|
+
CardActionText.displayName = 'CardActionText';
|
|
9
|
+
export default CardActionText;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
const CardActionTrailingContent = ({ children, ...props }) => (_jsx(View, { ...props, children: children }));
|
|
4
|
+
CardActionTrailingContent.displayName = 'CardActionTrailingContent';
|
|
5
|
+
export default CardActionTrailingContent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { IconProps } from '../../Icon';
|
|
3
|
+
declare const CardActionTrailingIcon: {
|
|
4
|
+
({ children, ...props }: IconProps & {
|
|
5
|
+
as?: ComponentType;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
displayName: string;
|
|
8
|
+
};
|
|
9
|
+
export default CardActionTrailingIcon;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { Icon } from '../../Icon';
|
|
5
|
+
const CardActionTrailingIcon = ({ children, ...props }) => {
|
|
6
|
+
return (_jsx(Icon, { ...props, style: Platform.OS === 'web'
|
|
7
|
+
? // @ts-expect-error - style prop type issue
|
|
8
|
+
{ ...styles.icon, ...props.style }
|
|
9
|
+
: [styles.icon, props.style], children: children }));
|
|
10
|
+
};
|
|
11
|
+
CardActionTrailingIcon.displayName = 'CardActionTrailingIcon';
|
|
12
|
+
const styles = StyleSheet.create(theme => ({
|
|
13
|
+
icon: {
|
|
14
|
+
color: theme.color.icon.primary,
|
|
15
|
+
minWidth: 20,
|
|
16
|
+
minHeight: 20,
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
export default CardActionTrailingIcon;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as CardAction } from './CardAction';
|
|
2
|
+
export { useCardActionContext } from './CardAction.context';
|
|
3
|
+
export type { default as CardActionProps } from './CardAction.props';
|
|
4
|
+
export { default as CardActionContent } from './CardActionContent';
|
|
5
|
+
export { default as CardActionHelperText } from './CardActionHelperText';
|
|
6
|
+
export { default as CardActionIcon } from './CardActionIcon';
|
|
7
|
+
export { default as CardActionLeadingContent } from './CardActionLeadingContent';
|
|
8
|
+
export { default as CardActionText } from './CardActionText';
|
|
9
|
+
export { default as CardActionTrailingContent } from './CardActionTrailingContent';
|
|
10
|
+
export { default as CardActionTrailingIcon } from './CardActionTrailingIcon';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as CardAction } from './CardAction';
|
|
2
|
+
export { useCardActionContext } from './CardAction.context';
|
|
3
|
+
export { default as CardActionContent } from './CardActionContent';
|
|
4
|
+
export { default as CardActionHelperText } from './CardActionHelperText';
|
|
5
|
+
export { default as CardActionIcon } from './CardActionIcon';
|
|
6
|
+
export { default as CardActionLeadingContent } from './CardActionLeadingContent';
|
|
7
|
+
export { default as CardActionText } from './CardActionText';
|
|
8
|
+
export { default as CardActionTrailingContent } from './CardActionTrailingContent';
|
|
9
|
+
export { default as CardActionTrailingIcon } from './CardActionTrailingIcon';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { useCardContext } from './Card.context';
|
|
5
|
+
const CardContent = ({ children, style, ...props }) => {
|
|
6
|
+
const { noPadding, space } = useCardContext();
|
|
7
|
+
styles.useVariants({
|
|
8
|
+
noPadding,
|
|
9
|
+
space,
|
|
10
|
+
});
|
|
11
|
+
return (_jsx(View, { style: [styles.container, style], ...props, children: children }));
|
|
12
|
+
};
|
|
13
|
+
CardContent.displayName = 'CardContent';
|
|
14
|
+
const styles = StyleSheet.create(theme => ({
|
|
15
|
+
container: {
|
|
16
|
+
variants: {
|
|
17
|
+
space: theme.globalStyle.variants.space,
|
|
18
|
+
noPadding: {
|
|
19
|
+
true: {
|
|
20
|
+
padding: theme.components.card.mobile.paddingNone,
|
|
21
|
+
},
|
|
22
|
+
false: {
|
|
23
|
+
padding: {
|
|
24
|
+
base: theme.components.card.mobile.padding,
|
|
25
|
+
md: theme.components.card.tablet.padding,
|
|
26
|
+
lg: theme.components.card.desktop.padding,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}));
|
|
33
|
+
export default CardContent;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
declare const
|
|
2
|
+
declare const CardPressHandler: {
|
|
3
3
|
({ children }: PropsWithChildren<{
|
|
4
|
-
|
|
4
|
+
handlerToInherit?: string;
|
|
5
5
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
displayName: string;
|
|
7
7
|
};
|
|
8
|
-
export default
|
|
8
|
+
export default CardPressHandler;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { useCardContext } from './Card.context';
|
|
4
|
+
import { CardPressHandlerContext } from './CardPressHandler.context';
|
|
5
|
+
const CardPressHandler = ({ children }) => {
|
|
6
|
+
const { pressed } = useCardContext();
|
|
7
|
+
const context = useMemo(() => ({
|
|
8
|
+
pressed,
|
|
9
|
+
}), [pressed]);
|
|
10
|
+
return (_jsx(CardPressHandlerContext.Provider, { value: context, children: children }));
|
|
11
|
+
};
|
|
12
|
+
CardPressHandler.displayName = 'CardPressHandler';
|
|
13
|
+
export default CardPressHandler;
|
|
@@ -1,21 +1,80 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
3
|
import { Pressable } from 'react-native';
|
|
4
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
5
5
|
import { useStyleProps } from '../../hooks';
|
|
6
6
|
import { CardContext } from './Card.context';
|
|
7
|
+
import CardContent from './CardContent';
|
|
8
|
+
// Helper to check if children contain specific component types
|
|
9
|
+
const checkForComponentType = (children, displayName) => {
|
|
10
|
+
return React.Children.toArray(children).some(child => {
|
|
11
|
+
if (React.isValidElement(child)) {
|
|
12
|
+
// @ts-expect-error - type
|
|
13
|
+
if (child.type.displayName === displayName) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
const childProps = child.props;
|
|
17
|
+
if (childProps.children) {
|
|
18
|
+
return checkForComponentType(childProps.children, displayName);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
// Helper to filter out specific component types from children
|
|
25
|
+
const filterChildren = (children, excludeDisplayName) => {
|
|
26
|
+
return React.Children.map(children, child => {
|
|
27
|
+
if (React.isValidElement(child)) {
|
|
28
|
+
// @ts-expect-error - type
|
|
29
|
+
if (child.type.displayName === excludeDisplayName) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const childProps = child.props;
|
|
33
|
+
if (childProps.children) {
|
|
34
|
+
return React.cloneElement(child, {
|
|
35
|
+
...childProps,
|
|
36
|
+
children: filterChildren(childProps.children, excludeDisplayName),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return child;
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
// Helper to extract specific component types from children
|
|
44
|
+
const extractChildren = (children, includeDisplayName, markFirst = false) => {
|
|
45
|
+
let isFirstFound = false;
|
|
46
|
+
return React.Children.map(children, child => {
|
|
47
|
+
if (React.isValidElement(child)) {
|
|
48
|
+
// @ts-expect-error - type
|
|
49
|
+
if (child.type.displayName === includeDisplayName) {
|
|
50
|
+
const isFirst = markFirst && !isFirstFound;
|
|
51
|
+
if (isFirst) {
|
|
52
|
+
isFirstFound = true;
|
|
53
|
+
}
|
|
54
|
+
return markFirst
|
|
55
|
+
? React.cloneElement(child, { ...(child.props || {}), isFirst })
|
|
56
|
+
: child;
|
|
57
|
+
}
|
|
58
|
+
const childProps = child.props;
|
|
59
|
+
if (childProps.children) {
|
|
60
|
+
return extractChildren(childProps.children, includeDisplayName, markFirst);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
});
|
|
65
|
+
};
|
|
7
66
|
// Helper that recursively collects onPress or other defined handlers from descendants
|
|
8
67
|
const collectChildActionHandlers = (children) => React.Children.toArray(children).reduce((handlers, child) => {
|
|
9
68
|
if (React.isValidElement(child)) {
|
|
10
69
|
const childProps = child.props;
|
|
11
70
|
// @ts-expect-error - type
|
|
12
|
-
if (child.type.displayName === '
|
|
71
|
+
if (child.type.displayName === 'CardPressHandler') {
|
|
13
72
|
const actionChildren = React.Children.toArray(childProps.children);
|
|
14
|
-
const
|
|
73
|
+
const handlerToInherit = childProps['handlerToInherit'] || 'onPress';
|
|
15
74
|
const firstChild = actionChildren[0];
|
|
16
75
|
if (React.isValidElement(firstChild) &&
|
|
17
|
-
typeof firstChild.props[
|
|
18
|
-
handlers.push(firstChild.props[
|
|
76
|
+
typeof firstChild.props[handlerToInherit] === 'function') {
|
|
77
|
+
handlers.push(firstChild.props[handlerToInherit]);
|
|
19
78
|
}
|
|
20
79
|
}
|
|
21
80
|
if (childProps.children) {
|
|
@@ -27,6 +86,8 @@ const collectChildActionHandlers = (children) => React.Children.toArray(children
|
|
|
27
86
|
const Card = ({ children, variant = 'subtle', colorScheme = 'neutralStrong', noPadding = false, style, states, space, disabled = false, onPress, ...rest }) => {
|
|
28
87
|
const { active } = states || { active: false };
|
|
29
88
|
const childActionHandlers = collectChildActionHandlers(children);
|
|
89
|
+
const hasActions = checkForComponentType(children, 'CardAction');
|
|
90
|
+
const hasContent = checkForComponentType(children, 'CardContent');
|
|
30
91
|
// Extract style props using our custom hook
|
|
31
92
|
const { computedStyles, remainingProps } = useStyleProps(rest);
|
|
32
93
|
const handlePress = (e) => {
|
|
@@ -37,19 +98,50 @@ const Card = ({ children, variant = 'subtle', colorScheme = 'neutralStrong', noP
|
|
|
37
98
|
};
|
|
38
99
|
const inheritChildAction = childActionHandlers.length > 0;
|
|
39
100
|
const showPressed = inheritChildAction || !!onPress;
|
|
101
|
+
const filteredChildren = !hasContent && hasActions ? filterChildren(children, 'CardAction') : null;
|
|
102
|
+
// Check if there's any content besides CardActions
|
|
103
|
+
const hasOnlyActions = hasActions &&
|
|
104
|
+
!hasContent &&
|
|
105
|
+
React.Children.toArray(filteredChildren).filter(child => child != null).length === 0;
|
|
106
|
+
const filteredCardActions = !hasContent && hasActions
|
|
107
|
+
? extractChildren(children, 'CardAction', hasOnlyActions)
|
|
108
|
+
: null;
|
|
109
|
+
const context = useMemo(() => ({
|
|
110
|
+
pressed: showPressed && active,
|
|
111
|
+
noPadding,
|
|
112
|
+
hasActions,
|
|
113
|
+
hasContent,
|
|
114
|
+
hasOnlyActions,
|
|
115
|
+
space,
|
|
116
|
+
variant,
|
|
117
|
+
}), [showPressed, active, hasActions, hasContent, hasOnlyActions, noPadding, space, variant]);
|
|
40
118
|
styles.useVariants({
|
|
41
119
|
variant,
|
|
42
120
|
colorScheme,
|
|
43
|
-
noPadding,
|
|
121
|
+
noPadding: noPadding || hasActions || hasContent,
|
|
44
122
|
active,
|
|
45
123
|
showPressed,
|
|
46
124
|
disabled,
|
|
47
|
-
space,
|
|
125
|
+
space: hasActions || hasContent ? 'none' : space,
|
|
48
126
|
});
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
127
|
+
const renderChildren = () => {
|
|
128
|
+
// Default: render children as-is
|
|
129
|
+
if (hasContent || !hasActions) {
|
|
130
|
+
return children;
|
|
131
|
+
}
|
|
132
|
+
// Card has actions but no explicit CardContent
|
|
133
|
+
if (hasOnlyActions) {
|
|
134
|
+
// Only CardActions, no other content - render actions directly
|
|
135
|
+
return filteredCardActions;
|
|
136
|
+
}
|
|
137
|
+
if (filteredChildren) {
|
|
138
|
+
// Has both actions and other content - wrap content and render actions below
|
|
139
|
+
return (_jsxs(_Fragment, { children: [_jsx(CardContent, { children: filteredChildren }), filteredCardActions] }));
|
|
140
|
+
}
|
|
141
|
+
// Fallback
|
|
142
|
+
return children;
|
|
143
|
+
};
|
|
144
|
+
return (_jsx(CardContext.Provider, { value: context, children: _jsx(Pressable, { ...remainingProps, disabled: disabled, style: [styles.card, computedStyles, style], onPress: handlePress, accessible: showPressed, importantForAccessibility: showPressed ? 'yes' : 'no', children: renderChildren() }) }));
|
|
53
145
|
};
|
|
54
146
|
Card.displayName = 'Card';
|
|
55
147
|
const styles = StyleSheet.create(theme => ({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as Card } from './Card';
|
|
2
2
|
export { useCardContext } from './Card.context';
|
|
3
|
-
export
|
|
4
|
-
export { default as
|
|
3
|
+
export * from './CardAction';
|
|
4
|
+
export { default as CardPressHandler } from './CardPressHandler';
|
|
5
|
+
export { useCardPressHandlerContext } from './CardPressHandler.context';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as Card } from './Card';
|
|
2
2
|
export { useCardContext } from './Card.context';
|
|
3
|
-
export
|
|
4
|
-
export { default as
|
|
3
|
+
export * from './CardAction';
|
|
4
|
+
export { default as CardPressHandler } from './CardPressHandler';
|
|
5
|
+
export { useCardPressHandlerContext } from './CardPressHandler.context';
|
|
@@ -5,7 +5,8 @@ import { StyleSheet } from 'react-native-unistyles';
|
|
|
5
5
|
import { Icon } from '../Icon';
|
|
6
6
|
const CheckboxIcon = ({ style, ...props }) => {
|
|
7
7
|
return (_jsx(Icon, { as: TickSmallIcon, ...props, style: Platform.OS === 'web'
|
|
8
|
-
?
|
|
8
|
+
? // @ts-expect-error - style prop type issue
|
|
9
|
+
{ ...styles.icon, ...props.style }
|
|
9
10
|
: [styles.icon, style] }));
|
|
10
11
|
};
|
|
11
12
|
const styles = StyleSheet.create(theme => ({
|
|
@@ -26,9 +26,9 @@ const styles = StyleSheet.create(theme => ({
|
|
|
26
26
|
: undefined,
|
|
27
27
|
marginHorizontal: typeof extra.margin === 'undefined' && typeof extra.marginHorizontal === 'undefined'
|
|
28
28
|
? {
|
|
29
|
-
base: theme.layout.mobile.container.
|
|
30
|
-
md: theme.layout.tablet.container.
|
|
31
|
-
lg: theme.layout.desktop.container.
|
|
29
|
+
base: theme.layout.mobile.container.marginHorizontal,
|
|
30
|
+
md: theme.layout.tablet.container.marginHorizontal,
|
|
31
|
+
lg: theme.layout.desktop.container.marginHorizontal,
|
|
32
32
|
}
|
|
33
33
|
: undefined,
|
|
34
34
|
...extra,
|
|
@@ -38,7 +38,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
38
38
|
input: {
|
|
39
39
|
fontSize: theme.typography.mobile.detailText['4xl'].fontSize,
|
|
40
40
|
fontFamily: theme.typography.mobile.detailText.fontFamily,
|
|
41
|
-
fontWeight: theme.typography.mobile.detailText.fontWeight
|
|
41
|
+
fontWeight: `${theme.typography.mobile.detailText.fontWeight}`,
|
|
42
42
|
paddingTop: 0,
|
|
43
43
|
paddingBottom: 0,
|
|
44
44
|
paddingLeft: 0,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExpandableProps } from './Expandable.props';
|
|
2
|
+
declare const Expandable: {
|
|
3
|
+
({ expanded, onExpandedChange, children, duration, style, accessibilityLabel, testID, animateOpacity, ...props }: ExpandableProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
export default Expandable;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import Animated, { useAnimatedStyle, useDerivedValue, useSharedValue, withTiming, } from 'react-native-reanimated';
|
|
5
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
6
|
+
const Expandable = ({ expanded = false, onExpandedChange, children, duration = 200, style, accessibilityLabel, testID, animateOpacity = true, ...props }) => {
|
|
7
|
+
const height = useSharedValue(0);
|
|
8
|
+
const open = useSharedValue(expanded);
|
|
9
|
+
// Update open value when expanded prop changes and call callback
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (open.value !== expanded) {
|
|
12
|
+
open.value = expanded;
|
|
13
|
+
onExpandedChange?.(expanded);
|
|
14
|
+
}
|
|
15
|
+
}, [expanded, onExpandedChange, open]);
|
|
16
|
+
const derivedHeight = useDerivedValue(() => withTiming(height.value * Number(open.value), {
|
|
17
|
+
duration,
|
|
18
|
+
}));
|
|
19
|
+
const derivedOpacity = useDerivedValue(() => animateOpacity
|
|
20
|
+
? withTiming(Number(open.value), {
|
|
21
|
+
duration,
|
|
22
|
+
})
|
|
23
|
+
: 1);
|
|
24
|
+
const heightStyle = useAnimatedStyle(() => ({
|
|
25
|
+
height: derivedHeight.value,
|
|
26
|
+
}));
|
|
27
|
+
const opacityStyle = useAnimatedStyle(() => ({
|
|
28
|
+
opacity: derivedOpacity.value,
|
|
29
|
+
}));
|
|
30
|
+
return (_jsx(Animated.View, { style: [styles.container, heightStyle, style], accessible: true, accessibilityLabel: accessibilityLabel, accessibilityRole: "none", accessibilityState: { expanded }, testID: testID, ...props, children: _jsx(Animated.View, { style: opacityStyle, children: _jsx(View, { onLayout: e => {
|
|
31
|
+
height.value = e.nativeEvent.layout.height;
|
|
32
|
+
}, style: styles.content, children: children }) }) }));
|
|
33
|
+
};
|
|
34
|
+
Expandable.displayName = 'Expandable';
|
|
35
|
+
const styles = StyleSheet.create(() => ({
|
|
36
|
+
container: {
|
|
37
|
+
overflow: 'hidden',
|
|
38
|
+
},
|
|
39
|
+
content: {
|
|
40
|
+
position: 'absolute',
|
|
41
|
+
width: '100%',
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
export default Expandable;
|