1import { ClassAttributes, ComponentProps, ComponentType } from 'react'; 2import { 3 AccessibilityRole, 4 StyleProp, 5 Text as NativeText, 6 TextStyle as NativeTextStyle, 7} from 'react-native'; 8 9// https://github.com/necolas/react-native-web/issues/832 10 11type NativeTextProps = ComponentProps<typeof NativeText> & ClassAttributes<typeof NativeText>; 12 13export interface WebTextStyle { 14 /** string is only available on web */ 15 fontSize?: NativeTextStyle['fontSize'] | string; 16 /** string is only available on web */ 17 lineHeight?: NativeTextStyle['lineHeight'] | string; 18 /** @platform web */ 19 fontFeatureSettings?: string; 20 /** @platform web */ 21 textIndent?: string; 22 /** @platform web */ 23 textOverflow?: string; 24 /** @platform web */ 25 textRendering?: string; 26 /** @platform web */ 27 textTransform?: string; 28 /** @platform web */ 29 unicodeBidi?: string; 30 /** @platform web */ 31 wordWrap?: string; 32} 33 34export type TextStyle = Omit<NativeTextStyle, 'fontSize' | 'lineHeight'> & WebTextStyle; 35 36export type WebTextProps = { 37 style?: StyleProp<TextStyle>; 38 /** @platform web */ 39 tabIndex?: number; 40 accessibilityRole?: 'listitem' | AccessibilityRole; 41}; 42 43export type TextProps = Omit<NativeTextProps, 'style' | 'accessibilityRole'> & WebTextProps; 44 45const Text = NativeText as ComponentType<TextProps>; 46 47export default Text; 48