@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/Box.tsx
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import React, {useImperativeHandle} from "react";
|
|
2
|
+
import {
|
|
3
|
+
type AccessibilityProps,
|
|
4
|
+
KeyboardAvoidingView,
|
|
5
|
+
Platform,
|
|
6
|
+
Pressable,
|
|
7
|
+
SafeAreaView,
|
|
8
|
+
ScrollView,
|
|
9
|
+
View,
|
|
10
|
+
} from "react-native";
|
|
11
|
+
|
|
12
|
+
import {getRounding, getSpacing, useTheme} from ".";
|
|
13
|
+
import type {
|
|
14
|
+
AlignContent,
|
|
15
|
+
AlignItems,
|
|
16
|
+
AlignSelf,
|
|
17
|
+
BorderTheme,
|
|
18
|
+
BoxProps,
|
|
19
|
+
JustifyContent,
|
|
20
|
+
SurfaceTheme,
|
|
21
|
+
} from "./Common";
|
|
22
|
+
import {mediaQueryLargerThan} from "./MediaQuery";
|
|
23
|
+
import {Unifier} from "./Unifier";
|
|
24
|
+
|
|
25
|
+
const ALIGN_CONTENT = {
|
|
26
|
+
around: "space-around",
|
|
27
|
+
between: "space-between",
|
|
28
|
+
center: "center",
|
|
29
|
+
end: "flex-end",
|
|
30
|
+
start: "flex-start",
|
|
31
|
+
stretch: "stretch",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const ALIGN_ITEMS = {
|
|
35
|
+
baseline: "baseline",
|
|
36
|
+
center: "center",
|
|
37
|
+
end: "flex-end",
|
|
38
|
+
start: "flex-start",
|
|
39
|
+
stretch: "stretch",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const ALIGN_SELF = {
|
|
43
|
+
around: "space-around",
|
|
44
|
+
auto: "auto",
|
|
45
|
+
baseline: "baseline",
|
|
46
|
+
between: "space-between",
|
|
47
|
+
center: "center",
|
|
48
|
+
end: "flex-end",
|
|
49
|
+
start: "flex-start",
|
|
50
|
+
stretch: "stretch",
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const BORDER_WIDTH = 1;
|
|
54
|
+
|
|
55
|
+
const isValidPercentage = (value: string): boolean => {
|
|
56
|
+
return /^\d+(\.\d+)?%$/.test(value);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const isValidWidthHeight = (value: number | string): boolean => {
|
|
60
|
+
return typeof value === "number" || !Number.isNaN(Number(value)) || isValidPercentage(value);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const Box = React.forwardRef((props: BoxProps, ref) => {
|
|
64
|
+
const {theme} = useTheme();
|
|
65
|
+
|
|
66
|
+
useImperativeHandle(ref, () => ({
|
|
67
|
+
scrollTo: (y: number) => {
|
|
68
|
+
if (scrollRef?.current) {
|
|
69
|
+
// HACK HACK HACK...but it works. Probably need to do some onContentSizeChange or onLayout
|
|
70
|
+
// to avoid this, but it works well enough.
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
scrollRef?.current?.scrollTo({y});
|
|
73
|
+
}, 50);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
scrollToEnd: () => {
|
|
77
|
+
if (scrollRef?.current) {
|
|
78
|
+
// HACK HACK HACK...but it works. Probably need to do some onContentSizeChange or onLayout
|
|
79
|
+
// to avoid this, but it works well enough.
|
|
80
|
+
setTimeout(() => {
|
|
81
|
+
scrollRef?.current?.scrollToEnd();
|
|
82
|
+
}, 50);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
}));
|
|
86
|
+
|
|
87
|
+
const BOX_STYLE_MAP: {
|
|
88
|
+
[prop: string]: (
|
|
89
|
+
value: any,
|
|
90
|
+
all: {[prop: string]: any}
|
|
91
|
+
) => {[style: string]: string | number} | {};
|
|
92
|
+
} = {
|
|
93
|
+
alignContent: (value: AlignContent) => ({alignContent: ALIGN_CONTENT[value]}),
|
|
94
|
+
alignItems: (value: AlignItems) => ({alignItems: ALIGN_ITEMS[value]}),
|
|
95
|
+
alignSelf: (value: AlignSelf) => ({alignSelf: ALIGN_SELF[value]}),
|
|
96
|
+
border: (value: keyof BorderTheme) => {
|
|
97
|
+
if (!value) {
|
|
98
|
+
return {};
|
|
99
|
+
}
|
|
100
|
+
return {borderColor: theme.border[value], borderWidth: BORDER_WIDTH};
|
|
101
|
+
},
|
|
102
|
+
borderBottom: (value: keyof BorderTheme) => {
|
|
103
|
+
if (!value) {
|
|
104
|
+
return {};
|
|
105
|
+
}
|
|
106
|
+
return {borderBottomColor: theme.border[value], borderBottomWidth: BORDER_WIDTH};
|
|
107
|
+
},
|
|
108
|
+
borderLeft: (value: keyof BorderTheme) => {
|
|
109
|
+
if (!value) {
|
|
110
|
+
return {};
|
|
111
|
+
}
|
|
112
|
+
return {borderLeftColor: theme.border[value], borderLeftWidth: BORDER_WIDTH};
|
|
113
|
+
},
|
|
114
|
+
borderRight: (value: keyof BorderTheme) => {
|
|
115
|
+
if (!value) {
|
|
116
|
+
return {};
|
|
117
|
+
}
|
|
118
|
+
return {borderRightColor: theme.border[value], borderRightWidth: BORDER_WIDTH};
|
|
119
|
+
},
|
|
120
|
+
borderTop: (value: keyof BorderTheme) => {
|
|
121
|
+
if (!value) {
|
|
122
|
+
return {};
|
|
123
|
+
}
|
|
124
|
+
return {borderTopColor: theme.border[value], borderTopWidth: BORDER_WIDTH};
|
|
125
|
+
},
|
|
126
|
+
bottom: (bottom) => ({bottom: bottom ? 0 : undefined}),
|
|
127
|
+
color: (value: keyof SurfaceTheme) => ({backgroundColor: theme.surface[value]}),
|
|
128
|
+
direction: (value: any) => ({display: "flex", flexDirection: value}),
|
|
129
|
+
display: (value: any) => {
|
|
130
|
+
if (value === "none") {
|
|
131
|
+
return {display: "none"};
|
|
132
|
+
}
|
|
133
|
+
return value === "flex" ? {flex: undefined} : {flex: 0, flexDirection: "row"};
|
|
134
|
+
},
|
|
135
|
+
flex: (value: string) => {
|
|
136
|
+
if (value === "grow") {
|
|
137
|
+
return {display: "flex", flexGrow: 1, flexShrink: 1};
|
|
138
|
+
} else if (value === "shrink") {
|
|
139
|
+
return {display: "flex", flexShrink: 1};
|
|
140
|
+
} else {
|
|
141
|
+
return {display: "flex", flex: 0};
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
gap: (value) => ({gap: getSpacing(value)}),
|
|
145
|
+
height: (value) => {
|
|
146
|
+
if (!isValidWidthHeight(value)) {
|
|
147
|
+
console.warn(
|
|
148
|
+
`Box: height prop must be a number or percentage string (e.g., "50%"), received: ${value}`
|
|
149
|
+
);
|
|
150
|
+
return {};
|
|
151
|
+
}
|
|
152
|
+
if (props.border && !Number.isNaN(Number(value))) {
|
|
153
|
+
return {height: Number(value) + 2 * 2};
|
|
154
|
+
} else {
|
|
155
|
+
return {height: value};
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
justifyContent: (value: JustifyContent) => ({justifyContent: ALIGN_CONTENT[value]}),
|
|
159
|
+
left: (left) => ({left: left ? 0 : undefined}),
|
|
160
|
+
lgDirection: (value: any) =>
|
|
161
|
+
mediaQueryLargerThan("lg") ? {display: "flex", flexDirection: value} : {},
|
|
162
|
+
margin: (value) => ({margin: getSpacing(value)}),
|
|
163
|
+
marginBottom: (value) => ({marginBottom: getSpacing(value)}),
|
|
164
|
+
marginLeft: (value) => ({marginLeft: getSpacing(value)}),
|
|
165
|
+
marginRight: (value) => ({marginRight: getSpacing(value)}),
|
|
166
|
+
marginTop: (value) => ({marginTop: getSpacing(value)}),
|
|
167
|
+
maxHeight: (value) => {
|
|
168
|
+
if (!isValidWidthHeight(value)) {
|
|
169
|
+
console.warn(
|
|
170
|
+
`Box: maxHeight prop must be a number or percentage string (e.g., "50%"), received: ${value}`
|
|
171
|
+
);
|
|
172
|
+
return {};
|
|
173
|
+
}
|
|
174
|
+
return {maxHeight: value};
|
|
175
|
+
},
|
|
176
|
+
maxWidth: (value) => {
|
|
177
|
+
if (!isValidWidthHeight(value)) {
|
|
178
|
+
console.warn(
|
|
179
|
+
`Box: maxWidth prop must be a number or percentage string (e.g., "50%"), received: ${value}`
|
|
180
|
+
);
|
|
181
|
+
return {};
|
|
182
|
+
}
|
|
183
|
+
return {maxWidth: value};
|
|
184
|
+
},
|
|
185
|
+
mdDirection: (value: any) =>
|
|
186
|
+
mediaQueryLargerThan("md") ? {display: "flex", flexDirection: value} : {},
|
|
187
|
+
minHeight: (value) => {
|
|
188
|
+
if (!isValidWidthHeight(value)) {
|
|
189
|
+
console.warn(
|
|
190
|
+
`Box: minHeight prop must be a number or percentage string (e.g., "50%"), received: ${value}`
|
|
191
|
+
);
|
|
192
|
+
return {};
|
|
193
|
+
}
|
|
194
|
+
return {minHeight: value};
|
|
195
|
+
},
|
|
196
|
+
minWidth: (value) => {
|
|
197
|
+
if (!isValidWidthHeight(value)) {
|
|
198
|
+
console.warn(
|
|
199
|
+
`Box: minWidth prop must be a number or percentage string (e.g., "50%"), received: ${value}`
|
|
200
|
+
);
|
|
201
|
+
return {};
|
|
202
|
+
}
|
|
203
|
+
return {minWidth: value};
|
|
204
|
+
},
|
|
205
|
+
overflow: (value) => {
|
|
206
|
+
if (value === "scrollY" || value === "scroll") {
|
|
207
|
+
return {overflow: "scroll"};
|
|
208
|
+
}
|
|
209
|
+
return {overflow: value};
|
|
210
|
+
},
|
|
211
|
+
padding: (value) => ({padding: getSpacing(value)}),
|
|
212
|
+
paddingX: (value) => ({paddingLeft: getSpacing(value), paddingRight: getSpacing(value)}),
|
|
213
|
+
paddingY: (value) => ({paddingBottom: getSpacing(value), paddingTop: getSpacing(value)}),
|
|
214
|
+
position: (value) => ({position: value}),
|
|
215
|
+
right: (right) => ({right: right ? 0 : undefined}),
|
|
216
|
+
rounding: (rounding, allProps) => {
|
|
217
|
+
if (rounding === "circle") {
|
|
218
|
+
if (!allProps.height && !allProps.width) {
|
|
219
|
+
console.warn("Cannot use Box rounding='circle' without height or width.");
|
|
220
|
+
return {borderRadius: undefined};
|
|
221
|
+
}
|
|
222
|
+
return {borderRadius: allProps.height || allProps.width};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (rounding) {
|
|
226
|
+
return {borderRadius: getRounding(rounding)};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return {borderRadius: undefined};
|
|
230
|
+
},
|
|
231
|
+
shadow: (value) => {
|
|
232
|
+
if (!value) {
|
|
233
|
+
return {};
|
|
234
|
+
}
|
|
235
|
+
if (Platform.OS === "ios" || Platform.OS === "web") {
|
|
236
|
+
return {
|
|
237
|
+
boxShadow: "2px 2px 2px rgba(153, 153, 153, 1.0)",
|
|
238
|
+
};
|
|
239
|
+
} else {
|
|
240
|
+
return {elevation: 4};
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
smDirection: (value: any) =>
|
|
244
|
+
mediaQueryLargerThan("sm") ? {display: "flex", flexDirection: value} : {},
|
|
245
|
+
top: (top) => ({top: top ? 0 : undefined}),
|
|
246
|
+
width: (value) => {
|
|
247
|
+
if (!isValidWidthHeight(value)) {
|
|
248
|
+
console.warn(
|
|
249
|
+
`Box: width prop must be a number or percentage string (e.g., "50%"), received: ${value}`
|
|
250
|
+
);
|
|
251
|
+
return {};
|
|
252
|
+
}
|
|
253
|
+
if (props.border && !Number.isNaN(Number(value))) {
|
|
254
|
+
return {width: Number(value) + 2 * 2};
|
|
255
|
+
} else {
|
|
256
|
+
return {width: value};
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
wrap: (value) => ({alignItems: "flex-start", flexWrap: value ? "wrap" : "nowrap"}),
|
|
260
|
+
zIndex: (value) => ({zIndex: value ? value : undefined}),
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const scrollRef = props.scrollRef ?? React.createRef();
|
|
264
|
+
|
|
265
|
+
const propsToStyle = (): any => {
|
|
266
|
+
let style: any = {};
|
|
267
|
+
for (const prop of Object.keys(props) as Array<keyof typeof props>) {
|
|
268
|
+
const value = props[prop];
|
|
269
|
+
if (BOX_STYLE_MAP[prop]) {
|
|
270
|
+
Object.assign(style, BOX_STYLE_MAP[prop](value, props));
|
|
271
|
+
} else if (prop !== "children" && prop !== "onClick") {
|
|
272
|
+
style[prop] = value;
|
|
273
|
+
// console.warn(`Box: unknown property ${prop}`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (props.wrap && props.alignItems && Platform.OS !== "web") {
|
|
278
|
+
console.warn("React Native doesn't support wrap and alignItems together.");
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Finally, dangerously set overrides.
|
|
282
|
+
if (props.dangerouslySetInlineStyle) {
|
|
283
|
+
style = {...style, ...props.dangerouslySetInlineStyle.__style};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return style;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
const onHoverIn = async () => {
|
|
290
|
+
await props.onHoverStart?.();
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
const onHoverOut = async () => {
|
|
294
|
+
await props.onHoverEnd?.();
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
let box;
|
|
298
|
+
|
|
299
|
+
// Adding the accessibilityRole of button throws a warning in React Native since we nest buttons
|
|
300
|
+
// within Box and RN does not support nested buttons
|
|
301
|
+
if (props.onClick) {
|
|
302
|
+
box = (
|
|
303
|
+
<Pressable
|
|
304
|
+
accessibilityHint={(props as AccessibilityProps).accessibilityHint}
|
|
305
|
+
aria-label={(props as AccessibilityProps).accessibilityLabel}
|
|
306
|
+
aria-role="button"
|
|
307
|
+
onLayout={props.onLayout}
|
|
308
|
+
onPointerEnter={onHoverIn}
|
|
309
|
+
onPointerLeave={onHoverOut}
|
|
310
|
+
onPress={async () => {
|
|
311
|
+
await Unifier.utils.haptic();
|
|
312
|
+
await props.onClick?.();
|
|
313
|
+
}}
|
|
314
|
+
style={propsToStyle()}
|
|
315
|
+
testID={props.testID ? `${props.testID}-clickable` : undefined}
|
|
316
|
+
>
|
|
317
|
+
{props.children}
|
|
318
|
+
</Pressable>
|
|
319
|
+
);
|
|
320
|
+
} else {
|
|
321
|
+
box = (
|
|
322
|
+
<View
|
|
323
|
+
onPointerEnter={onHoverIn}
|
|
324
|
+
onPointerLeave={onHoverOut}
|
|
325
|
+
style={propsToStyle()}
|
|
326
|
+
testID={props.testID}
|
|
327
|
+
>
|
|
328
|
+
{props.children}
|
|
329
|
+
</View>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (props.scroll) {
|
|
334
|
+
const {justifyContent, alignContent, alignItems, ...scrollStyle} = propsToStyle();
|
|
335
|
+
|
|
336
|
+
box = (
|
|
337
|
+
<ScrollView
|
|
338
|
+
contentContainerStyle={{alignContent, alignItems, justifyContent}}
|
|
339
|
+
horizontal={props.overflow === "scrollX"}
|
|
340
|
+
keyboardShouldPersistTaps="handled"
|
|
341
|
+
nestedScrollEnabled
|
|
342
|
+
onScroll={(event) => {
|
|
343
|
+
if (props.onScroll && event) {
|
|
344
|
+
props.onScroll(event.nativeEvent.contentOffset.y);
|
|
345
|
+
}
|
|
346
|
+
}}
|
|
347
|
+
ref={props.scrollRef || scrollRef}
|
|
348
|
+
scrollEventThrottle={50}
|
|
349
|
+
style={scrollStyle}
|
|
350
|
+
>
|
|
351
|
+
{box}
|
|
352
|
+
</ScrollView>
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (props.avoidKeyboard) {
|
|
357
|
+
box = (
|
|
358
|
+
<KeyboardAvoidingView
|
|
359
|
+
behavior={Platform.OS === "ios" ? "padding" : "height"}
|
|
360
|
+
keyboardVerticalOffset={props.keyboardOffset}
|
|
361
|
+
style={{display: "flex", flex: 1}}
|
|
362
|
+
>
|
|
363
|
+
<SafeAreaView style={{display: "flex", flex: 1}}>{box}</SafeAreaView>
|
|
364
|
+
</KeyboardAvoidingView>
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
return box;
|
|
368
|
+
});
|
package/src/Button.tsx
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import FontAwesome6 from "@expo/vector-icons/FontAwesome6";
|
|
2
|
+
import debounce from "lodash/debounce";
|
|
3
|
+
import {type FC, useMemo, useState} from "react";
|
|
4
|
+
import {ActivityIndicator, Pressable, Text, View} from "react-native";
|
|
5
|
+
|
|
6
|
+
import {Box} from "./Box";
|
|
7
|
+
import type {ButtonProps} from "./Common";
|
|
8
|
+
import {isMobileDevice} from "./MediaQuery";
|
|
9
|
+
import {Modal} from "./Modal";
|
|
10
|
+
import {useTheme} from "./Theme";
|
|
11
|
+
import {Tooltip} from "./Tooltip";
|
|
12
|
+
import {Unifier} from "./Unifier";
|
|
13
|
+
import {isNative} from "./Utilities";
|
|
14
|
+
|
|
15
|
+
const ConfirmationModal: FC<{
|
|
16
|
+
visible: boolean;
|
|
17
|
+
title: string;
|
|
18
|
+
subtitle?: string;
|
|
19
|
+
text: string;
|
|
20
|
+
onConfirm: () => void;
|
|
21
|
+
onCancel: () => void;
|
|
22
|
+
}> = ({visible, title, subtitle, text, onConfirm, onCancel}) => {
|
|
23
|
+
return (
|
|
24
|
+
<Modal
|
|
25
|
+
onDismiss={onCancel}
|
|
26
|
+
primaryButtonOnClick={onConfirm}
|
|
27
|
+
primaryButtonText="Confirm"
|
|
28
|
+
secondaryButtonOnClick={onCancel}
|
|
29
|
+
secondaryButtonText="Cancel"
|
|
30
|
+
subtitle={subtitle}
|
|
31
|
+
title={title}
|
|
32
|
+
visible={visible}
|
|
33
|
+
>
|
|
34
|
+
<Text>{text}</Text>
|
|
35
|
+
</Modal>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const ButtonComponent: FC<ButtonProps> = ({
|
|
40
|
+
confirmationText = "Are you sure you want to continue?",
|
|
41
|
+
disabled = false,
|
|
42
|
+
fullWidth = false,
|
|
43
|
+
iconName,
|
|
44
|
+
iconPosition = "left",
|
|
45
|
+
loading: propsLoading,
|
|
46
|
+
modalTitle = "Confirm",
|
|
47
|
+
modalSubTitle,
|
|
48
|
+
testID,
|
|
49
|
+
text,
|
|
50
|
+
variant = "primary",
|
|
51
|
+
withConfirmation = false,
|
|
52
|
+
onClick,
|
|
53
|
+
}) => {
|
|
54
|
+
const [loading, setLoading] = useState(propsLoading);
|
|
55
|
+
const [showConfirmation, setShowConfirmation] = useState(false);
|
|
56
|
+
const {theme} = useTheme();
|
|
57
|
+
|
|
58
|
+
const {backgroundColor, borderColor, borderWidth, color} = useMemo(() => {
|
|
59
|
+
if (!theme) {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
let bgColor = theme.surface.primary;
|
|
63
|
+
let bColor: string | undefined;
|
|
64
|
+
let bWidth: number | undefined;
|
|
65
|
+
let textColor = theme.text.inverted;
|
|
66
|
+
|
|
67
|
+
if (disabled) {
|
|
68
|
+
bgColor = theme.surface.disabled;
|
|
69
|
+
} else if (variant === "secondary") {
|
|
70
|
+
bgColor = theme.surface.secondaryDark;
|
|
71
|
+
} else if (variant === "muted") {
|
|
72
|
+
bgColor = theme.surface.secondaryLight;
|
|
73
|
+
textColor = theme.surface.neutralDark;
|
|
74
|
+
} else if (variant === "outline") {
|
|
75
|
+
bgColor = theme.surface.base;
|
|
76
|
+
bColor = theme.text.secondaryDark;
|
|
77
|
+
bWidth = 2;
|
|
78
|
+
textColor = theme.text.secondaryDark;
|
|
79
|
+
} else if (variant === "destructive") {
|
|
80
|
+
bgColor = theme.surface.error;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
backgroundColor: bgColor,
|
|
85
|
+
borderColor: bColor,
|
|
86
|
+
borderWidth: bWidth,
|
|
87
|
+
color: textColor,
|
|
88
|
+
};
|
|
89
|
+
}, [disabled, variant, theme]);
|
|
90
|
+
|
|
91
|
+
if (!theme) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<Pressable
|
|
97
|
+
accessibilityHint={
|
|
98
|
+
withConfirmation ? "Opens a confirmation dialog" : "Press to perform action"
|
|
99
|
+
}
|
|
100
|
+
aria-label={text}
|
|
101
|
+
aria-role="button"
|
|
102
|
+
disabled={disabled || loading}
|
|
103
|
+
onPress={debounce(
|
|
104
|
+
async () => {
|
|
105
|
+
await Unifier.utils.haptic();
|
|
106
|
+
setLoading(true);
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
// If a confirmation is required, and the confirmation modal is not currently open,
|
|
110
|
+
// open it
|
|
111
|
+
if (withConfirmation && !showConfirmation) {
|
|
112
|
+
setShowConfirmation(true);
|
|
113
|
+
} else if (!withConfirmation && onClick) {
|
|
114
|
+
// If a confirmation is not required, perform the action.
|
|
115
|
+
await onClick();
|
|
116
|
+
}
|
|
117
|
+
} catch (error) {
|
|
118
|
+
setLoading(false);
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
setLoading(false);
|
|
122
|
+
},
|
|
123
|
+
500,
|
|
124
|
+
{leading: true}
|
|
125
|
+
)}
|
|
126
|
+
style={{
|
|
127
|
+
alignItems: "center",
|
|
128
|
+
alignSelf: fullWidth ? "stretch" : undefined,
|
|
129
|
+
backgroundColor,
|
|
130
|
+
borderColor,
|
|
131
|
+
borderRadius: theme.radius.rounded,
|
|
132
|
+
borderWidth,
|
|
133
|
+
flexDirection: "column",
|
|
134
|
+
justifyContent: "center",
|
|
135
|
+
paddingHorizontal: 20,
|
|
136
|
+
paddingVertical: 8,
|
|
137
|
+
width: fullWidth ? "100%" : "auto",
|
|
138
|
+
}}
|
|
139
|
+
testID={testID}
|
|
140
|
+
>
|
|
141
|
+
<View style={{flexDirection: "row"}}>
|
|
142
|
+
<View style={{flexDirection: iconPosition === "left" ? "row" : "row-reverse"}}>
|
|
143
|
+
{Boolean(iconName) && (
|
|
144
|
+
<View
|
|
145
|
+
style={{
|
|
146
|
+
alignSelf: "center",
|
|
147
|
+
marginLeft: iconPosition === "right" ? 8 : 0,
|
|
148
|
+
marginRight: iconPosition === "left" ? 8 : 0,
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
<FontAwesome6 color={color} name={iconName} size={16} solid />
|
|
152
|
+
</View>
|
|
153
|
+
)}
|
|
154
|
+
<Text style={{color, fontSize: 16, fontWeight: "700"}}>{text}</Text>
|
|
155
|
+
</View>
|
|
156
|
+
{Boolean(loading) && (
|
|
157
|
+
<Box marginLeft={2}>
|
|
158
|
+
<ActivityIndicator color={color} size="small" />
|
|
159
|
+
</Box>
|
|
160
|
+
)}
|
|
161
|
+
</View>
|
|
162
|
+
{withConfirmation && (
|
|
163
|
+
<ConfirmationModal
|
|
164
|
+
onCancel={() => setShowConfirmation(false)}
|
|
165
|
+
onConfirm={async () => {
|
|
166
|
+
await onClick();
|
|
167
|
+
setShowConfirmation(false);
|
|
168
|
+
}}
|
|
169
|
+
subtitle={modalSubTitle}
|
|
170
|
+
text={confirmationText}
|
|
171
|
+
title={modalTitle}
|
|
172
|
+
visible={showConfirmation}
|
|
173
|
+
/>
|
|
174
|
+
)}
|
|
175
|
+
</Pressable>
|
|
176
|
+
);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export const Button: FC<ButtonProps> = (props) => {
|
|
180
|
+
const {tooltipText, tooltipIdealPosition, tooltipIncludeArrow = false} = props;
|
|
181
|
+
const isMobileOrNative = isMobileDevice() || isNative();
|
|
182
|
+
|
|
183
|
+
if (tooltipText && !isMobileOrNative) {
|
|
184
|
+
return (
|
|
185
|
+
<Tooltip
|
|
186
|
+
idealPosition={tooltipIdealPosition}
|
|
187
|
+
includeArrow={tooltipIncludeArrow}
|
|
188
|
+
text={tooltipText}
|
|
189
|
+
>
|
|
190
|
+
<ButtonComponent {...props} />
|
|
191
|
+
</Tooltip>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return <ButtonComponent {...props} />;
|
|
196
|
+
};
|
package/src/Card.tsx
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {Box} from "./Box";
|
|
2
|
+
import type {BoxProps} from "./Common";
|
|
3
|
+
|
|
4
|
+
export const Card = ({children, color = "base", padding = 4, width, ...rest}: BoxProps) => {
|
|
5
|
+
return (
|
|
6
|
+
<Box
|
|
7
|
+
color={color}
|
|
8
|
+
direction="column"
|
|
9
|
+
display="flex"
|
|
10
|
+
padding={padding}
|
|
11
|
+
rounding="md"
|
|
12
|
+
shadow
|
|
13
|
+
width={width}
|
|
14
|
+
{...rest}
|
|
15
|
+
>
|
|
16
|
+
{children}
|
|
17
|
+
</Box>
|
|
18
|
+
);
|
|
19
|
+
};
|
package/src/CheckBox.tsx
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import FontAwesome6 from "@expo/vector-icons/FontAwesome6";
|
|
2
|
+
import type {FC} from "react";
|
|
3
|
+
import {View} from "react-native";
|
|
4
|
+
|
|
5
|
+
import type {CheckBoxProps} from "./Common";
|
|
6
|
+
import {useTheme} from "./Theme";
|
|
7
|
+
|
|
8
|
+
export const CheckBox: FC<CheckBoxProps> = ({selected, size = "md", bgColor = "default"}) => {
|
|
9
|
+
const {theme} = useTheme();
|
|
10
|
+
const px = {
|
|
11
|
+
lg: {container: 24, icon: 16},
|
|
12
|
+
md: {container: 16, icon: 13},
|
|
13
|
+
sm: {container: 10, icon: 8},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const backgroundColor = {
|
|
17
|
+
accent: theme.text.accent,
|
|
18
|
+
black: theme.text.primary,
|
|
19
|
+
default: theme.text.link,
|
|
20
|
+
};
|
|
21
|
+
return (
|
|
22
|
+
<View
|
|
23
|
+
style={{
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
backgroundColor: selected ? backgroundColor[bgColor] : "transparent",
|
|
26
|
+
borderColor: backgroundColor[bgColor],
|
|
27
|
+
borderRadius: 3,
|
|
28
|
+
borderWidth: 1,
|
|
29
|
+
height: px[size].container,
|
|
30
|
+
justifyContent: "center",
|
|
31
|
+
width: px[size].container,
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
{selected ? (
|
|
35
|
+
<FontAwesome6
|
|
36
|
+
color={theme.surface.base}
|
|
37
|
+
name="check"
|
|
38
|
+
selectable={undefined}
|
|
39
|
+
size={px[size].icon}
|
|
40
|
+
solid
|
|
41
|
+
/>
|
|
42
|
+
) : null}
|
|
43
|
+
</View>
|
|
44
|
+
);
|
|
45
|
+
};
|