ferns-ui 0.47.10 → 1.0.0-beta.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 +31 -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 +90 -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 +1071 -406
- 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 +35 -67
- 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 +31 -30
- 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 +189 -89
- 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 +84 -0
- package/src/ActionSheet.tsx +8 -5
- package/src/AddressField.tsx +122 -0
- package/src/Avatar.tsx +193 -147
- package/src/Badge.tsx +107 -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 +1304 -2041
- 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 +44 -96
- 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 +58 -37
- 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 +258 -141
- 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/Banner.tsx
CHANGED
|
@@ -1,13 +1,90 @@
|
|
|
1
|
+
import debounce from "lodash/debounce";
|
|
1
2
|
import React, {useEffect, useState} from "react";
|
|
3
|
+
import {ActivityIndicator, Pressable, Text as NativeText, View} from "react-native";
|
|
2
4
|
|
|
3
5
|
import {Box} from "./Box";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
+
import {BannerProps, IconName, SurfaceTheme} from "./Common";
|
|
7
|
+
import {DismissButton} from "./DismissButton";
|
|
6
8
|
import {Icon} from "./Icon";
|
|
7
|
-
import {
|
|
8
|
-
import {Text} from "./Text";
|
|
9
|
+
import {useTheme} from "./Theme";
|
|
9
10
|
import {Unifier} from "./Unifier";
|
|
10
11
|
|
|
12
|
+
type BannerButtonProps = {
|
|
13
|
+
buttonIconName?: string;
|
|
14
|
+
buttonOnClick: () => void | Promise<void>;
|
|
15
|
+
buttonText: string;
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const BannerButton = ({
|
|
20
|
+
loading: propsLoading,
|
|
21
|
+
buttonText,
|
|
22
|
+
buttonIconName,
|
|
23
|
+
buttonOnClick,
|
|
24
|
+
}: BannerButtonProps): React.ReactElement | null => {
|
|
25
|
+
const [loading, setLoading] = useState(propsLoading);
|
|
26
|
+
const {theme} = useTheme();
|
|
27
|
+
|
|
28
|
+
if (!theme) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Pressable
|
|
34
|
+
accessibilityHint={`Press to perform action ${buttonText}`}
|
|
35
|
+
accessibilityLabel={buttonText}
|
|
36
|
+
accessibilityRole="button"
|
|
37
|
+
style={{
|
|
38
|
+
alignItems: "center",
|
|
39
|
+
alignSelf: "stretch",
|
|
40
|
+
backgroundColor: theme.surface.base,
|
|
41
|
+
borderRadius: theme.radius.rounded as any,
|
|
42
|
+
flexDirection: "column",
|
|
43
|
+
justifyContent: "center",
|
|
44
|
+
paddingHorizontal: 12,
|
|
45
|
+
paddingVertical: 4,
|
|
46
|
+
}}
|
|
47
|
+
onPress={debounce(
|
|
48
|
+
async () => {
|
|
49
|
+
await Unifier.utils.haptic();
|
|
50
|
+
setLoading(true);
|
|
51
|
+
try {
|
|
52
|
+
await buttonOnClick();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
setLoading(false);
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
setLoading(false);
|
|
58
|
+
},
|
|
59
|
+
500,
|
|
60
|
+
{leading: true}
|
|
61
|
+
)}
|
|
62
|
+
>
|
|
63
|
+
<View style={{flexDirection: "row"}}>
|
|
64
|
+
<View style={{flexDirection: "row-reverse"}}>
|
|
65
|
+
{Boolean(buttonIconName) && (
|
|
66
|
+
<View
|
|
67
|
+
style={{
|
|
68
|
+
alignSelf: "center",
|
|
69
|
+
marginRight: 0,
|
|
70
|
+
marginLeft: 8,
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
<Icon iconName={buttonIconName as IconName} type="solid" />
|
|
74
|
+
</View>
|
|
75
|
+
)}
|
|
76
|
+
<NativeText style={{fontSize: 12}}>{buttonText}</NativeText>
|
|
77
|
+
</View>
|
|
78
|
+
{Boolean(loading) && (
|
|
79
|
+
<Box marginLeft={2}>
|
|
80
|
+
<ActivityIndicator size="small" />
|
|
81
|
+
</Box>
|
|
82
|
+
)}
|
|
83
|
+
</View>
|
|
84
|
+
</Pressable>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
11
88
|
function getKey(id: string): string {
|
|
12
89
|
return `@FernsUI:${id}`;
|
|
13
90
|
}
|
|
@@ -17,137 +94,107 @@ export const hideBanner = (id: string): Promise<void> => {
|
|
|
17
94
|
return Unifier.storage.setItem(getKey(id), "true");
|
|
18
95
|
};
|
|
19
96
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
97
|
+
export const Banner = (props: BannerProps): React.ReactElement | null => {
|
|
98
|
+
const {id, text, status = "info", dismissible = false, hasIcon = false, buttonOnClick} = props;
|
|
99
|
+
|
|
100
|
+
const {buttonText, buttonIconName} = props as BannerButtonProps;
|
|
101
|
+
|
|
102
|
+
const {theme} = useTheme();
|
|
103
|
+
|
|
104
|
+
let bgColor: keyof SurfaceTheme = "secondaryDark";
|
|
105
|
+
|
|
106
|
+
if (status === "alert") {
|
|
107
|
+
bgColor = "error";
|
|
108
|
+
} else if (status === "warning") {
|
|
109
|
+
bgColor = "warning";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const [show, setShow] = useState(true);
|
|
26
113
|
|
|
27
|
-
export const Banner = ({
|
|
28
|
-
id,
|
|
29
|
-
customButtonProps,
|
|
30
|
-
text,
|
|
31
|
-
subtext,
|
|
32
|
-
color = "secondaryDark",
|
|
33
|
-
iconName,
|
|
34
|
-
textColor = "white",
|
|
35
|
-
negativeXMargin = 0,
|
|
36
|
-
width,
|
|
37
|
-
shape,
|
|
38
|
-
type,
|
|
39
|
-
onClick,
|
|
40
|
-
}: BannerProps): React.ReactElement | null => {
|
|
41
|
-
// If the banner is not type dismiss, show it immediately.
|
|
42
|
-
const {ACTION, DISMISS, CUSTOM_BUTTON} = BannerType;
|
|
43
|
-
const [show, setShow] = useState(type !== DISMISS);
|
|
44
114
|
// Load seen from async storage.
|
|
45
115
|
useEffect(() => {
|
|
46
|
-
if (
|
|
116
|
+
if (dismissible) {
|
|
47
117
|
void Unifier.storage.getItem(getKey(id)).then((isSeen) => {
|
|
48
118
|
console.debug(`[banner] ${getKey(id)} seen? ${isSeen}`);
|
|
49
119
|
setShow(!isSeen);
|
|
50
120
|
});
|
|
51
121
|
}
|
|
52
122
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
|
-
}, [id
|
|
123
|
+
}, [id]);
|
|
54
124
|
|
|
55
125
|
const dismiss = async (): Promise<void> => {
|
|
56
|
-
if (
|
|
126
|
+
if (!dismissible) {
|
|
57
127
|
return;
|
|
58
128
|
}
|
|
59
129
|
await hideBanner(id);
|
|
60
130
|
setShow(false);
|
|
61
131
|
};
|
|
62
132
|
|
|
63
|
-
const renderButton = (): React.ReactElement | null => {
|
|
64
|
-
if (type === CUSTOM_BUTTON) {
|
|
65
|
-
return (
|
|
66
|
-
<Button
|
|
67
|
-
{...customButtonProps}
|
|
68
|
-
color={customButtonProps?.color ?? "primary"}
|
|
69
|
-
size={customButtonProps?.size ?? "sm"}
|
|
70
|
-
text={customButtonProps?.text ?? ""}
|
|
71
|
-
onClick={onClick}
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
74
|
-
} else if (type === ACTION) {
|
|
75
|
-
return (
|
|
76
|
-
<Box alignItems="center" display="block" justifyContent="center" width={40}>
|
|
77
|
-
<IconButton
|
|
78
|
-
accessibilityLabel=""
|
|
79
|
-
icon="arrow-right"
|
|
80
|
-
iconColor={textColor as ButtonColor}
|
|
81
|
-
prefix="fas"
|
|
82
|
-
onClick={(): void => onClick?.()}
|
|
83
|
-
/>
|
|
84
|
-
</Box>
|
|
85
|
-
);
|
|
86
|
-
} else if (type === DISMISS) {
|
|
87
|
-
return (
|
|
88
|
-
<Box alignItems="center" display="block" justifyContent="center" width={40}>
|
|
89
|
-
<IconButton
|
|
90
|
-
accessibilityLabel=""
|
|
91
|
-
icon="times-circle"
|
|
92
|
-
iconColor={textColor as ButtonColor}
|
|
93
|
-
prefix="fas"
|
|
94
|
-
onClick={dismiss}
|
|
95
|
-
/>
|
|
96
|
-
</Box>
|
|
97
|
-
);
|
|
98
|
-
} else {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
133
|
if (!show) {
|
|
104
134
|
return null;
|
|
105
135
|
}
|
|
106
136
|
|
|
107
|
-
if ((type === ACTION && !onClick) || (type === CUSTOM_BUTTON && !onClick)) {
|
|
108
|
-
console.warn("Banners with type action require an onClick property.");
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const negativeMargin = negativeXMargin * -4;
|
|
112
|
-
|
|
113
137
|
return (
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
138
|
+
<View
|
|
139
|
+
style={{
|
|
140
|
+
alignItems: "center",
|
|
141
|
+
backgroundColor: theme.surface[bgColor],
|
|
142
|
+
height: "auto",
|
|
143
|
+
width: "100%",
|
|
144
|
+
margin: "auto",
|
|
145
|
+
flexDirection: "row",
|
|
146
|
+
borderRadius: theme.radius.default,
|
|
147
|
+
minHeight: theme.spacing.xl,
|
|
148
|
+
padding: theme.spacing.xs,
|
|
121
149
|
}}
|
|
122
|
-
direction="row"
|
|
123
|
-
justifyContent="between"
|
|
124
|
-
paddingX={3}
|
|
125
|
-
paddingY={2}
|
|
126
|
-
rounding={shape}
|
|
127
|
-
shadow
|
|
128
|
-
width={width || Unifier.utils.dimensions().width || "100%"}
|
|
129
|
-
onClick={type === DISMISS ? dismiss : undefined}
|
|
130
150
|
>
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
<Box paddingY={1}>
|
|
144
|
-
<Text align="center" color={textColor}>
|
|
145
|
-
{subtext}
|
|
146
|
-
</Text>
|
|
147
|
-
</Box>
|
|
151
|
+
<View
|
|
152
|
+
style={{
|
|
153
|
+
flexDirection: "row",
|
|
154
|
+
flex: 1,
|
|
155
|
+
alignItems: "center",
|
|
156
|
+
justifyContent: "center",
|
|
157
|
+
}}
|
|
158
|
+
>
|
|
159
|
+
{Boolean(hasIcon) && (
|
|
160
|
+
<View style={{paddingRight: 12, paddingLeft: 10}}>
|
|
161
|
+
<Icon color="inverted" iconName="triangle-exclamation" />
|
|
162
|
+
</View>
|
|
148
163
|
)}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
164
|
+
<NativeText
|
|
165
|
+
style={{
|
|
166
|
+
color: theme.text.inverted,
|
|
167
|
+
fontWeight: "bold",
|
|
168
|
+
textAlign: "center",
|
|
169
|
+
flexShrink: 1,
|
|
170
|
+
flexWrap: "wrap",
|
|
171
|
+
}}
|
|
172
|
+
>
|
|
173
|
+
{text}
|
|
174
|
+
</NativeText>
|
|
175
|
+
{Boolean(buttonText && buttonIconName && buttonOnClick) && (
|
|
176
|
+
<View style={{paddingLeft: 16, paddingRight: 10}}>
|
|
177
|
+
<BannerButton
|
|
178
|
+
buttonIconName={buttonIconName}
|
|
179
|
+
buttonOnClick={buttonOnClick ?? (() => {})}
|
|
180
|
+
buttonText={buttonText}
|
|
181
|
+
/>
|
|
182
|
+
</View>
|
|
183
|
+
)}
|
|
184
|
+
{Boolean(buttonText && !buttonIconName && buttonOnClick) && (
|
|
185
|
+
<View style={{paddingLeft: 16, paddingRight: 10}}>
|
|
186
|
+
<BannerButton buttonOnClick={buttonOnClick ?? (() => {})} buttonText={buttonText} />
|
|
187
|
+
</View>
|
|
188
|
+
)}
|
|
189
|
+
</View>
|
|
190
|
+
{Boolean(dismissible) && (
|
|
191
|
+
<DismissButton
|
|
192
|
+
accessibilityHint="Press to dismiss banner"
|
|
193
|
+
accessibilityLabel="Dismiss"
|
|
194
|
+
color="inverted"
|
|
195
|
+
onClick={dismiss}
|
|
196
|
+
/>
|
|
197
|
+
)}
|
|
198
|
+
</View>
|
|
152
199
|
);
|
|
153
200
|
};
|
package/src/Body.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
import {ActivityIndicator, KeyboardAvoidingView} from "react-native";
|
|
3
3
|
|
|
4
4
|
import {Box} from "./Box";
|
|
5
5
|
import {BodyProps} from "./Common";
|
|
6
|
-
import {
|
|
6
|
+
import {useTheme} from "./Theme";
|
|
7
7
|
|
|
8
8
|
export const Body = ({
|
|
9
9
|
scroll,
|
|
@@ -13,13 +13,13 @@ export const Body = ({
|
|
|
13
13
|
avoidKeyboard,
|
|
14
14
|
children,
|
|
15
15
|
}: BodyProps): React.ReactElement => {
|
|
16
|
-
const {theme} =
|
|
16
|
+
const {theme} = useTheme();
|
|
17
17
|
|
|
18
18
|
const renderBody = () => {
|
|
19
19
|
return (
|
|
20
20
|
<Box avoidKeyboard height="100%" scroll={scroll}>
|
|
21
21
|
<Box height={height || "100%"} padding={padding !== undefined ? padding : 5}>
|
|
22
|
-
{loading === true && <ActivityIndicator color={theme.
|
|
22
|
+
{loading === true && <ActivityIndicator color={theme.text.primary} size="large" />}
|
|
23
23
|
{children}
|
|
24
24
|
</Box>
|
|
25
25
|
</Box>
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React, {ReactElement, useRef} from "react";
|
|
2
|
+
import {Animated, TouchableWithoutFeedback, View} from "react-native";
|
|
3
|
+
|
|
4
|
+
import {BooleanFieldProps} from "./Common";
|
|
5
|
+
import {FieldHelperText, FieldTitle} from "./fieldElements";
|
|
6
|
+
import {Text} from "./Text";
|
|
7
|
+
import {useTheme} from "./Theme";
|
|
8
|
+
|
|
9
|
+
export const BooleanField = ({
|
|
10
|
+
title,
|
|
11
|
+
variant,
|
|
12
|
+
value,
|
|
13
|
+
onChange,
|
|
14
|
+
disabled,
|
|
15
|
+
disabledHelperText,
|
|
16
|
+
helperText,
|
|
17
|
+
}: BooleanFieldProps): ReactElement => {
|
|
18
|
+
const {theme} = useTheme();
|
|
19
|
+
const backgroundColor = useRef(new Animated.Value(value ? 75 : -75)).current;
|
|
20
|
+
const circleColor = useRef(new Animated.Value(value ? 75 : -75)).current;
|
|
21
|
+
const circleBorderColor = useRef(new Animated.Value(value ? 75 : -75)).current;
|
|
22
|
+
const transformSwitch = useRef(new Animated.Value(value ? 15 : -15)).current;
|
|
23
|
+
|
|
24
|
+
const animateSwitch = (newValue: boolean) => {
|
|
25
|
+
Animated.parallel([
|
|
26
|
+
Animated.spring(transformSwitch, {
|
|
27
|
+
toValue: newValue ? 15 : -15,
|
|
28
|
+
useNativeDriver: false,
|
|
29
|
+
}),
|
|
30
|
+
Animated.timing(backgroundColor, {
|
|
31
|
+
toValue: newValue ? 75 : -75,
|
|
32
|
+
duration: 200,
|
|
33
|
+
useNativeDriver: false,
|
|
34
|
+
}),
|
|
35
|
+
Animated.timing(circleColor, {
|
|
36
|
+
toValue: newValue ? 75 : -75,
|
|
37
|
+
duration: 200,
|
|
38
|
+
useNativeDriver: false,
|
|
39
|
+
}),
|
|
40
|
+
Animated.timing(circleBorderColor, {
|
|
41
|
+
toValue: value ? 75 : -75,
|
|
42
|
+
duration: 200,
|
|
43
|
+
useNativeDriver: false,
|
|
44
|
+
}),
|
|
45
|
+
]).start();
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const handleSwitch = () => {
|
|
49
|
+
if (disabled) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
animateSwitch(!value);
|
|
53
|
+
onChange(!value);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const interpolatedColorAnimation = backgroundColor.interpolate({
|
|
57
|
+
inputRange: [-75, 75],
|
|
58
|
+
outputRange: [theme.surface.base, theme.surface.secondaryDark],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<View
|
|
63
|
+
style={{
|
|
64
|
+
flexDirection: "column",
|
|
65
|
+
alignItems: "flex-start",
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
<View
|
|
69
|
+
style={{
|
|
70
|
+
flexDirection: variant === "title" ? "column" : "row",
|
|
71
|
+
alignItems: variant === "title" ? "flex-start" : "center",
|
|
72
|
+
justifyContent: variant === "title" ? "flex-start" : "center",
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
{Boolean(title) && <FieldTitle text={title!} />}
|
|
76
|
+
<TouchableWithoutFeedback accessibilityRole="button" onPress={handleSwitch}>
|
|
77
|
+
<View style={{flexDirection: "row", alignItems: "center", justifyContent: "center"}}>
|
|
78
|
+
<Animated.View
|
|
79
|
+
style={{
|
|
80
|
+
width: 60,
|
|
81
|
+
height: 30,
|
|
82
|
+
borderRadius: 30,
|
|
83
|
+
backgroundColor: disabled ? theme.surface.disabled : interpolatedColorAnimation,
|
|
84
|
+
borderColor: disabled ? theme.surface.disabled : theme.surface.secondaryDark,
|
|
85
|
+
borderWidth: 1,
|
|
86
|
+
marginHorizontal: variant === "title" ? undefined : 8,
|
|
87
|
+
marginRight: variant === "title" ? 8 : undefined,
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
<Animated.View
|
|
91
|
+
style={{
|
|
92
|
+
flex: 1,
|
|
93
|
+
width: 60,
|
|
94
|
+
flexDirection: "row",
|
|
95
|
+
justifyContent: "center",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
left: transformSwitch,
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
<Animated.View
|
|
101
|
+
style={{
|
|
102
|
+
borderWidth: 1,
|
|
103
|
+
borderColor: disabled ? theme.surface.disabled : theme.surface.secondaryDark,
|
|
104
|
+
backgroundColor: theme.surface.base,
|
|
105
|
+
width: 30,
|
|
106
|
+
height: 30,
|
|
107
|
+
borderRadius: 15,
|
|
108
|
+
alignItems: "center",
|
|
109
|
+
justifyContent: "center",
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
</Animated.View>
|
|
113
|
+
</Animated.View>
|
|
114
|
+
{variant === "title" && <Text size="md">{value ? "Yes" : "No"}</Text>}
|
|
115
|
+
</View>
|
|
116
|
+
</TouchableWithoutFeedback>
|
|
117
|
+
</View>
|
|
118
|
+
{disabled && disabledHelperText && <FieldHelperText text={disabledHelperText} />}
|
|
119
|
+
{Boolean(helperText) && <FieldHelperText text={helperText!} />}
|
|
120
|
+
</View>
|
|
121
|
+
);
|
|
122
|
+
};
|