@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
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Component, createRef } from "react";
|
|
3
|
+
import { Animated, Dimensions, FlatList, findNodeHandle, Keyboard, Modal, Platform, Pressable, SafeAreaView, StatusBar, StyleSheet, TextInput, UIManager, View, } from "react-native";
|
|
4
|
+
export const styles = StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
alignSelf: "center",
|
|
7
|
+
backgroundColor: "white",
|
|
8
|
+
width: "100%",
|
|
9
|
+
},
|
|
10
|
+
indicator: {
|
|
11
|
+
alignSelf: "center",
|
|
12
|
+
backgroundColor: "#f0f0f0",
|
|
13
|
+
borderRadius: 100,
|
|
14
|
+
height: 6,
|
|
15
|
+
marginVertical: 5,
|
|
16
|
+
width: 45,
|
|
17
|
+
},
|
|
18
|
+
parentContainer: {
|
|
19
|
+
alignItems: "center",
|
|
20
|
+
height: "100%",
|
|
21
|
+
justifyContent: "center",
|
|
22
|
+
width: "100%",
|
|
23
|
+
},
|
|
24
|
+
safearea: {
|
|
25
|
+
left: 999999,
|
|
26
|
+
position: "absolute",
|
|
27
|
+
top: 999999,
|
|
28
|
+
},
|
|
29
|
+
scrollView: {
|
|
30
|
+
backgroundColor: "transparent",
|
|
31
|
+
height: "100%",
|
|
32
|
+
width: "100%",
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
export function getDeviceHeight(statusBarTranslucent) {
|
|
36
|
+
const height = Dimensions.get("window").height;
|
|
37
|
+
if (Platform.OS === "android" && !statusBarTranslucent) {
|
|
38
|
+
return StatusBar.currentHeight ? height - StatusBar.currentHeight : height;
|
|
39
|
+
}
|
|
40
|
+
return height;
|
|
41
|
+
}
|
|
42
|
+
export const getElevation = (elevation) => {
|
|
43
|
+
if (!elevation) {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
boxShadow: `${0.3 * elevation}px ${0.5 * elevation}px ${0.7 * elevation}px rgba(0, 0, 0, 0.2)`,
|
|
48
|
+
elevation,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export const SUPPORTED_ORIENTATIONS = ["portrait", "portrait-upside-down", "landscape", "landscape-left", "landscape-right"];
|
|
52
|
+
export const waitAsync = (ms) => new Promise((resolve) => {
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
resolve(null);
|
|
55
|
+
}, ms);
|
|
56
|
+
});
|
|
57
|
+
const safeAreaInnerHeight = 0;
|
|
58
|
+
const dummyData = ["dummy"];
|
|
59
|
+
let safeAreaPaddingTop = Platform.OS === "android" ? StatusBar.currentHeight || 0 : 0;
|
|
60
|
+
let calculatedDeviceHeight = Dimensions.get("window").height;
|
|
61
|
+
const defaultProps = {
|
|
62
|
+
animated: true,
|
|
63
|
+
bottomOffset: 0,
|
|
64
|
+
bounciness: 8,
|
|
65
|
+
closable: true,
|
|
66
|
+
closeAnimationDuration: 300,
|
|
67
|
+
closeOnPressBack: true,
|
|
68
|
+
closeOnTouchBackdrop: true,
|
|
69
|
+
defaultOverlayOpacity: 0.3,
|
|
70
|
+
delayActionSheetDrawTime: 0,
|
|
71
|
+
drawUnderStatusBar: true,
|
|
72
|
+
elevation: 5,
|
|
73
|
+
extraScroll: 0,
|
|
74
|
+
gestureEnabled: false,
|
|
75
|
+
indicatorColor: "#f0f0f0",
|
|
76
|
+
initialOffsetFromBottom: 1,
|
|
77
|
+
keyboardMode: "padding",
|
|
78
|
+
openAnimationSpeed: 12,
|
|
79
|
+
overlayColor: "black",
|
|
80
|
+
springOffset: 100,
|
|
81
|
+
statusBarTranslucent: true,
|
|
82
|
+
};
|
|
83
|
+
export class ActionSheet extends Component {
|
|
84
|
+
constructor(props) {
|
|
85
|
+
super(props);
|
|
86
|
+
this.actionSheetHeight = 0;
|
|
87
|
+
this.keyboardDidShowListener = null;
|
|
88
|
+
this.keyboardDidHideListener = null;
|
|
89
|
+
this.prevScroll = 0;
|
|
90
|
+
this.timeout = null;
|
|
91
|
+
this.offsetY = 0;
|
|
92
|
+
this.currentOffsetFromBottom = 0;
|
|
93
|
+
this.scrollAnimationEndValue = 0;
|
|
94
|
+
this.hasBounced = false;
|
|
95
|
+
this.layoutHasCalled = false;
|
|
96
|
+
this.isClosing = false;
|
|
97
|
+
this.isRecoiling = false;
|
|
98
|
+
this.isReachedTop = false;
|
|
99
|
+
this.deviceLayoutCalled = false;
|
|
100
|
+
/**
|
|
101
|
+
* Snap ActionSheet to Offset
|
|
102
|
+
*/
|
|
103
|
+
this.snapToOffset = (offset) => {
|
|
104
|
+
const correction = this.state.deviceHeight * 0.15;
|
|
105
|
+
const extraScroll = this.props.extraScroll || 0;
|
|
106
|
+
const scrollOffset = this.props.gestureEnabled
|
|
107
|
+
? offset + correction + extraScroll
|
|
108
|
+
: offset + correction + extraScroll;
|
|
109
|
+
this.currentOffsetFromBottom = offset / this.actionSheetHeight;
|
|
110
|
+
this._scrollTo(scrollOffset);
|
|
111
|
+
this.updateActionSheetPosition(scrollOffset);
|
|
112
|
+
};
|
|
113
|
+
// Open the ActionSheet
|
|
114
|
+
this.show = () => {
|
|
115
|
+
this.setModalVisible(true);
|
|
116
|
+
};
|
|
117
|
+
// Close the ActionSheet
|
|
118
|
+
this.hide = () => {
|
|
119
|
+
this.setModalVisible(false);
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Open/Close the ActionSheet
|
|
123
|
+
*/
|
|
124
|
+
this.setModalVisible = (visible) => {
|
|
125
|
+
let modalVisible = this.state.modalVisible;
|
|
126
|
+
if (visible !== undefined) {
|
|
127
|
+
if (modalVisible === visible) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
modalVisible = !visible;
|
|
131
|
+
}
|
|
132
|
+
if (!modalVisible) {
|
|
133
|
+
this.setState({
|
|
134
|
+
modalVisible: true,
|
|
135
|
+
scrollable: this.props.gestureEnabled || false,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
this._hideModal();
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
this._hideModal = () => {
|
|
143
|
+
if (this.isClosing)
|
|
144
|
+
return;
|
|
145
|
+
this.isClosing = true;
|
|
146
|
+
this._hideAnimation();
|
|
147
|
+
};
|
|
148
|
+
this.measure = async () => {
|
|
149
|
+
return new Promise((resolve) => {
|
|
150
|
+
setTimeout(() => {
|
|
151
|
+
UIManager.measureInWindow(this.safeAreaViewRef.current._nativeTag, (_x, _y, _width, height) => {
|
|
152
|
+
safeAreaPaddingTop = height;
|
|
153
|
+
resolve(height === 0 ? 20 : height);
|
|
154
|
+
});
|
|
155
|
+
}, 100);
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
this._showModal = async (event) => {
|
|
159
|
+
var _a, _b;
|
|
160
|
+
const { gestureEnabled, delayActionSheetDraw, delayActionSheetDrawTime } = this.props;
|
|
161
|
+
if (!(event === null || event === void 0 ? void 0 : event.nativeEvent))
|
|
162
|
+
return;
|
|
163
|
+
const height = event.nativeEvent.layout.height;
|
|
164
|
+
if (this.layoutHasCalled) {
|
|
165
|
+
this.actionSheetHeight = height;
|
|
166
|
+
this._returnToPrevScrollPosition(height);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
this.layoutHasCalled = true;
|
|
171
|
+
this.actionSheetHeight = height;
|
|
172
|
+
const scrollOffset = this.getInitialScrollPosition();
|
|
173
|
+
this.isRecoiling = false;
|
|
174
|
+
if (Platform.OS === "ios") {
|
|
175
|
+
await waitAsync(delayActionSheetDrawTime);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
if (delayActionSheetDraw) {
|
|
179
|
+
await waitAsync(delayActionSheetDrawTime);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
this._scrollTo(scrollOffset, false);
|
|
183
|
+
this.prevScroll = scrollOffset;
|
|
184
|
+
if (Platform.OS === "ios") {
|
|
185
|
+
await waitAsync(delayActionSheetDrawTime !== null && delayActionSheetDrawTime !== void 0 ? delayActionSheetDrawTime : 0 / 2);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
if (delayActionSheetDraw) {
|
|
189
|
+
await waitAsync(delayActionSheetDrawTime !== null && delayActionSheetDrawTime !== void 0 ? delayActionSheetDrawTime : 0 / 2);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
this._openAnimation(scrollOffset);
|
|
193
|
+
this.underlayScale.setValue(1);
|
|
194
|
+
this.underlayTranslateY.setValue(100);
|
|
195
|
+
if (!gestureEnabled) {
|
|
196
|
+
(_b = (_a = this.props).onPositionChanged) === null || _b === void 0 ? void 0 : _b.call(_a, true);
|
|
197
|
+
}
|
|
198
|
+
this.updateActionSheetPosition(scrollOffset);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
this._openAnimation = (scrollOffset) => {
|
|
202
|
+
const { bounciness, bounceOnOpen, animated, openAnimationSpeed } = this.props;
|
|
203
|
+
if (animated) {
|
|
204
|
+
this.transformValue.setValue(scrollOffset);
|
|
205
|
+
Animated.parallel([
|
|
206
|
+
Animated.spring(this.transformValue, {
|
|
207
|
+
bounciness: bounceOnOpen ? bounciness : 1,
|
|
208
|
+
speed: openAnimationSpeed,
|
|
209
|
+
toValue: 0,
|
|
210
|
+
useNativeDriver: true,
|
|
211
|
+
}),
|
|
212
|
+
Animated.timing(this.opacityValue, {
|
|
213
|
+
duration: 150,
|
|
214
|
+
toValue: 1,
|
|
215
|
+
useNativeDriver: true,
|
|
216
|
+
}),
|
|
217
|
+
]).start();
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
this.opacityValue.setValue(1);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
this._onScrollBegin = async () => { };
|
|
224
|
+
this._onScrollBeginDrag = async (event) => {
|
|
225
|
+
this.prevScroll = event.nativeEvent.contentOffset.y;
|
|
226
|
+
};
|
|
227
|
+
this._onScrollEnd = async (event) => {
|
|
228
|
+
var _a, _b, _c;
|
|
229
|
+
const { springOffset, extraScroll } = this.props;
|
|
230
|
+
const verticalOffset = event.nativeEvent.contentOffset.y;
|
|
231
|
+
const correction = this.state.deviceHeight * 0.15;
|
|
232
|
+
if (this.isRecoiling)
|
|
233
|
+
return;
|
|
234
|
+
if (this.prevScroll < verticalOffset) {
|
|
235
|
+
if (verticalOffset - this.prevScroll > (springOffset !== null && springOffset !== void 0 ? springOffset : 0) * 0.75) {
|
|
236
|
+
this.isRecoiling = true;
|
|
237
|
+
this._applyHeightLimiter();
|
|
238
|
+
this.currentOffsetFromBottom =
|
|
239
|
+
this.currentOffsetFromBottom < ((_a = this.props.initialOffsetFromBottom) !== null && _a !== void 0 ? _a : 0)
|
|
240
|
+
? this.props.initialOffsetFromBottom
|
|
241
|
+
: 1;
|
|
242
|
+
const scrollOffset = this.actionSheetHeight * this.currentOffsetFromBottom + correction + (extraScroll !== null && extraScroll !== void 0 ? extraScroll : 0);
|
|
243
|
+
this._scrollTo(scrollOffset);
|
|
244
|
+
await waitAsync(300);
|
|
245
|
+
this.isRecoiling = false;
|
|
246
|
+
(_c = (_b = this.props).onPositionChanged) === null || _c === void 0 ? void 0 : _c.call(_b, true);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
this._returnToPrevScrollPosition(this.actionSheetHeight);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
if (this.prevScroll - verticalOffset > (springOffset !== null && springOffset !== void 0 ? springOffset : 0)) {
|
|
254
|
+
this._hideModal();
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
if (this.isRecoiling) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
this.isRecoiling = true;
|
|
261
|
+
this._returnToPrevScrollPosition(this.actionSheetHeight);
|
|
262
|
+
await waitAsync(300);
|
|
263
|
+
this.isRecoiling = false;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
this._scrollTo = (y, animated = true) => {
|
|
268
|
+
var _a;
|
|
269
|
+
this.scrollAnimationEndValue = y;
|
|
270
|
+
this.prevScroll = y;
|
|
271
|
+
(_a = this.scrollViewRef.current) === null || _a === void 0 ? void 0 : _a._listRef._scrollRef.scrollTo({
|
|
272
|
+
animated,
|
|
273
|
+
x: 0,
|
|
274
|
+
y: this.scrollAnimationEndValue,
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
this._onTouchMove = () => {
|
|
278
|
+
if (this.props.closeOnTouchBackdrop) {
|
|
279
|
+
this._hideModal();
|
|
280
|
+
}
|
|
281
|
+
this.setState({
|
|
282
|
+
scrollable: false,
|
|
283
|
+
});
|
|
284
|
+
};
|
|
285
|
+
this._onTouchStart = () => {
|
|
286
|
+
if (this.props.closeOnTouchBackdrop) {
|
|
287
|
+
this._hideModal();
|
|
288
|
+
}
|
|
289
|
+
this.setState({
|
|
290
|
+
scrollable: false,
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
this._onTouchEnd = () => {
|
|
294
|
+
this._returnToPrevScrollPosition(this.actionSheetHeight);
|
|
295
|
+
if (this.props.gestureEnabled) {
|
|
296
|
+
this.setState({
|
|
297
|
+
scrollable: true,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
this._onScroll = (event) => {
|
|
302
|
+
var _a, _b, _c, _d;
|
|
303
|
+
this.offsetY = event.nativeEvent.contentOffset.y;
|
|
304
|
+
const correction = this.state.deviceHeight * 0.15;
|
|
305
|
+
const distanceFromTop = this.actionSheetHeight + correction - this.offsetY;
|
|
306
|
+
if (this.actionSheetHeight < this.offsetY) {
|
|
307
|
+
if (!this.isReachedTop) {
|
|
308
|
+
this.isReachedTop = true;
|
|
309
|
+
(_b = (_a = this.props).onPositionChanged) === null || _b === void 0 ? void 0 : _b.call(_a, true);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
if (this.isReachedTop) {
|
|
314
|
+
this.isReachedTop = false;
|
|
315
|
+
(_d = (_c = this.props).onPositionChanged) === null || _d === void 0 ? void 0 : _d.call(_c, false);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (this.actionSheetHeight >= this.state.deviceHeight - 1) {
|
|
319
|
+
if (distanceFromTop < safeAreaPaddingTop) {
|
|
320
|
+
if (!this.props.drawUnderStatusBar)
|
|
321
|
+
return;
|
|
322
|
+
this.indicatorTranslateY.setValue(-this.state.paddingTop + (safeAreaPaddingTop - distanceFromTop));
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
this.indicatorTranslateY.setValue(-safeAreaPaddingTop);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
this._onRequestClose = () => {
|
|
330
|
+
if (this.props.closeOnPressBack)
|
|
331
|
+
this._hideModal();
|
|
332
|
+
};
|
|
333
|
+
this._onTouchBackdrop = () => {
|
|
334
|
+
if (this.props.closeOnTouchBackdrop) {
|
|
335
|
+
this._hideModal();
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
this._onKeyboardShow = (event) => {
|
|
339
|
+
this.setState({
|
|
340
|
+
keyboard: true,
|
|
341
|
+
});
|
|
342
|
+
const ReactNativeVersion = require("react-native/Libraries/Core/ReactNativeVersion");
|
|
343
|
+
let v = ReactNativeVersion.version.major + ReactNativeVersion.version.minor;
|
|
344
|
+
v = parseInt(v, 10);
|
|
345
|
+
if (v >= 63 || Platform.OS === "ios") {
|
|
346
|
+
const keyboardHeight = event.endCoordinates.height;
|
|
347
|
+
const { height: windowHeight } = Dimensions.get("window");
|
|
348
|
+
const currentlyFocusedField = TextInput.State.currentlyFocusedField
|
|
349
|
+
? findNodeHandle(TextInput.State.currentlyFocusedField())
|
|
350
|
+
: TextInput.State.currentlyFocusedField();
|
|
351
|
+
if (!currentlyFocusedField) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
UIManager.measure(currentlyFocusedField, (_originX, _originY, _width, height, _pageX, pageY) => {
|
|
355
|
+
const fieldHeight = height;
|
|
356
|
+
const gap = windowHeight - keyboardHeight - (pageY + fieldHeight);
|
|
357
|
+
if (gap >= 0) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
const toValue = this.props.keyboardMode === "position" ? -(keyboardHeight + 15) : gap - 10;
|
|
361
|
+
Animated.timing(this.transformValue, {
|
|
362
|
+
duration: 250,
|
|
363
|
+
toValue,
|
|
364
|
+
useNativeDriver: true,
|
|
365
|
+
}).start();
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
Animated.timing(this.transformValue, {
|
|
370
|
+
duration: 250,
|
|
371
|
+
toValue: -10,
|
|
372
|
+
useNativeDriver: true,
|
|
373
|
+
}).start();
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
/**
|
|
377
|
+
* Attach this to any child ScrollView Component's onScrollEndDrag,
|
|
378
|
+
* onMomentumScrollEnd,onScrollAnimationEnd callbacks to handle the ActionSheet
|
|
379
|
+
* closing and bouncing back properly.
|
|
380
|
+
*/
|
|
381
|
+
this.handleChildScrollEnd = async () => {
|
|
382
|
+
var _a, _b;
|
|
383
|
+
if (this.offsetY > this.prevScroll)
|
|
384
|
+
return;
|
|
385
|
+
if (this.prevScroll - ((_a = this.props.springOffset) !== null && _a !== void 0 ? _a : 0) > this.offsetY) {
|
|
386
|
+
const scrollOffset = this.getInitialScrollPosition();
|
|
387
|
+
if (this.offsetY > scrollOffset - 100) {
|
|
388
|
+
this.isRecoiling = true;
|
|
389
|
+
this._scrollTo(scrollOffset);
|
|
390
|
+
this.currentOffsetFromBottom = (_b = this.props.initialOffsetFromBottom) !== null && _b !== void 0 ? _b : 0;
|
|
391
|
+
this.prevScroll = scrollOffset;
|
|
392
|
+
setTimeout(() => {
|
|
393
|
+
this.isRecoiling = false;
|
|
394
|
+
}, 500);
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
this._hideModal();
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
this.isRecoiling = true;
|
|
402
|
+
this._scrollTo(this.prevScroll, true);
|
|
403
|
+
setTimeout(() => {
|
|
404
|
+
this.isRecoiling = false;
|
|
405
|
+
}, 500);
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
this._onKeyboardHide = () => {
|
|
409
|
+
this.setState({
|
|
410
|
+
keyboard: false,
|
|
411
|
+
});
|
|
412
|
+
this.opacityValue.setValue(1);
|
|
413
|
+
Animated.timing(this.transformValue, {
|
|
414
|
+
duration: 100,
|
|
415
|
+
toValue: 0,
|
|
416
|
+
useNativeDriver: true,
|
|
417
|
+
}).start();
|
|
418
|
+
};
|
|
419
|
+
this._onDeviceLayout = async (_event) => {
|
|
420
|
+
const event = Object.assign({}, _event);
|
|
421
|
+
if (this.timeout) {
|
|
422
|
+
clearTimeout(this.timeout);
|
|
423
|
+
}
|
|
424
|
+
this.timeout = setTimeout(async () => {
|
|
425
|
+
var _a;
|
|
426
|
+
let safeMarginFromTop = 0;
|
|
427
|
+
const measuredPadding = Platform.OS === "ios" ? await this.measure() : StatusBar.currentHeight;
|
|
428
|
+
if (!this.props.drawUnderStatusBar) {
|
|
429
|
+
if (Platform.OS === "android" && !this.props.statusBarTranslucent)
|
|
430
|
+
return;
|
|
431
|
+
safeMarginFromTop = measuredPadding !== null && measuredPadding !== void 0 ? measuredPadding : 0;
|
|
432
|
+
this.indicatorTranslateY.setValue(-measuredPadding);
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
this.updateActionSheetPosition(this.offsetY);
|
|
436
|
+
}
|
|
437
|
+
const height = event.nativeEvent.layout.height - safeMarginFromTop;
|
|
438
|
+
const width = Dimensions.get("window").width;
|
|
439
|
+
if ((height === null || height === void 0 ? void 0 : height.toFixed(0)) === (calculatedDeviceHeight === null || calculatedDeviceHeight === void 0 ? void 0 : calculatedDeviceHeight.toFixed(0)) &&
|
|
440
|
+
(width === null || width === void 0 ? void 0 : width.toFixed(0)) === ((_a = this.state.deviceWidth) === null || _a === void 0 ? void 0 : _a.toFixed(0)) &&
|
|
441
|
+
this.deviceLayoutCalled)
|
|
442
|
+
return;
|
|
443
|
+
this.deviceLayoutCalled = true;
|
|
444
|
+
calculatedDeviceHeight = height;
|
|
445
|
+
this.setState({
|
|
446
|
+
deviceHeight: height,
|
|
447
|
+
deviceWidth: width,
|
|
448
|
+
paddingTop: measuredPadding !== null && measuredPadding !== void 0 ? measuredPadding : 0,
|
|
449
|
+
portrait: height > width,
|
|
450
|
+
});
|
|
451
|
+
}, 1);
|
|
452
|
+
};
|
|
453
|
+
this._keyExtractor = (item) => item;
|
|
454
|
+
this.state = {
|
|
455
|
+
deviceHeight: calculatedDeviceHeight || getDeviceHeight(this.props.statusBarTranslucent),
|
|
456
|
+
deviceWidth: Dimensions.get("window").width,
|
|
457
|
+
keyboard: false,
|
|
458
|
+
layoutHasCalled: false,
|
|
459
|
+
modalVisible: false,
|
|
460
|
+
paddingTop: safeAreaPaddingTop,
|
|
461
|
+
portrait: true,
|
|
462
|
+
safeAreaInnerHeight,
|
|
463
|
+
scrollable: false,
|
|
464
|
+
};
|
|
465
|
+
this.actionSheetHeight = 0;
|
|
466
|
+
this.prevScroll = 0;
|
|
467
|
+
this.scrollAnimationEndValue = 0;
|
|
468
|
+
this.hasBounced = false;
|
|
469
|
+
this.scrollViewRef = createRef();
|
|
470
|
+
this.layoutHasCalled = false;
|
|
471
|
+
this.isClosing = false;
|
|
472
|
+
this.isRecoiling = false;
|
|
473
|
+
this.offsetY = 0;
|
|
474
|
+
this.safeAreaViewRef = createRef();
|
|
475
|
+
this.transformValue = new Animated.Value(0);
|
|
476
|
+
this.opacityValue = new Animated.Value(0);
|
|
477
|
+
this.borderRadius = new Animated.Value(10);
|
|
478
|
+
this.currentOffsetFromBottom = this.props.initialOffsetFromBottom;
|
|
479
|
+
this.underlayTranslateY = new Animated.Value(100);
|
|
480
|
+
this.underlayScale = new Animated.Value(1);
|
|
481
|
+
this.indicatorTranslateY = new Animated.Value(-this.state.paddingTop | 0);
|
|
482
|
+
this.isReachedTop = false;
|
|
483
|
+
this.deviceLayoutCalled = false;
|
|
484
|
+
this.timeout = null;
|
|
485
|
+
}
|
|
486
|
+
_hideAnimation() {
|
|
487
|
+
const { animated, closeAnimationDuration, bottomOffset, initialOffsetFromBottom, extraScroll, closable, } = this.props;
|
|
488
|
+
Animated.parallel([
|
|
489
|
+
Animated.timing(this.opacityValue, {
|
|
490
|
+
duration: animated ? closeAnimationDuration : 1,
|
|
491
|
+
toValue: closable ? 0 : 1,
|
|
492
|
+
useNativeDriver: true,
|
|
493
|
+
}),
|
|
494
|
+
Animated.timing(this.transformValue, {
|
|
495
|
+
duration: animated ? closeAnimationDuration : 1,
|
|
496
|
+
toValue: closable ? this.actionSheetHeight * 2 : 0,
|
|
497
|
+
useNativeDriver: true,
|
|
498
|
+
}),
|
|
499
|
+
]).start();
|
|
500
|
+
void waitAsync(closeAnimationDuration / 1.5).then(() => {
|
|
501
|
+
if (!closable) {
|
|
502
|
+
if (bottomOffset && bottomOffset > 0) {
|
|
503
|
+
this.snapToOffset(bottomOffset);
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
this._scrollTo((this.actionSheetHeight * (initialOffsetFromBottom || 0)) +
|
|
507
|
+
this.state.deviceHeight * 0.1 +
|
|
508
|
+
(extraScroll !== null && extraScroll !== void 0 ? extraScroll : 0), true);
|
|
509
|
+
this.currentOffsetFromBottom = initialOffsetFromBottom;
|
|
510
|
+
}
|
|
511
|
+
this.isClosing = false;
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
this._scrollTo(0, false);
|
|
515
|
+
this.currentOffsetFromBottom = initialOffsetFromBottom;
|
|
516
|
+
this.setState({
|
|
517
|
+
modalVisible: !closable,
|
|
518
|
+
}, () => {
|
|
519
|
+
var _a, _b, _c, _d;
|
|
520
|
+
this.isClosing = false;
|
|
521
|
+
this.isReachedTop = false;
|
|
522
|
+
(_b = (_a = this.props).onPositionChanged) === null || _b === void 0 ? void 0 : _b.call(_a, false);
|
|
523
|
+
this.indicatorTranslateY.setValue(-this.state.paddingTop);
|
|
524
|
+
this.layoutHasCalled = false;
|
|
525
|
+
this.deviceLayoutCalled = false;
|
|
526
|
+
(_d = (_c = this.props).onClose) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
_applyHeightLimiter() {
|
|
532
|
+
if (this.actionSheetHeight > this.state.deviceHeight) {
|
|
533
|
+
this.actionSheetHeight =
|
|
534
|
+
this.actionSheetHeight - (this.actionSheetHeight - this.state.deviceHeight);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
updateActionSheetPosition(scrollPosition) {
|
|
538
|
+
if (this.actionSheetHeight >= this.state.deviceHeight - 1) {
|
|
539
|
+
const correction = this.state.deviceHeight * 0.15;
|
|
540
|
+
const distanceFromTop = this.actionSheetHeight + correction - scrollPosition;
|
|
541
|
+
if (distanceFromTop < safeAreaPaddingTop) {
|
|
542
|
+
if (!this.props.drawUnderStatusBar)
|
|
543
|
+
return;
|
|
544
|
+
this.indicatorTranslateY.setValue(0);
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
this.indicatorTranslateY.setValue(-safeAreaPaddingTop);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
_returnToPrevScrollPosition(height) {
|
|
552
|
+
var _a;
|
|
553
|
+
const correction = this.state.deviceHeight * 0.15;
|
|
554
|
+
const scrollOffset = height * this.currentOffsetFromBottom + correction + ((_a = this.props.extraScroll) !== null && _a !== void 0 ? _a : 0);
|
|
555
|
+
this.updateActionSheetPosition(scrollOffset);
|
|
556
|
+
this._scrollTo(scrollOffset);
|
|
557
|
+
}
|
|
558
|
+
componentDidMount() {
|
|
559
|
+
this.keyboardDidShowListener = Keyboard.addListener(Platform.OS === "android" ? "keyboardDidShow" : "keyboardWillShow", this._onKeyboardShow);
|
|
560
|
+
this.keyboardDidHideListener = Keyboard.addListener(Platform.OS === "android" ? "keyboardDidHide" : "keyboardWillHide", this._onKeyboardHide);
|
|
561
|
+
}
|
|
562
|
+
componentWillUnmount() {
|
|
563
|
+
var _a, _b;
|
|
564
|
+
(_a = this.keyboardDidShowListener) === null || _a === void 0 ? void 0 : _a.remove();
|
|
565
|
+
(_b = this.keyboardDidHideListener) === null || _b === void 0 ? void 0 : _b.remove();
|
|
566
|
+
}
|
|
567
|
+
getInitialScrollPosition() {
|
|
568
|
+
var _a, _b, _c, _d;
|
|
569
|
+
this._applyHeightLimiter();
|
|
570
|
+
const correction = this.state.deviceHeight * 0.15;
|
|
571
|
+
const scrollPosition = this.props.gestureEnabled
|
|
572
|
+
? this.actionSheetHeight * ((_a = this.props.initialOffsetFromBottom) !== null && _a !== void 0 ? _a : 0) +
|
|
573
|
+
correction +
|
|
574
|
+
((_b = this.props.extraScroll) !== null && _b !== void 0 ? _b : 0)
|
|
575
|
+
: this.actionSheetHeight + correction + ((_c = this.props.extraScroll) !== null && _c !== void 0 ? _c : 0);
|
|
576
|
+
this.currentOffsetFromBottom = (_d = this.props.initialOffsetFromBottom) !== null && _d !== void 0 ? _d : 0;
|
|
577
|
+
this.updateActionSheetPosition(scrollPosition);
|
|
578
|
+
return scrollPosition;
|
|
579
|
+
}
|
|
580
|
+
render() {
|
|
581
|
+
const { scrollable, modalVisible, keyboard } = this.state;
|
|
582
|
+
const { onOpen, overlayColor, gestureEnabled, elevation, indicatorColor, defaultOverlayOpacity, children, containerStyle, CustomHeaderComponent, headerAlwaysVisible, keyboardShouldPersistTaps, statusBarTranslucent, } = this.props;
|
|
583
|
+
return (_jsx(Modal, { animationType: "none", onRequestClose: this._onRequestClose,
|
|
584
|
+
// testID={testID}
|
|
585
|
+
onShow: onOpen, statusBarTranslucent: statusBarTranslucent, supportedOrientations: SUPPORTED_ORIENTATIONS, transparent: true, visible: modalVisible, children: _jsxs(Animated.View, { onLayout: this._onDeviceLayout, style: [
|
|
586
|
+
styles.parentContainer,
|
|
587
|
+
{
|
|
588
|
+
opacity: this.opacityValue,
|
|
589
|
+
width: this.state.deviceWidth,
|
|
590
|
+
},
|
|
591
|
+
], children: [_jsx(SafeAreaView, { ref: this.safeAreaViewRef, style: styles.safearea, children: _jsx(View, {}) }), _jsx(FlatList, { bounces: false, contentContainerStyle: {
|
|
592
|
+
width: this.state.deviceWidth,
|
|
593
|
+
}, data: dummyData, keyboardShouldPersistTaps: keyboardShouldPersistTaps, keyExtractor: this._keyExtractor, onMomentumScrollBegin: this._onScrollBegin, onMomentumScrollEnd: this._onScrollEnd, onScroll: this._onScroll, onScrollBeginDrag: this._onScrollBeginDrag, onTouchEnd: this._onTouchEnd, ref: this.scrollViewRef, renderItem: () => (_jsxs(View, { style: {
|
|
594
|
+
width: "100%",
|
|
595
|
+
}, children: [_jsx(Animated.View, { onTouchEnd: this._onTouchBackdrop, onTouchMove: this._onTouchBackdrop, onTouchStart: this._onTouchBackdrop, style: {
|
|
596
|
+
backgroundColor: overlayColor,
|
|
597
|
+
height: "100%",
|
|
598
|
+
opacity: defaultOverlayOpacity,
|
|
599
|
+
position: "absolute",
|
|
600
|
+
width: "100%",
|
|
601
|
+
zIndex: 1,
|
|
602
|
+
} }), _jsx(View, { onTouchEnd: this._onTouchEnd, onTouchMove: this._onTouchMove, onTouchStart: this._onTouchStart, style: {
|
|
603
|
+
height: this.state.deviceHeight * 1.15,
|
|
604
|
+
width: "100%",
|
|
605
|
+
zIndex: 10,
|
|
606
|
+
}, children: _jsx(Pressable, { "aria-role": "button", onLongPress: this._onTouchBackdrop, onPress: this._onTouchBackdrop, style: {
|
|
607
|
+
height: this.state.deviceHeight * 1.15,
|
|
608
|
+
width: "100%",
|
|
609
|
+
} }) }), _jsx(Animated.View, { onLayout: this._showModal, style: [
|
|
610
|
+
styles.container,
|
|
611
|
+
{
|
|
612
|
+
borderRadius: 10,
|
|
613
|
+
},
|
|
614
|
+
containerStyle,
|
|
615
|
+
Object.assign(Object.assign({}, getElevation(elevation)), { maxHeight: this.state.deviceHeight, opacity: this.opacityValue, transform: [
|
|
616
|
+
{
|
|
617
|
+
translateY: this.transformValue,
|
|
618
|
+
},
|
|
619
|
+
], zIndex: 11 }),
|
|
620
|
+
], children: _jsxs(Animated.View, { style: {
|
|
621
|
+
marginTop: this.state.paddingTop,
|
|
622
|
+
maxHeight: this.state.deviceHeight,
|
|
623
|
+
transform: [
|
|
624
|
+
{
|
|
625
|
+
translateY: this.indicatorTranslateY,
|
|
626
|
+
},
|
|
627
|
+
],
|
|
628
|
+
}, children: [gestureEnabled || headerAlwaysVisible ? (CustomHeaderComponent ? (CustomHeaderComponent) : (_jsx(Animated.View, { style: [styles.indicator, { backgroundColor: indicatorColor }] }))) : null, children] }) })] })), scrollEnabled: scrollable && !keyboard, scrollEventThrottle: 5, scrollsToTop: false, showsVerticalScrollIndicator: false, style: [
|
|
629
|
+
styles.scrollView,
|
|
630
|
+
{
|
|
631
|
+
width: this.state.deviceWidth,
|
|
632
|
+
},
|
|
633
|
+
] })] }) }));
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
ActionSheet.defaultProps = defaultProps;
|
|
637
|
+
//# sourceMappingURL=ActionSheet.js.map
|