ferns-ui 0.41.0 → 0.41.2

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 (157) hide show
  1. package/dist/Avatar.js +1 -0
  2. package/dist/Avatar.js.map +1 -1
  3. package/dist/Badge.d.ts +1 -1
  4. package/dist/Badge.js +2 -2
  5. package/dist/Badge.js.map +1 -1
  6. package/dist/Body.d.ts +1 -1
  7. package/dist/Body.js +2 -2
  8. package/dist/Body.js.map +1 -1
  9. package/dist/Button.d.ts +1 -1
  10. package/dist/Button.js +4 -4
  11. package/dist/Button.js.map +1 -1
  12. package/dist/Card.d.ts +1 -1
  13. package/dist/Card.js +2 -2
  14. package/dist/Card.js.map +1 -1
  15. package/dist/CheckBox.d.ts +1 -1
  16. package/dist/CheckBox.js +2 -2
  17. package/dist/CheckBox.js.map +1 -1
  18. package/dist/CustomSelect.js +1 -0
  19. package/dist/CustomSelect.js.map +1 -1
  20. package/dist/DateTimeActionSheet.d.ts +1 -1
  21. package/dist/DateTimeActionSheet.js +8 -7
  22. package/dist/DateTimeActionSheet.js.map +1 -1
  23. package/dist/FernsProvider.d.ts +2 -2
  24. package/dist/FernsProvider.js +2 -2
  25. package/dist/FernsProvider.js.map +1 -1
  26. package/dist/Hyperlink.d.ts +1 -1
  27. package/dist/Hyperlink.js +4 -4
  28. package/dist/Hyperlink.js.map +1 -1
  29. package/dist/Icon.d.ts +1 -1
  30. package/dist/Icon.js +2 -2
  31. package/dist/Icon.js.map +1 -1
  32. package/dist/InfoTooltipButton.d.ts +1 -1
  33. package/dist/InfoTooltipButton.js +2 -2
  34. package/dist/InfoTooltipButton.js.map +1 -1
  35. package/dist/Link.d.ts +1 -1
  36. package/dist/Link.js +2 -2
  37. package/dist/Link.js.map +1 -1
  38. package/dist/Mask.d.ts +1 -1
  39. package/dist/Mask.js +2 -2
  40. package/dist/Mask.js.map +1 -1
  41. package/dist/MobileAddressAutoComplete.js +1 -0
  42. package/dist/MobileAddressAutoComplete.js.map +1 -1
  43. package/dist/ModalSheet.js +1 -0
  44. package/dist/ModalSheet.js.map +1 -1
  45. package/dist/OpenAPIContext.d.ts +1 -1
  46. package/dist/OpenAPIContext.js +4 -3
  47. package/dist/OpenAPIContext.js.map +1 -1
  48. package/dist/PickerSelect.js +1 -0
  49. package/dist/PickerSelect.js.map +1 -1
  50. package/dist/Pill.d.ts +1 -1
  51. package/dist/Pill.js +2 -2
  52. package/dist/Pill.js.map +1 -1
  53. package/dist/Pog.d.ts +1 -1
  54. package/dist/Pog.js +2 -2
  55. package/dist/Pog.js.map +1 -1
  56. package/dist/ProgressBar.d.ts +1 -1
  57. package/dist/ProgressBar.js +2 -2
  58. package/dist/ProgressBar.js.map +1 -1
  59. package/dist/SelectList.d.ts +1 -1
  60. package/dist/SelectList.js +2 -2
  61. package/dist/SelectList.js.map +1 -1
  62. package/dist/Signature.d.ts +1 -1
  63. package/dist/Signature.js +2 -2
  64. package/dist/Signature.js.map +1 -1
  65. package/dist/Signature.native.js +1 -1
  66. package/dist/Signature.native.js.map +1 -1
  67. package/dist/Spinner.d.ts +1 -1
  68. package/dist/Spinner.js +2 -2
  69. package/dist/Spinner.js.map +1 -1
  70. package/dist/SplitPage.js +1 -0
  71. package/dist/SplitPage.js.map +1 -1
  72. package/dist/SplitPage.native.js +1 -0
  73. package/dist/SplitPage.native.js.map +1 -1
  74. package/dist/Switch.d.ts +1 -1
  75. package/dist/Switch.js +2 -2
  76. package/dist/Switch.js.map +1 -1
  77. package/dist/Table.d.ts +2 -2
  78. package/dist/Table.js +2 -2
  79. package/dist/Table.js.map +1 -1
  80. package/dist/TableHeader.d.ts +1 -1
  81. package/dist/TableHeader.js +2 -2
  82. package/dist/TableHeader.js.map +1 -1
  83. package/dist/TableHeaderCell.d.ts +1 -1
  84. package/dist/TableHeaderCell.js +2 -2
  85. package/dist/TableHeaderCell.js.map +1 -1
  86. package/dist/TableRow.d.ts +1 -1
  87. package/dist/TableRow.js +2 -2
  88. package/dist/TableRow.js.map +1 -1
  89. package/dist/TapToEdit.js +1 -1
  90. package/dist/TapToEdit.js.map +1 -1
  91. package/dist/Text.d.ts +1 -1
  92. package/dist/Text.js +2 -2
  93. package/dist/Text.js.map +1 -1
  94. package/dist/TextArea.d.ts +1 -1
  95. package/dist/TextArea.js +2 -2
  96. package/dist/TextArea.js.map +1 -1
  97. package/dist/TextField.d.ts +1 -1
  98. package/dist/TextField.js +2 -2
  99. package/dist/TextField.js.map +1 -1
  100. package/dist/Toast.d.ts +1 -1
  101. package/dist/Toast.js +2 -2
  102. package/dist/Toast.js.map +1 -1
  103. package/dist/Tooltip.js +1 -0
  104. package/dist/Tooltip.js.map +1 -1
  105. package/dist/Unifier.js +5 -5
  106. package/dist/Unifier.js.map +1 -1
  107. package/dist/WebAddressAutocomplete.js +1 -0
  108. package/dist/WebAddressAutocomplete.js.map +1 -1
  109. package/dist/WithLabel.d.ts +1 -1
  110. package/dist/WithLabel.js +2 -2
  111. package/dist/WithLabel.js.map +1 -1
  112. package/dist/tableContext.d.ts +1 -1
  113. package/dist/tableContext.js +2 -2
  114. package/dist/tableContext.js.map +1 -1
  115. package/package.json +9 -23
  116. package/src/Avatar.tsx +1 -0
  117. package/src/Badge.tsx +3 -3
  118. package/src/Body.tsx +3 -3
  119. package/src/Button.tsx +5 -5
  120. package/src/Card.tsx +2 -2
  121. package/src/CheckBox.tsx +3 -3
  122. package/src/CustomSelect.tsx +1 -0
  123. package/src/DateTimeActionSheet.tsx +10 -9
  124. package/src/FernsProvider.tsx +2 -2
  125. package/src/Hyperlink.tsx +4 -4
  126. package/src/Icon.tsx +2 -2
  127. package/src/InfoTooltipButton.tsx +2 -2
  128. package/src/Link.tsx +2 -2
  129. package/src/Mask.tsx +2 -2
  130. package/src/MobileAddressAutoComplete.tsx +1 -0
  131. package/src/ModalSheet.tsx +1 -0
  132. package/src/OpenAPIContext.tsx +4 -3
  133. package/src/PickerSelect.tsx +1 -0
  134. package/src/Pill.tsx +2 -2
  135. package/src/Pog.tsx +2 -2
  136. package/src/ProgressBar.tsx +2 -2
  137. package/src/SelectList.tsx +3 -3
  138. package/src/Signature.native.tsx +1 -0
  139. package/src/Signature.tsx +2 -2
  140. package/src/Spinner.tsx +2 -2
  141. package/src/SplitPage.native.tsx +1 -0
  142. package/src/SplitPage.tsx +1 -0
  143. package/src/Switch.tsx +7 -2
  144. package/src/Table.tsx +3 -3
  145. package/src/TableHeader.tsx +3 -3
  146. package/src/TableHeaderCell.tsx +3 -3
  147. package/src/TableRow.tsx +3 -3
  148. package/src/TapToEdit.tsx +1 -1
  149. package/src/Text.tsx +3 -3
  150. package/src/TextArea.tsx +2 -2
  151. package/src/TextField.tsx +3 -3
  152. package/src/Toast.tsx +2 -2
  153. package/src/Tooltip.tsx +1 -0
  154. package/src/Unifier.ts +5 -5
  155. package/src/WebAddressAutocomplete.tsx +1 -0
  156. package/src/WithLabel.tsx +3 -3
  157. package/src/tableContext.tsx +3 -3
package/src/CheckBox.tsx CHANGED
@@ -5,7 +5,7 @@ import {BoxColor, CheckBoxProps} from "./Common";
5
5
  import {Icon} from "./Icon";
6
6
  import {Text} from "./Text";
7
7
 
8
- export function CheckBox({
8
+ export const CheckBox = ({
9
9
  color,
10
10
  checked,
11
11
  size,
@@ -18,7 +18,7 @@ export function CheckBox({
18
18
  onClick,
19
19
  indeterminate,
20
20
  testID,
21
- }: CheckBoxProps): React.ReactElement {
21
+ }: CheckBoxProps): React.ReactElement => {
22
22
  if (checked && indeterminate) {
23
23
  console.error("CheckBox cannot be checked and indeterminate at the same time");
24
24
  }
@@ -117,4 +117,4 @@ export function CheckBox({
117
117
  </Box>
118
118
  </Box>
119
119
  );
120
- }
120
+ };
@@ -23,6 +23,7 @@ export const CustomSelect = ({
23
23
  return ![...options, {value: ""}].map((i) => i.value).includes(customValue);
24
24
  }, [options, customValue]);
25
25
 
26
+ // If the value is set to custom, show the custom input
26
27
  useEffect(() => {
27
28
  setShowCustomInput(isValueCustom);
28
29
  if (!showCustomInput) {
@@ -22,7 +22,7 @@ const hours = range(1, 13).map((n) => String(n));
22
22
  const minutes = range(0, 60).map((n) => String(n).padStart(2, "0"));
23
23
  const minutesOptions = [...minutes, "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
24
24
 
25
- function TimeInput({
25
+ const TimeInput = ({
26
26
  type,
27
27
  value,
28
28
  onChange,
@@ -30,7 +30,7 @@ function TimeInput({
30
30
  type: "hour" | "minute";
31
31
  value: number;
32
32
  onChange: (value: number) => void;
33
- }): React.ReactElement {
33
+ }): React.ReactElement => {
34
34
  const {theme} = useContext(ThemeContext);
35
35
 
36
36
  const defaultText = type === "minute" ? String(value).padStart(2, "0") : String(value);
@@ -98,15 +98,15 @@ function TimeInput({
98
98
  />
99
99
  </View>
100
100
  );
101
- }
101
+ };
102
102
 
103
- function CalendarHeader({
103
+ const CalendarHeader = ({
104
104
  addMonth,
105
105
  month,
106
106
  }: {
107
107
  addMonth: (num: number) => void;
108
108
  month: Date[];
109
- }): React.ReactElement {
109
+ }): React.ReactElement => {
110
110
  const displayDate = dayjs(month[0]).format("MMM YYYY");
111
111
  return (
112
112
  <Box alignItems="center" direction="row" height={40} justifyContent="between" width="100%">
@@ -153,7 +153,7 @@ function CalendarHeader({
153
153
  />
154
154
  </Box>
155
155
  );
156
- }
156
+ };
157
157
 
158
158
  // For mobile, renders all components in an action sheet. For web, renders all components in a
159
159
  // modal. For mobile: If mode is "time", renders a spinner picker for time picker on both platforms.
@@ -161,14 +161,14 @@ function CalendarHeader({
161
161
  // renders a spinner picker for time picker and our custom calendar on both platforms. For web,
162
162
  // renders a simplistic text box for time picker and a calendar for date picker in a modal In the
163
163
  // future, web time picker should be a typeahead dropdown like Google calendar.
164
- export function DateTimeActionSheet({
164
+ export const DateTimeActionSheet = ({
165
165
  // actionSheetRef,
166
166
  mode,
167
167
  value,
168
168
  onChange,
169
169
  visible,
170
170
  onDismiss,
171
- }: DateTimeActionSheetProps) {
171
+ }: DateTimeActionSheetProps) => {
172
172
  const {theme} = useContext(ThemeContext);
173
173
 
174
174
  // Accept ISO 8601, HH:mm, or hh:mm A formats. We may want only HH:mm or hh:mm A for mode=time
@@ -193,6 +193,7 @@ export function DateTimeActionSheet({
193
193
  const [amPm, setAmPm] = useState<"am" | "pm">(dayjs(m).format("a") === "am" ? "am" : "pm");
194
194
  const [date, setDate] = useState<string>(dayjs(m).toISOString());
195
195
 
196
+ // If the value changes in the props, update the state for the date and time.
196
197
  useEffect(() => {
197
198
  let datetime;
198
199
  if (value) {
@@ -398,4 +399,4 @@ export function DateTimeActionSheet({
398
399
  {renderContent()}
399
400
  </Modal>
400
401
  );
401
- }
402
+ };
@@ -5,7 +5,7 @@ import {ToastProvider} from "react-native-toast-notifications";
5
5
  import {ThemeProvider} from "./Theme";
6
6
  import {Toast} from "./Toast";
7
7
 
8
- export function FernsProvider({children}: {children: React.ReactNode}): React.ReactElement {
8
+ export const FernsProvider = ({children}: {children: React.ReactNode}): React.ReactElement => {
9
9
  return (
10
10
  <ThemeProvider>
11
11
  <ToastProvider
@@ -21,4 +21,4 @@ export function FernsProvider({children}: {children: React.ReactNode}): React.Re
21
21
  </ToastProvider>
22
22
  </ThemeProvider>
23
23
  );
24
- }
24
+ };
package/src/Hyperlink.tsx CHANGED
@@ -27,7 +27,7 @@
27
27
  * SOFTWARE.
28
28
  * */
29
29
 
30
- import mdurl from "mdurl";
30
+ import * as mdurl from "mdurl";
31
31
  import React from "react";
32
32
  import {Linking, Platform, Text, View} from "react-native";
33
33
 
@@ -104,7 +104,7 @@ class HyperlinkComponent extends React.Component<HyperlinkProps> {
104
104
  component.props.children.substring(_lastIndex, component.props.children.length)
105
105
  );
106
106
  return React.cloneElement(component, componentProps, elements);
107
- } catch (err) {
107
+ } catch (error) {
108
108
  return component;
109
109
  }
110
110
  };
@@ -155,7 +155,7 @@ class HyperlinkComponent extends React.Component<HyperlinkProps> {
155
155
  }
156
156
  }
157
157
 
158
- export function Hyperlink(props: HyperlinkProps) {
158
+ export const Hyperlink = (props: HyperlinkProps) => {
159
159
  const handleLink = (url: string) => {
160
160
  const urlObject = mdurl.parse(url);
161
161
  urlObject.protocol = urlObject.protocol.toLowerCase();
@@ -169,4 +169,4 @@ export function Hyperlink(props: HyperlinkProps) {
169
169
  const onPress = handleLink || props.onPress;
170
170
  if (props.linkDefault) return <HyperlinkComponent {...props} onPress={onPress} />;
171
171
  return <HyperlinkComponent {...props} />;
172
- }
172
+ };
package/src/Icon.tsx CHANGED
@@ -10,7 +10,7 @@ export function initIcons() {
10
10
 
11
11
  // TODO: Update <Icon /> to be closer to Expo's Vector Icon, letting multiple icon packs be used,
12
12
  // etc.
13
- export function Icon({color, size, name, prefix, testID}: IconProps): React.ReactElement {
13
+ export const Icon = ({color, size, name, prefix, testID}: IconProps): React.ReactElement => {
14
14
  const {theme} = useContext(ThemeContext);
15
15
  const iconColor = theme[color || "primary"];
16
16
  const iconSize = iconSizeToNumber(size);
@@ -24,4 +24,4 @@ export function Icon({color, size, name, prefix, testID}: IconProps): React.Reac
24
24
  testID={testID}
25
25
  />
26
26
  );
27
- }
27
+ };
@@ -3,7 +3,7 @@ import React from "react";
3
3
  import {InfoTooltipButtonProps} from "./Common";
4
4
  import {IconButton} from "./IconButton";
5
5
 
6
- export function InfoTooltipButton({text, size}: InfoTooltipButtonProps): React.ReactElement {
6
+ export const InfoTooltipButton = ({text, size}: InfoTooltipButtonProps): React.ReactElement => {
7
7
  return (
8
8
  <IconButton
9
9
  accessibilityLabel="info"
@@ -15,4 +15,4 @@ export function InfoTooltipButton({text, size}: InfoTooltipButtonProps): React.R
15
15
  onClick={() => {}}
16
16
  />
17
17
  );
18
- }
18
+ };
package/src/Link.tsx CHANGED
@@ -4,10 +4,10 @@ import {Linking} from "react-native";
4
4
  import {LinkProps} from "./Common";
5
5
  import {Text} from "./Text";
6
6
 
7
- export function Link(props: LinkProps): React.ReactElement {
7
+ export const Link = (props: LinkProps): React.ReactElement => {
8
8
  return (
9
9
  <Text {...props} color={props.color || "blue"} onPress={() => Linking.openURL(props.href)}>
10
10
  {props.children}
11
11
  </Text>
12
12
  );
13
- }
13
+ };
package/src/Mask.tsx CHANGED
@@ -3,7 +3,7 @@ import {View} from "react-native";
3
3
 
4
4
  import {MaskProps, ReactChildren} from "./Common";
5
5
 
6
- export function Mask(props: MaskProps): ReactChildren {
6
+ export const Mask = (props: MaskProps): ReactChildren => {
7
7
  if (props.shape === "rounded") {
8
8
  return <View style={{overflow: "hidden", borderRadius: 12}}>{props.children}</View>;
9
9
  } else if (props.shape === "circle") {
@@ -18,4 +18,4 @@ export function Mask(props: MaskProps): ReactChildren {
18
18
  } else {
19
19
  return props.children || null;
20
20
  }
21
- }
21
+ };
@@ -26,6 +26,7 @@ export const MobileAddressAutocomplete = ({
26
26
  const ref = useRef<GooglePlacesAutocompleteRef | null>(null);
27
27
  const [isFocused, setIsFocused] = useState(false);
28
28
 
29
+ // Load the Google Maps script and initialize the autocomplete.
29
30
  useEffect(() => {
30
31
  if (!googleMapsApiKey) return;
31
32
  if (ref?.current) {
@@ -7,6 +7,7 @@ import {Portal} from "react-native-portalize";
7
7
  export const useCombinedRefs = (...refs: any) => {
8
8
  const targetRef = useRef();
9
9
 
10
+ // Iterate through the refs array, and set the ref.current value to the targetRef
10
11
  useEffect(() => {
11
12
  refs.forEach((ref: any) => {
12
13
  if (!ref) {
@@ -37,7 +37,7 @@ interface OpenAPIProviderProps {
37
37
  specUrl?: string;
38
38
  }
39
39
 
40
- export function OpenAPIProvider({children, specUrl}: OpenAPIProviderProps): React.ReactElement {
40
+ export const OpenAPIProvider = ({children, specUrl}: OpenAPIProviderProps): React.ReactElement => {
41
41
  const [spec, setSpec] = useState<OpenAPISpec | null>(null);
42
42
 
43
43
  const getModelFields = (modelName: string): ModelFields | null => {
@@ -71,6 +71,7 @@ export function OpenAPIProvider({children, specUrl}: OpenAPIProviderProps): Reac
71
71
  return field;
72
72
  };
73
73
 
74
+ // Fetch the OpenAPI spec from the provided URL.
74
75
  useEffect((): void => {
75
76
  if (!specUrl) {
76
77
  return;
@@ -81,7 +82,7 @@ export function OpenAPIProvider({children, specUrl}: OpenAPIProviderProps): Reac
81
82
  const data = (await response.json()) as OpenAPISpec;
82
83
  setSpec(data);
83
84
  })
84
- .catch((err) => console.error(`Error fetching OpenAPI spec: ${err}`));
85
+ .catch((error: any) => console.error(`Error fetching OpenAPI spec: ${error}`));
85
86
  }, [specUrl]);
86
87
 
87
88
  return (
@@ -89,7 +90,7 @@ export function OpenAPIProvider({children, specUrl}: OpenAPIProviderProps): Reac
89
90
  {children}
90
91
  </OpenAPIContext.Provider>
91
92
  );
92
- }
93
+ };
93
94
 
94
95
  export const useOpenAPISpec = () => {
95
96
  const context = useContext(OpenAPIContext);
@@ -210,6 +210,7 @@ export function RNPickerSelect({
210
210
  [options]
211
211
  );
212
212
 
213
+ // Set selected item
213
214
  useEffect(() => {
214
215
  const item = getSelectedItem(itemKey, value);
215
216
  setSelectedItem(item.selectedItem);
package/src/Pill.tsx CHANGED
@@ -4,7 +4,7 @@ import {Box} from "./Box";
4
4
  import {PillProps} from "./Common";
5
5
  import {Text} from "./Text";
6
6
 
7
- export function Pill({onClick, enabled, color = "white", text}: PillProps): React.ReactElement {
7
+ export const Pill = ({onClick, enabled, color = "white", text}: PillProps): React.ReactElement => {
8
8
  return (
9
9
  <Box
10
10
  border={color}
@@ -19,4 +19,4 @@ export function Pill({onClick, enabled, color = "white", text}: PillProps): Reac
19
19
  </Text>
20
20
  </Box>
21
21
  );
22
- }
22
+ };
package/src/Pog.tsx CHANGED
@@ -23,7 +23,7 @@ const defaultIconButtonIconColors = {
23
23
  white: "gray",
24
24
  };
25
25
 
26
- export function Pog(props: PogProps) {
26
+ export const Pog = (props: PogProps) => {
27
27
  const {
28
28
  bgColor = "transparent",
29
29
  iconColor,
@@ -72,4 +72,4 @@ export function Pog(props: PogProps) {
72
72
  </Box>
73
73
  </div>
74
74
  );
75
- }
75
+ };
@@ -4,7 +4,7 @@ import {View} from "react-native";
4
4
  import {ProgressBarProps} from "./Common";
5
5
  import {ThemeContext} from "./Theme";
6
6
 
7
- export function ProgressBar({color, completed}: ProgressBarProps): React.ReactElement {
7
+ export const ProgressBar = ({color, completed}: ProgressBarProps): React.ReactElement => {
8
8
  const {theme} = useContext(ThemeContext);
9
9
 
10
10
  return (
@@ -44,4 +44,4 @@ export function ProgressBar({color, completed}: ProgressBarProps): React.ReactEl
44
44
  />
45
45
  </View>
46
46
  );
47
- }
47
+ };
@@ -21,7 +21,7 @@ export interface SelectListProps extends FieldWithLabelsProps {
21
21
  style?: StyleProp<RNPickerSelectProps["style"]>;
22
22
  }
23
23
 
24
- export function SelectList({
24
+ export const SelectList = ({
25
25
  options,
26
26
  value,
27
27
  onChange,
@@ -30,7 +30,7 @@ export function SelectList({
30
30
  style,
31
31
  placeholder,
32
32
  disabled,
33
- }: SelectListProps) {
33
+ }: SelectListProps) => {
34
34
  const {theme} = useContext(ThemeContext);
35
35
 
36
36
  const withLabelProps = {label, labelColor};
@@ -87,4 +87,4 @@ export function SelectList({
87
87
  />
88
88
  </WithLabel>
89
89
  );
90
- }
90
+ };
@@ -35,6 +35,7 @@ export const Signature: React.FC<Props> = ({onChange, onStart, onEnd}: Props) =>
35
35
  <Box border="black" height={100}>
36
36
  <SignatureScreen
37
37
  ref={ref}
38
+ trimWhitespace
38
39
  webStyle={style}
39
40
  onBegin={onBegin}
40
41
  onEnd={handleEnd}
package/src/Signature.tsx CHANGED
@@ -10,7 +10,7 @@ export interface SignatureProps {
10
10
  onEnd?: () => void;
11
11
  }
12
12
 
13
- export function Signature({onChange}: SignatureProps): ReactElement | null {
13
+ export const Signature = ({onChange}: SignatureProps): ReactElement | null => {
14
14
  const ref = useRef<SignatureCanvas>(null);
15
15
 
16
16
  const onClear = () => {
@@ -33,4 +33,4 @@ export function Signature({onChange}: SignatureProps): ReactElement | null {
33
33
  </Box>
34
34
  </Box>
35
35
  );
36
- }
36
+ };
package/src/Spinner.tsx CHANGED
@@ -3,7 +3,7 @@ import {ActivityIndicator} from "react-native";
3
3
 
4
4
  import {SpinnerProps} from "./Common";
5
5
 
6
- export function Spinner({size, color}: SpinnerProps): ReactElement | null {
6
+ export const Spinner = ({size, color}: SpinnerProps): ReactElement | null => {
7
7
  const [show, setShow] = useState(false);
8
8
 
9
9
  // The delay is for perceived performance. You don't want to show a spinner when you're doing a
@@ -18,4 +18,4 @@ export function Spinner({size, color}: SpinnerProps): ReactElement | null {
18
18
  }
19
19
  const spinnerSize: "small" | "large" = size === "sm" ? "small" : "large";
20
20
  return <ActivityIndicator color={color ?? "darkGray"} size={spinnerSize} />;
21
- }
21
+ };
@@ -48,6 +48,7 @@ export const SplitPage = ({
48
48
  await onSelectionChange(undefined);
49
49
  }, [onSelectionChange]);
50
50
 
51
+ // If the list is showing, deselect the item.
51
52
  useEffect(() => {
52
53
  if (showItemList) {
53
54
  void onItemDeselect();
package/src/SplitPage.tsx CHANGED
@@ -52,6 +52,7 @@ export const SplitPage = ({
52
52
  await onSelectionChange(undefined);
53
53
  }, [onSelectionChange]);
54
54
 
55
+ // If the list is showing, deselect the item.
55
56
  useEffect(() => {
56
57
  if (showItemList) {
57
58
  void onItemDeselect();
package/src/Switch.tsx CHANGED
@@ -4,10 +4,15 @@ import {Switch as NativeSwitch} from "react-native";
4
4
  import {SwitchProps} from "./Common";
5
5
  import {WithLabel} from "./WithLabel";
6
6
 
7
- export function Switch({disabled, switched, onChange, ...rest}: SwitchProps): React.ReactElement {
7
+ export const Switch = ({
8
+ disabled,
9
+ switched,
10
+ onChange,
11
+ ...rest
12
+ }: SwitchProps): React.ReactElement => {
8
13
  return (
9
14
  <WithLabel labelAlignItems="center" labelInline labelJustifyContent="between" {...rest}>
10
15
  <NativeSwitch disabled={disabled} value={switched} onValueChange={onChange} />
11
16
  </WithLabel>
12
17
  );
13
- }
18
+ };
package/src/Table.tsx CHANGED
@@ -5,14 +5,14 @@ import {TableProps} from "./Common";
5
5
  import {ScrollView} from "./ScrollView";
6
6
  import {ColumnSortInterface, TableContextProvider} from "./tableContext";
7
7
 
8
- export function Table({
8
+ export const Table = ({
9
9
  children,
10
10
  columns,
11
11
  borderStyle,
12
12
  alternateRowBackground = true,
13
13
  maxHeight,
14
14
  stickyHeader = true,
15
- }: TableProps): React.ReactElement {
15
+ }: TableProps): React.ReactElement => {
16
16
  const arrayChildren = Children.toArray(children);
17
17
  const [sortColumn, setSortColumn] = React.useState<ColumnSortInterface | undefined>(undefined);
18
18
 
@@ -60,4 +60,4 @@ export function Table({
60
60
  </ScrollView>
61
61
  </TableContextProvider>
62
62
  );
63
- }
63
+ };
@@ -7,14 +7,14 @@ import {TableRow} from "./TableRow";
7
7
  /**
8
8
  * Use TableHeader to group the header content in Table.
9
9
  */
10
- export function TableHeader({
10
+ export const TableHeader = ({
11
11
  children,
12
12
  display = "tableHeaderGroup",
13
13
  color,
14
- }: TableHeaderProps): React.ReactElement {
14
+ }: TableHeaderProps): React.ReactElement => {
15
15
  return (
16
16
  <Box color={color ?? "white"} display={display === "visuallyHidden" ? "none" : "flex"}>
17
17
  <TableRow headerRow>{children}</TableRow>
18
18
  </Box>
19
19
  );
20
- }
20
+ };
@@ -8,12 +8,12 @@ import {useTableContext} from "./tableContext";
8
8
  /**
9
9
  * Use TableHeaderCell to define a header cell in Table.
10
10
  */
11
- export function TableHeaderCell({
11
+ export const TableHeaderCell = ({
12
12
  children,
13
13
  index,
14
14
  sortable,
15
15
  onSortChange,
16
- }: TableHeaderCellProps): ReactElement {
16
+ }: TableHeaderCellProps): ReactElement => {
17
17
  const {columns, setSortColumn, sortColumn} = useTableContext();
18
18
  const width = columns[index];
19
19
  if (!width) {
@@ -69,4 +69,4 @@ export function TableHeaderCell({
69
69
  </Box>
70
70
  );
71
71
  }
72
- }
72
+ };
package/src/TableRow.tsx CHANGED
@@ -8,13 +8,13 @@ import {useTableContext} from "./tableContext";
8
8
  /**
9
9
  * Use TableRow to define a row in Table.
10
10
  */
11
- export function TableRow({
11
+ export const TableRow = ({
12
12
  children,
13
13
  headerRow = false,
14
14
  expanded,
15
15
  drawerContents,
16
16
  color = "white",
17
- }: TableRowProps): React.ReactElement {
17
+ }: TableRowProps): React.ReactElement => {
18
18
  const [isExpanded, setIsExpanded] = React.useState(expanded || false);
19
19
  const {columns, hasDrawerContents} = useTableContext();
20
20
  const rowRef = useRef<typeof Box>(null);
@@ -61,4 +61,4 @@ export function TableRow({
61
61
  )}
62
62
  </Box>
63
63
  );
64
- }
64
+ };
package/src/TapToEdit.tsx CHANGED
@@ -160,7 +160,7 @@ export const TapToEdit = ({
160
160
  try {
161
161
  const url = new URL(value);
162
162
  displayValue = url?.hostname ?? value;
163
- } catch (e) {
163
+ } catch (error) {
164
164
  // Don't print an error message for empty values.
165
165
  if (value) {
166
166
  console.debug(`Invalid URL: ${value}`);
package/src/Text.tsx CHANGED
@@ -12,7 +12,7 @@ const fontSizes = {
12
12
  lg: 16,
13
13
  };
14
14
 
15
- export function Text({
15
+ export const Text = ({
16
16
  align = "left",
17
17
  children,
18
18
  color,
@@ -28,7 +28,7 @@ export function Text({
28
28
  skipLinking,
29
29
  testID,
30
30
  weight = "normal",
31
- }: TextProps): React.ReactElement {
31
+ }: TextProps): React.ReactElement => {
32
32
  const {theme} = useContext(ThemeContext);
33
33
 
34
34
  function propsToStyle(): any {
@@ -115,4 +115,4 @@ export function Text({
115
115
  </Hyperlink>
116
116
  );
117
117
  }
118
- }
118
+ };
package/src/TextArea.tsx CHANGED
@@ -3,6 +3,6 @@ import React from "react";
3
3
  import {TextAreaProps} from "./Common";
4
4
  import {TextField} from "./TextField";
5
5
 
6
- export function TextArea({height, ...rest}: TextAreaProps): React.ReactElement {
6
+ export const TextArea = ({height, ...rest}: TextAreaProps): React.ReactElement => {
7
7
  return <TextField {...rest} height={height ?? 100} multiline />;
8
- }
8
+ };
package/src/TextField.tsx CHANGED
@@ -59,7 +59,7 @@ const textContentMap: {
59
59
  username: "username",
60
60
  };
61
61
 
62
- export function TextField({
62
+ export const TextField = ({
63
63
  blurOnSubmit = true,
64
64
  value,
65
65
  height: propsHeight,
@@ -86,7 +86,7 @@ export function TextField({
86
86
  onEnter,
87
87
  onSubmitEditing,
88
88
  testID,
89
- }: TextFieldProps): ReactElement {
89
+ }: TextFieldProps): ReactElement => {
90
90
  const {theme} = useContext(ThemeContext);
91
91
 
92
92
  const dateActionSheetRef: React.RefObject<any> = React.createRef();
@@ -404,4 +404,4 @@ export function TextField({
404
404
  )}
405
405
  </>
406
406
  );
407
- }
407
+ };
package/src/Toast.tsx CHANGED
@@ -34,7 +34,7 @@ export function useToast(): any {
34
34
  };
35
35
  }
36
36
 
37
- export function Toast({message, data}: ToastProps): React.ReactElement {
37
+ export const Toast = ({message, data}: ToastProps): React.ReactElement => {
38
38
  // margin 8 on either side, times the standard 4px we multiply by.
39
39
  const width = Math.min(Dimensions.get("window").width - 16 * 4, 712);
40
40
  const {variant, buttonText, buttonOnClick, persistent, onDismiss} = data ?? {};
@@ -89,4 +89,4 @@ export function Toast({message, data}: ToastProps): React.ReactElement {
89
89
  )}
90
90
  </Box>
91
91
  );
92
- }
92
+ };
package/src/Tooltip.tsx CHANGED
@@ -138,6 +138,7 @@ export const Tooltip = (props: TooltipProps) => {
138
138
 
139
139
  const isWeb = Platform.OS === "web";
140
140
 
141
+ // If the tooltip is visible, and the user clicks outside of the tooltip, hide it.
141
142
  React.useEffect(() => {
142
143
  return () => {
143
144
  if (showTooltipTimer.current) {
package/src/Unifier.ts CHANGED
@@ -151,8 +151,8 @@ class UnifierClass {
151
151
  } else {
152
152
  return null;
153
153
  }
154
- } catch (e) {
155
- console.error(`[storage] Error reading ${key}`, e);
154
+ } catch (error) {
155
+ console.error(`[storage] Error reading ${key}`, error);
156
156
  return defaultValue || null;
157
157
  }
158
158
  },
@@ -160,9 +160,9 @@ class UnifierClass {
160
160
  try {
161
161
  const jsonValue = JSON.stringify(item);
162
162
  await AsyncStorage.setItem(key, jsonValue);
163
- } catch (e) {
164
- console.error(`[storage] Error storing ${key}`, item, e);
165
- throw new Error(e as any);
163
+ } catch (error) {
164
+ console.error(`[storage] Error storing ${key}`, item, error);
165
+ throw new Error(error as any);
166
166
  }
167
167
  },
168
168
  };
@@ -34,6 +34,7 @@ export const WebAddressAutocomplete = ({
34
34
  const [scriptLoaded, setScriptLoaded] = useState(true);
35
35
  const autocompleteInputRef = useRef(null);
36
36
 
37
+ // Load the Google Maps script and initialize the autocomplete.
37
38
  useEffect(() => {
38
39
  const callbackName = "initAutocomplete";
39
40
  if (!googleMapsApiKey) {