1 | var __rest = (this && this.__rest) || function (s, e) {
|
2 | var t = {};
|
3 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
4 | t[p] = s[p];
|
5 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
6 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
7 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
8 | t[p[i]] = s[p[i]];
|
9 | }
|
10 | return t;
|
11 | };
|
12 | import React from 'react';
|
13 | import { Text, StyleSheet, Platform, } from 'react-native';
|
14 | import { fonts, withTheme } from '../config';
|
15 | import { patchWebProps } from '../helpers';
|
16 | import normalize from '../helpers/normalizeText';
|
17 | const TextElement = (props) => {
|
18 | var _a;
|
19 | const { style, theme, children = '', h1, h2, h3, h4, h1Style, h2Style, h3Style, h4Style } = props, rest = __rest(props, ["style", "theme", "children", "h1", "h2", "h3", "h4", "h1Style", "h2Style", "h3Style", "h4Style"]);
|
20 | return (<Text style={StyleSheet.flatten([
|
21 | Object.assign(Object.assign({}, Platform.select({
|
22 | android: Object.assign({}, fonts.android.regular),
|
23 | })), { color: (_a = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _a === void 0 ? void 0 : _a.black }),
|
24 | style,
|
25 | (h1 || h2 || h3 || h4) && styles.bold,
|
26 | h1 && StyleSheet.flatten([{ fontSize: normalize(40) }, h1Style]),
|
27 | h2 && StyleSheet.flatten([{ fontSize: normalize(34) }, h2Style]),
|
28 | h3 && StyleSheet.flatten([{ fontSize: normalize(28) }, h3Style]),
|
29 | h4 && StyleSheet.flatten([{ fontSize: normalize(22) }, h4Style]),
|
30 | ])} {...patchWebProps(rest)}>
|
31 | {children}
|
32 | </Text>);
|
33 | };
|
34 | TextElement.defaultProps = {
|
35 | h1: false,
|
36 | h2: false,
|
37 | h3: false,
|
38 | h4: false,
|
39 | style: {},
|
40 | h1Style: {},
|
41 | h2Style: {},
|
42 | h3Style: {},
|
43 | h4Style: {},
|
44 | };
|
45 | const styles = StyleSheet.create({
|
46 | bold: Object.assign({}, Platform.select({
|
47 | android: Object.assign({}, fonts.android.bold),
|
48 | })),
|
49 | });
|
50 | export { TextElement };
|
51 | export default withTheme(TextElement, 'Text');
|