ferns-ui 0.39.0 → 0.39.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 (197) hide show
  1. package/dist/ActionSheet.d.ts +2 -317
  2. package/dist/ActionSheet.js.map +1 -1
  3. package/dist/Avatar.d.ts +1 -70
  4. package/dist/Avatar.js +4 -4
  5. package/dist/Avatar.js.map +1 -1
  6. package/dist/Badge.d.ts +1 -8
  7. package/dist/Badge.js.map +1 -1
  8. package/dist/Banner.d.ts +1 -14
  9. package/dist/Banner.js.map +1 -1
  10. package/dist/Body.d.ts +2 -10
  11. package/dist/Body.js.map +1 -1
  12. package/dist/Box.js +4 -4
  13. package/dist/Box.js.map +1 -1
  14. package/dist/Button.d.ts +1 -24
  15. package/dist/Button.js.map +1 -1
  16. package/dist/Card.d.ts +1 -3
  17. package/dist/Card.js +14 -4
  18. package/dist/Card.js.map +1 -1
  19. package/dist/CheckBox.d.ts +1 -1
  20. package/dist/CheckBox.js +2 -2
  21. package/dist/CheckBox.js.map +1 -1
  22. package/dist/Common.d.ts +713 -371
  23. package/dist/Common.js +0 -35
  24. package/dist/Common.js.map +1 -1
  25. package/dist/CustomSelect.d.ts +1 -12
  26. package/dist/CustomSelect.js +6 -3
  27. package/dist/CustomSelect.js.map +1 -1
  28. package/dist/DateTimeActionSheet.d.ts +1 -10
  29. package/dist/DateTimeActionSheet.js +8 -10
  30. package/dist/DateTimeActionSheet.js.map +1 -1
  31. package/dist/DecimalRangeActionSheet.d.ts +1 -13
  32. package/dist/DecimalRangeActionSheet.js.map +1 -1
  33. package/dist/ErrorBoundary.d.ts +1 -1
  34. package/dist/ErrorPage.d.ts +1 -5
  35. package/dist/ErrorPage.js.map +1 -1
  36. package/dist/Field.d.ts +2 -20
  37. package/dist/Field.js +15 -15
  38. package/dist/Field.js.map +1 -1
  39. package/dist/Form.d.ts +1 -7
  40. package/dist/Form.js.map +1 -1
  41. package/dist/Heading.d.ts +1 -1
  42. package/dist/Heading.js +2 -2
  43. package/dist/Heading.js.map +1 -1
  44. package/dist/HeightActionSheet.d.ts +1 -6
  45. package/dist/HeightActionSheet.js.map +1 -1
  46. package/dist/Hyperlink.d.ts +2 -14
  47. package/dist/Hyperlink.js +2 -1
  48. package/dist/Hyperlink.js.map +1 -1
  49. package/dist/Icon.d.ts +1 -1
  50. package/dist/Icon.js +4 -3
  51. package/dist/Icon.js.map +1 -1
  52. package/dist/IconButton.d.ts +1 -24
  53. package/dist/IconButton.js +6 -6
  54. package/dist/IconButton.js.map +1 -1
  55. package/dist/InfoTooltipButton.d.ts +1 -6
  56. package/dist/InfoTooltipButton.js.map +1 -1
  57. package/dist/Link.d.ts +1 -5
  58. package/dist/Link.js.map +1 -1
  59. package/dist/MobileAddressAutoComplete.d.ts +2 -11
  60. package/dist/MobileAddressAutoComplete.js +2 -2
  61. package/dist/MobileAddressAutoComplete.js.map +1 -1
  62. package/dist/Modal.d.ts +1 -17
  63. package/dist/Modal.js +2 -2
  64. package/dist/Modal.js.map +1 -1
  65. package/dist/NumberPickerActionSheet.d.ts +1 -8
  66. package/dist/NumberPickerActionSheet.js.map +1 -1
  67. package/dist/Page.d.ts +1 -21
  68. package/dist/Page.js.map +1 -1
  69. package/dist/PickerSelect.d.ts +1 -2
  70. package/dist/Pill.d.ts +1 -3
  71. package/dist/Pill.js +3 -5
  72. package/dist/Pill.js.map +1 -1
  73. package/dist/Pog.d.ts +2 -14
  74. package/dist/Pog.js +1 -1
  75. package/dist/Pog.js.map +1 -1
  76. package/dist/ProgressBar.d.ts +1 -5
  77. package/dist/ProgressBar.js.map +1 -1
  78. package/dist/SelectList.d.ts +4 -2
  79. package/dist/SelectList.js.map +1 -1
  80. package/dist/SideDrawer.d.ts +1 -11
  81. package/dist/SideDrawer.js.map +1 -1
  82. package/dist/Spinner.d.ts +1 -5
  83. package/dist/Spinner.js +2 -1
  84. package/dist/Spinner.js.map +1 -1
  85. package/dist/Switch.d.ts +1 -3
  86. package/dist/Switch.js +15 -5
  87. package/dist/Switch.js.map +1 -1
  88. package/dist/Table.d.ts +1 -28
  89. package/dist/Table.js +4 -2
  90. package/dist/Table.js.map +1 -1
  91. package/dist/TableHeader.d.ts +1 -17
  92. package/dist/TableHeader.js.map +1 -1
  93. package/dist/TableHeaderCell.d.ts +2 -11
  94. package/dist/TableHeaderCell.js +1 -1
  95. package/dist/TableHeaderCell.js.map +1 -1
  96. package/dist/TableRow.d.ts +2 -25
  97. package/dist/TableRow.js.map +1 -1
  98. package/dist/TapToEdit.d.ts +1 -2
  99. package/dist/TapToEdit.js +2 -2
  100. package/dist/TapToEdit.js.map +1 -1
  101. package/dist/Text.d.ts +1 -18
  102. package/dist/Text.js.map +1 -1
  103. package/dist/TextArea.d.ts +1 -4
  104. package/dist/TextArea.js +3 -9
  105. package/dist/TextArea.js.map +1 -1
  106. package/dist/TextField.d.ts +1 -1
  107. package/dist/TextField.js +6 -5
  108. package/dist/TextField.js.map +1 -1
  109. package/dist/TextFieldNumberActionSheet.d.ts +2 -8
  110. package/dist/TextFieldNumberActionSheet.js.map +1 -1
  111. package/dist/Toast.d.ts +2 -10
  112. package/dist/Toast.js +1 -1
  113. package/dist/Toast.js.map +1 -1
  114. package/dist/Tooltip.d.ts +1 -7
  115. package/dist/Tooltip.js +8 -6
  116. package/dist/Tooltip.js.map +1 -1
  117. package/dist/UnifiedAddressAutoComplete.d.ts +2 -11
  118. package/dist/UnifiedAddressAutoComplete.js +4 -4
  119. package/dist/UnifiedAddressAutoComplete.js.map +1 -1
  120. package/dist/Utilities.d.ts +3 -0
  121. package/dist/Utilities.js +24 -0
  122. package/dist/Utilities.js.map +1 -1
  123. package/dist/WebAddressAutocomplete.d.ts +2 -9
  124. package/dist/WebAddressAutocomplete.js +1 -0
  125. package/dist/WebAddressAutocomplete.js.map +1 -1
  126. package/dist/WithLabel.d.ts +1 -12
  127. package/dist/WithLabel.js.map +1 -1
  128. package/dist/dayjsExtended.js +1 -0
  129. package/dist/dayjsExtended.js.map +1 -1
  130. package/dist/index.d.ts +6 -7
  131. package/dist/index.js +0 -2
  132. package/dist/index.js.map +1 -1
  133. package/package.json +17 -39
  134. package/src/ActionSheet.tsx +1 -351
  135. package/src/Avatar.tsx +5 -85
  136. package/src/Badge.tsx +1 -12
  137. package/src/Banner.tsx +1 -15
  138. package/src/Body.tsx +2 -11
  139. package/src/Box.tsx +4 -4
  140. package/src/Button.tsx +1 -27
  141. package/src/Card.tsx +15 -17
  142. package/src/CheckBox.tsx +2 -0
  143. package/src/Common.ts +801 -531
  144. package/src/CustomSelect.tsx +7 -13
  145. package/src/DateTimeActionSheet.tsx +9 -21
  146. package/src/DecimalRangeActionSheet.tsx +1 -14
  147. package/src/ErrorPage.tsx +1 -4
  148. package/src/Field.tsx +17 -37
  149. package/src/Form.tsx +1 -8
  150. package/src/Heading.tsx +8 -2
  151. package/src/HeightActionSheet.tsx +1 -7
  152. package/src/Hyperlink.tsx +7 -16
  153. package/src/Icon.tsx +4 -2
  154. package/src/IconButton.tsx +6 -43
  155. package/src/InfoTooltipButton.tsx +1 -6
  156. package/src/Link.tsx +2 -5
  157. package/src/MobileAddressAutoComplete.tsx +4 -11
  158. package/src/Modal.tsx +3 -26
  159. package/src/NumberPickerActionSheet.tsx +1 -9
  160. package/src/Page.tsx +1 -22
  161. package/src/PickerSelect.tsx +1 -1
  162. package/src/Pill.tsx +15 -17
  163. package/src/Pog.tsx +2 -14
  164. package/src/ProgressBar.tsx +1 -6
  165. package/src/SelectList.tsx +4 -4
  166. package/src/SideDrawer.tsx +1 -16
  167. package/src/Spinner.tsx +3 -7
  168. package/src/Switch.tsx +6 -12
  169. package/src/Table.tsx +5 -29
  170. package/src/TableHeader.tsx +1 -17
  171. package/src/TableHeaderCell.tsx +7 -11
  172. package/src/TableRow.tsx +2 -25
  173. package/src/TapToEdit.tsx +4 -4
  174. package/src/Text.tsx +1 -19
  175. package/src/TextArea.tsx +2 -10
  176. package/src/TextField.tsx +6 -3
  177. package/src/TextFieldNumberActionSheet.tsx +2 -9
  178. package/src/Toast.tsx +2 -14
  179. package/src/Tooltip.tsx +9 -15
  180. package/src/UnifiedAddressAutoComplete.tsx +6 -11
  181. package/src/Utilities.tsx +27 -1
  182. package/src/WebAddressAutocomplete.tsx +3 -9
  183. package/src/WithLabel.tsx +1 -13
  184. package/src/dayjsExtended.ts +1 -0
  185. package/src/index.tsx +6 -7
  186. package/dist/Layer.d.ts +0 -9
  187. package/dist/Layer.js +0 -12
  188. package/dist/Layer.js.map +0 -1
  189. package/dist/Meta.d.ts +0 -5
  190. package/dist/Meta.js +0 -7
  191. package/dist/Meta.js.map +0 -1
  192. package/dist/UnifiedScreens.d.ts +0 -9
  193. package/dist/UnifiedScreens.js +0 -25
  194. package/dist/UnifiedScreens.js.map +0 -1
  195. package/src/Layer.tsx +0 -17
  196. package/src/Meta.tsx +0 -9
  197. package/src/UnifiedScreens.ts +0 -24
@@ -1,19 +1,10 @@
1
1
  import React, {ReactElement, useEffect, useMemo, useState} from "react";
2
2
 
3
3
  import {Box} from "./Box";
4
+ import {CustomSelectProps} from "./Common";
4
5
  import {SelectList} from "./SelectList";
5
6
  import {TextField} from "./TextField";
6
7
 
7
- export interface CustomSelectProps {
8
- value: string;
9
- onChange: (value: string) => void;
10
- options: Array<{label: string; value: string}>;
11
- placeholder?: string;
12
- disabled?: boolean;
13
- label?: string;
14
- labelColor?: string;
15
- }
16
-
17
8
  export const CustomSelect = ({
18
9
  value,
19
10
  onChange,
@@ -27,7 +18,8 @@ export const CustomSelect = ({
27
18
  // Boolean that checks if customValue is a value from the
28
19
  // options prop or if it is a true custom value
29
20
  const isValueCustom: boolean = useMemo((): boolean => {
30
- // We add an empty value to protect against an empty string custom value or if the placeholder value is selected
21
+ // We add an empty value to protect against an empty string custom value or if the placeholder
22
+ // value is selected
31
23
  return ![...options, {value: ""}].map((i) => i.value).includes(customValue);
32
24
  }, [options, customValue]);
33
25
 
@@ -38,9 +30,11 @@ export const CustomSelect = ({
38
30
  }
39
31
  }, [showCustomInput, value, isValueCustom]);
40
32
 
41
- // Custom select has 3 values - the overall field value, the value of the select menu, and the value of the custom input
33
+ // Custom select has 3 values - the overall field value, the value of the select menu,
34
+ // and the value of the custom input
42
35
  const handleCustomSelectListChange = (newValue: string) => {
43
- // If "custom" is selected from the dropdown, toggle the custom input open and clear the previous value
36
+ // If "custom" is selected from the dropdown, toggle the custom input open and clear the
37
+ // previous value
44
38
  if (newValue === "custom") {
45
39
  setShowCustomInput(true);
46
40
  setCustomValue(isValueCustom ? "custom" : newValue);
@@ -5,7 +5,7 @@ import {Platform, StyleProp, TextInput, TextStyle, View} from "react-native";
5
5
  import {Calendar} from "react-native-calendars";
6
6
 
7
7
  import {Box} from "./Box";
8
- import {OnChangeCallback} from "./Common";
8
+ import {DateTimeActionSheetProps} from "./Common";
9
9
  import dayjs from "./dayjsExtended";
10
10
  import {Heading} from "./Heading";
11
11
  import {IconButton} from "./IconButton";
@@ -155,24 +155,12 @@ function CalendarHeader({
155
155
  );
156
156
  }
157
157
 
158
- interface DateTimeActionSheetProps {
159
- value?: string;
160
- mode?: "date" | "time" | "datetime";
161
- // Returns an ISO 8601 string. If mode is "time", the date portion is today.
162
- onChange: OnChangeCallback;
163
- actionSheetRef: React.RefObject<any>;
164
- visible: boolean;
165
- onDismiss: () => void;
166
- }
167
-
168
- // For mobile, renders all components in an action sheet.
169
- // For web, renders all components in a modal.
170
- // For mobile:
171
- // If mode is "time", renders a spinner picker for time picker on both platforms.
172
- // If mode is "date", renders our custom calendar on both platforms.
173
- // If mode is "datetime", renders a spinner picker for time picker and our custom calendar on both platforms.
174
- // For web, renders a simplistic text box for time picker and a calendar for date picker in a modal
175
- // In the future, web time picker should be a typeahead dropdown like Google calendar.
158
+ // For mobile, renders all components in an action sheet. For web, renders all components in a
159
+ // modal. For mobile: If mode is "time", renders a spinner picker for time picker on both platforms.
160
+ // If mode is "date", renders our custom calendar on both platforms. If mode is "datetime",
161
+ // renders a spinner picker for time picker and our custom calendar on both platforms. For web,
162
+ // renders a simplistic text box for time picker and a calendar for date picker in a modal In the
163
+ // future, web time picker should be a typeahead dropdown like Google calendar.
176
164
  export function DateTimeActionSheet({
177
165
  // actionSheetRef,
178
166
  mode,
@@ -366,8 +354,8 @@ export function DateTimeActionSheet({
366
354
  markedDates={markedDates}
367
355
  onDayPress={(day) => {
368
356
  setDate(day.dateString);
369
- // If mode is just date, we can shortcut and close right away. time and datetime need to wait for the
370
- // primary button.
357
+ // If mode is just date, we can shortcut and close right away.
358
+ // time and datetime need to wait for the primary button.
371
359
  if (mode === "date") {
372
360
  onChange({value: day.dateString});
373
361
  onDismiss();
@@ -5,23 +5,10 @@ import React from "react";
5
5
  import {ActionSheet} from "./ActionSheet";
6
6
  import {Box} from "./Box";
7
7
  import {Button} from "./Button";
8
- import {OnChangeCallback} from "./Common";
8
+ import {DecimalRangeActionSheetProps, DecimalRangeActionSheetState} from "./Common";
9
9
 
10
10
  const PICKER_HEIGHT = 104;
11
11
 
12
- interface DecimalRangeActionSheetProps {
13
- value: string;
14
- min: number;
15
- max: number;
16
- onChange: OnChangeCallback;
17
- actionSheetRef: React.RefObject<any>;
18
- }
19
-
20
- interface DecimalRangeActionSheetState {
21
- whole: string;
22
- decimal: string;
23
- }
24
-
25
12
  export class DecimalRangeActionSheet extends React.Component<
26
13
  DecimalRangeActionSheetProps,
27
14
  DecimalRangeActionSheetState
package/src/ErrorPage.tsx CHANGED
@@ -2,11 +2,8 @@ import React from "react";
2
2
 
3
3
  import {Box} from "./Box";
4
4
  import {Button} from "./Button";
5
+ import {ErrorPageProps} from "./Common";
5
6
  import {Text} from "./Text";
6
- interface ErrorPageProps {
7
- error: Error;
8
- resetError: () => void;
9
- }
10
7
 
11
8
  export class ErrorPage extends React.Component<ErrorPageProps, {}> {
12
9
  constructor(props: ErrorPageProps) {
package/src/Field.tsx CHANGED
@@ -1,53 +1,18 @@
1
1
  import React from "react";
2
- import {Styles} from "react-native-google-places-autocomplete";
3
2
 
4
3
  import {Box} from "./Box";
5
4
  import {CheckBox} from "./CheckBox";
6
- import {AddressInterface, FieldWithLabelsProps, ReactChildren, TextFieldType} from "./Common";
5
+ import {AddressInterface, FieldProps, ReactChildren, TextFieldType} from "./Common";
7
6
  import {USSTATESLIST} from "./Constants";
8
7
  import {CustomSelect} from "./CustomSelect";
9
8
  import {FieldWithLabels} from "./FieldWithLabels";
10
- import {SelectList, SelectListOptions} from "./SelectList";
9
+ import {SelectList} from "./SelectList";
11
10
  import {Switch} from "./Switch";
12
11
  import {Text} from "./Text";
13
12
  import {TextArea} from "./TextArea";
14
13
  import {TextField} from "./TextField";
15
14
  import {UnifiedAddressAutoCompleteField} from "./UnifiedAddressAutoComplete";
16
15
 
17
- export interface FieldProps extends FieldWithLabelsProps {
18
- name?: string;
19
- label?: string;
20
- height?: number;
21
- type?:
22
- | "address"
23
- | "boolean"
24
- | "currency"
25
- | "customSelect"
26
- | "date"
27
- | "datetime"
28
- | "email"
29
- | "multiselect"
30
- | "number"
31
- | "password"
32
- | "percent"
33
- | "phoneNumber"
34
- | "select"
35
- | "text"
36
- | "textarea"
37
- | "time"
38
- | "url";
39
- rows?: number;
40
- value?: any;
41
- onChange?: any;
42
- options?: SelectListOptions;
43
- placeholder?: string;
44
- disabled?: boolean;
45
- useCheckbox?: boolean;
46
- includeCounty?: boolean;
47
- googleMapsApiKey?: string;
48
- googlePlacesMobileStyles?: Styles;
49
- }
50
-
51
16
  export const Field = ({
52
17
  name,
53
18
  label,
@@ -67,6 +32,7 @@ export const Field = ({
67
32
  includeCounty = false,
68
33
  googleMapsApiKey,
69
34
  googlePlacesMobileStyles,
35
+ testID,
70
36
  }: FieldProps) => {
71
37
  const handleAddressChange = (field: string, newValue: string) => {
72
38
  onChange({...value, [field]: newValue});
@@ -92,6 +58,7 @@ export const Field = ({
92
58
  id={name}
93
59
  options={options}
94
60
  placeholder={placeholder}
61
+ testID={testID}
95
62
  value={value}
96
63
  onChange={onChange}
97
64
  />
@@ -121,6 +88,7 @@ export const Field = ({
121
88
  disabled={disabled}
122
89
  name={name}
123
90
  size="sm"
91
+ testID={`${testID}-${o.value}`}
124
92
  onChange={(result) => {
125
93
  let newValue;
126
94
  if (result.value) {
@@ -148,6 +116,7 @@ export const Field = ({
148
116
  id={name}
149
117
  placeholder={Boolean(value) ? "" : placeholder}
150
118
  rows={rows}
119
+ testID={testID}
151
120
  value={String(value)}
152
121
  onChange={(result) => onChange(result.value)}
153
122
  />
@@ -159,6 +128,7 @@ export const Field = ({
159
128
  id={name}
160
129
  name={name}
161
130
  switched={Boolean(value)}
131
+ testID={testID}
162
132
  onChange={(result) => handleSwitchChange(result)}
163
133
  />
164
134
  );
@@ -168,6 +138,7 @@ export const Field = ({
168
138
  disabled={disabled}
169
139
  id={name}
170
140
  placeholder={placeholder}
141
+ testID={testID}
171
142
  type={type as "date" | "time" | "datetime"}
172
143
  value={value}
173
144
  onChange={(result) => onChange(result.value)}
@@ -194,11 +165,13 @@ export const Field = ({
194
165
  handleAutoCompleteChange={(result) => handleAutoCompleteChange(result)}
195
166
  includeCounty={includeCounty}
196
167
  inputValue={address1}
168
+ testID={`${testID}-address1`}
197
169
  />
198
170
  <TextField
199
171
  disabled={disabled}
200
172
  id="address2"
201
173
  label="Apt, suite, etc"
174
+ testID={`${testID}-address2`}
202
175
  type="text"
203
176
  value={address2}
204
177
  onChange={(result) => handleAddressChange("address2", result.value)}
@@ -207,6 +180,7 @@ export const Field = ({
207
180
  disabled={disabled}
208
181
  id="city"
209
182
  label="City"
183
+ testID={`${testID}-city`}
210
184
  type="text"
211
185
  value={city}
212
186
  onChange={(result) => handleAddressChange("city", result.value)}
@@ -218,6 +192,7 @@ export const Field = ({
218
192
  options={USSTATESLIST}
219
193
  placeholder="Select state"
220
194
  style={{borderRadius: 16}}
195
+ testID={`${testID}-state`}
221
196
  value={state}
222
197
  onChange={(result) => handleAddressChange("state", result)}
223
198
  />
@@ -225,6 +200,7 @@ export const Field = ({
225
200
  disabled={disabled}
226
201
  id="zipcode"
227
202
  label="Zipcode"
203
+ testID={`${testID}-zip`}
228
204
  type="text"
229
205
  value={zipcode}
230
206
  onChange={(result) => handleAddressChange("zipcode", result.value)}
@@ -235,6 +211,7 @@ export const Field = ({
235
211
  disabled={disabled}
236
212
  id="countyName"
237
213
  label="County Name"
214
+ testID={`${testID}-county`}
238
215
  type="text"
239
216
  value={countyName}
240
217
  onChange={(result) => handleAddressChange("countyName", result.value)}
@@ -243,6 +220,7 @@ export const Field = ({
243
220
  disabled={disabled}
244
221
  id="countyCode"
245
222
  label="County Code"
223
+ testID={`${testID}-county-code`}
246
224
  type="number"
247
225
  value={countyCode}
248
226
  onChange={(result) => handleAddressChange("countyCode", result.value)}
@@ -271,6 +249,7 @@ export const Field = ({
271
249
  disabled={disabled}
272
250
  id={name}
273
251
  placeholder={placeholder}
252
+ testID={testID}
274
253
  type="number"
275
254
  value={value}
276
255
  onChange={(result) => onChange(result.value)}
@@ -306,6 +285,7 @@ export const Field = ({
306
285
  disabled={disabled}
307
286
  id={name}
308
287
  placeholder={placeholder}
288
+ testID={testID}
309
289
  type={
310
290
  tfType as
311
291
  | "date"
package/src/Form.tsx CHANGED
@@ -2,6 +2,7 @@ import React from "react";
2
2
 
3
3
  import {Box} from "./Box";
4
4
  import {Button} from "./Button";
5
+ import {FormLineProps} from "./Common";
5
6
  import {IconButton} from "./IconButton";
6
7
  import {SelectList} from "./SelectList";
7
8
  import {Switch} from "./Switch";
@@ -16,14 +17,6 @@ function objToJoinedString(obj: any) {
16
17
  .join(", ");
17
18
  }
18
19
 
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
20
  interface FormLineState {
28
21
  editing: boolean;
29
22
  value: any;
package/src/Heading.tsx CHANGED
@@ -10,7 +10,13 @@ const fontSizes = {
10
10
  lg: 36,
11
11
  };
12
12
 
13
- export const Heading = ({align, children, color, size}: HeadingProps): React.ReactElement => {
13
+ export const Heading = ({
14
+ align,
15
+ children,
16
+ color,
17
+ size,
18
+ testID,
19
+ }: HeadingProps): React.ReactElement => {
14
20
  const {theme} = useContext(ThemeContext);
15
21
 
16
22
  const style: StyleProp<TextStyle> = {};
@@ -29,7 +35,7 @@ export const Heading = ({align, children, color, size}: HeadingProps): React.Rea
29
35
 
30
36
  const lines = 0;
31
37
  return (
32
- <NativeText numberOfLines={lines} style={style}>
38
+ <NativeText numberOfLines={lines} style={style} testID={testID}>
33
39
  {children}
34
40
  </NativeText>
35
41
  );
@@ -5,16 +5,10 @@ import React from "react";
5
5
  import {ActionSheet} from "./ActionSheet";
6
6
  import {Box} from "./Box";
7
7
  import {Button} from "./Button";
8
- import {OnChangeCallback} from "./Common";
8
+ import {HeightActionSheetProps} from "./Common";
9
9
 
10
10
  const PICKER_HEIGHT = 104;
11
11
 
12
- interface HeightActionSheetProps {
13
- value?: string;
14
- onChange: OnChangeCallback;
15
- actionSheetRef: React.RefObject<any>;
16
- }
17
-
18
12
  interface HeightActionSheetState {
19
13
  feet: string;
20
14
  inches: string;
package/src/Hyperlink.tsx CHANGED
@@ -29,26 +29,17 @@
29
29
 
30
30
  import mdurl from "mdurl";
31
31
  import React from "react";
32
- import {Linking, Platform, StyleProp, Text, View} from "react-native";
32
+ import {Linking, Platform, Text, View} from "react-native";
33
+
34
+ import {HyperlinkProps} from "./Common";
33
35
 
34
36
  const linkifyLib = require("linkify-it")();
35
37
 
36
38
  const {OS} = Platform;
37
39
 
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> {
40
+ // Leaving this as a class component because it was easier to handle the `pasrse(this)` in
41
+ // `render()`
42
+ class HyperlinkComponent extends React.Component<HyperlinkProps> {
52
43
  isTextNested = (component: any) => {
53
44
  if (!React.isValidElement(component)) throw new Error("Invalid component");
54
45
  const {type: {displayName} = {} as any} = component;
@@ -164,7 +155,7 @@ class HyperlinkComponent extends React.Component<Props> {
164
155
  }
165
156
  }
166
157
 
167
- export function Hyperlink(props: Props) {
158
+ export function Hyperlink(props: HyperlinkProps) {
168
159
  const handleLink = (url: string) => {
169
160
  const urlObject = mdurl.parse(url);
170
161
  urlObject.protocol = urlObject.protocol.toLowerCase();
package/src/Icon.tsx CHANGED
@@ -8,8 +8,9 @@ export function initIcons() {
8
8
  console.debug("Initializing icons");
9
9
  }
10
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 {
11
+ // TODO: Update <Icon /> to be closer to Expo's Vector Icon, letting multiple icon packs be used,
12
+ // etc.
13
+ export function Icon({color, size, name, prefix, testID}: IconProps): React.ReactElement {
13
14
  const {theme} = useContext(ThemeContext);
14
15
  const iconColor = theme[color || "primary"];
15
16
  const iconSize = iconSizeToNumber(size);
@@ -20,6 +21,7 @@ export function Icon({color, size, name, prefix}: IconProps): React.ReactElement
20
21
  regular={prefix === "far"}
21
22
  size={iconSize}
22
23
  solid={!prefix || prefix === "fas"}
24
+ testID={testID}
23
25
  />
24
26
  );
25
27
  }
@@ -1,18 +1,7 @@
1
1
  import React, {forwardRef, useContext, useState} from "react";
2
2
  import {Platform, Pressable, View, ViewStyle} from "react-native";
3
3
 
4
- import {
5
- AllColors,
6
- ButtonColor,
7
- Color,
8
- IconName,
9
- IconPrefix,
10
- IconSize,
11
- iconSizeToNumber,
12
- IndicatorDirection,
13
- ThemeColor,
14
- TooltipDirection,
15
- } from "./Common";
4
+ import {IconButtonProps, iconSizeToNumber} from "./Common";
16
5
  import {Icon} from "./Icon";
17
6
  import {Modal} from "./Modal";
18
7
  import {Text} from "./Text";
@@ -20,34 +9,6 @@ import {ThemeContext} from "./Theme";
20
9
  import {Tooltip} from "./Tooltip";
21
10
  import {Unifier} from "./Unifier";
22
11
 
23
- export interface IconButtonProps {
24
- prefix?: IconPrefix;
25
- icon: IconName;
26
- accessibilityLabel: string;
27
- iconColor: "darkGray" | ButtonColor | ThemeColor | Color;
28
- onClick: () => void;
29
- size?: IconSize;
30
- bgColor?:
31
- | "transparent"
32
- | "transparentDarkGray"
33
- | "gray"
34
- | "lightGray"
35
- | "white"
36
- | "background"
37
- | "backgroundSecondary"; // default transparent
38
- disabled?: boolean;
39
- selected?: boolean;
40
- withConfirmation?: boolean;
41
- confirmationText?: string;
42
- confirmationHeading?: string;
43
- tooltip?: {
44
- text: string;
45
- idealDirection?: TooltipDirection;
46
- };
47
- indicator?: boolean;
48
- indicatorStyle?: {position: IndicatorDirection; color: AllColors};
49
- }
50
-
51
12
  // eslint-disable-next-line react/display-name
52
13
  export const IconButton = forwardRef(
53
14
  (
@@ -64,6 +25,7 @@ export const IconButton = forwardRef(
64
25
  tooltip,
65
26
  indicator,
66
27
  indicatorStyle = {position: "bottomRight", color: "primary"},
28
+ testID,
67
29
  }: IconButtonProps,
68
30
  ref
69
31
  ) => {
@@ -131,6 +93,7 @@ export const IconButton = forwardRef(
131
93
  justifyContent: "center",
132
94
  alignItems: "center",
133
95
  }}
96
+ testID={testID}
134
97
  onPress={async () => {
135
98
  await Unifier.utils.haptic();
136
99
  if (withConfirmation && !showConfirmation) {
@@ -158,9 +121,9 @@ export const IconButton = forwardRef(
158
121
  );
159
122
  }
160
123
 
161
- // Only add for web. This doesn't make much sense for mobile, since the action would be performed for the button
162
- // as well as the tooltip appearing.
163
- // TODO: Add tooltip info button next to the icon button on mobile.
124
+ // Only add for web. This doesn't make much sense for mobile,
125
+ // since the action would be performed for the button as well as the tooltip appearing. TODO:
126
+ // Add tooltip info button next to the icon button on mobile.
164
127
  if (tooltip && Platform.OS === "web") {
165
128
  return (
166
129
  <Tooltip idealDirection={tooltip.idealDirection} text={tooltip.text}>
@@ -1,13 +1,8 @@
1
1
  import React from "react";
2
2
 
3
- import {IconSize} from "./Common";
3
+ import {InfoTooltipButtonProps} from "./Common";
4
4
  import {IconButton} from "./IconButton";
5
5
 
6
- interface InfoTooltipButtonProps {
7
- text: string;
8
- size?: IconSize;
9
- }
10
-
11
6
  export function InfoTooltipButton({text, size}: InfoTooltipButtonProps): React.ReactElement {
12
7
  return (
13
8
  <IconButton
package/src/Link.tsx CHANGED
@@ -1,11 +1,8 @@
1
1
  import React from "react";
2
2
  import {Linking} from "react-native";
3
3
 
4
- import {Text, TextProps} from "./Text";
5
-
6
- interface LinkProps extends TextProps {
7
- href: string;
8
- }
4
+ import {LinkProps} from "./Common";
5
+ import {Text} from "./Text";
9
6
 
10
7
  export function Link(props: LinkProps): React.ReactElement {
11
8
  return (
@@ -3,10 +3,9 @@ import {TextStyle, TouchableOpacity, View} from "react-native";
3
3
  import {
4
4
  GooglePlacesAutocomplete,
5
5
  GooglePlacesAutocompleteRef,
6
- Styles,
7
6
  } from "react-native-google-places-autocomplete";
8
7
 
9
- import {AddressInterface, OnChangeCallback} from "./Common";
8
+ import {AddressAutocompleteProps} from "./Common";
10
9
  import {GOOGLE_PLACES_API_RESTRICTIONS} from "./Constants";
11
10
  import {TextField} from "./TextField";
12
11
  import {ThemeContext} from "./Theme";
@@ -21,15 +20,8 @@ export const MobileAddressAutocomplete = ({
21
20
  styles,
22
21
  handleAddressChange,
23
22
  handleAutoCompleteChange,
24
- }: {
25
- disabled?: boolean;
26
- googleMapsApiKey?: string;
27
- includeCounty?: boolean;
28
- inputValue: string;
29
- styles?: Styles;
30
- handleAddressChange: OnChangeCallback;
31
- handleAutoCompleteChange: (value: AddressInterface) => void;
32
- }) => {
23
+ testID,
24
+ }: AddressAutocompleteProps) => {
33
25
  const {theme} = useContext(ThemeContext);
34
26
  const ref = useRef<GooglePlacesAutocompleteRef | null>(null);
35
27
  const [isFocused, setIsFocused] = useState(false);
@@ -71,6 +63,7 @@ export const MobileAddressAutocomplete = ({
71
63
  disabled={disabled}
72
64
  id="address1"
73
65
  label="Street Address"
66
+ testID={testID}
74
67
  type="text"
75
68
  value={inputValue}
76
69
  onChange={(result) => handleAddressChange(result)}
package/src/Modal.tsx CHANGED
@@ -4,36 +4,13 @@ import ActionSheet, {ActionSheetRef} from "react-native-actions-sheet";
4
4
 
5
5
  import {Box} from "./Box";
6
6
  import {Button} from "./Button";
7
+ import {ModalProps} from "./Common";
7
8
  import {Heading} from "./Heading";
8
9
  import {IconButton} from "./IconButton";
9
10
  import {isMobileDevice} from "./MediaQuery";
10
11
  import {Text} from "./Text";
11
12
  import {isNative} from "./Utilities";
12
13
 
13
- interface ModalProps {
14
- onDismiss: () => void;
15
- visible: boolean;
16
- // Alignment of the header. Default is "center".
17
- align?: "center" | "start";
18
- // Element to render in the middle part of the modal.
19
- children?: React.ReactElement;
20
- // Element to render in the bottom of the modal. This takes precedence over primaryButton and secondaryButton.
21
- footer?: React.ReactElement;
22
- heading?: string;
23
- size?: "sm" | "md" | "lg";
24
- subHeading?: string;
25
- // Renders a primary colored button all the way to the right in the footer, if no footer prop is provided.
26
- primaryButtonText?: string;
27
- primaryButtonOnClick?: (value?: any) => void;
28
- primaryButtonDisabled?: boolean;
29
- // Renders a gray button to the left of the primary button in the footer, if no footer prop is provided.
30
- // Requires primaryButtonText to be defined, but is not required itself.
31
- secondaryButtonText?: string;
32
- secondaryButtonOnClick?: (value?: any) => void;
33
- // Whether to show a close button in the upper left of modals or action sheets.
34
- showClose?: boolean;
35
- }
36
-
37
14
  export const Modal = ({
38
15
  onDismiss,
39
16
  visible,
@@ -187,7 +164,7 @@ export const Modal = ({
187
164
  return (
188
165
  <ActionSheet ref={actionSheetRef} onClose={onDismiss}>
189
166
  <Box direction="row" marginBottom={2} paddingX={2} paddingY={2} width="100%">
190
- <Box marginRight={4}>
167
+ <Box marginRight={4} minWidth={50}>
191
168
  {Boolean(showClose) && (
192
169
  <IconButton
193
170
  accessibilityLabel="close"
@@ -220,7 +197,7 @@ export const Modal = ({
220
197
  )}
221
198
  </Box>
222
199
 
223
- <Box alignSelf="start" height="100%" justifyContent="start">
200
+ <Box alignSelf="start" height="100%" justifyContent="start" marginLeft={4} minWidth={50}>
224
201
  {Boolean(primaryButtonText) && (
225
202
  <Button
226
203
  color="primary"
@@ -5,18 +5,10 @@ import React from "react";
5
5
  import {ActionSheet} from "./ActionSheet";
6
6
  import {Box} from "./Box";
7
7
  import {Button} from "./Button";
8
- import {OnChangeCallback} from "./Common";
8
+ import {NumberPickerActionSheetProps} from "./Common";
9
9
 
10
10
  const PICKER_HEIGHT = 104;
11
11
 
12
- interface NumberPickerActionSheetProps {
13
- value: string;
14
- min: number;
15
- max: number;
16
- onChange: OnChangeCallback;
17
- actionSheetRef: React.RefObject<any>;
18
- }
19
-
20
12
  interface NumberPickerActionSheetState {}
21
13
 
22
14
  export class NumberPickerActionSheet extends React.Component<