|
1 | 1 | import { Theme } from '@xstyled/system' |
2 | | -import { |
3 | | - AnyStyledComponent, |
4 | | - StyledComponentInnerAttrs, |
5 | | - StyledComponentInnerComponent, |
6 | | - StyledComponentInnerOtherProps, |
7 | | - ThemedStyledFunction, |
8 | | -} from 'styled-components' |
9 | 2 | import type { |
10 | 3 | ReactNativeStyledInterface, |
11 | 4 | ReactNativeThemedStyledFunction, |
12 | 5 | } from 'styled-components/native' |
13 | 6 |
|
14 | | -export type NativeElements = ReactNativeStyledInterface<Theme> |
| 7 | +export type ReactNativeElements = ReactNativeStyledInterface<Theme> |
15 | 8 |
|
16 | | -export type NativeElement<T extends NativeElementsKeys> = |
17 | | - NativeElements[T] extends ReactNativeThemedStyledFunction<infer U, any> |
18 | | - ? U |
19 | | - : never |
| 9 | +export type ReactNativeElementsKeys = keyof ReactNativeElements |
20 | 10 |
|
21 | | -export type NativeElementsKeys = keyof NativeElements |
22 | | - |
23 | | -export interface ReactNativeThemedBaseStyledInterface<T extends object> |
24 | | - extends ReactNativeStyledInterface<Theme> { |
25 | | - <C extends AnyStyledComponent>(component: C): ThemedStyledFunction< |
26 | | - StyledComponentInnerComponent<C>, |
27 | | - T, |
28 | | - StyledComponentInnerOtherProps<C>, |
29 | | - StyledComponentInnerAttrs<C> |
30 | | - > |
31 | | - <C extends React.ComponentType<any>>( |
32 | | - // unfortunately using a conditional type to validate that it can receive a `theme?: Theme` |
33 | | - // causes tests to fail in TS 3.1 |
34 | | - component: C, |
35 | | - ): ThemedStyledFunction<C, T> |
| 11 | +export type ReactNativeBoxElements = { |
| 12 | + [ReactNativeElement in ReactNativeElementsKeys as `${ReactNativeElement}Box`]: ReactNativeElement |
36 | 13 | } |
| 14 | + |
| 15 | +export type ReactNativeElement< |
| 16 | + RNElement extends ReactNativeElementsKeys, |
| 17 | + Theme extends object, |
| 18 | +> = ReactNativeElements[RNElement] extends ReactNativeThemedStyledFunction< |
| 19 | + infer U, |
| 20 | + Theme |
| 21 | +> |
| 22 | + ? U |
| 23 | + : never |
0 commit comments