|
9 | 9 | ViewStyle, |
10 | 10 | } from 'react-native'; |
11 | 11 |
|
| 12 | +import type { ThemedComponent } from '@callstack/react-theme-provider'; |
| 13 | + |
12 | 14 | import { withInternalTheme } from '../../core/theming'; |
13 | 15 | import type { InternalTheme } from '../../types'; |
14 | 16 | import Surface from '../Surface'; |
@@ -39,7 +41,7 @@ type HandlePressType = 'in' | 'out'; |
39 | 41 |
|
40 | 42 | type Mode = 'elevated' | 'outlined' | 'contained'; |
41 | 43 |
|
42 | | -export type Props = React.ComponentProps<typeof Surface> & { |
| 44 | +export type CardProps = React.ComponentProps<typeof Surface> & { |
43 | 45 | /** |
44 | 46 | * Mode of the Card. |
45 | 47 | * - `elevated` - Card with elevation. |
@@ -82,6 +84,13 @@ export type Props = React.ComponentProps<typeof Surface> & { |
82 | 84 | accessible?: boolean; |
83 | 85 | }; |
84 | 86 |
|
| 87 | +export type Props = ( |
| 88 | + | OutlinedCardProps |
| 89 | + | ElevatedCardProps |
| 90 | + | ContainedCardProps |
| 91 | +) & |
| 92 | + CardProps; |
| 93 | + |
85 | 94 | /** |
86 | 95 | * A card is a sheet of material that serves as an entry point to more detailed information. |
87 | 96 | * |
@@ -137,7 +146,7 @@ const Card = ({ |
137 | 146 | testID = 'card', |
138 | 147 | accessible, |
139 | 148 | ...rest |
140 | | -}: (OutlinedCardProps | ElevatedCardProps | ContainedCardProps) & Props) => { |
| 149 | +}: Props) => { |
141 | 150 | const isMode = React.useCallback( |
142 | 151 | (modeToCompare: Mode) => { |
143 | 152 | return cardMode === modeToCompare; |
@@ -314,4 +323,9 @@ const styles = StyleSheet.create({ |
314 | 323 | }, |
315 | 324 | }); |
316 | 325 |
|
317 | | -export default withInternalTheme(Card); |
| 326 | +export default withInternalTheme(Card) as ThemedComponent<unknown, Props> & { |
| 327 | + Content: typeof CardContent; |
| 328 | + Actions: typeof CardActions; |
| 329 | + Cover: typeof CardCover; |
| 330 | + Title: typeof CardTitle; |
| 331 | +}; |
0 commit comments