ferns-ui 0.23.2 → 0.24.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 (45) hide show
  1. package/dist/ActionSheet.d.ts +7 -5
  2. package/dist/ActionSheet.js +7 -4
  3. package/dist/ActionSheet.js.map +1 -1
  4. package/dist/Avatar.js +2 -2
  5. package/dist/Avatar.js.map +1 -1
  6. package/dist/Box.d.ts +0 -1
  7. package/dist/Box.js +3 -9
  8. package/dist/Box.js.map +1 -1
  9. package/dist/Button.d.ts +2 -1
  10. package/dist/Button.js +3 -3
  11. package/dist/Button.js.map +1 -1
  12. package/dist/Common.d.ts +35 -49
  13. package/dist/Common.js.map +1 -1
  14. package/dist/DateTimeActionSheet.js.map +1 -1
  15. package/dist/DecimalRangeActionSheet.js.map +1 -1
  16. package/dist/ErrorBoundary.d.ts +1 -1
  17. package/dist/HeightActionSheet.js.map +1 -1
  18. package/dist/Image.d.ts +1 -1
  19. package/dist/NumberPickerActionSheet.js.map +1 -1
  20. package/dist/PickerSelect.js.map +1 -1
  21. package/dist/SelectList.d.ts +1 -1
  22. package/dist/SplitPage.js.map +1 -1
  23. package/dist/TapToEdit.js +2 -2
  24. package/dist/TapToEdit.js.map +1 -1
  25. package/dist/Text.d.ts +17 -9
  26. package/dist/Text.js +59 -49
  27. package/dist/Text.js.map +1 -1
  28. package/dist/TextField.js.map +1 -1
  29. package/dist/TextFieldNumberActionSheet.js.map +1 -1
  30. package/dist/Tooltip.js +6 -2
  31. package/dist/Tooltip.js.map +1 -1
  32. package/dist/Unifier.d.ts +3 -3
  33. package/dist/Unifier.js +52 -44
  34. package/dist/Unifier.js.map +1 -1
  35. package/dist/Utilities.d.ts +2 -2
  36. package/dist/index.d.ts +1 -1
  37. package/package.json +67 -60
  38. package/src/ActionSheet.tsx +9 -11
  39. package/src/Avatar.tsx +2 -2
  40. package/src/Box.tsx +7 -13
  41. package/src/Button.tsx +10 -9
  42. package/src/Common.ts +2 -19
  43. package/src/TapToEdit.tsx +1 -1
  44. package/src/Text.tsx +102 -62
  45. package/src/Tooltip.tsx +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ferns-ui",
3
- "version": "0.23.2",
3
+ "version": "0.24.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "scripts": {
@@ -112,96 +112,103 @@
112
112
  "jest-watch-typeahead/testname"
113
113
  ]
114
114
  },
115
- "resolutions": {
116
- "update-input-width": "1.1.1",
117
- "@types/react": "17.0.44"
118
- },
119
115
  "dependencies": {
120
- "expo-image-picker": "^13.3.1",
121
116
  "tsc-watch": "^5.0.3"
122
117
  },
123
118
  "devDependencies": {
124
119
  "@expo/vector-icons": "^13.0.0",
125
- "@react-native-async-storage/async-storage": "^1.17.10",
126
- "@react-native-community/blur": "^4.2.0",
127
- "@react-native-community/datetimepicker": "^6.3.2",
128
- "@react-native-picker/picker": "2.4.4",
129
- "@types/lodash": "^4.14.184",
120
+ "@react-native-async-storage/async-storage": "1.17.11",
121
+ "@react-native-community/blur": "^4.3.0",
122
+ "@react-native-community/datetimepicker": "6.7.3",
123
+ "@react-native-picker/picker": "2.4.8",
130
124
  "@types/mdurl": "^1.0.2",
131
125
  "@types/react-datetime-picker": "^3.4.1",
132
- "@types/react-native": "^0.69.1",
133
- "@types/react-time-picker": "^4.0.2",
126
+ "@types/react-time-picker": "^4.0.3",
134
127
  "@typescript-eslint/eslint-plugin": "^5.34.0",
135
128
  "@typescript-eslint/parser": "^5.34.0",
136
- "eslint": "^8.22.0",
129
+ "eslint": "^8.35.0",
137
130
  "eslint-config-ferns": "^0.4.0",
138
- "eslint-config-prettier": "^8.5.0",
139
- "eslint-plugin-import": "^2.26.0",
131
+ "eslint-config-prettier": "^8.7.0",
132
+ "eslint-plugin-import": "^2.27.5",
140
133
  "eslint-plugin-lodash": "^7.1.0",
141
134
  "eslint-plugin-prettier": "^4.0.0",
142
- "eslint-plugin-react": "^7.29.4",
135
+ "eslint-plugin-react": "^7.32.2",
143
136
  "eslint-plugin-react-hooks": "^4.5.0",
144
137
  "eslint-plugin-react-native": "^4.0.0",
145
- "eslint-plugin-simple-import-sort": "^7.0.0",
138
+ "eslint-plugin-simple-import-sort": "^10.0.0",
146
139
  "eslint-plugin-unused-imports": "2.0.0",
147
- "expo-font": "^10.0.5",
148
- "expo-haptics": "~11.3.0",
149
- "expo-image-manipulator": "^10.4.0",
150
- "expo-image-picker": "^13.3.1",
151
- "libphonenumber-js": "^1.10.19",
140
+ "expo-font": "~11.1.1",
141
+ "expo-haptics": "~12.2.1",
142
+ "expo-image-manipulator": "~11.1.1",
143
+ "expo-image-picker": "~14.1.1",
144
+ "libphonenumber-js": "^1.10.21",
152
145
  "lodash": "^4.17.21",
153
- "mixpanel-browser": "^2.38.0",
154
- "moment-timezone": "^0.5.35",
155
- "prettier": "^2.6.2",
156
- "react": "^18.2.0",
146
+ "mdurl": "^1.0.1",
147
+ "moment-timezone": "^0.5.41",
148
+ "prettier": "^2.8.4",
149
+ "react": "18.2.0",
157
150
  "react-app-polyfill": "^3.0.0",
158
- "react-date-picker": "^9.0.0",
159
- "react-datetime-picker": "^4.0.1",
151
+ "react-date-picker": "^9.2.0",
152
+ "react-datetime-picker": "^4.2.0",
160
153
  "react-dev-utils": "^12.0.1",
161
154
  "react-dom": "18.2.0",
162
- "react-native": "0.69.4",
163
- "react-native-calendars": "^1.1288.2",
164
- "react-native-gesture-handler": "^2.1.0",
155
+ "react-native": "0.71.3",
156
+ "react-native-calendars": "^1.1293.0",
157
+ "react-native-gesture-handler": "~2.9.0",
165
158
  "react-native-modalize": "^2.1.1",
166
- "react-native-permissions": "^3.6.1",
167
- "react-native-picker-select": "^8.0.0",
159
+ "react-native-permissions": "^3.7.3",
160
+ "react-native-picker-select": "^8.0.4",
168
161
  "react-native-portalize": "^1.0.7",
169
- "react-native-svg": "^13.0.0",
162
+ "react-native-svg": "^13.4.0",
170
163
  "react-native-toast-notifications": "^3.3.1",
171
- "react-router": "^6.3.0",
172
- "react-router-dom": "^6.3.0",
173
- "react-time-picker": "^5.0.0",
174
- "typescript": "4.1.5"
164
+ "react-router": "^6.8.2",
165
+ "react-router-dom": "^6.8.2",
166
+ "react-time-picker": "^5.2.0",
167
+ "typescript": "^4.9.4"
175
168
  },
176
169
  "peerDependencies": {
177
170
  "@expo/vector-icons": "^13.0.0",
178
- "@react-native-async-storage/async-storage": "^1.17.10",
179
- "@react-native-community/blur": "^4.2.0",
180
- "@react-native-community/datetimepicker": "^6.3.2",
181
- "@react-native-picker/picker": "2.4.4",
182
- "expo-font": "^10.0.5",
183
- "expo-haptics": "~11.3.0",
184
- "expo-image-manipulator": "^10.4.0",
185
- "expo-image-picker": "^13.3.1",
171
+ "@react-native-async-storage/async-storage": "1.17.11",
172
+ "@react-native-community/blur": "^4.3.0",
173
+ "@react-native-community/datetimepicker": "6.7.3",
174
+ "@react-native-picker/picker": "2.4.8",
175
+ "@typescript-eslint/eslint-plugin": "^5.34.0",
176
+ "@typescript-eslint/parser": "^5.34.0",
177
+ "eslint": "^8.35.0",
178
+ "eslint-config-ferns": "^0.4.0",
179
+ "eslint-config-prettier": "^8.7.0",
180
+ "eslint-plugin-import": "^2.27.5",
181
+ "eslint-plugin-lodash": "^7.1.0",
182
+ "eslint-plugin-prettier": "^4.0.0",
183
+ "eslint-plugin-react": "^7.32.2",
184
+ "eslint-plugin-react-hooks": "^4.5.0",
185
+ "eslint-plugin-react-native": "^4.0.0",
186
+ "eslint-plugin-simple-import-sort": "^10.0.0",
187
+ "eslint-plugin-unused-imports": "2.0.0",
188
+ "expo-font": "~11.1.1",
189
+ "expo-haptics": "~12.2.1",
190
+ "expo-image-manipulator": "~11.1.1",
191
+ "expo-image-picker": "~14.1.1",
192
+ "libphonenumber-js": "^1.10.21",
186
193
  "lodash": "^4.17.21",
187
- "mixpanel-browser": "^2.38.0",
188
- "moment-timezone": "^0.5.35",
189
- "react": "^18.2.0",
194
+ "moment-timezone": "^0.5.41",
195
+ "react": "18.2.0",
190
196
  "react-app-polyfill": "^3.0.0",
191
- "react-datetime-picker": "^4.0.1",
197
+ "react-date-picker": "^9.2.0",
198
+ "react-datetime-picker": "^4.2.0",
192
199
  "react-dev-utils": "^12.0.1",
193
200
  "react-dom": "18.2.0",
194
- "react-native": "0.69.4",
195
- "react-native-calendars": "^1.1288.2",
196
- "react-native-gesture-handler": "^2.1.0",
201
+ "react-native": "0.71.3",
202
+ "react-native-calendars": "^1.1293.0",
203
+ "react-native-gesture-handler": "~2.9.0",
197
204
  "react-native-modalize": "^2.1.1",
198
- "react-native-permissions": "^3.6.1",
199
- "react-native-picker-select": "^8.0.0",
205
+ "react-native-permissions": "^3.7.3",
206
+ "react-native-picker-select": "^8.0.4",
200
207
  "react-native-portalize": "^1.0.7",
201
- "react-native-svg": "^13.0.0",
208
+ "react-native-svg": "^13.4.0",
202
209
  "react-native-toast-notifications": "^3.3.1",
203
- "react-router": "^6.3.0",
204
- "react-router-dom": "^6.3.0",
205
- "react-time-picker": "^5.0.0"
210
+ "react-router": "^6.8.2",
211
+ "react-router-dom": "^6.8.2",
212
+ "react-time-picker": "^5.2.0"
206
213
  }
207
214
  }
@@ -4,6 +4,7 @@ import React, {Component, createRef} from "react";
4
4
  import {
5
5
  Animated,
6
6
  Dimensions,
7
+ EmitterSubscription,
7
8
  findNodeHandle,
8
9
  FlatList,
9
10
  Keyboard,
@@ -491,6 +492,10 @@ export class ActionSheet extends Component<Props, State, any> {
491
492
 
492
493
  actionSheetHeight = 0;
493
494
 
495
+ keyboardDidShowListener: EmitterSubscription | null = null;
496
+
497
+ keyboardDidHideListener: EmitterSubscription | null = null;
498
+
494
499
  prevScroll = 0;
495
500
 
496
501
  timeout: any | null = null;
@@ -910,12 +915,12 @@ export class ActionSheet extends Component<Props, State, any> {
910
915
  };
911
916
 
912
917
  componentDidMount() {
913
- Keyboard.addListener(
918
+ this.keyboardDidShowListener = Keyboard.addListener(
914
919
  Platform.OS === "android" ? "keyboardDidShow" : "keyboardWillShow",
915
920
  this._onKeyboardShow
916
921
  );
917
922
 
918
- Keyboard.addListener(
923
+ this.keyboardDidHideListener = Keyboard.addListener(
919
924
  Platform.OS === "android" ? "keyboardDidHide" : "keyboardWillHide",
920
925
  this._onKeyboardHide
921
926
  );
@@ -1010,15 +1015,8 @@ export class ActionSheet extends Component<Props, State, any> {
1010
1015
  };
1011
1016
 
1012
1017
  componentWillUnmount() {
1013
- Keyboard.removeListener(
1014
- Platform.OS === "android" ? "keyboardDidShow" : "keyboardWillShow",
1015
- this._onKeyboardShow
1016
- );
1017
-
1018
- Keyboard.removeListener(
1019
- Platform.OS === "android" ? "keyboardDidHide" : "keyboardWillHide",
1020
- this._onKeyboardHide
1021
- );
1018
+ this.keyboardDidShowListener?.remove();
1019
+ this.keyboardDidHideListener?.remove();
1022
1020
  }
1023
1021
 
1024
1022
  _onDeviceLayout = async (_event: any) => {
package/src/Avatar.tsx CHANGED
@@ -118,8 +118,8 @@ export const Avatar = (props: AvatarProps): React.ReactElement => {
118
118
  base64: true,
119
119
  });
120
120
 
121
- if (!result.cancelled) {
122
- const resizedImage = await resizeImage(result.uri);
121
+ if (!result.canceled && result.assets) {
122
+ const resizedImage = await resizeImage(result.assets[0].uri);
123
123
  setSrc(resizedImage.uri);
124
124
  if (onChange) {
125
125
  onChange({avatarImageFormat, ...resizedImage});
package/src/Box.tsx CHANGED
@@ -120,10 +120,8 @@ export class Box extends React.Component<BoxProps, {}> {
120
120
  overflow: (value) => {
121
121
  if (value === "scrollY" || value === "scroll") {
122
122
  return {overflow: "scroll"};
123
- } else if (value === "scrollX") {
124
- return {overflow: "scrollX"};
125
123
  }
126
- return {};
124
+ return {overflow: value};
127
125
  },
128
126
  width: (value) => {
129
127
  if (this.props.border && !isNaN(Number(value))) {
@@ -236,14 +234,6 @@ export class Box extends React.Component<BoxProps, {}> {
236
234
  return style;
237
235
  }
238
236
 
239
- renderBox() {
240
- return (
241
- <View style={!this.props.scroll && !this.props.overflow && this.propsToStyle()}>
242
- {this.props.children}
243
- </View>
244
- );
245
- }
246
-
247
237
  render() {
248
238
  let box;
249
239
 
@@ -251,6 +241,7 @@ export class Box extends React.Component<BoxProps, {}> {
251
241
  box = (
252
242
  <TouchableOpacity
253
243
  style={this.propsToStyle()}
244
+ testID={this.props.testID ? `${this.props.testID}-clickable` : undefined}
254
245
  // TODO: refactor this better..
255
246
  onLayout={this.props.onLayout}
256
247
  onPress={() => {
@@ -259,11 +250,14 @@ export class Box extends React.Component<BoxProps, {}> {
259
250
  }}
260
251
  >
261
252
  {this.props.children}
262
- {/* <View pointerEvents="none">{box}</View> */}
263
253
  </TouchableOpacity>
264
254
  );
265
255
  } else {
266
- box = <View style={this.propsToStyle()}>{this.props.children}</View>;
256
+ box = (
257
+ <View style={this.propsToStyle()} testID={this.props.testID}>
258
+ {this.props.children}
259
+ </View>
260
+ );
267
261
  }
268
262
 
269
263
  if (this.props.scroll) {
package/src/Button.tsx CHANGED
@@ -18,9 +18,7 @@ export interface ButtonProps {
18
18
  disabled?: boolean; // default false
19
19
  inline?: boolean; // default false
20
20
  size?: "sm" | "md" | "lg"; // default md
21
-
22
- // Pattern Addition
23
- type?: "solid" | "ghost" | "outline";
21
+ type?: "solid" | "ghost" | "outline"; // default solid
24
22
  loading?: boolean;
25
23
  onClick: any;
26
24
  icon?: IconName;
@@ -30,6 +28,7 @@ export interface ButtonProps {
30
28
  confirmationText?: string;
31
29
  confirmationHeading?: string;
32
30
  shape?: "rounded" | "pill";
31
+ testID?: string;
33
32
  }
34
33
 
35
34
  const buttonTextColor: {[buttonColor: string]: "white" | "darkGray"} = {
@@ -54,21 +53,22 @@ const HEIGHTS = {
54
53
  };
55
54
 
56
55
  export function Button({
57
- disabled,
58
- type,
56
+ disabled = false,
57
+ type = "solid",
59
58
  loading: propsLoading,
60
59
  children,
61
60
  text,
62
- inline,
61
+ inline = false,
63
62
  icon,
64
63
  iconPrefix,
65
- size,
64
+ size = "md",
66
65
  onClick,
67
- color = "lightGray",
66
+ color = "gray",
68
67
  withConfirmation = false,
69
68
  confirmationText = "Are you sure you want to continue?",
70
69
  confirmationHeading = "Confirm",
71
70
  shape = "rounded",
71
+ testID,
72
72
  }: ButtonProps) {
73
73
  const [loading, setLoading] = useState(propsLoading);
74
74
  const [showConfirmation, setShowConfirmation] = useState(false);
@@ -143,8 +143,9 @@ export function Button({
143
143
  borderWidth: type === "outline" ? 2 : 0,
144
144
  opacity: disabled ? 0.4 : 1,
145
145
  flexDirection: "row",
146
- paddingHorizontal: 4 * 2,
146
+ paddingHorizontal: 8 * 2,
147
147
  }}
148
+ testID={testID}
148
149
  onPress={debounce(
149
150
  async () => {
150
151
  Unifier.utils.haptic();
package/src/Common.ts CHANGED
@@ -1817,24 +1817,6 @@ export type IconPrefix = "far" | "fas";
1817
1817
  // | "simple-line"
1818
1818
  // | "feather";
1819
1819
 
1820
- export interface TextProps {
1821
- align?: "left" | "right" | "center" | "justify"; // default "left"
1822
- children?: React.ReactNode;
1823
- color?: AllColors;
1824
-
1825
- inline?: boolean; // default false
1826
- italic?: boolean; // default false
1827
- overflow?: "normal" | "breakWord"; // default "breakWord"
1828
- size?: TextSize; // default "md"
1829
- truncate?: boolean; // default false
1830
- font?: Font;
1831
- underline?: boolean;
1832
-
1833
- numberOfLines?: number;
1834
- skipLinking?: boolean;
1835
- weight?: "bold" | "normal";
1836
- }
1837
-
1838
1820
  export interface ActionBannerProps {
1839
1821
  /** The text to show in the banner. */
1840
1822
  text: string;
@@ -1967,6 +1949,7 @@ export interface BoxProps {
1967
1949
  scrollRef?: any;
1968
1950
  onScroll?: (offsetY: number) => void;
1969
1951
  onLayout?: (event: any) => void;
1952
+ testID?: string;
1970
1953
  }
1971
1954
 
1972
1955
  export type BoxColor = AllColors | "transparent";
@@ -2642,7 +2625,7 @@ export interface PickerProps {
2642
2625
  onValueChange?: (itemValue: any, itemPosition: number) => void;
2643
2626
  selectedValue?: any;
2644
2627
  style?: StyleProp;
2645
- testId?: string;
2628
+ testID?: string;
2646
2629
  itemStyle?: StyleProp;
2647
2630
  enabled?: boolean;
2648
2631
  mode?: "dialog" | "dropdown";
package/src/TapToEdit.tsx CHANGED
@@ -147,7 +147,7 @@ export const TapToEdit = ({
147
147
  </Box>
148
148
  <Box direction="row">
149
149
  <Box>
150
- <Text overflow="breakWord">{displayValue}</Text>
150
+ <Text>{displayValue}</Text>
151
151
  </Box>
152
152
  {editable && (
153
153
  <Box marginLeft={2} onClick={(): void => setEditing(true)}>
package/src/Text.tsx CHANGED
@@ -1,91 +1,131 @@
1
1
  import React from "react";
2
- import {Text as NativeText} from "react-native";
2
+ import {Text as NativeText, TextStyle} from "react-native";
3
3
 
4
- import {TextProps} from "./Common";
4
+ import {AllColors, Font, TextSize} from "./Common";
5
5
  import {Hyperlink} from "./Hyperlink";
6
6
  import {Unifier} from "./Unifier";
7
7
 
8
- export class Text extends React.Component<TextProps, {}> {
9
- fontSizes = {
10
- sm: 12,
11
- md: 14,
12
- lg: 16,
13
- };
8
+ export interface TextProps {
9
+ align?: "left" | "right" | "center" | "justify"; // default "left"
10
+ children?: React.ReactNode;
11
+ color?: AllColors;
12
+ inline?: boolean; // default false
13
+ italic?: boolean; // default false
14
+ overflow?: "normal" | "breakWord"; // deprecated
15
+ size?: TextSize; // default "md"
16
+ truncate?: boolean; // default false
17
+ font?: Font;
18
+ underline?: boolean;
19
+ numberOfLines?: number;
20
+ skipLinking?: boolean;
21
+ weight?: "bold" | "normal";
22
+ testID?: string;
23
+ }
14
24
 
15
- propsToStyle(): any {
16
- const style: any = {};
25
+ const fontSizes = {
26
+ sm: 12,
27
+ md: 14,
28
+ lg: 16,
29
+ };
17
30
 
18
- let font:
19
- | "primaryFont"
20
- | "primaryBoldFont"
21
- | "secondaryFont"
22
- | "secondaryBoldFont"
23
- | "buttonFont"
24
- | "accentFont"
25
- | "accentBoldFont"
26
- | "titleFont" = "primaryFont";
27
- if (this.props.font === "primary" || !this.props.font) {
28
- if (this.props.weight === "bold") {
29
- font = "primaryBoldFont";
31
+ export function Text({
32
+ align = "left",
33
+ children,
34
+ color,
35
+ inline = false,
36
+ italic = false,
37
+ overflow,
38
+ size = "md",
39
+ truncate = false,
40
+ font,
41
+ underline,
42
+ numberOfLines,
43
+ skipLinking,
44
+ testID,
45
+ weight = "normal",
46
+ }: TextProps): React.ReactElement {
47
+ function propsToStyle(): any {
48
+ const style: TextStyle = {};
49
+ if (overflow) {
50
+ console.warn(
51
+ "Text overflow is deprecated. Use `truncate` to cut off the text and add ellipse, otherwise breakWord is the default."
52
+ );
53
+ }
54
+ let computedFont = "primary";
55
+ if (font === "primary" || !font) {
56
+ if (weight === "bold") {
57
+ computedFont = "primaryBoldFont";
30
58
  } else {
31
- font = "primaryFont";
59
+ computedFont = "primaryFont";
32
60
  }
33
- } else if (this.props.font === "secondary") {
34
- if (this.props.weight === "bold") {
35
- font = "secondaryBoldFont";
61
+ } else if (font === "secondary") {
62
+ if (weight === "bold") {
63
+ computedFont = "secondaryBoldFont";
36
64
  } else {
37
- font = "secondaryFont";
65
+ computedFont = "secondaryFont";
38
66
  }
39
- } else if (this.props.font === "button") {
40
- font = "buttonFont";
41
- } else if (this.props.font === "title") {
42
- font = "titleFont";
43
- } else if (this.props.font === "accent") {
44
- if (this.props.weight === "bold") {
45
- font = "accentBoldFont";
67
+ } else if (font === "button") {
68
+ computedFont = "buttonFont";
69
+ } else if (font === "title") {
70
+ computedFont = "titleFont";
71
+ } else if (font === "accent") {
72
+ if (weight === "bold") {
73
+ computedFont = "accentBoldFont";
46
74
  } else {
47
- font = "accentFont";
75
+ computedFont = "accentFont";
48
76
  }
49
77
  }
78
+ if (weight === "bold") {
79
+ style.fontWeight = "bold";
80
+ }
50
81
 
51
- style.fontFamily = Unifier.theme[font];
82
+ style.fontFamily = Unifier.theme[computedFont];
52
83
 
53
- style.fontSize = this.fontSizes[this.props.size || "md"];
54
- if (this.props.align) {
55
- style.textAlign = this.props.align;
84
+ style.fontSize = fontSizes[size || "md"];
85
+ if (align) {
86
+ style.textAlign = align;
56
87
  }
57
- if (this.props.color) {
58
- style.color = Unifier.theme[this.props.color];
88
+ if (color) {
89
+ style.color = Unifier.theme[color];
59
90
  } else {
60
91
  style.color = Unifier.theme.darkGray;
61
92
  }
93
+
94
+ if (italic) {
95
+ style.fontStyle = "italic";
96
+ }
97
+ if (underline) {
98
+ style.textDecorationLine = "underline";
99
+ }
62
100
  // TODO: might be useful for wrapping/truncating
63
- // if (this.props.numberOfLines !== 1 && !this.props.inline) {
101
+ // if (numberOfLines !== 1 && !inline) {
64
102
  // style.flexWrap = "wrap";
65
103
  // }
104
+
66
105
  return style;
67
106
  }
68
107
 
69
- render() {
70
- let lines = 0;
71
- if (this.props.numberOfLines) {
72
- lines = this.props.numberOfLines;
73
- } else if (this.props.inline) {
74
- lines = 1;
75
- }
76
- const inner = (
77
- <NativeText numberOfLines={lines} style={this.propsToStyle()}>
78
- {this.props.children}
79
- </NativeText>
108
+ let lines = 0;
109
+ if (numberOfLines && truncate && numberOfLines > 1) {
110
+ console.error(`Cannot truncate Text and have ${numberOfLines} lines`);
111
+ }
112
+ if (numberOfLines) {
113
+ lines = numberOfLines;
114
+ } else if (inline || truncate) {
115
+ lines = 1;
116
+ }
117
+ const inner = (
118
+ <NativeText numberOfLines={lines} style={propsToStyle()} testID={testID}>
119
+ {children}
120
+ </NativeText>
121
+ );
122
+ if (skipLinking) {
123
+ return inner;
124
+ } else {
125
+ return (
126
+ <Hyperlink linkDefault linkStyle={{textDecorationLine: "underline"}}>
127
+ {inner}
128
+ </Hyperlink>
80
129
  );
81
- if (this.props.skipLinking) {
82
- return inner;
83
- } else {
84
- return (
85
- <Hyperlink linkDefault linkStyle={{textDecorationLine: "underline"}}>
86
- {inner}
87
- </Hyperlink>
88
- );
89
- }
90
130
  }
91
131
  }
package/src/Tooltip.tsx CHANGED
@@ -157,6 +157,10 @@ export const Tooltip = forwardRef((props: TooltipProps, _ref: any) => {
157
157
  }, []);
158
158
 
159
159
  const handleOnLayout = ({nativeEvent: {layout}}: LayoutChangeEvent) => {
160
+ if (childrenWrapperRef?.current && !childrenWrapperRef?.current?.measure) {
161
+ console.error("Tooltip: childrenWrapperRef does not have a measure method.");
162
+ return;
163
+ }
160
164
  childrenWrapperRef?.current?.measure((_x, _y, width, height, pageX, pageY) => {
161
165
  setMeasurement({
162
166
  children: {pageX, pageY, height, width},