ferns-ui 0.47.10 → 1.0.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/Accordion.d.ts +3 -0
- package/dist/Accordion.js +38 -0
- package/dist/Accordion.js.map +1 -0
- package/dist/ActionSheet.d.ts +9 -10
- package/dist/ActionSheet.js +8 -6
- package/dist/ActionSheet.js.map +1 -1
- package/dist/AddressField.d.ts +3 -0
- package/dist/AddressField.js +33 -0
- package/dist/AddressField.js.map +1 -0
- package/dist/Avatar.d.ts +2 -2
- package/dist/Avatar.js +132 -96
- package/dist/Avatar.js.map +1 -1
- package/dist/Badge.d.ts +1 -1
- package/dist/Badge.js +95 -20
- package/dist/Badge.js.map +1 -1
- package/dist/Banner.d.ts +1 -1
- package/dist/Banner.js +89 -51
- package/dist/Banner.js.map +1 -1
- package/dist/Body.js +4 -4
- package/dist/Body.js.map +1 -1
- package/dist/BooleanField.d.ts +3 -0
- package/dist/BooleanField.js +90 -0
- package/dist/BooleanField.js.map +1 -0
- package/dist/Box.js +80 -80
- package/dist/Box.js.map +1 -1
- package/dist/Button.d.ts +2 -2
- package/dist/Button.js +87 -109
- package/dist/Button.js.map +1 -1
- package/dist/Card.js +2 -2
- package/dist/Card.js.map +1 -1
- package/dist/CheckBox.d.ts +2 -2
- package/dist/CheckBox.js +23 -35
- package/dist/CheckBox.js.map +1 -1
- package/dist/Common.d.ts +1129 -413
- package/dist/Common.js +39 -3
- package/dist/Common.js.map +1 -1
- package/dist/CommonIconTypes.d.ts +3 -0
- package/dist/CommonIconTypes.js +2 -0
- package/dist/CommonIconTypes.js.map +1 -0
- package/dist/CustomSelectField.d.ts +3 -0
- package/dist/CustomSelectField.js +64 -0
- package/dist/CustomSelectField.js.map +1 -0
- package/dist/DateTimeActionSheet.d.ts +1 -1
- package/dist/DateTimeActionSheet.js +170 -158
- package/dist/DateTimeActionSheet.js.map +1 -1
- package/dist/DateTimeField.d.ts +3 -3
- package/dist/DateTimeField.js +140 -30
- package/dist/DateTimeField.js.map +1 -1
- package/dist/DateUtilities.js.map +1 -1
- package/dist/DateUtilities.test.js +2 -1
- package/dist/DateUtilities.test.js.map +1 -1
- package/dist/DecimalRangeActionSheet.js +3 -15
- package/dist/DecimalRangeActionSheet.js.map +1 -1
- package/dist/DismissButton.d.ts +3 -0
- package/dist/DismissButton.js +14 -0
- package/dist/DismissButton.js.map +1 -0
- package/dist/EmailField.d.ts +3 -0
- package/dist/EmailField.js +52 -0
- package/dist/EmailField.js.map +1 -0
- package/dist/ErrorBoundary.d.ts +1 -1
- package/dist/ErrorPage.js +2 -2
- package/dist/ErrorPage.js.map +1 -1
- package/dist/FernsProvider.js +1 -1
- package/dist/FernsProvider.js.map +1 -1
- package/dist/Field.d.ts +2 -2
- package/dist/Field.js +67 -136
- package/dist/Field.js.map +1 -1
- package/dist/Heading.js +37 -16
- package/dist/Heading.js.map +1 -1
- package/dist/HeightActionSheet.js +3 -7
- package/dist/HeightActionSheet.js.map +1 -1
- package/dist/Hyperlink.js +7 -1
- package/dist/Hyperlink.js.map +1 -1
- package/dist/Icon.d.ts +1 -2
- package/dist/Icon.js +8 -10
- package/dist/Icon.js.map +1 -1
- package/dist/IconButton.d.ts +2 -2
- package/dist/IconButton.js +93 -92
- package/dist/IconButton.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 +7 -3
- package/dist/Link.js.map +1 -1
- package/dist/MobileAddressAutoComplete.js +8 -8
- package/dist/MobileAddressAutoComplete.js.map +1 -1
- package/dist/Modal.d.ts +2 -2
- package/dist/Modal.js +95 -80
- package/dist/Modal.js.map +1 -1
- package/dist/MultiselectField.d.ts +3 -0
- package/dist/MultiselectField.js +49 -0
- package/dist/MultiselectField.js.map +1 -0
- package/dist/NumberField.d.ts +3 -0
- package/dist/NumberField.js +49 -0
- package/dist/NumberField.js.map +1 -0
- package/dist/NumberPickerActionSheet.js +2 -2
- package/dist/NumberPickerActionSheet.js.map +1 -1
- package/dist/OpenAPIContext.js.map +1 -1
- package/dist/Page.js +6 -6
- package/dist/Page.js.map +1 -1
- package/dist/Pagination.d.ts +2 -8
- package/dist/Pagination.js +107 -13
- package/dist/Pagination.js.map +1 -1
- package/dist/PasswordField.d.ts +2 -0
- package/dist/PasswordField.js +6 -0
- package/dist/PasswordField.js.map +1 -0
- package/dist/PhoneNumberField.d.ts +3 -0
- package/dist/PhoneNumberField.js +79 -0
- package/dist/PhoneNumberField.js.map +1 -0
- package/dist/PickerSelect.d.ts +6 -67
- package/dist/PickerSelect.js +145 -115
- package/dist/PickerSelect.js.map +1 -1
- package/dist/Radio.d.ts +3 -0
- package/dist/Radio.js +21 -0
- package/dist/Radio.js.map +1 -0
- package/dist/RadioField.d.ts +3 -0
- package/dist/RadioField.js +22 -0
- package/dist/RadioField.js.map +1 -0
- package/dist/SegmentedControl.d.ts +1 -1
- package/dist/SegmentedControl.js +37 -68
- package/dist/SegmentedControl.js.map +1 -1
- package/dist/SelectField.d.ts +3 -0
- package/dist/SelectField.js +20 -0
- package/dist/SelectField.js.map +1 -0
- package/dist/SideDrawer.js +8 -2
- package/dist/SideDrawer.js.map +1 -1
- package/dist/Signature.d.ts +1 -0
- package/dist/Signature.js +8 -7
- package/dist/Signature.js.map +1 -1
- package/dist/Signature.native.js +8 -7
- package/dist/Signature.native.js.map +1 -1
- package/dist/SignatureField.d.ts +3 -0
- package/dist/SignatureField.js +54 -0
- package/dist/SignatureField.js.map +1 -0
- package/dist/Spinner.js +17 -2
- package/dist/Spinner.js.map +1 -1
- package/dist/SplitPage.d.ts +1 -1
- package/dist/SplitPage.js +10 -10
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.js +7 -7
- package/dist/SplitPage.native.js.map +1 -1
- package/dist/TapToEdit.d.ts +3 -3
- package/dist/TapToEdit.js +64 -59
- package/dist/TapToEdit.js.map +1 -1
- package/dist/Text.d.ts +1 -1
- package/dist/Text.js +70 -64
- package/dist/Text.js.map +1 -1
- package/dist/TextArea.d.ts +1 -1
- package/dist/TextArea.js +2 -14
- package/dist/TextArea.js.map +1 -1
- package/dist/TextField.d.ts +2 -2
- package/dist/TextField.js +89 -206
- package/dist/TextField.js.map +1 -1
- package/dist/TextFieldNumberActionSheet.js +2 -2
- package/dist/TextFieldNumberActionSheet.js.map +1 -1
- package/dist/Theme.d.ts +87 -3
- package/dist/Theme.js +197 -98
- package/dist/Theme.js.map +1 -1
- package/dist/TimezonePicker.js +3 -5
- package/dist/TimezonePicker.js.map +1 -1
- package/dist/Toast.d.ts +18 -5
- package/dist/Toast.js +130 -31
- package/dist/Toast.js.map +1 -1
- package/dist/Tooltip.d.ts +2 -2
- package/dist/Tooltip.js +177 -80
- package/dist/Tooltip.js.map +1 -1
- package/dist/UnifiedAddressAutoComplete.js +2 -2
- package/dist/UnifiedAddressAutoComplete.js.map +1 -1
- package/dist/Unifier.js.map +1 -1
- package/dist/Utilities.js +5 -3
- package/dist/Utilities.js.map +1 -1
- package/dist/WebAddressAutocomplete.js +2 -2
- package/dist/WebAddressAutocomplete.js.map +1 -1
- package/dist/fieldElements/FieldError.d.ts +6 -0
- package/dist/fieldElements/FieldError.js +14 -0
- package/dist/fieldElements/FieldError.js.map +1 -0
- package/dist/fieldElements/FieldHelperText.d.ts +6 -0
- package/dist/fieldElements/FieldHelperText.js +11 -0
- package/dist/fieldElements/FieldHelperText.js.map +1 -0
- package/dist/fieldElements/FieldTitle.d.ts +6 -0
- package/dist/fieldElements/FieldTitle.js +19 -0
- package/dist/fieldElements/FieldTitle.js.map +1 -0
- package/dist/fieldElements/index.d.ts +3 -0
- package/dist/fieldElements/index.js +4 -0
- package/dist/fieldElements/index.js.map +1 -0
- package/dist/icons/MobileIcon.d.ts +3 -0
- package/dist/icons/MobileIcon.js +24 -0
- package/dist/icons/MobileIcon.js.map +1 -0
- package/dist/icons/OfflineIcon.d.ts +3 -0
- package/dist/icons/OfflineIcon.js +23 -0
- package/dist/icons/OfflineIcon.js.map +1 -0
- package/dist/icons/OnlineIcon.d.ts +3 -0
- package/dist/icons/OnlineIcon.js +24 -0
- package/dist/icons/OnlineIcon.js.map +1 -0
- package/dist/icons/OutOfficeIcon.d.ts +3 -0
- package/dist/icons/OutOfficeIcon.js +24 -0
- package/dist/icons/OutOfficeIcon.js.map +1 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +5 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/index.d.ts +28 -14
- package/dist/index.js +28 -14
- package/dist/index.js.map +1 -1
- package/dist/setupTests.d.ts +1 -0
- package/dist/setupTests.js +1 -1
- package/dist/setupTests.js.map +1 -1
- package/dist/{Table.d.ts → table/Table.d.ts} +2 -2
- package/dist/{Table.js → table/Table.js} +18 -10
- package/dist/table/Table.js.map +1 -0
- package/dist/table/TableBadge.d.ts +6 -0
- package/dist/table/TableBadge.js +22 -0
- package/dist/table/TableBadge.js.map +1 -0
- package/dist/table/TableBoolean.d.ts +6 -0
- package/dist/table/TableBoolean.js +39 -0
- package/dist/table/TableBoolean.js.map +1 -0
- package/dist/table/TableDate.d.ts +3 -0
- package/dist/table/TableDate.js +26 -0
- package/dist/table/TableDate.js.map +1 -0
- package/dist/{TableHeader.d.ts → table/TableHeader.d.ts} +1 -1
- package/dist/{TableHeader.js → table/TableHeader.js} +2 -2
- package/dist/table/TableHeader.js.map +1 -0
- package/dist/{TableHeaderCell.d.ts → table/TableHeaderCell.d.ts} +2 -2
- package/dist/table/TableHeaderCell.js +58 -0
- package/dist/table/TableHeaderCell.js.map +1 -0
- package/dist/table/TableIconButton.d.ts +3 -0
- package/dist/table/TableIconButton.js +42 -0
- package/dist/table/TableIconButton.js.map +1 -0
- package/dist/table/TableNumber.d.ts +3 -0
- package/dist/table/TableNumber.js +18 -0
- package/dist/table/TableNumber.js.map +1 -0
- package/dist/{TableRow.d.ts → table/TableRow.d.ts} +1 -1
- package/dist/table/TableRow.js +28 -0
- package/dist/table/TableRow.js.map +1 -0
- package/dist/table/TableText.d.ts +3 -0
- package/dist/table/TableText.js +18 -0
- package/dist/table/TableText.js.map +1 -0
- package/dist/table/TableTitle.d.ts +3 -0
- package/dist/table/TableTitle.js +22 -0
- package/dist/table/TableTitle.js.map +1 -0
- package/dist/{tableContext.d.ts → table/tableContext.d.ts} +1 -1
- package/dist/table/tableContext.js.map +1 -0
- package/package.json +10 -4
- package/src/Accordion.tsx +92 -0
- package/src/ActionSheet.tsx +8 -5
- package/src/AddressField.tsx +122 -0
- package/src/Avatar.tsx +193 -147
- package/src/Badge.tsx +117 -49
- package/src/Banner.tsx +158 -111
- package/src/Body.tsx +4 -4
- package/src/BooleanField.tsx +122 -0
- package/src/Box.tsx +92 -82
- package/src/Button.tsx +151 -167
- package/src/Card.tsx +2 -2
- package/src/CheckBox.tsx +30 -111
- package/src/Common.ts +1380 -2059
- package/src/CommonIconTypes.ts +2030 -0
- package/src/CustomSelectField.tsx +116 -0
- package/src/DateTimeActionSheet.tsx +341 -259
- package/src/DateTimeField.tsx +168 -61
- package/src/DateUtilities.test.ts +6 -2
- package/src/DateUtilities.tsx +1 -1
- package/src/DecimalRangeActionSheet.tsx +2 -17
- package/src/DismissButton.tsx +31 -0
- package/src/EmailField.tsx +70 -0
- package/src/ErrorPage.tsx +2 -2
- package/src/FernsProvider.tsx +1 -1
- package/src/Field.tsx +83 -345
- package/src/Heading.tsx +44 -16
- package/src/HeightActionSheet.tsx +2 -9
- package/src/Hyperlink.tsx +8 -1
- package/src/Icon.tsx +22 -14
- package/src/IconButton.tsx +188 -156
- package/src/InfoTooltipButton.tsx +4 -6
- package/src/Link.tsx +14 -5
- package/src/MobileAddressAutoComplete.tsx +17 -13
- package/src/Modal.tsx +214 -190
- package/src/MultiselectField.tsx +103 -0
- package/src/NumberField.tsx +55 -0
- package/src/NumberPickerActionSheet.tsx +1 -4
- package/src/OpenAPIContext.tsx +1 -1
- package/src/Page.tsx +9 -13
- package/src/Pagination.tsx +171 -36
- package/src/PasswordField.tsx +7 -0
- package/src/PhoneNumberField.tsx +103 -0
- package/src/PickerSelect.tsx +169 -151
- package/src/Radio.tsx +33 -0
- package/src/RadioField.tsx +43 -0
- package/src/SegmentedControl.tsx +46 -97
- package/src/SelectField.tsx +41 -0
- package/src/SideDrawer.tsx +8 -2
- package/src/Signature.native.tsx +16 -9
- package/src/Signature.tsx +19 -11
- package/src/SignatureField.tsx +92 -0
- package/src/Spinner.tsx +16 -2
- package/src/SplitPage.native.tsx +9 -7
- package/src/SplitPage.tsx +11 -12
- package/src/TapToEdit.tsx +122 -109
- package/src/Text.tsx +79 -69
- package/src/TextArea.tsx +2 -2
- package/src/TextField.tsx +133 -285
- package/src/TextFieldNumberActionSheet.tsx +1 -4
- package/src/Theme.tsx +223 -172
- package/src/TimezonePicker.tsx +3 -18
- package/src/Toast.tsx +193 -70
- package/src/Tooltip.tsx +233 -122
- package/src/UnifiedAddressAutoComplete.tsx +3 -3
- package/src/Unifier.ts +4 -4
- package/src/Utilities.tsx +11 -3
- package/src/WebAddressAutocomplete.tsx +2 -3
- package/src/fieldElements/FieldError.tsx +24 -0
- package/src/fieldElements/FieldHelperText.tsx +20 -0
- package/src/fieldElements/FieldTitle.tsx +31 -0
- package/src/fieldElements/index.tsx +3 -0
- package/src/icons/MobileIcon.tsx +41 -0
- package/src/icons/OfflineIcon.tsx +38 -0
- package/src/icons/OnlineIcon.tsx +40 -0
- package/src/icons/OutOfficeIcon.tsx +37 -0
- package/src/icons/index.ts +4 -0
- package/src/index.tsx +28 -14
- package/src/setupTests.ts +1 -0
- package/src/{Table.tsx → table/Table.tsx} +24 -14
- package/src/table/TableBadge.tsx +46 -0
- package/src/table/TableBoolean.tsx +70 -0
- package/src/table/TableDate.tsx +38 -0
- package/src/{TableHeader.tsx → table/TableHeader.tsx} +3 -3
- package/src/table/TableHeaderCell.tsx +93 -0
- package/src/table/TableIconButton.tsx +62 -0
- package/src/table/TableNumber.tsx +29 -0
- package/src/{TableRow.tsx → table/TableRow.tsx} +28 -25
- package/src/table/TableText.tsx +29 -0
- package/src/table/TableTitle.tsx +32 -0
- package/src/{tableContext.tsx → table/tableContext.tsx} +1 -1
- package/dist/BlurBox.d.ts +0 -5
- package/dist/BlurBox.js +0 -28
- package/dist/BlurBox.js.map +0 -1
- package/dist/BlurBox.native.d.ts +0 -6
- package/dist/BlurBox.native.js +0 -30
- package/dist/BlurBox.native.js.map +0 -1
- package/dist/CustomSelect.d.ts +0 -3
- package/dist/CustomSelect.js +0 -47
- package/dist/CustomSelect.js.map +0 -1
- package/dist/DateTimeField.android.d.ts +0 -3
- package/dist/DateTimeField.android.js +0 -67
- package/dist/DateTimeField.android.js.map +0 -1
- package/dist/DateTimeField.ios.d.ts +0 -3
- package/dist/DateTimeField.ios.js +0 -49
- package/dist/DateTimeField.ios.js.map +0 -1
- package/dist/FieldWithLabels.d.ts +0 -3
- package/dist/FieldWithLabels.js +0 -8
- package/dist/FieldWithLabels.js.map +0 -1
- package/dist/Form.d.ts +0 -16
- package/dist/Form.js +0 -89
- package/dist/Form.js.map +0 -1
- package/dist/HeaderButtons.d.ts +0 -31
- package/dist/HeaderButtons.js +0 -53
- package/dist/HeaderButtons.js.map +0 -1
- package/dist/Mask.d.ts +0 -2
- package/dist/Mask.js +0 -19
- package/dist/Mask.js.map +0 -1
- package/dist/Pill.d.ts +0 -3
- package/dist/Pill.js +0 -8
- package/dist/Pill.js.map +0 -1
- package/dist/Pog.d.ts +0 -3
- package/dist/Pog.js +0 -48
- package/dist/Pog.js.map +0 -1
- package/dist/ProgressBar.d.ts +0 -3
- package/dist/ProgressBar.js +0 -35
- package/dist/ProgressBar.js.map +0 -1
- package/dist/SelectList.d.ts +0 -27
- package/dist/SelectList.js +0 -56
- package/dist/SelectList.js.map +0 -1
- package/dist/Switch.d.ts +0 -3
- package/dist/Switch.js +0 -20
- package/dist/Switch.js.map +0 -1
- package/dist/Table.js.map +0 -1
- package/dist/TableHeader.js.map +0 -1
- package/dist/TableHeaderCell.js +0 -36
- package/dist/TableHeaderCell.js.map +0 -1
- package/dist/TableRow.js +0 -30
- package/dist/TableRow.js.map +0 -1
- package/dist/WithLabel.d.ts +0 -3
- package/dist/WithLabel.js +0 -15
- package/dist/WithLabel.js.map +0 -1
- package/dist/tableContext.js.map +0 -1
- package/src/BlurBox.native.tsx +0 -40
- package/src/BlurBox.tsx +0 -31
- package/src/CustomSelect.tsx +0 -80
- package/src/DateTimeField.android.tsx +0 -103
- package/src/DateTimeField.ios.tsx +0 -85
- package/src/FieldWithLabels.tsx +0 -36
- package/src/Form.tsx +0 -175
- package/src/HeaderButtons.tsx +0 -107
- package/src/Mask.tsx +0 -21
- package/src/Pill.tsx +0 -22
- package/src/Pog.tsx +0 -75
- package/src/ProgressBar.tsx +0 -47
- package/src/SelectList.tsx +0 -109
- package/src/Switch.tsx +0 -18
- package/src/TableHeaderCell.tsx +0 -72
- package/src/WithLabel.tsx +0 -45
- /package/dist/{tableContext.js → table/tableContext.js} +0 -0
package/src/TapToEdit.tsx
CHANGED
|
@@ -1,48 +1,36 @@
|
|
|
1
1
|
import React, {ReactElement, useEffect, useState} from "react";
|
|
2
|
-
import {Linking} from "react-native";
|
|
2
|
+
import {Linking, View} from "react-native";
|
|
3
3
|
|
|
4
4
|
import {Box} from "./Box";
|
|
5
5
|
import {Button} from "./Button";
|
|
6
|
-
import {TapToEditProps} from "./Common";
|
|
6
|
+
import {AddressInterface, FieldProps, TapToEditProps} from "./Common";
|
|
7
7
|
import {Field} from "./Field";
|
|
8
8
|
import {Icon} from "./Icon";
|
|
9
9
|
// import {useOpenAPISpec} from "./OpenAPIContext";
|
|
10
10
|
import {Text} from "./Text";
|
|
11
|
-
import {Tooltip} from "./Tooltip";
|
|
12
11
|
|
|
13
12
|
const TapToEditTitle = ({
|
|
14
13
|
title,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
onlyShowDescriptionWhileEditing,
|
|
14
|
+
helperText,
|
|
15
|
+
onlyShowHelperTextWhileEditing,
|
|
18
16
|
}: {
|
|
19
|
-
|
|
20
|
-
showDescriptionAsTooltip?: boolean;
|
|
17
|
+
onlyShowHelperTextWhileEditing?: boolean;
|
|
21
18
|
title: string;
|
|
22
|
-
|
|
19
|
+
helperText?: string;
|
|
23
20
|
}): ReactElement => {
|
|
24
|
-
|
|
25
|
-
<
|
|
26
|
-
<Text
|
|
27
|
-
{Boolean(
|
|
28
|
-
<Text color="
|
|
29
|
-
{
|
|
21
|
+
return (
|
|
22
|
+
<View style={{flex: 1, justifyContent: "center"}}>
|
|
23
|
+
<Text bold>{title}</Text>
|
|
24
|
+
{Boolean(helperText && !onlyShowHelperTextWhileEditing) && (
|
|
25
|
+
<Text color="secondaryLight" size="sm">
|
|
26
|
+
{helperText}
|
|
30
27
|
</Text>
|
|
31
28
|
)}
|
|
32
|
-
</
|
|
29
|
+
</View>
|
|
33
30
|
);
|
|
34
|
-
if (showDescriptionAsTooltip) {
|
|
35
|
-
return (
|
|
36
|
-
<Tooltip idealDirection="top" text={description}>
|
|
37
|
-
{Title}
|
|
38
|
-
</Tooltip>
|
|
39
|
-
);
|
|
40
|
-
} else {
|
|
41
|
-
return Title;
|
|
42
|
-
}
|
|
43
31
|
};
|
|
44
32
|
|
|
45
|
-
export function formatAddress(address:
|
|
33
|
+
export function formatAddress(address: AddressInterface, asString = false): string {
|
|
46
34
|
let city = "";
|
|
47
35
|
if (address?.city) {
|
|
48
36
|
city = address?.state || address.zipcode ? `${address.city}, ` : `${address.city}`;
|
|
@@ -62,7 +50,7 @@ export function formatAddress(address: any, asString = false): string {
|
|
|
62
50
|
const addressLineOne = address?.address1 ?? "";
|
|
63
51
|
const addressLineTwo = address?.address2 ?? "";
|
|
64
52
|
const addressLineThree = `${city}${state}${zip}`;
|
|
65
|
-
const addressLineFour = `${countyName}${address?.countyCode ? `
|
|
53
|
+
const addressLineFour = `${countyName}${address?.countyCode ? ` (${countyCode})` : ""}`;
|
|
66
54
|
|
|
67
55
|
if (!asString) {
|
|
68
56
|
// Only add new lines if lines before and after are not empty to avoid awkward whitespace
|
|
@@ -83,25 +71,21 @@ export function formatAddress(address: any, asString = false): string {
|
|
|
83
71
|
export const TapToEdit = ({
|
|
84
72
|
value,
|
|
85
73
|
setValue,
|
|
86
|
-
placeholder,
|
|
87
74
|
title,
|
|
88
75
|
onSave,
|
|
89
76
|
editable = true,
|
|
90
77
|
isEditing = false,
|
|
91
|
-
rowBoxProps,
|
|
92
78
|
transform,
|
|
93
|
-
fieldComponent,
|
|
94
79
|
withConfirmation = false,
|
|
95
80
|
confirmationText = "Are you sure you want to save your changes?",
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
onlyShowDescriptionWhileEditing = true,
|
|
81
|
+
confirmationTitle = "Confirm",
|
|
82
|
+
helperText: propsHelperText,
|
|
83
|
+
onlyShowHelperTextWhileEditing = true,
|
|
100
84
|
...fieldProps
|
|
101
85
|
}: TapToEditProps): ReactElement => {
|
|
102
86
|
const [editing, setEditing] = useState(false);
|
|
103
87
|
const [initialValue, setInitialValue] = useState();
|
|
104
|
-
const
|
|
88
|
+
const helperText: string | undefined = propsHelperText;
|
|
105
89
|
// setInitialValue is called after initial render to handle the case where the value is updated
|
|
106
90
|
useEffect(() => {
|
|
107
91
|
setInitialValue(value);
|
|
@@ -115,43 +99,25 @@ export const TapToEdit = ({
|
|
|
115
99
|
|
|
116
100
|
if (editable && (editing || isEditing)) {
|
|
117
101
|
return (
|
|
118
|
-
<
|
|
119
|
-
{
|
|
120
|
-
|
|
121
|
-
|
|
102
|
+
<View style={{flexDirection: "column", width: "100%"}}>
|
|
103
|
+
<View style={{flex: 1, justifyContent: "center"}}>
|
|
104
|
+
<Text bold>{title}</Text>
|
|
105
|
+
</View>
|
|
106
|
+
<View style={{gap: 16}}>
|
|
122
107
|
<Field
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
108
|
+
grow={fieldProps?.type === "textarea" ? fieldProps.grow ?? true : undefined}
|
|
109
|
+
helperText={helperText}
|
|
110
|
+
row={fieldProps?.type === "textarea" ? 5 : undefined}
|
|
111
|
+
type={(fieldProps?.type ?? "text") as NonNullable<FieldProps["type"]>}
|
|
126
112
|
value={value}
|
|
127
|
-
onChange={setValue}
|
|
128
|
-
{...fieldProps}
|
|
113
|
+
onChange={setValue ?? (() => {})}
|
|
114
|
+
{...(fieldProps as any)}
|
|
129
115
|
/>
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
<Box direction="row">
|
|
133
|
-
<Button
|
|
134
|
-
color="blue"
|
|
135
|
-
confirmationHeading={confirmationHeading}
|
|
136
|
-
confirmationText={confirmationText}
|
|
137
|
-
inline
|
|
138
|
-
text="Save"
|
|
139
|
-
withConfirmation={withConfirmation}
|
|
140
|
-
onClick={async (): Promise<void> => {
|
|
141
|
-
if (!onSave) {
|
|
142
|
-
console.error("No onSave provided for editable TapToEdit");
|
|
143
|
-
} else {
|
|
144
|
-
setInitialValue(value);
|
|
145
|
-
await onSave(value);
|
|
146
|
-
}
|
|
147
|
-
setEditing(false);
|
|
148
|
-
}}
|
|
149
|
-
/>
|
|
150
|
-
<Box marginLeft={2}>
|
|
116
|
+
{editing && !isEditing && (
|
|
117
|
+
<View style={{flexDirection: "row", justifyContent: "flex-end", gap: 16}}>
|
|
151
118
|
<Button
|
|
152
|
-
color="red"
|
|
153
|
-
inline
|
|
154
119
|
text="Cancel"
|
|
120
|
+
variant="muted"
|
|
155
121
|
onClick={(): void => {
|
|
156
122
|
if (setValue) {
|
|
157
123
|
setValue(initialValue);
|
|
@@ -159,10 +125,27 @@ export const TapToEdit = ({
|
|
|
159
125
|
setEditing(false);
|
|
160
126
|
}}
|
|
161
127
|
/>
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
128
|
+
<View style={{marginLeft: 8}}>
|
|
129
|
+
<Button
|
|
130
|
+
confirmationText={confirmationText}
|
|
131
|
+
modalTitle={confirmationTitle}
|
|
132
|
+
text="Save"
|
|
133
|
+
withConfirmation={withConfirmation}
|
|
134
|
+
onClick={async (): Promise<void> => {
|
|
135
|
+
if (!onSave) {
|
|
136
|
+
console.error("No onSave provided for editable TapToEdit");
|
|
137
|
+
} else {
|
|
138
|
+
setInitialValue(value);
|
|
139
|
+
await onSave(value);
|
|
140
|
+
}
|
|
141
|
+
setEditing(false);
|
|
142
|
+
}}
|
|
143
|
+
/>
|
|
144
|
+
</View>
|
|
145
|
+
</View>
|
|
146
|
+
)}
|
|
147
|
+
</View>
|
|
148
|
+
</View>
|
|
166
149
|
);
|
|
167
150
|
} else {
|
|
168
151
|
let displayValue = value;
|
|
@@ -173,18 +156,19 @@ export const TapToEdit = ({
|
|
|
173
156
|
// If no transform, try and display the value reasonably.
|
|
174
157
|
if (fieldProps?.type === "boolean") {
|
|
175
158
|
displayValue = value ? "Yes" : "No";
|
|
176
|
-
|
|
177
|
-
//
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
//
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
159
|
+
// TODO: put transform back in after field types are updated
|
|
160
|
+
// } else if (fieldProps?.type === "percent") {
|
|
161
|
+
// // Prevent floating point errors from showing up by using parseFloat and precision.
|
|
162
|
+
// // Pass through parseFloat again to trim off insignificant zeroes.
|
|
163
|
+
// displayValue = `${parseFloat(parseFloat(String(value * 100)).toPrecision(7))}%`;
|
|
164
|
+
// } else if (fieldProps?.type === "currency") {
|
|
165
|
+
// // TODO: support currencies other than USD in Field and related components.
|
|
166
|
+
// const formatter = new Intl.NumberFormat("en-US", {
|
|
167
|
+
// style: "currency",
|
|
168
|
+
// currency: "USD",
|
|
169
|
+
// minimumFractionDigits: 2, // (this suffices for whole numbers, but will print 2500.10 as $2,500.1)
|
|
170
|
+
// });
|
|
171
|
+
// displayValue = formatter.format(value);
|
|
188
172
|
} else if (fieldProps?.type === "multiselect") {
|
|
189
173
|
// ???
|
|
190
174
|
displayValue = value.join(", ");
|
|
@@ -196,7 +180,7 @@ export const TapToEdit = ({
|
|
|
196
180
|
} catch (error) {
|
|
197
181
|
// Don't print an error message for empty values.
|
|
198
182
|
if (value) {
|
|
199
|
-
console.debug(`Invalid URL: $
|
|
183
|
+
console.debug(`Invalid URL: $value`);
|
|
200
184
|
}
|
|
201
185
|
displayValue = value;
|
|
202
186
|
}
|
|
@@ -221,45 +205,74 @@ export const TapToEdit = ({
|
|
|
221
205
|
// For textarea to display correctly, we place the title on its own line, then the text
|
|
222
206
|
// on the next line. This is because the textarea will take up the full width of the row.
|
|
223
207
|
return (
|
|
224
|
-
<
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
{...rowBoxProps}
|
|
208
|
+
<View
|
|
209
|
+
style={{
|
|
210
|
+
alignItems: fieldProps?.type === "textarea" ? "flex-start" : "center",
|
|
211
|
+
flexDirection: fieldProps?.type === "textarea" ? "column" : "row",
|
|
212
|
+
justifyContent: "space-between",
|
|
213
|
+
width: "100%",
|
|
214
|
+
}}
|
|
232
215
|
>
|
|
233
|
-
<
|
|
216
|
+
<View style={{flexDirection: "row", width: "100%", gap: 16}}>
|
|
234
217
|
<TapToEditTitle
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
showDescriptionAsTooltip={showDescriptionAsTooltip}
|
|
218
|
+
helperText={helperText}
|
|
219
|
+
onlyShowHelperTextWhileEditing={onlyShowHelperTextWhileEditing}
|
|
238
220
|
title={title}
|
|
239
221
|
/>
|
|
240
|
-
<
|
|
241
|
-
|
|
222
|
+
<View
|
|
223
|
+
style={{
|
|
224
|
+
flexDirection: "row",
|
|
225
|
+
flex: 1,
|
|
226
|
+
justifyContent: "flex-end",
|
|
227
|
+
}}
|
|
228
|
+
>
|
|
229
|
+
<Box
|
|
230
|
+
accessibilityHint=""
|
|
231
|
+
accessibilityLabel="Link"
|
|
232
|
+
justifyContent="start"
|
|
233
|
+
onClick={isClickable ? openLink : undefined}
|
|
234
|
+
>
|
|
242
235
|
{Boolean(fieldProps?.type !== "textarea") && (
|
|
243
236
|
<Text align="right" underline={isClickable}>
|
|
244
237
|
{displayValue}
|
|
245
238
|
</Text>
|
|
246
239
|
)}
|
|
247
240
|
</Box>
|
|
248
|
-
{editable && (
|
|
249
|
-
<Box
|
|
250
|
-
|
|
241
|
+
{editable && fieldProps?.type !== "textarea" && (
|
|
242
|
+
<Box
|
|
243
|
+
accessibilityHint=""
|
|
244
|
+
accessibilityLabel="Edit"
|
|
245
|
+
marginLeft={2}
|
|
246
|
+
width={16}
|
|
247
|
+
onClick={(): void => setEditing(true)}
|
|
248
|
+
>
|
|
249
|
+
<Icon iconName="pencil" size="md" />
|
|
251
250
|
</Box>
|
|
252
251
|
)}
|
|
253
|
-
</
|
|
254
|
-
</
|
|
252
|
+
</View>
|
|
253
|
+
</View>
|
|
255
254
|
{fieldProps?.type === "textarea" && (
|
|
256
|
-
|
|
257
|
-
<
|
|
258
|
-
{
|
|
259
|
-
|
|
260
|
-
|
|
255
|
+
<>
|
|
256
|
+
<View style={{marginTop: 8, paddingVertical: 8, width: "100%"}}>
|
|
257
|
+
<Text align="left" underline={isClickable}>
|
|
258
|
+
{displayValue}
|
|
259
|
+
</Text>
|
|
260
|
+
</View>
|
|
261
|
+
{editable && (
|
|
262
|
+
<Box
|
|
263
|
+
accessibilityHint=""
|
|
264
|
+
accessibilityLabel="Edit"
|
|
265
|
+
alignSelf="end"
|
|
266
|
+
marginLeft={2}
|
|
267
|
+
width={16}
|
|
268
|
+
onClick={(): void => setEditing(true)}
|
|
269
|
+
>
|
|
270
|
+
<Icon color="primary" iconName="pencil" size="md" />
|
|
271
|
+
</Box>
|
|
272
|
+
)}
|
|
273
|
+
</>
|
|
261
274
|
)}
|
|
262
|
-
</
|
|
275
|
+
</View>
|
|
263
276
|
);
|
|
264
277
|
}
|
|
265
278
|
};
|
package/src/Text.tsx
CHANGED
|
@@ -1,108 +1,118 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Nunito_400Regular,
|
|
3
|
+
Nunito_400Regular_Italic,
|
|
4
|
+
Nunito_500Medium,
|
|
5
|
+
Nunito_500Medium_Italic,
|
|
6
|
+
Nunito_700Bold,
|
|
7
|
+
Nunito_700Bold_Italic,
|
|
8
|
+
useFonts,
|
|
9
|
+
} from "@expo-google-fonts/nunito";
|
|
10
|
+
import React from "react";
|
|
11
|
+
import {Platform, Text as NativeText, TextStyle} from "react-native";
|
|
3
12
|
|
|
4
13
|
import {TextProps} from "./Common";
|
|
5
14
|
import {Hyperlink} from "./Hyperlink";
|
|
6
|
-
import {
|
|
15
|
+
import {useTheme} from "./Theme";
|
|
7
16
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
const fontSizeAndWeightWeb = {
|
|
18
|
+
sm: {size: 12, weight: "regular"},
|
|
19
|
+
md: {size: 16, weight: "regular"},
|
|
20
|
+
lg: {size: 18, weight: "medium"},
|
|
21
|
+
xl: {size: 20, weight: "medium"},
|
|
13
22
|
};
|
|
14
23
|
|
|
24
|
+
const fontSizeAndWeighMobile = {
|
|
25
|
+
sm: {size: 10, weight: "regular"},
|
|
26
|
+
md: {size: 14, weight: "regular"},
|
|
27
|
+
lg: {size: 16, weight: "medium"},
|
|
28
|
+
xl: {size: 18, weight: "medium"},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const fontSizes = Platform.OS === "web" ? fontSizeAndWeightWeb : fontSizeAndWeighMobile;
|
|
32
|
+
|
|
15
33
|
export const Text = ({
|
|
16
34
|
align = "left",
|
|
35
|
+
bold,
|
|
17
36
|
children,
|
|
18
37
|
color,
|
|
19
|
-
inline = false,
|
|
20
38
|
italic = false,
|
|
21
|
-
overflow,
|
|
22
39
|
size = "md",
|
|
23
40
|
truncate = false,
|
|
24
|
-
font,
|
|
25
|
-
onPress,
|
|
26
41
|
underline,
|
|
27
42
|
numberOfLines,
|
|
28
43
|
skipLinking,
|
|
29
44
|
testID,
|
|
30
|
-
weight = "normal",
|
|
31
45
|
}: TextProps): React.ReactElement => {
|
|
32
|
-
const {theme} =
|
|
46
|
+
const {theme} = useTheme();
|
|
33
47
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
computedFont = "primaryBoldFont";
|
|
45
|
-
} else {
|
|
46
|
-
computedFont = "primaryFont";
|
|
47
|
-
}
|
|
48
|
-
} else if (font === "secondary") {
|
|
49
|
-
if (weight === "bold") {
|
|
50
|
-
computedFont = "secondaryBoldFont";
|
|
51
|
-
} else {
|
|
52
|
-
computedFont = "secondaryFont";
|
|
53
|
-
}
|
|
54
|
-
} else if (font === "button") {
|
|
55
|
-
computedFont = "buttonFont";
|
|
56
|
-
} else if (font === "title") {
|
|
57
|
-
computedFont = "titleFont";
|
|
58
|
-
} else if (font === "accent") {
|
|
59
|
-
if (weight === "bold") {
|
|
60
|
-
computedFont = "accentBoldFont";
|
|
61
|
-
} else {
|
|
62
|
-
computedFont = "accentFont";
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (weight === "bold") {
|
|
66
|
-
style.fontWeight = "bold";
|
|
67
|
-
}
|
|
48
|
+
// TODO: make fonts part of theme.
|
|
49
|
+
const [fontsLoaded] = useFonts({
|
|
50
|
+
"text-bold": Nunito_700Bold,
|
|
51
|
+
"text-bold-italic": Nunito_700Bold_Italic,
|
|
52
|
+
"text-medium": Nunito_500Medium,
|
|
53
|
+
"text-medium-italic": Nunito_500Medium_Italic,
|
|
54
|
+
text: Nunito_400Regular,
|
|
55
|
+
"text-regular": Nunito_400Regular,
|
|
56
|
+
"text-regular-italic": Nunito_400Regular_Italic,
|
|
57
|
+
});
|
|
68
58
|
|
|
69
|
-
|
|
59
|
+
// TODO: How should we handle unloaded fonts.
|
|
60
|
+
if (!fontsLoaded) {
|
|
61
|
+
// eslint-disable-next-line react-native/no-raw-text
|
|
62
|
+
return <NativeText />;
|
|
63
|
+
}
|
|
70
64
|
|
|
71
|
-
|
|
72
|
-
if (align) {
|
|
73
|
-
style.textAlign = align;
|
|
74
|
-
}
|
|
75
|
-
if (color) {
|
|
76
|
-
style.color = theme[color];
|
|
77
|
-
} else {
|
|
78
|
-
style.color = theme.darkGray;
|
|
79
|
-
}
|
|
65
|
+
const style: TextStyle = {};
|
|
80
66
|
|
|
81
|
-
|
|
82
|
-
|
|
67
|
+
if (size === "sm" || size === "md") {
|
|
68
|
+
if (bold && italic) {
|
|
69
|
+
style.fontFamily = "text-bold-italic";
|
|
70
|
+
} else if (italic) {
|
|
71
|
+
style.fontFamily = "text-regular-italic";
|
|
72
|
+
} else if (bold) {
|
|
73
|
+
style.fontFamily = "text-bold";
|
|
74
|
+
} else {
|
|
75
|
+
style.fontFamily = "text-regular";
|
|
83
76
|
}
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
} else {
|
|
78
|
+
if (bold && italic) {
|
|
79
|
+
style.fontFamily = "text-bold-italic";
|
|
80
|
+
} else if (italic) {
|
|
81
|
+
style.fontFamily = "text-medium-italic";
|
|
82
|
+
} else if (bold) {
|
|
83
|
+
style.fontFamily = "text-bold";
|
|
84
|
+
} else {
|
|
85
|
+
style.fontFamily = "text-medium";
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
// if (numberOfLines !== 1 && !inline) {
|
|
89
|
-
// style.flexWrap = "wrap";
|
|
90
|
-
// }
|
|
87
|
+
}
|
|
91
88
|
|
|
92
|
-
|
|
89
|
+
style.fontSize = fontSizes[size].size;
|
|
90
|
+
if (align) {
|
|
91
|
+
style.textAlign = align;
|
|
92
|
+
}
|
|
93
|
+
if (color) {
|
|
94
|
+
style.color = theme.text[color];
|
|
95
|
+
} else {
|
|
96
|
+
style.color = theme.text.primary;
|
|
93
97
|
}
|
|
94
98
|
|
|
99
|
+
if (italic) {
|
|
100
|
+
style.fontStyle = "italic";
|
|
101
|
+
}
|
|
102
|
+
if (underline) {
|
|
103
|
+
style.textDecorationLine = "underline";
|
|
104
|
+
}
|
|
95
105
|
let lines = 0;
|
|
96
106
|
if (numberOfLines && truncate && numberOfLines > 1) {
|
|
97
107
|
console.error(`Cannot truncate Text and have ${numberOfLines} lines`);
|
|
98
108
|
}
|
|
99
109
|
if (numberOfLines) {
|
|
100
110
|
lines = numberOfLines;
|
|
101
|
-
} else if (
|
|
111
|
+
} else if (truncate) {
|
|
102
112
|
lines = 1;
|
|
103
113
|
}
|
|
104
114
|
const inner = (
|
|
105
|
-
<NativeText numberOfLines={lines} style={
|
|
115
|
+
<NativeText numberOfLines={lines} style={style} testID={testID}>
|
|
106
116
|
{children}
|
|
107
117
|
</NativeText>
|
|
108
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 const TextArea = (
|
|
7
|
-
return <TextField {...
|
|
6
|
+
export const TextArea = (props: TextAreaProps): React.ReactElement => {
|
|
7
|
+
return <TextField {...props} multiline type="text" />;
|
|
8
8
|
};
|