ferns-ui 0.36.4 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/Banner.d.ts +6 -16
  2. package/dist/Banner.js +52 -43
  3. package/dist/Banner.js.map +1 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +1 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/useStoredState.d.ts +1 -0
  8. package/dist/useStoredState.js +33 -0
  9. package/dist/useStoredState.js.map +1 -0
  10. package/package.json +55 -56
  11. package/src/ActionSheet.tsx +1231 -0
  12. package/src/Avatar.tsx +317 -0
  13. package/src/Badge.tsx +65 -0
  14. package/src/Banner.tsx +149 -0
  15. package/src/BlurBox.native.tsx +40 -0
  16. package/src/BlurBox.tsx +31 -0
  17. package/src/Body.tsx +32 -0
  18. package/src/Box.tsx +308 -0
  19. package/src/Button.tsx +219 -0
  20. package/src/Card.tsx +23 -0
  21. package/src/CheckBox.tsx +118 -0
  22. package/src/Common.ts +2743 -0
  23. package/src/Constants.ts +53 -0
  24. package/src/CustomSelect.tsx +85 -0
  25. package/src/DateTimeActionSheet.tsx +409 -0
  26. package/src/DateTimeField.android.tsx +101 -0
  27. package/src/DateTimeField.ios.tsx +83 -0
  28. package/src/DateTimeField.tsx +69 -0
  29. package/src/DecimalRangeActionSheet.tsx +113 -0
  30. package/src/ErrorBoundary.tsx +37 -0
  31. package/src/ErrorPage.tsx +44 -0
  32. package/src/FernsProvider.tsx +21 -0
  33. package/src/Field.tsx +299 -0
  34. package/src/FieldWithLabels.tsx +36 -0
  35. package/src/FlatList.tsx +2 -0
  36. package/src/Form.tsx +182 -0
  37. package/src/HeaderButtons.tsx +107 -0
  38. package/src/Heading.tsx +53 -0
  39. package/src/HeightActionSheet.tsx +104 -0
  40. package/src/Hyperlink.tsx +181 -0
  41. package/src/Icon.tsx +24 -0
  42. package/src/IconButton.tsx +165 -0
  43. package/src/Image.tsx +50 -0
  44. package/src/ImageBackground.tsx +14 -0
  45. package/src/InfoTooltipButton.tsx +23 -0
  46. package/src/Layer.tsx +17 -0
  47. package/src/Link.tsx +17 -0
  48. package/src/Mask.tsx +21 -0
  49. package/src/MediaQuery.ts +46 -0
  50. package/src/Meta.tsx +9 -0
  51. package/src/Modal.tsx +248 -0
  52. package/src/ModalSheet.tsx +58 -0
  53. package/src/NumberPickerActionSheet.tsx +66 -0
  54. package/src/Page.tsx +133 -0
  55. package/src/Permissions.ts +44 -0
  56. package/src/PickerSelect.tsx +553 -0
  57. package/src/Pill.tsx +24 -0
  58. package/src/Pog.tsx +87 -0
  59. package/src/ProgressBar.tsx +55 -0
  60. package/src/ScrollView.tsx +2 -0
  61. package/src/SegmentedControl.tsx +102 -0
  62. package/src/SelectList.tsx +89 -0
  63. package/src/SideDrawer.tsx +62 -0
  64. package/src/Spinner.tsx +20 -0
  65. package/src/SplitPage.native.tsx +160 -0
  66. package/src/SplitPage.tsx +302 -0
  67. package/src/Switch.tsx +19 -0
  68. package/src/Table.tsx +87 -0
  69. package/src/TableHeader.tsx +36 -0
  70. package/src/TableHeaderCell.tsx +76 -0
  71. package/src/TableRow.tsx +87 -0
  72. package/src/TapToEdit.tsx +221 -0
  73. package/src/Text.tsx +131 -0
  74. package/src/TextArea.tsx +16 -0
  75. package/src/TextField.tsx +401 -0
  76. package/src/TextFieldNumberActionSheet.tsx +61 -0
  77. package/src/Toast.tsx +106 -0
  78. package/src/Tooltip.tsx +269 -0
  79. package/src/UnifiedScreens.ts +24 -0
  80. package/src/Unifier.ts +371 -0
  81. package/src/Utilities.tsx +159 -0
  82. package/src/WithLabel.tsx +57 -0
  83. package/src/dayjsExtended.ts +10 -0
  84. package/src/index.tsx +1347 -0
  85. package/src/polyfill.d.ts +11 -0
  86. package/src/tableContext.tsx +80 -0
  87. package/src/useStoredState.ts +39 -0
@@ -0,0 +1,2 @@
1
+ import {FlatList} from "react-native";
2
+ export {FlatList};
package/src/Form.tsx ADDED
@@ -0,0 +1,182 @@
1
+ import React from "react";
2
+
3
+ import {Box} from "./Box";
4
+ import {Button} from "./Button";
5
+ import {IconButton} from "./IconButton";
6
+ import {SelectList} from "./SelectList";
7
+ import {Switch} from "./Switch";
8
+ import {Text} from "./Text";
9
+ import {TextArea} from "./TextArea";
10
+ import {TextField} from "./TextField";
11
+
12
+ function objToJoinedString(obj: any) {
13
+ return Object.keys(obj || {})
14
+ .map((k) => (obj[k] ? k : undefined))
15
+ .filter((v) => v)
16
+ .join(", ");
17
+ }
18
+
19
+ interface FormLineProps {
20
+ name: string;
21
+ value: any;
22
+ onSave: (value: any) => void;
23
+ kind: "boolean" | "string" | "textarea" | "select" | "multiboolean";
24
+ options?: string[];
25
+ }
26
+
27
+ interface FormLineState {
28
+ editing: boolean;
29
+ value: any;
30
+ }
31
+
32
+ export class FormLine extends React.Component<FormLineProps, FormLineState> {
33
+ constructor(props: FormLineProps) {
34
+ super(props);
35
+ this.state = {editing: false, value: ""};
36
+ }
37
+
38
+ renderMultiBoolean() {
39
+ return (
40
+ <>
41
+ <Box marginRight={2}>
42
+ <Text weight="bold">{this.props.name}</Text>
43
+ </Box>
44
+ <Box direction="column" display="flex">
45
+ {Object.keys(this.props.value).map((k) => (
46
+ <>
47
+ <Text weight="bold">{k}</Text>
48
+ <Switch
49
+ id={k}
50
+ switched={this.state.value[k]}
51
+ onChange={() => {
52
+ this.setState({value: {...this.state.value, [k]: !this.state.value[k]}});
53
+ }}
54
+ />
55
+ </>
56
+ ))}
57
+ </Box>
58
+ </>
59
+ );
60
+ }
61
+
62
+ renderBooleanField() {
63
+ return (
64
+ <>
65
+ <Box marginRight={2}>
66
+ <Text weight="bold">{this.props.name}</Text>
67
+ </Box>
68
+ <Switch
69
+ id={this.props.name}
70
+ switched={this.state.value}
71
+ onChange={() => this.setState({value: !this.state.value})}
72
+ />
73
+ </>
74
+ );
75
+ }
76
+
77
+ renderTextField() {
78
+ return (
79
+ <>
80
+ <Box marginRight={2}>
81
+ <Text weight="bold">{this.props.name}</Text>
82
+ </Box>
83
+ <TextField
84
+ id={this.props.name}
85
+ value={this.state.value}
86
+ onChange={(result) => this.setState({value: result.value})}
87
+ />
88
+ </>
89
+ );
90
+ }
91
+
92
+ renderTextArea() {
93
+ return (
94
+ <>
95
+ <Box marginRight={2}>
96
+ <Text weight="bold">{this.props.name}</Text>
97
+ </Box>
98
+ <TextArea
99
+ id={this.props.name}
100
+ value={this.state.value}
101
+ onChange={(result) => this.setState({value: result.value})}
102
+ />
103
+ <Button size="sm" text="Save" onClick={() => this.props.onSave(this.state.value)} />
104
+ </>
105
+ );
106
+ }
107
+
108
+ renderSelect() {
109
+ return (
110
+ <>
111
+ <Box marginRight={2}>
112
+ <Text weight="bold">{this.props.name}</Text>
113
+ </Box>
114
+ <SelectList
115
+ id={this.props.name}
116
+ options={(this.props.options || []).map((o) => ({label: o ?? "---", value: o}))}
117
+ value={this.state.value}
118
+ onChange={(result) => {
119
+ this.setState({value: result});
120
+ }}
121
+ />
122
+ </>
123
+ );
124
+ }
125
+
126
+ render() {
127
+ if (!this.state.editing) {
128
+ let text = this.props.value;
129
+ if (text === undefined) {
130
+ text = " - ";
131
+ }
132
+ if (typeof text === "object") {
133
+ text = objToJoinedString(text);
134
+ }
135
+ return (
136
+ <Box direction="row" display="flex">
137
+ <IconButton
138
+ accessibilityLabel="edit"
139
+ icon="edit"
140
+ iconColor="darkGray"
141
+ prefix="far"
142
+ size="xs"
143
+ onClick={() => this.setState({editing: true, value: this.props.value})}
144
+ />
145
+ <Box marginRight={2}>
146
+ <Text weight="bold">{this.props.name}: </Text>
147
+ </Box>
148
+ <Text>{text}</Text>
149
+ </Box>
150
+ );
151
+ }
152
+ return (
153
+ <Box direction="row" display="flex">
154
+ <IconButton
155
+ accessibilityLabel="edit"
156
+ icon="times"
157
+ iconColor="darkGray"
158
+ prefix="far"
159
+ size="xs"
160
+ onClick={() => this.setState({editing: false})}
161
+ />
162
+ {this.props.kind === "boolean" && this.renderBooleanField()}
163
+ {this.props.kind === "multiboolean" && this.renderMultiBoolean()}
164
+
165
+ {this.props.kind === "string" && this.renderTextField()}
166
+ {this.props.kind === "textarea" && this.renderTextArea()}
167
+ {this.props.kind === "select" && this.renderSelect()}
168
+ <Box width={60}>
169
+ <Button
170
+ color="blue"
171
+ size="sm"
172
+ text="Save"
173
+ onClick={() => {
174
+ this.props.onSave(this.state.value);
175
+ this.setState({editing: false});
176
+ }}
177
+ />
178
+ </Box>
179
+ </Box>
180
+ );
181
+ }
182
+ }
@@ -0,0 +1,107 @@
1
+ import React from "react";
2
+
3
+ import {Box} from "./Box";
4
+ import {Button} from "./Button";
5
+ import {BackButtonInterface, SearchButtonProps} from "./Common";
6
+ import {IconButton} from "./IconButton";
7
+ import {Text} from "./Text";
8
+ import {Unifier} from "./Unifier";
9
+
10
+ interface HeaderButtonProps {
11
+ onClick: () => void;
12
+ text: string;
13
+ }
14
+
15
+ interface HeaderButtonState {}
16
+
17
+ export class HeaderButton extends React.Component<HeaderButtonProps, HeaderButtonState> {
18
+ constructor(props: HeaderButtonProps) {
19
+ super(props);
20
+ this.state = {};
21
+ }
22
+
23
+ render() {
24
+ return (
25
+ <Box marginRight={2}>
26
+ <Button color="primary" text={this.props.text} type="ghost" onClick={this.props.onClick} />
27
+ </Box>
28
+ );
29
+ }
30
+ }
31
+
32
+ export class SearchButton extends React.Component<SearchButtonProps, {}> {
33
+ render() {
34
+ return (
35
+ <Box>
36
+ <IconButton
37
+ accessibilityLabel="search"
38
+ icon="search"
39
+ iconColor={this.props.color || "white"}
40
+ prefix="fas"
41
+ onClick={this.props.onClick}
42
+ />
43
+ </Box>
44
+ );
45
+ }
46
+ }
47
+
48
+ export class BackButton extends React.Component<BackButtonInterface, {}> {
49
+ render() {
50
+ return (
51
+ <Box alignItems="center" justifyContent="center" paddingX={3} width={50}>
52
+ <IconButton
53
+ accessibilityLabel=""
54
+ icon="chevron-left"
55
+ iconColor="white"
56
+ prefix="fas"
57
+ size="md"
58
+ onClick={() => this.props.onBack && this.props.onBack()}
59
+ />
60
+ </Box>
61
+ );
62
+ }
63
+ }
64
+
65
+ export class FilterButton extends React.Component<SearchButtonProps, {}> {
66
+ render() {
67
+ return <Button color="white" text="Filter" type="ghost" onClick={this.props.onClick} />;
68
+ }
69
+ }
70
+
71
+ export class EditButton extends React.Component<SearchButtonProps, {}> {
72
+ render() {
73
+ return (
74
+ <IconButton
75
+ accessibilityLabel="edit"
76
+ icon="pen"
77
+ iconColor={this.props.color}
78
+ prefix="fas"
79
+ onClick={this.props.onClick}
80
+ />
81
+ );
82
+ }
83
+ }
84
+
85
+ export class UseButton extends React.Component<SearchButtonProps, {}> {
86
+ render() {
87
+ return (
88
+ <Button
89
+ text="Use"
90
+ onClick={() => {
91
+ Unifier.utils.haptic();
92
+ this.props.onClick();
93
+ }}
94
+ />
95
+ );
96
+ }
97
+ }
98
+
99
+ export class AddTabButton extends React.Component<SearchButtonProps, {}> {
100
+ render() {
101
+ return (
102
+ <Box color="blue" height={62} width={62} onClick={this.props.onClick}>
103
+ <Text color="darkGray">Add</Text>
104
+ </Box>
105
+ );
106
+ }
107
+ }
@@ -0,0 +1,53 @@
1
+ import React from "react";
2
+ import {Text as NativeText} from "react-native";
3
+
4
+ import {HeadingProps} from "./Common";
5
+ import {Unifier} from "./Unifier";
6
+
7
+ export class Heading extends React.Component<HeadingProps, {}> {
8
+ fontSizes = {
9
+ sm: 20,
10
+ md: 28,
11
+ lg: 36,
12
+ };
13
+
14
+ propsToStyle(): any {
15
+ const style: any = {};
16
+
17
+ // let font = this.props.font || "primary";
18
+ // if (this.props.bold) {
19
+ // font += "Bold";
20
+ // }
21
+ style.fontFamily = Unifier.theme.titleFont;
22
+
23
+ style.fontSize = this.fontSizes[this.props.size || "md"];
24
+ if (this.props.align) {
25
+ style.textAlign = this.props.align;
26
+ }
27
+ if (this.props.color) {
28
+ style.color = Unifier.theme[this.props.color];
29
+ } else {
30
+ style.color = Unifier.theme.darkGray;
31
+ }
32
+ // TODO: might be useful for wrapping/truncating
33
+ // if (this.props.numberOfLines !== 1 && !this.props.inline) {
34
+ // style.flexWrap = "wrap";
35
+ // }
36
+
37
+ return style;
38
+ }
39
+
40
+ render() {
41
+ const lines = 0;
42
+ // if (this.props.numberOfLines) {
43
+ // lines = this.props.numberOfLines;
44
+ // } else if (this.props.inline) {
45
+ // lines = 1;
46
+ // }
47
+ return (
48
+ <NativeText numberOfLines={lines} style={this.propsToStyle()}>
49
+ {this.props.children}
50
+ </NativeText>
51
+ );
52
+ }
53
+ }
@@ -0,0 +1,104 @@
1
+ import {Picker} from "@react-native-picker/picker";
2
+ import range from "lodash/range";
3
+ import React from "react";
4
+
5
+ import {ActionSheet} from "./ActionSheet";
6
+ import {Box} from "./Box";
7
+ import {Button} from "./Button";
8
+ import {OnChangeCallback} from "./Common";
9
+
10
+ const PICKER_HEIGHT = 104;
11
+
12
+ interface HeightActionSheetProps {
13
+ value?: string;
14
+ onChange: OnChangeCallback;
15
+ actionSheetRef: React.RefObject<any>;
16
+ }
17
+
18
+ interface HeightActionSheetState {
19
+ feet: string;
20
+ inches: string;
21
+ }
22
+
23
+ export class HeightActionSheet extends React.Component<
24
+ HeightActionSheetProps,
25
+ HeightActionSheetState
26
+ > {
27
+ constructor(props: HeightActionSheetProps) {
28
+ super(props);
29
+ this.state = {
30
+ feet: String(Math.floor(Number(props.value) / 12)),
31
+ inches: String(Number(props.value) % 12),
32
+ };
33
+ }
34
+
35
+ render() {
36
+ return (
37
+ <ActionSheet ref={this.props.actionSheetRef} bounceOnOpen gestureEnabled>
38
+ <Box marginBottom={8} paddingX={4} width="100%">
39
+ <Box alignItems="end" display="flex" width="100%">
40
+ <Box width="33%">
41
+ <Button
42
+ color="blue"
43
+ size="lg"
44
+ text="Close"
45
+ type="ghost"
46
+ onClick={() => {
47
+ this.props.actionSheetRef?.current?.setModalVisible(false);
48
+ }}
49
+ />
50
+ </Box>
51
+ </Box>
52
+ <Box direction="row" width="100%">
53
+ <Box width="50%">
54
+ <Picker
55
+ itemStyle={{
56
+ height: PICKER_HEIGHT,
57
+ }}
58
+ selectedValue={this.state.feet}
59
+ style={{
60
+ height: PICKER_HEIGHT,
61
+ backgroundColor: "#FFFFFF",
62
+ }}
63
+ onValueChange={(feet) => {
64
+ this.setState({feet: String(feet)});
65
+ this.props.onChange({
66
+ value: String(Number(feet) * 12 + Number(this.state.inches)),
67
+ });
68
+ }}
69
+ >
70
+ {range(4, 8).map((n) => {
71
+ // console.log("FIRST", String(n));
72
+ return <Picker.Item key={String(n)} label={`${String(n)}ft`} value={String(n)} />;
73
+ })}
74
+ </Picker>
75
+ </Box>
76
+ <Box width="50%">
77
+ <Picker
78
+ itemStyle={{
79
+ height: PICKER_HEIGHT,
80
+ }}
81
+ selectedValue={this.state.inches}
82
+ style={{
83
+ height: PICKER_HEIGHT,
84
+ backgroundColor: "#FFFFFF",
85
+ }}
86
+ onValueChange={(inches) => {
87
+ this.setState({inches: String(inches)});
88
+ this.props.onChange({
89
+ value: String(Number(this.state.feet) * 12 + Number(inches)),
90
+ });
91
+ }}
92
+ >
93
+ {range(0, 12).map((n) => {
94
+ // console.log("N", n);
95
+ return <Picker.Item key={String(n)} label={`${String(n)}in`} value={String(n)} />;
96
+ })}
97
+ </Picker>
98
+ </Box>
99
+ </Box>
100
+ </Box>
101
+ </ActionSheet>
102
+ );
103
+ }
104
+ }
@@ -0,0 +1,181 @@
1
+ /**
2
+ * @providesModule Hyperlink
3
+ *
4
+ * Forked from https://github.com/obipawan/react-native-hyperlink
5
+ *
6
+ *
7
+ * MIT License
8
+ *
9
+ * Copyright (c) 2019 Pawan
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in all
19
+ * copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ * SOFTWARE.
28
+ * */
29
+
30
+ import mdurl from "mdurl";
31
+ import React from "react";
32
+ import {Linking, Platform, StyleProp, Text, View} from "react-native";
33
+
34
+ const linkifyLib = require("linkify-it")();
35
+
36
+ const {OS} = Platform;
37
+
38
+ interface Props {
39
+ linkDefault?: boolean;
40
+ linkify?: any;
41
+ linkStyle?: StyleProp<any>;
42
+ linkText?: string | ((url: string) => string);
43
+ onPress?: (url: string) => void;
44
+ onLongPress?: (url: string, text: string) => void;
45
+ injectViewProps?: (url: string) => any;
46
+ children?: React.ReactNode;
47
+ style?: StyleProp<any>;
48
+ }
49
+
50
+ // Leaving this as a class component because it was easier to handle the `pasrse(this)` in `render()`
51
+ class HyperlinkComponent extends React.Component<Props> {
52
+ isTextNested = (component: any) => {
53
+ if (!React.isValidElement(component)) throw new Error("Invalid component");
54
+ const {type: {displayName} = {} as any} = component;
55
+ if (displayName !== "Text") throw new Error("Not a Text component");
56
+ return typeof (component.props as any).children !== "string";
57
+ };
58
+
59
+ linkify = (component: any) => {
60
+ const linkifyIt = this.props.linkify || linkifyLib;
61
+
62
+ if (!linkifyIt.pretest(component.props.children) || !linkifyIt.test(component.props.children))
63
+ return component;
64
+
65
+ const elements = [];
66
+ let _lastIndex = 0;
67
+
68
+ const componentProps = {
69
+ ...component.props,
70
+ ref: undefined,
71
+ key: undefined,
72
+ };
73
+
74
+ try {
75
+ linkifyIt.match(component.props.children).forEach(({index, lastIndex, text, url}: any) => {
76
+ const nonLinkedText = component.props.children.substring(_lastIndex, index);
77
+ nonLinkedText && elements.push(nonLinkedText);
78
+ _lastIndex = lastIndex;
79
+ if (this.props.linkText)
80
+ text =
81
+ typeof this.props.linkText === "function"
82
+ ? this.props.linkText(url)
83
+ : this.props.linkText;
84
+
85
+ const clickHandlerProps: any = {};
86
+ if (OS !== "web") {
87
+ if (this.props.onLongPress) {
88
+ clickHandlerProps.onLongPress = () => (this.props as any).onLongPress(url, text);
89
+ }
90
+ }
91
+ if (this.props.onPress) {
92
+ clickHandlerProps.onPress = () => (this.props as any).onPress(url, text);
93
+ }
94
+
95
+ let injected: any = {};
96
+ if (this.props.injectViewProps) {
97
+ injected = this.props.injectViewProps(url);
98
+ }
99
+
100
+ elements.push(
101
+ <Text
102
+ {...componentProps}
103
+ {...clickHandlerProps}
104
+ key={url + index}
105
+ style={[component.props.style, this.props.linkStyle]}
106
+ {...injected}
107
+ >
108
+ {text}
109
+ </Text>
110
+ );
111
+ });
112
+ elements.push(
113
+ component.props.children.substring(_lastIndex, component.props.children.length)
114
+ );
115
+ return React.cloneElement(component, componentProps, elements);
116
+ } catch (err) {
117
+ return component;
118
+ }
119
+ };
120
+
121
+ parse = (component: any): React.ReactElement => {
122
+ const {props: {children} = {} as any} = component || {};
123
+ if (!children) return component;
124
+
125
+ const componentProps = {
126
+ ...component.props,
127
+ ref: undefined,
128
+ key: undefined,
129
+ };
130
+
131
+ const linkifyIt = this.props.linkify || linkifyLib;
132
+
133
+ return React.cloneElement(
134
+ component,
135
+ componentProps,
136
+ React.Children.map(children, (child) => {
137
+ const {type: {displayName} = {} as any} = child || {};
138
+ if (typeof child === "string" && linkifyIt.pretest(child))
139
+ return this.linkify(
140
+ <Text {...componentProps} style={component.props.style}>
141
+ {child}
142
+ </Text>
143
+ );
144
+ if (displayName === "Text" && !this.isTextNested(child)) return this.linkify(child);
145
+ return this.parse(child);
146
+ })
147
+ );
148
+ };
149
+
150
+ render() {
151
+ const {...viewProps} = this.props;
152
+ delete viewProps.onPress;
153
+ delete viewProps.linkDefault;
154
+ delete viewProps.onLongPress;
155
+ delete viewProps.linkStyle;
156
+
157
+ return (
158
+ <View {...viewProps} style={this.props.style}>
159
+ {!this.props.onPress && !this.props.onLongPress && !this.props.linkStyle
160
+ ? this.props.children
161
+ : this.parse(this).props.children}
162
+ </View>
163
+ );
164
+ }
165
+ }
166
+
167
+ export function Hyperlink(props: Props) {
168
+ const handleLink = (url: string) => {
169
+ const urlObject = mdurl.parse(url);
170
+ urlObject.protocol = urlObject.protocol.toLowerCase();
171
+ const normalizedURL = mdurl.format(urlObject);
172
+
173
+ Linking.canOpenURL(normalizedURL).then(
174
+ (supported) => supported && Linking.openURL(normalizedURL)
175
+ );
176
+ };
177
+
178
+ const onPress = handleLink || props.onPress;
179
+ if (props.linkDefault) return <HyperlinkComponent {...props} onPress={onPress} />;
180
+ return <HyperlinkComponent {...props} />;
181
+ }
package/src/Icon.tsx ADDED
@@ -0,0 +1,24 @@
1
+ import {FontAwesome5} from "@expo/vector-icons";
2
+ import React from "react";
3
+
4
+ import {IconProps, iconSizeToNumber} from "./Common";
5
+ import {Unifier} from "./Unifier";
6
+
7
+ export function initIcons() {
8
+ console.debug("Initializing icons");
9
+ }
10
+
11
+ // TODO: Update <Icon /> to be closer to Expo's Vector Icon, letting multiple icon packs be used, etc.
12
+ export function Icon({color, size, name, prefix}: IconProps): React.ReactElement {
13
+ const iconColor = Unifier.theme[color || "primary"];
14
+ const iconSize = iconSizeToNumber(size);
15
+ return (
16
+ <FontAwesome5
17
+ color={iconColor}
18
+ name={name}
19
+ regular={prefix === "far"}
20
+ size={iconSize}
21
+ solid={!prefix || prefix === "fas"}
22
+ />
23
+ );
24
+ }