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/IconButton.tsx
CHANGED
|
@@ -1,176 +1,208 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import FontAwesome6 from "@expo/vector-icons/FontAwesome6";
|
|
2
|
+
import debounce from "lodash/debounce";
|
|
3
|
+
import React, {FC, useState} from "react";
|
|
4
|
+
import {ActivityIndicator, Pressable, Text as NativeText, View} from "react-native";
|
|
3
5
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {Icon} from "./Icon";
|
|
6
|
+
import {IconButtonProps} from "./Common";
|
|
7
|
+
import {isMobileDevice} from "./MediaQuery";
|
|
7
8
|
import {Modal} from "./Modal";
|
|
8
9
|
import {Text} from "./Text";
|
|
9
|
-
import {
|
|
10
|
+
import {useTheme} from "./Theme";
|
|
10
11
|
import {Tooltip} from "./Tooltip";
|
|
11
12
|
import {Unifier} from "./Unifier";
|
|
13
|
+
import {isNative} from "./Utilities";
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
size,
|
|
22
|
-
bgColor = "transparent",
|
|
23
|
-
withConfirmation = false,
|
|
24
|
-
confirmationText = "Are you sure you want to continue?",
|
|
25
|
-
confirmationHeading = "Confirm",
|
|
26
|
-
tooltip,
|
|
27
|
-
indicator,
|
|
28
|
-
indicatorNumber,
|
|
29
|
-
indicatorStyle = {position: "bottomRight", color: "primary"},
|
|
30
|
-
testID,
|
|
31
|
-
}: IconButtonProps,
|
|
32
|
-
ref
|
|
33
|
-
) => {
|
|
34
|
-
const {theme} = useContext(ThemeContext);
|
|
35
|
-
const [showConfirmation, setShowConfirmation] = useState(false);
|
|
15
|
+
type ConfirmationModalProps = {
|
|
16
|
+
visible: boolean;
|
|
17
|
+
title: string;
|
|
18
|
+
subtitle?: string;
|
|
19
|
+
text: string;
|
|
20
|
+
onConfirm: () => void;
|
|
21
|
+
onCancel: () => void;
|
|
22
|
+
};
|
|
36
23
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
24
|
+
const ConfirmationModal: FC<ConfirmationModalProps> = ({
|
|
25
|
+
visible,
|
|
26
|
+
title,
|
|
27
|
+
subtitle,
|
|
28
|
+
text,
|
|
29
|
+
onConfirm,
|
|
30
|
+
onCancel,
|
|
31
|
+
}) => {
|
|
32
|
+
return (
|
|
33
|
+
<Modal
|
|
34
|
+
primaryButtonOnClick={onConfirm}
|
|
35
|
+
primaryButtonText="Confirm"
|
|
36
|
+
secondaryButtonOnClick={onCancel}
|
|
37
|
+
secondaryButtonText="Cancel"
|
|
38
|
+
subtitle={subtitle}
|
|
39
|
+
title={title}
|
|
40
|
+
visible={visible}
|
|
41
|
+
onDismiss={onCancel}
|
|
42
|
+
>
|
|
43
|
+
<Text>{text}</Text>
|
|
44
|
+
</Modal>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
const IconButtonComponent: FC<IconButtonProps> = ({
|
|
49
|
+
accessibilityHint,
|
|
50
|
+
accessibilityLabel,
|
|
51
|
+
confirmationHeading = "Confirm",
|
|
52
|
+
confirmationText = "Are you sure you want to continue?",
|
|
53
|
+
iconName,
|
|
54
|
+
indicator,
|
|
55
|
+
indicatorText,
|
|
56
|
+
loading: propsLoading = false,
|
|
57
|
+
testID,
|
|
58
|
+
variant = "primary",
|
|
59
|
+
withConfirmation = false,
|
|
60
|
+
tooltipText,
|
|
61
|
+
onClick,
|
|
62
|
+
}) => {
|
|
63
|
+
const [loading, setLoading] = useState(propsLoading);
|
|
64
|
+
const [showConfirmation, setShowConfirmation] = useState(false);
|
|
65
|
+
const {theme} = useTheme();
|
|
66
|
+
let accessLabel = accessibilityLabel;
|
|
67
|
+
if (tooltipText && accessibilityLabel === "") {
|
|
68
|
+
accessLabel = tooltipText;
|
|
69
|
+
}
|
|
53
70
|
|
|
54
|
-
|
|
71
|
+
if (!theme) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
55
74
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
bottomLeft: {bottom: "10%", left: "10%"},
|
|
59
|
-
topRight: {top: "-5%", right: "-5%"},
|
|
60
|
-
topLeft: {top: "10%", left: "10%"},
|
|
61
|
-
};
|
|
75
|
+
let backgroundColor = theme.surface.primary;
|
|
76
|
+
let color = theme.text.inverted;
|
|
62
77
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
78
|
+
if (variant === "secondary") {
|
|
79
|
+
backgroundColor = theme.surface.neutralLight;
|
|
80
|
+
color = theme.surface.secondaryDark;
|
|
81
|
+
} else if (variant === "muted") {
|
|
82
|
+
backgroundColor = theme.text.inverted;
|
|
83
|
+
color = theme.surface.primary;
|
|
84
|
+
} else if (variant === "navigation") {
|
|
85
|
+
backgroundColor = theme.text.inverted;
|
|
86
|
+
color = theme.text.primary;
|
|
87
|
+
} else if (variant === "destructive") {
|
|
88
|
+
backgroundColor = theme.text.inverted;
|
|
89
|
+
color = theme.text.error;
|
|
90
|
+
}
|
|
67
91
|
|
|
68
|
-
|
|
69
|
-
if (indicator && indicatorNumber && indicatorNumber > 0) {
|
|
70
|
-
return (
|
|
71
|
-
<View style={numberIndicatorProps as ViewStyle}>
|
|
72
|
-
<Box
|
|
73
|
-
alignItems="center"
|
|
74
|
-
color={indicatorStyle.color}
|
|
75
|
-
dangerouslySetInlineStyle={{
|
|
76
|
-
__style: {
|
|
77
|
-
padding: indicatorNumber && indicatorNumber > 9 ? 2 : 0,
|
|
78
|
-
},
|
|
79
|
-
}}
|
|
80
|
-
justifyContent="center"
|
|
81
|
-
minHeight={15}
|
|
82
|
-
minWidth={15}
|
|
83
|
-
rounding="pill"
|
|
84
|
-
>
|
|
85
|
-
<Text color="white" size="sm" weight="bold">
|
|
86
|
-
{indicatorNumber}
|
|
87
|
-
</Text>
|
|
88
|
-
</Box>
|
|
89
|
-
</View>
|
|
90
|
-
);
|
|
91
|
-
} else if (indicator) {
|
|
92
|
-
return (
|
|
93
|
-
<View style={indicatorPosition as ViewStyle}>
|
|
94
|
-
<Icon color={indicatorStyle.color} name="circle" prefix={prefix || "fas"} size="sm" />
|
|
95
|
-
</View>
|
|
96
|
-
);
|
|
97
|
-
} else {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
92
|
+
const indicatorColor = indicator ? theme.surface[indicator] : undefined;
|
|
101
93
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
94
|
+
return (
|
|
95
|
+
<Pressable
|
|
96
|
+
accessibilityHint={
|
|
97
|
+
accessibilityHint ?? withConfirmation
|
|
98
|
+
? `Opens a confirmation dialog to confirm ${accessLabel}`
|
|
99
|
+
: `Press to perform ${accessLabel} action`
|
|
100
|
+
}
|
|
101
|
+
accessibilityLabel={accessLabel}
|
|
102
|
+
accessibilityRole="button"
|
|
103
|
+
disabled={loading}
|
|
104
|
+
style={{
|
|
105
|
+
alignItems: "center",
|
|
106
|
+
backgroundColor,
|
|
107
|
+
borderRadius: theme.radius.rounded,
|
|
108
|
+
justifyContent: "center",
|
|
109
|
+
height: 32,
|
|
110
|
+
width: 32,
|
|
111
|
+
}}
|
|
112
|
+
testID={testID}
|
|
113
|
+
onPress={debounce(
|
|
114
|
+
async () => {
|
|
115
|
+
await Unifier.utils.haptic();
|
|
116
|
+
setLoading(true);
|
|
117
|
+
try {
|
|
118
|
+
if (withConfirmation && !showConfirmation) {
|
|
119
|
+
setShowConfirmation(true);
|
|
120
|
+
} else if (onClick) {
|
|
121
|
+
await onClick();
|
|
122
|
+
}
|
|
123
|
+
} catch (error) {
|
|
124
|
+
setLoading(false);
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
setLoading(false);
|
|
128
|
+
},
|
|
129
|
+
500,
|
|
130
|
+
{leading: true}
|
|
131
|
+
)}
|
|
132
|
+
>
|
|
133
|
+
{Boolean(loading) ? (
|
|
134
|
+
<ActivityIndicator color={color} size="small" />
|
|
135
|
+
) : (
|
|
136
|
+
<FontAwesome6
|
|
137
|
+
color={color}
|
|
138
|
+
name={iconName}
|
|
139
|
+
size={variant === "navigation" ? 20 : 16}
|
|
140
|
+
solid
|
|
141
|
+
/>
|
|
142
|
+
)}
|
|
143
|
+
{Boolean(indicator) && (
|
|
144
|
+
<View
|
|
145
|
+
style={{
|
|
146
|
+
display: "flex",
|
|
147
|
+
height: 12,
|
|
148
|
+
width: 12,
|
|
149
|
+
borderRadius: 10,
|
|
150
|
+
padding: theme.spacing.xs as any,
|
|
151
|
+
backgroundColor: indicatorColor,
|
|
152
|
+
position: "absolute",
|
|
153
|
+
alignItems: "center",
|
|
154
|
+
justifyContent: "center",
|
|
155
|
+
bottom: 0,
|
|
156
|
+
right: 0,
|
|
109
157
|
}}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
158
|
+
>
|
|
159
|
+
{Boolean(indicatorText) && (
|
|
160
|
+
<NativeText
|
|
161
|
+
style={{
|
|
162
|
+
color: theme.text.inverted,
|
|
163
|
+
textAlign: "center",
|
|
164
|
+
fontFamily: "text",
|
|
165
|
+
fontSize: 10,
|
|
166
|
+
fontWeight: 700,
|
|
167
|
+
}}
|
|
168
|
+
>
|
|
169
|
+
{indicatorText}
|
|
170
|
+
</NativeText>
|
|
171
|
+
)}
|
|
172
|
+
</View>
|
|
173
|
+
)}
|
|
174
|
+
{withConfirmation && (
|
|
175
|
+
<ConfirmationModal
|
|
176
|
+
subtitle={undefined}
|
|
177
|
+
text={confirmationText}
|
|
178
|
+
title={confirmationHeading}
|
|
114
179
|
visible={showConfirmation}
|
|
115
|
-
|
|
180
|
+
onCancel={() => setShowConfirmation(false)}
|
|
181
|
+
onConfirm={async () => {
|
|
182
|
+
await onClick();
|
|
116
183
|
setShowConfirmation(false);
|
|
117
184
|
}}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
function renderIconButton(): React.ReactElement {
|
|
125
|
-
return (
|
|
126
|
-
<>
|
|
127
|
-
<Pressable
|
|
128
|
-
ref={ref as any}
|
|
129
|
-
hitSlop={{top: 10, left: 10, bottom: 10, right: 10}}
|
|
130
|
-
style={{
|
|
131
|
-
opacity,
|
|
132
|
-
backgroundColor: color,
|
|
133
|
-
borderRadius: 100,
|
|
134
|
-
// paddingBottom: iconSizeToNumber(size) / 4,
|
|
135
|
-
// paddingTop: iconSizeToNumber(size) / 4,
|
|
136
|
-
// paddingLeft: iconSizeToNumber(size) / 2,
|
|
137
|
-
// paddingRight: iconSizeToNumber(size) / 2,
|
|
138
|
-
width: iconSizeToNumber(size) * 2.5,
|
|
139
|
-
height: iconSizeToNumber(size) * 2.5,
|
|
140
|
-
display: "flex",
|
|
141
|
-
justifyContent: "center",
|
|
142
|
-
alignItems: "center",
|
|
143
|
-
}}
|
|
144
|
-
testID={testID}
|
|
145
|
-
onPress={async () => {
|
|
146
|
-
await Unifier.utils.haptic();
|
|
147
|
-
if (withConfirmation && !showConfirmation) {
|
|
148
|
-
setShowConfirmation(true);
|
|
149
|
-
} else if (onClick) {
|
|
150
|
-
onClick();
|
|
151
|
-
}
|
|
152
|
-
}}
|
|
153
|
-
>
|
|
154
|
-
<Icon color={iconColor} name={icon} prefix={prefix || "fas"} size={size} />
|
|
155
|
-
{renderIndicator()}
|
|
156
|
-
</Pressable>
|
|
185
|
+
/>
|
|
186
|
+
)}
|
|
187
|
+
</Pressable>
|
|
188
|
+
);
|
|
189
|
+
};
|
|
157
190
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
191
|
+
export const IconButton: FC<IconButtonProps> = (props) => {
|
|
192
|
+
const {tooltipText, tooltipIdealPosition, tooltipIncludeArrow = false} = props;
|
|
193
|
+
const isMobileOrNative = isMobileDevice() || isNative();
|
|
162
194
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return renderIconButton();
|
|
174
|
-
}
|
|
195
|
+
if (tooltipText && !isMobileOrNative) {
|
|
196
|
+
return (
|
|
197
|
+
<Tooltip
|
|
198
|
+
idealPosition={tooltipIdealPosition}
|
|
199
|
+
includeArrow={tooltipIncludeArrow}
|
|
200
|
+
text={tooltipText}
|
|
201
|
+
>
|
|
202
|
+
<IconButtonComponent {...props} />
|
|
203
|
+
</Tooltip>
|
|
204
|
+
);
|
|
175
205
|
}
|
|
176
|
-
|
|
206
|
+
|
|
207
|
+
return <IconButtonComponent {...props} />;
|
|
208
|
+
};
|
|
@@ -3,15 +3,13 @@ import React from "react";
|
|
|
3
3
|
import {InfoTooltipButtonProps} from "./Common";
|
|
4
4
|
import {IconButton} from "./IconButton";
|
|
5
5
|
|
|
6
|
-
export const InfoTooltipButton = ({text
|
|
6
|
+
export const InfoTooltipButton = ({text}: InfoTooltipButtonProps): React.ReactElement => {
|
|
7
7
|
return (
|
|
8
8
|
<IconButton
|
|
9
|
+
accessibilityHint="Show info tooltip"
|
|
9
10
|
accessibilityLabel="info"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
iconColor="blue"
|
|
13
|
-
size={size}
|
|
14
|
-
tooltip={{text}}
|
|
11
|
+
iconName="exclamation"
|
|
12
|
+
tooltipText={text}
|
|
15
13
|
onClick={() => {}}
|
|
16
14
|
/>
|
|
17
15
|
);
|
package/src/Link.tsx
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {Linking} from "react-native";
|
|
2
|
+
import {Linking, Pressable} from "react-native";
|
|
3
3
|
|
|
4
4
|
import {LinkProps} from "./Common";
|
|
5
5
|
import {Text} from "./Text";
|
|
6
6
|
|
|
7
|
-
export const Link = (
|
|
7
|
+
export const Link = ({text, href, onClick}: LinkProps): React.ReactElement => {
|
|
8
|
+
if (!href && !onClick) {
|
|
9
|
+
console.error("Link component requires either href or onClick prop");
|
|
10
|
+
}
|
|
8
11
|
return (
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
<Pressable
|
|
13
|
+
accessibilityRole="button"
|
|
14
|
+
hitSlop={20}
|
|
15
|
+
onPress={() => (onClick ? onClick() : Linking.openURL(href))}
|
|
16
|
+
>
|
|
17
|
+
<Text color="link" underline>
|
|
18
|
+
{text}
|
|
19
|
+
</Text>
|
|
20
|
+
</Pressable>
|
|
12
21
|
);
|
|
13
22
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {useEffect, useRef, useState} from "react";
|
|
2
2
|
import {TextStyle, TouchableOpacity, View} from "react-native";
|
|
3
3
|
import {
|
|
4
4
|
GooglePlacesAutocomplete,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import {AddressAutocompleteProps} from "./Common";
|
|
9
9
|
import {GOOGLE_PLACES_API_RESTRICTIONS} from "./Constants";
|
|
10
10
|
import {TextField} from "./TextField";
|
|
11
|
-
import {
|
|
11
|
+
import {useTheme} from "./Theme";
|
|
12
12
|
import {processAddressComponents} from "./Utilities";
|
|
13
13
|
|
|
14
14
|
export const MobileAddressAutocomplete = ({
|
|
@@ -22,7 +22,7 @@ export const MobileAddressAutocomplete = ({
|
|
|
22
22
|
handleAutoCompleteChange,
|
|
23
23
|
testID,
|
|
24
24
|
}: AddressAutocompleteProps) => {
|
|
25
|
-
const {theme} =
|
|
25
|
+
const {theme} = useTheme();
|
|
26
26
|
const ref = useRef<GooglePlacesAutocompleteRef | null>(null);
|
|
27
27
|
const [isFocused, setIsFocused] = useState(false);
|
|
28
28
|
|
|
@@ -36,20 +36,20 @@ export const MobileAddressAutocomplete = ({
|
|
|
36
36
|
}, []);
|
|
37
37
|
|
|
38
38
|
const textInputContainerStyles = {
|
|
39
|
-
backgroundColor: theme.
|
|
40
|
-
borderColor: isFocused ? theme.
|
|
39
|
+
backgroundColor: theme.surface.base,
|
|
40
|
+
borderColor: isFocused ? theme.border.hover : theme.border.default,
|
|
41
41
|
borderWidth: isFocused ? 5 : 1,
|
|
42
|
-
borderRadius:
|
|
42
|
+
borderRadius: theme.radius.default,
|
|
43
43
|
paddingHorizontal: isFocused ? 10 : 14,
|
|
44
44
|
paddingVertical: isFocused ? 0 : 4,
|
|
45
45
|
...(styles?.textInputContainer as object),
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
const textInputStyles = {
|
|
49
|
-
backgroundColor: theme.
|
|
50
|
-
borderRadius:
|
|
51
|
-
color: theme.
|
|
52
|
-
fontFamily:
|
|
49
|
+
backgroundColor: theme.surface.base,
|
|
50
|
+
borderRadius: theme.radius.default,
|
|
51
|
+
color: theme.text.primary,
|
|
52
|
+
fontFamily: "text",
|
|
53
53
|
fontSize: (styles?.textInput as TextStyle)?.fontSize ?? 14,
|
|
54
54
|
height: 40,
|
|
55
55
|
marginBottom: 0,
|
|
@@ -63,7 +63,6 @@ export const MobileAddressAutocomplete = ({
|
|
|
63
63
|
<TextField
|
|
64
64
|
disabled={disabled}
|
|
65
65
|
id="address1"
|
|
66
|
-
label="Street Address"
|
|
67
66
|
testID={testID}
|
|
68
67
|
type="text"
|
|
69
68
|
value={inputValue}
|
|
@@ -73,7 +72,12 @@ export const MobileAddressAutocomplete = ({
|
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
return (
|
|
76
|
-
<TouchableOpacity
|
|
75
|
+
<TouchableOpacity
|
|
76
|
+
accessibilityRole="button"
|
|
77
|
+
activeOpacity={1}
|
|
78
|
+
style={{flex: 1}}
|
|
79
|
+
onPress={() => setIsFocused(false)}
|
|
80
|
+
>
|
|
77
81
|
<View>
|
|
78
82
|
<GooglePlacesAutocomplete
|
|
79
83
|
ref={ref}
|
|
@@ -101,7 +105,7 @@ export const MobileAddressAutocomplete = ({
|
|
|
101
105
|
onFocus: () => setIsFocused(true),
|
|
102
106
|
onBlur: () => setIsFocused(false),
|
|
103
107
|
onChange: (event) => {
|
|
104
|
-
handleAddressChange(
|
|
108
|
+
handleAddressChange(event.nativeEvent.text);
|
|
105
109
|
},
|
|
106
110
|
}}
|
|
107
111
|
onPress={(data, details = null) => {
|