@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.
Files changed (258) hide show
  1. package/.storybook/main.ts +12 -6
  2. package/.turbo/turbo-build.log +1 -1
  3. package/.turbo/turbo-lint.log +1 -1
  4. package/CHANGELOG.md +18 -0
  5. package/build/components/Banner/Banner.d.ts +6 -0
  6. package/build/components/Banner/Banner.js +161 -0
  7. package/build/components/Banner/Banner.props.d.ts +82 -0
  8. package/build/components/Banner/Banner.props.js +1 -0
  9. package/build/components/Banner/index.d.ts +2 -0
  10. package/build/components/Banner/index.js +1 -0
  11. package/build/components/BottomSheet/BottomSheetBackdrop.js +1 -5
  12. package/build/components/BottomSheet/BottomSheetFlatList.js +1 -5
  13. package/build/components/BottomSheet/BottomSheetHandle.js +1 -5
  14. package/build/components/BottomSheet/useBottomSheetLogic.d.ts +1 -1
  15. package/build/components/Button/ButtonIcon.js +2 -1
  16. package/build/components/Button/ButtonRoot.js +2 -6
  17. package/build/components/Button/ButtonText.js +4 -1
  18. package/build/components/Card/Card.context.d.ts +7 -0
  19. package/build/components/Card/CardAction/CardAction.context.d.ts +9 -0
  20. package/build/components/Card/{CardAction.context.js → CardAction/CardAction.context.js} +7 -1
  21. package/build/components/Card/CardAction/CardAction.d.ts +18 -0
  22. package/build/components/Card/CardAction/CardAction.js +7 -0
  23. package/build/components/Card/CardAction/CardAction.props.d.ts +63 -0
  24. package/build/components/Card/CardAction/CardAction.props.js +1 -0
  25. package/build/components/Card/CardAction/CardActionContent.d.ts +6 -0
  26. package/build/components/Card/CardAction/CardActionContent.js +13 -0
  27. package/build/components/Card/CardAction/CardActionHelperText.d.ts +6 -0
  28. package/build/components/Card/CardAction/CardActionHelperText.js +13 -0
  29. package/build/components/Card/CardAction/CardActionIcon.d.ts +9 -0
  30. package/build/components/Card/CardAction/CardActionIcon.js +19 -0
  31. package/build/components/Card/CardAction/CardActionLeadingContent.d.ts +6 -0
  32. package/build/components/Card/CardAction/CardActionLeadingContent.js +5 -0
  33. package/build/components/Card/CardAction/CardActionRoot.d.ts +12 -0
  34. package/build/components/Card/CardAction/CardActionRoot.js +155 -0
  35. package/build/components/Card/CardAction/CardActionText.d.ts +6 -0
  36. package/build/components/Card/CardAction/CardActionText.js +9 -0
  37. package/build/components/Card/CardAction/CardActionTrailingContent.d.ts +6 -0
  38. package/build/components/Card/CardAction/CardActionTrailingContent.js +5 -0
  39. package/build/components/Card/CardAction/CardActionTrailingIcon.d.ts +9 -0
  40. package/build/components/Card/CardAction/CardActionTrailingIcon.js +19 -0
  41. package/build/components/Card/CardAction/index.d.ts +10 -0
  42. package/build/components/Card/CardAction/index.js +9 -0
  43. package/build/components/Card/CardContent.d.ts +6 -0
  44. package/build/components/Card/CardContent.js +33 -0
  45. package/build/components/Card/CardPressHandler.context.d.ts +6 -0
  46. package/build/components/Card/CardPressHandler.context.js +6 -0
  47. package/build/components/Card/{CardAction.d.ts → CardPressHandler.d.ts} +3 -3
  48. package/build/components/Card/CardPressHandler.js +13 -0
  49. package/build/components/Card/CardRoot.js +103 -11
  50. package/build/components/Card/index.d.ts +3 -2
  51. package/build/components/Card/index.js +3 -2
  52. package/build/components/Checkbox/CheckboxIcon.js +2 -1
  53. package/build/components/Container/Container.js +3 -3
  54. package/build/components/CurrencyInput/CurrencyInput.js +1 -1
  55. package/build/components/Expandable/Expandable.d.ts +6 -0
  56. package/build/components/Expandable/Expandable.js +44 -0
  57. package/build/components/Expandable/Expandable.props.d.ts +38 -0
  58. package/build/components/Expandable/Expandable.props.js +1 -0
  59. package/build/components/Expandable/index.d.ts +2 -0
  60. package/build/components/Expandable/index.js +1 -0
  61. package/build/components/ExpandableCard/ExpandableCard.d.ts +6 -0
  62. package/build/components/ExpandableCard/ExpandableCard.js +23 -0
  63. package/build/components/ExpandableCard/ExpandableCard.props.d.ts +69 -0
  64. package/build/components/ExpandableCard/ExpandableCard.props.js +1 -0
  65. package/build/components/ExpandableCard/ExpandableCardContent.d.ts +6 -0
  66. package/build/components/ExpandableCard/ExpandableCardContent.js +14 -0
  67. package/build/components/ExpandableCard/ExpandableCardExpandedContent.d.ts +11 -0
  68. package/build/components/ExpandableCard/ExpandableCardExpandedContent.js +18 -0
  69. package/build/components/ExpandableCard/ExpandableCardGroup.d.ts +6 -0
  70. package/build/components/ExpandableCard/ExpandableCardGroup.js +17 -0
  71. package/build/components/ExpandableCard/ExpandableCardGroup.props.d.ts +25 -0
  72. package/build/components/ExpandableCard/ExpandableCardGroup.props.js +1 -0
  73. package/build/components/ExpandableCard/ExpandableCardHelperText.d.ts +6 -0
  74. package/build/components/ExpandableCard/ExpandableCardHelperText.js +13 -0
  75. package/build/components/ExpandableCard/ExpandableCardIcon.d.ts +9 -0
  76. package/build/components/ExpandableCard/ExpandableCardIcon.js +19 -0
  77. package/build/components/ExpandableCard/ExpandableCardLeadingContent.d.ts +6 -0
  78. package/build/components/ExpandableCard/ExpandableCardLeadingContent.js +5 -0
  79. package/build/components/ExpandableCard/ExpandableCardText.d.ts +6 -0
  80. package/build/components/ExpandableCard/ExpandableCardText.js +7 -0
  81. package/build/components/ExpandableCard/ExpandableCardTrailingContent.d.ts +6 -0
  82. package/build/components/ExpandableCard/ExpandableCardTrailingContent.js +5 -0
  83. package/build/components/ExpandableCard/ExpandableCardTrailingIcon.d.ts +9 -0
  84. package/build/components/ExpandableCard/ExpandableCardTrailingIcon.js +17 -0
  85. package/build/components/ExpandableCard/ExpandableCardTrigger.d.ts +17 -0
  86. package/build/components/ExpandableCard/ExpandableCardTrigger.js +7 -0
  87. package/build/components/ExpandableCard/ExpandableCardTrigger.props.d.ts +44 -0
  88. package/build/components/ExpandableCard/ExpandableCardTrigger.props.js +1 -0
  89. package/build/components/ExpandableCard/ExpandableCardTriggerRoot.d.ts +11 -0
  90. package/build/components/ExpandableCard/ExpandableCardTriggerRoot.js +91 -0
  91. package/build/components/ExpandableCard/index.d.ts +14 -0
  92. package/build/components/ExpandableCard/index.js +11 -0
  93. package/build/components/Helper/HelperIcon.js +2 -1
  94. package/build/components/HighlightBanner/HighlightBanner.d.ts +6 -0
  95. package/build/components/HighlightBanner/HighlightBanner.js +86 -0
  96. package/build/components/HighlightBanner/HighlightBanner.props.d.ts +14 -0
  97. package/build/components/HighlightBanner/HighlightBanner.props.js +1 -0
  98. package/build/components/HighlightBanner/index.d.ts +2 -0
  99. package/build/components/HighlightBanner/index.js +1 -0
  100. package/build/components/Icon/Icon.d.ts +2 -6
  101. package/build/components/IconButton/IconButtonIcon.js +2 -1
  102. package/build/components/IconContainer/IconContainer.d.ts +4 -3
  103. package/build/components/IconContainer/IconContainer.js +3 -3
  104. package/build/components/Input/InputField.js +4 -2
  105. package/build/components/Input/InputIcon.js +2 -1
  106. package/build/components/Link/LinkIcon.js +3 -2
  107. package/build/components/List/ListAction/ListActionTrailingIcon.js +2 -1
  108. package/build/components/List/ListItem/ListItemIcon.js +2 -1
  109. package/build/components/List/ListItem/ListItemTrailingIcon.js +2 -3
  110. package/build/components/Radio/RadioIcon.js +7 -2
  111. package/build/components/RadioCard/RadioCardIcon.js +3 -2
  112. package/build/components/Spinner/Spinner.web.d.ts +2 -1
  113. package/build/components/Switch/Switch.js +5 -3
  114. package/build/components/Textarea/TextareaField.js +1 -1
  115. package/build/components/ToggleButton/ToggleButtonIcon.js +2 -1
  116. package/build/components/ToggleButton/ToggleButtonRoot.js +2 -2
  117. package/build/components/UnstyledIconButton/UnstyledIconButtonIcon.js +2 -1
  118. package/build/components/index.d.ts +5 -1
  119. package/build/components/index.js +5 -1
  120. package/build/core/index.d.ts +3 -3
  121. package/build/core/index.js +3 -3
  122. package/build/core/themes.d.ts +24 -12
  123. package/build/hooks/useColorMode.d.ts +1 -1
  124. package/build/hooks/useColorMode.js +7 -8
  125. package/build/tokens/components/dark/banner.d.ts +19 -0
  126. package/build/tokens/components/dark/banner.js +19 -0
  127. package/build/tokens/components/dark/card-action.d.ts +11 -0
  128. package/build/tokens/components/dark/card-action.js +10 -0
  129. package/build/tokens/components/dark/card-content.d.ts +25 -0
  130. package/build/tokens/components/dark/card-content.js +24 -0
  131. package/build/tokens/components/dark/drawer.d.ts +29 -0
  132. package/build/tokens/components/dark/drawer.js +28 -0
  133. package/build/tokens/components/dark/illustrations.d.ts +0 -1
  134. package/build/tokens/components/dark/illustrations.js +0 -1
  135. package/build/tokens/components/dark/index.d.ts +3 -0
  136. package/build/tokens/components/dark/index.js +3 -0
  137. package/build/tokens/components/light/banner.d.ts +19 -0
  138. package/build/tokens/components/light/banner.js +19 -0
  139. package/build/tokens/components/light/card-action.d.ts +11 -0
  140. package/build/tokens/components/light/card-action.js +10 -0
  141. package/build/tokens/components/light/card-content.d.ts +25 -0
  142. package/build/tokens/components/light/card-content.js +24 -0
  143. package/build/tokens/components/light/drawer.d.ts +29 -0
  144. package/build/tokens/components/light/drawer.js +28 -0
  145. package/build/tokens/components/light/illustrations.d.ts +0 -1
  146. package/build/tokens/components/light/illustrations.js +0 -1
  147. package/build/tokens/components/light/index.d.ts +3 -0
  148. package/build/tokens/components/light/index.js +3 -0
  149. package/build/tokens/layout.d.ts +6 -6
  150. package/build/tokens/layout.js +3 -3
  151. package/build/tokens/typography.d.ts +6 -0
  152. package/build/tokens/typography.js +3 -0
  153. package/docs/components/AllComponents.web.tsx +75 -4
  154. package/docs/components/NextPrevPage.tsx +5 -5
  155. package/docs/components/VariantTitle.tsx +17 -7
  156. package/package.json +16 -14
  157. package/src/components/Banner/Banner.docs.mdx +402 -0
  158. package/src/components/Banner/Banner.props.ts +106 -0
  159. package/src/components/Banner/Banner.stories.tsx +494 -0
  160. package/src/components/Banner/Banner.tsx +264 -0
  161. package/src/components/Banner/index.ts +2 -0
  162. package/src/components/BottomSheet/BottomSheetBackdrop.tsx +1 -2
  163. package/src/components/BottomSheet/BottomSheetFlatList.tsx +1 -3
  164. package/src/components/BottomSheet/BottomSheetHandle.tsx +0 -1
  165. package/src/components/Button/ButtonIcon.tsx +2 -1
  166. package/src/components/Button/ButtonRoot.tsx +2 -6
  167. package/src/components/Button/ButtonText.tsx +4 -1
  168. package/src/components/Card/Card.context.ts +7 -0
  169. package/src/components/Card/Card.docs.mdx +221 -15
  170. package/src/components/Card/Card.stories.tsx +50 -3
  171. package/src/components/Card/CardAction/CardAction.context.ts +22 -0
  172. package/src/components/Card/CardAction/CardAction.props.ts +87 -0
  173. package/src/components/Card/CardAction/CardAction.stories.tsx +265 -0
  174. package/src/components/Card/CardAction/CardAction.tsx +10 -0
  175. package/src/components/Card/CardAction/CardActionContent.tsx +20 -0
  176. package/src/components/Card/CardAction/CardActionHelperText.tsx +21 -0
  177. package/src/components/Card/CardAction/CardActionIcon.tsx +32 -0
  178. package/src/components/Card/CardAction/CardActionLeadingContent.tsx +9 -0
  179. package/src/components/Card/CardAction/CardActionRoot.tsx +258 -0
  180. package/src/components/Card/CardAction/CardActionText.tsx +17 -0
  181. package/src/components/Card/CardAction/CardActionTrailingContent.tsx +9 -0
  182. package/src/components/Card/CardAction/CardActionTrailingIcon.tsx +32 -0
  183. package/src/components/Card/CardAction/index.ts +10 -0
  184. package/src/components/Card/CardContent.tsx +40 -0
  185. package/src/components/Card/CardPressHandler.context.ts +12 -0
  186. package/src/components/Card/CardPressHandler.tsx +20 -0
  187. package/src/components/Card/CardRoot.tsx +128 -13
  188. package/src/components/Card/index.ts +3 -2
  189. package/src/components/Checkbox/CheckboxIcon.tsx +2 -1
  190. package/src/components/Container/Container.tsx +3 -3
  191. package/src/components/CurrencyInput/CurrencyInput.tsx +1 -1
  192. package/src/components/Expandable/Expandable.docs.mdx +201 -0
  193. package/src/components/Expandable/Expandable.props.ts +46 -0
  194. package/src/components/Expandable/Expandable.stories.tsx +284 -0
  195. package/src/components/Expandable/Expandable.tsx +92 -0
  196. package/src/components/Expandable/index.ts +2 -0
  197. package/src/components/ExpandableCard/ExpandableCard.docs.mdx +312 -0
  198. package/src/components/ExpandableCard/ExpandableCard.props.ts +85 -0
  199. package/src/components/ExpandableCard/ExpandableCard.stories.tsx +326 -0
  200. package/src/components/ExpandableCard/ExpandableCard.tsx +76 -0
  201. package/src/components/ExpandableCard/ExpandableCardContent.tsx +21 -0
  202. package/src/components/ExpandableCard/ExpandableCardExpandedContent.tsx +42 -0
  203. package/src/components/ExpandableCard/ExpandableCardGroup.props.ts +31 -0
  204. package/src/components/ExpandableCard/ExpandableCardGroup.tsx +40 -0
  205. package/src/components/ExpandableCard/ExpandableCardHelperText.tsx +21 -0
  206. package/src/components/ExpandableCard/ExpandableCardIcon.tsx +32 -0
  207. package/src/components/ExpandableCard/ExpandableCardLeadingContent.tsx +9 -0
  208. package/src/components/ExpandableCard/ExpandableCardText.tsx +14 -0
  209. package/src/components/ExpandableCard/ExpandableCardTrailingContent.tsx +9 -0
  210. package/src/components/ExpandableCard/ExpandableCardTrailingIcon.tsx +30 -0
  211. package/src/components/ExpandableCard/ExpandableCardTrigger.props.ts +47 -0
  212. package/src/components/ExpandableCard/ExpandableCardTrigger.tsx +10 -0
  213. package/src/components/ExpandableCard/ExpandableCardTriggerRoot.tsx +154 -0
  214. package/src/components/ExpandableCard/index.ts +14 -0
  215. package/src/components/Helper/HelperIcon.tsx +2 -1
  216. package/src/components/HighlightBanner/HighlightBanner.docs.mdx +277 -0
  217. package/src/components/HighlightBanner/HighlightBanner.props.ts +29 -0
  218. package/src/components/HighlightBanner/HighlightBanner.stories.tsx +259 -0
  219. package/src/components/HighlightBanner/HighlightBanner.tsx +122 -0
  220. package/src/components/HighlightBanner/index.ts +2 -0
  221. package/src/components/Icon/Icon.tsx +4 -3
  222. package/src/components/IconButton/IconButtonIcon.tsx +2 -1
  223. package/src/components/IconContainer/IconContainer.tsx +17 -19
  224. package/src/components/Input/InputField.tsx +2 -1
  225. package/src/components/Input/InputIcon.tsx +2 -1
  226. package/src/components/Link/LinkIcon.tsx +3 -2
  227. package/src/components/List/ListAction/ListActionTrailingIcon.tsx +2 -1
  228. package/src/components/List/ListItem/ListItemIcon.tsx +2 -1
  229. package/src/components/List/ListItem/ListItemTrailingIcon.tsx +2 -3
  230. package/src/components/Radio/RadioIcon.tsx +8 -3
  231. package/src/components/RadioCard/RadioCardIcon.tsx +4 -3
  232. package/src/components/Switch/Switch.tsx +10 -5
  233. package/src/components/Switch/Switch.web.tsx +1 -0
  234. package/src/components/Textarea/TextareaField.tsx +1 -1
  235. package/src/components/ToggleButton/ToggleButtonIcon.tsx +2 -1
  236. package/src/components/ToggleButton/ToggleButtonRoot.tsx +2 -2
  237. package/src/components/UnstyledIconButton/UnstyledIconButtonIcon.tsx +2 -1
  238. package/src/components/index.ts +5 -9
  239. package/src/core/index.ts +14 -11
  240. package/src/hooks/useColorMode.ts +9 -12
  241. package/src/tokens/components/dark/banner.ts +19 -0
  242. package/src/tokens/components/dark/card-action.ts +11 -0
  243. package/src/tokens/components/dark/card-content.ts +25 -0
  244. package/src/tokens/components/dark/drawer.ts +29 -0
  245. package/src/tokens/components/dark/illustrations.ts +0 -1
  246. package/src/tokens/components/dark/index.ts +3 -0
  247. package/src/tokens/components/light/banner.ts +19 -0
  248. package/src/tokens/components/light/card-action.ts +11 -0
  249. package/src/tokens/components/light/card-content.ts +25 -0
  250. package/src/tokens/components/light/drawer.ts +29 -0
  251. package/src/tokens/components/light/illustrations.ts +0 -1
  252. package/src/tokens/components/light/index.ts +3 -0
  253. package/src/tokens/layout.ts +3 -3
  254. package/src/tokens/typography.ts +3 -0
  255. package/build/components/Card/CardAction.context.d.ts +0 -6
  256. package/build/components/Card/CardAction.js +0 -13
  257. package/src/components/Card/CardAction.context.ts +0 -12
  258. package/src/components/Card/CardAction.tsx +0 -18
@@ -0,0 +1,258 @@
1
+ import { ChevronRightSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
2
+ import { useMemo } from 'react';
3
+ import { Pressable, View, ViewStyle } from 'react-native';
4
+ import { StyleSheet } from 'react-native-unistyles';
5
+ import { Badge } from '../../Badge';
6
+ import { IconContainer } from '../../IconContainer';
7
+ import { Skeleton } from '../../Skeleton';
8
+ import { useCardContext } from '../Card.context';
9
+ import { CardActionContext, ICardActionContext } from './CardAction.context';
10
+ import type CardActionProps from './CardAction.props';
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
+
19
+ const CardActionRoot = ({
20
+ heading,
21
+ helperText,
22
+ leadingContent,
23
+ trailingContent,
24
+ disabled,
25
+ loading,
26
+ children,
27
+ states,
28
+ badge,
29
+ badgePosition = 'bottom',
30
+ iconContainer = true,
31
+ iconContainerColor,
32
+ iconContainerVariant,
33
+ leadingIcon,
34
+ trailingIcon = ChevronRightSmallIcon,
35
+ size = 'md',
36
+ ...props
37
+ }: CardActionProps & { states?: { active?: boolean; disabled?: boolean }; isFirst?: boolean }) => {
38
+ const { onPress } = props;
39
+ const { active } = states || { active: false };
40
+
41
+ const isLoading = loading;
42
+ const showPressed = isLoading ? false : !!onPress;
43
+ const isDisabled = disabled || false;
44
+
45
+ const testID = props.testID || 'card-action';
46
+ const loadingTestID = isLoading ? `${testID}-loading` : testID;
47
+
48
+ const { variant, hasOnlyActions } = useCardContext();
49
+ const isFirst = props.isFirst;
50
+
51
+ styles.useVariants({
52
+ showPressed,
53
+ active,
54
+ disabled: isDisabled || isLoading,
55
+ showDisabled: disabled,
56
+ hasIconContainer: !loading && iconContainer,
57
+ variant,
58
+ isFirst: hasOnlyActions && isFirst,
59
+ });
60
+
61
+ const value: ICardActionContext = useMemo(() => {
62
+ return {
63
+ showPressed,
64
+ active: active || false,
65
+ loading: isLoading || false,
66
+ disabled: isDisabled,
67
+ size,
68
+ };
69
+ }, [active, showPressed, isLoading, isDisabled, size]);
70
+
71
+ if (loading) {
72
+ return (
73
+ <Pressable
74
+ {...props}
75
+ testID={loadingTestID}
76
+ style={[styles.container, styles.alignCenter, props.style as ViewStyle]}
77
+ disabled={isDisabled}
78
+ >
79
+ {leadingContent || leadingIcon ? (
80
+ <Skeleton width={24} height={24} style={styles.alignCenter} />
81
+ ) : null}
82
+ <CardActionContent>
83
+ <Skeleton width="80%" height={24} borderRadius="xs" />
84
+ <Skeleton width="100%" height={24} borderRadius="xs" />
85
+ </CardActionContent>
86
+ {trailingIcon || trailingContent ? (
87
+ <Skeleton width={24} height={24} borderRadius="xs" style={styles.alignCenter} />
88
+ ) : null}
89
+ </Pressable>
90
+ );
91
+ }
92
+
93
+ return (
94
+ <CardActionContext.Provider value={value}>
95
+ <Pressable
96
+ {...props}
97
+ testID={testID}
98
+ style={[styles.container, props.style as ViewStyle]}
99
+ disabled={isDisabled}
100
+ accessibilityRole={onPress ? 'button' : undefined}
101
+ >
102
+ {children ? (
103
+ children
104
+ ) : (
105
+ <>
106
+ {leadingIcon && iconContainer ? (
107
+ <View style={styles.iconContainerWrap}>
108
+ <IconContainer
109
+ style={styles.iconContainer}
110
+ icon={leadingIcon}
111
+ variant={iconContainerVariant}
112
+ color={iconContainerColor}
113
+ radiusNone
114
+ />
115
+ </View>
116
+ ) : null}
117
+ <View style={styles.withIconContainer}>
118
+ {leadingContent ? (
119
+ <CardActionLeadingContent>{leadingContent}</CardActionLeadingContent>
120
+ ) : null}
121
+ {leadingIcon && !iconContainer && !leadingContent ? (
122
+ <CardActionLeadingContent>
123
+ <CardActionIcon as={leadingIcon} />
124
+ </CardActionLeadingContent>
125
+ ) : null}
126
+ <CardActionContent>
127
+ {badgePosition === 'top' && badge ? <Badge {...badge} /> : null}
128
+ <CardActionText>{heading}</CardActionText>
129
+ {badgePosition === 'middle' && badge ? <Badge {...badge} /> : null}
130
+ {helperText ? <CardActionHelperText>{helperText}</CardActionHelperText> : null}
131
+ {badgePosition === 'bottom' && badge ? <Badge {...badge} /> : null}
132
+ </CardActionContent>
133
+ {badgePosition === 'right' && badge ? (
134
+ <Badge {...badge} style={[badge.style, styles.alignCenter]} />
135
+ ) : null}
136
+ {trailingContent ? (
137
+ <CardActionTrailingContent>{trailingContent}</CardActionTrailingContent>
138
+ ) : null}
139
+ {trailingIcon && !trailingContent ? (
140
+ <CardActionTrailingContent>
141
+ <CardActionTrailingIcon as={trailingIcon} />
142
+ </CardActionTrailingContent>
143
+ ) : null}
144
+ </View>
145
+ </>
146
+ )}
147
+ </Pressable>
148
+ </CardActionContext.Provider>
149
+ );
150
+ };
151
+
152
+ CardActionRoot.displayName = 'CardActionRoot';
153
+
154
+ const styles = StyleSheet.create(theme => ({
155
+ container: {
156
+ paddingVertical: theme.components.cardAction.content.paddingVertical,
157
+ paddingHorizontal: theme.components.cardAction.content.paddingHorizontal,
158
+ flexDirection: 'row',
159
+ gap: theme.components.cardAction.content.gap,
160
+ borderTopWidth: theme.borderWidth[1],
161
+ borderColor: theme.color.border.strong,
162
+ width: '100%',
163
+ variants: {
164
+ isFirst: {
165
+ true: {
166
+ borderTopWidth: 0,
167
+ },
168
+ },
169
+ disabled: {
170
+ true: {
171
+ cursor: 'auto',
172
+ },
173
+ },
174
+ variant: {
175
+ subtle: {
176
+ borderColor: theme.color.border.subtle,
177
+ },
178
+ emphasis: {
179
+ borderColor: theme.color.border.strong,
180
+ },
181
+ },
182
+ hasIconContainer: {
183
+ true: {
184
+ paddingHorizontal: 0,
185
+ paddingVertical: 0,
186
+ gap: 0,
187
+ },
188
+ },
189
+ showDisabled: {
190
+ true: {
191
+ opacity: theme.opacity.disabled,
192
+ },
193
+ },
194
+ showPressed: {
195
+ true: {
196
+ _web: {
197
+ _hover: {
198
+ backgroundColor: theme.color.interactive.neutral.surface.subtle.hover,
199
+ },
200
+ _active: {
201
+ backgroundColor: theme.color.interactive.neutral.surface.subtle.active,
202
+ },
203
+ },
204
+ },
205
+ false: {
206
+ cursor: 'auto',
207
+ },
208
+ },
209
+ active: {
210
+ true: {},
211
+ },
212
+ },
213
+ compoundVariants: [
214
+ {
215
+ showPressed: true,
216
+ active: true,
217
+ styles: {
218
+ backgroundColor: theme.color.interactive.neutral.surface.subtle.active,
219
+ },
220
+ },
221
+ ],
222
+ },
223
+ withIconContainer: {
224
+ alignItems: 'center',
225
+ flexDirection: 'row',
226
+ paddingVertical: theme.components.list.item.functional.padding,
227
+ paddingHorizontal: theme.components.list.item.functional.padding,
228
+ gap: theme.components.list.item.gap,
229
+ flex: 1,
230
+ variants: {
231
+ hasIconContainer: {
232
+ true: {},
233
+ false: {
234
+ flex: 1,
235
+ paddingHorizontal: 0,
236
+ paddingVertical: 0,
237
+ alignItems: 'center',
238
+ },
239
+ },
240
+ },
241
+ },
242
+ alignCenter: {
243
+ alignSelf: 'center',
244
+ alignItems: 'center',
245
+ },
246
+ iconContainer: {
247
+ flex: 1,
248
+ _web: {
249
+ overflow: 'visible',
250
+ height: '100%',
251
+ },
252
+ },
253
+ iconContainerWrap: {
254
+ flexDirection: 'column',
255
+ },
256
+ }));
257
+
258
+ export default CardActionRoot;
@@ -0,0 +1,17 @@
1
+ import { TextProps } from 'react-native';
2
+ import { BodyText } from '../../BodyText';
3
+ import { useCardActionContext } from './CardAction.context';
4
+
5
+ const CardActionText = ({ children, ...props }: TextProps) => {
6
+ const { size } = useCardActionContext();
7
+
8
+ return (
9
+ <BodyText size={size} weight="semibold" {...props}>
10
+ {children}
11
+ </BodyText>
12
+ );
13
+ };
14
+
15
+ CardActionText.displayName = 'CardActionText';
16
+
17
+ export default CardActionText;
@@ -0,0 +1,9 @@
1
+ import { View, type ViewProps } from 'react-native';
2
+
3
+ const CardActionTrailingContent = ({ children, ...props }: ViewProps) => (
4
+ <View {...props}>{children}</View>
5
+ );
6
+
7
+ CardActionTrailingContent.displayName = 'CardActionTrailingContent';
8
+
9
+ export default CardActionTrailingContent;
@@ -0,0 +1,32 @@
1
+ import { ComponentType } from 'react';
2
+ import { Platform, type StyleProp, type ViewStyle } from 'react-native';
3
+ import { StyleSheet } from 'react-native-unistyles';
4
+ import { Icon, IconProps } from '../../Icon';
5
+
6
+ const CardActionTrailingIcon = ({ children, ...props }: IconProps & { as?: ComponentType }) => {
7
+ return (
8
+ <Icon
9
+ {...props}
10
+ style={
11
+ Platform.OS === 'web'
12
+ ? // @ts-expect-error - style prop type issue
13
+ { ...(styles.icon as StyleProp<ViewStyle>), ...props.style }
14
+ : ([styles.icon as StyleProp<ViewStyle>, props.style] as any)
15
+ }
16
+ >
17
+ {children}
18
+ </Icon>
19
+ );
20
+ };
21
+
22
+ CardActionTrailingIcon.displayName = 'CardActionTrailingIcon';
23
+
24
+ const styles = StyleSheet.create(theme => ({
25
+ icon: {
26
+ color: theme.color.icon.primary,
27
+ minWidth: 20,
28
+ minHeight: 20,
29
+ },
30
+ }));
31
+
32
+ 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,40 @@
1
+ import { View, ViewProps } from 'react-native';
2
+ import { StyleSheet } from 'react-native-unistyles';
3
+ import { useCardContext } from './Card.context';
4
+
5
+ const CardContent = ({ children, style, ...props }: ViewProps) => {
6
+ const { noPadding, space } = useCardContext();
7
+ styles.useVariants({
8
+ noPadding,
9
+ space,
10
+ });
11
+ return (
12
+ <View style={[styles.container, style]} {...props}>
13
+ {children}
14
+ </View>
15
+ );
16
+ };
17
+
18
+ CardContent.displayName = 'CardContent';
19
+
20
+ const styles = StyleSheet.create(theme => ({
21
+ container: {
22
+ variants: {
23
+ space: theme.globalStyle.variants.space,
24
+ noPadding: {
25
+ true: {
26
+ padding: theme.components.card.mobile.paddingNone,
27
+ },
28
+ false: {
29
+ padding: {
30
+ base: theme.components.card.mobile.padding,
31
+ md: theme.components.card.tablet.padding,
32
+ lg: theme.components.card.desktop.padding,
33
+ },
34
+ },
35
+ },
36
+ },
37
+ },
38
+ }));
39
+
40
+ export default CardContent;
@@ -0,0 +1,12 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ interface CardPressHandlerContextProps {
4
+ pressed?: boolean;
5
+ }
6
+
7
+ export const CardPressHandlerContext = createContext<CardPressHandlerContextProps>({});
8
+
9
+ export const useCardPressHandlerContext = (): CardPressHandlerContextProps => {
10
+ const context = useContext(CardPressHandlerContext);
11
+ return context;
12
+ };
@@ -0,0 +1,20 @@
1
+ import { PropsWithChildren, useMemo } from 'react';
2
+ import { useCardContext } from './Card.context';
3
+ import { CardPressHandlerContext } from './CardPressHandler.context';
4
+
5
+ const CardPressHandler = ({ children }: PropsWithChildren<{ handlerToInherit?: string }>) => {
6
+ const { pressed } = useCardContext();
7
+ const context = useMemo(
8
+ () => ({
9
+ pressed,
10
+ }),
11
+ [pressed]
12
+ );
13
+ return (
14
+ <CardPressHandlerContext.Provider value={context}>{children}</CardPressHandlerContext.Provider>
15
+ );
16
+ };
17
+
18
+ CardPressHandler.displayName = 'CardPressHandler';
19
+
20
+ export default CardPressHandler;
@@ -4,6 +4,72 @@ import { StyleSheet } from 'react-native-unistyles';
4
4
  import { useStyleProps } from '../../hooks';
5
5
  import { CardContext } from './Card.context';
6
6
  import CardProps from './Card.props';
7
+ import CardContent from './CardContent';
8
+
9
+ // Helper to check if children contain specific component types
10
+ const checkForComponentType = (children: React.ReactNode, displayName: string): boolean => {
11
+ return React.Children.toArray(children).some(child => {
12
+ if (React.isValidElement(child)) {
13
+ // @ts-expect-error - type
14
+ if (child.type.displayName === displayName) {
15
+ return true;
16
+ }
17
+ const childProps = child.props as any;
18
+ if (childProps.children) {
19
+ return checkForComponentType(childProps.children, displayName);
20
+ }
21
+ }
22
+ return false;
23
+ });
24
+ };
25
+
26
+ // Helper to filter out specific component types from children
27
+ const filterChildren = (children: React.ReactNode, excludeDisplayName: string): React.ReactNode => {
28
+ return React.Children.map(children, child => {
29
+ if (React.isValidElement(child)) {
30
+ // @ts-expect-error - type
31
+ if (child.type.displayName === excludeDisplayName) {
32
+ return null;
33
+ }
34
+ const childProps = child.props as any;
35
+ if (childProps.children) {
36
+ return React.cloneElement(child, {
37
+ ...childProps,
38
+ children: filterChildren(childProps.children, excludeDisplayName),
39
+ });
40
+ }
41
+ }
42
+ return child;
43
+ });
44
+ };
45
+
46
+ // Helper to extract specific component types from children
47
+ const extractChildren = (
48
+ children: React.ReactNode,
49
+ includeDisplayName: string,
50
+ markFirst = false
51
+ ): React.ReactNode => {
52
+ let isFirstFound = false;
53
+ return React.Children.map(children, child => {
54
+ if (React.isValidElement(child)) {
55
+ // @ts-expect-error - type
56
+ if (child.type.displayName === includeDisplayName) {
57
+ const isFirst = markFirst && !isFirstFound;
58
+ if (isFirst) {
59
+ isFirstFound = true;
60
+ }
61
+ return markFirst
62
+ ? React.cloneElement(child, { ...(child.props || {}), isFirst } as any)
63
+ : child;
64
+ }
65
+ const childProps = child.props as any;
66
+ if (childProps.children) {
67
+ return extractChildren(childProps.children, includeDisplayName, markFirst);
68
+ }
69
+ }
70
+ return null;
71
+ });
72
+ };
7
73
 
8
74
  // Helper that recursively collects onPress or other defined handlers from descendants
9
75
  const collectChildActionHandlers = (
@@ -14,15 +80,15 @@ const collectChildActionHandlers = (
14
80
  if (React.isValidElement(child)) {
15
81
  const childProps = child.props as any;
16
82
  // @ts-expect-error - type
17
- if (child.type.displayName === 'CardAction') {
83
+ if (child.type.displayName === 'CardPressHandler') {
18
84
  const actionChildren = React.Children.toArray(childProps.children);
19
- const actionToInherit = childProps['actionToInherit'] || 'onPress';
85
+ const handlerToInherit = childProps['handlerToInherit'] || 'onPress';
20
86
  const firstChild = actionChildren[0];
21
87
  if (
22
88
  React.isValidElement(firstChild) &&
23
- typeof (firstChild.props as any)[actionToInherit] === 'function'
89
+ typeof (firstChild.props as any)[handlerToInherit] === 'function'
24
90
  ) {
25
- handlers.push((firstChild.props as any)[actionToInherit]);
91
+ handlers.push((firstChild.props as any)[handlerToInherit]);
26
92
  }
27
93
  }
28
94
  if (childProps.children) {
@@ -48,6 +114,8 @@ const Card = ({
48
114
  }: CardProps & { states?: { active?: boolean; disabled?: boolean } }) => {
49
115
  const { active } = states || { active: false };
50
116
  const childActionHandlers = collectChildActionHandlers(children as ReactNode);
117
+ const hasActions = checkForComponentType(children as ReactNode, 'CardAction');
118
+ const hasContent = checkForComponentType(children as ReactNode, 'CardContent');
51
119
  // Extract style props using our custom hook
52
120
  const { computedStyles, remainingProps } = useStyleProps(rest);
53
121
 
@@ -62,22 +130,69 @@ const Card = ({
62
130
  const inheritChildAction = childActionHandlers.length > 0;
63
131
  const showPressed = inheritChildAction || !!onPress;
64
132
 
133
+ const filteredChildren =
134
+ !hasContent && hasActions ? filterChildren(children as ReactNode, 'CardAction') : null;
135
+
136
+ // Check if there's any content besides CardActions
137
+ const hasOnlyActions =
138
+ hasActions &&
139
+ !hasContent &&
140
+ React.Children.toArray(filteredChildren).filter(child => child != null).length === 0;
141
+
142
+ const filteredCardActions =
143
+ !hasContent && hasActions
144
+ ? extractChildren(children as ReactNode, 'CardAction', hasOnlyActions)
145
+ : null;
146
+
147
+ const context = useMemo(
148
+ () => ({
149
+ pressed: showPressed && active,
150
+ noPadding,
151
+ hasActions,
152
+ hasContent,
153
+ hasOnlyActions,
154
+ space,
155
+ variant,
156
+ }),
157
+ [showPressed, active, hasActions, hasContent, hasOnlyActions, noPadding, space, variant]
158
+ );
159
+
65
160
  styles.useVariants({
66
161
  variant,
67
162
  colorScheme,
68
- noPadding,
163
+ noPadding: noPadding || hasActions || hasContent,
69
164
  active,
70
165
  showPressed,
71
166
  disabled,
72
- space,
167
+ space: hasActions || hasContent ? 'none' : space,
73
168
  });
74
169
 
75
- const context = useMemo(
76
- () => ({
77
- pressed: showPressed && active,
78
- }),
79
- [showPressed, active]
80
- );
170
+ const renderChildren = () => {
171
+ // Default: render children as-is
172
+ if (hasContent || !hasActions) {
173
+ return children as ReactNode;
174
+ }
175
+
176
+ // Card has actions but no explicit CardContent
177
+ if (hasOnlyActions) {
178
+ // Only CardActions, no other content - render actions directly
179
+ return filteredCardActions as ReactNode;
180
+ }
181
+
182
+ if (filteredChildren) {
183
+ // Has both actions and other content - wrap content and render actions below
184
+ return (
185
+ <>
186
+ <CardContent>{filteredChildren as ReactNode}</CardContent>
187
+ {filteredCardActions as ReactNode}
188
+ </>
189
+ );
190
+ }
191
+
192
+ // Fallback
193
+ return children as ReactNode;
194
+ };
195
+
81
196
  return (
82
197
  <CardContext.Provider value={context}>
83
198
  <Pressable
@@ -88,7 +203,7 @@ const Card = ({
88
203
  accessible={showPressed}
89
204
  importantForAccessibility={showPressed ? 'yes' : 'no'}
90
205
  >
91
- {children}
206
+ {renderChildren()}
92
207
  </Pressable>
93
208
  </CardContext.Provider>
94
209
  );
@@ -1,4 +1,5 @@
1
1
  export { default as Card } from './Card';
2
2
  export { useCardContext } from './Card.context';
3
- export { useCardActionContext } from './CardAction.context';
4
- export { default as CardAction } from './CardAction';
3
+ export * from './CardAction';
4
+ export { default as CardPressHandler } from './CardPressHandler';
5
+ export { useCardPressHandlerContext } from './CardPressHandler.context';
@@ -11,7 +11,8 @@ const CheckboxIcon = ({ style, ...props }: IconProps) => {
11
11
  {...props}
12
12
  style={
13
13
  Platform.OS === 'web'
14
- ? StyleSheet.compose(styles.icon as any, style)
14
+ ? // @ts-expect-error - style prop type issue
15
+ { ...(styles.icon as StyleProp<ViewStyle>), ...props.style }
15
16
  : ([styles.icon as ViewStyle, style] as any)
16
17
  }
17
18
  />
@@ -37,9 +37,9 @@ const styles = StyleSheet.create(theme => ({
37
37
  marginHorizontal:
38
38
  typeof extra.margin === 'undefined' && typeof extra.marginHorizontal === 'undefined'
39
39
  ? {
40
- base: theme.layout.mobile.container.margin,
41
- md: theme.layout.tablet.container.margin,
42
- lg: theme.layout.desktop.container.margin,
40
+ base: theme.layout.mobile.container.marginHorizontal,
41
+ md: theme.layout.tablet.container.marginHorizontal,
42
+ lg: theme.layout.desktop.container.marginHorizontal,
43
43
  }
44
44
  : undefined,
45
45
  ...extra,
@@ -82,7 +82,7 @@ const styles = StyleSheet.create(theme => ({
82
82
  input: {
83
83
  fontSize: theme.typography.mobile.detailText['4xl'].fontSize,
84
84
  fontFamily: theme.typography.mobile.detailText.fontFamily,
85
- fontWeight: theme.typography.mobile.detailText.fontWeight,
85
+ fontWeight: `${theme.typography.mobile.detailText.fontWeight}`,
86
86
  paddingTop: 0,
87
87
  paddingBottom: 0,
88
88
  paddingLeft: 0,