@terreno/ui 0.0.1
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/LICENSE +203 -0
- package/README.md +160 -0
- package/dist/Accordion.d.ts +3 -0
- package/dist/Accordion.js +30 -0
- package/dist/Accordion.js.map +1 -0
- package/dist/ActionSheet.d.ts +169 -0
- package/dist/ActionSheet.js +637 -0
- package/dist/ActionSheet.js.map +1 -0
- package/dist/AddressField.d.ts +3 -0
- package/dist/AddressField.js +18 -0
- package/dist/AddressField.js.map +1 -0
- package/dist/Avatar.d.ts +3 -0
- package/dist/Avatar.js +189 -0
- package/dist/Avatar.js.map +1 -0
- package/dist/Badge.d.ts +3 -0
- package/dist/Badge.js +100 -0
- package/dist/Badge.js.map +1 -0
- package/dist/Banner.d.ts +4 -0
- package/dist/Banner.js +103 -0
- package/dist/Banner.js.map +1 -0
- package/dist/Body.d.ts +3 -0
- package/dist/Body.js +17 -0
- package/dist/Body.js.map +1 -0
- package/dist/BooleanField.d.ts +3 -0
- package/dist/BooleanField.js +89 -0
- package/dist/BooleanField.js.map +1 -0
- package/dist/Box.d.ts +3 -0
- package/dist/Box.js +289 -0
- package/dist/Box.js.map +1 -0
- package/dist/Button.d.ts +3 -0
- package/dist/Button.js +105 -0
- package/dist/Button.js.map +1 -0
- package/dist/Card.d.ts +2 -0
- package/dist/Card.js +18 -0
- package/dist/Card.js.map +1 -0
- package/dist/CheckBox.d.ts +3 -0
- package/dist/CheckBox.js +28 -0
- package/dist/CheckBox.js.map +1 -0
- package/dist/Common.d.ts +2325 -0
- package/dist/Common.js +47 -0
- package/dist/Common.js.map +1 -0
- package/dist/CommonIconTypes.d.ts +3 -0
- package/dist/CommonIconTypes.js +2 -0
- package/dist/CommonIconTypes.js.map +1 -0
- package/dist/Constants.d.ts +12685 -0
- package/dist/Constants.js +3310 -0
- package/dist/Constants.js.map +1 -0
- package/dist/CustomSelectField.d.ts +3 -0
- package/dist/CustomSelectField.js +59 -0
- package/dist/CustomSelectField.js.map +1 -0
- package/dist/DataTable.d.ts +3 -0
- package/dist/DataTable.js +190 -0
- package/dist/DataTable.js.map +1 -0
- package/dist/DateTimeActionSheet.d.ts +2 -0
- package/dist/DateTimeActionSheet.js +270 -0
- package/dist/DateTimeActionSheet.js.map +1 -0
- package/dist/DateTimeField.d.ts +3 -0
- package/dist/DateTimeField.js +514 -0
- package/dist/DateTimeField.js.map +1 -0
- package/dist/DateUtilities.d.ts +57 -0
- package/dist/DateUtilities.js +308 -0
- package/dist/DateUtilities.js.map +1 -0
- package/dist/DecimalRangeActionSheet.d.ts +6 -0
- package/dist/DecimalRangeActionSheet.js +45 -0
- package/dist/DecimalRangeActionSheet.js.map +1 -0
- package/dist/DismissButton.d.ts +3 -0
- package/dist/DismissButton.js +12 -0
- package/dist/DismissButton.js.map +1 -0
- package/dist/EmailField.d.ts +3 -0
- package/dist/EmailField.js +48 -0
- package/dist/EmailField.js.map +1 -0
- package/dist/EmojiSelector.d.ts +113 -0
- package/dist/EmojiSelector.js +322 -0
- package/dist/EmojiSelector.js.map +1 -0
- package/dist/ErrorBoundary.d.ts +19 -0
- package/dist/ErrorBoundary.js +30 -0
- package/dist/ErrorBoundary.js.map +1 -0
- package/dist/ErrorPage.d.ts +6 -0
- package/dist/ErrorPage.js +15 -0
- package/dist/ErrorPage.js.map +1 -0
- package/dist/Field.d.ts +3 -0
- package/dist/Field.js +80 -0
- package/dist/Field.js.map +1 -0
- package/dist/FlatList.d.ts +2 -0
- package/dist/FlatList.js +3 -0
- package/dist/FlatList.js.map +1 -0
- package/dist/Heading.d.ts +3 -0
- package/dist/Heading.js +43 -0
- package/dist/Heading.js.map +1 -0
- package/dist/HeightActionSheet.d.ts +11 -0
- package/dist/HeightActionSheet.js +46 -0
- package/dist/HeightActionSheet.js.map +1 -0
- package/dist/Hyperlink.d.ts +30 -0
- package/dist/Hyperlink.js +144 -0
- package/dist/Hyperlink.js.map +1 -0
- package/dist/Icon.d.ts +3 -0
- package/dist/Icon.js +15 -0
- package/dist/Icon.js.map +1 -0
- package/dist/IconButton.d.ts +3 -0
- package/dist/IconButton.js +111 -0
- package/dist/IconButton.js.map +1 -0
- package/dist/Image.d.ts +8 -0
- package/dist/Image.js +37 -0
- package/dist/Image.js.map +1 -0
- package/dist/ImageBackground.d.ts +10 -0
- package/dist/ImageBackground.js +9 -0
- package/dist/ImageBackground.js.map +1 -0
- package/dist/InfoModalIcon.d.ts +3 -0
- package/dist/InfoModalIcon.js +10 -0
- package/dist/InfoModalIcon.js.map +1 -0
- package/dist/InfoTooltipButton.d.ts +3 -0
- package/dist/InfoTooltipButton.js +6 -0
- package/dist/InfoTooltipButton.js.map +1 -0
- package/dist/Link.d.ts +3 -0
- package/dist/Link.js +10 -0
- package/dist/Link.js.map +1 -0
- package/dist/MarkdownView.d.ts +5 -0
- package/dist/MarkdownView.js +44 -0
- package/dist/MarkdownView.js.map +1 -0
- package/dist/MediaQuery.d.ts +4 -0
- package/dist/MediaQuery.js +52 -0
- package/dist/MediaQuery.js.map +1 -0
- package/dist/MobileAddressAutoComplete.d.ts +2 -0
- package/dist/MobileAddressAutoComplete.js +54 -0
- package/dist/MobileAddressAutoComplete.js.map +1 -0
- package/dist/Modal.d.ts +3 -0
- package/dist/Modal.js +127 -0
- package/dist/Modal.js.map +1 -0
- package/dist/ModalSheet.d.ts +6 -0
- package/dist/ModalSheet.js +42 -0
- package/dist/ModalSheet.js.map +1 -0
- package/dist/MultiselectField.d.ts +3 -0
- package/dist/MultiselectField.js +45 -0
- package/dist/MultiselectField.js.map +1 -0
- package/dist/NumberField.d.ts +3 -0
- package/dist/NumberField.js +60 -0
- package/dist/NumberField.js.map +1 -0
- package/dist/NumberPickerActionSheet.d.ts +7 -0
- package/dist/NumberPickerActionSheet.js +22 -0
- package/dist/NumberPickerActionSheet.js.map +1 -0
- package/dist/OpenAPIContext.d.ts +4 -0
- package/dist/OpenAPIContext.js +53 -0
- package/dist/OpenAPIContext.js.map +1 -0
- package/dist/Page.d.ts +7 -0
- package/dist/Page.js +24 -0
- package/dist/Page.js.map +1 -0
- package/dist/Pagination.d.ts +3 -0
- package/dist/Pagination.js +106 -0
- package/dist/Pagination.js.map +1 -0
- package/dist/PasswordField.d.ts +2 -0
- package/dist/PasswordField.js +6 -0
- package/dist/PasswordField.js.map +1 -0
- package/dist/Permissions.d.ts +2 -0
- package/dist/Permissions.js +35 -0
- package/dist/Permissions.js.map +1 -0
- package/dist/PhoneNumberField.d.ts +3 -0
- package/dist/PhoneNumberField.js +83 -0
- package/dist/PhoneNumberField.js.map +1 -0
- package/dist/PickerSelect.d.ts +46 -0
- package/dist/PickerSelect.js +306 -0
- package/dist/PickerSelect.js.map +1 -0
- 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 +16 -0
- package/dist/RadioField.js.map +1 -0
- package/dist/ScrollView.d.ts +2 -0
- package/dist/ScrollView.js +3 -0
- package/dist/ScrollView.js.map +1 -0
- package/dist/SectionDivider.d.ts +2 -0
- package/dist/SectionDivider.js +12 -0
- package/dist/SectionDivider.js.map +1 -0
- package/dist/SegmentedControl.d.ts +3 -0
- package/dist/SegmentedControl.js +65 -0
- package/dist/SegmentedControl.js.map +1 -0
- package/dist/SelectBadge.d.ts +3 -0
- package/dist/SelectBadge.js +166 -0
- package/dist/SelectBadge.js.map +1 -0
- package/dist/SelectField.d.ts +3 -0
- package/dist/SelectField.js +16 -0
- package/dist/SelectField.js.map +1 -0
- package/dist/SideDrawer.d.ts +3 -0
- package/dist/SideDrawer.js +32 -0
- package/dist/SideDrawer.js.map +1 -0
- package/dist/Signature.d.ts +8 -0
- package/dist/Signature.js +21 -0
- package/dist/Signature.js.map +1 -0
- package/dist/Signature.native.d.ts +8 -0
- package/dist/Signature.native.js +26 -0
- package/dist/Signature.native.js.map +1 -0
- package/dist/SignatureField.d.ts +3 -0
- package/dist/SignatureField.js +42 -0
- package/dist/SignatureField.js.map +1 -0
- package/dist/Slider.d.ts +3 -0
- package/dist/Slider.js +78 -0
- package/dist/Slider.js.map +1 -0
- package/dist/Spinner.d.ts +3 -0
- package/dist/Spinner.js +33 -0
- package/dist/Spinner.js.map +1 -0
- package/dist/SplitPage.d.ts +2 -0
- package/dist/SplitPage.js +139 -0
- package/dist/SplitPage.js.map +1 -0
- package/dist/SplitPage.native.d.ts +2 -0
- package/dist/SplitPage.native.js +75 -0
- package/dist/SplitPage.native.js.map +1 -0
- package/dist/TapToEdit.d.ts +4 -0
- package/dist/TapToEdit.js +170 -0
- package/dist/TapToEdit.js.map +1 -0
- package/dist/TerrenoProvider.d.ts +6 -0
- package/dist/TerrenoProvider.js +10 -0
- package/dist/TerrenoProvider.js.map +1 -0
- package/dist/Text.d.ts +3 -0
- package/dist/Text.js +95 -0
- package/dist/Text.js.map +1 -0
- package/dist/TextArea.d.ts +3 -0
- package/dist/TextArea.js +6 -0
- package/dist/TextArea.js.map +1 -0
- package/dist/TextField.d.ts +3 -0
- package/dist/TextField.js +144 -0
- package/dist/TextField.js.map +1 -0
- package/dist/TextFieldNumberActionSheet.d.ts +7 -0
- package/dist/TextFieldNumberActionSheet.js +20 -0
- package/dist/TextFieldNumberActionSheet.js.map +1 -0
- package/dist/Theme.d.ts +96 -0
- package/dist/Theme.js +213 -0
- package/dist/Theme.js.map +1 -0
- package/dist/TimezonePicker.d.ts +11 -0
- package/dist/TimezonePicker.js +27 -0
- package/dist/TimezonePicker.js.map +1 -0
- package/dist/Toast.d.ts +23 -0
- package/dist/Toast.js +157 -0
- package/dist/Toast.js.map +1 -0
- package/dist/Tooltip.d.ts +3 -0
- package/dist/Tooltip.js +289 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/UnifiedAddressAutoComplete.d.ts +2 -0
- package/dist/UnifiedAddressAutoComplete.js +23 -0
- package/dist/UnifiedAddressAutoComplete.js.map +1 -0
- package/dist/Unifier.d.ts +43 -0
- package/dist/Unifier.js +154 -0
- package/dist/Unifier.js.map +1 -0
- package/dist/Utilities.d.ts +56 -0
- package/dist/Utilities.js +193 -0
- package/dist/Utilities.js.map +1 -0
- package/dist/WebAddressAutocomplete.d.ts +3 -0
- package/dist/WebAddressAutocomplete.js +61 -0
- package/dist/WebAddressAutocomplete.js.map +1 -0
- package/dist/fieldElements/FieldError.d.ts +6 -0
- package/dist/fieldElements/FieldError.js +9 -0
- package/dist/fieldElements/FieldError.js.map +1 -0
- package/dist/fieldElements/FieldHelperText.d.ts +6 -0
- package/dist/fieldElements/FieldHelperText.js +8 -0
- package/dist/fieldElements/FieldHelperText.js.map +1 -0
- package/dist/fieldElements/FieldTitle.d.ts +6 -0
- package/dist/fieldElements/FieldTitle.js +16 -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 +2 -0
- package/dist/icons/MobileIcon.js +18 -0
- package/dist/icons/MobileIcon.js.map +1 -0
- package/dist/icons/OfflineIcon.d.ts +2 -0
- package/dist/icons/OfflineIcon.js +18 -0
- package/dist/icons/OfflineIcon.js.map +1 -0
- package/dist/icons/OnlineIcon.d.ts +2 -0
- package/dist/icons/OnlineIcon.js +19 -0
- package/dist/icons/OnlineIcon.js.map +1 -0
- package/dist/icons/OutOfficeIcon.d.ts +2 -0
- package/dist/icons/OutOfficeIcon.js +18 -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 +1328 -0
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -0
- package/dist/table/Table.d.ts +3 -0
- package/dist/table/Table.js +53 -0
- package/dist/table/Table.js.map +1 -0
- package/dist/table/TableBadge.d.ts +6 -0
- package/dist/table/TableBadge.js +23 -0
- package/dist/table/TableBadge.js.map +1 -0
- package/dist/table/TableBoolean.d.ts +6 -0
- package/dist/table/TableBoolean.js +37 -0
- package/dist/table/TableBoolean.js.map +1 -0
- package/dist/table/TableDate.d.ts +3 -0
- package/dist/table/TableDate.js +27 -0
- package/dist/table/TableDate.js.map +1 -0
- package/dist/table/TableHeader.d.ts +6 -0
- package/dist/table/TableHeader.js +10 -0
- package/dist/table/TableHeader.js.map +1 -0
- package/dist/table/TableHeaderCell.d.ts +6 -0
- package/dist/table/TableHeaderCell.js +54 -0
- package/dist/table/TableHeaderCell.js.map +1 -0
- package/dist/table/TableIconButton.d.ts +3 -0
- package/dist/table/TableIconButton.js +39 -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/table/TableRow.d.ts +6 -0
- package/dist/table/TableRow.js +22 -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 +21 -0
- package/dist/table/TableTitle.js.map +1 -0
- package/dist/table/tableContext.d.ts +5 -0
- package/dist/table/tableContext.js +38 -0
- package/dist/table/tableContext.js.map +1 -0
- package/dist/useStoredState.d.ts +1 -0
- package/dist/useStoredState.js +49 -0
- package/dist/useStoredState.js.map +1 -0
- package/package.json +123 -0
- package/src/Accordion.test.tsx +104 -0
- package/src/Accordion.tsx +81 -0
- package/src/ActionSheet.tsx +881 -0
- package/src/AddressField.test.tsx +120 -0
- package/src/AddressField.tsx +122 -0
- package/src/Avatar.test.tsx +163 -0
- package/src/Avatar.tsx +298 -0
- package/src/Badge.test.tsx +116 -0
- package/src/Badge.tsx +136 -0
- package/src/Banner.tsx +200 -0
- package/src/Body.tsx +34 -0
- package/src/BooleanField.tsx +141 -0
- package/src/Box.test.tsx +662 -0
- package/src/Box.tsx +368 -0
- package/src/Button.tsx +196 -0
- package/src/Card.tsx +19 -0
- package/src/CheckBox.tsx +45 -0
- package/src/Common.ts +2787 -0
- package/src/CommonIconTypes.ts +2030 -0
- package/src/Constants.ts +3311 -0
- package/src/CustomSelectField.tsx +115 -0
- package/src/DataTable.tsx +674 -0
- package/src/DateTimeActionSheet.tsx +559 -0
- package/src/DateTimeField.test.tsx +393 -0
- package/src/DateTimeField.tsx +777 -0
- package/src/DateUtilities.test.ts +440 -0
- package/src/DateUtilities.tsx +370 -0
- package/src/DecimalRangeActionSheet.tsx +85 -0
- package/src/DismissButton.tsx +31 -0
- package/src/EmailField.tsx +66 -0
- package/src/EmojiSelector.test.tsx +61 -0
- package/src/EmojiSelector.tsx +510 -0
- package/src/ErrorBoundary.tsx +37 -0
- package/src/ErrorPage.tsx +41 -0
- package/src/Field.tsx +101 -0
- package/src/FlatList.tsx +2 -0
- package/src/Heading.tsx +66 -0
- package/src/HeightActionSheet.tsx +91 -0
- package/src/Hyperlink.tsx +179 -0
- package/src/Icon.tsx +36 -0
- package/src/IconButton.tsx +217 -0
- package/src/Image.tsx +51 -0
- package/src/ImageBackground.tsx +14 -0
- package/src/InfoModalIcon.tsx +42 -0
- package/src/InfoTooltipButton.tsx +16 -0
- package/src/Link.tsx +22 -0
- package/src/MarkdownView.tsx +67 -0
- package/src/MediaQuery.ts +46 -0
- package/src/MobileAddressAutoComplete.tsx +126 -0
- package/src/Modal.tsx +300 -0
- package/src/ModalSheet.tsx +58 -0
- package/src/MultiselectField.tsx +112 -0
- package/src/NumberField.tsx +67 -0
- package/src/NumberPickerActionSheet.tsx +51 -0
- package/src/OpenAPIContext.tsx +74 -0
- package/src/Page.tsx +105 -0
- package/src/Pagination.tsx +169 -0
- package/src/PasswordField.tsx +7 -0
- package/src/Permissions.ts +43 -0
- package/src/PhoneNumberField.tsx +109 -0
- package/src/PickerSelect.tsx +571 -0
- package/src/Radio.tsx +33 -0
- package/src/RadioField.tsx +43 -0
- package/src/ScrollView.tsx +2 -0
- package/src/SectionDivider.tsx +18 -0
- package/src/SegmentedControl.tsx +126 -0
- package/src/SelectBadge.tsx +280 -0
- package/src/SelectField.tsx +41 -0
- package/src/SideDrawer.tsx +56 -0
- package/src/Signature.native.tsx +57 -0
- package/src/Signature.tsx +44 -0
- package/src/SignatureField.tsx +92 -0
- package/src/Slider.tsx +199 -0
- package/src/Spinner.tsx +35 -0
- package/src/SplitPage.native.tsx +163 -0
- package/src/SplitPage.tsx +304 -0
- package/src/TapToEdit.tsx +292 -0
- package/src/TerrenoProvider.tsx +31 -0
- package/src/Text.tsx +123 -0
- package/src/TextArea.test.tsx +255 -0
- package/src/TextArea.tsx +8 -0
- package/src/TextField.test.tsx +487 -0
- package/src/TextField.tsx +260 -0
- package/src/TextFieldNumberActionSheet.tsx +46 -0
- package/src/Theme.tsx +248 -0
- package/src/TimezonePicker.tsx +45 -0
- package/src/Toast.tsx +234 -0
- package/src/Tooltip.tsx +407 -0
- package/src/UnifiedAddressAutoComplete.tsx +66 -0
- package/src/Unifier.ts +172 -0
- package/src/Utilities.tsx +329 -0
- package/src/WebAddressAutocomplete.tsx +84 -0
- package/src/__snapshots__/Accordion.test.tsx.snap +126 -0
- package/src/__snapshots__/AddressField.test.tsx.snap +1197 -0
- package/src/__snapshots__/Avatar.test.tsx.snap +57 -0
- package/src/__snapshots__/Badge.test.tsx.snap +55 -0
- package/src/__snapshots__/Box.test.tsx.snap +162 -0
- package/src/__snapshots__/EmojiSelector.test.tsx.snap +422 -0
- package/src/__snapshots__/TextArea.test.tsx.snap +521 -0
- package/src/__snapshots__/TextField.test.tsx.snap +569 -0
- package/src/bunSetup.ts +1235 -0
- 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 +40 -0
- package/src/icons/OfflineIcon.tsx +37 -0
- package/src/icons/OnlineIcon.tsx +39 -0
- package/src/icons/OutOfficeIcon.tsx +36 -0
- package/src/icons/index.ts +4 -0
- package/src/index.tsx +1375 -0
- package/src/polyfill.d.ts +11 -0
- package/src/table/Table.tsx +109 -0
- package/src/table/TableBadge.tsx +46 -0
- package/src/table/TableBoolean.tsx +70 -0
- package/src/table/TableDate.tsx +38 -0
- package/src/table/TableHeader.tsx +20 -0
- package/src/table/TableHeaderCell.tsx +94 -0
- package/src/table/TableIconButton.tsx +61 -0
- package/src/table/TableNumber.tsx +29 -0
- package/src/table/TableRow.tsx +67 -0
- package/src/table/TableText.tsx +29 -0
- package/src/table/TableTitle.tsx +31 -0
- package/src/table/tableContext.tsx +67 -0
- package/src/test-utils.tsx +27 -0
- package/src/types/react-native-swiper-flatlist.d.ts +56 -0
- package/src/useStoredState.test.tsx +143 -0
- package/src/useStoredState.ts +56 -0
package/src/Heading.tsx
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TitilliumWeb_600SemiBold,
|
|
3
|
+
TitilliumWeb_700Bold,
|
|
4
|
+
useFonts,
|
|
5
|
+
} from "@expo-google-fonts/titillium-web";
|
|
6
|
+
import type React from "react";
|
|
7
|
+
import {Text as NativeText, Platform, type StyleProp, type TextStyle} from "react-native";
|
|
8
|
+
|
|
9
|
+
import type {HeadingProps} from "./Common";
|
|
10
|
+
import {useTheme} from "./Theme";
|
|
11
|
+
|
|
12
|
+
const fontSizeAndWeightWeb = {
|
|
13
|
+
"2xl": {size: 48, weight: "bold"},
|
|
14
|
+
lg: {size: 24, weight: "bold"},
|
|
15
|
+
md: {size: 18, weight: "bold"},
|
|
16
|
+
sm: {size: 16, weight: "semibold"},
|
|
17
|
+
xl: {size: 32, weight: "bold"},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const fontSizeAndWeighMobile = {
|
|
21
|
+
"2xl": {size: 32, weight: "bold"},
|
|
22
|
+
lg: {size: 20, weight: "bold"},
|
|
23
|
+
md: {size: 16, weight: "bold"},
|
|
24
|
+
sm: {size: 14, weight: "semibold"},
|
|
25
|
+
xl: {size: 28, weight: "bold"},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const fontSizes = Platform.OS === "web" ? fontSizeAndWeightWeb : fontSizeAndWeighMobile;
|
|
29
|
+
|
|
30
|
+
export const Heading = ({
|
|
31
|
+
align,
|
|
32
|
+
children,
|
|
33
|
+
color = "primary",
|
|
34
|
+
size,
|
|
35
|
+
testID,
|
|
36
|
+
}: HeadingProps): React.ReactElement => {
|
|
37
|
+
const {theme} = useTheme();
|
|
38
|
+
|
|
39
|
+
// TODO: make fonts part of theme.
|
|
40
|
+
useFonts({
|
|
41
|
+
heading: TitilliumWeb_600SemiBold,
|
|
42
|
+
"heading-bold": TitilliumWeb_700Bold,
|
|
43
|
+
"heading-semibold": TitilliumWeb_600SemiBold,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const style: StyleProp<TextStyle> = {};
|
|
47
|
+
|
|
48
|
+
if (size === "sm") {
|
|
49
|
+
style.fontFamily = "heading-semibold";
|
|
50
|
+
} else {
|
|
51
|
+
style.fontFamily = "heading-bold";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
style.fontSize = fontSizes[size || "md"].size;
|
|
55
|
+
if (align) {
|
|
56
|
+
style.textAlign = align;
|
|
57
|
+
}
|
|
58
|
+
style.color = theme.text[color];
|
|
59
|
+
|
|
60
|
+
const lines = 0;
|
|
61
|
+
return (
|
|
62
|
+
<NativeText numberOfLines={lines} style={style} testID={testID}>
|
|
63
|
+
{children}
|
|
64
|
+
</NativeText>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {Picker} from "@react-native-picker/picker";
|
|
2
|
+
import range from "lodash/range";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
import {ActionSheet} from "./ActionSheet";
|
|
6
|
+
import {Box} from "./Box";
|
|
7
|
+
import {Button} from "./Button";
|
|
8
|
+
import type {HeightActionSheetProps} from "./Common";
|
|
9
|
+
|
|
10
|
+
const PICKER_HEIGHT = 104;
|
|
11
|
+
|
|
12
|
+
interface HeightActionSheetState {
|
|
13
|
+
feet: string;
|
|
14
|
+
inches: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class HeightActionSheet extends React.Component<
|
|
18
|
+
HeightActionSheetProps,
|
|
19
|
+
HeightActionSheetState
|
|
20
|
+
> {
|
|
21
|
+
constructor(props: HeightActionSheetProps) {
|
|
22
|
+
super(props);
|
|
23
|
+
this.state = {
|
|
24
|
+
feet: String(Math.floor(Number(props.value) / 12)),
|
|
25
|
+
inches: String(Number(props.value) % 12),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
render() {
|
|
30
|
+
return (
|
|
31
|
+
<ActionSheet bounceOnOpen gestureEnabled ref={this.props.actionSheetRef}>
|
|
32
|
+
<Box marginBottom={8} paddingX={4} width="100%">
|
|
33
|
+
<Box alignItems="end" display="flex" width="100%">
|
|
34
|
+
<Box width="33%">
|
|
35
|
+
<Button
|
|
36
|
+
onClick={() => {
|
|
37
|
+
this.props.actionSheetRef?.current?.setModalVisible(false);
|
|
38
|
+
}}
|
|
39
|
+
text="Close"
|
|
40
|
+
/>
|
|
41
|
+
</Box>
|
|
42
|
+
</Box>
|
|
43
|
+
<Box direction="row" width="100%">
|
|
44
|
+
<Box width="50%">
|
|
45
|
+
<Picker
|
|
46
|
+
itemStyle={{
|
|
47
|
+
height: PICKER_HEIGHT,
|
|
48
|
+
}}
|
|
49
|
+
onValueChange={(feet) => {
|
|
50
|
+
this.setState({feet: String(feet)});
|
|
51
|
+
this.props.onChange(String(Number(feet) * 12 + Number(this.state.inches)));
|
|
52
|
+
}}
|
|
53
|
+
selectedValue={this.state.feet}
|
|
54
|
+
style={{
|
|
55
|
+
backgroundColor: "#FFFFFF",
|
|
56
|
+
height: PICKER_HEIGHT,
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
{range(4, 8).map((n) => {
|
|
60
|
+
// console.log("FIRST", String(n));
|
|
61
|
+
return <Picker.Item key={String(n)} label={`${String(n)}ft`} value={String(n)} />;
|
|
62
|
+
})}
|
|
63
|
+
</Picker>
|
|
64
|
+
</Box>
|
|
65
|
+
<Box width="50%">
|
|
66
|
+
<Picker
|
|
67
|
+
itemStyle={{
|
|
68
|
+
height: PICKER_HEIGHT,
|
|
69
|
+
}}
|
|
70
|
+
onValueChange={(inches) => {
|
|
71
|
+
this.setState({inches: String(inches)});
|
|
72
|
+
this.props.onChange(String(Number(this.state.feet) * 12 + Number(inches)));
|
|
73
|
+
}}
|
|
74
|
+
selectedValue={this.state.inches}
|
|
75
|
+
style={{
|
|
76
|
+
backgroundColor: "#FFFFFF",
|
|
77
|
+
height: PICKER_HEIGHT,
|
|
78
|
+
}}
|
|
79
|
+
>
|
|
80
|
+
{range(0, 12).map((n) => {
|
|
81
|
+
// console.log("N", n);
|
|
82
|
+
return <Picker.Item key={String(n)} label={`${String(n)}in`} value={String(n)} />;
|
|
83
|
+
})}
|
|
84
|
+
</Picker>
|
|
85
|
+
</Box>
|
|
86
|
+
</Box>
|
|
87
|
+
</Box>
|
|
88
|
+
</ActionSheet>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @providesModule Hyperlink
|
|
3
|
+
*
|
|
4
|
+
* Forked from https://github.com/obipawan/react-native-hyperlink
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* MIT License
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2019 Pawan
|
|
10
|
+
*
|
|
11
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
* in the Software without restriction, including without limitation the rights
|
|
14
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
* furnished to do so, subject to the following conditions:
|
|
17
|
+
*
|
|
18
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
* copies or substantial portions of the Software.
|
|
20
|
+
*
|
|
21
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
* SOFTWARE.
|
|
28
|
+
* */
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Hyperlink is used to wrap text that should be clickable.
|
|
32
|
+
* It will automatically detect URLs and open them in the browser. For example,
|
|
33
|
+
* this is great for wrapping text in a chat app so any link in a chat message is clickable.
|
|
34
|
+
* This is different than <Link> which is meant for specifically linking to a URL.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
import * as mdurl from "mdurl";
|
|
38
|
+
import React from "react";
|
|
39
|
+
import {Linking, Platform, Text, View} from "react-native";
|
|
40
|
+
|
|
41
|
+
import type {HyperlinkProps} from "./Common";
|
|
42
|
+
|
|
43
|
+
const linkifyLib = require("linkify-it")();
|
|
44
|
+
|
|
45
|
+
const {OS} = Platform;
|
|
46
|
+
|
|
47
|
+
// Leaving this as a class component because it was easier to handle the `parse(this)` in
|
|
48
|
+
// `render()`
|
|
49
|
+
class HyperlinkComponent extends React.Component<HyperlinkProps> {
|
|
50
|
+
isTextNested = (component: any) => {
|
|
51
|
+
if (!React.isValidElement(component)) throw new Error("Invalid component");
|
|
52
|
+
const {type: {displayName} = {} as any} = component;
|
|
53
|
+
if (displayName !== "Text") throw new Error("Not a Text component");
|
|
54
|
+
return typeof (component.props as any).children !== "string";
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
linkify = (component: any) => {
|
|
58
|
+
const linkifyIt = this.props.linkify || linkifyLib;
|
|
59
|
+
|
|
60
|
+
if (!linkifyIt.pretest(component.props.children) || !linkifyIt.test(component.props.children))
|
|
61
|
+
return component;
|
|
62
|
+
|
|
63
|
+
const elements = [];
|
|
64
|
+
let _lastIndex = 0;
|
|
65
|
+
|
|
66
|
+
const componentProps = {
|
|
67
|
+
...component.props,
|
|
68
|
+
key: undefined,
|
|
69
|
+
ref: undefined,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
linkifyIt.match(component.props.children).forEach(({index, lastIndex, text, url}: any) => {
|
|
74
|
+
const nonLinkedText = component.props.children.substring(_lastIndex, index);
|
|
75
|
+
nonLinkedText && elements.push(nonLinkedText);
|
|
76
|
+
_lastIndex = lastIndex;
|
|
77
|
+
if (this.props.linkText)
|
|
78
|
+
text =
|
|
79
|
+
typeof this.props.linkText === "function"
|
|
80
|
+
? this.props.linkText(url)
|
|
81
|
+
: this.props.linkText;
|
|
82
|
+
|
|
83
|
+
const clickHandlerProps: any = {};
|
|
84
|
+
if (OS !== "web") {
|
|
85
|
+
if (this.props.onLongPress) {
|
|
86
|
+
clickHandlerProps.onLongPress = () => (this.props as any).onLongPress(url, text);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (this.props.onPress) {
|
|
90
|
+
clickHandlerProps.onPress = () => (this.props as any).onPress(url, text);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let injected: any = {};
|
|
94
|
+
if (this.props.injectViewProps) {
|
|
95
|
+
injected = this.props.injectViewProps(url);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
elements.push(
|
|
99
|
+
<Text
|
|
100
|
+
{...componentProps}
|
|
101
|
+
{...clickHandlerProps}
|
|
102
|
+
key={url + index}
|
|
103
|
+
style={[component.props.style, this.props.linkStyle]}
|
|
104
|
+
{...injected}
|
|
105
|
+
>
|
|
106
|
+
{text}
|
|
107
|
+
</Text>
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
elements.push(
|
|
111
|
+
component.props.children.substring(_lastIndex, component.props.children.length)
|
|
112
|
+
);
|
|
113
|
+
return React.cloneElement(component, componentProps, elements);
|
|
114
|
+
} catch (_error) {
|
|
115
|
+
return component;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
parse = (component: any): React.ReactElement => {
|
|
120
|
+
const {props: {children} = {} as any} = component || {};
|
|
121
|
+
if (!children) return component;
|
|
122
|
+
|
|
123
|
+
const componentProps = {
|
|
124
|
+
...component.props,
|
|
125
|
+
key: undefined,
|
|
126
|
+
ref: undefined,
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const linkifyIt = this.props.linkify || linkifyLib;
|
|
130
|
+
|
|
131
|
+
return React.cloneElement(
|
|
132
|
+
component,
|
|
133
|
+
componentProps,
|
|
134
|
+
React.Children.map(children, (child) => {
|
|
135
|
+
const {type: {displayName} = {} as any} = child || {};
|
|
136
|
+
if (typeof child === "string" && linkifyIt.pretest(child))
|
|
137
|
+
return this.linkify(
|
|
138
|
+
<Text {...componentProps} style={component.props.style}>
|
|
139
|
+
{child}
|
|
140
|
+
</Text>
|
|
141
|
+
);
|
|
142
|
+
if (displayName === "Text" && !this.isTextNested(child)) return this.linkify(child);
|
|
143
|
+
return this.parse(child);
|
|
144
|
+
})
|
|
145
|
+
);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
render() {
|
|
149
|
+
const {...viewProps} = this.props;
|
|
150
|
+
delete viewProps.onPress;
|
|
151
|
+
delete viewProps.linkDefault;
|
|
152
|
+
delete viewProps.onLongPress;
|
|
153
|
+
delete viewProps.linkStyle;
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<View {...viewProps} style={this.props.style}>
|
|
157
|
+
{!this.props.onPress && !this.props.onLongPress && !this.props.linkStyle
|
|
158
|
+
? this.props.children
|
|
159
|
+
: (this.parse(this).props as {children?: React.ReactNode}).children}
|
|
160
|
+
</View>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export const Hyperlink = (props: HyperlinkProps) => {
|
|
166
|
+
const handleLink = (url: string) => {
|
|
167
|
+
const urlObject = mdurl.parse(url);
|
|
168
|
+
urlObject.protocol = urlObject.protocol.toLowerCase();
|
|
169
|
+
const normalizedURL = mdurl.format(urlObject);
|
|
170
|
+
|
|
171
|
+
void Linking.canOpenURL(normalizedURL).then(
|
|
172
|
+
(supported) => supported && Linking.openURL(normalizedURL)
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const onPress = handleLink || props.onPress;
|
|
177
|
+
if (props.linkDefault) return <HyperlinkComponent {...props} onPress={onPress} />;
|
|
178
|
+
return <HyperlinkComponent {...props} />;
|
|
179
|
+
};
|
package/src/Icon.tsx
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import FontAwesome6 from "@expo/vector-icons/FontAwesome6";
|
|
2
|
+
import type {FC} from "react";
|
|
3
|
+
|
|
4
|
+
import {type IconProps, iconSizeToNumber} from "./Common";
|
|
5
|
+
import {useTheme} from "./Theme";
|
|
6
|
+
|
|
7
|
+
// TODO: Update <Icon /> to be closer to Expo's Vector Icon, letting multiple icon packs be used,
|
|
8
|
+
// etc.
|
|
9
|
+
// TODO: Add documentation for adding FA6-Pro icons.
|
|
10
|
+
export const Icon: FC<IconProps> = ({
|
|
11
|
+
color = "primary",
|
|
12
|
+
size = "md",
|
|
13
|
+
iconName,
|
|
14
|
+
type = "solid",
|
|
15
|
+
testID,
|
|
16
|
+
}) => {
|
|
17
|
+
const {theme} = useTheme();
|
|
18
|
+
const iconColor = theme.text[color] ?? color;
|
|
19
|
+
const iconSize = iconSizeToNumber(size);
|
|
20
|
+
return (
|
|
21
|
+
<FontAwesome6
|
|
22
|
+
brand={type === "brand"}
|
|
23
|
+
color={iconColor}
|
|
24
|
+
duotone={type === "duotone"}
|
|
25
|
+
light={type === "light" || type === "sharpLight"}
|
|
26
|
+
name={iconName}
|
|
27
|
+
regular={type === "regular"}
|
|
28
|
+
selectable={undefined}
|
|
29
|
+
sharp={type === "sharp"}
|
|
30
|
+
size={iconSize}
|
|
31
|
+
solid={type === "solid" || type === "sharpSolid"}
|
|
32
|
+
testID={testID}
|
|
33
|
+
thin={type === "thin"}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import FontAwesome6 from "@expo/vector-icons/FontAwesome6";
|
|
2
|
+
import debounce from "lodash/debounce";
|
|
3
|
+
import {type FC, useState} from "react";
|
|
4
|
+
import {ActivityIndicator, Text as NativeText, Pressable, View} from "react-native";
|
|
5
|
+
|
|
6
|
+
import type {IconButtonProps} from "./Common";
|
|
7
|
+
import {isMobileDevice} from "./MediaQuery";
|
|
8
|
+
import {Modal} from "./Modal";
|
|
9
|
+
import {Text} from "./Text";
|
|
10
|
+
import {useTheme} from "./Theme";
|
|
11
|
+
import {Tooltip} from "./Tooltip";
|
|
12
|
+
import {Unifier} from "./Unifier";
|
|
13
|
+
import {isNative} from "./Utilities";
|
|
14
|
+
|
|
15
|
+
type ConfirmationModalProps = {
|
|
16
|
+
visible: boolean;
|
|
17
|
+
title: string;
|
|
18
|
+
subtitle?: string;
|
|
19
|
+
text: string;
|
|
20
|
+
onConfirm: () => void;
|
|
21
|
+
onCancel: () => void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const ConfirmationModal: FC<ConfirmationModalProps> = ({
|
|
25
|
+
visible,
|
|
26
|
+
title,
|
|
27
|
+
subtitle,
|
|
28
|
+
text,
|
|
29
|
+
onConfirm,
|
|
30
|
+
onCancel,
|
|
31
|
+
}) => {
|
|
32
|
+
return (
|
|
33
|
+
<Modal
|
|
34
|
+
onDismiss={onCancel}
|
|
35
|
+
primaryButtonOnClick={onConfirm}
|
|
36
|
+
primaryButtonText="Confirm"
|
|
37
|
+
secondaryButtonOnClick={onCancel}
|
|
38
|
+
secondaryButtonText="Cancel"
|
|
39
|
+
subtitle={subtitle}
|
|
40
|
+
title={title}
|
|
41
|
+
visible={visible}
|
|
42
|
+
>
|
|
43
|
+
<Text>{text}</Text>
|
|
44
|
+
</Modal>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const IconButtonComponent: FC<IconButtonProps> = ({
|
|
49
|
+
accessibilityHint,
|
|
50
|
+
accessibilityLabel,
|
|
51
|
+
confirmationHeading = "Confirm",
|
|
52
|
+
confirmationText = "Are you sure you want to continue?",
|
|
53
|
+
disabled = false,
|
|
54
|
+
iconName,
|
|
55
|
+
indicator,
|
|
56
|
+
indicatorText,
|
|
57
|
+
loading: propsLoading = false,
|
|
58
|
+
testID,
|
|
59
|
+
variant = "primary",
|
|
60
|
+
withConfirmation = false,
|
|
61
|
+
tooltipText,
|
|
62
|
+
onClick,
|
|
63
|
+
}) => {
|
|
64
|
+
const [loading, setLoading] = useState(propsLoading);
|
|
65
|
+
const [showConfirmation, setShowConfirmation] = useState(false);
|
|
66
|
+
const {theme} = useTheme();
|
|
67
|
+
let accessLabel = accessibilityLabel;
|
|
68
|
+
if (tooltipText && accessibilityLabel === "") {
|
|
69
|
+
accessLabel = tooltipText;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!theme) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let backgroundColor = theme.surface.primary;
|
|
77
|
+
let color = theme.text.inverted;
|
|
78
|
+
|
|
79
|
+
if (disabled) {
|
|
80
|
+
backgroundColor = theme.surface.disabled;
|
|
81
|
+
color = theme.text.secondaryLight;
|
|
82
|
+
} else if (variant === "secondary") {
|
|
83
|
+
backgroundColor = theme.surface.neutralLight;
|
|
84
|
+
color = theme.surface.secondaryDark;
|
|
85
|
+
} else if (variant === "muted") {
|
|
86
|
+
backgroundColor = theme.text.inverted;
|
|
87
|
+
color = theme.surface.primary;
|
|
88
|
+
} else if (variant === "navigation") {
|
|
89
|
+
backgroundColor = theme.text.inverted;
|
|
90
|
+
color = theme.text.primary;
|
|
91
|
+
} else if (variant === "destructive") {
|
|
92
|
+
backgroundColor = theme.text.inverted;
|
|
93
|
+
color = theme.text.error;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const indicatorColor = indicator ? theme.surface[indicator] : undefined;
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<Pressable
|
|
100
|
+
accessibilityHint={
|
|
101
|
+
(accessibilityHint ?? withConfirmation)
|
|
102
|
+
? `Opens a confirmation dialog to confirm ${accessLabel}`
|
|
103
|
+
: `Press to perform ${accessLabel} action`
|
|
104
|
+
}
|
|
105
|
+
aria-label={accessLabel}
|
|
106
|
+
aria-role="button"
|
|
107
|
+
disabled={loading || disabled}
|
|
108
|
+
onPress={debounce(
|
|
109
|
+
// TODO: Allow for a click outside of the confirmation modal to close it.
|
|
110
|
+
async () => {
|
|
111
|
+
await Unifier.utils.haptic();
|
|
112
|
+
setLoading(true);
|
|
113
|
+
try {
|
|
114
|
+
// If a confirmation is required, and the confirmation modal is not currently open,
|
|
115
|
+
// open it
|
|
116
|
+
if (withConfirmation && !showConfirmation) {
|
|
117
|
+
setShowConfirmation(true);
|
|
118
|
+
} else if (!withConfirmation && onClick) {
|
|
119
|
+
// If a confirmation is not required, perform the action.
|
|
120
|
+
await onClick();
|
|
121
|
+
}
|
|
122
|
+
} catch (error) {
|
|
123
|
+
setLoading(false);
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
setLoading(false);
|
|
127
|
+
},
|
|
128
|
+
500,
|
|
129
|
+
{leading: true}
|
|
130
|
+
)}
|
|
131
|
+
style={{
|
|
132
|
+
alignItems: "center",
|
|
133
|
+
backgroundColor,
|
|
134
|
+
borderRadius: theme.radius.rounded,
|
|
135
|
+
height: 32,
|
|
136
|
+
justifyContent: "center",
|
|
137
|
+
width: 32,
|
|
138
|
+
}}
|
|
139
|
+
testID={testID}
|
|
140
|
+
>
|
|
141
|
+
{loading ? (
|
|
142
|
+
<ActivityIndicator color={color} size="small" />
|
|
143
|
+
) : (
|
|
144
|
+
<FontAwesome6
|
|
145
|
+
color={color}
|
|
146
|
+
name={iconName}
|
|
147
|
+
selectable={undefined}
|
|
148
|
+
size={variant === "navigation" ? 20 : 16}
|
|
149
|
+
solid
|
|
150
|
+
/>
|
|
151
|
+
)}
|
|
152
|
+
{Boolean(indicator) && (
|
|
153
|
+
<View
|
|
154
|
+
style={{
|
|
155
|
+
alignItems: "center",
|
|
156
|
+
backgroundColor: indicatorColor,
|
|
157
|
+
borderRadius: 10,
|
|
158
|
+
bottom: 0,
|
|
159
|
+
display: "flex",
|
|
160
|
+
height: 12,
|
|
161
|
+
justifyContent: "center",
|
|
162
|
+
padding: theme.spacing.xs as any,
|
|
163
|
+
position: "absolute",
|
|
164
|
+
right: 0,
|
|
165
|
+
width: 12,
|
|
166
|
+
}}
|
|
167
|
+
>
|
|
168
|
+
{Boolean(indicatorText) && (
|
|
169
|
+
<NativeText
|
|
170
|
+
style={{
|
|
171
|
+
color: theme.text.inverted,
|
|
172
|
+
fontFamily: "text",
|
|
173
|
+
fontSize: 10,
|
|
174
|
+
fontWeight: 700,
|
|
175
|
+
textAlign: "center",
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
{indicatorText}
|
|
179
|
+
</NativeText>
|
|
180
|
+
)}
|
|
181
|
+
</View>
|
|
182
|
+
)}
|
|
183
|
+
{withConfirmation && (
|
|
184
|
+
<ConfirmationModal
|
|
185
|
+
onCancel={() => setShowConfirmation(false)}
|
|
186
|
+
onConfirm={async () => {
|
|
187
|
+
await onClick();
|
|
188
|
+
setShowConfirmation(false);
|
|
189
|
+
}}
|
|
190
|
+
subtitle={undefined}
|
|
191
|
+
text={confirmationText}
|
|
192
|
+
title={confirmationHeading}
|
|
193
|
+
visible={showConfirmation}
|
|
194
|
+
/>
|
|
195
|
+
)}
|
|
196
|
+
</Pressable>
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export const IconButton: FC<IconButtonProps> = (props) => {
|
|
201
|
+
const {tooltipText, tooltipIdealPosition, tooltipIncludeArrow = false} = props;
|
|
202
|
+
const isMobileOrNative = isMobileDevice() || isNative();
|
|
203
|
+
|
|
204
|
+
if (tooltipText && !isMobileOrNative) {
|
|
205
|
+
return (
|
|
206
|
+
<Tooltip
|
|
207
|
+
idealPosition={tooltipIdealPosition}
|
|
208
|
+
includeArrow={tooltipIncludeArrow}
|
|
209
|
+
text={tooltipText}
|
|
210
|
+
>
|
|
211
|
+
<IconButtonComponent {...props} />
|
|
212
|
+
</Tooltip>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return <IconButtonComponent {...props} />;
|
|
217
|
+
};
|
package/src/Image.tsx
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {Dimensions, Image as NativeImage} from "react-native";
|
|
3
|
+
|
|
4
|
+
import {Box} from "./Box";
|
|
5
|
+
import type {ImageProps} from "./Common";
|
|
6
|
+
|
|
7
|
+
const {width: DEVICE_WIDTH} = Dimensions.get("window");
|
|
8
|
+
|
|
9
|
+
export class Image extends React.Component<ImageProps, {}> {
|
|
10
|
+
resizeMode = (fit?: "cover" | "contain" | "none") => {
|
|
11
|
+
if (!fit || fit === "none") {
|
|
12
|
+
return undefined;
|
|
13
|
+
} else {
|
|
14
|
+
return fit;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
width = () => {
|
|
19
|
+
if (this.props.naturalWidth) {
|
|
20
|
+
return this.props.naturalWidth;
|
|
21
|
+
} else if (this.props.fullWidth) {
|
|
22
|
+
return DEVICE_WIDTH;
|
|
23
|
+
}
|
|
24
|
+
throw new Error("Width required for Image");
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
height = () => {
|
|
28
|
+
if (this.props.naturalWidth) {
|
|
29
|
+
return this.props.naturalWidth;
|
|
30
|
+
}
|
|
31
|
+
return this.width() * (9 / 16);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
render() {
|
|
35
|
+
return (
|
|
36
|
+
<Box color={this.props.color}>
|
|
37
|
+
<NativeImage
|
|
38
|
+
resizeMode={this.resizeMode(this.props.fit)}
|
|
39
|
+
source={{cache: "force-cache", uri: this.props.src}}
|
|
40
|
+
style={{
|
|
41
|
+
height: this.height(),
|
|
42
|
+
maxHeight: this.props.maxHeight,
|
|
43
|
+
maxWidth: this.props.maxWidth,
|
|
44
|
+
width: this.width(),
|
|
45
|
+
...this.props.style,
|
|
46
|
+
}}
|
|
47
|
+
/>
|
|
48
|
+
</Box>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {ImageBackground as ImageBackgroundNative} from "react-native";
|
|
3
|
+
|
|
4
|
+
interface ImageBackgroundProps {
|
|
5
|
+
children?: any;
|
|
6
|
+
style?: any;
|
|
7
|
+
source: any;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class ImageBackground extends React.Component<ImageBackgroundProps, {}> {
|
|
11
|
+
render() {
|
|
12
|
+
return <ImageBackgroundNative {...this.props} />;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {type FC, useState} from "react";
|
|
2
|
+
import {Pressable} from "react-native";
|
|
3
|
+
|
|
4
|
+
import type {InfoModalIconProps} from "./Common";
|
|
5
|
+
import {Heading} from "./Heading";
|
|
6
|
+
import {Modal} from "./Modal";
|
|
7
|
+
|
|
8
|
+
export const InfoModalIcon: FC<InfoModalIconProps> = ({
|
|
9
|
+
infoModalChildren,
|
|
10
|
+
infoModalSubtitle,
|
|
11
|
+
infoModalText,
|
|
12
|
+
infoModalTitle,
|
|
13
|
+
}) => {
|
|
14
|
+
const [infoModalVisibleState, setInfoModalVisibleState] = useState(false);
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<Modal
|
|
18
|
+
onDismiss={() => setInfoModalVisibleState(false)}
|
|
19
|
+
primaryButtonOnClick={() => setInfoModalVisibleState(false)}
|
|
20
|
+
primaryButtonText="Close"
|
|
21
|
+
size="md"
|
|
22
|
+
subtitle={infoModalSubtitle}
|
|
23
|
+
text={infoModalText}
|
|
24
|
+
title={infoModalTitle}
|
|
25
|
+
visible={infoModalVisibleState}
|
|
26
|
+
>
|
|
27
|
+
{infoModalChildren}
|
|
28
|
+
</Modal>
|
|
29
|
+
<Pressable
|
|
30
|
+
aria-role="button"
|
|
31
|
+
hitSlop={{bottom: 10, left: 10, right: 10, top: 10}}
|
|
32
|
+
onPress={() => setInfoModalVisibleState(true)}
|
|
33
|
+
style={{marginLeft: 8}}
|
|
34
|
+
testID="info-icon"
|
|
35
|
+
>
|
|
36
|
+
<Heading color="secondaryLight" size="sm">
|
|
37
|
+
ⓘ
|
|
38
|
+
</Heading>
|
|
39
|
+
</Pressable>
|
|
40
|
+
</>
|
|
41
|
+
);
|
|
42
|
+
};
|