ferns-ui 0.41.1 → 0.42.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.
- package/dist/Avatar.js +1 -0
- package/dist/Avatar.js.map +1 -1
- package/dist/Badge.d.ts +1 -1
- package/dist/Badge.js +2 -2
- package/dist/Badge.js.map +1 -1
- package/dist/Body.d.ts +1 -1
- package/dist/Body.js +2 -2
- package/dist/Body.js.map +1 -1
- package/dist/Button.d.ts +1 -1
- package/dist/Button.js +4 -4
- package/dist/Button.js.map +1 -1
- package/dist/Card.d.ts +1 -1
- package/dist/Card.js +2 -2
- package/dist/Card.js.map +1 -1
- package/dist/CheckBox.d.ts +1 -1
- package/dist/CheckBox.js +2 -2
- package/dist/CheckBox.js.map +1 -1
- package/dist/Common.d.ts +18 -0
- package/dist/CustomSelect.js +1 -0
- package/dist/CustomSelect.js.map +1 -1
- package/dist/DateTimeActionSheet.d.ts +1 -1
- package/dist/DateTimeActionSheet.js +8 -7
- package/dist/DateTimeActionSheet.js.map +1 -1
- package/dist/FernsProvider.d.ts +2 -2
- package/dist/FernsProvider.js +2 -2
- package/dist/FernsProvider.js.map +1 -1
- package/dist/Hyperlink.d.ts +1 -1
- package/dist/Hyperlink.js +3 -3
- package/dist/Hyperlink.js.map +1 -1
- package/dist/Icon.d.ts +1 -1
- package/dist/Icon.js +2 -2
- package/dist/Icon.js.map +1 -1
- package/dist/InfoTooltipButton.d.ts +1 -1
- package/dist/InfoTooltipButton.js +2 -2
- package/dist/InfoTooltipButton.js.map +1 -1
- package/dist/Link.d.ts +1 -1
- package/dist/Link.js +2 -2
- package/dist/Link.js.map +1 -1
- package/dist/Mask.d.ts +1 -1
- package/dist/Mask.js +2 -2
- package/dist/Mask.js.map +1 -1
- package/dist/MobileAddressAutoComplete.js +1 -0
- package/dist/MobileAddressAutoComplete.js.map +1 -1
- package/dist/ModalSheet.js +1 -0
- package/dist/ModalSheet.js.map +1 -1
- package/dist/OpenAPIContext.d.ts +1 -1
- package/dist/OpenAPIContext.js +4 -3
- package/dist/OpenAPIContext.js.map +1 -1
- package/dist/PickerSelect.js +1 -0
- package/dist/PickerSelect.js.map +1 -1
- package/dist/Pill.d.ts +1 -1
- package/dist/Pill.js +2 -2
- package/dist/Pill.js.map +1 -1
- package/dist/Pog.d.ts +1 -1
- package/dist/Pog.js +2 -2
- package/dist/Pog.js.map +1 -1
- package/dist/ProgressBar.d.ts +1 -1
- package/dist/ProgressBar.js +2 -2
- package/dist/ProgressBar.js.map +1 -1
- package/dist/SelectList.d.ts +1 -1
- package/dist/SelectList.js +2 -2
- package/dist/SelectList.js.map +1 -1
- package/dist/Signature.d.ts +1 -1
- package/dist/Signature.js +2 -2
- package/dist/Signature.js.map +1 -1
- package/dist/Signature.native.js +1 -1
- package/dist/Signature.native.js.map +1 -1
- package/dist/Spinner.d.ts +1 -1
- package/dist/Spinner.js +2 -2
- package/dist/Spinner.js.map +1 -1
- package/dist/SplitPage.js +1 -0
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.js +1 -0
- package/dist/SplitPage.native.js.map +1 -1
- package/dist/Switch.d.ts +1 -1
- package/dist/Switch.js +2 -2
- package/dist/Switch.js.map +1 -1
- package/dist/Table.d.ts +2 -2
- package/dist/Table.js +2 -2
- package/dist/Table.js.map +1 -1
- package/dist/TableHeader.d.ts +1 -1
- package/dist/TableHeader.js +2 -2
- package/dist/TableHeader.js.map +1 -1
- package/dist/TableHeaderCell.d.ts +1 -1
- package/dist/TableHeaderCell.js +2 -2
- package/dist/TableHeaderCell.js.map +1 -1
- package/dist/TableRow.d.ts +1 -1
- package/dist/TableRow.js +2 -2
- package/dist/TableRow.js.map +1 -1
- package/dist/TapToEdit.js +1 -1
- package/dist/TapToEdit.js.map +1 -1
- package/dist/Text.d.ts +1 -1
- package/dist/Text.js +2 -2
- package/dist/Text.js.map +1 -1
- package/dist/TextArea.d.ts +1 -1
- package/dist/TextArea.js +2 -2
- package/dist/TextArea.js.map +1 -1
- package/dist/TextField.d.ts +1 -1
- package/dist/TextField.js +2 -2
- package/dist/TextField.js.map +1 -1
- package/dist/Toast.d.ts +8 -2
- package/dist/Toast.js +30 -8
- package/dist/Toast.js.map +1 -1
- package/dist/Tooltip.js +1 -0
- package/dist/Tooltip.js.map +1 -1
- package/dist/Unifier.js +5 -5
- package/dist/Unifier.js.map +1 -1
- package/dist/Utilities.d.ts +3 -1
- package/dist/Utilities.js +12 -0
- package/dist/Utilities.js.map +1 -1
- package/dist/WebAddressAutocomplete.js +1 -0
- package/dist/WebAddressAutocomplete.js.map +1 -1
- package/dist/WithLabel.d.ts +1 -1
- package/dist/WithLabel.js +2 -2
- package/dist/WithLabel.js.map +1 -1
- package/dist/tableContext.d.ts +1 -1
- package/dist/tableContext.js +2 -2
- package/dist/tableContext.js.map +1 -1
- package/package.json +7 -22
- package/src/Avatar.tsx +1 -0
- package/src/Badge.tsx +3 -3
- package/src/Body.tsx +3 -3
- package/src/Button.tsx +5 -5
- package/src/Card.tsx +2 -2
- package/src/CheckBox.tsx +3 -3
- package/src/Common.ts +17 -0
- package/src/CustomSelect.tsx +1 -0
- package/src/DateTimeActionSheet.tsx +10 -9
- package/src/FernsProvider.tsx +2 -2
- package/src/Hyperlink.tsx +3 -3
- package/src/Icon.tsx +2 -2
- package/src/InfoTooltipButton.tsx +2 -2
- package/src/Link.tsx +2 -2
- package/src/Mask.tsx +2 -2
- package/src/MobileAddressAutoComplete.tsx +1 -0
- package/src/ModalSheet.tsx +1 -0
- package/src/OpenAPIContext.tsx +4 -3
- package/src/PickerSelect.tsx +1 -0
- package/src/Pill.tsx +2 -2
- package/src/Pog.tsx +2 -2
- package/src/ProgressBar.tsx +2 -2
- package/src/SelectList.tsx +3 -3
- package/src/Signature.native.tsx +1 -0
- package/src/Signature.tsx +2 -2
- package/src/Spinner.tsx +2 -2
- package/src/SplitPage.native.tsx +1 -0
- package/src/SplitPage.tsx +1 -0
- package/src/Switch.tsx +7 -2
- package/src/Table.tsx +3 -3
- package/src/TableHeader.tsx +3 -3
- package/src/TableHeaderCell.tsx +3 -3
- package/src/TableRow.tsx +3 -3
- package/src/TapToEdit.tsx +1 -1
- package/src/Text.tsx +3 -3
- package/src/TextArea.tsx +2 -2
- package/src/TextField.tsx +3 -3
- package/src/Toast.tsx +35 -18
- package/src/Tooltip.tsx +1 -0
- package/src/Unifier.ts +5 -5
- package/src/Utilities.tsx +13 -1
- package/src/WebAddressAutocomplete.tsx +1 -0
- package/src/WithLabel.tsx +3 -3
- package/src/tableContext.tsx +3 -3
package/src/TableHeaderCell.tsx
CHANGED
|
@@ -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
|
|
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
|
|
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 (
|
|
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
|
|
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
|
|
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
|
|
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
|
@@ -8,33 +8,50 @@ import {AllColors, ToastProps} from "./Common";
|
|
|
8
8
|
import {Icon} from "./Icon";
|
|
9
9
|
import {IconButton} from "./IconButton";
|
|
10
10
|
import {Text} from "./Text";
|
|
11
|
+
import {isAPIError, printAPIError} from "./Utilities";
|
|
11
12
|
|
|
12
13
|
const TOAST_DURATION_MS = 3 * 1000;
|
|
13
14
|
|
|
14
|
-
export function useToast():
|
|
15
|
+
export function useToast(): {
|
|
16
|
+
warn: (text: string, options?: Omit<ToastProps["data"], "variant">) => string;
|
|
17
|
+
hide: (id: string) => void;
|
|
18
|
+
show: (text: string, options?: ToastProps["data"]) => string;
|
|
19
|
+
catch: (error: any, message?: string, options?: Omit<ToastProps["data"], "variant">) => void;
|
|
20
|
+
error: (text: string, options?: Omit<ToastProps["data"], "variant">) => string;
|
|
21
|
+
} {
|
|
15
22
|
const toast = useRNToast();
|
|
23
|
+
const show = (text: string, options?: ToastProps["data"]): string => {
|
|
24
|
+
return toast.show(text, {
|
|
25
|
+
data: options,
|
|
26
|
+
// a duration of 0 keeps the toast up infinitely until hidden
|
|
27
|
+
duration: options?.persistent ? 0 : TOAST_DURATION_MS,
|
|
28
|
+
});
|
|
29
|
+
};
|
|
16
30
|
return {
|
|
17
|
-
show
|
|
18
|
-
|
|
19
|
-
options
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
persistent?: boolean;
|
|
24
|
-
onDismiss?: () => void | Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
): string => {
|
|
27
|
-
return toast.show(text, {
|
|
28
|
-
data: options,
|
|
29
|
-
// a duration of 0 keeps the toast up infinitely until hidden
|
|
30
|
-
duration: options?.persistent ? 0 : TOAST_DURATION_MS,
|
|
31
|
-
});
|
|
31
|
+
show,
|
|
32
|
+
warn: (text: string, options?: Omit<ToastProps["data"], "variant">): string => {
|
|
33
|
+
return show(text, {...options, variant: "warning"});
|
|
34
|
+
},
|
|
35
|
+
error: (text: string, options?: Omit<ToastProps["data"], "variant">): string => {
|
|
36
|
+
return show(text, {...options, variant: "error"});
|
|
32
37
|
},
|
|
33
38
|
hide: (id: string) => toast.hide(id),
|
|
39
|
+
catch: (error: any, message?: string, options?: Omit<ToastProps["data"], "variant">): void => {
|
|
40
|
+
let exceptionMsg;
|
|
41
|
+
if (isAPIError(error)) {
|
|
42
|
+
// Get the error without details.
|
|
43
|
+
exceptionMsg = `${message}: ${printAPIError(error)}`;
|
|
44
|
+
console.error(exceptionMsg);
|
|
45
|
+
} else {
|
|
46
|
+
exceptionMsg = error?.message ?? error?.error ?? String(error);
|
|
47
|
+
console.error(`${message}: ${exceptionMsg}`);
|
|
48
|
+
}
|
|
49
|
+
show(exceptionMsg, {...options, variant: "error"});
|
|
50
|
+
},
|
|
34
51
|
};
|
|
35
52
|
}
|
|
36
53
|
|
|
37
|
-
export
|
|
54
|
+
export const Toast = ({message, data}: ToastProps): React.ReactElement => {
|
|
38
55
|
// margin 8 on either side, times the standard 4px we multiply by.
|
|
39
56
|
const width = Math.min(Dimensions.get("window").width - 16 * 4, 712);
|
|
40
57
|
const {variant, buttonText, buttonOnClick, persistent, onDismiss} = data ?? {};
|
|
@@ -89,4 +106,4 @@ export function Toast({message, data}: ToastProps): React.ReactElement {
|
|
|
89
106
|
)}
|
|
90
107
|
</Box>
|
|
91
108
|
);
|
|
92
|
-
}
|
|
109
|
+
};
|
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 (
|
|
155
|
-
console.error(`[storage] Error reading ${key}`,
|
|
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 (
|
|
164
|
-
console.error(`[storage] Error storing ${key}`, item,
|
|
165
|
-
throw new Error(
|
|
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
|
};
|
package/src/Utilities.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import get from "lodash/get";
|
|
4
4
|
import {Platform} from "react-native";
|
|
5
5
|
|
|
6
|
-
import {BaseProfile, IconSize} from "./Common";
|
|
6
|
+
import {APIError, BaseProfile, IconSize} from "./Common";
|
|
7
7
|
import {COUNTY_AND_COUNTY_EQUIVALENT_ENTITIES} from "./Constants";
|
|
8
8
|
|
|
9
9
|
export function mergeInlineStyles(inlineStyle?: any, newStyle?: any) {
|
|
@@ -308,3 +308,15 @@ export function formattedCountyCode(state: string, countyName: string): string {
|
|
|
308
308
|
|
|
309
309
|
return `${countyData.stateFP}${countyData.countyFP}`;
|
|
310
310
|
}
|
|
311
|
+
|
|
312
|
+
export function isAPIError(error: any): error is APIError {
|
|
313
|
+
return error && error.data?.title;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export function printAPIError(error: APIError, details = true): string {
|
|
317
|
+
let message = error.data?.title;
|
|
318
|
+
if (error.data?.detail && details) {
|
|
319
|
+
message = `${message}: ${error.data?.detail}`;
|
|
320
|
+
}
|
|
321
|
+
return message;
|
|
322
|
+
}
|
|
@@ -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) {
|
package/src/WithLabel.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import {Box} from "./Box";
|
|
|
4
4
|
import {WithLabelProps} from "./Common";
|
|
5
5
|
import {Text} from "./Text";
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export const WithLabel = ({
|
|
8
8
|
label,
|
|
9
9
|
labelInline,
|
|
10
10
|
labelJustifyContent,
|
|
@@ -14,7 +14,7 @@ export function WithLabel({
|
|
|
14
14
|
labelColor,
|
|
15
15
|
show,
|
|
16
16
|
children,
|
|
17
|
-
}: WithLabelProps): React.ReactElement | null {
|
|
17
|
+
}: WithLabelProps): React.ReactElement | null => {
|
|
18
18
|
if (!children) {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
@@ -42,4 +42,4 @@ export function WithLabel({
|
|
|
42
42
|
)}
|
|
43
43
|
</Box>
|
|
44
44
|
);
|
|
45
|
-
}
|
|
45
|
+
};
|
package/src/tableContext.tsx
CHANGED
|
@@ -31,7 +31,7 @@ const TableContext: Context<TableContextType> = createContext<TableContextType>(
|
|
|
31
31
|
|
|
32
32
|
export const {Provider} = TableContext;
|
|
33
33
|
|
|
34
|
-
export
|
|
34
|
+
export const TableContextProvider = ({
|
|
35
35
|
children,
|
|
36
36
|
columns,
|
|
37
37
|
hasDrawerContents,
|
|
@@ -40,7 +40,7 @@ export function TableContextProvider({
|
|
|
40
40
|
stickyHeader,
|
|
41
41
|
borderStyle,
|
|
42
42
|
alternateRowBackground,
|
|
43
|
-
}: Props): React.ReactElement<typeof Provider> {
|
|
43
|
+
}: Props): React.ReactElement<typeof Provider> => {
|
|
44
44
|
return (
|
|
45
45
|
<Provider
|
|
46
46
|
value={{
|
|
@@ -56,7 +56,7 @@ export function TableContextProvider({
|
|
|
56
56
|
{children}
|
|
57
57
|
</Provider>
|
|
58
58
|
);
|
|
59
|
-
}
|
|
59
|
+
};
|
|
60
60
|
|
|
61
61
|
export function useTableContext(): TableContextType {
|
|
62
62
|
const {
|