1import React, { forwardRef } from 'react'; 2import { StyleSheet, Platform } from 'react-native'; 3import { em } from '../css/units'; 4import Text from '../primitives/Text'; 5import View from '../primitives/View'; 6export const P = forwardRef(({ style, ...props }, ref) => { 7 return React.createElement(Text, { ...props, style: [styles.p, style], ref: ref }); 8}); 9export const B = forwardRef(({ style, ...props }, ref) => { 10 return React.createElement(Text, { ...props, style: [styles.b, style], ref: ref }); 11}); 12export const S = forwardRef(({ style, ...props }, ref) => { 13 return React.createElement(Text, { ...props, style: [styles.s, style], ref: ref }); 14}); 15export const I = forwardRef(({ style, ...props }, ref) => { 16 return React.createElement(Text, { ...props, style: [styles.i, style], ref: ref }); 17}); 18export const Q = forwardRef(({ children, cite, style, ...props }, ref) => { 19 return (React.createElement(Text, { ...props, style: [styles.q, style], ref: ref }, 20 "\"", 21 children, 22 "\"")); 23}); 24export const BlockQuote = forwardRef(({ style, cite, ...props }, ref) => { 25 return React.createElement(View, { ...props, style: [styles.blockQuote, style], ref: ref }); 26}); 27export const BR = forwardRef(({ style, ...props }, ref) => { 28 return React.createElement(Text, { ...props, style: [styles.br, style], ref: ref }); 29}); 30export const Mark = forwardRef(({ style, ...props }, ref) => { 31 return React.createElement(Text, { ...props, style: [styles.mark, style], ref: ref }); 32}); 33export const Code = forwardRef(({ style, ...props }, ref) => { 34 return React.createElement(Text, { ...props, style: [styles.code, style], ref: ref }); 35}); 36function isTextProps(props) { 37 return typeof props.children === 'string'; 38} 39export const Pre = forwardRef((props, ref) => { 40 if (isTextProps(props)) { 41 return React.createElement(Text, { ...props, style: [styles.code, styles.pre, props.style], ref: ref }); 42 } 43 return React.createElement(View, { ...props, style: [styles.pre, props.style], ref: ref }); 44}); 45// Extract dateTime to prevent passing it to the native Text element 46export const Time = forwardRef(({ dateTime, ...props }, ref) => { 47 return React.createElement(Text, { ...props, ref: ref }); 48}); 49export const Strong = B; 50export const Del = S; 51export const EM = I; 52export const Span = Text; 53const styles = StyleSheet.create({ 54 p: { 55 // @ts-ignore 56 marginVertical: em(1), 57 }, 58 b: { 59 fontWeight: 'bold', 60 }, 61 q: { 62 fontStyle: 'italic', 63 }, 64 code: { 65 fontFamily: Platform.select({ default: 'Courier', ios: 'Courier New', android: 'monospace' }), 66 fontWeight: '500', 67 }, 68 pre: { 69 // @ts-ignore 70 marginVertical: em(1), 71 }, 72 blockQuote: { 73 // @ts-ignore 74 marginVertical: em(1), 75 }, 76 br: { 77 width: 0, 78 // @ts-ignore 79 height: em(0.5), 80 }, 81 s: { 82 textDecorationLine: 'line-through', 83 textDecorationStyle: 'solid', 84 }, 85 mark: { 86 backgroundColor: 'yellow', 87 color: 'black', 88 }, 89 i: { 90 fontStyle: 'italic', 91 }, 92}); 93//# sourceMappingURL=Text.js.map